Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::serialization problem with own defined primitive type
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-05-28 01:45:27


Robert Bielik wrote:
> Robert Bielik skrev 2011-05-25 18:52:
>> I've tried to define operator >> & << in order to make a
>> juce::String serializable in the same manner as a std::wstring. Here is
>> the question thread on
>> StackOverflow:
>> http://stackoverflow.com/questions/6126133/boost-deserialization-problem-of-jucestring-with-xml-wide-archive
>>
>> Any ideas what might be wrong ? Thing is (as I say in the thread
>> above), that it _has_ worked and I obviously have made a change but
>> 2 hours of checking SVN repo diffsets I cannot find it.
>
> Really? No one?
>
> /Rob

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.

And there's another problem. Your saving as one type (pointer to a wide
char
and loading a different type - a std::wstring. Not guarenteed to
work though some times you could get lucky. Also this will break
the machinery used to restore pointers.

if you can't do just

ar << wstring

and

ar >> wstring

You'll have to digg for the cause. I believe this is explictly tested in
one of the tests for the library. Look through the tests and verify
that it is in fact implemented.

Robert Ramey


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