c++ - serializing classes using boost serialization without changing the class -
this piece of code has written every time make class i.e.from template<class archive>
ar
& boost_serialization_nvp(b)
. how can make short? , how can serialize stl containers ?
class employee { private: friend class boost::serialization::access; template<class archive> void serialize(archive & ar, const unsigned int version) { ar & boost_serialization_nvp(a); ar & boost_serialization_nvp(b); } int a; int b; public: employee(int a, int b) { this->a = a; this->b = b; } };
i suggest start documentation :)
- http://www.boost.org/doc/libs/1_55_0/libs/serialization/doc/index.html (start under serializable concept)
stl containers serializable when include relevant header:
#include <boost/serialization/map.hpp> #include <boost/serialization/string.hpp>
a host of other stuff supported out of box.
you could make generic wrappers types have been made "reflectible" other means (e.g. fusion sequences, qt qobjects etc.)
Comments
Post a Comment