Honeycomb  0.1
Component-Model Framework
Public Types | Public Member Functions | List of all members
honey::Buffer< T > Class Template Reference

A contiguous region of referenced (not owned by object) memory. More...

#include <Buffer.h>

Public Types

typedef T value_type
 
typedef szt size_type
 
typedef sdt difference_type
 
typedef T & reference
 
typedef T * pointer
 
typedef T * iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 

Public Member Functions

 Buffer ()
 Construct empty buffer with null data and zero size. More...
 
 Buffer (T *data, szt size)
 Construct from memory reference and number of contiguous elements in region. More...
 
template<class U >
 Buffer (vector< U > &list)
 Construct from vector with compatible memory reference type. More...
 
template<class U >
 Buffer (const vector< U > &list)
 
template<class U , szt N>
 Buffer (array< U, N > &list)
 Construct from array with compatible memory reference type. More...
 
template<class U , szt N>
 Buffer (const array< U, N > &list)
 
 Buffer (const Buffer &rhs)
 
 Buffer (Buffer &&rhs)
 
Bufferoperator= (const Buffer &rhs)
 
Bufferoperator= (Buffer &&rhs)
 
T & at (szt pos) const
 Access element with bounds checking, throws std::out_of_range. More...
 
T & operator[] (szt pos) const
 Access element without bounds checking. More...
 
T & front () const
 Returns the first element without bounds checking. More...
 
T & back () const
 Returns the last element without bounds checking. More...
 
T * data () const
 Get the referenced memory. More...
 
Buffer slice (szt pos, optional< szt > size=optnull) const
 Get a view of this memory region in range [pos, pos+size) More...
 
T * begin () const
 Returns an iterator to the beginning. More...
 
T * end () const
 Returns an iterator to the end. More...
 
reverse_iterator rbegin () const
 Returns a reverse iterator to the beginning. More...
 
reverse_iterator rend () const
 Returns a reverse iterator to the end. More...
 
bool empty () const
 Checks whether the buffer does not have any elements. More...
 
 operator bool () const
 Checks whether the buffer has elements. More...
 
szt size () const
 Returns the number of elements. More...
 
bool operator== (const Buffer &rhs) const
 Check if buffers reference same memory region. More...
 
bool operator!= (const Buffer &rhs) const
 
void reset ()
 Set data to null with zero size. More...
 
void reset (T *data, szt size)
 Set new data and size. More...
 
 operator Buffer< const T > () const
 Implicitly convert to const buffer. More...
 

Detailed Description

template<class T>
class honey::Buffer< T >

A contiguous region of referenced (not owned by object) memory.

A buffer is a light wrapper around a pointer, as such the constness of a buffer object does not affect the mutability of its referenced memory. Also, for readability it is better to pass a buffer by value instead of by const reference (eg. declare Buffer<T> instead of const Buffer<T>&, similar to how one would declare T* instead of T* const&).

Member Typedef Documentation

template<class T>
typedef sdt honey::Buffer< T >::difference_type
template<class T>
typedef T* honey::Buffer< T >::iterator
template<class T>
typedef T* honey::Buffer< T >::pointer
template<class T>
typedef T& honey::Buffer< T >::reference
template<class T>
typedef std::reverse_iterator<iterator> honey::Buffer< T >::reverse_iterator
template<class T>
typedef szt honey::Buffer< T >::size_type
template<class T>
typedef T honey::Buffer< T >::value_type

Constructor & Destructor Documentation

template<class T>
honey::Buffer< T >::Buffer ( )
inline

Construct empty buffer with null data and zero size.

template<class T>
honey::Buffer< T >::Buffer ( T *  data,
szt  size 
)
inline

Construct from memory reference and number of contiguous elements in region.

template<class T>
template<class U >
honey::Buffer< T >::Buffer ( vector< U > &  list)
inline

Construct from vector with compatible memory reference type.

template<class T>
template<class U >
honey::Buffer< T >::Buffer ( const vector< U > &  list)
inline
template<class T>
template<class U , szt N>
honey::Buffer< T >::Buffer ( array< U, N > &  list)
inline

Construct from array with compatible memory reference type.

template<class T>
template<class U , szt N>
honey::Buffer< T >::Buffer ( const array< U, N > &  list)
inline
template<class T>
honey::Buffer< T >::Buffer ( const Buffer< T > &  rhs)
inline
template<class T>
honey::Buffer< T >::Buffer ( Buffer< T > &&  rhs)
inline

Member Function Documentation

template<class T>
T& honey::Buffer< T >::at ( szt  pos) const
inline

Access element with bounds checking, throws std::out_of_range.

template<class T>
T& honey::Buffer< T >::back ( ) const
inline

Returns the last element without bounds checking.

template<class T>
T* honey::Buffer< T >::begin ( ) const
inline

Returns an iterator to the beginning.

template<class T>
T* honey::Buffer< T >::data ( ) const
inline

Get the referenced memory.

template<class T>
bool honey::Buffer< T >::empty ( ) const
inline

Checks whether the buffer does not have any elements.

template<class T>
T* honey::Buffer< T >::end ( ) const
inline

Returns an iterator to the end.

template<class T>
T& honey::Buffer< T >::front ( ) const
inline

Returns the first element without bounds checking.

template<class T>
honey::Buffer< T >::operator bool ( ) const
inlineexplicit

Checks whether the buffer has elements.

template<class T>
honey::Buffer< T >::operator Buffer< const T > ( ) const
inline

Implicitly convert to const buffer.

template<class T>
bool honey::Buffer< T >::operator!= ( const Buffer< T > &  rhs) const
inline
template<class T>
Buffer& honey::Buffer< T >::operator= ( const Buffer< T > &  rhs)
inline
template<class T>
Buffer& honey::Buffer< T >::operator= ( Buffer< T > &&  rhs)
inline
template<class T>
bool honey::Buffer< T >::operator== ( const Buffer< T > &  rhs) const
inline

Check if buffers reference same memory region.

template<class T>
T& honey::Buffer< T >::operator[] ( szt  pos) const
inline

Access element without bounds checking.

template<class T>
reverse_iterator honey::Buffer< T >::rbegin ( ) const
inline

Returns a reverse iterator to the beginning.

template<class T>
reverse_iterator honey::Buffer< T >::rend ( ) const
inline

Returns a reverse iterator to the end.

template<class T>
void honey::Buffer< T >::reset ( )
inline

Set data to null with zero size.

template<class T>
void honey::Buffer< T >::reset ( T *  data,
szt  size 
)
inline

Set new data and size.

template<class T>
szt honey::Buffer< T >::size ( ) const
inline

Returns the number of elements.

template<class T>
Buffer honey::Buffer< T >::slice ( szt  pos,
optional< szt size = optnull 
) const
inline

Get a view of this memory region in range [pos, pos+size)

The view will be clipped against the bounds of this region, possibly resulting in an empty view.


The documentation for this class was generated from the following file: