This is a block of data that receives the results of DCPacker. More...
#include "dcPackData.h"
Public Member Functions | |
void | append_data (const char *buffer, size_t size) |
Adds the indicated bytes to the end of the data. More... | |
void | append_junk (size_t size) |
Adds some uninitialized bytes to the end of the data. More... | |
void | clear () |
Empties the contents of the data (without necessarily freeing its allocated memory). More... | |
const char * | get_data () const |
Returns the beginning of the data buffer. More... | |
size_t | get_length () const |
Returns the current length of the buffer. More... | |
char * | get_rewrite_pointer (size_t position, size_t size) |
Returns a pointer into the middle of the data at the indicated point. More... | |
std::string | get_string () const |
Returns the data buffer as a string. More... | |
char * | get_write_pointer (size_t size) |
Adds the indicated number of bytes to the end of the data without initializing them, and returns a pointer to the beginning of the new data. More... | |
void | rewrite_data (size_t position, const char *buffer, size_t size) |
Changes the data at the indicated position to the given value. More... | |
char * | take_data () |
Returns the pointer to the beginning of the data buffer, and transfers ownership of the buffer to the caller. More... | |
This is a block of data that receives the results of DCPacker.
Definition at line 22 of file dcPackData.h.
|
inline |
Adds the indicated bytes to the end of the data.
Definition at line 47 of file dcPackData.I.
Referenced by DCField::pack_default_value().
|
inline |
Adds some uninitialized bytes to the end of the data.
Definition at line 66 of file dcPackData.I.
Referenced by DCPacker::push().
|
inline |
Empties the contents of the data (without necessarily freeing its allocated memory).
Definition at line 39 of file dcPackData.I.
Referenced by DCPacker::clear_data().
|
inline |
Returns the beginning of the data buffer.
The buffer is not null- terminated, but see also get_string(). This may (or may not) return NULL if the buffer is empty.
This may be used in conjunction with get_length() to copy all of the bytes out of the buffer.
Definition at line 115 of file dcPackData.I.
Referenced by DCPacker::get_bytes(), and DCPacker::get_data().
|
inline |
Returns the current length of the buffer.
This is the number of useful bytes stored in the buffer, not the amount of memory it takes up.
Definition at line 102 of file dcPackData.I.
Referenced by DCPacker::get_bytes(), DCPacker::get_length(), DCPacker::pop(), and DCPacker::push().
|
inline |
Returns a pointer into the middle of the data at the indicated point.
Definition at line 84 of file dcPackData.I.
Referenced by DCPacker::pop().
|
inline |
Returns the data buffer as a string.
Also see get_data().
Definition at line 93 of file dcPackData.I.
Referenced by DCPacker::get_string().
|
inline |
Adds the indicated number of bytes to the end of the data without initializing them, and returns a pointer to the beginning of the new data.
Definition at line 57 of file dcPackData.I.
|
inline |
Changes the data at the indicated position to the given value.
It is an error if there are not at least position + size bytes in the data.
Definition at line 75 of file dcPackData.I.
|
inline |
Returns the pointer to the beginning of the data buffer, and transfers ownership of the buffer to the caller.
The caller is now responsible for ultimately freeing the returned pointer with delete[], if it is non-NULL. This may (or may not) return NULL if the buffer is empty.
This also empties the DCPackData structure, and sets its length to zero (so you should call get_length() before calling this method).
Definition at line 129 of file dcPackData.I.
Referenced by DCPacker::take_data().