Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
ParentNode Class Referenceabstract

#include <elm/xom/ParentNode.h>

+ Inheritance diagram for 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 Node
virtual ~Node (void)
 
voidgetNode (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 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 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 Node
static void freeNode (void *node)
 
- Protected Attributes inherited from Node
voidnode
 

Detailed Description

This class provides to the node facilities for containing children.

Constructor & Destructor Documentation

◆ ParentNode()

ParentNode ( void node)
inlineprotected

Build a node from a reader.

Parameters
nodeNode built by the reader.

Member Function Documentation

◆ appendChild()

void 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 Element.

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

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

◆ getChild()

Node * 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 Node.

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

Referenced by XOMElementSerializer::beginObject(), XOMUnserializer::flush(), ParentNode::removeChild(), Serializer::write(), Serializer::writeEndTag(), and Serializer::writeStartTag().

◆ getChildCount()

int getChildCount ( void  )
virtual

Get the count of children of the current node.

Returns
Children count.

Implements Node.

References Node::node.

Referenced by XOMElementSerializer::beginObject(), XOMUnserializer::flush(), Serializer::write(), Serializer::writeEndTag(), and Serializer::writeStartTag().

◆ indexOf()

int 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 Node::getNode(), and Node::node.

◆ insertChild()

void 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 Element.

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

Referenced by Element::insertChild().

◆ internSetBaseURI()

void internSetBaseURI ( String  URI)
protected

◆ removeChild() [1/2]

Node * 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 ParentNode::getChild().

Referenced by XOMElementSerializer::beginObject().

◆ removeChild() [2/2]

Node * removeChild ( Node child)
virtual

Removes the specified child of this node.

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

References Node::getNode().

◆ replaceChild()

void 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 Document.

References Node::getNode().

◆ setBaseURI()

virtual void setBaseURI ( String  URI)
pure virtual

Implemented in Element, and Document.


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