ug4
|
A special version of a std::streambuf, writes data directly into a buffer that is accessible at any time. More...
#include <binary_stream.h>
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 |
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.
ug::BinaryStreamBuffer::BinaryStreamBuffer | ( | ) |
|
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().
|
inline |
References ug::GetDataPtr(), and m_dataBuf.
void ug::BinaryStreamBuffer::clear | ( | ) |
clears the data and resets the read and write positions.
References resize().
Referenced by ug::BinaryStream::clear().
|
inlineprotected |
|
inlineprotected |
size_t ug::BinaryStreamBuffer::get_read_pos | ( | ) | const |
returns the read-position
Referenced by ug::BinaryStream::can_read_more(), and ug::BinaryStream::read_pos().
|
virtual |
void ug::BinaryStreamBuffer::read_jump | ( | size_t | jumpSize | ) |
advances the read-pointer by jumpSize bytes
Referenced by ug::BinaryStream::read_jump().
void ug::BinaryStreamBuffer::reserve | ( | size_t | newSize | ) |
Similar to resize, however, doesn't alter the read-area.
void ug::BinaryStreamBuffer::reset | ( | ) |
set read- and write-positions to the start of the buffer.
Referenced by ug::BinaryStream::reset().
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_t ug::BinaryStreamBuffer::size | ( | ) | const |
returns the size of the buffer in bytes.
Referenced by ug::BinaryStream::size().
|
virtual |
void ug::BinaryStreamBuffer::write_jump | ( | size_t | jumpSize | ) |
advances the write-pointer by jumpSize bytes
Referenced by ug::BinaryStream::write_jump().
|
protected |