OSVR-Core
Public Types | Public Member Functions | List of all members
osvr::common::BufferReader< ContainerType > Class Template Reference

Provides for a single reading pass over a buffer. More...

#include <Buffer.h>

Public Types

typedef ContainerType::const_iterator const_iterator
 
typedef ContainerType::value_type ElementType
 

Public Member Functions

 BufferReader (ContainerType const &buf)
 
size_t bytesRead () const
 
size_t bytesRemaining () const
 
template<typename T >
void read (T &v)
 Get the binary representation of a type from a buffer. More...
 
const_iterator readBytes (size_t const n)
 Returns an iterator into the buffer valid for n elements, and assumes you'll take care of copying them. More...
 
template<typename T >
void readAligned (T &v, size_t const alignment)
 Get the binary representation of a type from a buffer, after skipping the necessary number of bytes to begin the read at the given alignment. More...
 
const_iterator readBytesAligned (size_t const n, size_t const alignment)
 Returns an iterator into the buffer valid for n elements, after skipping the necessary number of bytes to begin the read at the given alignment, and assumes you'll take care of copying them. More...
 
void skipPadding (size_t const bytes)
 Skip reading the given number of bytes, assumed to be padding. More...
 

Detailed Description

template<typename ContainerType>
class osvr::common::BufferReader< ContainerType >

Provides for a single reading pass over a buffer.

It is important that the buffer not change while a Reader obtained from it is still in scope.

Get one by calling Buffer::startReading()

Member Function Documentation

§ read()

template<typename ContainerType>
template<typename T >
void osvr::common::BufferReader< ContainerType >::read ( T v)
inline

Get the binary representation of a type from a buffer.

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

§ readAligned()

template<typename ContainerType>
template<typename T >
void osvr::common::BufferReader< ContainerType >::readAligned ( T v,
size_t const  alignment 
)
inline

Get the binary representation of a type from a buffer, after skipping the necessary number of bytes to begin the read at the given alignment.

§ readBytes()

template<typename ContainerType>
const_iterator osvr::common::BufferReader< ContainerType >::readBytes ( size_t const  n)
inline

Returns an iterator into the buffer valid for n elements, and assumes you'll take care of copying them.

§ readBytesAligned()

template<typename ContainerType>
const_iterator osvr::common::BufferReader< ContainerType >::readBytesAligned ( size_t const  n,
size_t const  alignment 
)
inline

Returns an iterator into the buffer valid for n elements, after skipping the necessary number of bytes to begin the read at the given alignment, and assumes you'll take care of copying them.

§ skipPadding()

template<typename ContainerType>
void osvr::common::BufferReader< ContainerType >::skipPadding ( size_t const  bytes)
inline

Skip reading the given number of bytes, assumed to be padding.


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