SDX::Node Class Reference

A document node can have attributes and child nodes. More...

#include <SDXNode.h>

Inheritance diagram for SDX::Node:

SDX::NodeContainer

List of all members.

Public Member Functions

 Node (std::string name)
 Constructor.
 Node (Node &other)
 Copy contructor taking a reference to a node.
 Node (Node *other)
 Copy contructor taking a pointer to a node.
NodeaddAttribute (Attribute *attribute)
 Add attribute to node.
NodeaddAttribute (std::string name, std::string value)
 Convenience function that creates an attribute with the given name and value.
const std::string getName ()
 Get the name of this node.
const std::vector< Attribute * > getAttributes ()
 Get all attributes of this node.
const std::vector< Attribute * > getAttributes (std::string attributeName)
 Get all attributes that are named attributeName.
AttributegetAttribute (unsigned int index=0)
 Get the nth attribute of this node.
AttributegetAttribute (std::string attributeName)
 Get the last attribute that is named attributeName.
const std::vector< Attribute * > getNamedAttributes ()
 Get all named attributes of this node.
const std::vector< Attribute * > getUnnamedAttributes ()
 Get all unnamed attributes of this node.
template<class T >
bool getAttributeValue (T *value, int attributeIndex=0)
 Get the value of the nth attribute of this node.
template<class T >
bool getAttributeValue (T *value, std::string attributeName)
 Get the value of the last attribute that is named attributeName.
template<class T >
bool getNodeAttributeValue (T *value, std::string nodeName, int attributeIndex=0)
 Get the value of the nth attribute of the last child node that is named attributeName.
void sendToContentHandler (ContentHandler *contentHandler, bool onlySendContents=false)
 Send this node (recursively) to the given contentHandler.


Detailed Description

A document node can have attributes and child nodes.

Definition at line 16 of file SDXNode.h.


Constructor & Destructor Documentation

SDX::Node::Node ( std::string  name  ) 

Constructor.

Parameters:
name The name of the node

Node::Node ( Node other  ) 

Copy contructor taking a reference to a node.

Parameters:
other The node of which this node should be a copy.

Definition at line 15 of file SDXNode.cpp.

Node::Node ( Node other  ) 

Copy contructor taking a pointer to a node.

Parameters:
other The node of which this node should be a copy.

Definition at line 25 of file SDXNode.cpp.


Member Function Documentation

Node* SDX::Node::addAttribute ( std::string  name,
std::string  value 
)

Convenience function that creates an attribute with the given name and value.

This is equivalent to addAttribute(new Attribute(name, value)).

Parameters:
name The name of the attribute.
value The value of the attribute.

Node * Node::addAttribute ( Attribute attribute  ) 

Add attribute to node.

Remember that all child attributes of a node will be deallocated on destruction of the node unless NodeContainer::setDeallocateContentOnDestruct() has been called been used to prevent this.

Parameters:
attribute The attribute to add to the node.

Definition at line 42 of file SDXNode.cpp.

Attribute * Node::getAttribute ( std::string  attributeName  ) 

Get the last attribute that is named attributeName.

Parameters:
attributeName Name of the attribute to return.
Returns:
A pointer to the attribute named attributeName a NULL pointer if there's no such attribute.

Definition at line 81 of file SDXNode.cpp.

Attribute * Node::getAttribute ( unsigned int  index = 0  ) 

Get the nth attribute of this node.

Parameters:
index Position of the attribute to return.
Returns:
A pointer to the nth attribute of this node or a NULL pointer if the doesn't contain an attribute at this index.

Definition at line 73 of file SDXNode.cpp.

const std::vector<Attribute*> SDX::Node::getAttributes ( std::string  attributeName  ) 

Get all attributes that are named attributeName.

Parameters:
attributeName Only attributes that are named like this are returned.

template<class T >
bool SDX::Node::getAttributeValue ( T *  value,
std::string  attributeName 
) [inline]

Get the value of the last attribute that is named attributeName.

Parameters:
value The variable to write the value to.
attributeName Name of the attribute to get.
Returns:
True if there is an attribute at the given index and the value could be successfuly converted to type T, false otherwise.

Definition at line 112 of file SDXNode.h.

template<class T >
bool SDX::Node::getAttributeValue ( T *  value,
int  attributeIndex = 0 
) [inline]

Get the value of the nth attribute of this node.

Parameters:
value The variable to write the value to.
attributeIndex Position of the attribute to get.
Returns:
True if there is an attribute at the given index and the value could be successfuly converted to type T, false otherwise.

Definition at line 97 of file SDXNode.h.

template<class T >
bool SDX::Node::getNodeAttributeValue ( T *  value,
std::string  nodeName,
int  attributeIndex = 0 
) [inline]

Get the value of the nth attribute of the last child node that is named attributeName.

Parameters:
value The variable to write the value to.
nodeName Name of the child node of which to get the attribute.
attributeIndex Position of the attribute in the child node.
Returns:
True if there is an attribute at the given index in the last child node named nodeName and the value could be successfuly converted to type T, false otherwise.

Definition at line 128 of file SDXNode.h.

void Node::sendToContentHandler ( ContentHandler contentHandler,
bool  onlySendContents = false 
)

Send this node (recursively) to the given contentHandler.

Parameters:
contentHandler Content handler to send node to.
onlySendContents If set to true, contentHandler->startNode(<Name of this node>) and contentHandler->endNode() will not be called for this node (but they will be called for the child nodes).

Definition at line 113 of file SDXNode.cpp.


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

Generated on Mon Apr 27 16:55:49 2009 for SDX by  doxygen 1.5.8