|
Boost : |
From: Ivan Vecerina (ivec_at_[hidden])
Date: 2006-04-22 03:55:16
"Marcin Kalicinski" <kalita_at_[hidden]> wrote in message
news:e2bm6r$pnb$1_at_sea.gmane.org...
:> However, after thinking of how ptree compares to boost::serialization,
: > I can't take away from my mind the idea that someone should
: > assess the possibility to create a boost::serialization archive
: > that reads/writes objects to/from an in-memory ptree.
: > It seems feasible since boost::serialization can i/o to XML.
: >
: > Similarly, we should then be able to use boost::serialization
: > to i/o ptree to an xml file - preferably resulting in the
: > exact same data as if objects had been serialized directly
: > to XML.
:
: I'm really pleased to say I have already done that. It is indeed simple,
: about 100 lines of code for input and output archives. The
implementation of
: ptree_archive class is not first class at the moment (it's rather a
quick
: hack), so I refrain from posting it at the moment.
:
: But please have a look at this sample of how serialization data looks in
: JSON format. To create that I just used write_json() after writing some
: simple C++ data structures to ptree by means of ptree_archive:
Good. As a start this highlights some of the differences between
ptree and s11n - which I didn't think of because I don't use
s11n:
Even though it supports XML, serialization is designed to function
without field names. Adding XML tags is an afterthought, a limping
add-on. The output is less suitable for human editing. At least when
no dynamic typing is involved (e.g. an in-line field of an enclosing
class), I would have hoped that no additional type and version
tags would be needed.
There sure are good reasons for that in s11n, but it does make
the mechanism less suitable for human-editable data files.
And probably also for XML support in general.
I suspect also that the file-read system in s11n is sensitive
to the order in which the fields are created.
It would be great to find a common path between ptree and s11n.
Maybe we will some day.
But it is not reasonable to say that ptree is fully redundant
with existing boost libraries.
Not any more more than regex is redundant with boost::spirit.
Ivan
-- http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk