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
namespace A {
namespace B {
typedef std::string MyString;
typedef std::map<std::string,std::string> my_type;
typedef bool result;
struct MyTimer
{
int time;
private :
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive &ar, const unsigned int version)
{
ar & time;
}
};
enum MODE
{
Sleep=1,
HybridSleep,
Hybernate
}
}
}
I need to do implementation in corresponding MyFile.cpp but don't know how do i go ahead.
Thanks,
Maps, strings etc. can just be serialized by including the relevant header:
The enum counts as a primitive type:
For more tricky cases there is
BOOST_STRONG_TYPEDEF
(see documentation "Serialization Wrappers")