Defined in:Packs an object's data.
virtual void Pack(Packer& data, uint32 packFlags) const;
||The packing flags.|
Packfunction is called when the engine needs to pack an object's data. The implementation of an override should first call the direct base class's
Packfunction and then use the functions of the
Packerobject to pack its own data.
Often, chunks are used when packing data so that the format of the data can be changed in different versions of the code without breaking backwards compatibility. A chunk is written to the output stream by first writing a
ChunkHeaderstructure containing the chunk type and chunk size, and then writing the data belonging to the chunk. Each chunk must have a unique type within the set of chunks written by the particular implementation of the
Packfunction, and the size of each chunk must match the number of bytes of data written for the chunk.
After writing all of the chunks for an object, a special terminator chunk must be written to the output stream using the following code.
data << Packer::terminator;In the
Packable::Unpackfunction, chunks are read by calling the