Resource Manager
C4Packing.h

class Packer

Represents an output serialization stream.
Definition

class Packer

Member Functions
Packer::WriteArray Writes an array of data to the output stream.
Packer::GetStringSize Returns the serialized size of a string.
Constructor

Packer(void *ptr);

Parameters
ptr A pointer to a memory block for the packed data.
Description
A Packer object is passed to the Packable::Pack function when the engine needs to serialize data stored in an object. The Packer object encapsulates an output serialization stream, and the << operator is typically used to write data to it.
Overloaded Operators
template <typename type> Packer& operator <<(const type& data); Writes the data given by the data parameter to the output stream.
Packer& operator <<(const bool& data); Writes the boolean value given by the data parameter to the output stream. (This operation always writes four bytes to the output stream.)
template <long len> Packer& operator <<(const String<len>& string); Writes the string given by the string parameter to the output stream.
Description
In order to maintain four-byte alignment, char and short types should not be serialized directly with the << operator. Instead, such values should first be cast to a 32-bit type. Note that the bool type is given special handling by the << operator so that it always occupies four bytes.
See Also
Unpacker

Packable