Class for working with binary data. More...
Public Types | |
typedef cList< unsigned char > | raw_t |
Public Member Functions | |
FormatBinary () | |
Constructor for building an empty binary-object. | |
bool | operator== (const FormatBinary &b) const |
Comparison. More... | |
bool | empty () const |
Returns a TRUE when data is absent. | |
FormatBinary & | operator() (int i, raw_t::value_type v) |
Setter like array. More... | |
raw_t::value_type | operator() (int i) const |
Getter like array. More... | |
int | size () const |
Returns a filled count of bytes. More... | |
FormatBinary & | append (const raw_t::value_type &d) |
Appends a byte. More... | |
FormatBinary & | operator+= (const raw_t::value_type &d) |
FormatBinary & | prepend (const raw_t::value_type &d) |
Prepends a byte. More... | |
FormatBinary & | clear () |
Clears binary data. More... | |
Protected Member Functions | |
const raw_t & | raw () const |
raw_t & | raw () |
Class for working with binary data.
// creating a header of Free Lossless Image Format (FLIF)
// http://flif.info
FormatBinary a = { 0x46, 0x4c, 0x49, 0x46 };
|
inline |
Comparison.
FormatBinary a, b;
...
if (a == b) { ... }
|
inline |
Setter like array.
// creating a header of Flexible Image Transport System (FITS)
// http://digitalpreservation.gov/formats/fdd/fdd000317.shtml#sign
FormatBinary a = { 0x53, 0x49, 0x00, 0x50, 0x4c, 0x45 };
// setting third byte to 0xff
a[ 2, 0x4d ];
|
inline |
Getter like array.
FormatBinary a = { 0x53, 0x49, 0x4d, 0x50, 0x4c, 0x45 };
uint8 first = a[ 0 ];
uint8 second = a[ 1 ];
uint8 last = a[ 5 ];
|
inline |
Returns a filled count of bytes.
FormatBinary a = { 0x53, 0x49, 0x4d, 0x50, 0x4c, 0x45 };
string n = a.size();
|
inline |
Appends a byte.
// creating a header of Tagged Image File Format (TIFF)
// http://filesignatures.net/index.php?search=tiff&mode=EXT
FormatBinary a;
a.append( 0x49 );
a += 0x20;
a += 0x49;
|
inline |
|
inline |
Prepends a byte.
// creating a header of Portable Network Graphics (PNG)
// http://filesignatures.net/index.php?search=png&mode=EXT
FormatBinary a = { 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
a.prepend( 0x4e ); // G
a.prepend( 0x50 ); // N
a.prepend( 0x89 ); // P
|
inline |
Clears binary data.
FormatBinary a = { 0x00, 0x00 };
a.clear();