Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-08-22 10:43:43


I'm suspicious of

oa << BOOST_SERIALIZATION_NVP(*fixt);

This assigns an XML tag name of <*fixt> which I suspect isn't kosher. You
might try:

oa << boost::serialization::nvp("fixt_tag", *fixt);

See if that helps.

BTW, I find things like

oa << *x;

very odd. Its not clear what the intention is to me.

I would have written

p.speck_at_[hidden] wrote:
> I have a problem with serialization in XML-format.
>
> The ser.routine saves the data as xml, but when trying to reload, the
> execution breaks. When using the text-output saving and loading works
> fine...
>
> I hope someone can help me:
> Here the code of the functions:
> ------------------------------------------------
> main.cpp:
> ------------------------------------------------
>
> #include "fixture.h"
> #include <boost/archive/xml_oarchive.hpp>
> #include <boost/archive/xml_iarchive.hpp>
> #include <iostream>
> #include <fstream>
> #include <string>
> #include <sstream>
>
> void save(CFixture* fixt, const char* filename)
> {
> ofstream ofs(filename);
> assert(ofs.good());
> boost::archive::xml_oarchive oa(ofs);
> oa << BOOST_SERIALIZATION_NVP(*fixt);
> ofs.close();
> }
>
> void load(CFixture* fixt, const char* filename)
> {
> ifstream ifs(filename);
> assert(ifs.good());
> cout << filename << endl;
> boost::archive::xml_iarchive ia(ifs);
> cout << "Archive" << endl;
> ia >> BOOST_SERIALIZATION_NVP(*fixt);
> cout << "loaded" << endl;
> ifs.close();
> }
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net