Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-12-27 11:28:35


Sorry, I can't explain this.

a) I can't explain how output code would through an exception "unrecognized
XML syntax"
which should only be invoked when an archive is read.

b) the "<px ..." without corresponding "</px" .. indicates that the shared
pointer serialization
failed to complete - probably due to problems serializing the thing it
points to.

Try commenting out the shared_ptr serialzation and see if it works. If that
works, investigate
the serialization of the thing that your shared_ptr points to.

Robert Ramey

Merrill Cornish wrote:
> Robert,
>
> Here is the relevant code:
>
> ===========================================
> from the header file for the class being serialized...
>
> #include "boost/serialization/shared_ptr.hpp"
> #include "boost/serialization/nvp.hpp"
> #include "boost/date_time/posix_time/ptime.hpp"
> #include "boost/date_time/posix_time/time_serialize.hpp"
>
> . . .
>
> private:
> friend class boost::serialization::access;
> template<class Archive>
> void serialize(Archive& ar, const unsigned int version) {
> ar &
>
>
>
> BOOST_SERIALIZATION_BASE_OBJECT_NVP(WkFlo::RetractionMixin);
> ar & BOOST_SERIALIZATION_NVP(mNode); ar &
> BOOST_SERIALIZATION_NVP(mExportId); ar &
> BOOST_SERIALIZATION_NVP(mExportStart); }//serialize()
>
> where mNode is a shared_ptr<>, mExportedId is a string, and
> mExportStart
> is a ptime.
> ===========================================
>
> from the test source file...
>
> #include "boost/archive/xml_iarchive.hpp"
> #include "boost/archive/xml_oarchive.hpp"
> #include "boost/serialization/shared_ptr.hpp"
> #include "boost/serialization/nvp.hpp"
>
> . . .
>
> void ExportedNode_Test::serializationTest() {
> const char* archiveFile = "temp/Exported_Node_archive.xml";
> remove(archiveFile); // remove any file with that name
> MockNode_ptr BasicNodeObj1(new MockNode(2312));
>
> ExportedNode_ptr testObj_out(new ExportedNode(BasicNodeObj1, "abcd"));
> {
> // save data to archive
> ofstream outStream(archiveFile);
> boost::archive::xml_oarchive outArchive(outStream);
>
>
> // write class instance to archive
> try {
> outArchive << BOOST_SERIALIZATION_NVP(testObj_out);
> } catch (exception& ex) { cerr << "write: " <<
> ex.what() << endl;} } // archive and stream closed when destructors
> are called
>
> . . .
> }
>
> where the outArchive << is what wrote:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
> <!DOCTYPE boost_serialization>
> <boost_serialization signature="serialization::archive" version="3">
> <testObj_out class_id="0" tracking_level="0" version="1">
> <px class_id="1" tracking_level="1" version="0"
> object_id="_0"</boost_serialization>
>
> and threw the exception: "unrecognized XML syntax"
>
> Is this enough to go on?
>
> Merrill


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