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);

<if !private>
const t4_byte* Contents () const;
  Return a pointer to the contents

  <if !private>

union NONAME;

  <if !private>

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

  <if !private>

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

  <if !private>

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

  <if !private>

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

  <if !private>

void _LoseCopy ();

  <if !private>

void _MakeCopy ();

  <if !private>

t4_byte _buffer [kMaxBuf];

  <if !private>

bool _copy;

  <if !private>

int _size;

  <if !private>

c4_Bytes ();
  Construct an empty binary object

  <if !private>

c4_Bytes (const c4_Bytes& bytes_);
  Copy constructor

  <if !private>

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

  <if !private>

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

  <if !private>

enum { kMaxBuf = 16 };

  <if !private>

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

  <if !private>

~c4_Bytes ();
  Destructor

class c4_Bytes