Om  1.0.0
A universal framework for multimedia simulation
Public Types | Public Member Functions | List of all members
om::xml::XMLNode Class Reference

A class that stores a hierarchical representation of an XML node. More...

#include <omXMLNode.h>

Public Types

enum  Type { ROOT, ELEMENT, TEXT, COMMENT }
 

Public Member Functions

 XMLNode (Type newType)
 Create a new XML node with no children, no attributes, and the specified node type. More...
 
 XMLNode (Type newType, const UTF8String &newValue)
 Create a new XML node with no children, no attributes, and the specified type and value string. More...
 
 XMLNode (const XMLNode &other)
 
virtual ~XMLNode ()
 Destroy this XML node and release all resources that it contains. More...
 
Type getType () const
 Return an enum value representing the type of this node. More...
 
void setType (Type newType)
 Set an enum value representing the type of this node. More...
 
const UTF8String & getValue () const
 Return a string representing the value for this node. More...
 
void setValue (const UTF8String &newValue)
 Set a string representing the value for this node. More...
 
Size getAttributeCount () const
 Return the total number of attributes that this XML node has. More...
 
XMLAttributegetAttribute (Index index)
 Return a reference to the XML attribute at the specified index in this node. More...
 
const XMLAttributegetAttribute (Index index) const
 Return a const reference to the XML attribute at the specified index in this node. More...
 
XMLAttributegetAttribute (const UTF8String &name)
 Return a pointer to the XML attribute with the specified name in this node. More...
 
const XMLAttributegetAttribute (const UTF8String &name) const
 Return a const pointer to the XML attribute with the specified name in this node. More...
 
Bool getAttribute (const UTF8String &name, UTF8String &value) const
 Get the value of the specified attribute in the output parameter. More...
 
Bool getAttribute (const UTF8String &name, Bool &value) const
 Get an boolean value for the specified attribute in the output parameter. More...
 
Bool getAttribute (const UTF8String &name, Int32 &value) const
 Get a 32-bit integer value for the specified attribute in the output parameter. More...
 
Bool getAttribute (const UTF8String &name, UInt32 &value) const
 Get an unsigned 32-bit integer value for the specified attribute in the output parameter. More...
 
Bool getAttribute (const UTF8String &name, Int64 &value) const
 Get a 64-bit integer value for the specified attribute in the output parameter. More...
 
Bool getAttribute (const UTF8String &name, UInt64 &value) const
 Get an unsigned 64-bit integer value for the specified attribute in the output parameter. More...
 
Bool getAttribute (const UTF8String &name, Float &value) const
 Get a float value for the specified attribute in the output parameter. More...
 
Bool getAttribute (const UTF8String &name, Double &value) const
 Get a double value for the specified attribute in the output parameter. More...
 
void addAttribute (const UTF8String &name, const UTF8String &value)
 Add an attribute with the specified name and value to this XML node. More...
 
template<typename T >
void addAttribute (const UTF8String &name, const T &value)
 Add an attribute with the specified name and templated-type value to this XML node. More...
 
void setAttribute (const UTF8String &name, const UTF8String &value)
 Set the value of the attribute with the specified name in this XML node. More...
 
template<typename T >
void setAttribute (const UTF8String &name, const T &value)
 Set the value of the attribute with the specified name in this XML node. More...
 
Bool removeAttribute (const UTF8String &name)
 Remove the attribute with the specified name from this XML node. More...
 
void clearAttributes ()
 Remove all attributes from this XML node. More...
 
Size getChildCount () const
 Return the number of child nodes there are for this XML node. More...
 
const Shared< XMLNode > & getChild (Index childIndex) const
 Return a pointer to the child node of this node at the specified index in this node. More...
 
Shared< XMLNodegetFirstChildWithTag (const UTF8String &tag) const
 Return a pointer to the first child node of this node which has the specified node tag. More...
 
Bool getChildrenWithTag (const UTF8String &tag, ArrayList< Shared< XMLNode > > &nodes) const
 Get a list of all of the children of this node that have the specified node tag. More...
 
Shared< XMLNodegetFirstChildWithType (XMLNode::Type type) const
 Return a pointer to the first child node of this node which has the specified node type. More...
 
Bool getChildrenWithType (XMLNode::Type type, ArrayList< Shared< XMLNode > > &nodes) const
 Get a list of all of the children of this node that have the specified node type. More...
 
Bool addChild (const Shared< XMLNode > &newNode)
 Add the specified node to the end of this node's list of children. More...
 
Bool insertChild (Index insertionIndex, const Shared< XMLNode > &newNode)
 Insert the specified node into the specified index in this node's list of children. More...
 
