|
Yate
|
A class that holds just a block of raw data. More...
#include <yateclass.h>
Public Member Functions | |
| DataBlock (unsigned int overAlloc=0) | |
| DataBlock (const DataBlock &value) | |
| DataBlock (const DataBlock &value, unsigned int overAlloc) | |
| DataBlock (void *value, unsigned int len, bool copyData=true, unsigned int overAlloc=0) | |
| virtual | ~DataBlock () |
| virtual void * | getObject (const String &name) const |
| void * | data () const |
| unsigned char * | data (unsigned int offs, unsigned int len=1) const |
| int | at (unsigned int offs, int defvalue=-1) const |
| bool | null () const |
| unsigned int | length () const |
| unsigned int | overAlloc () const |
| void | overAlloc (unsigned int bytes) |
| void | clear (bool deleteData=true) |
| DataBlock & | assign (void *value, unsigned int len, bool copyData=true, unsigned int allocated=0) |
| void | append (void *value, unsigned int len) |
| void | append (const DataBlock &value) |
| void | append (const String &value) |
| void | insert (const DataBlock &value) |
| void | resize (unsigned int len) |
| void | truncate (unsigned int len) |
| void | cut (int len) |
| int | operator[] (signed int index) const |
| int | operator[] (unsigned int index) const |
| 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) |
| bool | unHexify (const char *data, unsigned int len, char sep) |
| bool | unHexify (const char *data, unsigned int len) |
| bool | unHexify (const String &data) |
| String | sqlEscape (char extraEsc) const |
Public Member Functions inherited from GenObject | |
| GenObject () | |
| virtual | ~GenObject () |
| virtual bool | alive () const |
| virtual void | destruct () |
| virtual const String & | toString () const |
| virtual const String & | traceId () const |
| NamedCounter * | getObjCounter () const |
| NamedCounter * | setObjCounter (NamedCounter *counter) |
Static Public Member Functions | |
| static const DataBlock & | empty () |
Static Public Member Functions inherited from GenObject | |
| static void * | getObject (const String &name, const GenObject *obj) |
| static bool | getObjCounting () |
| static void | setObjCounting (bool enable) |
| static NamedCounter * | getObjCounter (const String &name, bool create=true) |
| static ObjList & | getObjCounters () |
A class that holds just a block of raw data.
The DataBlock holds a data buffer with no specific formatting.
| DataBlock | ( | unsigned int | overAlloc = 0 | ) |
Constructs an empty data block
| overAlloc | How many bytes of memory to overallocate |
References overAlloc().
Referenced by append(), append(), assign(), Base64::Base64(), convert(), DataBlock(), DataBlock(), Base64::decode(), empty(), OctetString::fromHexString(), insert(), operator+=(), operator+=(), Base64::operator<<(), operator=(), SS7MSU::operator=(), SS7MSU::SS7MSU(), SS7MSU::SS7MSU(), and SS7MSU::SS7MSU().
Copy constructor with overallocation
| value | Data block to copy from |
| overAlloc | How many bytes of memory to overallocate |
References DataBlock(), and overAlloc().
| DataBlock | ( | void * | value, |
| unsigned int | len, | ||
| bool | copyData = true, | ||
| unsigned int | overAlloc = 0 ) |
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 |
| overAlloc | How many bytes of memory to overallocate |
References overAlloc().
|
virtual |
Destroys the data, disposes the memory.
| void append | ( | const DataBlock & | value | ) |
| void append | ( | const String & | value | ) |
|
inline |
Append data to the current block
| value | Data to append |
| len | Length of data |
References append(), clear(), and DataBlock().
Referenced by append(), IAXFrame::buildMiniFrame(), operator+=(), operator+=(), Base64::operator<<(), and Base64::operator<<().
| DataBlock & assign | ( | void * | value, |
| unsigned int | len, | ||
| bool | copyData = true, | ||
| unsigned int | allocated = 0 ) |
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 |
| allocated | Real allocated data length in case it should not be copied |
References DataBlock().
Referenced by IAXFrame::buildMiniFrame(), SS7SCCPDataSegment::fillSegment(), ISDNFrame::getData(), and resize().
|
inline |
Get the value of a single byte inside the stored data
| offs | Byte offset inside the stored data |
| defvalue | Default value to return if offset is outside data |
Referenced by ISDNFrame::getAi(), ISDNFrame::getType(), operator[](), and operator[]().
| 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 |
Referenced by FSKModem::addRaw(), append(), and SASL::buildAuthRspReply().
| 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 |
References DataBlock().
| 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 |
|
inline |
Get a pointer to the stored data.
Referenced by Cipher::decrypt(), SignallingDumpable::dump(), SignallingDumper::dump(), Cipher::encrypt(), SS7SCCPDataSegment::fillSegment(), SS7MSU::getData(), SS7MSU::getData(), SS7MSU::getNI(), SS7MSU::getPrio(), SS7MSU::getSIF(), SS7MSU::getSIO(), SS7MSU::getSSF(), OctetString::getString(), Hasher::hmac(), Hasher::hmacStart(), Cipher::initVector(), Base64::operator<<(), Cipher::setKey(), OctetString::toHexString(), unHexify(), unHexify(), unHexify(), SliceVector< Complex >::unHexify(), Hasher::update(), Compressor::writeComp(), Stream::writeData(), Compressor::writeDecomp(), and IAXEngine::writeSocket().
|
inline |
Get a pointer to a byte range inside the stored data.
| offs | Byte offset inside the stored data |
| len | Number of bytes that must be valid starting at offset |
|
static |
A static empty data block
References DataBlock().
|
virtual |
Get a pointer to a derived class given that class name
| name | Name of the class we are asking for |
Reimplemented from GenObject.
| void insert | ( | const DataBlock & | value | ) |
|
inline |
Get the length of the stored data.
Referenced by Cipher::decrypt(), SignallingDumpable::dump(), SignallingDumper::dump(), Cipher::encrypt(), SS7MSU::getData(), SS7MSU::getData(), OctetString::getString(), Hasher::hmac(), Hasher::hmacStart(), Cipher::initVector(), resize(), Cipher::setKey(), OctetString::toHexString(), SliceVector< Complex >::unHexify(), Hasher::update(), Compressor::writeComp(), Stream::writeData(), Compressor::writeDecomp(), and IAXEngine::writeSocket().
|
inline |
Checks if the block holds a NULL pointer.
Referenced by SS7MSU::getNI(), SS7MSU::getPrio(), SS7MSU::getSIF(), SS7MSU::getSIO(), and SS7MSU::getSSF().
Appending operator.
References append(), and DataBlock().
Appending operator for Strings.
References append(), and DataBlock().
Assignment operator.
References DataBlock().
Referenced by SS7MSU::operator=(), and SS7MSU::operator=().
|
inline |
Byte indexing operator with signed parameter
| index | Index of the byte to retrieve |
References at().
|
inline |
Byte indexing operator with unsigned parameter
| index | Index of the byte to retrieve |
References at().
|
inline |
Get the memory overallocation setting.
Referenced by DataBlock(), DataBlock(), and DataBlock().
|
inline |
Set the memory overallocation.
| bytes | How many bytes of memory to overallocate |
|
inline |
| String sqlEscape | ( | char | extraEsc | ) | const |
Create an escaped string suitable for use in SQL queries
| extraEsc | Character to escape other than the default ones |
| void truncate | ( | unsigned int | len | ) |
Truncate the data block
| len | The maximum length to keep |
| bool unHexify | ( | const char * | data, |
| unsigned int | len ) |
Build this data block from a hexadecimal string representation. Each octet must be represented in the input string with 2 hexadecimal characters. This method guesses if separators are used. If so the octets in input string must be separated using exactly 1 separator. Only 1 leading or 1 trailing separators are allowed.
| data | Input character string |
| len | Length of the input string |
References data().
| bool unHexify | ( | const char * | data, |
| unsigned int | len, | ||
| char | sep ) |
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.
| data | Input character string |
| len | Length of the input string |
| sep | Separator character used between octets. 0 if no separator is expected |
References data().
Referenced by OctetString::fromHexString(), unHexify(), and SliceVector< Complex >::unHexify().
|
inline |
Build this data block from a hexadecimal string representation. This version parses a String and guesses separators presence.
| data | Input character string |
References data(), and unHexify().