Hello,
i have some problems with the serialization of boost. I am working now
with a program and want to use boost to serialize an object to a xml
archive. I have read the tutorials on the homepage and make the
necessary steps but still get some errors while compiling:
In file included from
/home/v0d0i/libraries/boost_1_42_0/include/boost/archive/xml_oarchive.hpp:31,
from message/remote/RemoteMessagingSystem.h:30,
from message/remote/RemoteMessagingSystem.cpp:1:
/home/v0d0i/libraries/boost_1_42_0/include/boost/archive/basic_xml_oarchive.hpp:
In member function 'void
boost::archive::basic_xml_oarchive<Archive>::save_override(T&, int)
[with T = Message* const, Archive = boost::archive::xml_oarchive]':
/home/v0d0i/libraries/boost_1_42_0/include/boost/archive/detail/interface_oarchive.hpp:64:
instantiated from 'Archive&
boost::archive::detail::interface_oarchive<Archive>::operator<<(T&)
[with T = Message* const, Archive = boost::archive::xml_oarchive]'
/home/v0d0i/libraries/boost_1_42_0/include/boost/archive/detail/interface_oarchive.hpp:72:
instantiated from 'Archive&
boost::archive::detail::interface_oarchive<Archive>::operator&(T&) [with
T = Message*, Archive = boost::archive::xml_oarchive]'
message/remote/RemoteMessagingSystem.cpp:147: instantiated from here
/home/v0d0i/libraries/boost_1_42_0/include/boost/archive/basic_xml_oarchive.hpp:92:
error: no matching function for call to
'assertion_failed(mpl_::failed************
boost::serialization::is_wrapper
On Mar 1, 2010, at 1:50 PM, Binh Luong wrote:
Hello,
i have some problems with the serialization of boost. I am working now with a program and want to use boost to serialize an object to a xml archive. I have read the tutorials on the homepage and make the necessary steps but still get some errors while compiling: In file included from /home/v0d0i/libraries/boost_1_42_0/include/boost/archive/xml_oarchive.hpp:31, from message/remote/RemoteMessagingSystem.h:30, from message/remote/RemoteMessagingSystem.cpp:1: /home/v0d0i/libraries/boost_1_42_0/include/boost/archive/basic_xml_oarchive.hpp: In member function ‘void boost::archive::basic_xml_oarchive<Archive>::save_override(T&, int) [with T = Message* const, Archive = boost::archive::xml_oarchive]’: /home/v0d0i/libraries/boost_1_42_0/include/boost/archive/detail/interface_oarchive.hpp:64: instantiated from ‘Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = Message* const, Archive = boost::archive::xml_oarchive]’ /home/v0d0i/libraries/boost_1_42_0/include/boost/archive/detail/interface_oarchive.hpp:72: instantiated from ‘Archive& boost::archive::detail::interface_oarchive<Archive>::operator&(T&) [with T = Message*, Archive = boost::archive::xml_oarchive]’ message/remote/RemoteMessagingSystem.cpp:147: instantiated from here /home/v0d0i/libraries/boost_1_42_0/include/boost/archive/basic_xml_oarchive.hpp:92: error: no matching function for call to ‘assertion_failed(mpl_::failed************ boost::serialization::is_wrapper
::************)’ 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 ::************)’ make[2]: *** [RemoteMessagingSystem.o] Error 1 make[2]: Leaving directory `/home/v0d0i/workspace/trunk1/src/base' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/v0d0i/workspace/trunk1/src' make: *** [all-recursive] Error 1 It seems like there is something wrong with the Wrapper although i have defined the following Wrappers: BOOST_CLASS_IS_WRAPPER(Message*); BOOST_CLASS_IS_WRAPPER(Message* const); BOOST_CLASS_IS_WRAPPER(Message); I also used the boost::serialization::make_nvp for the name-value pairs purpose of xml archive.
What am i doing wrong?
Thanks, Ngoc Mai
You should not have to define your class as a wrapper. Can you send the code fragment that causes the problem? Matthias
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; } Regards, Binh -- View this message in context: http://old.nabble.com/Problem-with-Boost-Serialization-tp27743377p27762759.h... Sent from the Boost - Users mailing list archive at Nabble.com.
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
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.
On 4 Mar 2010, at 00:54, Binh Luong wrote:
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:
Here is the code fragement: 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; //line 164 inputArchive >> msg;
return msg; }
Should I also change here Message* to Message* const?
Actually it is something strange because with the old versoin Boost 1.38 there are no compiling errors. Since i compiled and installed the new version 1.42 i got those errors. Something should be changed between the 2 versions although i have compared the both source codes but do not find any difference :/
Did you try putting it into an NVP wrapper? AFAIK XML archives only serialize NVPs Matthias
Hi, oh sorry, i was wrong in the last message. Although i changed to pass a const pointer to the serialize function, the errors are still there ... I have put the attribute in NVP wrappers. You can see the header file Mesage.h here http://codepad.org/ktpm8Aab Regards, Binh Matthias Troyer-2 wrote:
On 4 Mar 2010, at 00:54, Binh Luong wrote:
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:
Here is the code fragement: 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; //line 164 inputArchive >> msg;
return msg; }
Should I also change here Message* to Message* const?
Actually it is something strange because with the old versoin Boost 1.38 there are no compiling errors. Since i compiled and installed the new version 1.42 i got those errors. Something should be changed between the 2 versions although i have compared the both source codes but do not find any difference :/
Did you try putting it into an NVP wrapper? AFAIK XML archives only serialize NVPs
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-tp27743377p27779665.h... Sent from the Boost - Users mailing list archive at Nabble.com.
On 4 Mar 2010, at 12:40, Binh Luong wrote:
Hi,
oh sorry, i was wrong in the last message. Although i changed to pass a const pointer to the serialize function, the errors are still there ... I have put the attribute in NVP wrappers.
You can see the header file Mesage.h here http://codepad.org/ktpm8Aab
Regards, Binh
Can you post the actual code you try to compile? the code you posted did not contain any NVP wrapper around the pointer Matthias
Hi, sorry that i forgot the code. Here you are http://codepad.org/TbPq2PWb Regards, Binh Matthias Troyer-2 wrote:
On 4 Mar 2010, at 12:40, Binh Luong wrote:
Hi,
oh sorry, i was wrong in the last message. Although i changed to pass a const pointer to the serialize function, the errors are still there ... I have put the attribute in NVP wrappers.
You can see the header file Mesage.h here http://codepad.org/ktpm8Aab
Regards, Binh
Can you post the actual code you try to compile? the code you posted did not contain any NVP wrapper around the pointer
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-tp27743377p27783591.h... Sent from the Boost - Users mailing list archive at Nabble.com.
Look at this line of code:
outputArchive & msg;
Can you try making a NVP from msg? and similarly for seserializing? Matthias On 4 Mar 2010, at 18:01, Binh Luong wrote:
Hi,
sorry that i forgot the code. Here you are http://codepad.org/TbPq2PWb
Regards, Binh
Matthias Troyer-2 wrote:
On 4 Mar 2010, at 12:40, Binh Luong wrote:
Hi,
oh sorry, i was wrong in the last message. Although i changed to pass a const pointer to the serialize function, the errors are still there ... I have put the attribute in NVP wrappers.
You can see the header file Mesage.h here http://codepad.org/ktpm8Aab
Regards, Binh
Can you post the actual code you try to compile? the code you posted did not contain any NVP wrapper around the pointer
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-tp27743377p27783591.h... Sent from the Boost - Users mailing list archive at Nabble.com.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi, many thanks for your help. After using the nvp-wrapper for msg it works! May be in the new version of boost we do not have to use the nvp-wrapper only for the attributes of a class but also for the class itself (because there are actually no problems with boost 1.38). Once again thank you very much :) Regards, Binh Matthias Troyer-2 wrote:
Look at this line of code:
outputArchive & msg;
Can you try making a NVP from msg? and similarly for seserializing?
Matthias
On 4 Mar 2010, at 18:01, Binh Luong wrote:
Hi,
sorry that i forgot the code. Here you are http://codepad.org/TbPq2PWb
Regards, Binh
Matthias Troyer-2 wrote:
On 4 Mar 2010, at 12:40, Binh Luong wrote:
Hi,
oh sorry, i was wrong in the last message. Although i changed to pass a const pointer to the serialize function, the errors are still there ... I have put the attribute in NVP wrappers.
You can see the header file Mesage.h here http://codepad.org/ktpm8Aab
Regards, Binh
Can you post the actual code you try to compile? the code you posted did not contain any NVP wrapper around the pointer
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-tp27743377p27783591.h... Sent from the Boost - Users mailing list archive at Nabble.com.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ 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-tp27743377p27798823.h... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
Binh Luong
-
Matthias Troyer