Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

DataBlock Class Reference

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

#include <yateclass.h>

Inheritance diagram for DataBlock:

GenObject List of all members.

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)
DataBlockassign (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)
DataBlockoperator= (const DataBlock &value)
DataBlockoperator+= (const DataBlock &value)
DataBlockoperator+= (const String &value)
bool convert (const DataBlock &src, const String &sFormat, const String &dFormat, unsigned maxlen=0)

Static Public Member Functions

static const DataBlockempty ()

Detailed Description

A class that holds just a block of raw data.

The DataBlock holds a data buffer with no specific formatting.


Constructor & Destructor Documentation

DataBlock  ) 
 

Constructs an empty data block

DataBlock const DataBlock value  ) 
 

Copy constructor

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

Constructs an initialized data block

Parameters:
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.


Member Function Documentation

void append const String value  ) 
 

Append a String to the current block

Parameters:
value String to append

void append const DataBlock value  ) 
 

Append data to the current block

Parameters:
value Data to append

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

Assign data to the object

Parameters:
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 clear bool  deleteData = true  ) 
 

Clear the data and optionally free the memory

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

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

Convert data from a different format

Parameters:
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
Returns:
True if converted successfully, false on failure

void cut int  len  ) 
 

Cut off a number of bytes from the data block

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

void* data  )  const [inline]
 

Get a pointer to the stored data.

Returns:
A pointer to the data or NULL.

static const DataBlock& empty  )  [static]
 

A static empty data block

virtual void* getObject const String name  )  const [virtual]
 

Get a pointer to a derived class given that class name

Parameters:
name Name 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.

void insert const DataBlock value  ) 
 

Insert data before the current block

Parameters:
value Data to insert

unsigned int length  )  const [inline]
 

Get the length of the stored data.

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

bool null  )  const [inline]
 

Checks if the block holds a NULL pointer.

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

DataBlock& operator+= const String value  )  [inline]
 

Appending operator for Strings.

DataBlock& operator+= const DataBlock value  )  [inline]
 

Appending operator.

DataBlock& operator= const DataBlock value  ) 
 

Assignment operator.

void truncate unsigned int  len  ) 
 

Truncate the data block

Parameters:
len The maximum length to keep


The documentation for this class was generated from the following file:
Generated on Mon Sep 18 20:56:12 2006 for Yate by  doxygen 1.4.4