📄 qdom.cpp
字号:
return !operator==(n);}/*! Destroys the object and frees its resources.*/QDomNodeList::~QDomNodeList(){ if (impl && !impl->ref.deref()) delete impl;}/*! Returns the node at position \a index. If \a index is negative or if \a index >= length() then a null node is returned (i.e. a node for which QDomNode::isNull() returns true). \sa length()*/QDomNode QDomNodeList::item(int index) const{ if (!impl) return QDomNode(); return QDomNode(impl->item(index));}/*! Returns the number of nodes in the list.*/uint QDomNodeList::length() const{ if (!impl) return 0; return impl->length();}/*! \fn bool QDomNodeList::isEmpty() const Returns true if the list contains no items; otherwise returns false. This function is provided for Qt API consistency.*//*! \fn int QDomNodeList::count() const This function is provided for Qt API consistency. It is equivalent to length().*//*! \fn int QDomNodeList::size() const This function is provided for Qt API consistency. It is equivalent to length().*//*! \fn QDomNode QDomNodeList::at(int index) const This function is provided for Qt API consistency. It is equivalent to item(). If \a index is negative or if \a index >= length() then a null node is returned (i.e. a node for which QDomNode::isNull() returns true).*//************************************************************** * * QDomNodePrivate * **************************************************************/inline void QDomNodePrivate::setOwnerDocument(QDomDocumentPrivate *doc){ ownerNode = doc; hasParent = false;}QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par){ ref = 1; if (par) setParent(par); else setOwnerDocument(doc); prev = 0; next = 0; first = 0; last = 0; createdWithDom1Interface = true; lineNumber = -1; columnNumber = -1;}QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n, bool deep){ ref = 1; setOwnerDocument(n->ownerDocument()); prev = 0; next = 0; first = 0; last = 0; name = n->name; value = n->value; prefix = n->prefix; namespaceURI = n->namespaceURI; createdWithDom1Interface = n->createdWithDom1Interface; lineNumber = -1; columnNumber = -1; if (!deep) return; for (QDomNodePrivate* x = n->first; x; x = x->next) appendChild(x->cloneNode(true));}QDomNodePrivate::~QDomNodePrivate(){ QDomNodePrivate* p = first; QDomNodePrivate* n; while (p) { n = p->next; if (!p->ref.deref()) delete p; else p->setNoParent(); p = n; } first = 0; last = 0;}void QDomNodePrivate::clear(){ QDomNodePrivate* p = first; QDomNodePrivate* n; while (p) { n = p->next; if (!p->ref.deref()) delete p; p = n; } first = 0; last = 0;}QDomNodePrivate* QDomNodePrivate::namedItem(const QString &n){ QDomNodePrivate* p = first; while (p) { if (p->nodeName() == n) return p; p = p->next; } return 0;}QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild){ // Error check if (!newChild) return 0; // Error check if (newChild == refChild) return 0; // Error check if (refChild && refChild->parent() != this) return 0; // "mark lists as dirty" qt_nodeListTime++; // Special handling for inserting a fragment. We just insert // all elements of the fragment instead of the fragment itself. if (newChild->isDocumentFragment()) { // Fragment is empty ? if (newChild->first == 0) return newChild; // New parent QDomNodePrivate* n = newChild->first; while (n) { n->setParent(this); n = n->next; } // Insert at the beginning ? if (!refChild || refChild->prev == 0) { if (first) first->prev = newChild->last; newChild->last->next = first; if (!last) last = newChild->last; first = newChild->first; } else { // Insert in the middle newChild->last->next = refChild; newChild->first->prev = refChild->prev; refChild->prev->next = newChild->first; refChild->prev = newChild->last; } // No need to increase the reference since QDomDocumentFragment // does not decrease the reference. // Remove the nodes from the fragment newChild->first = 0; newChild->last = 0; return newChild; } // No more errors can occur now, so we take // ownership of the node. newChild->ref.ref(); if (newChild->parent()) newChild->parent()->removeChild(newChild); newChild->setParent(this); if (!refChild) { if (first) first->prev = newChild; newChild->next = first; if (!last) last = newChild; first = newChild; return newChild; } if (refChild->prev == 0) { if (first) first->prev = newChild; newChild->next = first; if (!last) last = newChild; first = newChild; return newChild; } newChild->next = refChild; newChild->prev = refChild->prev; refChild->prev->next = newChild; refChild->prev = newChild; return newChild;}QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild){ // Error check if (!newChild) return 0; // Error check if (newChild == refChild) return 0; // Error check if (refChild && refChild->parent() != this) return 0; // "mark lists as dirty" qt_nodeListTime++; // Special handling for inserting a fragment. We just insert // all elements of the fragment instead of the fragment itself. if (newChild->isDocumentFragment()) { // Fragment is empty ? if (newChild->first == 0) return newChild; // New parent QDomNodePrivate* n = newChild->first; while (n) { n->setParent(this); n = n->next; } // Insert at the end if (!refChild || refChild->next == 0) { if (last) last->next = newChild->first; newChild->first->prev = last; if (!first) first = newChild->first; last = newChild->last; } else { // Insert in the middle newChild->first->prev = refChild; newChild->last->next = refChild->next; refChild->next->prev = newChild->last; refChild->next = newChild->first; } // No need to increase the reference since QDomDocumentFragment // does not decrease the reference. // Remove the nodes from the fragment newChild->first = 0; newChild->last = 0; return newChild; } // Release new node from its current parent if (newChild->parent()) newChild->parent()->removeChild(newChild); // No more errors can occur now, so we take // ownership of the node newChild->ref.ref(); newChild->setParent(this); // Insert at the end if (!refChild) { if (last) last->next = newChild; newChild->prev = last; if (!first) first = newChild; last = newChild; return newChild; } if (refChild->next == 0) { if (last) last->next = newChild; newChild->prev = last; if (!first) first = newChild; last = newChild; return newChild; } newChild->prev = refChild; newChild->next = refChild->next; refChild->next->prev = newChild; refChild->next = newChild; return newChild;}QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild){ if (!newChild || !oldChild) return 0; if (oldChild->parent() != this) return 0; if (newChild == oldChild) return 0; // mark lists as dirty qt_nodeListTime++; // Special handling for inserting a fragment. We just insert // all elements of the fragment instead of the fragment itself. if (newChild->isDocumentFragment()) { // Fragment is empty ? if (newChild->first == 0) return newChild; // New parent QDomNodePrivate* n = newChild->first; while (n) { n->setParent(this); n = n->next; } if (oldChild->next) oldChild->next->prev = newChild->last; if (oldChild->prev) oldChild->prev->next = newChild->first; newChild->last->next = oldChild->next; newChild->first->prev = oldChild->prev; if (first == oldChild) first = newChild->first; if (last == oldChild) last = newChild->last; oldChild->setNoParent(); oldChild->next = 0; oldChild->prev = 0; // No need to increase the reference since QDomDocumentFragment // does not decrease the reference. // Remove the nodes from the fragment newChild->first = 0; newChild->last = 0; // We are no longer interested in the old node if (oldChild) oldChild->ref.deref(); return oldChild; } // No more errors can occur now, so we take // ownership of the node newChild->ref.ref(); // Release new node from its current parent if (newChild->parent()) newChild->parent()->removeChild(newChild); newChild->setParent(this); if (oldChild->next) oldChild->next->prev = newChild; if (oldChild->prev) oldChild->prev->next = newChild; newChild->next = oldChild->next; newChild->prev = oldChild->prev; if (first == oldChild) first = newChild; if (last == oldChild) last = newChild; oldChild->setNoParent(); oldChild->next = 0; oldChild->prev = 0; // We are no longer interested in the old node if (oldChild) oldChild->ref.deref(); return oldChild;}QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -