1 | #include <boost/serialization/nvp.hpp>
|
---|
2 | #include <boost/archive/xml_oarchive.hpp>
|
---|
3 | #include <iostream>
|
---|
4 |
|
---|
5 | using namespace std;
|
---|
6 | using namespace boost::archive;
|
---|
7 |
|
---|
8 | class Nested {
|
---|
9 | public:
|
---|
10 | explicit Nested()
|
---|
11 | : mC()
|
---|
12 | { }
|
---|
13 |
|
---|
14 | explicit Nested(char c)
|
---|
15 | : mC(c)
|
---|
16 | { }
|
---|
17 |
|
---|
18 | private:
|
---|
19 | friend class boost::serialization::access;
|
---|
20 |
|
---|
21 | template<class Archive>
|
---|
22 | void serialize(Archive& ar, const unsigned int)
|
---|
23 | {
|
---|
24 | using boost::serialization::make_nvp;
|
---|
25 | ar & make_nvp("c", mC);
|
---|
26 | };
|
---|
27 |
|
---|
28 | private:
|
---|
29 | char mC;
|
---|
30 | };
|
---|
31 |
|
---|
32 | BOOST_CLASS_VERSION(Nested, 0);
|
---|
33 |
|
---|
34 | int main()
|
---|
35 | {
|
---|
36 | Nested n('c');
|
---|
37 |
|
---|
38 | {
|
---|
39 | using boost::serialization::make_nvp;
|
---|
40 | xml_oarchive ar(cout);
|
---|
41 | ar << make_nvp("Nested", n);
|
---|
42 | }
|
---|
43 |
|
---|
44 | return 0;
|
---|
45 | }
|
---|