Hi,
thank you very much for your answer. I was stuck with this problem for days.
I have changed the code so that a const pointer is now passed to the
RemoteMessagingSystem::serialize:
string RemoteMessagingSystem::serialize (Message* const msg)
{
...
}
But the problem with deserialize is still there:
In file included from
/home/v0d0i/libraries/boost_1_42_0/include/boost/archive/xml_iarchive.hpp:24,
from message/remote/RemoteMessagingSystem.h:31,
from message/remote/RemoteMessagingSystem.cpp:1:
/home/v0d0i/libraries/boost_1_42_0/include/boost/archive/basic_xml_iarchive.hpp:
In member function ‘void
boost::archive::basic_xml_iarchive<Archive>::load_override(T&, int) [with T
= Message*, Archive = boost::archive::xml_iarchive]’:
/home/v0d0i/libraries/boost_1_42_0/include/boost/archive/xml_iarchive.hpp:80:
instantiated from ‘void
boost::archive::xml_iarchive_impl<Archive>::load_override(T&, int) [with T =
Message*, Archive = boost::archive::xml_iarchive]’
/home/v0d0i/libraries/boost_1_42_0/include/boost/archive/detail/interface_iarchive.hpp:61:
instantiated from ‘Archive&
boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T
= Message*, Archive = boost::archive::xml_iarchive]’
message/remote/RemoteMessagingSystem.cpp:164: instantiated from here
/home/v0d0i/libraries/boost_1_42_0/include/boost/archive/basic_xml_iarchive.hpp:70:
error: no matching function for call to
‘assertion_failed(mpl_::failed************
boost::serialization::is_wrapper
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
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://old.nabble.com/Problem-with-Boost-Serialization-tp27743377p27773125.h... Sent from the Boost - Users mailing list archive at Nabble.com.