I have a MyFile.hpp header file which contains various types and enums. How do i do serialization/ desrialization of given example code.
//MyFile.hpp
Maps, strings etc. can just be serialized by including the relevant header:
#include <boost/serialization/map.hpp>
#include <boost/serialization/string.hpp>
The enum counts as a primitive type:
A type T is Serializable if and only if one of the following is true:
it is a primitive type.
By primitive type we mean a C++ built-in type and ONLY a C++ built-in type. Arithmetic (including characters), bool, enum are primitive types. Below in serialization traits, we define a "primitive" implementation level in a different way for a different purpose. This can be a source of confusion.
- It is a class type and one of the following has been declared according to the prototypes detailed below:
- a class member function serialize
- a global function serialize
- it is a pointer to a Serializable type.
- it is a reference to a Serializable type.
- it is a native C++ Array of Serializable type.
For more tricky cases there is BOOST_STRONG_TYPEDEF
(see documentation "Serialization Wrappers")