Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Document_XML.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2000-2002 Murray Cumming
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the Free
00016  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 #ifndef BAKERY_DOCUMENT_XML_H
00020 #define BAKERY_DOCUMENT_XML_H
00021 
00022 #include "bakery/Document/Document.h"
00023 #include <libxml++/libxml++.h>
00024 
00025 //Features:
00026 //- Read/Write to the Document in terms of XML DOM.
00027 
00028 //Future features:
00029 //- Parse the document from disk instad of memory - This *might* allow for very large documents.
00030 
00031 namespace Bakery
00032 {
00033 
00034 class Document_XML : public Bakery::Document
00035 {
00036 public: 
00037   Document_XML();
00038   virtual ~Document_XML();
00039 
00040   //overrides:
00041   virtual bool load_after();
00042   virtual bool save_before();
00043 
00044   virtual void set_dtd_name(const std::string& strVal); //e.g. "glom.dtd"
00045   virtual std::string get_dtd_name() const;
00046 
00047   virtual void set_dtd_root_node_name(const Glib::ustring& strVal);
00048   virtual Glib::ustring get_dtd_root_node_name() const;
00049 
00053   virtual void set_write_formatted(bool formatted = true);
00054   
00055   virtual bool set_xml(const Glib::ustring& strXML); //Parse the XML from the text.
00056   virtual Glib::ustring get_xml(); //Get the text for the XML.
00057 
00058 protected:
00059   static Glib::ustring get_node_attribute_value(const xmlpp::Element* node, const Glib::ustring& strAttributeName);
00060   static void set_node_attribute_value(xmlpp::Element* node, const Glib::ustring& strAttributeName, const Glib::ustring& strValue);
00061   virtual xmlpp::Element* get_node_child_named(const xmlpp::Element* node, const Glib::ustring& strName) const;
00062   virtual xmlpp::Element* get_node_child_named_with_add(xmlpp::Element* node, const Glib::ustring& strName);
00063 
00064   virtual const xmlpp::Element* get_node_document() const; //e.g. <glom_document> (root name)
00065   virtual xmlpp::Element* get_node_document(); //e.g. <glom_document> (root name)
00066 
00067 
00068   virtual void Util_DOM_Write(Glib::ustring& refstrXML);
00069 
00070   typedef Bakery::Document type_base;
00071 
00072   //XML Parsing bits:
00073   xmlpp::DomParser m_DOM_Parser; //Could be mutable to allow us to guarantee a root node.
00074   xmlpp::Document* m_pDOM_Document; //1-to-1 with the m_DOM_Parser.
00075   
00076   std::string m_strDTD_Name;
00077   Glib::ustring m_strRootNodeName;
00078   bool m_write_formatted;
00079 };
00080 
00081 } //namespace Bakery.
00082 
00083 #endif // BAKERY_DOCUMENT_XML_H

Generated on Tue Jan 4 19:00:07 2005 for bakery by  doxygen 1.3.9.1