XALM  1.0
 Vše Třídy Prostory jmen Soubory Funkce Proměnné Výčty Hodnoty výčtu Friends Definice maker
Veřejné metody | Privátní atributy | Seznam všech členů
Dokumentace třídy tinyxml2::XMLHandle

A XMLHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing. ...

#include <tinyxml2.h>

Veřejné metody

 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. ...
 
XMLHandleoperator= (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. ...
 
XMLNodeToNode ()
 Safe cast to XMLNode. This can return null. ...
 
XMLElementToElement ()
 Safe cast to XMLElement. This can return null. ...
 
XMLTextToText ()
 Safe cast to XMLText. This can return null. ...
 
XMLUnknownToUnknown ()
 Safe cast to XMLUnknown. This can return null. ...
 
XMLDeclarationToDeclaration ()
 Safe cast to XMLDeclaration. This can return null. ...
 

Privátní atributy

XMLNode_node
 

Detailní popis

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.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.

Definice je uvedena na řádku 1703 v souboru tinyxml2.h.

Dokumentace konstruktoru a destruktoru

tinyxml2::XMLHandle::XMLHandle ( XMLNode node)
inline

Create a handle from any node (at any depth of the tree.) This can be a null pointer.

Definice je uvedena na řádku 1707 v souboru tinyxml2.h.

tinyxml2::XMLHandle::XMLHandle ( XMLNode node)
inline

Create a handle from a node.

Definice je uvedena na řádku 1711 v souboru tinyxml2.h.

tinyxml2::XMLHandle::XMLHandle ( const XMLHandle ref)
inline

Copy constructor.

Definice je uvedena na řádku 1715 v souboru tinyxml2.h.

Odkazuje se na _node.

Dokumentace k metodám

XMLHandle tinyxml2::XMLHandle::FirstChild ( )
inline

Get the first child of this handle.

Definice je uvedena na řádku 1725 v souboru tinyxml2.h.

XMLHandle tinyxml2::XMLHandle::FirstChildElement ( const char *  value = 0)
inline

Get the first child element of this handle.

Definice je uvedena na řádku 1729 v souboru tinyxml2.h.

XMLHandle tinyxml2::XMLHandle::LastChild ( )
inline

Get the last child of this handle.

Definice je uvedena na řádku 1733 v souboru tinyxml2.h.

XMLHandle tinyxml2::XMLHandle::LastChildElement ( const char *  _value = 0)
inline

Get the last child element of this handle.

Definice je uvedena na řádku 1737 v souboru tinyxml2.h.

XMLHandle tinyxml2::XMLHandle::NextSibling ( )
inline

Get the next sibling of this handle.

Definice je uvedena na řádku 1749 v souboru tinyxml2.h.

XMLHandle tinyxml2::XMLHandle::NextSiblingElement ( const char *  _value = 0)
inline

Get the next sibling element of this handle.

Definice je uvedena na řádku 1753 v souboru tinyxml2.h.

XMLHandle& tinyxml2::XMLHandle::operator= ( const XMLHandle ref)
inline

Assignment.

Definice je uvedena na řádku 1719 v souboru tinyxml2.h.

Odkazuje se na _node.

XMLHandle tinyxml2::XMLHandle::PreviousSibling ( )
inline

Get the previous sibling of this handle.

Definice je uvedena na řádku 1741 v souboru tinyxml2.h.

XMLHandle tinyxml2::XMLHandle::PreviousSiblingElement ( const char *  _value = 0)
inline

Get the previous sibling element of this handle.

Definice je uvedena na řádku 1745 v souboru tinyxml2.h.

XMLDeclaration* tinyxml2::XMLHandle::ToDeclaration ( )
inline

Safe cast to XMLDeclaration. This can return null.

Definice je uvedena na řádku 1774 v souboru tinyxml2.h.

XMLElement* tinyxml2::XMLHandle::ToElement ( )
inline

Safe cast to XMLElement. This can return null.

Definice je uvedena na řádku 1762 v souboru tinyxml2.h.

XMLNode* tinyxml2::XMLHandle::ToNode ( )
inline

Safe cast to XMLNode. This can return null.

Definice je uvedena na řádku 1758 v souboru tinyxml2.h.

XMLText* tinyxml2::XMLHandle::ToText ( )
inline

Safe cast to XMLText. This can return null.

Definice je uvedena na řádku 1766 v souboru tinyxml2.h.

XMLUnknown* tinyxml2::XMLHandle::ToUnknown ( )
inline

Safe cast to XMLUnknown. This can return null.

Definice je uvedena na řádku 1770 v souboru tinyxml2.h.

Dokumentace k datovým členům

XMLNode* tinyxml2::XMLHandle::_node
private

Definice je uvedena na řádku 1779 v souboru tinyxml2.h.

Používá se v operator=() a XMLHandle().


Dokumentace pro tuto třídu byla generována z následujícího souboru: