3DCoatScripting  4.8.31β
You can manage 3DСoat features with help of scripting
coat::scripto::FormatBinary Class Reference

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.
 
FormatBinaryoperator() (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...
 
FormatBinaryappend (const raw_t::value_type &d)
 Appends a byte. More...
 
FormatBinaryoperator+= (const raw_t::value_type &d)
 
FormatBinaryprepend (const raw_t::value_type &d)
 Prepends a byte. More...
 
FormatBinaryclear ()
 Clears binary data. More...
 

Protected Member Functions

const raw_t & raw () const
 
raw_t & raw ()
 

Detailed Description

Class for working with binary data.

format-binary.jpg
// creating a header of Free Lossless Image Format (FLIF)
// http://flif.info
FormatBinary a = { 0x46, 0x4c, 0x49, 0x46 };
Since
4.5.32

Member Function Documentation

bool coat::scripto::FormatBinary::operator== ( const FormatBinary b) const
inline

Comparison.

...
if (a == b) { ... }
FormatBinary& coat::scripto::FormatBinary::operator() ( int  i,
raw_t::value_type  v 
)
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 ];
raw_t::value_type coat::scripto::FormatBinary::operator() ( int  i) const
inline

Getter like array.

FormatBinary a = { 0x53, 0x49, 0x4d, 0x50, 0x4c, 0x45 };
uint8 first = a[ 0 ];
uint8 second = a[ 1 ];
uint8 last = a[ 5 ];
int coat::scripto::FormatBinary::size ( ) const
inline

Returns a filled count of bytes.

FormatBinary a = { 0x53, 0x49, 0x4d, 0x50, 0x4c, 0x45 };
string n = a.size();
FormatBinary& coat::scripto::FormatBinary::append ( const raw_t::value_type &  d)
inline

Appends a byte.

// creating a header of Tagged Image File Format (TIFF)
// http://filesignatures.net/index.php?search=tiff&mode=EXT
a.append( 0x49 );
a += 0x20;
a += 0x49;
FormatBinary& coat::scripto::FormatBinary::operator+= ( const raw_t::value_type &  d)
inline

FormatBinary& coat::scripto::FormatBinary::prepend ( const raw_t::value_type &  d)
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
FormatBinary& coat::scripto::FormatBinary::clear ( )
inline

Clears binary data.

FormatBinary a = { 0x00, 0x00 };
a.clear();