Boost logo

Boost Users :

Subject: Re: [Boost-users] Automating Serialization?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-11-26 17:59:08


On Thu, Nov 26, 2009 at 5:05 AM, Bilokon, Paul <paul.bilokon_at_[hidden]> wrote:
> Hi,
>
> By design Boost Serialization requires the user to list each field that
> needs to be serialised.
>
> This is in contrast, for example, with Java and some other languages where
> serialisation is supported (kind of) at the language level.

No, Paul, C++ has no reflection and the reason is that unlike Java it
does not define ABI. Consider that in C++ not only the size of the
built-in types is not standardized, but even some operations have
"implementation-defined" semantics.

> The current approach requires some code duplication. We have to declare a
> field. We have to manually (de)serialise it. If we need to make a change, we
> make it in at least two distinct places.

You are thinking in terms of reflection. Think in terms of states and
invariants and it'll make more sense. For example, if you have an
array of items and a pointer, and your invariant is that the pointer
always points the last element in the array, the pointer should not be
serialized.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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