summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d93d643)
raw | patch | inline | side by side (parent: d93d643)
author | mental <mental@users.sourceforge.net> | |
Tue, 1 Jul 2008 23:07:59 +0000 (23:07 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Tue, 1 Jul 2008 23:07:59 +0000 (23:07 +0000) |
src/xml/simple-node.cpp | patch | blob | history | |
src/xml/simple-node.h | patch | blob | history |
index 7bbec74ee9a620ac39e9b1fd7544662c7f3f7759..3d82eed01068140216fc8a4a8a37dd88a543eef9 100644 (file)
--- a/src/xml/simple-node.cpp
+++ b/src/xml/simple-node.cpp
_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;
}
unsigned SimpleNode::_childPosition(Node 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);
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;
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;
diff --git a/src/xml/simple-node.h b/src/xml/simple-node.h
index 0dece19b905d3866421eece35cc2f80d5b2bd112..1d87c6db1adfbc877c674eba42e440c869e23ee2 100644 (file)
--- a/src/xml/simple-node.h
+++ b/src/xml/simple-node.h
public: // ideally these should be protected somehow...
NodeObserver &_subtreeObservers() { return _subtree_observers; }
void _setParent(Node *parent);
- void _setNext(Node *next) { _next = next; }
+ void _setNext(Node *next) { _next = dynamic_cast<SimpleNode *>(next); }
unsigned _childPosition(Node const &child) const;
unsigned _cachedPosition() const { return _cached_position; }
private:
void operator=(Node const &); // no assign
- Node *_parent;
- Node *_next;
+ SimpleNode *_parent;
+ SimpleNode *_next;
Document *_document;
mutable unsigned _cached_position;
unsigned _child_count;
mutable bool _cached_positions_valid;
- Node *_first_child;
- Node *_last_child;
+ SimpleNode *_first_child;
+ SimpleNode *_last_child;
CompositeNodeObserver _observers;
CompositeNodeObserver _subtree_observers;