OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
osvr::common::Buffer< ContainerType > Singleton Reference

A buffer of bytes, built on a byte-vector-like container. Provides methods for easily appending to the buffer (including alignment padding), and a nested class for reading from such a buffer. More...

#include <osvr/Common/Buffer.h>

Public Types

typedef ContainerType::value_type ElementType
 The (necessarily byte-size) type of elements in the underlying container.
 
typedef BufferReader
< ContainerType > 
Reader
 The corresponding BufferReader type.
 

Public Member Functions

 Buffer ()
 Constructs an empty buffer.
 
 Buffer (ContainerType const &buf)
 Constructs a buffer wrapper by copy-constructing the contained type.
 
template<typename InputIterator >
 Buffer (InputIterator beginIt, InputIterator endIt)
 Constructs a buffer by copying from two input iterators, representing a half-open range [beginIt, endIt) More...
 
template<typename T >
void append (T const v)
 Append the binary representation of a value. More...
 
template<typename T >
void appendAligned (T const v, size_t const alignment)
 Append the binary representation of a value, after adding the necessary number of padding bytes to begin the write at the given alignment within the buffer. More...
 
void append (ElementType const *v, size_t const n)
 Append a byte-array's contents.
 
void appendAligned (ElementType const *v, size_t const n, size_t const alignment)
 Append a byte-array's contents, after adding the necessary number of padding bytes to begin the write at the given alignment within the buffer.
 
void appendPadding (size_t const bytes)
 Append the specified number of bytes of padding.
 
Reader startReading () const
 Returns a reader object, for making a single read pass over the buffer. Do not modify this buffer during the lifetime of a reader!
 
size_t size () const
 Gets the current size, in bytes.
 
ContainerType & getContents ()
 Provides access to the underlying container.
 
ElementType const * data () const
 Provides access to the underlying data.
 

Detailed Description

template<typename ContainerType = BufferByteVector>
singleton osvr::common::Buffer< ContainerType >

A buffer of bytes, built on a byte-vector-like container. Provides methods for easily appending to the buffer (including alignment padding), and a nested class for reading from such a buffer.

Definition at line 206 of file Buffer.h.

Constructor & Destructor Documentation

template<typename ContainerType = BufferByteVector>
template<typename InputIterator >
osvr::common::Buffer< ContainerType >::Buffer ( InputIterator  beginIt,
InputIterator  endIt 
)
inline

Constructs a buffer by copying from two input iterators, representing a half-open range [beginIt, endIt)

Passed directly to contained type, so semantics are identical.

Definition at line 228 of file Buffer.h.

Member Function Documentation

template<typename ContainerType = BufferByteVector>
template<typename T >
void osvr::common::Buffer< ContainerType >::append ( T const  v)
inline

Append the binary representation of a value.

The value cannot be a pointer here.

Safe to do without violating strict aliasing because ElementType is a character type.

Definition at line 234 of file Buffer.h.

template<typename ContainerType = BufferByteVector>
template<typename T >
void osvr::common::Buffer< ContainerType >::appendAligned ( T const  v,
size_t const  alignment 
)
inline

Append the binary representation of a value, after adding the necessary number of padding bytes to begin the write at the given alignment within the buffer.

The value cannot be a pointer here.

Definition at line 249 of file Buffer.h.


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