Dumping and Restoring objects on XML

How to dump or restore a CLAM::Component in XML format. More...


class  CLAM::XmlStorage
 Provides XML format storage for CLAM Component's. More...

Detailed Description

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...

XML storage is a very expensive task when dealing with big amounts of numeric data.

Dumping and restoring a component in XML

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;
        CLAM::XmlStorage::Restore(comp, "mycomponent.xml");
 catch (CLAM::XmlStorageErr & err)
        // Handle the error, a dirty way could be:
        std::cerr << err.what() << std::endl;

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:

David Garcia.
Generated by  doxygen 1.6.3