Boost logo

Boost Users :

Subject: [Boost-users] [Serialization] Questions / Comments
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2009-07-16 14:16:12


After having used the serialization library for quite a while, it seems that
I'm approaching a point where I are seeing lots duplicate code which could
be inside a serialization function. In turn, this head lead me to some
questions / comments.

The use of serialization in my case is both file and network oriented. This
means reading and writing a great deal of short-lived archives. Works fine
in between c++ programs, but outside that it's quickly becoming an
infeasible task. Creating a custom archive could be an option, however, I
would need to spend serious time on understanding the code due to the heavy
use of macros.

The question to be answered first is whether the current serialization
architecture is able to fulfill my needs, or whether I should consider using
other options. Considering the following two scenarios / questions:

1) Suppose I would like to create a custom XML archive which can both read
shuffled XML data (its attributes/values in arbitrary order), and serialize
to child attributes as well as named child nodes.

Currently, name-value pairs are in the Serializable concept. I think they
belong in the Archive Concept. Otherwise, it may be impossible to read XML-
formatted data where the nodes are not in the same order as in the C++ code?

In addition, suppose serializing a program structure is like a tree or
graph, then name-value-pairs do not allow for any other nesting than the C++
code (i.e., it assumes everything is a child node). To allow for making
distinction between nesting levels, one could think of, e.g.,

template< typename Archive >
void serialize( Archive& ar, const unsigned int version ) {
  ar.serialize_node( "subtree", m_contained_class );
  ar.serialize_attribute( "use_count", m_int );
}

Is something like this possible? To this end, would it be possible to plug-
in another parser, e.g., RapidXML?

2) I would like to create an archive that speaks the Action Message Format
(AMF). Although I do have trouble finding a clear distinct parsing layer in
the archives, I think this is possible to do. However, perhaps you think
archive/serialization should not be used in conjunction with these kinds of
uses.

Many thanks in advance,
Kind regards,

Rutger ter Borg


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