Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-12-05 01:11:38


Robert Ramey wrote:
>>   binary_oarchive oa(...);
>>   Data data(....);
>>   oa << data;
>
>>Now, how do I deserialize it? I can't write
>
>>   Data data;
>>   ia >> data;
>
>>Since ctor is private. I would guess it's still possible to deserialize
>>this class, but I don't know how.
>
> what's the matter with
>
>    Data data(....);
>    ia >> data;

The wrong is that when I create and serialize data, I have something to pass
as ctor parameter. But when deserializing, I don't have that something.
Let's be more specific: the ctor parameter includes parse tree. I can't
serialize it because it requires lots of work.

> I don't see how the fact you want to construct different ways is related
> serialization.  Unless its a pointer, serialization presumes the
> instance has already been constructed.  How this is done is
> outside the influence of the serialization library.

What I'm after it telling to serialization lib: "hey, I know this data was
not serialized via pointer, but I want to restore it into pointer variable,
so that serialization lib creates it itself".

Specifically, I look at this code from collection_load_imp.hpp:

   stack_allocate<type> t;^M
   load_construct_data(ar, t.address(), 0U);^M
   ar >> make_nvp("item", t.reference());^M
   
Can the same trick be use from user code?

I'm not all all sure it's better than saving Data as pointer in the first
place, but I'm exploring possibilities.

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk