Boost logo

Boost :

Subject: Re: [boost] Interest in serialization library
From: iwg molw5 (iwg.molw5_at_[hidden])
Date: 2012-12-28 02:30:38

On Thu, Dec 27, 2012 at 11:23 PM, Emil Dotchevski

> 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.
> _______________________________________________
> Unsubscribe & other changes:

The library introduces a simple mark-up language used to map common
serialization routines to data members – the two are logically
independent. For example, you may want to serialize x and y as
members of a bit field:

  struct Object : serializable <Object,
      bit_field <little_endian <uint16_t>,
          value <NAME(“x”), bit_value <4, uint32_t>>,
          value <NAME(“y”), bit_value <10, uint32_t>>>

The specification above should be read as:
  - Provide a word-aligned bit field for the serialization of x and y
  - Read the first 4 bits in the bit field into x, stored as uint32_t
  - Read the next 10 bits in the bit field into y, stored as uint32_t
  - Discard the remaining two bits

Note - I'm still not entirely happy with the bit field implementations
I've put together. The above is intended to be illustrate of the syntax
only - a bit_field wrapper is not yet present in the library.

The value structure above defines the type of x (in this case
uint32_t, or rather a simple wrapper around that type), the remaining
information is used to define the serialization of Object.

Boost list run by bdawes at, gregod at, cpdaniel at, john at