Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::xom::ParentNode Class Referenceabstract

#include <elm/xom/ParentNode.h>

+ Inheritance diagram for elm::xom::ParentNode:

Public Member Functions

virtual void appendChild (Node *child)
 
virtual int indexOf (Node *child)
 
virtual void insertChild (Node *child, int position)
 
virtual NoderemoveChild (int position)
 
virtual NoderemoveChild (Node *child)
 
virtual void replaceChild (Node *old_child, Node *new_child)
 
virtual void setBaseURI (String URI)=0
 
virtual NodegetChild (int index)
 
virtual int getChildCount (void)
 
- Public Member Functions inherited from elm::xom::Node
virtual ~Node (void)
 
void * getNode (void) const
 
kind_t kind (void) const
 
virtual Nodecopy (void)=0
 
void detach (void)
 
bool equals (const Node *node) const
 
virtual String getBaseURI (void)
 
virtual DocumentgetDocument (void)
 
virtual ParentNodegetParent (void)
 
virtual String getValue (void)=0
 
virtual Nodesquery (const String &xpath)
 
virtual Nodesquery (const String &xpath, XPathContext *context)
 
virtual String toXML (void)=0
 
int line (void) const
 

Protected Member Functions

 ParentNode (void *node)
 
void internSetBaseURI (String URI)
 
- Protected Member Functions inherited from elm::xom::Node
 Node (void *_node)
 
void setNode (void *_node)
 
Nodemake (void *node)
 
Nodeget (void *node)
 
NodeinternCopy (void)
 
NodeinternGetChild (int index)
 
int internGetChildCount (void)
 
String internGetValue (void)
 
String internToXML (void)
 

Additional Inherited Members

- Public Types inherited from elm::xom::Node
enum  kind_t {
  NONE = 0, ELEMENT, DOCUMENT, TEXT,
  COMMENT, ATTRIBUTE, PROCESSING_INSTRUCTION, DOCTYPE,
  NAMESPACE
}
 
typedef enum elm::xom::Node::kind_t kind_t
 
- Static Protected Member Functions inherited from elm::xom::Node
static void freeNode (void *node)
 
- Protected Attributes inherited from elm::xom::Node
void * node
 

Detailed Description

This class provides to the node facilities for containing children.

Constructor & Destructor Documentation

elm::xom::ParentNode::ParentNode ( void *  node)
protected

Build a node from a reader.

Parameters
nodeNode built by the reader.

Member Function Documentation

void elm::xom::ParentNode::appendChild ( Node child)
virtual

Appends a node to the children of this node.

Parameters
childnode to append to this node
Note
Fails if (1) if this node cannot have children of this type, (2) if child already has a parent.

Reimplemented in elm::xom::Element.

References elm::xom::Node::freeNode(), elm::xom::Node::getNode(), elm::xom::Node::node, and elm::xom::Node::setNode().

Referenced by elm::xom::Element::appendChild(), and elm::xom::XSLTransform::toDocument().

Node * elm::xom::ParentNode::getChild ( int  position)
virtual

Get the child node at the given position.

Parameters
positionPosition of the looked child.
Returns
Child at the given position.

Implements elm::xom::Node.

References elm::xom::Node::make(), and elm::xom::Node::node.

Referenced by elm::serial2::XOMSerializer::beginObject(), elm::serial2::XOMUnserializer::flush(), removeChild(), elm::xom::Serializer::write(), elm::xom::Serializer::writeEndTag(), and elm::xom::Serializer::writeStartTag().

int elm::xom::ParentNode::getChildCount ( void  )
virtual
int elm::xom::ParentNode::indexOf ( Node child)
virtual

Returns the position of a node within the children of this node. This is a number between 0 and one less than the number of children of this node. It returns -1 if child does not have this node as a parent.

This method does a linear search through the node's children. On average, it executes in O(N) where N is the number of children of the node.
Parameters
childthe node whose position is desired
Returns
the position of the argument node among the children of this node

References elm::xom::Node::getNode(), and elm::xom::Node::node.

void elm::xom::ParentNode::insertChild ( Node child,
int  position 
)
virtual

Inserts a child node at the specified position. The child node previously at that position (if any) and all subsequent child nodes are moved up by one. That is, when inserting a node at 2, the old node at 2 is moved to 3, the old child at 3 is moved to 4, and so forth. Inserting at position 0 makes the child the first child of this node. Inserting at the position getChildCount() makes the child the last child of the node.

All the other methods that add a node to the tree ultimately invoke this method.
Parameters
positionwhere to insert the child
childthe node to insert
Exceptions
IllegalAddExceptionif this node cannot have a child of the argument's type.
MultipleParentExceptionif child already has a parent

Reimplemented in elm::xom::Element.

References elm::xom::Node::getNode(), and elm::xom::Node::node.

Referenced by elm::xom::Element::insertChild().

void elm::xom::ParentNode::internSetBaseURI ( String  URI)
protected
Node * elm::xom::ParentNode::removeChild ( int  position)
virtual

Removes the child of this node at the specified position. Indexes begin at 0 and count up to one less than the number of children in this node.

Parameters
positionindex of the node to remove
thenode which was removed

References getChild().

Referenced by elm::serial2::XOMSerializer::beginObject().

Node * elm::xom::ParentNode::removeChild ( Node child)
virtual

Removes the specified child of this node.

Parameters
childchild node to remove.
Returns
the node which was removed.

References elm::xom::Node::getNode().

void elm::xom::ParentNode::replaceChild ( Node old_child,
Node new_child 
)
virtual

Replaces an existing child with a new child node. If oldChild is not a child of this node, then a NoSuchChildException is thrown.

Parameters
oldChildthe node removed from the tree
newChildthe node inserted into the tree
Exceptions
MultipleParentExceptionif newChild already has a parent.
IllegalAddExceptionif this node cannot have children of the type of newChild.

Reimplemented in elm::xom::Document.

References elm::xom::Node::getNode().

virtual void elm::xom::ParentNode::setBaseURI ( String  URI)
pure virtual

Implemented in elm::xom::Element, and elm::xom::Document.


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