Bool removeChild (Index childIndex)
 Remove the child node at the specified index in this node's list of children. More...
 
Size removeChildrenWithTag (const UTF8String &tag)
 Remove all children from this XML node that have the specified node tag. More...
 
void clearChildren ()
 Remove all child nodes from this node. More...
 

Detailed Description

A class that stores a hierarchical representation of an XML node.

Each XML node has an associated value that has a meaning that depends on the type of the node. A node with type XMLNode::ELEMENT can have a list of attribute name-value pairs for that element, and can have a list of child nodes.

Member Enumeration Documentation

Enumerator
ROOT 

A node type where the node represents the root node of a document.

ELEMENT 

A node type where the node represents a normal XML element.

TEXT 

A node type where the node corresponds to text data contained within another element.

COMMENT 

A node type where the node represents an XML comment.

Constructor & Destructor Documentation

om::xml::XMLNode::XMLNode ( Type  newType)

Create a new XML node with no children, no attributes, and the specified node type.

om::xml::XMLNode::XMLNode ( Type  newType,
const UTF8String &  newValue 
)

Create a new XML node with no children, no attributes, and the specified type and value string.

om::xml::XMLNode::XMLNode ( const XMLNode other)
virtual om::xml::XMLNode::~XMLNode ( )
virtual

Destroy this XML node and release all resources that it contains.

Member Function Documentation

Type om::xml::XMLNode::getType ( ) const
inline

Return an enum value representing the type of this node.

void om::xml::XMLNode::setType ( Type  newType)
inline

Set an enum value representing the type of this node.

const UTF8String& om::xml::XMLNode::getValue ( ) const
inline

Return a string representing the value for this node.

The purpose of this string depends on the node type:

  • ROOT: this value is unused.
  • ELEMENT: this value represents the element's tag.
  • TEXT: this value represents the node's text string.
  • COMMENT: this value represents the comment string.
void om::xml::XMLNode::setValue ( const UTF8String &  newValue)
inline

Set a string representing the value for this node.

The purpose of this string depends on the node type:

  • ROOT: this value is unused.
  • ELEMENT: this value represents the element's tag.
  • TEXT: this value represents the node's text string.
  • COMMENT: this value represents the comment string.
Size om::xml::XMLNode::getAttributeCount ( ) const
inline

Return the total number of attributes that this XML node has.

XMLAttribute& om::xml::XMLNode::getAttribute ( Index  index)
inline

Return a reference to the XML attribute at the specified index in this node.

const XMLAttribute& om::xml::XMLNode::getAttribute ( Index  index) const
inline

Return a const reference to the XML attribute at the specified index in this node.

XMLAttribute* om::xml::XMLNode::getAttribute ( const UTF8String &  name)

Return a pointer to the XML attribute with the specified name in this node.

The method returns NULL if there is no attribute with that name in this node.

const XMLAttribute* om::xml::XMLNode::getAttribute ( const UTF8String &  name) const

Return a const pointer to the XML attribute with the specified name in this node.

The method returns NULL if there is no attribute with that name in this node.

Bool om::xml::XMLNode::getAttribute ( const UTF8String &  name,
UTF8String &  value 
) const

Get the value of the specified attribute in the output parameter.

The method returns whether or not there was an attribute with that name. If there is no attribute with that name, the value reference is not changed.

Bool om::xml::XMLNode::getAttribute ( const UTF8String &  name,
Bool value 
) const

Get an boolean value for the specified attribute in the output parameter.

The method returns whether or not the attribute was able to be accessed and then successfully converted to the output value parameter's type. If the method fails, the value reference is not changed.

Bool om::xml::XMLNode::getAttribute ( const UTF8String &  name,
Int32 value 
) const

Get a 32-bit integer value for the specified attribute in the output parameter.

The method returns whether or not the attribute was able to be accessed and then successfully converted to the output value parameter's type. If the method fails, the value reference is not changed.

Bool om::xml::XMLNode::getAttribute ( const UTF8String &  name,
UInt32 value 
) const

Get an unsigned 32-bit integer value for the specified attribute in the output parameter.

The method returns whether or not the attribute was able to be accessed and then successfully converted to the output value parameter's type. If the method fails, the value reference is not changed.

Bool om::xml::XMLNode::getAttribute ( const UTF8String &  name,
Int64 value 
) const

Get a 64-bit integer value for the specified attribute in the output parameter.

The method returns whether or not the attribute was able to be accessed and then successfully converted to the output value parameter's type. If the method fails, the value reference is not changed.

Bool om::xml::XMLNode::getAttribute ( const UTF8String &  name,
UInt64 value 
) const

