4

I am looking for recommendation for object serialization/deserialization library in c++? Which one are the most advanced and open-sourced?

Can it handle

  • Any class that users defined?
  • Object hierarchy (parent and child classes)?
  • A Tree of objects? Class A has an attribute of Class B which has an attribute of Class C?
  • STL containers? Class A has a vector of Class B?
  • A cyclic of objects? Class A has a pointer pointing to B which has a pointer to A?

I find boost serialization library. I am not sure what is its limitation from http://www.boost.org/doc/libs/1_42_0/libs/serialization/doc/tutorial.html

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
michael
  • 106,540
  • 116
  • 246
  • 346

3 Answers3

3

Protocol buffers is a library developed and used by Google for object serialization that is cross language. It may be a bit different in concept from what you're describing, but it's worth taking a look at.

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
3

It really depends what you're looking for. If you're looking for super-fast speed and rapid development within a library, Boost is awesome. If you're looking for super-fast speed, a little more customizability and cross-library binary compatibility, then Qt is a great solution (not saying that Boost can't be made to do this, too). If you're looking for crazy interoperability, then look for a text-based serialization system like JSON (jsoncpp), YAML (yamlcpp) or XML (way too many), each of which have about 8 billion independent libraries.

Travis Gockel
  • 26,877
  • 14
  • 89
  • 116
1

The Linderdaum Engine Core (iObject, iStaticClass and clLinker objects) provide the custom RTTI for C++.

The idea behind the serialization there is simple: we use an automated source code postprocessor (LSDC) to generate all the save/load code and the registration for all of the metaclassses and properties. Any object can be serialized to and from the abstract tree-based markup language script. XML and custom JSON-like (we call it XLML) script is supported.

The implementation details are described in this answer: https://stackoverflow.com/a/10332336/1182653

  1. Any class derived from iObject is supported
  2. Object hierarchies are supported
  3. "Trees" of objects are supported
  4. std::vector-like containers (supporting push_back/size semantics) are supported
  5. Well, the properties are defined explicitly and the "pointer fixup" can be performed in a custom iObject::EndLoad() method (redefined in user classes)
Community
  • 1
  • 1
Sergey K.
  • 24,894
  • 13
  • 106
  • 174