Hello StackOverflow!
im trying to serialize some object as xml and then read it back the code is: IncomingTradeMessage inherits BaseMessage and contains InternalRequestInfo which in turn contains InternalTradeTransInfo. this is the code:
std::ostringstream oStringStream;
boost::archive::xml_oarchive xmlArchive(oStringStream);
xmlArchive.register_type(static_cast<BaseMessage *>(NULL));
xmlArchive.register_type(static_cast<IncomingTradeMessage *>(NULL));
xmlArchive.register_type(static_cast<InternalRequestInfo *>(NULL));
xmlArchive.register_type(static_cast<InternalTradeTransInfo *>(NULL));
const BaseMessage* myMessage =message;
xmlArchive << make_nvp("Message", myMessage);
std::string strData = oStringStream.str();
std::istringstream iStringStream(strData,istringstream::in);
std::string nothing;
//iStringStream. >> nothing;
BaseMessage* x = new IncomingTradeMessage();
boost::archive::xml_iarchive xmlIncomingArchive(iStringStream);
xmlIncomingArchive >> make_nvp("Message",*x);
when trying to deserialize the first member of the base i get: Unhandled exception at 0x7c812aeb in mtsrv.exe: Microsoft C++ exception: boost::archive::archive_exception at memory location 0x0eb6df58..
at:
kernel32.dll!7c812aeb()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
kernel32.dll!7c812aeb()
xxxServerAPI.dll!_CxxThrowException(void * pExceptionObject=0x0eb6df58, const _s__ThrowInfo * pThrowInfo=0x05481c68) Line 161 C++
> xxxServerAPI.dll!boost::serialization::throw_exception<boost::archive::archive_exception>(const boost::archive::archive_exception & e={...}) Line 37 C++
xxxServerAPI.dll!boost::archive::basic_xml_iarchive<boost::archive::xml_iarchive>::load_end(const char * name=0x05458c20) Line 53 + 0x35 bytes C++
xxxServerAPI.dll!boost::archive::basic_xml_iarchive<boost::archive::xml_iarchive>::load_override<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >(const boost::serialization::nvp<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > & t={...}, int __formal=0) Line 88 C++
xxxServerAPI.dll!boost::archive::xml_iarchive_impl<boost::archive::xml_iarchive>::load_override<boost::serialization::nvp<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > const >(const boost::serialization::nvp<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > & t={...}, int __formal=0) Line 81 C++
xxxServerAPI.dll!boost::archive::detail::interface_iarchive<boost::archive::xml_iarchive>::operator>><boost::serialization::nvp<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > const >(const boost::serialization::nvp<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > & t={...}) Line 62 C++
xxxServerAPI.dll!boost::archive::detail::interface_iarchive<boost::archive::xml_iarchive>::operator&<boost::serialization::nvp<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > const >(const boost::serialization::nvp<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > & t={...}) Line 69 C++
xxxServerAPI.dll!x::Native::xServerApi::Messages::BaseMessage::serialize<boost::archive::xml_iarchive>(boost::archive::xml_iarchive & ar={...}, const unsigned int version=0) Line 30 C++
xxxServerAPI.dll!boost::serialization::access::serialize<boost::archive::xml_iarchive,x::Native::xServerApi::Messages::BaseMessage>(boost::archive::xml_iarchive & ar={...}, x::Native::xServerApi::Messages::BaseMessage & t={...}, const unsigned int file_version=0) Line 119 C++
xxxServerAPI.dll!boost::serialization::serialize<boost::archive::xml_iarchive,x::Native::xServerApi::Messages::BaseMessage>(boost::archive::xml_iarchive & ar={...}, x::Native::xServerApi::Messages::BaseMessage & t={...}, const unsigned int file_version=0) Line 74 + 0x11 bytes C++
xxxServerAPI.dll!boost::serialization::serialize_adl<boost::archive::xml_iarchive,x::Native::xServerApi::Messages::BaseMessage>(boost::archive::xml_iarchive & ar={...}, x::Native::xServerApi::Messages::BaseMessage & t={...}, const unsigned int file_version=0) Line 133 + 0x18 bytes C++
xxxServerAPI.dll!boost::archive::detail::iserializer<boost::archive::xml_iarchive,x::Native::xServerApi::Messages::BaseMessage>::load_object_data(boost::archive::detail::basic_iarchive & ar={...}, void * x=0x054e1490, const unsigned int file_version=0) Line 186 + 0x1a bytes C++
xxxServerAPI.dll!boost::archive::detail::basic_iarchive_impl::load_object(boost::archive::detail::basic_iarchive & ar={...}, void * t=0x054e1490, const boost::archive::detail::basic_iserializer & bis={...}) Line 400 C++
xxxServerAPI.dll!boost::archive::detail::basic_iarchive::load_object(void * t=0x054e1490, const boost::archive::detail::basic_iserializer & bis={...}) Line 548 C++
xxxServerAPI.dll!boost::archive::detail::load_non_pointer_type<boost::archive::xml_iarchive>::load_standard::invoke<x::Native::xServerApi::Messages::BaseMessage>(boost::archive::xml_iarchive & ar={...}, const x::Native::xServerApi::Messages::BaseMessage & t={...}) Line 387 C++
xxxServerAPI.dll!boost::archive::detail::load_non_pointer_type<boost::archive::xml_iarchive>::invoke<x::Native::xServerApi::Messages::BaseMessage>(boost::archive::xml_iarchive & ar={...}, x::Native::xServerApi::Messages::BaseMessage & t={...}) Line 433 + 0xd bytes C++
xxxServerAPI.dll!boost::archive::load<boost::archive::xml_iarchive,x::Native::xServerApi::Messages::BaseMessage>(boost::archive::xml_iarchive & ar={...}, x::Native::xServerApi::Messages::BaseMessage & t={...}) Line 580 + 0xd bytes C++
xxxServerAPI.dll!boost::archive::detail::common_iarchive<boost::archive::xml_iarchive>::load_override<x::Native::xServerApi::Messages::BaseMessage>(x::Native::xServerApi::Messages::BaseMessage & t={...}, int __formal=0) Line 68 + 0x15 bytes C++
xxxServerAPI.dll!boost::archive::basic_xml_iarchive<boost::archive::xml_iarchive>::load_override<x::Native::xServerApi::Messages::BaseMessage>(const boost::serialization::nvp<x::Native::xServerApi::Messages::BaseMessage> & t={...}, int __formal=0) Line 87 C++
xxxServerAPI.dll!boost::archive::xml_iarchive_impl<boost::archive::xml_iarchive>::load_override<boost::serialization::nvp<x::Native::xServerApi::Messages::BaseMessage> const >(const boost::serialization::nvp<x::Native::xServerApi::Messages::BaseMessage> & t={...}, int __formal=0) Line 81 C++
xxxServerAPI.dll!boost::archive::detail::interface_iarchive<boost::archive::xml_iarchive>::operator>><boost::serialization::nvp<x::Native::xServerApi::Messages::BaseMessage> const >(const boost::serialization::nvp<x::Native::xServerApi::Messages::BaseMessage> & t={...}) Line 62 C++
xxxServerAPI.dll!x::Native::xServerApi::Bridge::DistributeMessage(const x::Native::xServerApi::Messages::BaseMessage * message=0x04799248) Line 99 C++