Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

c4_Bytes Class Reference

Generic data buffer, with optional automatic clean up. More...

List of all members.

Public Member Functions

 c4_Bytes ()
 Construct an empty binary object.
 c4_Bytes (const void *, int)
 Construct an object with contents, no copy.
 c4_Bytes (const void *, int, bool)
 Construct an object with contents, optionally as a copy.
 c4_Bytes (const c4_Bytes &)
 Copy constructor.
 ~c4_Bytes ()
 Destructor, if a copy was made, it will be released here.
c4_Bytesoperator= (const c4_Bytes &)
 Assignment, this may make a private copy of contents.
void Swap (c4_Bytes &)
 Swap the contents and ownership of two byte objects.
int Size () const
 Returns the number of bytes of its contents.
const t4_byte * Contents () const
 Returns a pointer to the contents.
t4_byte * SetBuffer (int)
 Define contents as a freshly allocated buffer of given size.
t4_byte * SetBufferClear (int)
 Allocate a buffer and fills its contents with zero bytes.

Friends

bool operator== (const c4_Bytes &, const c4_Bytes &)
 Return true if the contents of both objects are equal.
bool operator!= (const c4_Bytes &, const c4_Bytes &)
 Returns true if the contents of both objects is not equal.


Detailed Description

Generic data buffer, with optional automatic clean up.

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


The documentation for this class was generated from the following files:

Metakit C++ API Reference - https://www.equi4.com/metakit.html - extracted with Doxygen