<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>bakery: Document_XML.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.6 --> <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><a href="classes.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <h1>Document_XML.h</h1><a href="Document__XML_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * Copyright 2000-2002 Murray Cumming</span> <a name="l00003"></a>00003 <span class="comment"> *</span> <a name="l00004"></a>00004 <span class="comment"> * This library is free software; you can redistribute it and/or</span> <a name="l00005"></a>00005 <span class="comment"> * modify it under the terms of the GNU Library General Public</span> <a name="l00006"></a>00006 <span class="comment"> * License as published by the Free Software Foundation; either</span> <a name="l00007"></a>00007 <span class="comment"> * version 2 of the License, or (at your option) any later version.</span> <a name="l00008"></a>00008 <span class="comment"> *</span> <a name="l00009"></a>00009 <span class="comment"> * This library is distributed in the hope that it will be useful,</span> <a name="l00010"></a>00010 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00011"></a>00011 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00012"></a>00012 <span class="comment"> * Library General Public License for more details.</span> <a name="l00013"></a>00013 <span class="comment"> *</span> <a name="l00014"></a>00014 <span class="comment"> * You should have received a copy of the GNU Library General Public</span> <a name="l00015"></a>00015 <span class="comment"> * License along with this library; if not, write to the Free</span> <a name="l00016"></a>00016 <span class="comment"> * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00017"></a>00017 <span class="comment"> */</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#ifndef BAKERY_DOCUMENT_XML_H</span> <a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#define BAKERY_DOCUMENT_XML_H</span> <a name="l00021"></a>00021 <span class="preprocessor"></span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="Document_8h.html">bakery/Document/Document.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include <libxml++/libxml++.h></span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="comment">//Features:</span> <a name="l00026"></a>00026 <span class="comment">//- Read/Write to the Document in terms of XML DOM.</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="comment">//Future features:</span> <a name="l00029"></a>00029 <span class="comment">//- Parse the document from disk instad of memory - This *might* allow for very large documents.</span> <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="keyword">namespace </span>Bakery <a name="l00032"></a>00032 { <a name="l00033"></a>00033 <a name="l00034"></a><a class="code" href="classBakery_1_1Document__XML.html">00034</a> <span class="keyword">class </span><a class="code" href="classBakery_1_1Document__XML.html">Document_XML</a> : <span class="keyword">public</span> Bakery::<a class="code" href="classBakery_1_1Document.html" title="The Document is like the &#39;Model&#39; in the Model-View-Controller framework.">Document</a> <a name="l00035"></a>00035 { <a name="l00036"></a>00036 <span class="keyword">public</span>: <a name="l00037"></a>00037 <a class="code" href="classBakery_1_1Document__XML.html#d524b3721793181db89aab56bccf30f8">Document_XML</a>(); <a name="l00038"></a>00038 <span class="keyword">virtual</span> <a class="code" href="classBakery_1_1Document__XML.html#cd1af4663c66d1d0a511b089b5f81b5d">~Document_XML</a>(); <a name="l00039"></a>00039 <a name="l00040"></a>00040 <span class="comment">//overrides:</span> <a name="l00041"></a>00041 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classBakery_1_1Document__XML.html#c772422b0744e84ef8fb7a1302aada04" title="Allow app to update icons/title bar.">load_after</a>(); <a name="l00042"></a>00042 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classBakery_1_1Document__XML.html#017da73e0f75ff7caae23a99fddc7319" title="overrideable.">save_before</a>(); <a name="l00043"></a>00043 <a name="l00044"></a>00044 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBakery_1_1Document__XML.html#67005d6046acd928b1e037ad763d1f11">set_dtd_name</a>(<span class="keyword">const</span> std::string& strVal); <span class="comment">//e.g. "glom.dtd"</span> <a name="l00045"></a>00045 <span class="keyword">virtual</span> std::string <a class="code" href="classBakery_1_1Document__XML.html#fa2ccbb8819b50d5c94114488dafc574">get_dtd_name</a>() <span class="keyword">const</span>; <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBakery_1_1Document__XML.html#c5852c3d2ff3b5624eccd0a595a58df6">set_dtd_root_node_name</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a>& strVal); <a name="l00048"></a>00048 <span class="keyword">virtual</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a> <a class="code" href="classBakery_1_1Document__XML.html#eb4213bb920171322d1fbec7de0e7443">get_dtd_root_node_name</a>() <span class="keyword">const</span>; <a name="l00049"></a>00049 <a name="l00054"></a>00054 <span class="keywordtype">void</span> <a class="code" href="classBakery_1_1Document__XML.html#e557f228bdc44777f3bcb2fbadd96c3d" title="Whether to add extra whitespace when writing the XML to disk.">set_write_formatted</a>(<span class="keywordtype">bool</span> formatted = <span class="keyword">true</span>); <a name="l00055"></a>00055 <a name="l00061"></a>00061 <span class="keywordtype">void</span> <a class="code" href="classBakery_1_1Document__XML.html#a4d47bdadf3eb27c1ea0d39e7ca5fd93" title="Put each node on its own line and add white space for indenting, even if there are...">add_indenting_white_space</a>(); <a name="l00062"></a>00062 <a name="l00063"></a>00063 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classBakery_1_1Document__XML.html#974122df8b3bed7874a3d897e427aa2e">set_xml</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a>& strXML); <span class="comment">//Parse the XML from the text.</span> <a name="l00064"></a>00064 <span class="keyword">virtual</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a> <a class="code" href="classBakery_1_1Document__XML.html#e5fba64588cea73b816576f5a5556903">get_xml</a>() <span class="keyword">const</span>; <span class="comment">//Get the text for the XML.</span> <a name="l00065"></a>00065 <a name="l00066"></a>00066 <span class="keyword">protected</span>: <a name="l00067"></a>00067 <span class="keyword">static</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a> <a class="code" href="classBakery_1_1Document__XML.html#9a4e94c8d429ea6c100ec34bfe1a1ba7">get_node_attribute_value</a>(<span class="keyword">const</span> xmlpp::Element* node, <span class="keyword">const</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a>& strAttributeName); <a name="l00068"></a>00068 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classBakery_1_1Document__XML.html#5578c2f85fd6dfe6e078f93fe487c66c">set_node_attribute_value</a>(xmlpp::Element* node, <span class="keyword">const</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a>& strAttributeName, <span class="keyword">const</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a>& strValue); <a name="l00069"></a>00069 <a name="l00070"></a>00070 <span class="keyword">static</span> xmlpp::Element* <a class="code" href="classBakery_1_1Document__XML.html#00b2452e8a0b3cdc785f076ce55c64e2">get_node_child_named</a>(<span class="keyword">const</span> xmlpp::Element* node, <span class="keyword">const</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a>& strName); <a name="l00071"></a>00071 <span class="keyword">static</span> xmlpp::Element* <a class="code" href="classBakery_1_1Document__XML.html#8fe7c853c20289762fa6c1400df6f1f9">get_node_child_named_with_add</a>(xmlpp::Element* node, <span class="keyword">const</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a>& strName); <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="keyword">virtual</span> <span class="keyword">const</span> xmlpp::Element* <a class="code" href="classBakery_1_1Document__XML.html#542a51d11bc87571e35715186508de6e">get_node_document</a>() <span class="keyword">const</span>; <span class="comment">//e.g. <glom_document> (root name)</span> <a name="l00074"></a>00074 <span class="keyword">virtual</span> xmlpp::Element* <a class="code" href="classBakery_1_1Document__XML.html#542a51d11bc87571e35715186508de6e">get_node_document</a>(); <span class="comment">//e.g. <glom_document> (root name)</span> <a name="l00075"></a>00075 <a name="l00076"></a>00076 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBakery_1_1Document__XML.html#9833aebcc8601986b587c9022697b94c">Util_DOM_Write</a>(<a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a>& refstrXML) <span class="keyword">const</span>; <a name="l00077"></a>00077 <a name="l00078"></a>00078 <span class="keywordtype">void</span> <a class="code" href="classBakery_1_1Document__XML.html#177ac15ca5857013b9c1bc5cd95f1f45">add_indenting_white_space_to_node</a>(xmlpp::Node* node = 0, <span class="keyword">const</span> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a>& start_indent = <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a>()); <a name="l00079"></a>00079 <a name="l00080"></a><a class="code" href="classBakery_1_1Document__XML.html#a2bef9cb432e9b3055d5ced564b8412f">00080</a> <span class="keyword">typedef</span> <a class="code" href="classBakery_1_1Document.html" title="The Document is like the &#39;Model&#39; in the Model-View-Controller framework.">Bakery::Document</a> <a class="code" href="classBakery_1_1Document.html" title="The Document is like the &#39;Model&#39; in the Model-View-Controller framework.">type_base</a>; <a name="l00081"></a>00081 <a name="l00082"></a>00082 <span class="comment">//XML Parsing bits:</span> <a name="l00083"></a><a class="code" href="classBakery_1_1Document__XML.html#2ace08b1edc2586c5205689b1e072832">00083</a> xmlpp::DomParser <a class="code" href="classBakery_1_1Document__XML.html#2ace08b1edc2586c5205689b1e072832">m_DOM_Parser</a>; <span class="comment">//Could be mutable to allow us to guarantee a root node.</span> <a name="l00084"></a><a class="code" href="classBakery_1_1Document__XML.html#50d289a260edbd9b7dc2160aab9b8429">00084</a> xmlpp::Document* <a class="code" href="classBakery_1_1Document__XML.html#50d289a260edbd9b7dc2160aab9b8429">m_pDOM_Document</a>; <span class="comment">//1-to-1 with the m_DOM_Parser.</span> <a name="l00085"></a>00085 <a name="l00086"></a><a class="code" href="classBakery_1_1Document__XML.html#d550aa14e504b76c28a8f23276a15a32">00086</a> std::string <a class="code" href="classBakery_1_1Document__XML.html#d550aa14e504b76c28a8f23276a15a32">m_strDTD_Name</a>; <a name="l00087"></a><a class="code" href="classBakery_1_1Document__XML.html#1b3f31a78a9e19e6905b02912afa913b">00087</a> <a class="codeRef" doxygen="glibmm_doxygen_tags:" href="classGlib_1_1ustring.html">Glib::ustring</a> <a class="code" href="classBakery_1_1Document__XML.html#1b3f31a78a9e19e6905b02912afa913b">m_strRootNodeName</a>; <a name="l00088"></a><a class="code" href="classBakery_1_1Document__XML.html#7125d90fc2141ec3bb3bb13611d51efb">00088</a> <span class="keywordtype">bool</span> <a class="code" href="classBakery_1_1Document__XML.html#7125d90fc2141ec3bb3bb13611d51efb">m_write_formatted</a>; <a name="l00089"></a>00089 }; <a name="l00090"></a>00090 <a name="l00091"></a>00091 } <span class="comment">//namespace Bakery.</span> <a name="l00092"></a>00092 <a name="l00093"></a>00093 <span class="preprocessor">#endif // BAKERY_DOCUMENT_XML_H</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Mon Dec 8 18:42:35 2008 for bakery by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address> </body> </html>