Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

Inkscape::XML::Node Class Reference

#include <node.h>

Inheritance diagram for Inkscape::XML::Node:

Inkscape::GC::Anchored Inkscape::XML::Document Inkscape::XML::SimpleNode Inkscape::XML::CommentNode Inkscape::XML::ElementNode Inkscape::XML::PINode Inkscape::XML::TextNode

List of all members.


Detailed Description

Interface for refcounted XML nodes.

This class is an abstract base type for all nodes in an XML document - this includes everything except attributes. An XML document is also a node itself. This is the main class used for interfacing with Inkscape's documents. Everything that has to be stored in the SVG has to go through this class at some point.

Each node unconditionally has to belong to a document. There no "documentless" nodes, and it's not possible to move nodes between documents - they have to be duplicated. Each node can only refer to the nodes in the same document. Name of the node is immutable, it cannot be changed after its creation. Same goes for the type of the node. To simplify the use of this class, you can perform all operations on all nodes, but only some of them make any sense. For example, only element nodes can have attributes, only element and document nodes can have children, and all nodes except element and document nodes can have content. Although you can set content for element nodes, it won't make any difference in the XML output.

To create new nodes, use the methods of the Inkscape::XML::Document class. You can obtain the nodes' document using the document() method. To destroy a node, just unparent it by calling sp_repr_unparent() or node->parent->removeChild() and release any references to it. The garbage collector will reclaim the memory in the next pass. There are additional convenience functions defined in xml/repr.h

In addition to regular DOM manipulations, you can register observer objects that will receive notifications about changes made to the node. See the NodeObserver class.

See also:
Inkscape::XML::Document

Inkscape::XML::NodeObserver

Definition at line 73 of file node.h.


Public Member Functions

unsigned _anchored_refcount () const
void anchor () const
void release () const
Manipulate the XML tree
virtual void addChild (Node *child, Node *after)=0
 Insert another node as a child of this node.
virtual void appendChild (Node *child)=0
 Append a node as the last child of this node.
virtual void changeOrder (Node *child, Node *after)=0
 Move a given node in this node's child order.
virtual Nodeduplicate (Document *doc) const =0
 Create a duplicate of this node.
virtual void mergeFrom (Node const *src, gchar const *key)=0
 Merge all children of another node with the current.
virtual void removeChild (Node *child)=0
 Remove a child of this node.
Notify observers about operations on the node
virtual void addListener (NodeEventVector const *vector, void *data)=0
 Add a set node change callbacks with an associated data.
virtual void addObserver (NodeObserver &observer)=0
 Add an object that will be notified of the changes to this node.
virtual void addSubtreeObserver (NodeObserver &observer)=0
 Add an object that will be notified of the changes to this node and its descendants.
virtual void removeListenerByData (void *data)=0
 Remove a set of node change callbacks by their associated data.
virtual void removeObserver (NodeObserver &observer)=0
 Remove an object from the list of observers.
virtual void removeSubtreeObserver (NodeObserver &observer)=0
 Remove an object from the subtree observers list.
virtual void synthesizeEvents (NodeEventVector const *vector, void *data)=0
 Generate a sequence of events corresponding to the state of this node.
virtual void synthesizeEvents (NodeObserver &observer)=0
 Generate a sequence of events corresponding to the state of this node.
Retrieve information about the node
virtual gchar const * attribute (gchar const *key) const =0
 Get the string representation of a node's attribute.
virtual Inkscape::Util::List
< AttributeRecord const > 
attributeList () const =0
 Get a list of the node's attributes.
virtual unsigned childCount () const =0
 Get the number of children of this node.
virtual int code () const =0
 Get the integer code corresponding to the node's name.
virtual gchar const * content () const =0
 Get the content of a text or comment node.
virtual bool matchAttributeName (gchar const *partial_name) const =0
 Check whether this node has any attribute that matches a string.
virtual gchar const * name () const =0
 Get the name of the element node.
virtual unsigned position () const =0
 Get the index of this node in parent's child order.
virtual NodeType type () const =0
 Get the type of the node.
Traverse the XML tree
virtual Document const * document () const =0
virtual Documentdocument ()=0
 Get the node's associated document.
virtual Node const * firstChild () const =0
virtual NodefirstChild ()=0
 Get the first child of this node.
virtual Node const * lastChild () const =0
virtual NodelastChild ()=0
 Get the last child of this node.
virtual Node const * next () const =0
virtual Nodenext ()=0
 Get the next sibling of this node.
virtual Node const * nthChild (unsigned index) const =0
virtual NodenthChild (unsigned index)=0
 Get the child of this node with a given index.
virtual Node const * parent () const =0
virtual Nodeparent ()=0
 Get the parent of this node.
virtual Node const * root () const =0
virtual Noderoot ()=0
 Get the root node of this node's document.
Modify the node
virtual void setAttribute (gchar const *key, gchar const *value, bool is_interactive=false)=0
 Change an attribute of this node.
virtual void setCodeUnsafe (int code)=0
 Directly set the integer GQuark code for the name of the node.
virtual void setContent (gchar const *value)=0
 Set the content of a text or comment node.
virtual void setPosition (int pos)=0
 Set the position of this node in parent's child order.

Protected Member Functions

 Node (Node const &)

Related Functions

(Note that these are not member functions.)

Inkscape::XML::Nodesp_repr_lookup_child (Inkscape::XML::Node *repr, gchar const *key, gchar const *value)
 Find an element node using an unique attribute.
Inkscape::XML::Nodesp_repr_lookup_name (Inkscape::XML::Node *repr, gchar const *name, gint maxdepth)
 Find an element node with the given name.
Nodenext_node (Node *node)
 Get the next node in sibling order.
Nodeparent_node (Node *node)
 Get the node's parent.
Nodeprevious_node (Node *node)
 Get the previous node in sibling order.

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

Generated by  Doxygen 1.6.0   Back to index