Boost logo

Boost Users :

Subject: Re: [Boost-users] Editable XML Serialization
From: michi7x7 (mailing-lists_at_[hidden])
Date: 2010-09-15 15:17:08


  Hi,

> Dear list members,
>
> I guess it's one of the hardest search terms around but I would like
> to know if there is any editable XML serialization provided by Boost
> or other C++ libraries. And I don't mean the kind of thing that
> requires you to go jumping around through trees, with iterators etc. I
> don't want to see any iterator!
>

I thought of something like this too. Actually, a specific XML-Format
could easily be implemented using boost.spirit:

qi::rule<iterator_t, data_t> = lit("<xml>") >> lit("<data1>") >> double_
>> lit("</data1>") >> lit("<data2>") >> int_ >> lit("</data2>") >>
lit("</xml>");

This way, you could define your own XML-based-grammar which then gets
parsed into structs. Thats enough for most applications IMO.
But this syntax is ugly, by writing own spirit-parsers, the syntax might
look like this:

qi::rule<iterator_t, data_t> = node("xml") [ node("data1") [double_] >>
node("data2") [double_] ];

Spirit will also complain if the format is unexpected, and throw an
exception containing an iterator pointing to the faulty position.

Is this enough for you? (You might want to take a look at spirit, to
understand what's going on here)

>
> It would be so great if there is something like this in which the XML
> files can actually be edited! I am almost sure that there should be
> something like that, but I can't find it.
You can edit the file by using a karma-rule that works exactly like the
qi::rule, but is used for output instead. Spirit is very fast, probably
faster than editing the XML and saving it using another xml-library.

Regards,

michi7x7


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