#include <XMLNode.h>
Public Member Functions | |
CXMLNode (void) | |
CXMLNode (xmlNodePtr node) | |
virtual | ~CXMLNode (void) |
bool | getName (std::string *destination) |
int | getType (void) |
bool | getFirstChildNode (CXMLNode *destination) |
This returns the first child node of this node. | |
bool | getNextSiblingNode (CXMLNode *destination) |
This returns the next sibling node of this node. | |
bool | getNameSpace (CXMLNameSpace *destination) |
bool | hasNameSpace (void) |
bool | getContent (std::string *destination) |
bool | getFirstDescendantByName (const std::string &name, CXMLNode *node) |
Returns the first descendant of this node with the given name. | |
bool | getText (std::string *destination) |
Returns the text of this node. | |
bool | getAttributes (CXMLAttributeList *destination) |
Returns the attributes of a node. | |
bool | getAttributeByName (const std::string &attrName, CXMLAttribute *destination) |
Returns the attribute of this node with the given name. | |
void | print (bool recursive=false) |
Prints out this node. | |
Static Private Member Functions | |
xmlNodePtr | getFirstDescendantByNamexmlPtr (const std::string &name, xmlNodePtr current) |
Private Attributes | |
xmlNode * | m_node |
|
Definition at line 97 of file XMLNode.cpp. References m_node. Referenced by getFirstChildNode(), getFirstDescendantByName(), getNextSiblingNode(), and print().
00097 { 00098 this->m_node = NULL; 00099 } |
|
Definition at line 105 of file XMLNode.cpp. References m_node.
00105 { 00106 this->m_node = node; 00107 } |
|
Definition at line 113 of file XMLNode.cpp.
00113 { 00114 // TODO: Currently it seems that xmlCleanup() does all the work 00115 // for all libxml objects. 00116 //if(m_node != NULL) { 00117 // delete m_node; 00118 // m_node = NULL; 00119 //} 00120 } |
|
Returns the attribute of this node with the given name.
Definition at line 302 of file XMLNode.cpp. References xml::CXMLAttributeList::get(), getAttributes(), xml::CXMLAttributeList::getSize(), and xml::CXMLAttribute::m_name. Referenced by pge::SGFFile::parseLight(), pge::SGFFile::parseMesh(), and pge::TextureResourceFile::parseTexture().
00302 { 00303 xml::CXMLAttributeList attrList; 00304 xml::CXMLAttribute attr; 00305 int i; 00306 00307 00308 // Get the attribute of the node. 00309 if(getAttributes(&attrList)) { 00310 for(i = 0; i < attrList.getSize(); i++) { 00311 attr = attrList.get(i); 00312 if(attr.m_name == attrName) { 00313 *destination = attr; 00314 return true; 00315 } 00316 } 00317 } 00318 return false; 00319 } |
Here is the call graph for this function:
|
Returns the attributes of a node.
Definition at line 274 of file XMLNode.cpp. References xml::CXMLAttributeList::add(), and m_node. Referenced by getAttributeByName().
00274 { 00275 xmlAttr *aPtr; 00276 00277 00278 if(destination == NULL) { 00279 return false; 00280 } 00281 00282 if(m_node != NULL) { 00283 if(m_node->properties != NULL) { 00284 00285 aPtr = m_node->properties; 00286 00287 while(aPtr != NULL) { 00288 CXMLAttribute attr = CXMLAttribute(aPtr); 00289 destination->add(attr); 00290 aPtr = aPtr->next; 00291 } 00292 return true; 00293 } 00294 } 00295 return false; 00296 } |
Here is the call graph for this function:
|
Definition at line 229 of file XMLNode.cpp. References m_node.
|
|
This returns the first child node of this node. This returns the first child node of this node. The child must be an element node. No text nodes or other nodes are returned, only element nodes. Definition at line 148 of file XMLNode.cpp. References CXMLNode(), and m_node. Referenced by pge::SGFFile::parseLight(), pge::SGFFile::parseMesh(), and pge::TextureResourceFile::parseTexture().
00148 { 00149 xmlNode *nPtr; 00150 00151 00152 if(m_node != NULL) { 00153 if(m_node->children != NULL) { 00154 00155 nPtr = m_node->children; 00156 00157 while(nPtr != NULL) { 00158 00159 // Get the first child element node, no text nodes! 00160 if(nPtr->type == XML_ELEMENT_NODE) { 00161 *destination = CXMLNode(nPtr); 00162 return true; 00163 } 00164 nPtr = nPtr->next; 00165 } 00166 } 00167 } 00168 return false; 00169 } |
Here is the call graph for this function:
|
Returns the first descendant of this node with the given name. Returns the first descendant of this node with the given name. The function returns false, if there is no such node. Definition at line 243 of file XMLNode.cpp. References CXMLNode(), and m_node. Referenced by pge::SGFFile::parseMesh().
|
Here is the call graph for this function:
|
Definition at line 364 of file XMLNode.cpp.
00364 { 00365 // 00366 // Variables 00367 // 00368 xmlNodePtr nodePtr = NULL; 00369 xmlNodePtr recNode = NULL; 00370 00371 00372 // Loop through all children of this node and check against name. 00373 // Do this first loop without recursion, because we want to first check the 00374 // first complete sibling level. If its not found, then procede with recursion. 00375 for(nodePtr = current->children; nodePtr != NULL; nodePtr = nodePtr->next) { 00376 // Ignore text only nodes 00377 if(nodePtr->type != XML_TEXT_NODE) { 00378 // Check for same name 00379 if(nodePtr->name) { 00380 if(std::string((char*)nodePtr->name) == name) { 00381 return nodePtr; 00382 } 00383 } 00384 } 00385 } 00386 00387 // It was not found in the above loop, so go ahead with recursion; 00388 for(nodePtr = current->children; nodePtr != NULL; nodePtr = nodePtr->next) { 00389 // Ignore text only nodes 00390 if(nodePtr->type != XML_TEXT_NODE) { 00391 recNode = CXMLNode::getFirstDescendantByNamexmlPtr(name, nodePtr); 00392 if(recNode) { 00393 return recNode; 00394 } 00395 } 00396 } 00397 00398 return NULL; 00399 } |
|
Definition at line 126 of file XMLNode.cpp. References m_node. Referenced by pge::SGFFile::parseMesh(), and pge::TextureResourceFile::parseTexture().
|
|
Definition at line 202 of file XMLNode.cpp. References m_node.
|
|
This returns the next sibling node of this node. This returns the next sibling node of this node. The sibling must be an element node. No text nodes or other nodes are returned, only element nodes. Definition at line 175 of file XMLNode.cpp. References CXMLNode(), and m_node. Referenced by pge::SGFFile::parseLight(), pge::SGFFile::parseMesh(), and pge::TextureResourceFile::parseTexture().
00175 { 00176 xmlNode *nPtr; 00177 00178 00179 if(m_node != NULL) { 00180 if(m_node->next != NULL) { 00181 00182 nPtr = m_node->next; 00183 00184 while(nPtr != NULL) { 00185 00186 // Get the first child element node, no text nodes! 00187 if(nPtr->type == XML_ELEMENT_NODE) { 00188 *destination = CXMLNode(nPtr); 00189 return true; 00190 } 00191 nPtr = nPtr->next; 00192 } 00193 } 00194 } 00195 return false; 00196 } |
Here is the call graph for this function:
|
Returns the text of this node. Returns the text of this node. This only returns text, if the node has a child with text content. If not, the function returns false. Definition at line 258 of file XMLNode.cpp. References m_node. Referenced by pge::SGFFile::parseLight(), pge::SGFFile::parseMesh(), and pge::TextureResourceFile::parseTexture().
|
|
Definition at line 140 of file XMLNode.cpp. References m_node.
00140 { 00141 return this->m_node->type; 00142 } |
|
Definition at line 216 of file XMLNode.cpp. References m_node. Referenced by print().
|
|
Prints out this node.
Definition at line 325 of file XMLNode.cpp. References CXMLNode(), hasNameSpace(), and m_node.
00325 { 00326 // 00327 // Variablen 00328 // 00329 xmlNodePtr nodePtr = NULL; 00330 00331 00332 // Gebe den momentanen Knoten aus 00333 switch(this->m_node->type) { 00334 case 1: printf("XML Element Node: "); break; 00335 case 2: printf("XML Attribute Node: "); break; 00336 case 3: printf("XML Text Node: "); break; 00337 case 6: printf("XML Entity Node: "); break; 00338 case 8: printf("XML Comment Node: "); break; 00339 default: break; 00340 } 00341 00342 if(hasNameSpace()) { 00343 // Name with namespace. 00344 printf("Name=\"%s::%s\";\n", this->m_node->ns->prefix, this->m_node->name); 00345 } else { 00346 printf("Name=\"%s\";\n", this->m_node->name); 00347 } 00348 00349 if(recursive) { 00350 // Gebe alle Kinder des aktuellen Knotens aus 00351 for(nodePtr = this->m_node->children; nodePtr != NULL; nodePtr = nodePtr->next) { 00352 // Ignoriere Text Knoten, da dies unheimlich viele Leerzeichenausgaben ergeben wuerde 00353 if(nodePtr->type != XML_TEXT_NODE) { 00354 CXMLNode(nodePtr).print(true); 00355 } 00356 } 00357 } 00358 } |
Here is the call graph for this function:
|
Definition at line 162 of file XMLNode.h. Referenced by CXMLNode(), getAttributes(), getContent(), getFirstChildNode(), getFirstDescendantByName(), getName(), getNameSpace(), getNextSiblingNode(), getText(), getType(), hasNameSpace(), and print(). |