class DataBlock

A class that holds just a block of raw data. More...

Full nameTelEngine::DataBlock
Definition#include <yateclass.h>
InheritsTelEngine::GenObject [public ]
Inherited byBase64
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods


Detailed Description

The DataBlock holds a data buffer with no specific formatting.

 DataBlock ()

DataBlock

Constructs an empty data block

 DataBlock (const DataBlock& value)

DataBlock

Copy constructor

 DataBlock (void* value, unsigned int len, bool copyData = true)

DataBlock

Constructs an initialized data block

Parameters:
valueData to assign, may be NULL to fill with zeros
lenLength of data, may be zero (then value is ignored)
copyDataTrue to make a copy of the data, false to just insert the pointer

 ~DataBlock ()

~DataBlock

[virtual]

Destroys the data, disposes the memory.

void*  getObject (const String& name)

getObject

[const virtual]

Get a pointer to a derived class given that class name

Parameters:
nameName of the class we are asking for

Returns: Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from GenObject.

const DataBlock&  empty ()

empty

[static]

A static empty data block

inline void*  data ()

data

[const]

Get a pointer to the stored data.

Returns: A pointer to the data or NULL.

inline unsigned char*  data (unsigned int offs, unsigned int len = 1)

data

[const]

Get a pointer to a byte range inside the stored data.

Parameters:
offsByte offset inside the stored data
lenNumber of bytes that must be valid starting at offset

Returns: A pointer to the data or NULL if the range is not available.

inline int  at (unsigned int offs, int defvalue = -1)

at

[const]

Get the value of a single byte inside the stored data

Parameters:
offsByte offset inside the stored data
defvalueDefault value to return if offset is outside data

Returns: Byte value at offset (0-255) or defvalue if offset outside data

inline bool  null ()

null

[const]

Checks if the block holds a NULL pointer.

Returns: True if the block holds NULL, false otherwise.

inline unsigned int  length ()

length

[const]

Get the length of the stored data.

Returns: The length of the stored data, zero for NULL.

void  clear (bool deleteData = true)

clear

Clear the data and optionally free the memory

Parameters:
deleteDataTrue to free the deta block, false to just forget it

DataBlock&  assign (void* value, unsigned int len, bool copyData = true)

assign

Assign data to the object

Parameters:
valueData to assign, may be NULL to fill with zeros
lenLength of data, may be zero (then value is ignored)
copyDataTrue to make a copy of the data, false to just insert the pointer

inline void  append (void* value, unsigned int len)

append

Append data to the current block

Parameters:
valueData to append
lenLength of data

void  append (const DataBlock& value)

append

Append data to the current block

Parameters:
valueData to append

void  append (const String& value)

append

Append a String to the current block

Parameters:
valueString to append

void  insert (const DataBlock& value)

insert

Insert data before the current block

Parameters:
valueData to insert

inline void  resize (unsigned int len)

resize

Resize (re-alloc or free) this block if required size is not the same as the current one

Parameters:
lenRequired block size

void  truncate (unsigned int len)

truncate

Truncate the data block

Parameters:
lenThe maximum length to keep

void  cut (int len)

cut

Cut off a number of bytes from the data block

Parameters:
lenAmount to cut, positive to cut from end, negative to cut from start of block

inline int  operator[] (signed int index)

operator[]

[const]

Byte indexing operator with signed parameter

Parameters:
indexIndex of the byte to retrieve

Returns: Byte value at offset (0-255) or -1 if index outside data

inline int  operator[] (unsigned int index)

operator[]

[const]

Byte indexing operator with unsigned parameter

Parameters:
indexIndex of the byte to retrieve

Returns: Byte value at offset (0-255) or -1 if index outside data

DataBlock&  operator= (const DataBlock& value)

operator=

Assignment operator.

inline DataBlock&  operator+= (const DataBlock& value)

operator+=

Appending operator.

inline DataBlock&  operator+= (const String& value)

operator+=

Appending operator for Strings.

bool  convert (const DataBlock& src, const String& sFormat, const String& dFormat, unsigned maxlen = 0)

convert

Convert data from a different format

Parameters:
srcSource data block
sFormatName of the source format
dFormatName of the destination format
maxlenMaximum amount to convert, 0 to use source

Returns: True if converted successfully, false on failure

bool  unHexify (const char* data, unsigned int len, char sep = 0)

unHexify

Build this data block from a hexadecimal string representation. Each octet must be represented in the input string with 2 hexadecimal characters. If a separator is specified, the octets in input string must be separated using exactly 1 separator. Only 1 leading or 1 trailing separators are allowed

Parameters:
dataInput character string
lenLength of the input string
sepSeparator character used between octets. 0 if no separator is expected

Returns: True if the input string was succesfully parsed, false otherwise

String  sqlEscape (char extraEsc)

sqlEscape

[const]

Create an escaped string suitable for use in SQL queries

Parameters:
extraEscCharacter to escape other than the default ones

Returns: A string with binary zeros and other special characters escaped


Generated by: paulc on bussard on Fri Dec 21 16:28:34 2012, using kdoc 2.0a54.