ticpp::Node Class Reference

Wrapper around TiXmlNode. More...

#include <ticpp.h>

Inheritance diagram for ticpp::Node:

ticpp::Base ticpp::NodeImp< T > ticpp::NodeImp< TiXmlComment > ticpp::NodeImp< TiXmlDeclaration > ticpp::NodeImp< TiXmlDocument > ticpp::NodeImp< TiXmlElement > ticpp::NodeImp< TiXmlText > ticpp::Comment ticpp::Declaration ticpp::Document ticpp::Element ticpp::Text List of all members.

Public Member Functions

template<class T>
void GetValue (T *value)
 Get the value of this node Uses Base::FromString to convert TiXmlNode::ValueStr from a std::string, and puts it in the passed pointer.
std::string Value ()
 Get the value of this node.
template<class T>
void SetValue (const T &value)
 Set the value of this node.
void Clear ()
 Clear all Nodes below this.
NodeParent (bool throwIfNoParent=true)
 The Parent of this Node.
NodeFirstChild (bool throwIfNoChildren=true)
 The first child of this node.
NodeFirstChild (const std::string &value, bool throwIfNoChildren=true)
 The first child of this node with the matching value.
NodeLastChild (bool throwIfNoChildren=true)
 The last child of this node.
NodeLastChild (const std::string &value, bool throwIfNoChildren=true)
 The last child of this node with the matching value.
NodeIterateChildren (Node *previous)
 An alternate way to walk the children of a node.
NodeIterateChildren (const std::string &value, Node *previous)
 This flavor of IterateChildren searches for children with a particular value.
NodeInsertEndChild (Node &addThis)
 Adds a child past the LastChild.
NodeLinkEndChild (Node *childNode)
 Adds a child past the LastChild.
NodeInsertBeforeChild (Node *beforeThis, Node &addThis)
 Adds a child before the specified child.
NodeInsertAfterChild (Node *afterThis, Node &addThis)
 Adds a child after the specified child.
NodeReplaceChild (Node *replaceThis, Node &withThis)
 Replace a child of this node.
void RemoveChild (Node *removeThis)
 Delete a child of this node.
NodePreviousSibling (bool throwIfNoSiblings=true)
 Navigate to a sibling node.
NodePreviousSibling (const std::string &value, bool throwIfNoSiblings=true)
 Navigate to a sibling node with the given value.
NodeNextSibling (bool throwIfNoSiblings=true)
 Navigate to a sibling node.
NodeNextSibling (const std::string &value, bool throwIfNoSiblings=true)
 Navigate to a sibling node with the given value.
ElementNextSiblingElement (bool throwIfNoSiblings=true)
 Navigate to a sibling element.
ElementNextSiblingElement (const std::string &value, bool throwIfNoSiblings=true)
 Navigate to a sibling element with the given value.
ElementFirstChildElement (bool throwIfNoChildren=true)
 The first child element of this node.
ElementFirstChildElement (const std::string &value, bool throwIfNoChildren=true)
 The first child element of this node with the matching value.
int Type ()
 Query the type (as TiXmlNode::NodeType ) of this node.
DocumentGetDocument (bool throwIfNoDocument=true)
 Return a pointer to the Document this node lives in.
bool NoChildren ()
 Check if this node has no children.
template<class T>
T * To ()
 Pointer conversion ( NOT OBJECT CONVERSION ) - replaces TiXmlNode::ToElement, TiXmlNode::ToDocument, TiXmlNode::ToComment, etc.
DocumentToDocument ()
 Pointer conversion - replaces TiXmlNode::ToDocument.
ElementToElement ()
 Pointer conversion - replaces TiXmlNode::ToElement.
CommentToComment ()
 Pointer conversion - replaces TiXmlNode::ToComment.
TextToText ()
 Pointer conversion - replaces TiXmlNode::ToText.
DeclarationToDeclaration ()
 Pointer conversion - replaces TiXmlNode::ToDeclaration.
std::auto_ptr< NodeClone ()
 Create an exact duplicate of this node and return it.

Detailed Description

Wrapper around TiXmlNode.


Member Function Documentation

void ticpp::Node::Clear (  ) 

Clear all Nodes below this.

Simple wrapper for TiXmlNode::Clear.

std::auto_ptr< Node > ticpp::Node::Clone (  ) 

Create an exact duplicate of this node and return it.

Note:
Using auto_ptr to manage the memory declared on the heap by TiXmlNode::Clone.
        // Now using clone
        ticpp::Document doc( "C:\\Test.xml" );
        ticpp::Node* sectionToClone;
        sectionToClone = doc.FirstChild( "settings" );
        std::auto_ptr< ticpp::Node > clonedNode = sectionToClone->Clone();
        // Now you can use the clone.
        ticpp::Node* node2 = clonedNode->FirstChildElement()->FirstChild();
        ...
        // After the variable clonedNode goes out of scope it will automatically be cleaned up.
Returns:
Pointer the duplicate node.

Node* ticpp::Node::FirstChild ( const std::string &  value,
bool  throwIfNoChildren = true 
)

