Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::serialization problem with own defined primitive type
From: Robert Bielik (robert.bielik_at_[hidden])
Date: 2011-05-30 02:20:43


Hi Robert,

Robert Ramey skrev 2011-05-28 07:45:
> If you look at how serialization of string is implemented inside
> the library (text_primitive), you'll see the it is something like
>
> <string length> <string characters> It has to be something like
> this to avoid "running over". I would think that your implemenation
> would have to have something similar.

With the text archive there is no problem. The problem occurs only when using the XML archive.

I've checked the xml_iarchive_impl::load impl for std::wstring and there it uses an xml_grammar
to parse out the string, which obviously is why that works. So I would need to do something like that.

Unfortunately there is no way to specialize xml_iarchive_impl::load for my string type, nor is there a way to
call xml_oarchive::save and xml_iarchive_impl::load explicitly (for std::wstring) from load/save implementations (when splitting
serialize into load/save) since they're protected.

For now I split serialize of juce::String into load/save and load/save a std::wstring (with the necessary additional tag)

<myString>
    <std_wstring>StringValue</std_wstring>
</myString>

My end goal is to be able to save my string as:

<myString>StringValue</myString>

Any tips towards that end would be greatly appreciated :)

TIA
/Rob


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net