#include "stdafx.h"
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/serialization/map.hpp>
#include <fstream>
#include <iostream>
class TestClass
{
public:
TestClass()
{
m_cMember1 = 'm';
m_strMemberName = "Hello.";
m_nData = 1;
}
char m_cMember1;
std::string m_strMemberName;
int m_nData;
// 串行化的函数,这一个函数完成对象的保存与恢复
template<class Archive>
void serialize(Archive& ar, const unsigned int version)
{
// 注意这个宏(变量名存储进去, XML文件的节点将作为节点的名称)
ar & BOOST_SERIALIZATION_NVP(m_cMember1);
ar & BOOST_SERIALIZATION_NVP(m_strMemberName);
ar & BOOST_SERIALIZATION_NVP(m_nData);
}
};
type