The first child of this node with the matching value.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
value Value to match.
throwIfNoChildren [DEF] If true, will throw an exception if there are no children.
See also:
FirstChild( const char* value, bool throwIfNoChildren = true )

Node* ticpp::Node::FirstChild ( bool  throwIfNoChildren = true  ) 

The first child of this node.

Parameters:
throwIfNoChildren [DEF] If true, will throw an exception if there are no children.
Returns:
Pointer to child, Null if no children and 'throwIfNoChildren' is false.
Exceptions:
Exception When throwIfNoChildren is true, and TiXmlNode::FirstChild returns Null.
See also:
TiXmlNode::FirstChild

Element* ticpp::Node::FirstChildElement ( const std::string &  value,
bool  throwIfNoChildren = true 
)

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
value Value to match.
throwIfNoChildren [DEF] If true, will throw an exception if there are no element children.
See also:
FirstChildElement( const char* value, bool throwIfNoChildren = true )

Element* ticpp::Node::FirstChildElement ( bool  throwIfNoChildren = true  ) 

The first child element of this node.

Parameters:
throwIfNoChildren [DEF] If true, will throw an exception if there are no element children.
Returns:
Pointer to child, Null if no element children and 'throwIfNoChildren' is false.
Exceptions:
Exception When throwIfNoChildren is true, and TiXmlNode::FirstChildElement returns Null.
See also:
TiXmlNode::FirstChildElement

Document* ticpp::Node::GetDocument ( bool  throwIfNoDocument = true  ) 

Return a pointer to the Document this node lives in.

Parameters:
throwIfNoDocument [DEF] If true, will throw an exception if this node is not linked under a Document.
Returns:
A pointer to the Document this node lives in, NULL if not linked under a Document, and 'throwIfNoDocument' is false.
Exceptions:
Exception When this node is not linked under a Document and 'throwIfNoDocument' is true.

template<class T>
void ticpp::Node::GetValue ( T *  value  )  [inline]

Get the value of this node Uses Base::FromString to convert TiXmlNode::ValueStr from a std::string, and puts it in the passed pointer.

Parameters:
value [OUT] A pointer to fill with the value

Node* ticpp::Node::InsertAfterChild ( Node afterThis,
Node addThis 
)

Adds a child after the specified child.

Throws if you try to insert a document.

Parameters:
afterThis Node that will have addThis linked after.
addThis Node to insert after.
Exceptions:
Exception When TiXmlNode::InsertAfterChild returns Null.
See also:
InsertBeforeChild

TiXmlNode::InsertAfterChild

Node* ticpp::Node::InsertBeforeChild ( Node beforeThis,
Node addThis 
)

Adds a child before the specified child.

Throws if you try to insert a document.

Parameters:
beforeThis Node that will have addThis linked before.
addThis Node to insert before.
Exceptions:
Exception When TiXmlNode::InsertBeforeChild returns Null.
See also:
InsertAfterChild

TiXmlNode::InsertBeforeChild

Node* ticpp::Node::InsertEndChild ( Node addThis  ) 

Adds a child past the LastChild.

Throws if you try to insert a document.

Note:
This takes a copy of addThis so it is not as efficiant as LinkEndChild.
Parameters:
addThis Node to insert.
Exceptions:
Exception When TiXmlNode::InsertEndChild returns Null
See also:
LinkEndChild

TiXmlNode::InsertEndChild

Node* ticpp::Node::IterateChildren ( const std::string &  value,
Node previous 
)

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

Simple wrapper for TiXmlNode::IterateChildren.

Parameters:
value The value you want to search for.
previous The previous Node* that was returned from IterateChildren.

Node* ticpp::Node::IterateChildren ( Node previous  ) 

An alternate way to walk the children of a node.

Simple wrapper for TiXmlNode::IterateChildren.

Parameters:
previous The previous Node* that was returned from IterateChildren.

Node* ticpp::Node::LastChild ( const std::string &  value,
bool  throwIfNoChildren = true 
)

The last child of this node with the matching value.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
value Value to match.
throwIfNoChildren [DEF] If true, will throw an exception if there are no children.
See also:
LastChild( const char* value, bool throwIfNoChildren = true )

Node* ticpp::Node::LastChild ( bool  throwIfNoChildren = true  ) 

The last child of this node.

Parameters:
throwIfNoChildren [DEF] If true, will throw an exception if there are no children.
Returns:
Pointer to child, Null if no children and 'throwIfNoChildren' is false.
Exceptions:
Exception When throwIfNoChildren is true, and TiXmlNode::LastChild returns Null.
See also:
TiXmlNode::LastChild

Node* ticpp::Node::LinkEndChild ( Node childNode  ) 

Adds a child past the LastChild.

Throws if you try to link a document.

Parameters:
childNode Node to link.
Exceptions:
Exception When TiXmlNode::LinkEndChild returns Null.
See also:
InsertEndChild

TiXmlNode::LinkEndChild

Node* ticpp::Node::NextSibling ( const std::string &  value,
bool  throwIfNoSiblings = true 
)

