ticpp::Node Class Reference

Wrapper around TiXmlNode. More...

#include <ticpp.h>

Inheritance diagram for ticpp::Node:

ticpp::Base ticpp::NodeImp< TiXmlComment > ticpp::NodeImp< TiXmlDeclaration > ticpp::NodeImp< TiXmlDocument > ticpp::NodeImp< TiXmlElement > ticpp::NodeImp< TiXmlStylesheetReference > ticpp::NodeImp< TiXmlText > ticpp::NodeImp< T > ticpp::Comment ticpp::Declaration ticpp::Document ticpp::Element ticpp::StylesheetReference ticpp::Text

List of all members.

Public Member Functions

template<class T>
void GetValue (T *value) const
 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 () const
 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) const
 The Parent of this Node.
NodeFirstChild (bool throwIfNoChildren=true) const
 The first child of this node.
NodeFirstChild (const std::string &value, bool throwIfNoChildren=true) const
 The first child of this node with the matching value.
NodeLastChild (bool throwIfNoChildren=true) const
 The last child of this node.
NodeLastChild (const std::string &value, bool throwIfNoChildren=true) const
 The last child of this node with the matching value.
NodeIterateChildren (Node *previous) const
 An alternate way to walk the children of a node.
NodeIterateChildren (const std::string &value, Node *previous) const
 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) const
 Navigate to a sibling node.
NodePreviousSibling (const std::string &value, bool throwIfNoSiblings=true) const
 Navigate to a sibling node with the given value.
NodeNextSibling (bool throwIfNoSiblings=true) const
 Navigate to a sibling node.
NodeNextSibling (const std::string &value, bool throwIfNoSiblings=true) const
 Navigate to a sibling node with the given value.
ElementNextSiblingElement (bool throwIfNoSiblings=true) const
 Navigate to a sibling element.
ElementNextSiblingElement (const std::string &value, bool throwIfNoSiblings=true) const
 Navigate to a sibling element with the given value.
ElementFirstChildElement (bool throwIfNoChildren=true) const
 The first child element of this node.
ElementFirstChildElement (const std::string &value, bool throwIfNoChildren=true) const
 The first child element of this node with the matching value.
int Type () const
 Query the type (as TiXmlNode::NodeType ) of this node.
DocumentGetDocument (bool throwIfNoDocument=true) const
 Return a pointer to the Document this node lives in.
bool NoChildren () const
 Check if this node has no children.
template<class T>
T * To () const
 Pointer conversion ( NOT OBJECT CONVERSION ) - replaces TiXmlNode::ToElement, TiXmlNode::ToDocument, TiXmlNode::ToComment, etc.
DocumentToDocument () const
 Pointer conversion - replaces TiXmlNode::ToDocument.
ElementToElement () const
 Pointer conversion - replaces TiXmlNode::ToElement.
CommentToComment () const
 Pointer conversion - replaces TiXmlNode::ToComment.
TextToText () const
 Pointer conversion - replaces TiXmlNode::ToText.
DeclarationToDeclaration () const
 Pointer conversion - replaces TiXmlNode::ToDeclaration.
StylesheetReferenceToStylesheetReference () const
 Pointer conversion - replaces TiXmlNode::ToStylesheetReference.
std::auto_ptr< NodeClone () const
 Create an exact duplicate of this node and return it.
bool Accept (TiXmlVisitor *visitor) const
 Accept a hierchical visit the nodes in the TinyXML DOM.

Friends

std::istream & operator>> (std::istream &in, Node &base)
 Stream input operator.
std::ostream & operator<< (std::ostream &out, const Node &base)
 Stream output operator.


Detailed Description

Wrapper around TiXmlNode.

Member Function Documentation

template<class T>
void ticpp::Node::GetValue ( T *  value  )  const [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

References ticpp::Base::FromString().

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

Get the value of this node.

Simple wrapper for TiXmlNode::ValueStr.

See also:
GetValue

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

References TiXmlNode::SetValue(), and ticpp::Base::ToString().

void ticpp::Node::Clear (  ) 

Clear all Nodes below this.

Simple wrapper for TiXmlNode::Clear.

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

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::FirstChild ( bool  throwIfNoChildren = true  )  const

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

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

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::LastChild ( bool  throwIfNoChildren = true  )  const

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::LastChild ( const std::string &  value,
bool  throwIfNoChildren = true 
) const

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::IterateChildren ( Node previous  )  const

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.
Returns:
NULL When there are no more children.

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

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.
Returns:
NULL When there are no more children.

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

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::PreviousSibling ( bool  throwIfNoSiblings = true  )  const

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.

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

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::NextSibling ( bool  throwIfNoSiblings = true  )  const

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.

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

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 )

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

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.

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

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::FirstChildElement ( bool  throwIfNoChildren = true  )  const

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

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

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 )

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

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.

bool ticpp::Node::NoChildren (  )  const

Check if this node has no children.

Returns:
true if this node has no children.

template<class T>
T* ticpp::Node::To (  )  const [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 ).

Document* ticpp::Node::ToDocument (  )  const

Pointer conversion - replaces TiXmlNode::ToDocument.

Exceptions:
Exception When this node is not a Document.

Element* ticpp::Node::ToElement (  )  const

Pointer conversion - replaces TiXmlNode::ToElement.

Exceptions:
Exception When this node is not a Element.

Comment* ticpp::Node::ToComment (  )  const

Pointer conversion - replaces TiXmlNode::ToComment.

Exceptions:
Exception When this node is not a Comment.

Text* ticpp::Node::ToText (  )  const

Pointer conversion - replaces TiXmlNode::ToText.

Exceptions:
Exception When this node is not a Text.

Declaration* ticpp::Node::ToDeclaration (  )  const

Pointer conversion - replaces TiXmlNode::ToDeclaration.

Exceptions:
Exception When this node is not a Declaration.

StylesheetReference* ticpp::Node::ToStylesheetReference (  )  const

Pointer conversion - replaces TiXmlNode::ToStylesheetReference.

Exceptions:
Exception When this node is not a StylesheetReference.

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

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.

bool ticpp::Node::Accept ( TiXmlVisitor visitor  )  const

Accept a hierchical visit the nodes in the TinyXML DOM.

Returns:
The boolean returned by the visitor.


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

Generated on Sun Feb 15 23:12:14 2009 for TinyXml by  doxygen 1.5.6