Skip to content

Session: Serialization

cpockrandt edited this page Feb 21, 2017 · 2 revisions

What is serialization?

It lets you take objects, put them on a disk, then later, perhaps on another computer, reverse the process: resurrect the original objects. The basic mechanisms are to flatten objects into a one-dimensional stream of bits, and to turn that stream of bits back into the original objects. (isocpp.org)

Criteria

  • multiple output formats (binary, json or xml for debugging)
  • portability (endianess)
  • built-in serialization of STL types
  • header-only
  • compression of binary format
  • versioning
  • handling pointers
  • easy to use

3 popular libraries:

Comparison:

Protobuf Boost Cereal
License 3-clause BSD Boost license 3-clause BSD
Header only Yes No Yes
STL support No Yes Almost
Portable Binary Format Yes Work in progress Yes
Versioning Yes Yes Yes
Formats Binary Binary, XML, Text Binary, XML, JSON
Compression No Yes No
Pointers No* Yes Smart, shared, unique and weak pointers

Benchmarking suite:

Clone this wiki locally