OpenSim::XMLNode Class Reference

A class for performing operations on XML nodes. More...

#include <XMLNode.h>

List of all members.

Public Member Functions

template<>
void SetValueArray (DOMNode *aNode, int aN, const bool *rData)
template<>
void SetValueArray (DOMNode *aNode, int aN, const int *rData)
template<>
void SetValueArray (DOMNode *aNode, int aN, const double *rData)
template<>
void SetValueArray (DOMNode *aNode, int aN, const std::string *rData)
template<>
int GetValueArray (const DOMNode *aNode, bool *&rData)
template<>
int GetValueArray (const DOMNode *aNode, int *&rData)
template<>
int GetValueArray (const DOMNode *aNode, double *&rData)
template<>
int GetValueArray (const DOMNode *aNode, std::string *&rData)

Static Public Member Functions

static int GetNumberOfParents (const DOMNode *node)
 Get the number of paraents a node has.
static std::string ToString (const DOMNode *aNode)
static std::string NodeContextString (const DOMNode *aNode)
static std::string Transcode (const XMLCh *aCh)
static std::string TranscodeAndTrim (const XMLCh *aCh)
static DOMElement * AppendNewElementWithComment (DOMNode *aParent, const std::string &aTag, const std::string &aName="", const std::string &aComment="")
static DOMElement * InsertNewElementWithComment (DOMNode *aParent, const std::string &aTag, const std::string &aName="", const std::string &aComment="", int aNodeIndex=0)
static void RemoveChildren (DOMNode *aNode)
 Remove all the children of a specified node.
static DOMNode * FindInsertionPoint (DOMNode *aElement, int aNodeIndex)
 Find the first node (comment or otherwise) that corresponds to the Nth object (N is aNodeIndex, and is one-based).
static void RemoveElementFromParent (DOMElement *aElement, bool aRemoveWhitespaceAndComments=true)
 Remove an element from its parent, and optionally remove whitespace and comments associated with that node.
static void UpdateCommentNodeCorrespondingToChildElement (DOMElement *aElement, const std::string &aComment)
static DOMText * CreateDOMText (DOMDocument *aDocument, const std::string &aText)
static DOMComment * CreateDOMComment (DOMDocument *aDocument, const std::string &aComment)
static DOMElement * CreateDOMElement (DOMDocument *aDocument, const std::string &aTag)
static DOMElement * GetFirstChildElementByTagName (const DOMNode *aNode, const std::string &aTagName, const std::string *aName=0, bool aCheckForMultiple=true)
static DOMCharacterData * GetCDataSectionNode (const DOMNode *aNode)
 Get the last character data section node associated with a specified node.
static DOMText * GetTextNode (const DOMNode *aNode)
 Get the last text node of a specified node.
static bool GetBool (const DOMNode *aNode)
 Interpret the value of this node as an bool.
static int GetInt (const DOMNode *aNode)
 Interpret the value of this node as an int.
static double GetDbl (const DOMNode *aNode)
 Interpret the value of this node as a double.
static std::string GetStr (const DOMNode *aNode)
 Interpret the value of this node as string.
static void SetBoolArray (DOMNode *aNode, int aN, const bool *aData)
 Set the text of a node to represent an array of booleans.
static int GetBoolArray (const DOMNode *aNode, bool *&rData)
 Interpret the value of this node as an array of boolean variables.
static void SetIntArray (DOMNode *aNode, int aN, const int *aData)
 Set the text of a node to represent an array of ints.
static int GetIntArray (const DOMNode *aNode, int *&rData)
 Interpret the value of this node as an array of ints.
static void SetDblArray (DOMNode *aNode, int aN, const double *aData)
 Set the text of a node to represent an array of doubles.
static int GetDblArray (const DOMNode *aNode, double *&rData)
 Interpret the value of this node as an array of doubles.
