XmlNode.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2008  Anders Hedstrom
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 */
00023 #ifndef _XmlNode_H
00024 #define _XmlNode_H
00025 
00026 #include <string>
00027 #include <libxml/xmlmemory.h>
00028 #include <libxml/parser.h>
00029 #include <map>
00030 
00031 namespace Xmlw {
00032 
00033 class XmlDocument;
00034 
00035 class XmlNode
00036 {
00037 public:
00038         XmlNode() {}
00039         XmlNode(XmlDocument&);
00040         XmlNode(XmlDocument&, const std::string& nodepath);
00041         XmlNode(const XmlNode&, const std::string& nodepath);
00042         XmlNode(xmlDocPtr, xmlNodePtr ptr);
00043         XmlNode(XmlDocument&, xmlNodePtr ptr);
00044         ~XmlNode();
00045 
00046         operator xmlNodePtr() const;
00047         XmlNode operator[](const std::string& name) const;
00048         operator std::string() const { return GetContent(); }
00049         void operator++() const;
00050 
00051         xmlDocPtr GetDocument() const { return m_doc; }
00052 
00053         bool Valid() const { return m_current ? true : false; }
00054 
00057         xmlNodePtr GetRootElement() const;
00058 
00060         std::string GetProperty(const std::string& propname) const;
00061         bool PropertyExists(const std::string& propname) const;
00062 
00065         xmlNodePtr GetChildrenNode() const;
00066 
00069         xmlNodePtr GetNextNode() const;
00070 
00072         const std::string& GetNodeName() const;
00074         const std::string& GetContent() const;
00075 
00084         void SetCurrent(xmlNodePtr p) const { m_current = p; }
00085 
00087         xmlNsPtr GetNodeNs() const;
00089         const std::string& GetNodeNsPrefix() const;
00091         const std::string& GetNodeNsHref() const;
00092 
00095         xmlNodePtr GetFirstElement(const std::string& name) const;
00096 
00099         xmlNodePtr GetFirstElement(xmlNodePtr parent,const std::string& name) const;
00100 
00103         xmlNodePtr GetNextElement(xmlNodePtr node,const std::string& name) const;
00104 
00106         std::string FromUtf8(const std::string& ) const;
00107 
00109         bool Exists(const std::string& name) const;
00110 
00112         std::map<std::string, std::string> GetNsMap() const;
00113 
00115         std::map<std::string, std::string> GetNsMapRe() const;
00116 
00117 private:
00118         xmlDocPtr m_doc;
00119         mutable xmlNodePtr m_current;
00120         mutable std::string m_current_name;
00121         mutable std::string m_ns_prefix;
00122         mutable std::string m_ns_href;
00123         mutable std::string m_content;
00124         mutable std::string m_lookup_name;
00125 };
00126 
00127 
00128 }
00129 
00130 #endif // _XmlNode_H

Generated on Sun Feb 10 17:01:02 2008 for xmlw - libxml2 C++ wrapper by  doxygen 1.5.2