Exception when reading from an archive
Hi, I'm using the serialization library, but have encountered problems. I have an archiver that I use with a stringstream to serialize objects. I write some ints to the archive using "ar << my_int", and finally I archive a derived class wi ar << derived. So far, so good. In a different process, I create an input archiver, read the integers, and then pass the archiver to a different method, where I create an instance of the class I serialized and use "ar >> instance". This throws an exception. The code for the object created is one *.so, and teh code that does the creating does it with a templated class factory in a different *.so. Is that why I'm gettin the exceptions? Is there a solution? The exception is boost::archive::archive_exception what(): stream error. Thanks.
Without seeing the code I can only speculate. But from your description I suspect the following: Eyal Susser wrote:
Hi, I'm using the serialization library, but have encountered problems.
I have an archiver that I use with a stringstream to serialize objects. I write some ints to the archive using "ar << my_int", and finally I archive a derived class wi ar << derived. So far, so good.
Is the derived class archived through a pointer? if so is that a pointer to the base class?
In a different process, I create an input archiver, read the integers, and then pass the archiver to a different method, where I create an instance of the class I serialized and use "ar >> instance". This throws an exception.
If it was save trough a pointer, it shouldn't be explicitly created - the serialization library does that. Rule: If saved through a pointer, it must be loaded to a pointer Rule: loads must use the exact same data type as the corresponding save. I don't know if this helps, but at least you know we care. Robert Ramey
participants (2)
-
Eyal Susser
-
Robert Ramey