00001 #ifndef SDXNODE_H 00002 #define SDXNODE_H 00003 00004 #include <list> 00005 #include <string> 00006 00007 #include "SDXNodeContainer.h" 00008 #include "SDXAttribute.h" 00009 00010 namespace SDX { 00011 class ContentHandler; 00012 00016 class Node : public NodeContainer { 00017 public: 00022 Node(std::string name); 00023 00028 Node(Node& other); 00029 00034 Node(Node* other); 00035 00036 ~Node(); 00037 00042 Node* addAttribute(Attribute* attribute); 00048 Node* addAttribute(std::string name, std::string value); 00049 00053 const std::string getName(); 00054 00058 const std::vector<Attribute*> getAttributes(); 00059 00064 const std::vector<Attribute*> getAttributes(std::string attributeName); 00065 00071 Attribute* getAttribute(unsigned int index = 0); 00072 00078 Attribute* getAttribute(std::string attributeName); 00079 00083 const std::vector<Attribute*> getNamedAttributes(); 00084 00088 const std::vector<Attribute*> getUnnamedAttributes(); 00089 00097 template <class T> bool getAttributeValue(T* value, int attributeIndex = 0){ 00098 Attribute* attribute = getAttribute(attributeIndex); 00099 if(!attribute) 00100 return false; 00101 00102 return attribute->getValue(value); 00103 } 00104 00112 template <class T> bool getAttributeValue(T* value, std::string attributeName){ 00113 Attribute* attribute = getAttribute(attributeName); 00114 if(!attribute) 00115 return false; 00116 00117 return attribute->getValue(value); 00118 } 00119 00128 template <class T> bool getNodeAttributeValue(T* value, std::string nodeName, int attributeIndex = 0){ 00129 Node* node = getChild(nodeName); 00130 if(!node) 00131 return false; 00132 00133 return node->getAttributeValue(value, attributeIndex); 00134 } 00135 00141 void sendToContentHandler(ContentHandler* contentHandler, bool onlySendContents = false); 00142 private: 00143 std::string m_name; 00144 std::vector<Attribute*> m_attributes; 00145 }; 00146 } 00147 00148 #endif
1.5.8