#include <iostream>
#include <fstream>
#include <boost/serialization/string.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/type_info_implementation.hpp>
#include <boost/serialization/export.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/foreach.hpp>
using namespace std;
class Father{
public :
string who;
Father(){ who = "father";};
virtual void whoAreYou(){ cout << "Hello, I am the " << this->who << endl; };
};
class Son : public Father{
public :
Son(){ who = "son" ;};
};
BOOST_CLASS_EXPORT_GUID(Son, "son");
template<class Archive>
void serialize(Archive & ar, Father & g, const unsigned int version)
{
ar & BOOST_SERIALIZATION_NVP(g.who);
}
template<class Archive>
void serialize(Archive & ar, Son & g, const unsigned int version)
{
ar & BOOST_SERIALIZATION_NVP(boost::serialization::base_object<Father>(g));
}
int main(){
std::ofstream ofs("wtf.xml");
assert(ofs.good());
boost::archive::xml_oarchive oa(ofs);
Father *mySon = new Son();
oa << BOOST_SERIALIZATION_NVP(mySon);
}