Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-11-07 21:37:30


> I really considered boost::serialization for that binding library,
> but I found the NVP-system not flexible enough to represent all xml
> possibilities. As far as I understood, every complex type gets
> converted
> into an xml node, while every primitive leaf type get converted into
> an attribute. That restriction is too hard to represetnt the full xml
> format space. E.g the model
> struct some_node { std::vector<int> data; };
> could be encoded like this:
> <some_node >
> <data value="1"/>
> <data value="41"/>
> <data value="2"/>
> <data value="9"/>
> </some_node>
> or:
> <some_node >
> <data>1</data>
> <data>41</data>
> <data>2</data>
> <data>9</data>
> </some_node>

That's not quite correct, in the current xml_archives, all primitives are
tagged as well.
The only things that are attributes are the "extra" things that that the
serialization
library needs to reconstruct the C++ structures. (class_id and object_id
index, etc).
In the course of implementing this, it became apparent to me that that there
were
lots of ways it could be done and still be valid XML. I just decided more
or less arbitrarily what should go as attributes and what should go as
tagged data.
Someone else might want it done differently, in which case he would have
to make his own implementation of xml_archive.

> To extend the binding idea one might add the possiblity to map only a
> certain view on the XML format onto these C++ structures.
>
>> I'm NOT exactly sure what you have in mind, but I can see the need for a
>> program which reads and xml schema and generates C++ data structures
>> which can be navigated with previously compiled code modules. I think
>> this
>> would be fairly easily achieved using spirit xml parsing.

> Aggreed. My binding library used libxml2 and later expat for parsing,
> but I initially planed to use spirit as backend.

Robert Ramey


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