[Boost-bugs] [Boost C++ Libraries] #3234: XML Serialization error when loading class that inherits from wstring

Subject: [Boost-bugs] [Boost C++ Libraries] #3234: XML Serialization error when loading class that inherits from wstring
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-06-30 03:54:19


#3234: XML Serialization error when loading class that inherits from wstring
-----------------------------------+----------------------------------------
 Reporter: nitram.cero@… | Owner: ramey
     Type: Bugs | Status: new
Milestone: Boost 1.40.0 | Component: serialization
  Version: Boost 1.37.0 | Severity: Problem
 Keywords: |
-----------------------------------+----------------------------------------
 Using version 1.37.0, but checked against SVN and it doesn't seem to have
 changed a lot.
 I'm sorry and I'll try the latest boost version, but please do not
 disregard this bug just because of the version.

 I've tested up until I reach basic_text_iprimitive::load(wstring &t):
 {{{
     template<class T>
     void load(T & t)
     {
         if(is.fail())
             boost::serialization::throw_exception(
                 archive_exception(archive_exception::stream_error)
             );
         is >> t;
     }

 }}}

 The value was "./"
 In this case t = "./</basePath>" :-O

 (basePath thas the NVP name for the wstring value)

 As the end tag is taken as the actual value, trying to get the end tag
 will break the serialization when continuing the execution.


 Call stack:

 {{{
 CharacterEditor.exe!boost::archive::basic_text_iprimitive<std::basic_istream<wchar_t,std::char_traits<wchar_t>
> >::load<nt::wstring>(nt::wstring & t={...}) Line 87 C++
 CharacterEditor.exe!boost::archive::xml_wiarchive_impl<boost::archive::xml_wiarchive>::load<nt::wstring>(nt::wstring
 & t={...}) Line 63 C++
 CharacterEditor.exe!boost::archive::load_access::load_primitive<boost::archive::xml_wiarchive,nt::wstring>(boost::archive::xml_wiarchive
 & ar={...}, nt::wstring & t={...}) Line 98 C++
 CharacterEditor.exe!boost::archive::detail::load_non_pointer_type<boost::archive::xml_wiarchive,nt::wstring>::load_primitive::invoke(boost::archive::xml_wiarchive
 & ar={...}, nt::wstring & t={...}) Line 306 + 0xd bytes C++
 CharacterEditor.exe!boost::archive::detail::load_non_pointer_type<boost::archive::xml_wiarchive,nt::wstring>::invoke(boost::archive::xml_wiarchive
 & ar={...}, nt::wstring & t={...}) Line 391 + 0xd bytes C++
 CharacterEditor.exe!boost::archive::load<boost::archive::xml_wiarchive,nt::wstring>(boost::archive::xml_wiarchive
 & ar={...}, nt::wstring & t={...}) Line 514 + 0xd bytes C++
 CharacterEditor.exe!boost::archive::detail::common_iarchive<boost::archive::xml_wiarchive>::load_override<nt::wstring>(nt::wstring
 & t={...}, int __formal=0) Line 59 + 0x15 bytes C++
 CharacterEditor.exe!boost::archive::basic_xml_iarchive<boost::archive::xml_wiarchive>::load_override<nt::wstring>(const
 boost::serialization::nvp<nt::wstring> & t={...}, int __formal=0) Line 82
 C++
>
 CharacterEditor.exe!boost::archive::xml_wiarchive_impl<boost::archive::xml_wiarchive>::load_override<boost::serialization::nvp<nt::wstring>
 const >(const boost::serialization::nvp<nt::wstring> & t={...}, int
 __formal=0) Line 79 C++
 .
 .
 .
 .

 }}}

 nt::string is almost the same as std::wstring

 {{{
 namespace nt { class wstring : public std::wstring { /*some extra helper
 functions for initialization from a wxWidgets' wxString*/} }
 BOOST_CLASS_IMPLEMENTATION(nt::wstring,
 boost::serialization::primitive_type)

 namespace boost { namespace serialization {

 template<class Archive>
 void serialize(Archive & ar, nt::wstring &s, const unsigned int version)
 {
         ar & static_cast<std::wstring &>(s);
 }

 } } // namespace serialization // namespace boost

 }}}

 The compiler is Microsoft Visual C++ Express 2008 (9)
 I did this hacks in order to get serialization templates to work under
 MSVC9:

 {{{
 //HACK: enable serialization of MSVC9 hash_map
 #define BOOST_HAS_HASH
 #define BOOST_HASH_MAP_HEADER <hash_map>

 //HACK: disable resize of hash_map
 #define __MWERKS__
 #include <boost/serialization/hash_collections_load_imp.hpp>
 #undef __MWERKS__

 #include <boost/serialization/hash_map.hpp>
 }}}

 Thanks for your time.
 -Martín

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3234>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:00 UTC