#include <yateclass.h>
Inheritance diagram for DataBlock:
Public Member Functions | |
DataBlock () | |
DataBlock (const DataBlock &value) | |
DataBlock (void *value, unsigned int len, bool copyData=true) | |
virtual | ~DataBlock () |
virtual void * | getObject (const String &name) const |
void * | data () const |
bool | null () const |
unsigned int | length () const |
void | clear (bool deleteData=true) |
DataBlock & | assign (void *value, unsigned int len, bool copyData=true) |
void | append (const DataBlock &value) |
void | append (const String &value) |
void | insert (const DataBlock &value) |
void | truncate (unsigned int len) |
void | cut (int len) |
DataBlock & | operator= (const DataBlock &value) |
DataBlock & | operator+= (const DataBlock &value) |
DataBlock & | operator+= (const String &value) |
bool | convert (const DataBlock &src, const String &sFormat, const String &dFormat, unsigned maxlen=0) |
Static Public Member Functions | |
static const DataBlock & | empty () |
The DataBlock holds a data buffer with no specific formatting.
DataBlock | ( | ) |
Constructs an empty data block
DataBlock | ( | void * | value, | |
unsigned int | len, | |||
bool | copyData = true | |||
) |
Constructs an initialized data block
value | Data to assign, may be NULL to fill with zeros | |
len | Length of data, may be zero (then value is ignored) | |
copyData | True to make a copy of the data, false to just insert the pointer |
virtual ~DataBlock | ( | ) | [virtual] |
Destroys the data, disposes the memory.
virtual void* getObject | ( | const String & | name | ) | const [virtual] |
Get a pointer to a derived class given that class name
name | Name of the class we are asking for |
Reimplemented from GenObject.
static const DataBlock& empty | ( | ) | [static] |
A static empty data block
void* data | ( | ) | const [inline] |
Get a pointer to the stored data.
bool null | ( | ) | const [inline] |
Checks if the block holds a NULL pointer.
unsigned int length | ( | ) | const [inline] |
Get the length of the stored data.
void clear | ( | bool | deleteData = true |
) |
Clear the data and optionally free the memory
deleteData | True to free the deta block, false to just forget it |
DataBlock& assign | ( | void * | value, | |
unsigned int | len, | |||
bool | copyData = true | |||
) |
Assign data to the object
value | Data to assign, may be NULL to fill with zeros | |
len | Length of data, may be zero (then value is ignored) | |
copyData | True to make a copy of the data, false to just insert the pointer |
void append | ( | const DataBlock & | value | ) |
Append data to the current block
value | Data to append |
void append | ( | const String & | value | ) |
void insert | ( | const DataBlock & | value | ) |
Insert data before the current block
value | Data to insert |
void truncate | ( | unsigned int | len | ) |
Truncate the data block
len | The maximum length to keep |
void cut | ( | int | len | ) |
Cut off a number of bytes from the data block
len | Amount to cut, positive to cut from end, negative to cut from start of block |
bool convert | ( | const DataBlock & | src, | |
const String & | sFormat, | |||
const String & | dFormat, | |||
unsigned | maxlen = 0 | |||
) |
Convert data from a different format
src | Source data block | |
sFormat | Name of the source format | |
dFormat | Name of the destination format | |
maxlen | Maximum amount to convert, 0 to use source |