Boost logo

Boost Users :

Subject: [Boost-users] Boost serialization archive stream error exception
From: Marco Piacentini (marcopiacenta_at_[hidden])
Date: 2011-05-18 12:07:52


Hi guys..I've the following problem.. I have a file called A.h and a file B.h. each contains some struct like this: (the structs inside the two classes are different) struct Base { friend class access; template <typename Archive> void serialize(Archive& ar,const unsigned int version) { ar & fieldLength; ar & fieldMD; ar & fieldTime_Stamp; } public: unsigned int fieldLength; unsigned int fieldMD; unsigned int fieldTime_Stamp; virtual void f(){} //to be polymorphic the struct }; struct Derived:public Base { . ... } So i serialize the struct in the classic manner: .... std::ostringstream archive_stream; boost::archive::text_oarchive archive(archive_stream); archive.register_type(static_cast<Derived*>(NULL)) archive <<p; // where p is a pointer to Base NOW THE PROBLEM... on the deserialization side, I follow the same (inverse) procedure...if I deserialize singularly the structs in A.h (without include in the project B.h) and the structs in B.h (without include in the project A.h) all works....but If I include in the project both the classes, the deserialization works for one class, but throws the "Stream error exception" in the instruction " archive >> m;" for the other...it seems a conflict in the registration class or something like this... Any ideas?thanks...



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