index 7bbec74ee9a620ac39e9b1fd7544662c7f3f7759..3cca393d228366d7b013d9109d7c207ebaddd85f 100644 (file)
--- a/src/xml/simple-node.cpp
+++ b/src/xml/simple-node.cpp
-/*
- * SimpleNode - simple XML node implementation
- *
- * Copyright 2003-2005 MenTaLguY <mental@rydia.net>
+/** @file
+ * @brief Garbage collected XML node implementation
+ */
+/* Copyright 2003-2005 MenTaLguY <mental@rydia.net>
* Copyright 2003 Nathan Hurst
* Copyright 1999-2003 Lauris Kaplinski
* Copyright 2000-2002 Ximian Inc.
* of the License, or (at your option) any later version.
*
* See the file COPYING for details.
- *
*/
#include <cstring>
_parent = _next = NULL;
_first_child = _last_child = NULL;
- for ( Node *child = node._first_child ;
- child != NULL ; child = child->next() )
+ for ( SimpleNode *child = node._first_child ;
+ child != NULL ; child = child->_next )
{
- Node *child_copy=child->duplicate(document);
+ SimpleNode *child_copy=dynamic_cast<SimpleNode *>(child->duplicate(document));
child_copy->_setParent(this);
if (_last_child) {
- _last_child->_setNext(child_copy);
+ _last_child->_next = child_copy;
} else {
_first_child = child_copy;
}
return _parent->_childPosition(*this);
}
-unsigned SimpleNode::_childPosition(Node const &child) const {
+unsigned SimpleNode::_childPosition(SimpleNode const &child) const {
if (!_cached_positions_valid) {
unsigned position=0;
- for ( Node *sibling = _first_child ;
- sibling ; sibling = sibling->next() )
+ for ( SimpleNode *sibling = _first_child ;
+ sibling ; sibling = sibling->_next )
{
- sibling->_setCachedPosition(position);
+ sibling->_cached_position = position;
position++;
}
_cached_positions_valid = true;
}
- return child._cachedPosition();
+ return child._cached_position;
}
Node *SimpleNode::nthChild(unsigned index) {
- Node *child = _first_child;
- for ( ; index > 0 && child ; child = child->next() ) {
+ SimpleNode *child = _first_child;
+ for ( ; index > 0 && child ; child = child->_next ) {
index--;
}
return child;
return false;
}
-void SimpleNode::_setParent(Node *generic_parent) {
- SimpleNode *parent = dynamic_cast<SimpleNode *>(generic_parent);
+void SimpleNode::_setParent(SimpleNode *parent) {
if (_parent) {
- _subtree_observers.remove(dynamic_cast<SimpleNode *>(_parent)->_subtree_observers);
+ _subtree_observers.remove(_parent->_subtree_observers);
}
_parent = parent;
if (parent) {
Debug::EventTracker<DebugAddChild> tracker(*this, *child, ref);
- Node *next;
+ SimpleNode *next;
if (ref) {
next = ref->_next;
ref->_next = child;
Debug::EventTracker<DebugRemoveChild> tracker(*this, *child);
- Node *next = child->_next;
+ SimpleNode *next = child->_next;
if (ref) {
ref->_next = next;
} else {
if (prev == ref) { return; }
- Node *next;
+ SimpleNode *next;
/* Remove from old position. */
next = child->_next;
// a position beyond the end of the list means the end of the list;
// a negative position is the same as an infinitely large position
- Node *ref=NULL;
- for ( Node *sibling = _parent->firstChild() ;
- sibling && pos ; sibling = sibling->next() )
+ SimpleNode *ref=NULL;
+ for ( SimpleNode *sibling = _parent->_first_child ;
+ sibling && pos ; sibling = sibling->_next )
{
if ( sibling != this ) {
ref = sibling;
}
}
if (vector->child_added) {
- Node *ref = NULL;
- for ( Node *child = this->_first_child ;
- child ; child = child->next() )
+ SimpleNode *ref = NULL;
+ for ( SimpleNode *child = this->_first_child ;
+ child ; child = child->_next )
{
vector->child_added(this, child, ref, data);
ref = child;
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :