Openholo
v5.0
Open Source Digital Holographic Library
|
#include <tinyxml2.h>
Public Member Functions | |
XMLHandle (XMLNode *node) | |
Create a handle from any node (at any depth of the tree.) This can be a null pointer. More... | |
XMLHandle (XMLNode &node) | |
Create a handle from a node. More... | |
XMLHandle (const XMLHandle &ref) | |
Copy constructor. More... | |
XMLHandle & | operator= (const XMLHandle &ref) |
Assignment. More... | |
XMLHandle | FirstChild () |
Get the first child of this handle. More... | |
XMLHandle | FirstChildElement (const char *name=0) |
Get the first child element of this handle. More... | |
XMLHandle | LastChild () |
Get the last child of this handle. More... | |
XMLHandle | LastChildElement (const char *name=0) |
Get the last child element of this handle. More... | |
XMLHandle | PreviousSibling () |
Get the previous sibling of this handle. More... | |
XMLHandle | PreviousSiblingElement (const char *name=0) |
Get the previous sibling element of this handle. More... | |
XMLHandle | NextSibling () |
Get the next sibling of this handle. More... | |
XMLHandle | NextSiblingElement (const char *name=0) |
Get the next sibling element of this handle. More... | |
XMLNode * | ToNode () |
Safe cast to XMLNode. This can return null. More... | |
XMLElement * | ToElement () |
Safe cast to XMLElement. This can return null. More... | |
XMLText * | ToText () |
Safe cast to XMLText. This can return null. More... | |
XMLUnknown * | ToUnknown () |
Safe cast to XMLUnknown. This can return null. More... | |
XMLDeclaration * | ToDeclaration () |
Safe cast to XMLDeclaration. This can return null. More... | |
XMLHandle (XMLNode *node) | |
Create a handle from any node (at any depth of the tree.) This can be a null pointer. More... | |
XMLHandle (XMLNode &node) | |
Create a handle from a node. More... | |
XMLHandle (const XMLHandle &ref) | |
Copy constructor. More... | |
XMLHandle & | operator= (const XMLHandle &ref) |
Assignment. More... | |
XMLHandle | FirstChild () |
Get the first child of this handle. More... | |
XMLHandle | FirstChildElement (const char *name=0) |
Get the first child element of this handle. More... | |
XMLHandle | LastChild () |
Get the last child of this handle. More... | |
XMLHandle | LastChildElement (const char *name=0) |
Get the last child element of this handle. More... | |
XMLHandle | PreviousSibling () |
Get the previous sibling of this handle. More... | |
XMLHandle | PreviousSiblingElement (const char *name=0) |
Get the previous sibling element of this handle. More... | |
XMLHandle | NextSibling () |
Get the next sibling of this handle. More... | |
XMLHandle | NextSiblingElement (const char *name=0) |
Get the next sibling element of this handle. More... | |
XMLNode * | ToNode () |
Safe cast to XMLNode. This can return null. More... | |
XMLElement * | ToElement () |
Safe cast to XMLElement. This can return null. More... | |
XMLText * | ToText () |
Safe cast to XMLText. This can return null. More... | |
XMLUnknown * | ToUnknown () |
Safe cast to XMLUnknown. This can return null. More... | |
XMLDeclaration * | ToDeclaration () |
Safe cast to XMLDeclaration. This can return null. More... | |
XMLHandle (XMLNode *node) | |
Create a handle from any node (at any depth of the tree.) This can be a null pointer. More... | |
XMLHandle (XMLNode &node) | |
Create a handle from a node. More... | |
XMLHandle (const XMLHandle &ref) | |
Copy constructor. More... | |
XMLHandle & | operator= (const XMLHandle &ref) |
Assignment. More... | |
XMLHandle | FirstChild () |
Get the first child of this handle. More... | |
XMLHandle | FirstChildElement (const char *name=0) |
Get the first child element of this handle. More... | |
XMLHandle | LastChild () |
Get the last child of this handle. More... | |
XMLHandle | LastChildElement (const char *name=0) |
Get the last child element of this handle. More... | |
XMLHandle | PreviousSibling () |
Get the previous sibling of this handle. More... | |
XMLHandle | PreviousSiblingElement (const char *name=0) |
Get the previous sibling element of this handle. More... | |
XMLHandle | NextSibling () |
Get the next sibling of this handle. More... | |
XMLHandle | NextSiblingElement (const char *name=0) |
Get the next sibling element of this handle. More... | |
XMLNode * | ToNode () |
Safe cast to XMLNode. This can return null. More... | |
XMLElement * | ToElement () |
Safe cast to XMLElement. This can return null. More... | |
XMLText * | ToText () |
Safe cast to XMLText. This can return null. More... | |
XMLUnknown * | ToUnknown () |
Safe cast to XMLUnknown. This can return null. More... | |
XMLDeclaration * | ToDeclaration () |
Safe cast to XMLDeclaration. This can return null. More... | |
A XMLHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing. Note that XMLHandle is not part of the TinyXML-2 DOM structure. It is a separate utility class.
Take an example:
<Document> <Element attributeA = "valueA"> <Child attributeB = "value1" /> <Child attributeB = "value2" /> </Element> </Document>
Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very easy to write a lot of code that looks like:
XMLElement* root = document.FirstChildElement( "Document" ); if ( root ) { XMLElement* element = root->FirstChildElement( "Element" ); if ( element ) { XMLElement* child = element->FirstChildElement( "Child" ); if ( child ) { XMLElement* child2 = child->NextSiblingElement( "Child" ); if ( child2 ) { // Finally do something useful.
And that doesn't even cover "else" cases. XMLHandle addresses the verbosity of such code. A XMLHandle checks for null pointers so it is perfectly safe and correct to use:
XMLHandle docHandle( &document ); XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement(); if ( child2 ) { // do something useful
Which is MUCH more concise and useful.
It is also safe to copy handles - internally they are nothing more than node pointers.
XMLHandle handleCopy = handle;
See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects.
Definition at line 1989 of file tinyxml2.h.
|
inline |
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition at line 1993 of file tinyxml2.h.
|
inline |
Create a handle from a node.
Definition at line 1996 of file tinyxml2.h.
|
inline |
Copy constructor.
Definition at line 1999 of file tinyxml2.h.
|
inline |
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition at line 1993 of file tinyxml2.h.
|
inline |
Create a handle from a node.
Definition at line 1996 of file tinyxml2.h.
|
inline |
Copy constructor.
Definition at line 1999 of file tinyxml2.h.
|
inline |
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition at line 1993 of file tinyxml2.h.
|
inline |
Create a handle from a node.
Definition at line 1996 of file tinyxml2.h.
|
inline |
Copy constructor.
Definition at line 1999 of file tinyxml2.h.
|
inline |
Get the first child of this handle.
Definition at line 2008 of file tinyxml2.h.
|
inline |
Get the first child of this handle.
Definition at line 2008 of file tinyxml2.h.
|
inline |
Get the first child of this handle.
Definition at line 2008 of file tinyxml2.h.
|
inline |
Get the first child element of this handle.
Definition at line 2012 of file tinyxml2.h.
|
inline |
Get the first child element of this handle.
Definition at line 2012 of file tinyxml2.h.
|
inline |
Get the first child element of this handle.
Definition at line 2012 of file tinyxml2.h.
|
inline |
Get the last child of this handle.
Definition at line 2016 of file tinyxml2.h.
|
inline |
Get the last child of this handle.
Definition at line 2016 of file tinyxml2.h.
|
inline |
Get the last child of this handle.
Definition at line 2016 of file tinyxml2.h.
|
inline |
Get the last child element of this handle.
Definition at line 2020 of file tinyxml2.h.
|
inline |
Get the last child element of this handle.
Definition at line 2020 of file tinyxml2.h.
|
inline |
Get the last child element of this handle.
Definition at line 2020 of file tinyxml2.h.
|
inline |
Get the next sibling of this handle.
Definition at line 2032 of file tinyxml2.h.
|
inline |
Get the next sibling of this handle.
Definition at line 2032 of file tinyxml2.h.
|
inline |
Get the next sibling of this handle.
Definition at line 2032 of file tinyxml2.h.
|
inline |
Get the next sibling element of this handle.
Definition at line 2036 of file tinyxml2.h.
|
inline |
Get the next sibling element of this handle.
Definition at line 2036 of file tinyxml2.h.
|
inline |
Get the next sibling element of this handle.
Definition at line 2036 of file tinyxml2.h.
Assignment.
Definition at line 2002 of file tinyxml2.h.
Assignment.
Definition at line 2002 of file tinyxml2.h.
Assignment.
Definition at line 2002 of file tinyxml2.h.
|
inline |
Get the previous sibling of this handle.
Definition at line 2024 of file tinyxml2.h.
|
inline |
Get the previous sibling of this handle.
Definition at line 2024 of file tinyxml2.h.
|
inline |
Get the previous sibling of this handle.
Definition at line 2024 of file tinyxml2.h.
|
inline |
Get the previous sibling element of this handle.
Definition at line 2028 of file tinyxml2.h.
|
inline |
Get the previous sibling element of this handle.
Definition at line 2028 of file tinyxml2.h.
|
inline |
Get the previous sibling element of this handle.
Definition at line 2028 of file tinyxml2.h.
|
inline |
Safe cast to XMLDeclaration. This can return null.
Definition at line 2057 of file tinyxml2.h.
|
inline |
Safe cast to XMLDeclaration. This can return null.
Definition at line 2057 of file tinyxml2.h.
|
inline |
Safe cast to XMLDeclaration. This can return null.
Definition at line 2057 of file tinyxml2.h.
|
inline |
Safe cast to XMLElement. This can return null.
Definition at line 2045 of file tinyxml2.h.
|
inline |
Safe cast to XMLElement. This can return null.
Definition at line 2045 of file tinyxml2.h.
|
inline |
Safe cast to XMLElement. This can return null.
Definition at line 2045 of file tinyxml2.h.
|
inline |
Safe cast to XMLNode. This can return null.
Definition at line 2041 of file tinyxml2.h.
|
inline |
Safe cast to XMLNode. This can return null.
Definition at line 2041 of file tinyxml2.h.
|
inline |
Safe cast to XMLNode. This can return null.
Definition at line 2041 of file tinyxml2.h.
|
inline |
Safe cast to XMLText. This can return null.
Definition at line 2049 of file tinyxml2.h.
|
inline |
Safe cast to XMLText. This can return null.
Definition at line 2049 of file tinyxml2.h.
|
inline |
Safe cast to XMLText. This can return null.
Definition at line 2049 of file tinyxml2.h.
|
inline |
Safe cast to XMLUnknown. This can return null.
Definition at line 2053 of file tinyxml2.h.
|
inline |
Safe cast to XMLUnknown. This can return null.
Definition at line 2053 of file tinyxml2.h.
|
inline |
Safe cast to XMLUnknown. This can return null.
Definition at line 2053 of file tinyxml2.h.