Gamedev Framework (gf)  0.4.0
A C++11 framework for 2D games
Public Member Functions | List of all members
gf::BufferRef< T > Class Template Reference

A reference to a modifiable buffer and its size. More...

#include <gf/BufferRef.h>

Public Member Functions

constexpr BufferRef ()
 Default 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...
 
TgetData () noexcept
 Get a pointer to the elements. More...
 
constexpr std::size_t getSize () const noexcept
 Get the number of elements. More...
 
Tbegin () noexcept
 Get an iterator to the first element. More...
 
Tend () noexcept
 Get an iterator past the last element. More...
 

Detailed Description

template<typename T>
class gf::BufferRef< T >

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.

See also
gf::ArrayRef, gf::StringRef

Constructor & Destructor Documentation

template<typename T >
constexpr gf::BufferRef< T >::BufferRef ( )
inline

Default constructor.

Data is nullptr and size is 0.

template<typename T >
constexpr gf::BufferRef< T >::BufferRef ( T data,
std::size_t  size 
)
inline

Constructor from a pointer and a size.

Parameters
dataA pointer to a buffer
sizeThe number of elements in the buffer
template<typename T >
gf::BufferRef< T >::BufferRef ( std::vector< T > &  values)
inline

Constructor from a std::vector

Parameters
valuesThe vector of elements
template<typename T >
template<std::size_t N>
gf::BufferRef< T >::BufferRef ( std::array< T, N > &  values)
inline

Constructor from a std::array

Parameters
valuesThe array of elements
template<typename T >
template<std::size_t N>
constexpr gf::BufferRef< T >::BufferRef ( T(&)  data[N])
inline

Constructor from a static array.

The size is computed at compile-time.

Parameters
dataThe static array

Member Function Documentation

template<typename T >
T* gf::BufferRef< T >::begin ( )
inlinenoexcept

Get an iterator to the first element.

Returns
A pointer to the first element
See also
end()
template<typename T >
T* gf::BufferRef< T >::end ( )
inlinenoexcept

Get an iterator past the last element.

Returns
A pointer past the last element
See also
begin()
template<typename T >
T* gf::BufferRef< T >::getData ( )
inlinenoexcept

Get a pointer to the elements.

Returns
A pointer to the first element in the array
template<typename T >
constexpr std::size_t gf::BufferRef< T >::getSize ( ) const
inlinenoexcept

Get the number of elements.

Returns
The number of elements in the array