nux-0.9.46

TiXmlNode Class Reference

The parent class for everything in the Document Object Model. More...

#include <NuxCore/TinyXML/tinyxml.h>

Inheritance diagram for TiXmlNode:
TiXmlBase TiXmlComment TiXmlDeclaration TiXmlDocument TiXmlElement TiXmlText TiXmlUnknown

Public Types

enum  NodeType {
  DOCUMENT, ELEMENT, COMMENT, UNKNOWN,
  TEXT, DECLARATION, TYPECOUNT
}
 

The types of XML nodes supported by TinyXml.

More...

Public Member Functions

virtual ~TiXmlNode ()
const char * Value () const
 The meaning of 'value' changes for the specific type of TiXmlNode.
const TIXML_STRING & ValueTStr () const
void SetValue (const char *_value)
 Changes the value of the node.
void Clear ()
 Delete all the children of this node. Does not affect 'this'.
TiXmlNode * Parent ()
 One step up the DOM.
const TiXmlNode * Parent () const
const TiXmlNode * FirstChild () const
TiXmlNode * FirstChild ()
const TiXmlNode * FirstChild (const char *value) const
 The first child of this node with the matching 'value'.
TiXmlNode * FirstChild (const char *_value)
 The first child of this node with the matching 'value'. Will be null if none found.
const TiXmlNode * LastChild () const
TiXmlNode * LastChild ()
const TiXmlNode * LastChild (const char *value) const
TiXmlNode * LastChild (const char *_value)
 The last child of this node matching 'value'. Will be null if there are no children.
const TiXmlNode * IterateChildren (const TiXmlNode *previous) const
 An alternate way to walk the children of a node.
TiXmlNode * IterateChildren (const TiXmlNode *previous)
const TiXmlNode * IterateChildren (const char *value, const TiXmlNode *previous) const
 This flavor of IterateChildren searches for children with a particular 'value'.
