CSer 0.0.1 review

Download
by rbytes.net on

CSer is a library for C++ serialization, also called 'persistence'

License: LGPL (GNU Lesser General Public License)
File size: 0K
Developer: Jeff Freedman
0 stars award from rbytes.net

CSer is a library for C++ serialization, also called 'persistence'. This isn't quite a simple as you might think, since one object may be pointed to by multiple other objects.

How does it work?
Writing out integers and character strings is fairly straightforward. The trick is dealing with objects, and pointers to them. Serialization of these involves assigning a unique ID # to each object as it is written, and in keeping a lookup table that maps each object to its ID.

That way, when an object is encountered a second time (because something else is pointing to it), only its ID is written. And when the network is read back in, CSer knows to only recreate the object once, and to use its pointer when its ID is encountered thereafter.

How do I use it?
Sorry for the lack of documentation. For a quick start, see the 'test1.cc' example included in the source. Here is a brief list of the steps you need to take (also listed in the README):

1. #include "CSer.h"
2. Derive from "Serializable".
3. Add a "CSER_DECLARE(Myclass);" in the public part of class 'MyClass'.
4. Add a "CSER_REGISTER(Myclass);" in the .cc file for your class.
5. Add methods "void write(CSer_out&) and void read(CSer_in&) to your class.
NOTE: If an object instance is part of another object
('composition'), then you must write/read the object itself before
writing/reading any pointers to it. See ClassC in 'test1.cc' as
an example.
6. Your class must also have a constructor taking no arguments.

CSer 0.0.1 search tags