TiXmlNode Class Reference

#include <src/tinyxml/tinyxml.h>

Inheritance diagram for TiXmlNode:

TiXmlBase TiXmlComment TiXmlDeclaration TiXmlDocument TiXmlElement TiXmlStylesheetReference TiXmlText TiXmlUnknown

List of all members.

Public Types

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

Public Member Functions

virtual bool Accept (TiXmlVisitor *visitor) const =0
void Clear ()
 Delete all the children of this node. Does not affect 'this'.
virtual TiXmlNodeClone () const =0
TiXmlNodeFirstChild (const char *_value)
 The first child of this node with the matching 'value'. Will be null if none found.
const TiXmlNodeFirstChild (const char *value) const
TiXmlNodeFirstChild ()
const TiXmlNodeFirstChild () const
 The first child of this node. Will be null if there are no children.
TiXmlElementFirstChildElement (const char *_value)
const TiXmlElementFirstChildElement (const char *_value) const
 Convenience function to get through elements.
TiXmlElementFirstChildElement ()
const TiXmlElementFirstChildElement () const
 Convenience function to get through elements.
TiXmlDocumentGetDocument ()
const TiXmlDocumentGetDocument () const
TiXmlNodeInsertAfterChild (TiXmlNode *afterThis, const TiXmlNode &addThis)
TiXmlNodeInsertBeforeChild (TiXmlNode *beforeThis, const TiXmlNode &addThis)
TiXmlNodeInsertEndChild (const TiXmlNode &addThis)
TiXmlNodeIterateChildren (const char *_value, const TiXmlNode *previous)
const TiXmlNodeIterateChildren (const char *value, const TiXmlNode *previous) const
 This flavor of IterateChildren searches for children with a particular 'value'.
TiXmlNodeIterateChildren (const TiXmlNode *previous)
const TiXmlNodeIterateChildren (const TiXmlNode *previous) const
TiXmlNodeLastChild (const char *_value)
 The last child of this node matching 'value'. Will be null if there are no children.
const TiXmlNodeLastChild (const char *value) const
TiXmlNodeLastChild ()
 The last child of this node. Will be null if there are no children.
const TiXmlNodeLastChild () const
TiXmlNodeLinkEndChild (TiXmlNode *addThis)
TiXmlNodeNextSibling (const char *_next)
const TiXmlNodeNextSibling (const char *) const
 Navigate to a sibling node with the given 'value'.
TiXmlNodeNextSibling ()
const TiXmlNodeNextSibling () const
 Navigate to a sibling node.
TiXmlElementNextSiblingElement (const char *_next)
const TiXmlElementNextSiblingElement (const char *) const
TiXmlElementNextSiblingElement ()
const TiXmlElementNextSiblingElement () const
bool NoChildren () const
 Returns true if this node has no children.
const TiXmlNodeParent () const
TiXmlNodeParent ()
 One step up the DOM.
TiXmlNodePreviousSibling (const char *_prev)
const TiXmlNodePreviousSibling (const char *) const
 Navigate to a sibling node.
TiXmlNodePreviousSibling ()
const TiXmlNodePreviousSibling () const
 Navigate to a sibling node.
bool RemoveChild (TiXmlNode *removeThis)
 Delete a child of this node.
TiXmlNodeReplaceChild (TiXmlNode *replaceThis, const TiXmlNode &withThis)
void SetValue (const char *_value)
virtual TiXmlCommentToComment ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlCommentToComment () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlDeclarationToDeclaration ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlDeclarationToDeclaration () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlDocumentToDocument ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlDocumentToDocument () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlElementToElement ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlElementToElement () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlStylesheetReferenceToStylesheetReference ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const
TiXmlStylesheetReference
ToStylesheetReference () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlTextToText ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlTextToText () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlUnknownToUnknown ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlUnknownToUnknown () const
 Cast to a more defined type. Will return null if not of the requested type.
int Type () const
const char * Value () const
const TIXML_STRING & ValueTStr () const
virtual ~TiXmlNode ()

Protected Member Functions

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

Protected Attributes

TiXmlNodefirstChild
TiXmlNodelastChild
TiXmlNodenext
TiXmlNodeparent
TiXmlNodeprev
NodeType type
TIXML_STRING value

Private Member Functions

void operator= (const TiXmlNode &base)
 TiXmlNode (const TiXmlNode &)

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 
STYLESHEETREFERENCE 
TYPECOUNT 


Constructor & Destructor Documentation

TiXmlNode::~TiXmlNode (  )  [virtual]

References firstChild, and next.

TiXmlNode::TiXmlNode ( NodeType  _type  )  [protected]

References firstChild, lastChild, next, parent, prev, and type.

TiXmlNode::TiXmlNode ( const TiXmlNode  )  [private]


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, TiXmlStylesheetReference, TiXmlUnknown, and TiXmlDocument.

void TiXmlNode::Clear (  ) 

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, TiXmlStylesheetReference, TiXmlUnknown, and TiXmlDocument.

Referenced by TiXmlDocument::CopyTo(), TiXmlElement::CopyTo(), InsertAfterChild(), InsertBeforeChild(), InsertEndChild(), and ReplaceChild().

void TiXmlNode::CopyTo ( TiXmlNode target  )  const [protected]

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 char *  value  )  const

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

