Boost logo

Boost :

Subject: Re: [boost] Interest in serialization library
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2012-12-28 01:23:04


On Thu, Dec 27, 2012 at 9:39 PM, iwg molw5 <iwg.molw5_at_[hidden]> wrote:
> struct Object : serializable <Object,
> value <NAME("x"), big_endian <uint32_t>>,
> value <NAME("y"), big_endian <uint32_t>>>
> {
> };

A "serialization" library is concerned with writing and reading the
state of objects depending on their type. In general, this is not
equivalent to simply writing and reading of the objects' members.

What you're defining seems to be a dictionary-type of structure:
type-safe map of names to objects. It can be implemented as follows:

struct dictionary;
shared_ptr<dictionary> create_empty_dictionary();

template <class T>
T & bind_element( dictionary &, name const & );

Given a dictionary d, we can create/bind elements it contains:

uint32_t & x=bind_element<uint32_t>(d,name("x"));
uint32_t & y=bind_element<uint32_t>(d,name("y"));

Serialization can then be supported through a separate library (for
example Boost Serialization) in terms of loading and saving dictionary
objects (implemented in terms of loading and saving the types they
contain, according to the serialization library interface.)

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


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