Navigate to a sibling node with the given value.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
value The value of the node to look for.
throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
See also:
NextSibling( bool throwIfNoSiblings )

Node* ticpp::Node::NextSibling ( bool  throwIfNoSiblings = true  ) 

Navigate to a sibling node.

Wrapper around TiXmlNode::NextSibling.

Parameters:
throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
Returns:
Pointer to sibling, Null if no siblings and 'throwIfNoSiblings' is false.
Exceptions:
Exception When TiXmlNode::NextSibling returns Null and 'throwIfNoSiblings' is true.

Element* ticpp::Node::NextSiblingElement ( const std::string &  value,
bool  throwIfNoSiblings = true 
)

Navigate to a sibling element with the given value.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
value The value of the element to look for.
throwIfNoSiblings [DEF] If true, will throw an exception if there are no sibling elements.
See also:
NextSiblingElement( bool throwIfNoSiblings )

Element* ticpp::Node::NextSiblingElement ( bool  throwIfNoSiblings = true  ) 

Navigate to a sibling element.

Wrapper around TiXmlNode::NextSibling.

Parameters:
throwIfNoSiblings [DEF] If true, will throw an exception if there are no sibling element.
Returns:
Pointer to sibling, Null if no siblings and 'throwIfNoSiblings' is false.
Exceptions:
Exception When TiXmlNode::NextSibling returns Null and 'throwIfNoSiblings' is true.

bool ticpp::Node::NoChildren (  ) 

Check if this node has no children.

Returns:
true if this node has no children.

Node* ticpp::Node::Parent ( bool  throwIfNoParent = true  ) 

The Parent of this Node.

Simple wrapper for TiXmlNode::Parent.

Parameters:
throwIfNoParent [DEF] If true, throws when Parent = NULL.
Returns:
The parent of this node, NULL if there is no Parent.
Exceptions:
Exception When throwIfNoParent is true, and TiXmlNode::Parent returns Null.

Node* ticpp::Node::PreviousSibling ( const std::string &  value,
bool  throwIfNoSiblings = true 
)

Navigate to a sibling node with the given value.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
value The value of the node to look for.
throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
See also:
PreviousSibling( bool throwIfNoSiblings )

Node* ticpp::Node::PreviousSibling ( bool  throwIfNoSiblings = true  ) 

Navigate to a sibling node.

Wrapper around TiXmlNode::PreviousSibling.

Parameters:
throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
Returns:
Pointer to sibling, Null if no siblings and 'throwIfNoSiblings' is false.
Exceptions:
Exception When TiXmlNode::PreviousSibling returns Null and 'throwIfNoSiblings' is true.

void ticpp::Node::RemoveChild ( Node removeThis  ) 

Delete a child of this node.

Parameters:
removeThis Node to delete.
Exceptions:
Exception When removeThis is not a child of this Node.
See also:
TiXmlNode::RemoveChild

Node* ticpp::Node::ReplaceChild ( Node replaceThis,
Node withThis 
)

Replace a child of this node.

Throws if you try to replace with a document.

Parameters:
replaceThis Node to replace.
withThis Node that is replacing replaceThis.
Exceptions:
Exception When TiXmlNode::ReplaceChild returns Null.
See also:
TiXmlNode::ReplaceChild

template<class T>
void ticpp::Node::SetValue ( const T &  value  )  [inline]

Set the value of this node.

Uses Base::ToString to convert value to a std::string, then calls TiXmlNode::SetValue.

Parameters:
value The value to set

template<class T>
T* ticpp::Node::To (  )  [inline]

Pointer conversion ( NOT OBJECT CONVERSION ) - replaces TiXmlNode::ToElement, TiXmlNode::ToDocument, TiXmlNode::ToComment, etc.

Exceptions:
Exception When the target is not an object of class T
Warning:
Some ancient compilers do not support explicit specification of member template arguments, which this depends on ( e.g. VC6 ).

Comment* ticpp::Node::ToComment (  ) 

Pointer conversion - replaces TiXmlNode::ToComment.

Exceptions:
Exception When this node is not a Comment.

Declaration* ticpp::Node::ToDeclaration (  ) 

Pointer conversion - replaces TiXmlNode::ToDeclaration.

Exceptions:
Exception When this node is not a Declaration.

Document* ticpp::Node::ToDocument (  ) 

Pointer conversion - replaces TiXmlNode::ToDocument.

Exceptions:
Exception When this node is not a Document.

Element* ticpp::Node::ToElement (  ) 

Pointer conversion - replaces TiXmlNode::ToElement.

Exceptions:
Exception When this node is not a Element.

Text* ticpp::Node::ToText (  ) 

Pointer conversion - replaces TiXmlNode::ToText.

Exceptions:
Exception When this node is not a Text.

std::string ticpp::Node::Value (  ) 

Get the value of this node.

Simple wrapper for TiXmlNode::ValueStr.

See also:
GetValue


The documentation for this class was generated from the following file:
Generated on Thu Sep 7 14:23:33 2006 for TinyXml by  doxygen 1.4.7