Boost logo

Boost Users :

Subject: [Boost-users] Optional XML serialization
From: Paul (elegant_dice_at_[hidden])
Date: 2010-02-22 02:43:18


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?

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
}

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?

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?

thanks,
Paul



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