References firstChild, next, and Value().

TiXmlNode* TiXmlNode::FirstChild (  )  [inline]

References firstChild.

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

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

const TiXmlElement * TiXmlNode::FirstChildElement ( const char *  _value  )  const

Convenience function to get through elements.

References FirstChild(), NextSibling(), and ToElement().

TiXmlElement* TiXmlNode::FirstChildElement (  )  [inline]

const TiXmlElement * TiXmlNode::FirstChildElement (  )  const

Convenience function to get through elements.

References FirstChild(), NextSibling(), and ToElement().

Referenced by TiXmlDocument::RootElement().

TiXmlDocument* TiXmlNode::GetDocument (  )  [inline]

const TiXmlDocument * TiXmlNode::GetDocument (  )  const

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.

References Clone(), DOCUMENT, GetDocument(), lastChild, next, parent, prev, TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY, and Type().

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.

References Clone(), DOCUMENT, firstChild, GetDocument(), next, parent, prev, TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY, and Type().

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.

References Clone(), DOCUMENT, GetDocument(), LinkEndChild(), TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY, and Type().

TiXmlNode* TiXmlNode::IterateChildren ( const char *  _value,
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'.

References FirstChild(), NextSibling(), and parent.

TiXmlNode* TiXmlNode::IterateChildren ( 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.

References FirstChild(), NextSibling(), and parent.

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

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

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

References lastChild, prev, and Value().

TiXmlNode* TiXmlNode::LastChild (  )  [inline]

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

References lastChild.

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

References lastChild.

Referenced by TiXmlPrinter::VisitEnter().

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

References DOCUMENT, firstChild, GetDocument(), lastChild, next, parent, prev, TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY, and Type().

Referenced by TiXmlDocument::CopyTo(), TiXmlElement::CopyTo(), InsertEndChild(), TiXmlDocument::Parse(), and TiXmlElement::ReadValue().

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

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

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

References next, and Value().

TiXmlNode* TiXmlNode::NextSibling (  )  [inline]

References next.

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

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

const TiXmlElement * TiXmlNode::NextSiblingElement ( const char *  _value  )  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.

References NextSibling(), and ToElement().

TiXmlElement* TiXmlNode::NextSiblingElement (  )  [inline]

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.

References NextSibling(), and ToElement().

Referenced by TiXmlHandle::ChildElement().

bool TiXmlNode::NoChildren (  )  const [inline]

Returns true if this node has no children.

References firstChild.

void TiXmlNode::operator= ( const TiXmlNode base  )  [private]

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

References parent.

TiXmlNode* TiXmlNode::Parent (  )  [inline]

One step up the DOM.

References parent.

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

const TiXmlNode * TiXmlNode::PreviousSibling ( const char *  _value  )  const

Navigate to a sibling node.

References prev, and Value().

TiXmlNode* TiXmlNode::PreviousSibling (  )  [inline]

References prev.

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

Navigate to a sibling node.

References prev.

bool TiXmlNode::RemoveChild ( TiXmlNode removeThis  ) 

Delete a child of this node.

References firstChild, lastChild, next, parent, and prev.

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.

References Clone(), firstChild, lastChild, next, parent, and prev.

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 CopyTo(), 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 TiXmlDeclaration* TiXmlNode::ToDeclaration (  )  [inline, virtual]

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

Reimplemented in TiXmlDeclaration.

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.

Referenced by TiXmlDocument::Parse().

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.

Referenced by GetDocument().

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

Referenced by FirstChildElement(), and NextSiblingElement().

virtual TiXmlStylesheetReference* TiXmlNode::ToStylesheetReference (  )  [inline, virtual]

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

Reimplemented in TiXmlStylesheetReference.

virtual const TiXmlStylesheetReference* TiXmlNode::ToStylesheetReference (  )  const [inline, virtual]

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

Reimplemented in TiXmlStylesheetReference.

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.

Referenced by TiXmlElement::GetText(), TiXmlElement::Print(), and TiXmlPrinter::VisitEnter().

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.

Reimplemented in TiXmlStylesheetReference.

References type.

Referenced by InsertAfterChild(), InsertBeforeChild(), InsertEndChild(), and LinkEndChild().

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.

Referenced by TiXmlElement::Clone(), FirstChild(), TiXmlElement::GetText(), LastChild(), TiXmlDocument::LoadFile(), NextSibling(), PreviousSibling(), TiXmlDocument::SaveFile(), TiXmlPrinter::Visit(), TiXmlPrinter::VisitEnter(), and TiXmlPrinter::VisitExit().

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

References value.

Referenced by TiXmlPrinter::Visit().


Friends And Related Function Documentation

friend class TiXmlDocument [friend]

Reimplemented from TiXmlBase.

friend class TiXmlElement [friend]

Reimplemented from TiXmlBase.

Reimplemented in TiXmlText.

Referenced by Identify().


Member Data Documentation

TiXmlNode* TiXmlNode::next [protected]

TiXmlNode* TiXmlNode::prev [protected]

Reimplemented in TiXmlStylesheetReference.

Referenced by TiXmlNode(), and Type().

TIXML_STRING TiXmlNode::value [protected]


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

Generated on Tue Jul 28 16:21:15 2009 for Orxonox by  doxygen 1.5.6