Boost serialization archive stream error exception
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
m;" for the other...it seems a conflict in the registration class or
something like this...
Any ideas?thanks...
On Wed, May 18, 2011 at 11:07 AM, Marco Piacentini
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
(NULL)) archive <
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...
I recently ran into this same exception in Boost (although my version was 1.36). I referred to the following URL for help - http://www.boost.org/doc/libs/1_36_0/libs/serialization/doc/exceptions.html#..., but my problem was solved with this reference ( http://stackoverflow.com/questions/5178321/boost-serialization-problem-in-wi...), which was more relevant to my problem, since I was using a binary_archive.
Hope one of these references are useful to you. Thanks Ganesh -- Ganeshram Iyer Open Source and CAD: http://ossandcad.blogspot.com ganeshramiyer@yahoo.com
participants (2)
-
Ganeshram Iyer
-
Marco Piacentini