
Robert Ramey
Anne van Rossum wrote:
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 really iike the XML serialization method that boost::serialization provides:
A rich subject which comes up from time to time. Here are a few miscelleaneous observations.
a) Most of the time what people want when they ask this question is
xml_in >> my data structure for some arbitrarily defined structure. Of course after you become familiar with the library, it's easy to see that this is not possible. It's annoying to me how often this is stated as a failing of the library.
What I want "at the C++ side" so to say, is just the same as with boost::serialization. That supports already "custom" data structures, because in the serialize(Archive & ar,...) routine it is possible to define what fields to write/read. I am not talking about marshalling / unmarshalling to entire objects. Serializing arbitrary data structures does not make sense to me. However, I am not familiar with the library, so perhaps I misunderstood you. Forgive me, I just encountered it today.
b) It is possble to so some limited editing of xml (or other archives) but this would be an ad hoc procedure subject to errors. you might change a value here and there but the minute you change something tracked or add a value to a collection or whatever, you're not going to be able to keep things consistent. I guess you're familiar with this.
Yes.
I've thought about this alot. Here are some ideas that I thought about.
a) create an xml_archive along with an xml schema which would be friendly with known xml editors. I thought about this alot an concluded that it would be too much like training an ant to train a flea. I don't think it would be possible to make a bunch of rules that an xml editor could follow and guarentee that that the resulting C++ data object would be correct. Even it were possible, one would likely have to add a bunch of "helper" information to get it right. It would be hard to use, easy to misuse, and a maintainence (and support) nightmare.
So what I want to do is to make the following:
edit_oarchive
edit_iarchive The usage would be the following:
edit_archive
ea ... ea << my_data
That's a solution. I would then need to distribute a separate binary to manipulate the XML files. My idea was to "misuse" boost::serialization for writing XML configuration files without the need to manually build DOM-like structures. For just changing configuration parameters, a graphical solution might be a bit cumbersome. It's a nice idea nevertheless!
Robert Ramey
Anne