deSerialize(Packet p1, Packet p2){ // Version 1 using
stringstreams
std::ostringstream *serialized = new std::ostringstream[2];
serialized[0]=std::ostringstream(std::ios_base::binary);
serialized[1]=std::ostringstream(std::ios_base::binary);
boost::archive::text_oarchive oa(serialized[0]);
oa << p1;
boost::archive::text_oarchive oa2(serialized[1]);
oa2 << p2;
std::string s1, s2;
s1 = serialized[0].str();
s2 = serialized[1].str();
//deserialize
CCNDataPkt newPacket;
std::istringstream inputStream(s2, std::ios_base::binary);
boost::archive::text_iarchive ia(inputStream);
ia >> newPacket;
// throws boost::archive::archive_exception: invalid signature.
}
and
deSerialize(Packet p1, Packet p2){ // Version 2 using
ofstreams
std::ofstream
of("deleteme",std::ios_base::binary);
boost::archive::binary_oarchive oa(of);
oa << p1;
std::ifstream ifstr("deleteme",
std::ios_base::binary);
CCNDataPkt newp;
boost::archive::binary_iarchive ia(ifstr);
ia >> newp;
// boost::archive::archive_exception: invalid signature.
}
However, both variants returned an invalid signature exception even though I haven't changed anything on the serialized data. Does anyone know what is wrong in either of the examples above? The methods for serializing the custom object 'Packet' are implemented according to the boost serialization tutorial (non-intrusive version splitted)