Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::XML::SimpleNode Class Reference

Default implementation of the XML node stored in memory. More...

#include <simple-node.h>

Inheritance diagram for Inkscape::XML::SimpleNode:
Inkscape::XML::Node Inkscape::GC::Managed< default_scan, default_collect > Inkscape::GC::Anchored Inkscape::XML::CommentNode Inkscape::XML::ElementNode Inkscape::XML::PINode Inkscape::XML::SimpleDocument Inkscape::XML::TextNode

Public Member Functions

char const * name () const override
 Get the name of the element node.
 
int code () const override
 Get the integer code corresponding to the node's name.
 
void setCodeUnsafe (int code) override
 Set the integer GQuark code for the name of the node.
 
Documentdocument () override
 Get the node's associated document.
 
Document const * document () const override
 
Noderoot () override
 Get the root node of this node's document.
 
Node const * root () const override
 
Nodeparent () override
 Get the parent of this node.
 
Node const * parent () const override
 
Nodenext () override
 Get the next sibling of this node.
 
Node const * next () const override
 
Nodeprev () override
 
Node const * prev () const override
 
NodefirstChild () override
 Get the first child of this node.
 
Node const * firstChild () const override
 
NodelastChild () override
 Get the last child of this node.
 
Node const * lastChild () const override
 
unsigned childCount () const override
 Get the number of children of this node.
 
NodenthChild (unsigned index) override
 Get the child of this node with a given index.
 
Node const * nthChild (unsigned index) const override
 
void addChild (Node *child, Node *ref) override
 Insert another node as a child of this node.
 
void appendChild (Node *child) override
 Append a node as the last child of this node.
 
void removeChild (Node *child) override
 Remove a child of this node.
 
void changeOrder (Node *child, Node *ref) override
 Move a given node in this node's child order.
 
unsigned position () const override
 Get the index of this node in parent's child order.
 
void setPosition (int pos) override
 Set the position of this node in parent's child order.
 
char const * attribute (char const *key) const override
 Get the string representation of a node's attribute.
 
bool matchAttributeName (char const *partial_name) const override
 Check whether this node has any attribute that matches a string.
 
char const * content () const override
 Get the content of a text or comment node.
 
void setContent (char const *value) override
 Set the content of a text or comment node.
 
void cleanOriginal (Node *src, gchar const *key) override
 
bool equal (Node const *other, bool recursive, bool skip_ids=false) override
 Compare 2 nodes equality.
 
void mergeFrom (Node const *src, char const *key, bool extension=false, bool clean=false) override
 Merge all children of another node with the current.
 
const AttributeVectorattributeList () const override
 Get a list of the node's attributes.
 
void synthesizeEvents (NodeObserver &observer) override
 Generate a sequence of events corresponding to the state of this node.
 
void addObserver (NodeObserver &observer) override
 Add an object that will be notified of the changes to this node.
 
void removeObserver (NodeObserver &observer) override
 Remove an object from the list of observers.
 
void addSubtreeObserver (NodeObserver &observer) override
 Add an object that will be notified of the changes to this node and its descendants.
 
void removeSubtreeObserver (NodeObserver &observer) override
 Remove an object from the subtree observers list.
 
void recursivePrintTree (unsigned level=0) override
 
- Public Member Functions inherited from Inkscape::XML::Node
 Node ()=default
 
 ~Node () override=default
 
virtual NodeType type () const =0
 Get the type of the node.
 
void setAttribute (Util::const_char_ptr key, Util::const_char_ptr value)
 Change an attribute of this node.
 
bool copyAttribute (Util::const_char_ptr key, Node const *source_node, bool remove_if_empty=false)
 Copy attribute value from another node to this node.
 
bool getAttributeBoolean (Util::const_char_ptr key, bool default_value=false) const
 Parses the boolean value of an attribute "key" in repr and sets val accordingly, or to false if the attr is not set.
 
int getAttributeInt (Util::const_char_ptr key, int default_value=0) const
 
double getAttributeDouble (Util::const_char_ptr key, double default_value=0.0) const
 
bool setAttributeBoolean (Util::const_char_ptr key, bool val)
 
bool setAttributeInt (Util::const_char_ptr key, int val)
 