Get an unsigned 64-bit integer value for the specified attribute in the output parameter.

The method returns whether or not the attribute was able to be accessed and then successfully converted to the output value parameter's type. If the method fails, the value reference is not changed.

Bool om::xml::XMLNode::getAttribute ( const UTF8String &  name,
Float value 
) const

Get a float value for the specified attribute in the output parameter.

The method returns whether or not the attribute was able to be accessed and then successfully converted to the output value parameter's type. If the method fails, the value reference is not changed.

Bool om::xml::XMLNode::getAttribute ( const UTF8String &  name,
Double value 
) const

Get a double value for the specified attribute in the output parameter.

The method returns whether or not the attribute was able to be accessed and then successfully converted to the output value parameter's type. If the method fails, the value reference is not changed.

void om::xml::XMLNode::addAttribute ( const UTF8String &  name,
const UTF8String &  value 
)

Add an attribute with the specified name and value to this XML node.

template<typename T >
void om::xml::XMLNode::addAttribute ( const UTF8String &  name,
const T &  value 
)
inline

Add an attribute with the specified name and templated-type value to this XML node.

The template type must have an operator which allows conversion to a UTF8String.

void om::xml::XMLNode::setAttribute ( const UTF8String &  name,
const UTF8String &  value 
)

Set the value of the attribute with the specified name in this XML node.

If the attribute was not already part of the node, a new attribute with that name and value is added to the node.

template<typename T >
void om::xml::XMLNode::setAttribute ( const UTF8String &  name,
const T &  value 
)
inline

Set the value of the attribute with the specified name in this XML node.

If the attribute was not already part of the node, a new attribute with that name and value is added to the node.

The template type must have an operator which allows conversion to a UTF8String.

Bool om::xml::XMLNode::removeAttribute ( const UTF8String &  name)

Remove the attribute with the specified name from this XML node.

The method returns whether or not there was an attribute with that name that was removed successfully.

void om::xml::XMLNode::clearAttributes ( )

Remove all attributes from this XML node.

Size om::xml::XMLNode::getChildCount ( ) const
inline

Return the number of child nodes there are for this XML node.

const Shared<XMLNode>& om::xml::XMLNode::getChild ( Index  childIndex) const
inline

Return a pointer to the child node of this node at the specified index in this node.

Shared<XMLNode> om::xml::XMLNode::getFirstChildWithTag ( const UTF8String &  tag) const

Return a pointer to the first child node of this node which has the specified node tag.

If there is no child with that tag, a NULL pointer is returned. This method ignores any child nodes that don't have the node type ELEMENT.

Bool om::xml::XMLNode::getChildrenWithTag ( const UTF8String &  tag,
ArrayList< Shared< XMLNode > > &  nodes 
) const

Get a list of all of the children of this node that have the specified node tag.

The method places all of the children which have the specified tag into the given output list. The method returns whether or not any children with matching tags were found. This method ignores any child nodes that don't have the node type ELEMENT.

Shared<XMLNode> om::xml::XMLNode::getFirstChildWithType ( XMLNode::Type  type) const

Return a pointer to the first child node of this node which has the specified node type.

If there is no child with that node type, a NULL pointer is returned.

Bool om::xml::XMLNode::getChildrenWithType ( XMLNode::Type  type,
ArrayList< Shared< XMLNode > > &  nodes 
) const

Get a list of all of the children of this node that have the specified node type.

The method places all of the children which have the specified type into the given output list. The method returns whether or not any children with matching types were found.

Bool om::xml::XMLNode::addChild ( const Shared< XMLNode > &  newNode)

Add the specified node to the end of this node's list of children.

If the new child node pointer is NULL, the operation fails and FALSE is returned. Otherwise, TRUE is returned.

Bool om::xml::XMLNode::insertChild ( Index  insertionIndex,
const Shared< XMLNode > &  newNode 
)

Insert the specified node into the specified index in this node's list of children.

If the new child node pointer is NULL or the insertion index is not in the range [0,n], where n is the previous number of children, the operation fails and FALSE is returned. Otherwise, TRUE is returned.

Bool om::xml::XMLNode::removeChild ( Index  childIndex)

Remove the child node at the specified index in this node's list of children.

If the specified index is invalid, the method fails and FALSE is returned. Otherwise, the child is removed at that index and TRUE is returned. This method ignores any child nodes that don't have the node type ELEMENT.

Size om::xml::XMLNode::removeChildrenWithTag ( const UTF8String &  tag)

Remove all children from this XML node that have the specified node tag.

The method returns the number of children that were removed from the node.

void om::xml::XMLNode::clearChildren ( )

Remove all child nodes from this node.


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