I have a problem deserializing data serialized using Boost.Serialization.
I want a method like this DataObject* Transmitter::read()
. DataObject
is the parent class of multiple classes that can be send using Transmitter::write(DataObject& data)
.
What I have at the moment looks like this, but it doesn't work.
DataObject* Transmitter::read()
{
std::string dataString;
// Data is read into the string here!
// The data in dataString is correct, so this isn't the problem
std::istringstream inputStream(dataString);
boost::archive::text_iarchive inputArchive(inputStream);
DataObject* data;
ia >> BOOST_SERIALIZATION_NVP(data);
return data;
}
When I use it like that I get a boost::archive::archive_exception
with "unregistered class". I looked at other examples that used serialization just like that, but it doesn't work inside the read()
method of my class.
PS: On a side note I would like to use boost::archive::binary_iarchive
. Can I use it like that in a stringstream
or is this problematic because of zero-bytes?