bool setAttributeCssDouble (Util::const_char_ptr key, double val)
 Set a property attribute to val [slightly rounded], in the format required for CSS properties: in particular, it never uses exponent notation.
 
bool setAttributeSvgDouble (Util::const_char_ptr key, double val)
 For attributes where an exponent is allowed.
 
bool setAttributeSvgNonDefaultDouble (Util::const_char_ptr key, double val, double default_value)
 
bool setAttributeSvgLength (Util::const_char_ptr key, SVGLength const &val)
 
bool setAttributePoint (Util::const_char_ptr key, Geom::Point const &val)
 
Geom::Point getAttributePoint (Util::const_char_ptr key, Geom::Point default_value={}) const
 
void setAttributeOrRemoveIfEmpty (Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
 Change an attribute of this node.
 
void removeAttribute (Inkscape::Util::const_char_ptr key)
 Remove an attribute of this node.
 
virtual Nodeduplicate (Document *doc) const =0
 Create a duplicate of this node.
 
void addChildAtPos (Node *child, unsigned pos)
 Insert another node as a child of this node.
 
virtual void cleanOriginal (Node *src, char const *key)=0
 Remove all elements that not in src node.
 
iterator begin ()
 Iterator over children.
 
iterator end ()
 Helper to use the standard lib container functions.
 
bool operator== (const std::string &name) const
 Compare a node by looking at its name to a string.
 
template<typename T >
NodefindChildPath (T list)
 depth first search to find a node
 
template<typename iterT >
NodefindChildPath (iterT itr, iterT end)
 template reshuffling to make the more useful findChildPath cleaner
 
- Public Member Functions inherited from Inkscape::GC::Anchored
void anchor () const
 
void release () const
 
unsigned _anchored_refcount () const
 
 Anchored (Anchored const &)=delete
 
void operator= (Anchored const &)=delete
 
- Public Member Functions inherited from Inkscape::GC::Managed< default_scan, default_collect >
void * operator new (std::size_t size, ScanPolicy scan=default_scan, CollectionPolicy collect=default_collect)
 
void * operator new[] (std::size_t size, ScanPolicy scan=default_scan, CollectionPolicy collect=default_collect)
 
void operator delete (void *p)
 

Protected Member Functions

 SimpleNode (int code, Document *document)
 
 SimpleNode (SimpleNode const &repr, Document *document)
 
void setAttributeImpl (char const *key, char const *value) override
 
- Protected Member Functions inherited from Inkscape::XML::Node
 Node (Node const &)
 
- Protected Member Functions inherited from Inkscape::GC::Anchored
 Anchored ()
 
virtual ~Anchored ()=default
 

Private Member Functions

void operator= (Node const &)
 
void _setParent (SimpleNode *parent)
 
unsigned _childPosition (SimpleNode const &child) const
 

Private Attributes

SimpleNode_parent
 
SimpleNode_next
 
SimpleNode_prev
 
Document_document
 
unsigned _cached_position
 
int _name
 
AttributeVector _attributes
 
Inkscape::Util::ptr_shared _content
 
unsigned _child_count {0}
 
bool _cached_positions_valid {false}
 
SimpleNode_first_child
 
SimpleNode_last_child
 
CompositeNodeObserver _observers
 
CompositeNodeObserver _subtree_observers
 

Additional Inherited Members

- Public Types inherited from Inkscape::XML::Node
using iterator = Inkscape::XML::NodeSiblingIterator
 

Detailed Description

Default implementation of the XML node stored in memory.

See also
Inkscape::XML::Node

Definition at line 35 of file simple-node.h.

Constructor & Destructor Documentation

◆ SimpleNode() [1/2]

Inkscape::XML::SimpleNode::SimpleNode ( int  code,
Document document 
)
protected

◆ SimpleNode() [2/2]

Inkscape::XML::SimpleNode::SimpleNode ( SimpleNode const &  repr,
Document document 
)
protected

Member Function Documentation

◆ _childPosition()

unsigned Inkscape::XML::SimpleNode::_childPosition ( SimpleNode const &  child) const
private

Definition at line 248 of file simple-node.cpp.

References _cached_positions_valid, _first_child, _next, child, and position().

Referenced by position().

◆ _setParent()

void Inkscape::XML::SimpleNode::_setParent ( SimpleNode parent)
private

◆ addChild()

void Inkscape::XML::SimpleNode::addChild ( Node child,
Node after 
)
overridevirtual

Insert another node as a child of this node.

When after is NULL, the inserted node will be placed as the first child of this node. after must be a child of this node.

Parameters
childThe node to insert
afterThe node after which the inserted node should be placed, or NULL

Implements Inkscape::XML::Node.

Definition at line 414 of file simple-node.cpp.

References _cached_position, _cached_positions_valid, _child_count, _document, _first_child, _last_child, _observers, _prev, child, Inkscape::XML::Node::document(), Inkscape::XML::Document::logger(), next(), Inkscape::XML::NodeObserver::notifyChildAdded(), Inkscape::XML::CompositeNodeObserver::notifyChildAdded(), and ref.

Referenced by appendChild().

◆ addObserver()

void Inkscape::XML::SimpleNode::addObserver ( NodeObserver observer)
inlineoverridevirtual

Add an object that will be notified of the changes to this node.

observer must be an object deriving from the NodeObserver class. The virtual methods of this object will be called when a corresponding change happens to this node. You can also notify the observer of the node's current state using synthesizeEvents(NodeObserver &).

Parameters
observerThe observer object

Implements Inkscape::XML::Node.

Definition at line 98 of file simple-node.h.

References _observers, Inkscape::XML::CompositeNodeObserver::add(), and observer.

◆ addSubtreeObserver()

void Inkscape::XML::SimpleNode::addSubtreeObserver ( NodeObserver observer)
inlineoverridevirtual

Add an object that will be notified of the changes to this node and its descendants.

The difference between adding a regular observer and a subtree observer is that the subtree observer will also be notified if a change occurs to any of the node's descendants, while a regular observer will only be notified of changes to the node it was assigned to.

Parameters
observerThe observer object

Implements Inkscape::XML::Node.

Definition at line 105 of file simple-node.h.

References _subtree_observers, Inkscape::XML::CompositeNodeObserver::add(), and observer.

◆ appendChild()

void Inkscape::XML::SimpleNode::appendChild ( Node child)
inlineoverridevirtual

Append a node as the last child of this node.

Parameters
childThe node to append

Implements Inkscape::XML::Node.

Definition at line 73 of file simple-node.h.

References _last_child, addChild(), and child.

◆ attribute()

gchar const * Inkscape::XML::SimpleNode::attribute ( char const *  key) const
overridevirtual

Get the string representation of a node's attribute.

If there is no attribute with the given name, the method will return NULL. All strings returned by this method are owned by the node and may not be freed. The returned pointer will become invalid when the attribute changes. If you need to store the return value, use g_strdup(). To parse the string, use methods in repr.h

Parameters
keyThe name of the node's attribute

Implements Inkscape::XML::Node.

Definition at line 228 of file simple-node.cpp.

References _attributes, key, and name().

Referenced by recursivePrintTree(), and setAttributeImpl().

◆ attributeList()

const AttributeVector & Inkscape::XML::SimpleNode::attributeList ( ) const
inlineoverridevirtual

Get a list of the node's attributes.

The returned list is a functional programming style list rather than a standard one.

Returns
A list of AttributeRecord structures describing the attributes
Todo:
This method should return std::map<Glib::Quark const, char const *> or something similar with a custom allocator

Implements Inkscape::XML::Node.

Definition at line 92 of file simple-node.h.

References _attributes.

Referenced by equal().

◆ changeOrder()

void Inkscape::XML::SimpleNode::changeOrder ( Node child,
Node after 
)
overridevirtual

Move a given node in this node's child order.

Both child and after must be children of this node for the method to work.

Parameters
childThe node to move in the order
afterThe sibling node after which the moved node should be placed

Implements Inkscape::XML::Node.

Definition at line 497 of file simple-node.cpp.

References _cached_positions_valid, _document, _first_child, _last_child, _next, _observers, _prev, child, Inkscape::XML::Node::document(), Inkscape::XML::Document::logger(), next(), Inkscape::XML::NodeObserver::notifyChildOrderChanged(), Inkscape::XML::CompositeNodeObserver::notifyChildOrderChanged(), prev(), and ref.

Referenced by setPosition().

◆ childCount()

unsigned Inkscape::XML::SimpleNode::childCount ( ) const
inlineoverridevirtual

Get the number of children of this node.

Returns
The number of children

Implements Inkscape::XML::Node.

Definition at line 66 of file simple-node.h.

References _child_count.

◆ cleanOriginal()

void Inkscape::XML::SimpleNode::cleanOriginal ( Node src,
gchar const *  key 
)
override

◆ code()

int Inkscape::XML::SimpleNode::code ( ) const
inlineoverridevirtual

Get the integer code corresponding to the node's name.

Returns
GQuark code corresponding to the name

Implements Inkscape::XML::Node.

Definition at line 40 of file simple-node.h.

References _name.

Referenced by setCodeUnsafe().

◆ content()

gchar const * Inkscape::XML::SimpleNode::content ( ) const
overridevirtual

Get the content of a text or comment node.

This method makes no sense for element nodes. To retrieve the element node's name, use the name() method.

Returns
The node's content

Implements Inkscape::XML::Node.

Definition at line 224 of file simple-node.cpp.

References _content.

Referenced by Inkscape::XML::CommentNode::CommentNode(), Inkscape::XML::SimpleDocument::createComment(), Inkscape::XML::SimpleDocument::createPI(), Inkscape::XML::SimpleDocument::createTextNode(), Inkscape::XML::SimpleDocument::createTextNode(), equal(), Inkscape::XML::PINode::PINode(), setContent(), Inkscape::XML::TextNode::TextNode(), and Inkscape::XML::TextNode::TextNode().

◆ document() [1/2]

Document const * Inkscape::XML::SimpleNode::document ( ) const
inlineoverridevirtual

Implements Inkscape::XML::Node.

Definition at line 44 of file simple-node.h.

References document().

◆ document() [2/2]

Document * Inkscape::XML::SimpleNode::document ( )
inlineoverridevirtual

Get the node's associated document.

Returns
The document to which the node belongs. Never NULL.

Implements Inkscape::XML::Node.

Definition at line 43 of file simple-node.h.

References _document.

Referenced by document(), SimpleNode(), and SimpleNode().

◆ equal()

bool Inkscape::XML::SimpleNode::equal ( Node const *  other,
bool  recursive,
bool  skip_ids = false 
)
overridevirtual

Compare 2 nodes equality.

Parameters
otherThe other node to compare
recursiveRecursive mode check

Implements Inkscape::XML::Node.

Definition at line 654 of file simple-node.cpp.

References Inkscape::XML::Node::attributeList(), attributeList(), child, Inkscape::XML::Node::content(), content(), firstChild(), Inkscape::XML::Node::firstChild(), key, Inkscape::XML::Node::name(), name(), Inkscape::XML::Node::next(), and Inkscape::XML::string_equal().

◆ firstChild() [1/2]

Node const * Inkscape::XML::SimpleNode::firstChild ( ) const
inlineoverridevirtual

Implements Inkscape::XML::Node.

Definition at line 62 of file simple-node.h.

References _first_child.

◆ firstChild() [2/2]

Node * Inkscape::XML::SimpleNode::firstChild ( )
inlineoverridevirtual

Get the first child of this node.

For nodes without any children, this method returns NULL.

Returns
Pointer to the first child, or NULL

Implements Inkscape::XML::Node.

Definition at line 61 of file simple-node.h.

References _first_child.

Referenced by cleanOriginal(), Inkscape::XML::SimpleDocument::duplicate(), and equal().

◆ lastChild() [1/2]

Node const * Inkscape::XML::SimpleNode::lastChild ( ) const
inlineoverridevirtual

Implements Inkscape::XML::Node.

Definition at line 64 of file simple-node.h.

References _last_child.

◆ lastChild() [2/2]

Node * Inkscape::XML::SimpleNode::lastChild ( )
inlineoverridevirtual

Get the last child of this node.

For nodes without any children, this method returns NULL.

Returns
Pointer to the last child, or NULL

Implements Inkscape::XML::Node.

Definition at line 63 of file simple-node.h.

References _last_child.

◆ matchAttributeName()

bool Inkscape::XML::SimpleNode::matchAttributeName ( char const *  partial_name) const
overridevirtual

Check whether this node has any attribute that matches a string.

This method checks whether this node has any attributes whose names have partial_name as their substrings. The check is done using the strstr() function of the C library. I don't know what would require that functionality, because matchAttributeName("id") matches both "identity" and "hidden".

Parameters
partial_nameThe string to match against all attributes
Returns
true if there is such an attribute, false otherwise

Implements Inkscape::XML::Node.

Definition at line 270 of file simple-node.cpp.

References _attributes, and name().

◆ mergeFrom()

void Inkscape::XML::SimpleNode::mergeFrom ( Node const *  src,
char const *  key,
bool  extension = false,
bool  clean = false 
)
overridevirtual

Merge all children of another node with the current.

This method merges two node hierarchies, where src takes precedence. key is the name of the attribute that determines whether two nodes are corresponding (it must be the same for both, and all of their ancestors). If there is a corresponding node in src hierarchy, their attributes and content override the ones already present in this node's hierarchy. If there is no corresponding node, it is copied from src to this node. This method is used when merging the user's preferences file with the defaults, and has little use beyond that.

Parameters
srcThe node to merge into this node
keyThe attribute to use as the identity attribute
noidIf true process noid items
keyIf clean callback to cleanOriginal

Implements Inkscape::XML::Node.

Definition at line 698 of file simple-node.cpp.

References _document, _parent, Inkscape::XML::Node::addChildAtPos(), Inkscape::XML::Node::attributeList(), child, clean, cleanOriginal(), Inkscape::XML::Node::content(), Inkscape::XML::Node::duplicate(), Inkscape::XML::Node::equal(), Inkscape::XML::Node::firstChild(), key, Inkscape::XML::Node::mergeFrom(), Inkscape::XML::Node::position(), Inkscape::GC::Anchored::release(), removeChild(), Inkscape::XML::Node::setAttribute(), setContent(), setPosition(), and Inkscape::XML::Node::sp_repr_lookup_child().

◆ name()

gchar const * Inkscape::XML::SimpleNode::name ( ) const
overridevirtual

Get the name of the element node.

This method only makes sense for element nodes. Names are stored as GQuarks to accelerate conversions.

Returns
Name for element nodes, NULL for others

Implements Inkscape::XML::Node.

Definition at line 220 of file simple-node.cpp.

References _name.

Referenced by attribute(), Inkscape::XML::SimpleDocument::createElement(), equal(), matchAttributeName(), Inkscape::XML::SimpleDocument::notifyAttributeChanged(), recursivePrintTree(), and setAttributeImpl().

◆ next() [1/2]

Node const * Inkscape::XML::SimpleNode::next ( ) const
inlineoverridevirtual

Implements Inkscape::XML::Node.

Definition at line 57 of file simple-node.h.

References _next.

◆ next() [2/2]

Node * Inkscape::XML::SimpleNode::next ( )
inlineoverridevirtual

Get the next sibling of this node.

This method will return NULL if the node is the last sibling element of the parent. The nodes form a singly-linked list, so there is no "prev()" method. Use the provided external function for that.

Returns
Pointer to the next sibling, or NULL
See also
Inkscape::XML::previous_node()

Implements Inkscape::XML::Node.

Definition at line 56 of file simple-node.h.

References _next.

Referenced by addChild(), changeOrder(), and removeChild().

◆ nthChild() [1/2]

Node const * Inkscape::XML::SimpleNode::nthChild ( unsigned  index) const
inlineoverridevirtual

Implements Inkscape::XML::Node.

Definition at line 68 of file simple-node.h.

References index, and nthChild().

◆ nthChild() [2/2]

Node * Inkscape::XML::SimpleNode::nthChild ( unsigned  index)
overridevirtual

Get the child of this node with a given index.

If there is no child with the specified index number, this method will return NULL.

Parameters
indexThe zero-based index of the child to retrieve
Returns
Pointer to the appropriate child, or NULL

Implements Inkscape::XML::Node.

Definition at line 262 of file simple-node.cpp.

References _first_child, child, and index.

Referenced by nthChild().

◆ operator=()

void Inkscape::XML::SimpleNode::operator= ( Node const &  )
private

◆ parent() [1/2]

Node const * Inkscape::XML::SimpleNode::parent ( ) const
inlineoverridevirtual

Implements Inkscape::XML::Node.

Definition at line 54 of file simple-node.h.

References _parent.

◆ parent() [2/2]

Node * Inkscape::XML::SimpleNode::parent ( )
inlineoverridevirtual

Get the parent of this node.

This method will return NULL for detached nodes.

Returns
Pointer to the parent, or NULL

Implements Inkscape::XML::Node.

Definition at line 53 of file simple-node.h.

References _parent.

Referenced by _setParent(), Inkscape::XML::SimpleDocument::notifyChildAdded(), Inkscape::XML::SimpleDocument::notifyChildOrderChanged(), Inkscape::XML::SimpleDocument::notifyChildRemoved(), and root().

◆ position()

unsigned Inkscape::XML::SimpleNode::position ( ) const
overridevirtual

Get the index of this node in parent's child order.

If this method is used on a node that doesn't have a parent, the method will return 0, and a warning will be printed on the console.

Returns
The node's index, or 0 if the node does not have a parent

Implements Inkscape::XML::Node.

Definition at line 243 of file simple-node.cpp.

References _childPosition(), and _parent.

Referenced by _childPosition().

◆ prev() [1/2]

Node const * Inkscape::XML::SimpleNode::prev ( ) const
inlineoverridevirtual

Implements Inkscape::XML::Node.

Definition at line 59 of file simple-node.h.

References _prev.

◆ prev() [2/2]

Node * Inkscape::XML::SimpleNode::prev ( )
inlineoverridevirtual

◆ recursivePrintTree()

void Inkscape::XML::SimpleNode::recursivePrintTree ( unsigned  level = 0)
overridevirtual

Implements Inkscape::XML::Node.

Definition at line 588 of file simple-node.cpp.

References _first_child, _next, attribute(), child, and name().

◆ removeChild()

void Inkscape::XML::SimpleNode::removeChild ( Node child)
overridevirtual

Remove a child of this node.

Once the pointer to the removed node disappears from the stack, the removed node will be collected in the next GC pass, but only as long as its refcount is zero. You should keep a refcount of zero for all nodes in the document except for the document node itself, because they will be held in memory by the parent.

Parameters
childThe child to remove

Implements Inkscape::XML::Node.

Definition at line 463 of file simple-node.cpp.

References _cached_positions_valid, _child_count, _document, _first_child, _last_child, _next, _observers, _prev, _setParent(), child, Inkscape::XML::Node::document(), Inkscape::XML::Document::logger(), next(), Inkscape::XML::NodeObserver::notifyChildRemoved(), Inkscape::XML::CompositeNodeObserver::notifyChildRemoved(), and ref.

Referenced by cleanOriginal(), and mergeFrom().

◆ removeObserver()

void Inkscape::XML::SimpleNode::removeObserver ( NodeObserver observer)
inlineoverridevirtual

Remove an object from the list of observers.

Parameters
observerThe object to be removed

Implements Inkscape::XML::Node.

Definition at line 101 of file simple-node.h.

References _observers, observer, and Inkscape::XML::CompositeNodeObserver::remove().

◆ removeSubtreeObserver()

void Inkscape::XML::SimpleNode::removeSubtreeObserver ( NodeObserver observer)
inlineoverridevirtual

Remove an object from the subtree observers list.

Parameters
observerThe object to be removed

Implements Inkscape::XML::Node.

Definition at line 108 of file simple-node.h.

References _subtree_observers, observer, and Inkscape::XML::CompositeNodeObserver::remove().

◆ root() [1/2]

Node const * Inkscape::XML::SimpleNode::root ( ) const
inlineoverridevirtual

Implements Inkscape::XML::Node.

Definition at line 49 of file simple-node.h.

References root().

◆ root() [2/2]

Node * Inkscape::XML::SimpleNode::root ( )
overridevirtual

Get the root node of this node's document.

This method works on any node that is part of an XML document, and returns the root node of the document in which it resides. For detached node hierarchies (i.e. nodes that are not descendants of a document node) this method returns the highest-level element node. For detached non-element nodes this method returns NULL.

Returns
A pointer to the root element node, or NULL if the node is detached

Implements Inkscape::XML::Node.

Definition at line 608 of file simple-node.cpp.

References _document, child, Inkscape::XML::DOCUMENT_NODE, Inkscape::XML::ELEMENT_NODE, Inkscape::XML::Node::firstChild(), parent(), Inkscape::XML::Node::parent(), and Inkscape::XML::Node::type().

Referenced by root().

◆ setAttributeImpl()

◆ setCodeUnsafe()

void Inkscape::XML::SimpleNode::setCodeUnsafe ( int  code)
overridevirtual

Set the integer GQuark code for the name of the node.

Do not use this function unless you really have a good reason.

Parameters
codeThe integer value corresponding to the string to be set as the name of this node

Implements Inkscape::XML::Node.

Definition at line 399 of file simple-node.cpp.

References _document, _name, _observers, code(), Inkscape::XML::Document::logger(), Inkscape::XML::NodeObserver::notifyElementNameChanged(), Inkscape::XML::CompositeNodeObserver::notifyElementNameChanged(), and Inkscape::Debug::EventTracker< typename >::set().

◆ setContent()

void Inkscape::XML::SimpleNode::setContent ( char const *  value)
overridevirtual

◆ setPosition()

void Inkscape::XML::SimpleNode::setPosition ( int  pos)
overridevirtual

Set the position of this node in parent's child order.

To move the node to the end of the parent's child order, pass a negative argument.

Parameters
posThe new position in parent's child order

Implements Inkscape::XML::Node.

Definition at line 554 of file simple-node.cpp.

References _first_child, _parent, changeOrder(), and ref.

Referenced by mergeFrom().

◆ synthesizeEvents()

void Inkscape::XML::SimpleNode::synthesizeEvents ( NodeObserver observer)
overridevirtual

Generate a sequence of events corresponding to the state of this node.

This function notifies the specified observer of all the events that would recreate the current state of this node; e.g. the observer is notified of all the attributes, children and content like they were just created. This function can greatly simplify observer logic.

Parameters
observerThe node observer to notify of the events

Implements Inkscape::XML::Node.

Definition at line 573 of file simple-node.cpp.

References _attributes, _content, _first_child, _next, child, observer, and ref.

Member Data Documentation

◆ _attributes

AttributeVector Inkscape::XML::SimpleNode::_attributes
private

◆ _cached_position

unsigned Inkscape::XML::SimpleNode::_cached_position
mutableprivate

Definition at line 130 of file simple-node.h.

Referenced by addChild().

◆ _cached_positions_valid

bool Inkscape::XML::SimpleNode::_cached_positions_valid {false}
mutableprivate

Definition at line 139 of file simple-node.h.

Referenced by _childPosition(), addChild(), changeOrder(), and removeChild().

◆ _child_count

unsigned Inkscape::XML::SimpleNode::_child_count {0}
private

Definition at line 138 of file simple-node.h.

Referenced by addChild(), childCount(), and removeChild().

◆ _content

Inkscape::Util::ptr_shared Inkscape::XML::SimpleNode::_content
private

Definition at line 136 of file simple-node.h.

Referenced by content(), setContent(), and synthesizeEvents().

◆ _document

Document* Inkscape::XML::SimpleNode::_document
private

◆ _first_child

◆ _last_child

SimpleNode* Inkscape::XML::SimpleNode::_last_child
private

◆ _name

int Inkscape::XML::SimpleNode::_name
private

Definition at line 132 of file simple-node.h.

Referenced by code(), name(), setAttributeImpl(), and setCodeUnsafe().

◆ _next

SimpleNode* Inkscape::XML::SimpleNode::_next
private

◆ _observers

CompositeNodeObserver Inkscape::XML::SimpleNode::_observers
private

◆ _parent

SimpleNode* Inkscape::XML::SimpleNode::_parent
private

◆ _prev

SimpleNode* Inkscape::XML::SimpleNode::_prev
private

Definition at line 128 of file simple-node.h.

Referenced by addChild(), changeOrder(), prev(), prev(), removeChild(), SimpleNode(), and SimpleNode().

◆ _subtree_observers

CompositeNodeObserver Inkscape::XML::SimpleNode::_subtree_observers
private

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