| Xml Scol plugin
    | 
#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. | |
| XMLHandle (XMLNode &node) | |
| Create a handle from a node. | |
| XMLHandle (const XMLHandle &ref) | |
| Copy constructor. | |
| XMLHandle & | operator= (const XMLHandle &ref) | 
| Assignment. | |
| XMLHandle | FirstChild () | 
| Get the first child of this handle. | |
| XMLHandle | FirstChildElement (const char *value=0) | 
| Get the first child element of this handle. | |
| XMLHandle | LastChild () | 
| Get the last child of this handle. | |
| XMLHandle | LastChildElement (const char *_value=0) | 
| Get the last child element of this handle. | |
| XMLHandle | PreviousSibling () | 
| Get the previous sibling of this handle. | |
| XMLHandle | PreviousSiblingElement (const char *_value=0) | 
| Get the previous sibling element of this handle. | |
| XMLHandle | NextSibling () | 
| Get the next sibling of this handle. | |
| XMLHandle | NextSiblingElement (const char *_value=0) | 
| Get the next sibling element of this handle. | |
| XMLNode * | ToNode () | 
| Safe cast to XMLNode. This can return null. | |
| XMLElement * | ToElement () | 
| Safe cast to XMLElement. This can return null. | |
| XMLText * | ToText () | 
| Safe cast to XMLText. This can return null. | |
| XMLUnknown * | ToUnknown () | 
| Safe cast to XMLUnknown. This can return null. | |
| XMLDeclaration * | ToDeclaration () | 
| Safe cast to XMLDeclaration. This can return null. | |
Detailed Description
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 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.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement();
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 1596 of file tinyxml2.h.
Constructor & Destructor Documentation
◆ XMLHandle() [1/3]
| 
 | inline | 
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition at line 1600 of file tinyxml2.h.
◆ XMLHandle() [2/3]
| 
 | inline | 
Create a handle from a node.
Definition at line 1604 of file tinyxml2.h.
◆ XMLHandle() [3/3]
Copy constructor.
Definition at line 1608 of file tinyxml2.h.
Member Function Documentation
◆ FirstChild()
| 
 | inline | 
Get the first child of this handle.
Definition at line 1618 of file tinyxml2.h.
◆ FirstChildElement()
Get the first child element of this handle.
Definition at line 1622 of file tinyxml2.h.
◆ LastChild()
| 
 | inline | 
Get the last child of this handle.
Definition at line 1626 of file tinyxml2.h.
◆ LastChildElement()
Get the last child element of this handle.
Definition at line 1630 of file tinyxml2.h.
◆ NextSibling()
| 
 | inline | 
Get the next sibling of this handle.
Definition at line 1642 of file tinyxml2.h.
◆ NextSiblingElement()
Get the next sibling element of this handle.
Definition at line 1646 of file tinyxml2.h.
◆ operator=()
Assignment.
Definition at line 1612 of file tinyxml2.h.
◆ PreviousSibling()
| 
 | inline | 
Get the previous sibling of this handle.
Definition at line 1634 of file tinyxml2.h.
◆ PreviousSiblingElement()
Get the previous sibling element of this handle.
Definition at line 1638 of file tinyxml2.h.
◆ ToDeclaration()
| 
 | inline | 
Safe cast to XMLDeclaration. This can return null.
Definition at line 1667 of file tinyxml2.h.
◆ ToElement()
| 
 | inline | 
Safe cast to XMLElement. This can return null.
Definition at line 1655 of file tinyxml2.h.
◆ ToNode()
| 
 | inline | 
Safe cast to XMLNode. This can return null.
Definition at line 1651 of file tinyxml2.h.
◆ ToText()
| 
 | inline | 
Safe cast to XMLText. This can return null.
Definition at line 1659 of file tinyxml2.h.
◆ ToUnknown()
| 
 | inline | 
Safe cast to XMLUnknown. This can return null.
Definition at line 1663 of file tinyxml2.h.
The documentation for this class was generated from the following file:
- G:/work/subversion/scol-technologies/trunk/scol/plugins/sXml/include/tinyxml2.h
Generated by