Serialization is a technique of encoding any C++ object to an array of bytes. This technique is used whenever an object should be sent to another process via network. After the transportation via network is the array decoded and the proper object is constructed. We call this reverse operation deserialization. The array of bytes produced by serialization we call the type map.
Every class that is intended to be serialized has to be an ancestor of the class TObj. This base class implements serialization and deserialization methods for scalar types and for arrays of scalar type. When an object shall be serialized, these methods are called for all attributes of the object. This way the values of attributes are encoded to the resulting type map. Within deserialization operation these values are decoded in the same order and an exact copy of the original object can be constructed. All these operations are performed within the inheritance hierarchy of the serialized object (e.g. de/serialization of the predecessor is performed before the serialization of own attributes).
Serialization is divided into two steps. At first the total length of the resulting type map is computed. This is performed in the method GetSerSize(). The base class TObj implements this method for all basic scalar types and arrays. The second step is the serialization itself, performed in the method Serialize(). This method awaits an allocated buffer of the proper length to store type map into. Deserialization is performed by a special constructor.
The serialization is, in fact, simple transformation of an object to an array of values of the object's attributes. Each attribute (value of certain type of an array of them) is encoded in the following format:
An example: attribute containing a single integer of value 9 is encoded:(MT_INT, 1, 9).
For details of adding the de/serialization feature to a class see section How to Serialize.