
Paul wrote:
Hi,
I use xml_woarchive and xml_wiarchive for reading/writing configuration files.
It seems work work well for me, but now I'd like to see if I can do more with it... is it possible to load an XML serialized file, but completely IGNORE a subtree of the XML file if desired?
Anything is possible if you're willing to change the code that's in there.
eg template <class Archive> void load( Archive & ar, MyConfig & c, const unsigned int version ) { ar >> make_nvp("standard",c.standard); if (some_global_flag_or_whatever) ar >> make_nvp("advanced", c.advanced); else ar.skip("advanced"); // key bit }
Something like the following might be made to work. ar >> c.standard if(flag) ar >> c.advanced else{ Advanced a; // to be thrown away ar >> a } But you would have to start thinking about issues such as tracking. That is if you throw away something that is tracked and referred to somewhere else then it would be a problem. In general, I can't predict the consequences of such code.
The motivation is that I want to "register modules" (in my app) that can read/write their configuration in an XML configuration file. But if the module is not registered, I want to skip that part of the configuration file and move on. I figure since the XML format is like a tree, it might/should be possible to ignore an entire segment of the tree.
Is it possible?
That's what the above would do.
In a related note, the "class_id" bits in xml archives seems to make it difficult for users to hand-edit the XML file... Are these tags required?
In general, we don't include anything in the archive unless it has to be there to recover the data.
thanks, Paul
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users