00001 #ifndef __CXMLNode__ 00002 #define __CXMLNode__ 00003 00004 #include "../Collections/TCountedPointerArray.hpp" 00005 #include "CXMLAttribute.hpp" 00006 using Exponent::Collections::TCountedPointerArray; 00007 using Exponent::IO::CXMLAttribute; 00008 00009 namespace Exponent 00010 { 00011 namespace IO 00012 { 00030 class CXMLNode : public CCountedObject 00031 { 00033 EXPONENT_CLASS_DECLARATION; 00036 // =========================================================================== 00037 00038 public: 00039 00040 // =========================================================================== 00041 00047 CXMLNode(const CString &name, CXMLNode *parent = NULL); 00048 00052 virtual ~CXMLNode(); 00053 00054 // =========================================================================== 00055 00060 void setParentNode(CXMLNode *parent); 00061 00066 CXMLNode *getParentNode(); 00067 00072 void setNodeName(const CString &name); 00073 00078 const CString &getNodeName() const; 00079 00080 // =========================================================================== 00081 00087 void addAttribute(const CString &name, const CString &value); 00088 00093 void addAttribute(CXMLAttribute *attribute); 00094 00099 long getNumberOfAttributes() const; 00100 00106 CXMLAttribute *getAttribute(const long index); 00107 00113 CXMLAttribute *getAttribute(const CString &name); 00114 00120 const CXMLAttribute *getConstAttribute(const long index) const; 00121 00127 const CXMLAttribute *getConstAttribute(const CString &name) const; 00128 00133 CString getValueOfAttributeNamed(const CString &name); 00134 00139 void removeAttribute(CXMLAttribute *attribute); 00140 00145 void removeAttribute(const CString &name); 00146 00150 void clearAttributes(); 00151 00152 // =========================================================================== 00153 00158 void addChildNode(CXMLNode *node); 00159 00164 void addChildNode(const CString &name); 00165 00170 long getNumberOfChildNodes() const; 00171 00177 const CXMLNode *getConstChildNode(const long index) const; 00178 00184 const CXMLNode *getConstChildNode(const CString &name) const; 00185 00191 const CXMLNode *getConstFirstChildNode(const CString &name) const; 00192 00198 CXMLNode *getChildNode(const long index); 00199 00205 CXMLNode *getChildNode(const CString &name); 00206 00212 CXMLNode *getFirstChildNode(const CString &name); 00213 00218 void removeChildNode(CXMLNode *node); 00219 00224 void removeChildNode(const CString &name); 00225 00229 void clearChildNodes(); 00230 00231 // =========================================================================== 00232 00233 protected: 00234 00235 // =========================================================================== 00236 00237 CString m_name; 00238 TCountedPointerArray<CXMLAttribute> m_attributes; 00239 CXMLNode *m_parentNode; 00240 TCountedPointerArray<CXMLNode> m_children; 00241 }; 00242 } 00243 } 00244 00245 #endif // End of CXMLNode.hpp