00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _XmlNode_H
00034 #define _XmlNode_H
00035
00036 #include "sockets-config.h"
00037
00038 #ifdef ENABLE_XML
00039
00040 #include <string>
00041 #include <libxml/xmlmemory.h>
00042 #include <libxml/parser.h>
00043 #include <map>
00044
00045 #ifdef SOCKETS_NAMESPACE
00046 namespace SOCKETS_NAMESPACE {
00047 #endif
00048 namespace Xml {
00049
00050 class XmlDocument;
00051
00052 class XmlNode
00053 {
00054 public:
00055 XmlNode() {}
00056 XmlNode(XmlDocument&);
00057 XmlNode(XmlDocument&, const std::string& nodepath);
00058 XmlNode(const XmlNode&, const std::string& nodepath);
00059 XmlNode(xmlDocPtr, xmlNodePtr ptr);
00060 XmlNode(XmlDocument&, xmlNodePtr ptr);
00061 ~XmlNode();
00062
00063 operator xmlNodePtr() const;
00064 XmlNode operator[](const std::string& name) const;
00065 operator std::string() const { return GetContent(); }
00066 void operator++() const;
00067
00068 xmlDocPtr GetDocument() const { return m_doc; }
00069
00070 bool Valid() const { return m_current ? true : false; }
00071
00074 xmlNodePtr GetRootElement() const;
00075
00077 std::string GetProperty(const std::string& propname) const;
00078 bool PropertyExists(const std::string& propname) const;
00079
00082 xmlNodePtr GetChildrenNode() const;
00083
00086 xmlNodePtr GetNextNode() const;
00087
00089 const std::string& GetNodeName() const;
00091 const std::string& GetContent() const;
00092
00101 void SetCurrent(xmlNodePtr p) const { m_current = p; }
00102
00104 xmlNsPtr GetNodeNs() const;
00106 const std::string& GetNodeNsPrefix() const;
00108 const std::string& GetNodeNsHref() const;
00109
00112 xmlNodePtr GetFirstElement(const std::string& name) const;
00113
00116 xmlNodePtr GetFirstElement(xmlNodePtr parent,const std::string& name) const;
00117
00120 xmlNodePtr GetNextElement(xmlNodePtr node,const std::string& name) const;
00121
00123 bool Exists(const std::string& name) const;
00124
00126 std::map<std::string, std::string> GetNsMap() const;
00127
00129 std::map<std::string, std::string> GetNsMapRe() const;
00130
00131 const std::string FindProperty(const std::string& propname, bool climb = false) const;
00132
00133 private:
00134 xmlDocPtr m_doc;
00135 mutable xmlNodePtr m_current;
00136 mutable std::string m_current_name;
00137 mutable std::string m_ns_prefix;
00138 mutable std::string m_ns_href;
00139 mutable std::string m_content;
00140 mutable std::string m_lookup_name;
00141 };
00142
00143
00144 }
00145 #ifdef SOCKETS_NAMESPACE
00146 }
00147 #endif
00148
00149 #endif // ENABLE_XML
00150 #endif // _XmlNode_H