<!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"/> <title>The Gnome Chemistry Utils: gcu::Loader Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="classes.html"><span>Class Index</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="namespacegcu.html">gcu</a>::<a class="el" href="classgcu_1_1Loader.html">Loader</a> </div> </div> <div class="contents"> <h1>gcu::Loader Class Reference</h1><!-- doxytag: class="gcu::Loader" --> <p>class used to implement serialization engines. <a href="#_details">More...</a></p> <p><code>#include <<a class="el" href="loader_8h_source.html">gcu/loader.h</a>></code></p> <p><a href="classgcu_1_1Loader-members.html">List of all members.</a></p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#a69799b1df7ba819a59923023886a1ce6">Loader</a> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#a7fd44366c449021558b3dffa7157aef3">~Loader</a> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#ac7bf5f4ede3bfd9be1390e7cf949d140">Read</a> (<a class="el" href="classgcu_1_1Document.html">Document</a> *doc, GsfInput *in, char const *mime_type, IOContext *io)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#acee683aa2f1b76dea9e793dc1f609413">Write</a> (<a class="el" href="classgcu_1_1Document.html">Document</a> *doc, GsfOutput *out, char const *mime_type, IOContext *io)</td></tr> <tr><td colspan="2"><h2>Static Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#aeccea675f75e66a6aa930ec92bfb624c">Init</a> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#aeef5ea41aacf0f7b95ac3c965737535b">GetFirstLoader</a> (std::map< std::string, <a class="el" href="structgcu_1_1LoaderStruct.html">LoaderStruct</a> >::iterator &it)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#ad2ad56c39863ec7b82959b79b9479303">GetNextLoader</a> (std::map< std::string, <a class="el" href="structgcu_1_1LoaderStruct.html">LoaderStruct</a> >::iterator &it)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classgcu_1_1Loader.html">Loader</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#aa77a287a17dee7ec63008b8cbaaf195d">GetLoader</a> (char const *mime_type)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classgcu_1_1Loader.html">Loader</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#a53c5dba360861091155b645c9db83b32">GetSaver</a> (char const *mime_type)</td></tr> <tr><td colspan="2"><h2>Protected Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#ac972a854361fe7430a7cd7b2cf2bab57">AddMimeType</a> (const char *mime_type)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#a5d75ed95d04deae7a80e21e958c5f27d">RemoveMimeType</a> (const char *mime_type)</td></tr> <tr><td colspan="2"><h2>Protected Attributes</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">std::list< std::string > </td><td class="memItemRight" valign="bottom"><a class="el" href="classgcu_1_1Loader.html#af8b3620a51ddd6ee9359b57e4d26cb65">MimeTypes</a></td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>class used to implement serialization engines. </p> <p>This class is used to load and save files of various types, using the <a class="el" href="classgcu_1_1Object.html">gcu::Object</a> framework. Derived classes should be implemented in plugins, using the goffice plugins API. When <a class="el" href="classgcu_1_1Loader.html#aeccea675f75e66a6aa930ec92bfb624c">Loader::Init</a> is called, the framework collects informations about the services exposed by each plugin in XML files. For the CDX file loader plugin, the corresponding plugin.xml.in file content is:</p> <div class="fragment"><pre class="fragment"><?xml version=<span class="stringliteral">"1.0"</span> encoding=<span class="stringliteral">"UTF-8"</span>?> <plugin <span class="keywordtype">id</span>=<span class="stringliteral">"GCULoader_cdxml"</span>> <information> <_name><a class="code" href="classgcu_1_1Loader.html#a69799b1df7ba819a59923023886a1ce6">Loader</a> : cdxml</_name> <_description>Chemdraw XML files loader.</_description> </information> <loader type=<span class="stringliteral">"Gnumeric_Builtin:module"</span>> <attribute name=<span class="stringliteral">"module_file"</span> value=<span class="stringliteral">"cdxml"</span>/> </loader> <services> <service type=<span class="stringliteral">"chemical_loader"</span> <span class="keywordtype">id</span>=<span class="stringliteral">"GCULoader_cdxml"</span>> <mime_type name=<span class="stringliteral">"chemical/x-cdxml"</span> capabilities=<span class="stringliteral">"r"</span> scope=<span class="stringliteral">"2"</span>/> <information> <_description>Chemdraw XML files loader</_description> </information> </service> </services> </plugin> </pre></div><p>In the present context, the important node is the mime type related one. Its attributes are:</p> <ul> <li>name: the mime type.</li> <li>capabilities: what is supported: r for reading, w for writing. Both "rw" and "wr" are valid.</li> <li>scope: 2 and 3 mean 2D and 3D structures, repectively, c means crystal structure, and s, spectra . Any combination might be used.</li> </ul> <p>Other fields are standard in the goffice world. The plugin is loaded only when needed.</p> <p>Each plugin should implement at least one derived class and a static instance of this class. The CDX loader has:</p> <div class="fragment"><pre class="fragment"><span class="keyword">class </span>CDXLoader: <span class="keyword">public</span> gcu::<a class="code" href="classgcu_1_1Loader.html#a69799b1df7ba819a59923023886a1ce6">Loader</a> { <span class="keyword">public</span>: CDXLoader (); <span class="keyword">virtual</span> ~CDXLoader (); <span class="keywordtype">bool</span> <a class="code" href="classgcu_1_1Loader.html#ac7bf5f4ede3bfd9be1390e7cf949d140">Read</a> (Document *doc, GsfInput *in, <span class="keywordtype">char</span> <span class="keyword">const</span> *mime_type, IOContext *io); <span class="keywordtype">bool</span> <a class="code" href="classgcu_1_1Loader.html#acee683aa2f1b76dea9e793dc1f609413">Write</a> (Document *doc, GsfOutput *out, <span class="keywordtype">char</span> <span class="keyword">const</span> *mime_type, IOContext *io); <span class="keyword">private</span>: ... }; ... static CDXLoader loader; </pre></div> <p>Definition at line <a class="el" href="loader_8h_source.html#l00147">147</a> of file <a class="el" href="loader_8h_source.html">loader.h</a>.</p> <hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="a69799b1df7ba819a59923023886a1ce6"></a><!-- doxytag: member="gcu::Loader::Loader" ref="a69799b1df7ba819a59923023886a1ce6" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">gcu::Loader::Loader </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>The constructor. Derived class need to call <a class="el" href="classgcu_1_1Loader.html#ac972a854361fe7430a7cd7b2cf2bab57">Loader::AddMimeType</a> for each mime type they support. </p> </div> </div> <a class="anchor" id="a7fd44366c449021558b3dffa7157aef3"></a><!-- doxytag: member="gcu::Loader::~Loader" ref="a7fd44366c449021558b3dffa7157aef3" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual gcu::Loader::~Loader </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>The destructor Derived class should call <a class="el" href="classgcu_1_1Loader.html#a5d75ed95d04deae7a80e21e958c5f27d">Loader::RemoveMimeType</a> for each mime type they support. </p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="ac972a854361fe7430a7cd7b2cf2bab57"></a><!-- doxytag: member="gcu::Loader::AddMimeType" ref="ac972a854361fe7430a7cd7b2cf2bab57" args="(const char *mime_type)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void gcu::Loader::AddMimeType </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"> <em>mime_type</em></td> <td> ) </td> <td><code> [protected]</code></td> </tr> </table> </div> <div class="memdoc"> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>mime_type</em> </td><td>a mime type.</td></tr> </table> </dd> </dl> <p>Registers a mime type and stores the instance calling it as the <a class="el" href="classgcu_1_1Loader.html" title="class used to implement serialization engines.">Loader</a> for this mime type. </p> </div> </div> <a class="anchor" id="aeef5ea41aacf0f7b95ac3c965737535b"></a><!-- doxytag: member="gcu::Loader::GetFirstLoader" ref="aeef5ea41aacf0f7b95ac3c965737535b" args="(std::map< std::string, LoaderStruct >::iterator &it)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static bool gcu::Loader::GetFirstLoader </td> <td>(</td> <td class="paramtype">std::map< std::string, <a class="el" href="structgcu_1_1LoaderStruct.html">LoaderStruct</a> >::iterator & </td> <td class="paramname"> <em>it</em></td> <td> ) </td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>it</em> </td><td>a std::map iterator.</td></tr> </table> </dd> </dl> <p>Must be called to access the first <a class="el" href="structgcu_1_1LoaderStruct.html">LoaderStruct</a> instance. When successful the iterator can be used to retrieve both the mime type ((*it).first), and the corresponding <a class="el" href="structgcu_1_1LoaderStruct.html">LoaderStruct</a> ((*it).second) </p> <dl class="return"><dt><b>Returns:</b></dt><dd>true if successful, false otherwise. </dd></dl> </div> </div> <a class="anchor" id="aa77a287a17dee7ec63008b8cbaaf195d"></a><!-- doxytag: member="gcu::Loader::GetLoader" ref="aa77a287a17dee7ec63008b8cbaaf195d" args="(char const *mime_type)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static <a class="el" href="classgcu_1_1Loader.html">Loader</a>* gcu::Loader::GetLoader </td> <td>(</td> <td class="paramtype">char const * </td> <td class="paramname"> <em>mime_type</em></td> <td> ) </td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>mime_type</em> </td><td>a mime type. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>the <a class="el" href="classgcu_1_1Loader.html" title="class used to implement serialization engines.">Loader</a> instance able to read the mime type if any. </dd></dl> </div> </div> <a class="anchor" id="ad2ad56c39863ec7b82959b79b9479303"></a><!-- doxytag: member="gcu::Loader::GetNextLoader" ref="ad2ad56c39863ec7b82959b79b9479303" args="(std::map< std::string, LoaderStruct >::iterator &it)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static bool gcu::Loader::GetNextLoader </td> <td>(</td> <td class="paramtype">std::map< std::string, <a class="el" href="structgcu_1_1LoaderStruct.html">LoaderStruct</a> >::iterator & </td> <td class="paramname"> <em>it</em></td> <td> ) </td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>it</em> </td><td>a std::map iterator initialized by <a class="el" href="classgcu_1_1Loader.html#aeef5ea41aacf0f7b95ac3c965737535b">Loader::GetFirstLoader</a></td></tr> </table> </dd> </dl> <p>Gets the next LoderStruct and its associated mime type. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>true if successful, false otherwise. </dd></dl> </div> </div> <a class="anchor" id="a53c5dba360861091155b645c9db83b32"></a><!-- doxytag: member="gcu::Loader::GetSaver" ref="a53c5dba360861091155b645c9db83b32" args="(char const *mime_type)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static <a class="el" href="classgcu_1_1Loader.html">Loader</a>* gcu::Loader::GetSaver </td> <td>(</td> <td class="paramtype">char const * </td> <td class="paramname"> <em>mime_type</em></td> <td> ) </td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>mime_type</em> </td><td>a mime type. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>the <a class="el" href="classgcu_1_1Loader.html" title="class used to implement serialization engines.">Loader</a> instance able to write the mime type if any. </dd></dl> </div> </div> <a class="anchor" id="aeccea675f75e66a6aa930ec92bfb624c"></a><!-- doxytag: member="gcu::Loader::Init" ref="aeccea675f75e66a6aa930ec92bfb624c" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static void gcu::Loader::Init </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Initializes the load/save engines system. This must be called before trying to use any loader (no one will be available before, anyway). </p> </div> </div> <a class="anchor" id="ac7bf5f4ede3bfd9be1390e7cf949d140"></a><!-- doxytag: member="gcu::Loader::Read" ref="ac7bf5f4ede3bfd9be1390e7cf949d140" args="(Document *doc, GsfInput *in, char const *mime_type, IOContext *io)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual bool gcu::Loader::Read </td> <td>(</td> <td class="paramtype"><a class="el" href="classgcu_1_1Document.html">Document</a> * </td> <td class="paramname"> <em>doc</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">GsfInput * </td> <td class="paramname"> <em>in</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">char const * </td> <td class="paramname"> <em>mime_type</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">IOContext * </td> <td class="paramname"> <em>io</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>doc</em> </td><td>the <a class="el" href="classgcu_1_1Document.html">gcu::Document</a> being read. </td></tr> <tr><td valign="top"></td><td valign="top"><em>in</em> </td><td>a GsfInput (see the libgsf documentation at <a href="http://library.gnome.org/devel/gsf/stable/gsf-Input-from-unstructured-files.html#GsfInput">http://library.gnome.org/devel/gsf/stable/gsf-Input-from-unstructured-files.html#GsfInput</a>). </td></tr> <tr><td valign="top"></td><td valign="top"><em>mime_type</em> </td><td>the mime type of the data. </td></tr> <tr><td valign="top"></td><td valign="top"><em>io</em> </td><td>a GOffice IOContext.</td></tr> </table> </dd> </dl> <p>This function must be overloaded by a derived class able to read. Default implementation just return false. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>true on success, false otherwise. </dd></dl> </div> </div> <a class="anchor" id="a5d75ed95d04deae7a80e21e958c5f27d"></a><!-- doxytag: member="gcu::Loader::RemoveMimeType" ref="a5d75ed95d04deae7a80e21e958c5f27d" args="(const char *mime_type)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void gcu::Loader::RemoveMimeType </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"> <em>mime_type</em></td> <td> ) </td> <td><code> [protected]</code></td> </tr> </table> </div> <div class="memdoc"> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>mime_type</em> </td><td>a mime type.</td></tr> </table> </dd> </dl> <p>Unregisters a mime type. </p> </div> </div> <a class="anchor" id="acee683aa2f1b76dea9e793dc1f609413"></a><!-- doxytag: member="gcu::Loader::Write" ref="acee683aa2f1b76dea9e793dc1f609413" args="(Document *doc, GsfOutput *out, char const *mime_type, IOContext *io)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual bool gcu::Loader::Write </td> <td>(</td> <td class="paramtype"><a class="el" href="classgcu_1_1Document.html">Document</a> * </td> <td class="paramname"> <em>doc</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">GsfOutput * </td> <td class="paramname"> <em>out</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">char const * </td> <td class="paramname"> <em>mime_type</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">IOContext * </td> <td class="paramname"> <em>io</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>doc</em> </td><td>the <a class="el" href="classgcu_1_1Document.html">gcu::Document</a> being written. </td></tr> <tr><td valign="top"></td><td valign="top"><em>out</em> </td><td>a GsfOutput (see the libgsf documentation at <a href="http://library.gnome.org/devel/gsf/stable/gsf-Output-to-unstructured-files.html#GsfOutput">http://library.gnome.org/devel/gsf/stable/gsf-Output-to-unstructured-files.html#GsfOutput</a>). </td></tr> <tr><td valign="top"></td><td valign="top"><em>mime_type</em> </td><td>the mime type of the data. </td></tr> <tr><td valign="top"></td><td valign="top"><em>io</em> </td><td>a GOffice IOContext.</td></tr> </table> </dd> </dl> <p>This function must be overloaded by a derived class able to write. Default implementation just return false. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>true on success, false otherwise. </dd></dl> </div> </div> <hr/><h2>Member Data Documentation</h2> <a class="anchor" id="af8b3620a51ddd6ee9359b57e4d26cb65"></a><!-- doxytag: member="gcu::Loader::MimeTypes" ref="af8b3620a51ddd6ee9359b57e4d26cb65" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">std::list<std::string> <a class="el" href="classgcu_1_1Loader.html#af8b3620a51ddd6ee9359b57e4d26cb65">gcu::Loader::MimeTypes</a><code> [protected]</code></td> </tr> </table> </div> <div class="memdoc"> <p>The list of supported mime types. </p> <p>Definition at line <a class="el" href="loader_8h_source.html#l00241">241</a> of file <a class="el" href="loader_8h_source.html">loader.h</a>.</p> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="loader_8h_source.html">loader.h</a></li> </ul> </div> <hr size="1"/><address style="text-align: right;"><small>Generated on Sun Sep 6 18:33:55 2009 for The Gnome Chemistry Utils by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>