static void SetStrArray (DOMNode *aNode, int aN, const std::string *aData)
static int GetStrArray (const DOMNode *aNode, std::string *&rData)
template<class T >
static T GetValue (const DOMNode *aNode)
template<class T >
static void SetValueArray (DOMNode *aNode, int aN, const T *rData)
template<class T >
static int GetValueArray (const DOMNode *aNode, T *&rData)
static void SetAttribute (DOMNode *aNode, const std::string &aName, const std::string &aValue)
static std::string GetAttribute (DOMNode *aNode, const std::string &aName)
static void RemoveAttribute (DOMNode *aNode, const std::string &aName)

Detailed Description

A class for performing operations on XML nodes.

The methods in this class are generally static methods that take an DOMNode as their first argument.

This product includes software developed by the Apache Software Foundation (http://www.apache.org/).

Version:
1.0
Author:
Frank C. Anderson

Member Function Documentation

static DOMElement* OpenSim::XMLNode::AppendNewElementWithComment ( DOMNode *  aParent,
const std::string &  aTag,
const std::string &  aName = "",
const std::string &  aComment = "" 
) [static]
static DOMComment* OpenSim::XMLNode::CreateDOMComment ( DOMDocument *  aDocument,
const std::string &  aComment 
) [static]
static DOMElement* OpenSim::XMLNode::CreateDOMElement ( DOMDocument *  aDocument,
const std::string &  aTag 
) [static]
static DOMText* OpenSim::XMLNode::CreateDOMText ( DOMDocument *  aDocument,
const std::string &  aText 
) [static]
DOMNode * XMLNode::FindInsertionPoint ( DOMNode *  aParent,
int  aNodeIndex 
) [static]

Find the first node (comment or otherwise) that corresponds to the Nth object (N is aNodeIndex, and is one-based).

This method is used to find the appropriate insertion point for the nodes associated with an object that is being inserted into the middle of an array or set of objects. If the object will be the Nth one, then find the Nth element child of the parent node, and then back up over comment/text nodes, if there are any. This will be the node before which the new object's nodes should be inserted. This code assumes that all objects before the one being inserted already have their nodes in the parent.

static std::string OpenSim::XMLNode::GetAttribute ( DOMNode *  aNode,
const std::string &  aName 
) [static]
bool XMLNode::GetBool ( const DOMNode *  aNode  )  [static]

Interpret the value of this node as an bool.

If the specified node is a text node (DOMText) then it itself is interpretted. However, if the specified node is any other type of node (for example, an element node (DOMElement)), the data is interpretted from the specified node's last child that is a text node. If the specified node has no such child, an exception is thrown.

Returns:
Value. If an error is encountered a false is returned.
Exceptions:
Exception if it was not possible to get a value.
int XMLNode::GetBoolArray ( const DOMNode *  aNode,
bool *&  rData 
) [static]

Interpret the value of this node as an array of boolean variables.

If the specified node is a text node (DOMText) then it itself is interpretted. However, if the specified node is any other type of node (for example, an element node (DOMElement)), the data is interpretted from the specified node's last child that is a text node. If the specified node has no such child, rData is set to NULL and 0 is returned. The caller is responsible for deleting the returned array.

Parameters:
aNode Node from which to obtain the data.
rData Reference to a bool pointer. If there is no data, rData is set to NULL.
Returns:
Length of the array.
DOMCharacterData * XMLNode::GetCDataSectionNode ( const DOMNode *  aNode  )  [static]

Get the last character data section node associated with a specified node.

Parameters:
aNode Node for which to identify a character data section node.
Returns:
Character data section node. If aNode is a character data section node it is returned. Otherwise, aNode's children are searched, and the LAST character data section node child found is returned. If a character data section node is not found, NULL is returned.
double XMLNode::GetDbl ( const DOMNode *  aNode  )  [static]

Interpret the value of this node as a double.

If the specified node is a text node (DOMText) then it itself is interpretted. However, if the specified node is any other type of node (for example, an element node (DOMElement)), the data is interpretted from the specified node's last child that is a text node. If the specified node has no such child, an exception is thrown.

Returns:
Value. If an error is encountered 0.0 is returned.
Exceptions:
Exception if it was not possible to get a value.
int XMLNode::GetDblArray ( const DOMNode *  aNode,
double *&  rData 
) [static]

Interpret the value of this node as an array of doubles.

If the specified node is a text node (DOMText) then it itself is interpretted. However, if the specified node is any other type of node (for example, an element node (DOMElement)), the data is interpretted from the specified node's last child that is a text node. If the specified node has no such child, rData is set to NULL and 0 is returned.

The caller is responsible for deleting the returned array.

Parameters:
aNode Node from which to obtain the data.
rData Reference to a double pointer. If there is no data, rData is set to NULL.
Returns:
Length of the array.
static DOMElement* OpenSim::XMLNode::GetFirstChildElementByTagName ( const DOMNode *  aNode,
const std::string &  aTagName,
const std::string *  aName = 0,
bool  aCheckForMultiple = true 
) [static]
int XMLNode::GetInt ( const DOMNode *  aNode  )  [static]

Interpret the value of this node as an int.

If the specified node is a text node (DOMText) then it itself is interpretted. However, if the specified node is any other type of node (for example, an element node (DOMElement)), the data is interpretted from the specified node's last child that is a text node. If the specified node has no such child, an exception is thrown.

Returns:
Value. If an error is encountered a 0 is returned.
Exceptions:
Exception if it was not possible to get a value.
int XMLNode::GetIntArray ( const DOMNode *  aNode,
int *&  rData 
) [static]

Interpret the value of this node as an array of ints.

If the specified node is a text node (DOMText) then it itself is interpretted. However, if the specified node is any other type of node (for example, an element node (DOMElement)), the data is interpretted from the specified node's last child that is a text node. If the specified node has no such child, rData is set to NULL and 0 is returned. The caller is responsible for deleting the returned array.

Parameters:
aNode Node from which to obtain the data.
rData Reference to a int pointer. If there is no data, rData is set to NULL.
Returns:
Length of the array.
int XMLNode::GetNumberOfParents ( const DOMNode *  aNode  )  [static]

Get the number of paraents a node has.

The owner document is included in this count.

Parameters:
aNode Node for which to count the number of parents.
Returns:
Number of parents including the owner document.
string XMLNode::GetStr ( const DOMNode *  aNode  )  [static]

Interpret the value of this node as string.

Whitespace is trimmed before string is returned.

If the specified node is a text node (DOMText) then it itself is interpretted. However, if the specified node is any other type of node (for example, an element node (DOMElement)), the data is interpretted from the specified node's last child that is a text node. If the specified node has no such child, rData is set to NULL and 0 is returned.

Note that the caller is responsible for deleting the returned string.

Parameters:
aNode Node from which to obtain the data.
Returns:
Value. If an error is encountered NULL is returned.
Exceptions:
Exception if it was not possible to get a value.
static int OpenSim::XMLNode::GetStrArray ( const DOMNode *  aNode,
std::string *&  rData 
) [static]
DOMText * XMLNode::GetTextNode ( const DOMNode *  aNode  )  [static]

Get the last text node of a specified node.

Parameters:
aNode Node for which to identify a text node.
Returns:
Text node. If aNode is a text node it is returned. Otherwise, aNode's children are searched, and the LAST text node child found is returned. If a text node is not found, NULL is returned.
std::string OpenSim::XMLNode::GetValue ( const DOMNode *  aNode  )  [inline, static]
template<>
int OpenSim::XMLNode::GetValueArray ( const DOMNode *  aNode,
std::string *&  rData 
) [inline]
template<>
int OpenSim::XMLNode::GetValueArray ( const DOMNode *  aNode,
double *&  rData 
) [inline]
template<>
int OpenSim::XMLNode::GetValueArray ( const DOMNode *  aNode,
int *&  rData 
) [inline]
template<>
int OpenSim::XMLNode::GetValueArray ( const DOMNode *  aNode,
bool *&  rData 
) [inline]
template<class T >
static int OpenSim::XMLNode::GetValueArray ( const DOMNode *  aNode,
T *&  rData 
) [inline, static]
static DOMElement* OpenSim::XMLNode::InsertNewElementWithComment ( DOMNode *  aParent,
const std::string &  aTag,
const std::string &  aName = "",
const std::string &  aComment = "",
int  aNodeIndex = 0 
) [static]
string XMLNode::NodeContextString ( const DOMNode *  aNode  )  [static]
static void OpenSim::XMLNode::RemoveAttribute ( DOMNode *  aNode,
const std::string &  aName 
) [static]
void XMLNode::RemoveChildren ( DOMNode *  aNode  )  [static]

Remove all the children of a specified node.

Parameters:
aNode Node whose children are to be removed.
void XMLNode::RemoveElementFromParent ( DOMElement *  aElement,
bool  aRemoveWhitespaceAndComments = true 
) [static]

Remove an element from its parent, and optionally remove whitespace and comments associated with that node.

static void OpenSim::XMLNode::SetAttribute ( DOMNode *  aNode,
const std::string &  aName,
const std::string &  aValue 
) [static]
void XMLNode::SetBoolArray ( DOMNode *  aNode,
int  aN,
const bool *  aData 
) [static]

Set the text of a node to represent an array of booleans.

If the specified node is a text node (DOMText) then it itself is modified. However, if the specified node is any other type of node (for example, an element node (DOMElement)), the data is set on the specified node's last child that is a text node. If the specified node has no such child, a new text node is created and appended to the specified node as a child.

Parameters:
aNode Node on which to set the text data.
aN Size of the specified data array.
aData Data array.
void XMLNode::SetDblArray ( DOMNode *  aNode,
int  aN,
const double *  aData 
) [static]

Set the text of a node to represent an array of doubles.

If the specified node is a text node (DOMText) then it itself is modified. However, if the specified node is any other type of node (for example, an element node (DOMElement)), the data is set on the specified node's last child that is a text node. If the specified node has no such child, a new text node is created and appended to the specified node as a child.

Parameters:
aNode Node on which to set the text data.
aN Size of the specified data array.
aData Data array.
void XMLNode::SetIntArray ( DOMNode *  aNode,
int  aN,
const int *  aData 
) [static]

Set the text of a node to represent an array of ints.

If the specified node is a text node (DOMText) then it itself is modified. However, if the specified node is any other type of node (for example, an element node (DOMElement)), the data is set on the specified node's last child that is a text node. If the specified node has no such child, a new text node is created and appended to the specified node as a child.

Parameters:
aNode Node on which to set the text data.
aN Size of the specified data array.
aData Data array.
static void OpenSim::XMLNode::SetStrArray ( DOMNode *  aNode,
int  aN,
const std::string *  aData 
) [static]
template<>
void OpenSim::XMLNode::SetValueArray ( DOMNode *  aNode,
int  aN,
const std::string *  rData 
) [inline]
template<>
void OpenSim::XMLNode::SetValueArray ( DOMNode *  aNode,
int  aN,
const double *  rData 
) [inline]
template<>
void OpenSim::XMLNode::SetValueArray ( DOMNode *  aNode,
int  aN,
const int *  rData 
) [inline]
template<>
void OpenSim::XMLNode::SetValueArray ( DOMNode *  aNode,
int  aN,
const bool *  rData 
) [inline]
template<class T >
static void OpenSim::XMLNode::SetValueArray ( DOMNode *  aNode,
int  aN,
const T *  rData 
) [inline, static]
string XMLNode::ToString ( const DOMNode *  aNode  )  [static]
string XMLNode::Transcode ( const XMLCh *  aCh  )  [static]
string XMLNode::TranscodeAndTrim ( const XMLCh *  aCh  )  [static]
void XMLNode::UpdateCommentNodeCorrespondingToChildElement ( DOMElement *  aElement,
const std::string &  aComment 
) [static]

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

Generated on Sun Sep 25 00:19:53 2011 for OpenSim by  doxygen 1.6.1