ug4
ug::BinaryStreamBuffer Class Reference

A special version of a std::streambuf, writes data directly into a buffer that is accessible at any time. More...

#include <binary_stream.h>

+ Inheritance diagram for ug::BinaryStreamBuffer:

Public Member Functions

 BinaryStreamBuffer ()
 
char_type * buffer ()
 returns a pointer to the front of the buffer or NULL if the buffer is empty. More...
 
const char_type * buffer () const
 
void clear ()
 clears the data and resets the read and write positions. More...
 
size_t get_read_pos () const
 returns the read-position More...
 
virtual int_type overflow (int_type c=traits_type::eof())
 
void read_jump (size_t jumpSize)
 advances the read-pointer by jumpSize bytes More...
 
void reserve (size_t newSize)
 Similar to resize, however, doesn't alter the read-area. More...
 
void reset ()
 set read- and write-positions to the start of the buffer. More...
 
void resize (size_t newSize)
 resizes the data-buffer but does not alter read and write positions. More...
 
size_t size () const
 returns the size of the buffer in bytes. More...
 
virtual int_type underflow ()
 
void write_jump (size_t jumpSize)
 advances the write-pointer by jumpSize bytes More...
 

Protected Member Functions

char_type * end ()
 returns pointer to the first entry behind the buffer. More...
 
const char_type * end () const
 

Protected Attributes

std::vector< unsigned char > m_dataBuf
 

Detailed Description

A special version of a std::streambuf, writes data directly into a buffer that is accessible at any time.

This buffer stores the data directly in a growing array. You may receive a pointer to that array using get_buffer(). The size of the buffer is returned by get_buffer_size().

Note that the pointer returned from get_buffer may be invalidated after new insertions into the buffer. Using resize() you may reserve a buffer-section. Input- and output-positions won't be affected by a resize.

Constructor & Destructor Documentation

◆ BinaryStreamBuffer()

ug::BinaryStreamBuffer::BinaryStreamBuffer ( )

Member Function Documentation

◆ buffer() [1/2]

char_type* ug::BinaryStreamBuffer::buffer ( )
inline

returns a pointer to the front of the buffer or NULL if the buffer is empty.

References ug::GetDataPtr(), and m_dataBuf.

Referenced by ug::BinaryStream::buffer(), and end().

◆ buffer() [2/2]

const char_type* ug::BinaryStreamBuffer::buffer ( ) const
inline

References ug::GetDataPtr(), and m_dataBuf.

◆ clear()

void ug::BinaryStreamBuffer::clear ( )

clears the data and resets the read and write positions.

References resize().

Referenced by ug::BinaryStream::clear().

◆ end() [1/2]

char_type* ug::BinaryStreamBuffer::end ( )
inlineprotected

returns pointer to the first entry behind the buffer.

References buffer(), and m_dataBuf.

◆ end() [2/2]

const char_type* ug::BinaryStreamBuffer::end ( ) const
inlineprotected

References buffer(), and m_dataBuf.

◆ get_read_pos()

size_t ug::BinaryStreamBuffer::get_read_pos ( ) const

returns the read-position

Referenced by ug::BinaryStream::can_read_more(), and ug::BinaryStream::read_pos().

◆ overflow()

BinaryStreamBuffer::int_type ug::BinaryStreamBuffer::overflow ( int_type  c = traits_type::eof())
virtual

◆ read_jump()

void ug::BinaryStreamBuffer::read_jump ( size_t  jumpSize)

advances the read-pointer by jumpSize bytes

Referenced by ug::BinaryStream::read_jump().

◆ reserve()

void ug::BinaryStreamBuffer::reserve ( size_t  newSize)

Similar to resize, however, doesn't alter the read-area.

◆ reset()

void ug::BinaryStreamBuffer::reset ( )

set read- and write-positions to the start of the buffer.

Referenced by ug::BinaryStream::reset().

◆ resize()

void ug::BinaryStreamBuffer::resize ( size_t  newSize)

resizes the data-buffer but does not alter read and write positions.

A resize extends the readable area.

Referenced by ug::BinaryStream::resize().

◆ size()

size_t ug::BinaryStreamBuffer::size ( ) const

returns the size of the buffer in bytes.

Referenced by ug::BinaryStream::size().

◆ underflow()

BinaryStreamBuffer::int_type ug::BinaryStreamBuffer::underflow ( )
virtual

◆ write_jump()

void ug::BinaryStreamBuffer::write_jump ( size_t  jumpSize)

advances the write-pointer by jumpSize bytes

Referenced by ug::BinaryStream::write_jump().

Member Data Documentation

◆ m_dataBuf

std::vector<unsigned char> ug::BinaryStreamBuffer::m_dataBuf
protected

Referenced by buffer(), and end().


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