CnC
Non bitwise serializable objects
Serialization

You'll have to provide a serializer function for your class. One way of doing this is to derive your class from serializable and to provide a method "serialize":

           class Your_class : public serializable {
               ...
           public:
               void serialize( CnC::serializer & );
               ...
           };

In the implementation of this serialize method you should use the operator& of the serializer class. Here is an example:

           class Your_class : public serializable {
           private:
               double x;
               float  y;
               int    len;
               char*  arr; // array of lenth len
               ...
           public:
               void serialize( CnC::serializer & buf ) {
                   buf & x
                       & y
                       & len;
                   buf & CnC::chunk< char >( arr, len_arr ); // chunk declared below
                   ...
               }
           }

This method will called for both packing and unpacking (what will actually be done, depends on the internal mode of the serializer.)
Alternatively, you can provide a global function

           void serialize( serializer& buf, Your_class& obj );

which should use the operator& of the serializer class (same as for method 2. above). This is useful in cases where you want to leave your class unchanged.

 All Classes Namespaces Functions Variables Typedefs Enumerator Friends