TiXmlNode * IterateChildren (const char *_value, const TiXmlNode *previous)
TiXmlNode * InsertEndChild (const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNode * LinkEndChild (TiXmlNode *addThis)
 Add a new node related to this.
TiXmlNode * InsertBeforeChild (TiXmlNode *beforeThis, const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNode * InsertAfterChild (TiXmlNode *afterThis, const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNode * ReplaceChild (TiXmlNode *replaceThis, const TiXmlNode &withThis)
 Replace a child of this node.
bool RemoveChild (TiXmlNode *removeThis)
 Delete a child of this node.
const TiXmlNode * PreviousSibling () const
 Navigate to a sibling node.
TiXmlNode * PreviousSibling ()
const TiXmlNode * PreviousSibling (const char *) const
 Navigate to a sibling node.
TiXmlNode * PreviousSibling (const char *_prev)
const TiXmlNode * NextSibling () const
 Navigate to a sibling node.
TiXmlNode * NextSibling ()
const TiXmlNode * NextSibling (const char *) const
 Navigate to a sibling node with the given 'value'.
TiXmlNode * NextSibling (const char *_next)
const TiXmlElement * NextSiblingElement () const
 Convenience function to get through elements.
TiXmlElement * NextSiblingElement ()
const TiXmlElement * NextSiblingElement (const char *) const
 Convenience function to get through elements.
TiXmlElement * NextSiblingElement (const char *_next)
const TiXmlElement * FirstChildElement () const
 Convenience function to get through elements.
TiXmlElement * FirstChildElement ()
const TiXmlElement * FirstChildElement (const char *_value) const
 Convenience function to get through elements.
TiXmlElement * FirstChildElement (const char *_value)
int Type () const
 Query the type (as an enumerated value, above) of this node.
const TiXmlDocument * GetDocument () const
 Return a pointer to the Document this node lives in.
TiXmlDocument * GetDocument ()
bool NoChildren () const
 Returns true if this node has no children.
virtual const TiXmlDocument * ToDocument () const
virtual const TiXmlElement * ToElement () const
virtual const TiXmlComment * ToComment () const
virtual const TiXmlUnknown * ToUnknown () const
virtual const TiXmlText * ToText () const
virtual const TiXmlDeclaration * ToDeclaration () const
virtual TiXmlDocument * ToDocument ()
virtual TiXmlElement * ToElement ()
virtual TiXmlComment * ToComment ()
virtual TiXmlUnknown * ToUnknown ()
virtual TiXmlText * ToText ()
virtual TiXmlDeclaration * ToDeclaration ()
virtual TiXmlNode * Clone () const =0
 Create an exact duplicate of this node and return it.
virtual bool Accept (TiXmlVisitor *visitor) const =0
 Accept a hierchical visit the nodes in the TinyXML DOM.

Protected Member Functions

 TiXmlNode (NodeType _type)
void CopyTo (TiXmlNode *target) const
TiXmlNode * Identify (const char *start, TiXmlEncoding encoding)

Protected Attributes

TiXmlNode * parent
NodeType type
TiXmlNode * firstChild
TiXmlNode * lastChild
TIXML_STRING value
TiXmlNode * prev
TiXmlNode * next

Friends

class TiXmlDocument
class TiXmlElement

Detailed Description

The parent class for everything in the Document Object Model.

(Except for attributes). Nodes have siblings, a parent, and children. A node can be in a document, or stand on its own. The type of a TiXmlNode can be queried, and it can be cast to its more defined type.


Member Enumeration Documentation

The types of XML nodes supported by TinyXml.

(All the unsupported types are picked up by UNKNOWN.)

Enumerator:
DOCUMENT 
ELEMENT 
COMMENT 
UNKNOWN 
TEXT 
DECLARATION 
TYPECOUNT 

Constructor & Destructor Documentation

virtual TiXmlNode::~TiXmlNode ( ) [virtual]
TiXmlNode::TiXmlNode ( NodeType  _type) [protected]

Member Function Documentation

virtual bool TiXmlNode::Accept ( TiXmlVisitor *  visitor) const [pure virtual]

Accept a hierchical visit the nodes in the TinyXML DOM.

Every node in the XML tree will be conditionally visited and the host will be called back via the TiXmlVisitor interface.

This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse the XML for the callbacks, so the performance of TinyXML is unchanged by using this interface versus any other.)

The interface has been based on ideas from:

Which are both good references for "visiting".

An example of using Accept():

  	TiXmlPrinter printer;
  	tinyxmlDoc.Accept( &printer );
  	const char* xmlcstr = printer.CStr();
  	

Implemented in TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument.

void TiXmlNode::Clear ( )

Delete all the children of this node. Does not affect 'this'.

virtual TiXmlNode* TiXmlNode::Clone ( ) const [pure virtual]

Create an exact duplicate of this node and return it.

The memory must be deleted by the caller.

Implemented in TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument.

void TiXmlNode::CopyTo ( TiXmlNode *  target) const [protected]
TiXmlNode* TiXmlNode::FirstChild ( ) [inline]

References firstChild.

const TiXmlNode* TiXmlNode::FirstChild ( const char *  value) const

The first child of this node with the matching 'value'.

Will be null if none found.

TiXmlNode* TiXmlNode::FirstChild ( const char *  _value) [inline]

The first child of this node with the matching 'value'. Will be null if none found.

const TiXmlNode* TiXmlNode::FirstChild ( ) const [inline]

< The first child of this node. Will be null if there are no children.

References firstChild.

const TiXmlElement* TiXmlNode::FirstChildElement ( ) const

Convenience function to get through elements.

Referenced by TiXmlDocument::RootElement().

TiXmlElement* TiXmlNode::FirstChildElement ( ) [inline]
const TiXmlElement* TiXmlNode::FirstChildElement ( const char *  _value) const

Convenience function to get through elements.

TiXmlElement* TiXmlNode::FirstChildElement ( const char *  _value) [inline]
const TiXmlDocument* TiXmlNode::GetDocument ( ) const

Return a pointer to the Document this node lives in.

Returns null if not in a document.

TiXmlDocument* TiXmlNode::GetDocument ( ) [inline]
TiXmlNode* TiXmlNode::Identify ( const char *  start,
TiXmlEncoding  encoding 
) [protected]
TiXmlNode* TiXmlNode::InsertAfterChild ( TiXmlNode *  afterThis,
const TiXmlNode &  addThis 
)

Add a new node related to this.

Adds a child after the specified child. Returns a pointer to the new object or NULL if an error occured.

TiXmlNode* TiXmlNode::InsertBeforeChild ( TiXmlNode *  beforeThis,
const TiXmlNode &  addThis 
)

Add a new node related to this.

Adds a child before the specified child. Returns a pointer to the new object or NULL if an error occured.

TiXmlNode* TiXmlNode::InsertEndChild ( const TiXmlNode &  addThis)

Add a new node related to this.

Adds a child past the LastChild. Returns a pointer to the new object or NULL if an error occured.

TiXmlNode* TiXmlNode::IterateChildren ( const TiXmlNode *  previous) [inline]
const TiXmlNode* TiXmlNode::IterateChildren ( const char *  value,
const TiXmlNode *  previous 
) const

This flavor of IterateChildren searches for children with a particular 'value'.

TiXmlNode* TiXmlNode::IterateChildren ( const char *  _value,
const TiXmlNode *  previous 
) [inline]
const TiXmlNode* TiXmlNode::IterateChildren ( const TiXmlNode *  previous) const

An alternate way to walk the children of a node.

One way to iterate over nodes is:

  		for( child = parent->FirstChild(); child; child = child->NextSibling() )
  	

IterateChildren does the same thing with the syntax:

  		child = 0;
  		while( child = parent->IterateChildren( child ) )
  	

IterateChildren takes the previous child as input and finds the next one. If the previous child is null, it returns the first. IterateChildren will return null when done.

const TiXmlNode* TiXmlNode::LastChild ( ) const [inline]

The last child of this node. Will be null if there are no children.

References lastChild.

TiXmlNode* TiXmlNode::LastChild ( ) [inline]

References lastChild.

const TiXmlNode* TiXmlNode::LastChild ( const char *  value) const
TiXmlNode* TiXmlNode::LastChild ( const char *  _value) [inline]

The last child of this node matching 'value'. Will be null if there are no children.

TiXmlNode* TiXmlNode::LinkEndChild ( TiXmlNode *  addThis)

Add a new node related to this.

Adds a child past the LastChild.

NOTE: the node to be added is passed by pointer, and will be henceforth owned (and deleted) by tinyXml. This method is efficient and avoids an extra copy, but should be used with care as it uses a different memory model than the other insert functions.

See also:
InsertEndChild
TiXmlNode* TiXmlNode::NextSibling ( const char *  _next) [inline]
const TiXmlNode* TiXmlNode::NextSibling ( ) const [inline]

Navigate to a sibling node.

References next.

TiXmlNode* TiXmlNode::NextSibling ( ) [inline]

References next.

const TiXmlNode* TiXmlNode::NextSibling ( const char *  ) const

Navigate to a sibling node with the given 'value'.

const TiXmlElement* TiXmlNode::NextSiblingElement ( const char *  ) const

Convenience function to get through elements.

Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

const TiXmlElement* TiXmlNode::NextSiblingElement ( ) const

Convenience function to get through elements.

Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

TiXmlElement* TiXmlNode::NextSiblingElement ( ) [inline]
TiXmlElement* TiXmlNode::NextSiblingElement ( const char *  _next) [inline]
bool TiXmlNode::NoChildren ( ) const [inline]

Returns true if this node has no children.

References firstChild.

TiXmlNode* TiXmlNode::Parent ( void  ) [inline]

One step up the DOM.

References parent.

const TiXmlNode* TiXmlNode::Parent ( void  ) const [inline]

References parent.

TiXmlNode* TiXmlNode::PreviousSibling ( const char *  _prev) [inline]
const TiXmlNode* TiXmlNode::PreviousSibling ( const char *  ) const

Navigate to a sibling node.

const TiXmlNode* TiXmlNode::PreviousSibling ( ) const [inline]

Navigate to a sibling node.

References prev.

TiXmlNode* TiXmlNode::PreviousSibling ( ) [inline]

References prev.

bool TiXmlNode::RemoveChild ( TiXmlNode *  removeThis)

Delete a child of this node.

TiXmlNode* TiXmlNode::ReplaceChild ( TiXmlNode *  replaceThis,
const TiXmlNode &  withThis 
)

Replace a child of this node.

Returns a pointer to the new object or NULL if an error occured.

void TiXmlNode::SetValue ( const char *  _value) [inline]

Changes the value of the node.

Defined as:

  	Document:	filename of the xml file
  	Element:	name of the element
  	Comment:	the comment text
  	Unknown:	the tag contents
  	Text:		the text string
  	

References value.

Referenced by TiXmlComment::TiXmlComment(), and TiXmlText::TiXmlText().

virtual TiXmlComment* TiXmlNode::ToComment ( ) [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlComment.

virtual const TiXmlComment* TiXmlNode::ToComment ( ) const [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlComment.

virtual const TiXmlDeclaration* TiXmlNode::ToDeclaration ( ) const [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlDeclaration.

virtual TiXmlDeclaration* TiXmlNode::ToDeclaration ( ) [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlDeclaration.

virtual TiXmlDocument* TiXmlNode::ToDocument ( ) [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlDocument.

virtual const TiXmlDocument* TiXmlNode::ToDocument ( ) const [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlDocument.

virtual const TiXmlElement* TiXmlNode::ToElement ( ) const [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlElement.

virtual TiXmlElement* TiXmlNode::ToElement ( ) [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlElement.

virtual TiXmlText* TiXmlNode::ToText ( ) [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlText.

virtual const TiXmlText* TiXmlNode::ToText ( ) const [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlText.

virtual TiXmlUnknown* TiXmlNode::ToUnknown ( ) [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlUnknown.

virtual const TiXmlUnknown* TiXmlNode::ToUnknown ( ) const [inline, virtual]

< Cast to a more defined type. Will return null if not of the requested type.

Reimplemented in TiXmlUnknown.

int TiXmlNode::Type ( ) const [inline]

Query the type (as an enumerated value, above) of this node.

The possible types are: DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, and DECLARATION.

References type.

const char* TiXmlNode::Value ( ) const [inline]

The meaning of 'value' changes for the specific type of TiXmlNode.

  	Document:	filename of the xml file
  	Element:	name of the element
  	Comment:	the comment text
  	Unknown:	the tag contents
  	Text:		the text string
  	

The subclasses will wrap this function.

References value.

const TIXML_STRING& TiXmlNode::ValueTStr ( ) const [inline]

References value.


Friends And Related Function Documentation

friend class TiXmlDocument [friend]

Reimplemented from TiXmlBase.

friend class TiXmlElement [friend]

Reimplemented from TiXmlBase.

Reimplemented in TiXmlText.


Field Documentation

Referenced by FirstChild(), and NoChildren().

Referenced by LastChild().

TiXmlNode* TiXmlNode::next [protected]

Referenced by NextSibling().

Referenced by Parent().

TiXmlNode* TiXmlNode::prev [protected]

Referenced by PreviousSibling().

Referenced by Type().

TIXML_STRING TiXmlNode::value [protected]

Referenced by SetValue(), Value(), and ValueTStr().


The documentation for this class was generated from the following file: