B.1 How to Serialize

This section contains description of all steps necessary to add an de/serialization feature to a class. More detailed information about de/serialization is in section Serialization and Deserialization. We have also prepared an example of de/serialization methods. For better understanding we suggest to read also chapter about base class TObj.

  1. Implement the class as successor of the base class TObj.
  2. Implement virtual method uint GetSerSize(BOOL subclass)
    This method counts the length of type map for all attributes of the class. Call methods TObj::GetSerSize<type>() for each attribute of the class within this method.
  3. Implement virtual method uint Serialize(BYTE** rawbytes,BOOL subclass)
    This method serializes the class. Call methods TObj::Serialize<type>() for each attribute of the class within it.
  4. Implement deserialization constructor Classname(BYTE** rawbytes,uint len,BOOL subclass)
    This constructor creates a new object and initializes its attributes to values decoded from the type map (argument rawbytes). Call methods TObj::Deserialize<type>() to decode all values. It is necessary to call these methods in the same order as the serialisation methods were called  in the step 3.

Important notes:

Programmer's Guide Project Antares