A simple buffer that can expand when data is added (like std::vector), but that can also return a pointer to the underlying data (like std::valarray). More...
#include <dashel-private.h>
Public Member Functions | |
void | add (const void *data, const size_t size) |
Append data to the buffer. | |
void | clear () |
Remove all data from the buffer, the allocated memory is not freed to speed-up further reduce. | |
ExpandableBuffer (size_t size=0) | |
Construct an expandable buffer of specific size. | |
unsigned char * | get () |
Return a pointer to the underlying data. | |
size_t | reservedSize () const |
Return the amount of allocated memory, always >= size(), to reduce the amount of reallocation required. | |
size_t | size () const |
Return the actual amount of data stored. | |
~ExpandableBuffer () | |
Destroy the buffer and frees the allocated memory. | |
Private Attributes | |
unsigned char * | _data |
data buffer. Its size is increased when required. | |
size_t | _pos |
size of used part of data | |
size_t | _size |
allocated size of data |
A simple buffer that can expand when data is added (like std::vector), but that can also return a pointer to the underlying data (like std::valarray).
Definition at line 54 of file dashel-private.h.
Dashel::ExpandableBuffer::ExpandableBuffer | ( | size_t | size = 0 | ) |
Construct an expandable buffer of specific size.
Definition at line 64 of file dashel-common.cpp.
Destroy the buffer and frees the allocated memory.
Definition at line 71 of file dashel-common.cpp.
void Dashel::ExpandableBuffer::add | ( | const void * | data, |
const size_t | size | ||
) |
Append data to the buffer.
Definition at line 81 of file dashel-common.cpp.
void Dashel::ExpandableBuffer::clear | ( | ) |
Remove all data from the buffer, the allocated memory is not freed to speed-up further reduce.
Definition at line 76 of file dashel-common.cpp.
unsigned char* Dashel::ExpandableBuffer::get | ( | ) | [inline] |
Return a pointer to the underlying data.
Definition at line 72 of file dashel-private.h.
size_t Dashel::ExpandableBuffer::reservedSize | ( | ) | const [inline] |
Return the amount of allocated memory, always >= size(), to reduce the amount of reallocation required.
Definition at line 76 of file dashel-private.h.
size_t Dashel::ExpandableBuffer::size | ( | ) | const [inline] |
Return the actual amount of data stored.
Definition at line 74 of file dashel-private.h.
unsigned char* Dashel::ExpandableBuffer::_data [private] |
data buffer. Its size is increased when required.
Definition at line 57 of file dashel-private.h.
size_t Dashel::ExpandableBuffer::_pos [private] |
size of used part of data
Definition at line 59 of file dashel-private.h.
size_t Dashel::ExpandableBuffer::_size [private] |
allocated size of data
Definition at line 58 of file dashel-private.h.