Boost logo

Boost Users :

From: Scott Howlett (boost_at_[hidden])
Date: 2008-04-27 14:20:55


Hello,

In a recent post, I asked whether it was possible to swap deserialized
pointer values for already-existing ones so I could merge the incoming
data with objects already in memory. I guess the answer is no...

An alternative is to serialize some other identifier instead of writing
pointers, and then on de-serialization I find my existing objects via
those identifiers. This works fine, but it leads to another question:

How do I make my internal objects available to the deserialization
routines so that they have an opportunity to look up the necessary
information? Or more generally, How do I do stateful serialization /
deserialization? For example, maybe I want to supply options that
fine-tune how my data is serialized or deserialized.

The only parameter that is passed around to all the serialization
functions is the Archive, so if I want to add options or other context
information, it seems like I should add this to the Archive. That's
simple enough to do; I just made a wrapper Archive that can sit atop any
other Archive and contain any other options / context data I need.

On the one hand it seems sneaky to hijack the Archive for this purpose,
but on the other hand iostreams do basically the same thing via the
various ios_base calls (setf, width, precision, etc.) so maybe it's not
so bad.

Am I perhaps overlooking some facility already present in the
serialization library?

Thanks,
Scott


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