CSer

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

CSer Ranking & Summary

Advertisement

  • Rating:
  • License:
  • LGPL
  • Price:
  • FREE
  • Publisher Name:
  • Jeff Freedman
  • Publisher web site:

CSer Tags


CSer Description

CSer is a library for C serialization, also called 'persistence'. 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 Related Software