| 1 |
|
|---|
| 2 | #include <iostream>
|
|---|
| 3 | #include <sstream>
|
|---|
| 4 | #include <string>
|
|---|
| 5 | #include <boost/archive/xml_iarchive.hpp>
|
|---|
| 6 |
|
|---|
| 7 | void f(const std::string& xml)
|
|---|
| 8 | {
|
|---|
| 9 | try
|
|---|
| 10 | {
|
|---|
| 11 | std::string str;
|
|---|
| 12 | boost::archive::xml_iarchive(std::istringstream(xml))
|
|---|
| 13 | >> boost::serialization::make_nvp("str", str);
|
|---|
| 14 | std::cout << str << std::endl;
|
|---|
| 15 | }
|
|---|
| 16 | catch(boost::archive::archive_exception& e)
|
|---|
| 17 | {
|
|---|
| 18 | std::cout << e.what() << std::endl;
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | int main()
|
|---|
| 23 | {
|
|---|
| 24 | // deserialize some xml, which was created using xml_oarchive
|
|---|
| 25 |
|
|---|
| 26 | f("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
|
|---|
| 27 | "<!DOCTYPE boost_serialization>"
|
|---|
| 28 | "<boost_serialization signature=\"serialization::archive\" version=\"7\">"
|
|---|
| 29 | "<str>deserialize successfull</str>"
|
|---|
| 30 | "</boost_serialization>");
|
|---|
| 31 |
|
|---|
| 32 | // the same xml, but attributes of <boost_serialization> reorderd
|
|---|
| 33 |
|
|---|
| 34 | f("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
|
|---|
| 35 | "<!DOCTYPE boost_serialization>"
|
|---|
| 36 | "<boost_serialization version=\"7\" signature=\"serialization::archive\">"
|
|---|
| 37 | "<str>deserialize successfull</str>"
|
|---|
| 38 | "</boost_serialization>");
|
|---|
| 39 |
|
|---|
| 40 | return 0;
|
|---|
| 41 | }
|
|---|