![]() |
Gamedev Framework (gf)
0.16.0
A C++14 framework for 2D games
|
A reference to a modifiable buffer and its size. More...
#include <gf/BufferRef.h>
Public Member Functions | |
constexpr | BufferRef () |
Default constructor. More... | |
constexpr | BufferRef (std::nullptr_t) |
Null constructor. More... | |
constexpr | BufferRef (T *data, std::size_t size) |
Constructor from a pointer and a size. More... | |
BufferRef (std::vector< T > &values) | |
Constructor from a std::vector More... | |
template<std::size_t N> | |
BufferRef (std::array< T, N > &values) | |
Constructor from a std::array More... | |
template<std::size_t N> | |
constexpr | BufferRef (T(&data)[N]) |
Constructor from a static array. More... | |
T * | getData () noexcept |
Get a pointer to the elements. More... | |
constexpr std::size_t | getSize () const noexcept |
Get the number of elements. More... | |
constexpr bool | isEmpty () const noexcept |
Check if the buffer is empty. More... | |
constexpr BufferRef< T > | sub (std::size_t index) |
Create a buffer starting at a specified index. More... | |
T * | begin () noexcept |
Get an iterator to the first element. More... | |
T * | end () noexcept |
Get an iterator past the last element. More... | |
T & | operator[] (std::size_t index) |
Get an element at a given index. More... | |
A reference to a modifiable buffer and its size.
This class stores a pointer to a buffer and its size. It can be built from various inputs: std::vector
, std::array
, static array, pointer and size.
|
inline |
Default constructor.
Data is nullptr
and size is 0.
|
inline |
Null constructor.
Data is nullptr
and size is 0.
|
inline |
Constructor from a pointer and a size.
data | A pointer to a buffer |
size | The number of elements in the buffer |
|
inline |
Constructor from a std::vector
values | The vector of elements |
|
inline |
Constructor from a std::array
values | The array of elements |
|
inline |
Constructor from a static array.
The size is computed at compile-time.
data | The static array |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Get a pointer to the elements.
|
inlinenoexcept |
Get the number of elements.
|
inlinenoexcept |
Check if the buffer is empty.
|
inline |
Get an element at a given index.
No verification is done on the index.
index | The index of the element |
|
inline |
Create a buffer starting at a specified index.
index | The starting index of the new buffer |