How to dump or restore a CLAM::Component in XML format. More...
Classes | |
class | CLAM::XmlStorage |
Provides XML format storage for CLAM Component's. More... |
How to dump or restore a CLAM::Component in XML format.
Any class that derives from Component can be dumped and restored in XML (http://www.w3.org/XML) format. Components includes Arrays, DynamicType, ProcessingConfig, ProcessingData...
In its simplest usage, you can use the static functions Dump and Restore.
MyComponent myComponent; // Here you can modify your Component CLAM::XmlStorage::Dump(myComponent, "Document", "MyComponent.xml")
Later you can restore the component:
// An unmodified default constructed object!!! MyComponent comp; try { CLAM::XmlStorage::Restore(comp, "mycomponent.xml"); } catch (CLAM::XmlStorageErr & err) { // Handle the error, a dirty way could be: std::cerr << err.what() << std::endl; exit(-1); }
Dump and Restore are overloaded to accept any C++ stream instead of a filename. So, you can also write:
MyComponent myComponent; CLAM::XmlStorage::Dump(myComponent, "Document", std::cout)
You can the AppendToDocument static function to add an object in a given path of an existing XML file, or using RestoreFromFragment to restore the object taking an XML fragment.
Catchable exceptions (CLAM::XmlStorageErr) are thrown on the following conditions: