Subject: Re: [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-07-01 16:04:43
#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 Development Trunk | Severity: Problem
Keywords: |
-------------------------------------+--------------------------------------
Changes (by nitram.cero@â¦):
* version: Boost 1.37.0 => Boost Development Trunk
Comment:
Ok, I've been investigating a bit more.
Serialization in '''XML''' of nt::wstring (my std::wstring derived class)
as a primitive makes it get loaded by a template instead of an specialized
std::wstring function. And that reads until a space (sometimes including
the end tag).
If I don't define my nt::wstring class as a primitive type, and wrap the
base (std::wstring) as a NVP, then I get a redundant tag
(i.e: <my_value><base>the string</base></my_value>)
Shouldn't be a wrapper to explicitly define that it's unnamed and
shouldn't produce a tags?
or maybe a having a "primitive_string_type" instead of "primitive_type"
that has std::wstring and std::string specialized.
{{{
BOOST_CLASS_IMPLEMENTATION(nt::wstring,
boost::serialization::primitive_type)
}}}
Fails, loads as with a generic template instead of std::wstring specific
{{{
namespace boost { namespace serialization {
template<class Archive>
void serialize(Archive & ar, nt::wstring &s, const unsigned int version)
{
ar & boost::serialization::make_nvp("base",
static_cast<std::wstring &>(s));
}
} } // namespace serialization // namespace boost
}}}
This works but for each string I have a redundant tag just for the base.
For now I'll have it wrapped around "<base>" tags.
I don't know if this trac entry should be of type Bugs or Feature
request... I'll just leave it this way, feel free to change it.
Regards
-MartÃn
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3234#comment:2> 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