Re:[boost] serialization request

Russell Balest wrote
My request is support for xml <!-- comments --> in the serialization xml archive. I believe it currently chokes if I add a comment in an xml archive.
The application is for QA to compose test objects in xml and then read them into applications with boost serialization. It would be nice to annotate the test object 'templates' with comments so QA can know what values are valid.
Does someone know where in the code I can implement this easily. I just want to ignore the comments.
Hmmm - my question is: What program is generating the XML archive in the first place? It its being generated by something other than the serialization library itself, its not going to be easy to generate such an archive that is guaranteed to be compatible with the C++ data structures of the reading program. (The organization of the data in the C++ program is what dicates the XML schema). At best it would be a maintenance pain in the neck to keep the reading program based on serialization in sync with some other program that doesn't use serialization to generate the XML archive. On the other hand, if the original XML archive is generated by the serialization library and just modified with comments, your request is very easy to accommodate. Just create a use the following in your serialize functions: Template<class Archive> Void serialize(Archive, my_class & t){ std::string comment; ar & BOOST_NVP("comment", comment); ar & BOOST_NVP("myclass_data", t);; } In which case your XML output will look like: ... <comment></comment> <myclass_data>..contents of t</myclass_data> ... After the archive is created you can edit the space between <comment> and </comment> with anything you want - it would be just thrown away. Generally I wouldn't encourage the practice of editing an archive but in this circumstance I could see it as an acceptable practice. But then this raises the question if the comments are so important, why are they being thrown them away? Shouldn't they be data read by the program? Robert Ramey

Robert Ramey wrote:
Russell Balest wrote
My request is support for xml <!-- comments --> in the serialization xml archive. I believe it currently chokes if I add a comment in an xml archive.
The application is for QA to compose test objects in xml and then read them into applications with boost serialization. It would be nice to annotate the test object 'templates' with comments so QA can know what values are valid.
Does someone know where in the code I can implement this easily. I just want to ignore the comments.
Hmmm - my question is: What program is generating the XML archive in the first place?
It's generated by the boost serialization library. At that point, we effectively have an XML configuration file that is used as an input to another program, again via boost serialization. Think of something like the Apache config file if you're familiar with it. The main reason I was drawn to the boost serialization is that a QA person will be able to edit this XML file with an editor and create new test configurations, as long as they just change data and don't mess with the schema. Since it's now basically being viewed as a configuration file, comments would of course be nice. The data structures I'm dealing with typically contain 10 or 30 C++ classes and can be 3-5 layers deep in nesting. They're very big and it's too labor intensive for a QA'er (apparently) to compose them in C++ code. We also have a hundred different data structures of this type. They want this ability.
On the other hand, if the original XML archive is generated by the serialization library and just modified with comments, your request is very easy to accommodate. Just create a use the following in your serialize functions:
Template<class Archive> Void serialize(Archive, my_class & t){ std::string comment; ar & BOOST_NVP("comment", comment); ar & BOOST_NVP("myclass_data", t);; }
In which case your XML output will look like:
... <comment></comment> <myclass_data>..contents of t</myclass_data> ...
Good idea. I'll probably do that.
After the archive is created you can edit the space between <comment> and </comment> with anything you want - it would be just thrown away. Generally I wouldn't encourage the practice of editing an archive but in this circumstance I could see it as an acceptable practice.
But then this raises the question if the comments are so important, why are they being thrown them away? Shouldn't they be data read by the program?
The same data structures are being used in 2 separate contexts: the production system sends binary data around and doesn't care about comments or xml, but the development environment is migrating to use xml and involve QA more. A side note - the serialization itself is not being tested in this case. What's being tested is the behavior of the programs when they receive various ranges of data or combinations of (maybe internally inconsistent) data. Thanks for the suggestion, Russell
Robert Ramey
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Robert Ramey wrote:
Russell Balest wrote
Does someone know where in the code I can implement this easily. I just want to ignore the comments.
easy to accommodate. Just create a use the following in your serialize functions:
Template<class Archive> Void serialize(Archive, my_class & t){ std::string comment; ar & BOOST_NVP("comment", comment); ar & BOOST_NVP("myclass_data", t);; }
In which case your XML output will look like:
... <comment></comment> <myclass_data>..contents of t</myclass_data> ...
Good idea. I'll probably do that.
Another approach would be to preprocess your input files and strip the added comments using XSLT, perl, or a simple regex program. That way you don't have to modify the data structures under test. Jeff
participants (3)
-
Jeff Garland
-
Robert Ramey
-
Russell Balest