These objects are used to pass around untyped data without concern about clean-up. They know whether the bytes need to be de-allocated when these objects go out of scope. Small amounts of data are stored in the object.

Objects of this class are used a lot within Metakit to manipulate its own data items generically. The c4_BytesProp class allows storing binary data explicitly in a file. If such data files must be portable, then the application itself must define a generic format to deal with byte order.

How to store an object in binary form in a row (this is not portable):

    struct MyStruct { ... };
    MyStruct something;

    c4_BytesProp pData ("Data");
    c4_Row row;

    pData (row) = c4_Bytes (&something, sizeof something);


const t4_byte* Contents () const;
Return a pointer to the contents

union NONAME;

t4_byte* SetBuffer (int length_);
Define contents as a freshly allocated buffer of given size

t4_byte* SetBufferClear (int length_);
Allocate a buffer and fills its contents with zero bytes

int Size () const;
Return the number of bytes of its contents

void Swap (c4_Bytes& bytes_);
Swap the contents and ownership of two byte objects

void _LoseCopy ();

void _MakeCopy ();

t4_byte _buffer [kMaxBuf];

bool _copy;

int _size;

c4_Bytes ();
Construct an empty binary object

c4_Bytes (const c4_Bytes& bytes_);
Copy constructor

c4_Bytes (const void* buffer_, int length_);
Construct an object with contents, no copy

c4_Bytes (const void* buffer_, int length_, bool makeCopy_);
Construct an object with contents, optionally as a copy

enum { kMaxBuf = 16 };

c4_Bytes& operator= (const c4_Bytes& bytes_);
Assignment, this may make a private copy of contents

~c4_Bytes ();
Destructor


class c4_Bytes