
On 3 Mar 2010, at 00:44, Binh Luong wrote:
Hi,
Matthias Troyer-2 wrote:
You should not have to define your class as a wrapper. Can you send the code fragment that causes the problem?
Matthias _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
here are the code segments that cause the problem: As you see in the last message, there are errors in RemoteMessagingSystem.cpp:147 and RemoteMessagingSystem.cpp:147. They are the following 2 functions which serializes the obj Message to xml archive and deserializes xml archive backwards to obj Message.
string RemoteMessagingSystem::serialize (Message* msg) { stringstream archiveStream (ios_base::binary | ios_base::out); { #ifdef REMOTE_XML boost::archive::xml_oarchive outputArchive( archiveStream ); #else boost::archive::binary_oarchive outputArchive( archiveStream ); #endif //REMOTE_XML outputArchive & msg; //line 147 }
string data = archiveStream.str(); return data; }
Message* RemoteMessagingSystem::deserialize (string data) { stringstream archivStream (data, ios_base::binary | ios_base::in); #ifdef REMOTE_XML boost::archive::xml_iarchive inputArchive( archivStream ); #else boost::archive::binary_iarchive inputArchive( archivStream ); #endif
Message* msg = NULL; inputArchive >> msg; // line 164
return msg; }
Two things: 1.) You need to wrap the object into a NVP to use it with XML archives. 2.) You can only serialize const objects into a output archive, hence try passing a const pointer to the RemoteMessagingSystem::serialize function Matthias