I'm starting to use boost::serialization on XML archives. I can produce and read data, but when I hand-modify the XML and interchange two tags, it "fails to fail" (i.e. it proceeds happily).
Here's a small, self-complete example showing what I see:
#include <iostream>
#include <fstream>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/split_member.hpp>
using namespace std;
int main (void)
{
boost::archive::xml_oarchive oa (cout);
static const string producer = "XXX", version = "0.0.1";
oa << boost::serialization::make_nvp ("producer", producer);
oa << boost::serialization::make_nvp ("producer_version", version);
}
This writes XML to standard output, which contains:
<producer>XXX</producer>
<producer_version>0.0.1</producer_version>
Now, I replace all the code in the main funtion with a reader:
boost::archive::xml_iarchive ia (cin);
string producer, version;
ia >> boost::serialization::make_nvp ("producer", producer);
ia >> boost::serialization::make_nvp ("producer_version", version);
cout << producer << " " << version << endl;
which works as expected when fed the previous output (outputs "XXX 0.0.1"). If, however, I feed it XML in which I changed the order of the two lines "producer" and "producer_version", it still runs and outputs "0.0.1 XXX".
Thus, it fails to recognize that the tags don't have the expected names, and just proceed. I would have expected it to thrown a xml_archive_parsing_error
exception, as indicated in the doc.
Does someone here have experience with that? What I am doing wrong?