OpenCoverage

qdom.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/xml/dom/qdom.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtXml module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include <qplatformdefs.h>-
41#include <qdom.h>-
42#include "private/qxmlutils_p.h"-
43-
44#ifndef QT_NO_DOM-
45-
46#include <qatomic.h>-
47#include <qbuffer.h>-
48#include <qhash.h>-
49#include <qiodevice.h>-
50#include <qlist.h>-
51#include <qregexp.h>-
52#include <qtextcodec.h>-
53#include <qtextstream.h>-
54#include <qxml.h>-
55#include "private/qxml_p.h"-
56#include <qvariant.h>-
57#include <qmap.h>-
58#include <qshareddata.h>-
59#include <qdebug.h>-
60#include <stdio.h>-
61-
62QT_BEGIN_NAMESPACE-
63-
64/*-
65 ### old todo comments -- I don't know if they still apply...-
66-
67 If the document dies, remove all pointers to it from children-
68 which can not be deleted at this time.-
69-
70 If a node dies and has direct children which can not be deleted,-
71 then remove the pointer to the parent.-
72-
73 createElement and friends create double reference counts.-
74*/-
75-
76/* ##### new TODOs:-
77-
78 Remove emtpy emthods in the *Private classes-
79-
80 Make a lot of the (mostly empty) methods in the public classes inline.-
81 Specially constructors assignment operators and comparison operators are candidates.-
82*/-
83-
84/*-
85 Reference counting:-
86-
87 Some simple rules:-
88 1) If an intern object returns a pointer to another intern object-
89 then the reference count of the returned object is not increased.-
90 2) If an extern object is created and gets a pointer to some intern-
91 object, then the extern object increases the intern objects reference count.-
92 3) If an extern object is deleted, then it decreases the reference count-
93 on its associated intern object and deletes it if nobody else hold references-
94 on the intern object.-
95*/-
96-
97-
98/*-
99 Helper to split a qualified name in the prefix and local name.-
100*/-
101static void qt_split_namespace(QString& prefix, QString& name, const QString& qName, bool hasURI)-
102{-
103 int i = qName.indexOf(QLatin1Char(':'));-
104 if (i == -1) {
i == -1Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
4
105 if (hasURI)
hasURIDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
2
106 prefix = QLatin1String("");
executed 2 times by 1 test: prefix = QLatin1String("");
Executed by:
  • tst_qxmlsimplereader - unknown status
2
107 else-
108 prefix.clear();
executed 2 times by 1 test: prefix.clear();
Executed by:
  • tst_qxmlsimplereader - unknown status
2
109 name = qName;-
110 } else {
executed 4 times by 1 test: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
4
111 prefix = qName.left(i);-
112 name = qName.mid(i + 1);-
113 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
4
114}-
115-
116/**************************************************************-
117 *-
118 * Private class declerations-
119 *-
120 **************************************************************/-
121-
122class QDomImplementationPrivate-
123{-
124public:-
125 inline QDomImplementationPrivate() {}-
126-
127 QDomImplementationPrivate* clone();-
128 QAtomicInt ref;-
129 static QDomImplementation::InvalidDataPolicy invalidDataPolicy;-
130};-
131-
132class QDomNodePrivate-
133{-
134public:-
135 QDomNodePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0);-
136 QDomNodePrivate(QDomNodePrivate* n, bool deep);-
137 virtual ~QDomNodePrivate();-
138-
139 QString nodeName() const { return name; }
executed 1982 times by 4 tests: return name;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
1982
140 QString nodeValue() const { return value; }
executed 33 times by 1 test: return value;
Executed by:
  • tst_qcssparser - unknown status
33
141 virtual void setNodeValue(const QString& v) { value = v; }
never executed: end of block
0
142-
143 QDomDocumentPrivate* ownerDocument();-
144 void setOwnerDocument(QDomDocumentPrivate* doc);-
145-
146 virtual QDomNodePrivate* insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild);-
147 virtual QDomNodePrivate* insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild);-
148 virtual QDomNodePrivate* replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild);-
149 virtual QDomNodePrivate* removeChild(QDomNodePrivate* oldChild);-
150 virtual QDomNodePrivate* appendChild(QDomNodePrivate* newChild);-
151-
152 QDomNodePrivate* namedItem(const QString& name);-
153-
154 virtual QDomNodePrivate* cloneNode(bool deep = true);-
155 virtual void normalize();-
156 virtual void clear();-
157-
158 inline QDomNodePrivate* parent() const { return hasParent ? ownerNode : 0; }
executed 15338 times by 5 tests: return hasParent ? ownerNode : 0;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
15338
159 inline void setParent(QDomNodePrivate *p) { ownerNode = p; hasParent = true; }
executed 4239 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
4239
160-
161 void setNoParent() {-
162 ownerNode = hasParent ? (QDomNodePrivate*)ownerDocument() : 0;
hasParentDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qtextdocument - unknown status
FALSEnever evaluated
0-1
163 hasParent = false;-
164 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_qtextdocument - unknown status
1
165-
166 // Dynamic cast-
167 bool isAttr() const { return nodeType() == QDomNode::AttributeNode; }
never executed: return nodeType() == QDomNode::AttributeNode;
0
168 bool isCDATASection() const { return nodeType() == QDomNode::CDATASectionNode; }
never executed: return nodeType() == QDomNode::CDATASectionNode;
0
169 bool isDocumentFragment() const { return nodeType() == QDomNode::DocumentFragmentNode; }
executed 2016 times by 5 tests: return nodeType() == QDomNode::DocumentFragmentNode;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
2016
170 bool isDocument() const { return nodeType() == QDomNode::DocumentNode; }
executed 14368 times by 5 tests: return nodeType() == QDomNode::DocumentNode;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
14368
171 bool isDocumentType() const { return nodeType() == QDomNode::DocumentTypeNode; }
never executed: return nodeType() == QDomNode::DocumentTypeNode;
0
172 bool isElement() const { return nodeType() == QDomNode::ElementNode; }
executed 365 times by 1 test: return nodeType() == QDomNode::ElementNode;
Executed by:
  • tst_qcssparser - unknown status
365
173 bool isEntityReference() const { return nodeType() == QDomNode::EntityReferenceNode; }
never executed: return nodeType() == QDomNode::EntityReferenceNode;
0
174 bool isText() const { const QDomNode::NodeType nt = nodeType();-
175 return (nt == QDomNode::TextNode)
executed 320 times by 1 test: return (nt == QDomNode::TextNode) || (nt == QDomNode::CDATASectionNode);
Executed by:
  • tst_qdbusxmlparser - unknown status
320
176 || (nt == QDomNode::CDATASectionNode); }
executed 320 times by 1 test: return (nt == QDomNode::TextNode) || (nt == QDomNode::CDATASectionNode);
Executed by:
  • tst_qdbusxmlparser - unknown status
320
177 bool isEntity() const { return nodeType() == QDomNode::EntityNode; }
never executed: return nodeType() == QDomNode::EntityNode;
0
178 bool isNotation() const { return nodeType() == QDomNode::NotationNode; }
never executed: return nodeType() == QDomNode::NotationNode;
0
179 bool isProcessingInstruction() const { return nodeType() == QDomNode::ProcessingInstructionNode; }
executed 172 times by 2 tests: return nodeType() == QDomNode::ProcessingInstructionNode;
Executed by:
  • tst_qdbusxmlparser - unknown status
  • tst_qxmlsimplereader - unknown status
172
180 bool isCharacterData() const { const QDomNode::NodeType nt = nodeType();-
181 return (nt == QDomNode::CharacterDataNode)
never executed: return (nt == QDomNode::CharacterDataNode) || (nt == QDomNode::TextNode) || (nt == QDomNode::CommentNode);
0
182 || (nt == QDomNode::TextNode)
never executed: return (nt == QDomNode::CharacterDataNode) || (nt == QDomNode::TextNode) || (nt == QDomNode::CommentNode);
0
183 || (nt == QDomNode::CommentNode); }
never executed: return (nt == QDomNode::CharacterDataNode) || (nt == QDomNode::TextNode) || (nt == QDomNode::CommentNode);
0
184 bool isComment() const { return nodeType() == QDomNode::CommentNode; }
never executed: return nodeType() == QDomNode::CommentNode;
0
185-
186 virtual QDomNode::NodeType nodeType() const { return QDomNode::BaseNode; }
never executed: return QDomNode::BaseNode;
0
187-
188 virtual void save(QTextStream&, int, int) const;-
189-
190 void setLocation(int lineNumber, int columnNumber);-
191-
192 // Variables-
193 QAtomicInt ref;-
194 QDomNodePrivate* prev;-
195 QDomNodePrivate* next;-
196 QDomNodePrivate* ownerNode; // either the node's parent or the node's owner document-
197 QDomNodePrivate* first;-
198 QDomNodePrivate* last;-
199-
200 QString name; // this is the local name if prefix != null-
201 QString value;-
202 QString prefix; // set this only for ElementNode and AttributeNode-
203 QString namespaceURI; // set this only for ElementNode and AttributeNode-
204 bool createdWithDom1Interface : 1;-
205 bool hasParent : 1;-
206-
207 int lineNumber;-
208 int columnNumber;-
209};-
210-
211class QDomNodeListPrivate-
212{-
213public:-
214 QDomNodeListPrivate(QDomNodePrivate*);-
215 QDomNodeListPrivate(QDomNodePrivate*, const QString& );-
216 QDomNodeListPrivate(QDomNodePrivate*, const QString&, const QString& );-
217 ~QDomNodeListPrivate();-
218-
219 bool operator== (const QDomNodeListPrivate&) const;-
220 bool operator!= (const QDomNodeListPrivate&) const;-
221-
222 void createList();-
223 QDomNodePrivate* item(int index);-
224 int length() const;-
225-
226 QAtomicInt ref;-
227 /*-
228 This list contains the children of this node.-
229 */-
230 QDomNodePrivate* node_impl;-
231 QString tagname;-
232 QString nsURI;-
233 QList<QDomNodePrivate*> list;-
234 long timestamp;-
235};-
236-
237class QDomNamedNodeMapPrivate-
238{-
239public:-
240 QDomNamedNodeMapPrivate(QDomNodePrivate*);-
241 ~QDomNamedNodeMapPrivate();-
242-
243 QDomNodePrivate* namedItem(const QString& name) const;-
244 QDomNodePrivate* namedItemNS(const QString& nsURI, const QString& localName) const;-
245 QDomNodePrivate* setNamedItem(QDomNodePrivate* arg);-
246 QDomNodePrivate* setNamedItemNS(QDomNodePrivate* arg);-
247 QDomNodePrivate* removeNamedItem(const QString& name);-
248 QDomNodePrivate* item(int index) const;-
249 int length() const;-
250 bool contains(const QString& name) const;-
251 bool containsNS(const QString& nsURI, const QString & localName) const;-
252-
253 /**-
254 * Remove all children from the map.-
255 */-
256 void clearMap();-
257 bool isReadOnly() { return readonly; }
never executed: return readonly;
0
258 void setReadOnly(bool r) { readonly = r; }
never executed: end of block
0
259 bool isAppendToParent() { return appendToParent; }
never executed: return appendToParent;
0
260 /**-
261 * If true, then the node will redirect insert/remove calls-
262 * to its parent by calling QDomNodePrivate::appendChild or removeChild.-
263 * In addition the map won't increase or decrease the reference count-
264 * of the nodes it contains.-
265 *-
266 * By default this value is false and the map will handle reference counting-
267 * by itself.-
268 */-
269 void setAppendToParent(bool b) { appendToParent = b; }
executed 976 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
976
270-
271 /**-
272 * Creates a copy of the map. It is a deep copy-
273 * that means that all children are cloned.-
274 */-
275 QDomNamedNodeMapPrivate* clone(QDomNodePrivate* parent);-
276-
277 // Variables-
278 QAtomicInt ref;-
279 QHash<QString, QDomNodePrivate *> map;-
280 QDomNodePrivate* parent;-
281 bool readonly;-
282 bool appendToParent;-
283};-
284-
285class QDomDocumentTypePrivate : public QDomNodePrivate-
286{-
287public:-
288 QDomDocumentTypePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0);-
289 QDomDocumentTypePrivate(QDomDocumentTypePrivate* n, bool deep);-
290 ~QDomDocumentTypePrivate();-
291 void init();-
292-
293 // Reimplemented from QDomNodePrivate-
294 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
295 QDomNodePrivate* insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild) Q_DECL_OVERRIDE;-
296 QDomNodePrivate* insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild) Q_DECL_OVERRIDE;-
297 QDomNodePrivate* replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild) Q_DECL_OVERRIDE;-
298 QDomNodePrivate* removeChild(QDomNodePrivate* oldChild) Q_DECL_OVERRIDE;-
299 QDomNodePrivate* appendChild(QDomNodePrivate* newChild) Q_DECL_OVERRIDE;-
300-
301 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::DocumentTypeNode; }
never executed: return QDomNode::DocumentTypeNode;
0
302-
303 void save(QTextStream& s, int, int) const Q_DECL_OVERRIDE;-
304-
305 // Variables-
306 QDomNamedNodeMapPrivate* entities;-
307 QDomNamedNodeMapPrivate* notations;-
308 QString publicId;-
309 QString systemId;-
310 QString internalSubset;-
311};-
312-
313class QDomDocumentFragmentPrivate : public QDomNodePrivate-
314{-
315public:-
316 QDomDocumentFragmentPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0);-
317 QDomDocumentFragmentPrivate(QDomNodePrivate* n, bool deep);-
318-
319 // Reimplemented from QDomNodePrivate-
320 virtual QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
321 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::DocumentFragmentNode; }
never executed: return QDomNode::DocumentFragmentNode;
0
322};-
323-
324class QDomCharacterDataPrivate : public QDomNodePrivate-
325{-
326public:-
327 QDomCharacterDataPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& data);-
328 QDomCharacterDataPrivate(QDomCharacterDataPrivate* n, bool deep);-
329-
330 int dataLength() const;-
331 QString substringData(unsigned long offset, unsigned long count) const;-
332 void appendData(const QString& arg);-
333 void insertData(unsigned long offset, const QString& arg);-
334 void deleteData(unsigned long offset, unsigned long count);-
335 void replaceData(unsigned long offset, unsigned long count, const QString& arg);-
336-
337 // Reimplemented from QDomNodePrivate-
338 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::CharacterDataNode; }
never executed: return QDomNode::CharacterDataNode;
0
339 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
340};-
341-
342class QDomTextPrivate : public QDomCharacterDataPrivate-
343{-
344public:-
345 QDomTextPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val);-
346 QDomTextPrivate(QDomTextPrivate* n, bool deep);-
347-
348 QDomTextPrivate* splitText(int offset);-
349-
350 // Reimplemented from QDomNodePrivate-
351 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
352 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::TextNode; }
executed 994 times by 5 tests: return QDomNode::TextNode;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
994
353 virtual void save(QTextStream& s, int, int) const Q_DECL_OVERRIDE;-
354};-
355-
356class QDomAttrPrivate : public QDomNodePrivate-
357{-
358public:-
359 QDomAttrPrivate(QDomDocumentPrivate*, QDomNodePrivate*, const QString& name);-
360 QDomAttrPrivate(QDomDocumentPrivate*, QDomNodePrivate*, const QString& nsURI, const QString& qName);-
361 QDomAttrPrivate(QDomAttrPrivate* n, bool deep);-
362-
363 bool specified() const;-
364-
365 // Reimplemented from QDomNodePrivate-
366 void setNodeValue(const QString& v) Q_DECL_OVERRIDE;-
367 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
368 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::AttributeNode; }
executed 1738 times by 4 tests: return QDomNode::AttributeNode;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
1738
369 virtual void save(QTextStream& s, int, int) const Q_DECL_OVERRIDE;-
370-
371 // Variables-
372 bool m_specified;-
373};-
374-
375class QDomElementPrivate : public QDomNodePrivate-
376{-
377public:-
378 QDomElementPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name);-
379 QDomElementPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& nsURI, const QString& qName);-
380 QDomElementPrivate(QDomElementPrivate* n, bool deep);-
381 ~QDomElementPrivate();-
382-
383 QString attribute(const QString& name, const QString& defValue) const;-
384 QString attributeNS(const QString& nsURI, const QString& localName, const QString& defValue) const;-
385 void setAttribute(const QString& name, const QString& value);-
386 void setAttributeNS(const QString& nsURI, const QString& qName, const QString& newValue);-
387 void removeAttribute(const QString& name);-
388 QDomAttrPrivate* attributeNode(const QString& name);-
389 QDomAttrPrivate* attributeNodeNS(const QString& nsURI, const QString& localName);-
390 QDomAttrPrivate* setAttributeNode(QDomAttrPrivate* newAttr);-
391 QDomAttrPrivate* setAttributeNodeNS(QDomAttrPrivate* newAttr);-
392 QDomAttrPrivate* removeAttributeNode(QDomAttrPrivate* oldAttr);-
393 bool hasAttribute(const QString& name);-
394 bool hasAttributeNS(const QString& nsURI, const QString& localName);-
395-
396 QString text();-
397-
398 // Reimplemented from QDomNodePrivate-
399 QDomNamedNodeMapPrivate* attributes() { return m_attr; }
never executed: return m_attr;
0
400 bool hasAttributes() { return (m_attr->length() > 0); }
executed 26 times by 1 test: return (m_attr->length() > 0);
Executed by:
  • tst_qcssparser - unknown status
26
401 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::ElementNode; }
executed 10667 times by 5 tests: return QDomNode::ElementNode;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
10667
402 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
403 virtual void save(QTextStream& s, int, int) const Q_DECL_OVERRIDE;-
404-
405 // Variables-
406 QDomNamedNodeMapPrivate* m_attr;-
407};-
408-
409-
410class QDomCommentPrivate : public QDomCharacterDataPrivate-
411{-
412public:-
413 QDomCommentPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val);-
414 QDomCommentPrivate(QDomCommentPrivate* n, bool deep);-
415-
416 // Reimplemented from QDomNodePrivate-
417 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
418 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::CommentNode; }
never executed: return QDomNode::CommentNode;
0
419 virtual void save(QTextStream& s, int, int) const Q_DECL_OVERRIDE;-
420};-
421-
422class QDomCDATASectionPrivate : public QDomTextPrivate-
423{-
424public:-
425 QDomCDATASectionPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val);-
426 QDomCDATASectionPrivate(QDomCDATASectionPrivate* n, bool deep);-
427-
428 // Reimplemented from QDomNodePrivate-
429 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
430 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::CDATASectionNode; }
never executed: return QDomNode::CDATASectionNode;
0
431 virtual void save(QTextStream& s, int, int) const Q_DECL_OVERRIDE;-
432};-
433-
434class QDomNotationPrivate : public QDomNodePrivate-
435{-
436public:-
437 QDomNotationPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name,-
438 const QString& pub, const QString& sys);-
439 QDomNotationPrivate(QDomNotationPrivate* n, bool deep);-
440-
441 // Reimplemented from QDomNodePrivate-
442 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
443 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::NotationNode; }
never executed: return QDomNode::NotationNode;
0
444 virtual void save(QTextStream& s, int, int) const Q_DECL_OVERRIDE;-
445-
446 // Variables-
447 QString m_sys;-
448 QString m_pub;-
449};-
450-
451class QDomEntityPrivate : public QDomNodePrivate-
452{-
453public:-
454 QDomEntityPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name,-
455 const QString& pub, const QString& sys, const QString& notation);-
456 QDomEntityPrivate(QDomEntityPrivate* n, bool deep);-
457-
458 // Reimplemented from QDomNodePrivate-
459 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
460 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::EntityNode; }
never executed: return QDomNode::EntityNode;
0
461 virtual void save(QTextStream& s, int, int) const Q_DECL_OVERRIDE;-
462-
463 // Variables-
464 QString m_sys;-
465 QString m_pub;-
466 QString m_notationName;-
467};-
468-
469class QDomEntityReferencePrivate : public QDomNodePrivate-
470{-
471public:-
472 QDomEntityReferencePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name);-
473 QDomEntityReferencePrivate(QDomNodePrivate* n, bool deep);-
474-
475 // Reimplemented from QDomNodePrivate-
476 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
477 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::EntityReferenceNode; }
never executed: return QDomNode::EntityReferenceNode;
0
478 virtual void save(QTextStream& s, int, int) const Q_DECL_OVERRIDE;-
479};-
480-
481class QDomProcessingInstructionPrivate : public QDomNodePrivate-
482{-
483public:-
484 QDomProcessingInstructionPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& target,-
485 const QString& data);-
486 QDomProcessingInstructionPrivate(QDomProcessingInstructionPrivate* n, bool deep);-
487-
488 // Reimplemented from QDomNodePrivate-
489 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
490 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::ProcessingInstructionNode; }
never executed: return QDomNode::ProcessingInstructionNode;
0
491 virtual void save(QTextStream& s, int, int) const Q_DECL_OVERRIDE;-
492};-
493-
494class QDomDocumentPrivate : public QDomNodePrivate-
495{-
496public:-
497 QDomDocumentPrivate();-
498 QDomDocumentPrivate(const QString& name);-
499 QDomDocumentPrivate(QDomDocumentTypePrivate* dt);-
500 QDomDocumentPrivate(QDomDocumentPrivate* n, bool deep);-
501 ~QDomDocumentPrivate();-
502-
503 bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn);-
504 bool setContent(QXmlInputSource *source, QXmlReader *reader, QXmlSimpleReader *simpleReader, QString *errorMsg, int *errorLine, int *errorColumn);-
505-
506 // Attributes-
507 QDomDocumentTypePrivate* doctype() { return type.data(); }
executed 471 times by 2 tests: return type.data();
Executed by:
  • tst_qcssparser - unknown status
  • tst_qtextdocument - unknown status
471
508 QDomImplementationPrivate* implementation() { return impl.data(); }
never executed: return impl.data();
0
509 QDomElementPrivate* documentElement();-
510-
511 // Factories-
512 QDomElementPrivate* createElement(const QString& tagName);-
513 QDomElementPrivate* createElementNS(const QString& nsURI, const QString& qName);-
514 QDomDocumentFragmentPrivate* createDocumentFragment();-
515 QDomTextPrivate* createTextNode(const QString& data);-
516 QDomCommentPrivate* createComment(const QString& data);-
517 QDomCDATASectionPrivate* createCDATASection(const QString& data);-
518 QDomProcessingInstructionPrivate* createProcessingInstruction(const QString& target, const QString& data);-
519 QDomAttrPrivate* createAttribute(const QString& name);-
520 QDomAttrPrivate* createAttributeNS(const QString& nsURI, const QString& qName);-
521 QDomEntityReferencePrivate* createEntityReference(const QString& name);-
522-
523 QDomNodePrivate* importNode(QDomNodePrivate* importedNode, bool deep);-
524-
525 // Reimplemented from QDomNodePrivate-
526 QDomNodePrivate* cloneNode(bool deep = true) Q_DECL_OVERRIDE;-
527 QDomNode::NodeType nodeType() const Q_DECL_OVERRIDE { return QDomNode::DocumentNode; }
executed 3842 times by 5 tests: return QDomNode::DocumentNode;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
3842
528 void clear() Q_DECL_OVERRIDE;-
529-
530 // Variables-
531 QExplicitlySharedDataPointer<QDomImplementationPrivate> impl;-
532 QExplicitlySharedDataPointer<QDomDocumentTypePrivate> type;-
533-
534 void saveDocument(QTextStream& stream, const int indent, QDomNode::EncodingPolicy encUsed) const;-
535-
536 /* \internal-
537 Counter for the QDomNodeListPrivate timestamps.-
538-
539 This is a cache optimization, that might in some cases be effective. The-
540 dilemma is that QDomNode::childNodes() returns a list, but the-
541 implementation stores the children in a linked list. Hence, in order to-
542 get the children out through childNodes(), a list must be populated each-
543 time, which is O(N).-
544-
545 DOM has the requirement of node references being live, see DOM Core-
546 Level 3, 1.1.1 The DOM Structure Model, which means that changes to the-
547 underlying documents must be reflected in node lists.-
548-
549 This mechanism, nodeListTime, is a caching optimization that reduces the-
550 amount of times the node list is rebuilt, by only doing so when the-
551 document actually changes. However, a change to anywhere in any document-
552 invalidate all lists, since no dependency tracking is done.-
553-
554 It functions by that all modifying functions(insertBefore() and so on)-
555 increment the count; each QDomNodeListPrivate copies nodeListTime on-
556 construction, and compares its own value to nodeListTime in order to-
557 determine whether it needs to rebuild.-
558-
559 This is reentrant. The nodeListTime may overflow, but that's ok since we-
560 check for equalness, not whether nodeListTime is smaller than the list's-
561 stored timestamp.-
562 */-
563 long nodeListTime;-
564};-
565-
566/**************************************************************-
567 *-
568 * QDomHandler-
569 *-
570 **************************************************************/-
571-
572class QDomHandler : public QXmlDefaultHandler-
573{-
574public:-
575 QDomHandler(QDomDocumentPrivate* d, QXmlSimpleReader *reader, bool namespaceProcessing);-
576 ~QDomHandler();-
577-
578 // content handler-
579 bool endDocument() Q_DECL_OVERRIDE;-
580 bool startElement(const QString& nsURI, const QString& localName, const QString& qName, const QXmlAttributes& atts) Q_DECL_OVERRIDE;-
581 bool endElement(const QString& nsURI, const QString& localName, const QString& qName) Q_DECL_OVERRIDE;-
582 bool characters(const QString& ch) Q_DECL_OVERRIDE;-
583 bool processingInstruction(const QString& target, const QString& data) Q_DECL_OVERRIDE;-
584 bool skippedEntity(const QString& name) Q_DECL_OVERRIDE;-
585-
586 // error handler-
587 bool fatalError(const QXmlParseException& exception) Q_DECL_OVERRIDE;-
588-
589 // lexical handler-
590 bool startCDATA() Q_DECL_OVERRIDE;-
591 bool endCDATA() Q_DECL_OVERRIDE;-
592 bool startEntity(const QString &) Q_DECL_OVERRIDE;-
593 bool endEntity(const QString &) Q_DECL_OVERRIDE;-
594 bool startDTD(const QString& name, const QString& publicId, const QString& systemId) Q_DECL_OVERRIDE;-
595 bool comment(const QString& ch) Q_DECL_OVERRIDE;-
596-
597 // decl handler-
598 bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId) Q_DECL_OVERRIDE ;-
599-
600 // DTD handler-
601 bool notationDecl(const QString & name, const QString & publicId, const QString & systemId) Q_DECL_OVERRIDE;-
602 bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString &notationName) Q_DECL_OVERRIDE ;-
603-
604 void setDocumentLocator(QXmlLocator *locator) Q_DECL_OVERRIDE;-
605-
606 QString errorMsg;-
607 int errorLine;-
608 int errorColumn;-
609-
610private:-
611 QDomDocumentPrivate *doc;-
612 QDomNodePrivate *node;-
613 QString entityName;-
614 bool cdata;-
615 bool nsProcessing;-
616 QXmlLocator *locator;-
617 QXmlSimpleReader *reader;-
618};-
619-
620/**************************************************************-
621 *-
622 * Functions for verifying legal data-
623 *-
624 **************************************************************/-
625QDomImplementation::InvalidDataPolicy QDomImplementationPrivate::invalidDataPolicy-
626 = QDomImplementation::AcceptInvalidChars;-
627-
628// [5] Name ::= (Letter | '_' | ':') (NameChar)*-
629-
630static QString fixedXmlName(const QString &_name, bool *ok, bool namespaces = false)-
631{-
632 QString name, prefix;-
633 if (namespaces)
namespacesDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1021 times by 4 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
2-1021
634 qt_split_namespace(prefix, name, _name, true);
executed 2 times by 1 test: qt_split_namespace(prefix, name, _name, true);
Executed by:
  • tst_qxmlsimplereader - unknown status
2
635 else-
636 name = _name;
executed 1021 times by 4 tests: name = _name;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
1021
637-
638 if (name.isEmpty()) {
name.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 1023 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
0-1023
639 *ok = false;-
640 return QString();
never executed: return QString();
0
641 }-
642-
643 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
QDomImplementa...ptInvalidCharsDescription
TRUEevaluated 1023 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
0-1023
644 *ok = true;-
645 return _name;
executed 1023 times by 5 tests: return _name;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
1023
646 }-
647-
648 QString result;-
649 bool firstChar = true;-
650 for (int i = 0; i < name.size(); ++i) {
i < name.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
651 QChar c = name.at(i);-
652 if (firstChar) {
firstCharDescription
TRUEnever evaluated
FALSEnever evaluated
0
653 if (QXmlUtils::isLetter(c) || c.unicode() == '_' || c.unicode() == ':') {
QXmlUtils::isLetter(c)Description
TRUEnever evaluated
FALSEnever evaluated
c.unicode() == '_'Description
TRUEnever evaluated
FALSEnever evaluated
c.unicode() == ':'Description
TRUEnever evaluated
FALSEnever evaluated
0
654 result.append(c);-
655 firstChar = false;-
656 } else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
never executed: end of block
QDomImplementa...ReturnNullNodeDescription
TRUEnever evaluated
FALSEnever evaluated
0
657 *ok = false;-
658 return QString();
never executed: return QString();
0
659 }-
660 } else {
never executed: end of block
0
661 if (QXmlUtils::isNameChar(c))
QXmlUtils::isNameChar(c)Description
TRUEnever evaluated
FALSEnever evaluated
0
662 result.append(c);
never executed: result.append(c);
0
663 else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
QDomImplementa...ReturnNullNodeDescription
TRUEnever evaluated
FALSEnever evaluated
0
664 *ok = false;-
665 return QString();
never executed: return QString();
0
666 }-
667 }
never executed: end of block
0
668 }-
669-
670 if (result.isEmpty()) {
result.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
671 *ok = false;-
672 return QString();
never executed: return QString();
0
673 }-
674-
675 *ok = true;-
676 if (namespaces && !prefix.isEmpty())
namespacesDescription
TRUEnever evaluated
FALSEnever evaluated
!prefix.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
677 return prefix + QLatin1Char(':') + result;
never executed: return prefix + QLatin1Char(':') + result;
0
678 return result;
never executed: return result;
0
679}-
680-
681// [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)-
682// '<', '&' and "]]>" will be escaped when writing-
683-
684static QString fixedCharData(const QString &data, bool *ok)-
685{-
686 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
QDomImplementa...ptInvalidCharsDescription
TRUEevaluated 125 times by 2 tests
Evaluated by:
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
FALSEnever evaluated
0-125
687 *ok = true;-
688 return data;
executed 125 times by 2 tests: return data;
Executed by:
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
125
689 }-
690-
691 QString result;-
692 for (int i = 0; i < data.size(); ++i) {
i < data.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
693 QChar c = data.at(i);-
694 if (QXmlUtils::isChar(c)) {
QXmlUtils::isChar(c)Description
TRUEnever evaluated
FALSEnever evaluated
0
695 result.append(c);-
696 } else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
never executed: end of block
QDomImplementa...ReturnNullNodeDescription
TRUEnever evaluated
FALSEnever evaluated
0
697 *ok = false;-
698 return QString();
never executed: return QString();
0
699 }-
700 }
never executed: end of block
0
701-
702 *ok = true;-
703 return result;
never executed: return result;
0
704}-
705-
706// [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'-
707// can't escape "--", since entities are not recognised within comments-
708-
709static QString fixedComment(const QString &data, bool *ok)-
710{-
711 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
QDomImplementa...ptInvalidCharsDescription
TRUEnever evaluated
FALSEnever evaluated
0
712 *ok = true;-
713 return data;
never executed: return data;
0
714 }-
715-
716 QString fixedData = fixedCharData(data, ok);-
717 if (!*ok)
!*okDescription
TRUEnever evaluated
FALSEnever evaluated
0
718 return QString();
never executed: return QString();
0
719-
720 for (;;) {-
721 int idx = fixedData.indexOf(QLatin1String("--"));-
722 if (idx == -1)
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
723 break;
never executed: break;
0
724 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
QDomImplementa...ReturnNullNodeDescription
TRUEnever evaluated
FALSEnever evaluated
0
725 *ok = false;-
726 return QString();
never executed: return QString();
0
727 }-
728 fixedData.remove(idx, 2);-
729 }
never executed: end of block
0
730-
731 *ok = true;-
732 return fixedData;
never executed: return fixedData;
0
733}-
734-
735// [20] CData ::= (Char* - (Char* ']]>' Char*))-
736// can't escape "]]>", since entities are not recognised within comments-
737-
738static QString fixedCDataSection(const QString &data, bool *ok)-
739{-
740 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
QDomImplementa...ptInvalidCharsDescription
TRUEnever evaluated
FALSEnever evaluated
0
741 *ok = true;-
742 return data;
never executed: return data;
0
743 }-
744-
745 QString fixedData = fixedCharData(data, ok);-
746 if (!*ok)
!*okDescription
TRUEnever evaluated
FALSEnever evaluated
0
747 return QString();
never executed: return QString();
0
748-
749 for (;;) {-
750 int idx = fixedData.indexOf(QLatin1String("]]>"));-
751 if (idx == -1)
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
752 break;
never executed: break;
0
753 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
QDomImplementa...ReturnNullNodeDescription
TRUEnever evaluated
FALSEnever evaluated
0
754 *ok = false;-
755 return QString();
never executed: return QString();
0
756 }-
757 fixedData.remove(idx, 3);-
758 }
never executed: end of block
0
759-
760 *ok = true;-
761 return fixedData;
never executed: return fixedData;
0
762}-
763-
764// [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'-
765-
766static QString fixedPIData(const QString &data, bool *ok)-
767{-
768 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
QDomImplementa...ptInvalidCharsDescription
TRUEnever evaluated
FALSEnever evaluated
0
769 *ok = true;-
770 return data;
never executed: return data;
0
771 }-
772-
773 QString fixedData = fixedCharData(data, ok);-
774 if (!*ok)
!*okDescription
TRUEnever evaluated
FALSEnever evaluated
0
775 return QString();
never executed: return QString();
0
776-
777 for (;;) {-
778 int idx = fixedData.indexOf(QLatin1String("?>"));-
779 if (idx == -1)
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
780 break;
never executed: break;
0
781 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
QDomImplementa...ReturnNullNodeDescription
TRUEnever evaluated
FALSEnever evaluated
0
782 *ok = false;-
783 return QString();
never executed: return QString();
0
784 }-
785 fixedData.remove(idx, 2);-
786 }
never executed: end of block
0
787-
788 *ok = true;-
789 return fixedData;
never executed: return fixedData;
0
790}-
791-
792// [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"-
793// The correct quote will be chosen when writing-
794-
795static QString fixedPubidLiteral(const QString &data, bool *ok)-
796{-
797 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
QDomImplementa...ptInvalidCharsDescription
TRUEnever evaluated
FALSEnever evaluated
0
798 *ok = true;-
799 return data;
never executed: return data;
0
800 }-
801-
802 QString result;-
803-
804 if(QXmlUtils::isPublicID(data))
QXmlUtils::isPublicID(data)Description
TRUEnever evaluated
FALSEnever evaluated
0
805 result = data;
never executed: result = data;
0
806 else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
QDomImplementa...ReturnNullNodeDescription
TRUEnever evaluated
FALSEnever evaluated
0
807 *ok = false;-
808 return QString();
never executed: return QString();
0
809 }-
810-
811 if (result.indexOf(QLatin1Char('\'')) != -1
result.indexOf...r('\'')) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
812 && result.indexOf(QLatin1Char('"')) != -1) {
result.indexOf...ar('"')) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
813 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
QDomImplementa...ReturnNullNodeDescription
TRUEnever evaluated
FALSEnever evaluated
0
814 *ok = false;-
815 return QString();
never executed: return QString();
0
816 } else {-
817 result.remove(QLatin1Char('\''));-
818 }
never executed: end of block
0
819 }-
820-
821 *ok = true;-
822 return result;
never executed: return result;
0
823}-
824-
825// [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")-
826// The correct quote will be chosen when writing-
827-
828static QString fixedSystemLiteral(const QString &data, bool *ok)-
829{-
830 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
QDomImplementa...ptInvalidCharsDescription
TRUEnever evaluated
FALSEnever evaluated
0
831 *ok = true;-
832 return data;
never executed: return data;
0
833 }-
834-
835 QString result = data;-
836-
837 if (result.indexOf(QLatin1Char('\'')) != -1
result.indexOf...r('\'')) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
838 && result.indexOf(QLatin1Char('"')) != -1) {
result.indexOf...ar('"')) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
839 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
QDomImplementa...ReturnNullNodeDescription
TRUEnever evaluated
FALSEnever evaluated
0
840 *ok = false;-
841 return QString();
never executed: return QString();
0
842 } else {-
843 result.remove(QLatin1Char('\''));-
844 }
never executed: end of block
0
845 }-
846-
847 *ok = true;-
848 return result;
never executed: return result;
0
849}-
850-
851/**************************************************************-
852 *-
853 * QDomImplementationPrivate-
854 *-
855 **************************************************************/-
856-
857QDomImplementationPrivate* QDomImplementationPrivate::clone()-
858{-
859 return new QDomImplementationPrivate;
never executed: return new QDomImplementationPrivate;
0
860}-
861-
862/**************************************************************-
863 *-
864 * QDomImplementation-
865 *-
866 **************************************************************/-
867-
868/*!-
869 \class QDomImplementation-
870 \reentrant-
871 \brief The QDomImplementation class provides information about the-
872 features of the DOM implementation.-
873-
874 \inmodule QtXml-
875 \ingroup xml-tools-
876-
877 This class describes the features that are supported by the DOM-
878 implementation. Currently the XML subset of DOM Level 1 and DOM-
879 Level 2 Core are supported.-
880-
881 Normally you will use the function QDomDocument::implementation()-
882 to get the implementation object.-
883-
884 You can create a new document type with createDocumentType() and a-
885 new document with createDocument().-
886-
887 For further information about the Document Object Model see-
888 \l{http://www.w3.org/TR/REC-DOM-Level-1/}{Level 1} and-
889 \l{http://www.w3.org/TR/DOM-Level-2-Core/}{Level 2 Core}. For a more-
890 general introduction of the DOM implementation see the QDomDocument-
891 documentation.-
892-
893 The QDom classes have a few issues of nonconformance with the XML-
894 specifications that cannot be fixed in Qt 4 without breaking backward-
895 compatibility. The Qt XML Patterns module and the QXmlStreamReader and-
896 QXmlStreamWriter classes have a higher degree of a conformance.-
897-
898 \sa hasFeature()-
899*/-
900-
901/*!-
902 Constructs a QDomImplementation object.-
903*/-
904QDomImplementation::QDomImplementation()-
905{-
906 impl = 0;-
907}
never executed: end of block
0
908-
909/*!-
910 Constructs a copy of \a x.-
911*/-
912QDomImplementation::QDomImplementation(const QDomImplementation &x)-
913{-
914 impl = x.impl;-
915 if (impl)
implDescription
TRUEnever evaluated
FALSEnever evaluated
0
916 impl->ref.ref();
never executed: impl->ref.ref();
0
917}
never executed: end of block
0
918-
919QDomImplementation::QDomImplementation(QDomImplementationPrivate *p)-
920{-
921 // We want to be co-owners, so increase the reference count-
922 impl = p;-
923 if (impl)
implDescription
TRUEnever evaluated
FALSEnever evaluated
0
924 impl->ref.ref();
never executed: impl->ref.ref();
0
925}
never executed: end of block
0
926-
927/*!-
928 Assigns \a x to this DOM implementation.-
929*/-
930QDomImplementation& QDomImplementation::operator=(const QDomImplementation &x)-
931{-
932 if (x.impl)
x.implDescription
TRUEnever evaluated
FALSEnever evaluated
0
933 x.impl->ref.ref();
never executed: x.impl->ref.ref();
0
934 if (impl && !impl->ref.deref())
implDescription
TRUEnever evaluated
FALSEnever evaluated
!impl->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
935 delete impl;
never executed: delete impl;
0
936 impl = x.impl;-
937 return *this;
never executed: return *this;
0
938}-
939-
940/*!-
941 Returns \c true if \a x and this DOM implementation object were-
942 created from the same QDomDocument; otherwise returns \c false.-
943*/-
944bool QDomImplementation::operator==(const QDomImplementation &x) const-
945{-
946 return (impl == x.impl);
never executed: return (impl == x.impl);
0
947}-
948-
949/*!-
950 Returns \c true if \a x and this DOM implementation object were-
951 created from different QDomDocuments; otherwise returns \c false.-
952*/-
953bool QDomImplementation::operator!=(const QDomImplementation &x) const-
954{-
955 return (impl != x.impl);
never executed: return (impl != x.impl);
0
956}-
957-
958/*!-
959 Destroys the object and frees its resources.-
960*/-
961QDomImplementation::~QDomImplementation()-
962{-
963 if (impl && !impl->ref.deref())
implDescription
TRUEnever evaluated
FALSEnever evaluated
!impl->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
964 delete impl;
never executed: delete impl;
0
965}
never executed: end of block
0
966-
967/*!-
968 The function returns \c true if QDom implements the requested \a-
969 version of a \a feature; otherwise returns \c false.-
970-
971 The currently supported features and their versions:-
972 \table-
973 \header \li Feature \li Version-
974 \row \li XML \li 1.0-
975 \endtable-
976*/-
977bool QDomImplementation::hasFeature(const QString& feature, const QString& version) const-
978{-
979 if (feature == QLatin1String("XML")) {
feature == QLa...1String("XML")Description
TRUEnever evaluated
FALSEnever evaluated
0
980 if (version.isEmpty() || version == QLatin1String("1.0")) {
version.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
version == QLa...1String("1.0")Description
TRUEnever evaluated
FALSEnever evaluated
0
981 return true;
never executed: return true;
0
982 }-
983 }
never executed: end of block
0
984 // ### add DOM level 2 features-
985 return false;
never executed: return false;
0
986}-
987-
988/*!-
989 Creates a document type node for the name \a qName.-
990-
991 \a publicId specifies the public identifier of the external-
992 subset. If you specify an empty string (QString()) as the \a-
993 publicId, this means that the document type has no public-
994 identifier.-
995-
996 \a systemId specifies the system identifier of the external-
997 subset. If you specify an empty string as the \a systemId, this-
998 means that the document type has no system identifier.-
999-
1000 Since you cannot have a public identifier without a system-
1001 identifier, the public identifier is set to an empty string if-
1002 there is no system identifier.-
1003-
1004 DOM level 2 does not support any other document type declaration-
1005 features.-
1006-
1007 The only way you can use a document type that was created this-
1008 way, is in combination with the createDocument() function to-
1009 create a QDomDocument with this document type.-
1010-
1011 In the DOM specification, this is the only way to create a non-null-
1012 document. For historical reasons, Qt also allows to create the-
1013 document using the default empty constructor. The resulting document-
1014 is null, but becomes non-null when a factory function, for example-
1015 QDomDocument::createElement(), is called. The document also becomes-
1016 non-null when setContent() is called.-
1017-
1018 \sa createDocument()-
1019*/-
1020QDomDocumentType QDomImplementation::createDocumentType(const QString& qName, const QString& publicId, const QString& systemId)-
1021{-
1022 bool ok;-
1023 QString fixedName = fixedXmlName(qName, &ok, true);-
1024 if (!ok)
!okDescription
TRUEnever evaluated
FALSEnever evaluated
0
1025 return QDomDocumentType();
never executed: return QDomDocumentType();
0
1026-
1027 QString fixedPublicId = fixedPubidLiteral(publicId, &ok);-
1028 if (!ok)
!okDescription
TRUEnever evaluated
FALSEnever evaluated
0
1029 return QDomDocumentType();
never executed: return QDomDocumentType();
0
1030-
1031 QString fixedSystemId = fixedSystemLiteral(systemId, &ok);-
1032 if (!ok)
!okDescription
TRUEnever evaluated
FALSEnever evaluated
0
1033 return QDomDocumentType();
never executed: return QDomDocumentType();
0
1034-
1035 QDomDocumentTypePrivate *dt = new QDomDocumentTypePrivate(0);-
1036 dt->name = fixedName;-
1037 if (systemId.isNull()) {
systemId.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1038 dt->publicId.clear();-
1039 dt->systemId.clear();-
1040 } else {
never executed: end of block
0
1041 dt->publicId = fixedPublicId;-
1042 dt->systemId = fixedSystemId;-
1043 }
never executed: end of block
0
1044 dt->ref.deref();-
1045 return QDomDocumentType(dt);
never executed: return QDomDocumentType(dt);
0
1046}-
1047-
1048/*!-
1049 Creates a DOM document with the document type \a doctype. This-
1050 function also adds a root element node with the qualified name \a-
1051 qName and the namespace URI \a nsURI.-
1052*/-
1053QDomDocument QDomImplementation::createDocument(const QString& nsURI, const QString& qName, const QDomDocumentType& doctype)-
1054{-
1055 QDomDocument doc(doctype);-
1056 QDomElement root = doc.createElementNS(nsURI, qName);-
1057 if (root.isNull())
root.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1058 return QDomDocument();
never executed: return QDomDocument();
0
1059 doc.appendChild(root);-
1060 return doc;
never executed: return doc;
0
1061}-
1062-
1063/*!-
1064 Returns \c false if the object was created by-
1065 QDomDocument::implementation(); otherwise returns \c true.-
1066*/-
1067bool QDomImplementation::isNull()-
1068{-
1069 return (impl == 0);
never executed: return (impl == 0);
0
1070}-
1071-
1072/*!-
1073 \enum QDomImplementation::InvalidDataPolicy-
1074-
1075 This enum specifies what should be done when a factory function-
1076 in QDomDocument is called with invalid data.-
1077 \value AcceptInvalidChars The data should be stored in the DOM object-
1078 anyway. In this case the resulting XML document might not be well-formed.-
1079 This is the default value and QDom's behavior in Qt < 4.1.-
1080 \value DropInvalidChars The invalid characters should be removed from-
1081 the data.-
1082 \value ReturnNullNode The factory function should return a null node.-
1083-
1084 \sa setInvalidDataPolicy(), invalidDataPolicy()-
1085*/-
1086-
1087/*!-
1088 \enum QDomNode::EncodingPolicy-
1089 \since 4.3-
1090-
1091 This enum specifies how QDomNode::save() determines what encoding to use-
1092 when serializing.-
1093-
1094 \value EncodingFromDocument The encoding is fetched from the document.-
1095 \value EncodingFromTextStream The encoding is fetched from the QTextStream.-
1096-
1097 \sa QDomNode::save()-
1098*/-
1099-
1100/*!-
1101 \since 4.1-
1102 \nonreentrant-
1103-
1104 Returns the invalid data policy, which specifies what should be done when-
1105 a factory function in QDomDocument is passed invalid data.-
1106-
1107 \sa setInvalidDataPolicy(), InvalidDataPolicy-
1108*/-
1109-
1110QDomImplementation::InvalidDataPolicy QDomImplementation::invalidDataPolicy()-
1111{-
1112 return QDomImplementationPrivate::invalidDataPolicy;
never executed: return QDomImplementationPrivate::invalidDataPolicy;
0
1113}-
1114-
1115/*!-
1116 \since 4.1-
1117 \nonreentrant-
1118-
1119 Sets the invalid data policy, which specifies what should be done when-
1120 a factory function in QDomDocument is passed invalid data.-
1121-
1122 The \a policy is set for all instances of QDomDocument which already-
1123 exist and which will be created in the future.-
1124-
1125 \snippet code/src_xml_dom_qdom.cpp 0-
1126-
1127 \sa invalidDataPolicy(), InvalidDataPolicy-
1128*/-
1129-
1130void QDomImplementation::setInvalidDataPolicy(InvalidDataPolicy policy)-
1131{-
1132 QDomImplementationPrivate::invalidDataPolicy = policy;-
1133}
never executed: end of block
0
1134-
1135/**************************************************************-
1136 *-
1137 * QDomNodeListPrivate-
1138 *-
1139 **************************************************************/-
1140-
1141QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl) : ref(1)-
1142{-
1143 node_impl = n_impl;-
1144 if (node_impl)
node_implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1145 node_impl->ref.ref();
never executed: node_impl->ref.ref();
0
1146 timestamp = 0;-
1147}
never executed: end of block
0
1148-
1149QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &name) :-
1150 ref(1)-
1151{-
1152 node_impl = n_impl;-
1153 if (node_impl)
node_implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1154 node_impl->ref.ref();
never executed: node_impl->ref.ref();
0
1155 tagname = name;-
1156 timestamp = 0;-
1157}
never executed: end of block
0
1158-
1159QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &_nsURI, const QString &localName) :-
1160 ref(1)-
1161{-
1162 node_impl = n_impl;-
1163 if (node_impl)
node_implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1164 node_impl->ref.ref();
never executed: node_impl->ref.ref();
0
1165 tagname = localName;-
1166 nsURI = _nsURI;-
1167 timestamp = 0;-
1168}
never executed: end of block
0
1169-
1170QDomNodeListPrivate::~QDomNodeListPrivate()-
1171{-
1172 if (node_impl && !node_impl->ref.deref())
node_implDescription
TRUEnever evaluated
FALSEnever evaluated
!node_impl->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
1173 delete node_impl;
never executed: delete node_impl;
0
1174}
never executed: end of block
0
1175-
1176bool QDomNodeListPrivate::operator==(const QDomNodeListPrivate &other) const-
1177{-
1178 return (node_impl == other.node_impl) && (tagname == other.tagname);
never executed: return (node_impl == other.node_impl) && (tagname == other.tagname);
0
1179}-
1180-
1181bool QDomNodeListPrivate::operator!=(const QDomNodeListPrivate &other) const-
1182{-
1183 return (node_impl != other.node_impl) || (tagname != other.tagname);
never executed: return (node_impl != other.node_impl) || (tagname != other.tagname);
0
1184}-
1185-
1186void QDomNodeListPrivate::createList()-
1187{-
1188 if (!node_impl)
!node_implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1189 return;
never executed: return;
0
1190-
1191 const QDomDocumentPrivate *const doc = node_impl->ownerDocument();-
1192 if (doc && timestamp != doc->nodeListTime)
docDescription
TRUEnever evaluated
FALSEnever evaluated
timestamp != doc->nodeListTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1193 timestamp = doc->nodeListTime;
never executed: timestamp = doc->nodeListTime;
0
1194-
1195 QDomNodePrivate* p = node_impl->first;-
1196-
1197 list.clear();-
1198 if (tagname.isNull()) {
tagname.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1199 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1200 list.append(p);-
1201 p = p->next;-
1202 }
never executed: end of block
0
1203 } else if (nsURI.isNull()) {
never executed: end of block
nsURI.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1204 while (p && p != node_impl) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
p != node_implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1205 if (p->isElement() && p->nodeName() == tagname) {
p->isElement()Description
TRUEnever evaluated
FALSEnever evaluated
p->nodeName() == tagnameDescription
TRUEnever evaluated
FALSEnever evaluated
0
1206 list.append(p);-
1207 }
never executed: end of block
0
1208 if (p->first)
p->firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
1209 p = p->first;
never executed: p = p->first;
0
1210 else if (p->next)
p->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1211 p = p->next;
never executed: p = p->next;
0
1212 else {-
1213 p = p->parent();-
1214 while (p && p != node_impl && !p->next)
pDescription
TRUEnever evaluated
FALSEnever evaluated
p != node_implDescription
TRUEnever evaluated
FALSEnever evaluated
!p->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1215 p = p->parent();
never executed: p = p->parent();
0
1216 if (p && p != node_impl)
pDescription
TRUEnever evaluated
FALSEnever evaluated
p != node_implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1217 p = p->next;
never executed: p = p->next;
0
1218 }
never executed: end of block
0
1219 }-
1220 } else {
never executed: end of block
0
1221 while (p && p != node_impl) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
p != node_implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1222 if (p->isElement() && p->name==tagname && p->namespaceURI==nsURI) {
p->isElement()Description
TRUEnever evaluated
FALSEnever evaluated
p->name==tagnameDescription
TRUEnever evaluated
FALSEnever evaluated
p->namespaceURI==nsURIDescription
TRUEnever evaluated
FALSEnever evaluated
0
1223 list.append(p);-
1224 }
never executed: end of block
0
1225 if (p->first)
p->firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
1226 p = p->first;
never executed: p = p->first;
0
1227 else if (p->next)
p->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1228 p = p->next;
never executed: p = p->next;
0
1229 else {-
1230 p = p->parent();-
1231 while (p && p != node_impl && !p->next)
pDescription
TRUEnever evaluated
FALSEnever evaluated
p != node_implDescription
TRUEnever evaluated
FALSEnever evaluated
!p->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1232 p = p->parent();
never executed: p = p->parent();
0
1233 if (p && p != node_impl)
pDescription
TRUEnever evaluated
FALSEnever evaluated
p != node_implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1234 p = p->next;
never executed: p = p->next;
0
1235 }
never executed: end of block
0
1236 }-
1237 }
never executed: end of block
0
1238}-
1239-
1240QDomNodePrivate* QDomNodeListPrivate::item(int index)-
1241{-
1242 if (!node_impl)
!node_implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1243 return 0;
never executed: return 0;
0
1244-
1245 const QDomDocumentPrivate *const doc = node_impl->ownerDocument();-
1246 if (!doc || timestamp != doc->nodeListTime)
!docDescription
TRUEnever evaluated
FALSEnever evaluated
timestamp != doc->nodeListTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1247 createList();
never executed: createList();
0
1248-
1249 if (index >= list.size())
index >= list.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1250 return 0;
never executed: return 0;
0
1251-
1252 return list.at(index);
never executed: return list.at(index);
0
1253}-
1254-
1255int QDomNodeListPrivate::length() const-
1256{-
1257 if (!node_impl)
!node_implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1258 return 0;
never executed: return 0;
0
1259-
1260 const QDomDocumentPrivate *const doc = node_impl->ownerDocument();-
1261 if (!doc || timestamp != doc->nodeListTime) {
!docDescription
TRUEnever evaluated
FALSEnever evaluated
timestamp != doc->nodeListTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1262 QDomNodeListPrivate *that = const_cast<QDomNodeListPrivate *>(this);-
1263 that->createList();-
1264 }
never executed: end of block
0
1265-
1266 return list.count();
never executed: return list.count();
0
1267}-
1268-
1269/**************************************************************-
1270 *-
1271 * QDomNodeList-
1272 *-
1273 **************************************************************/-
1274-
1275/*!-
1276 \class QDomNodeList-
1277 \reentrant-
1278 \brief The QDomNodeList class is a list of QDomNode objects.-
1279-
1280 \inmodule QtXml-
1281 \ingroup xml-tools-
1282-
1283 Lists can be obtained by QDomDocument::elementsByTagName() and-
1284 QDomNode::childNodes(). The Document Object Model (DOM) requires-
1285 these lists to be "live": whenever you change the underlying-
1286 document, the contents of the list will get updated.-
1287-
1288 You can get a particular node from the list with item(). The-
1289 number of items in the list is returned by length().-
1290-
1291 For further information about the Document Object Model see-
1292 \l{http://www.w3.org/TR/REC-DOM-Level-1/}{Level 1} and-
1293 \l{http://www.w3.org/TR/DOM-Level-2-Core/}{Level 2 Core}.-
1294 For a more general introduction of the DOM implementation see the-
1295 QDomDocument documentation.-
1296-
1297 \sa QDomNode::childNodes(), QDomDocument::elementsByTagName()-
1298*/-
1299-
1300/*!-
1301 Creates an empty node list.-
1302*/-
1303QDomNodeList::QDomNodeList()-
1304{-
1305 impl = 0;-
1306}
never executed: end of block
0
1307-
1308QDomNodeList::QDomNodeList(QDomNodeListPrivate* p)-
1309{-
1310 impl = p;-
1311}
never executed: end of block
0
1312-
1313/*!-
1314 Constructs a copy of \a n.-
1315*/-
1316QDomNodeList::QDomNodeList(const QDomNodeList& n)-
1317{-
1318 impl = n.impl;-
1319 if (impl)
implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1320 impl->ref.ref();
never executed: impl->ref.ref();
0
1321}
never executed: end of block
0
1322-
1323/*!-
1324 Assigns \a n to this node list.-
1325*/-
1326QDomNodeList& QDomNodeList::operator=(const QDomNodeList &n)-
1327{-
1328 if (n.impl)
n.implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1329 n.impl->ref.ref();
never executed: n.impl->ref.ref();
0
1330 if (impl && !impl->ref.deref())
implDescription
TRUEnever evaluated
FALSEnever evaluated
!impl->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
1331 delete impl;
never executed: delete impl;
0
1332 impl = n.impl;-
1333 return *this;
never executed: return *this;
0
1334}-
1335-
1336/*!-
1337 Returns \c true if the node list \a n and this node list are equal;-
1338 otherwise returns \c false.-
1339*/-
1340bool QDomNodeList::operator==(const QDomNodeList &n) const-
1341{-
1342 if (impl == n.impl)
impl == n.implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1343 return true;
never executed: return true;
0
1344 if (!impl || !n.impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
!n.implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1345 return false;
never executed: return false;
0
1346 return (*impl == *n.impl);
never executed: return (*impl == *n.impl);
0
1347}-
1348-
1349/*!-
1350 Returns \c true the node list \a n and this node list are not equal;-
1351 otherwise returns \c false.-
1352*/-
1353bool QDomNodeList::operator!=(const QDomNodeList &n) const-
1354{-
1355 return !operator==(n);
never executed: return !operator==(n);
0
1356}-
1357-
1358/*!-
1359 Destroys the object and frees its resources.-
1360*/-
1361QDomNodeList::~QDomNodeList()-
1362{-
1363 if (impl && !impl->ref.deref())
implDescription
TRUEnever evaluated
FALSEnever evaluated
!impl->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
1364 delete impl;
never executed: delete impl;
0
1365}
never executed: end of block
0
1366-
1367/*!-
1368 Returns the node at position \a index.-
1369-
1370 If \a index is negative or if \a index >= length() then a null-
1371 node is returned (i.e. a node for which QDomNode::isNull() returns-
1372 true).-
1373-
1374 \sa length()-
1375*/-
1376QDomNode QDomNodeList::item(int index) const-
1377{-
1378 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1379 return QDomNode();
never executed: return QDomNode();
0
1380-
1381 return QDomNode(impl->item(index));
never executed: return QDomNode(impl->item(index));
0
1382}-
1383-
1384/*!-
1385 Returns the number of nodes in the list.-
1386*/-
1387int QDomNodeList::length() const-
1388{-
1389 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
1390 return 0;
never executed: return 0;
0
1391 return impl->length();
never executed: return impl->length();
0
1392}-
1393-
1394/*!-
1395 \fn bool QDomNodeList::isEmpty() const-
1396-
1397 Returns \c true if the list contains no items; otherwise returns \c false.-
1398 This function is provided for Qt API consistency.-
1399*/-
1400-
1401/*!-
1402 \fn int QDomNodeList::count() const-
1403-
1404 This function is provided for Qt API consistency. It is equivalent to length().-
1405*/-
1406-
1407/*!-
1408 \fn int QDomNodeList::size() const-
1409-
1410 This function is provided for Qt API consistency. It is equivalent to length().-
1411*/-
1412-
1413/*!-
1414 \fn QDomNode QDomNodeList::at(int index) const-
1415-
1416 This function is provided for Qt API consistency. It is equivalent-
1417 to item().-
1418-
1419 If \a index is negative or if \a index >= length() then a null-
1420 node is returned (i.e. a node for which QDomNode::isNull() returns-
1421 true).-
1422*/-
1423-
1424/**************************************************************-
1425 *-
1426 * QDomNodePrivate-
1427 *-
1428 **************************************************************/-
1429-
1430inline void QDomNodePrivate::setOwnerDocument(QDomDocumentPrivate *doc)-
1431{-
1432 ownerNode = doc;-
1433 hasParent = false;-
1434}
executed 1392 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
1392
1435-
1436QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) : ref(1)-
1437{-
1438 if (par)
parDescription
TRUEevaluated 2223 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1392 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
1392-2223
1439 setParent(par);
executed 2223 times by 5 tests: setParent(par);
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
2223
1440 else-
1441 setOwnerDocument(doc);
executed 1392 times by 5 tests: setOwnerDocument(doc);
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
1392
1442 prev = 0;-
1443 next = 0;-
1444 first = 0;-
1445 last = 0;-
1446 createdWithDom1Interface = true;-
1447 lineNumber = -1;-
1448 columnNumber = -1;-
1449}
executed 3615 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
3615
1450-
1451QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n, bool deep) : ref(1)-
1452{-
1453 setOwnerDocument(n->ownerDocument());-
1454 prev = 0;-
1455 next = 0;-
1456 first = 0;-
1457 last = 0;-
1458-
1459 name = n->name;-
1460 value = n->value;-
1461 prefix = n->prefix;-
1462 namespaceURI = n->namespaceURI;-
1463 createdWithDom1Interface = n->createdWithDom1Interface;-
1464 lineNumber = -1;-
1465 columnNumber = -1;-
1466-
1467 if (!deep)
!deepDescription
TRUEnever evaluated
FALSEnever evaluated
0
1468 return;
never executed: return;
0
1469-
1470 for (QDomNodePrivate* x = n->first; x; x = x->next)
xDescription
TRUEnever evaluated
FALSEnever evaluated
0
1471 appendChild(x->cloneNode(true));
never executed: appendChild(x->cloneNode(true));
0
1472}
never executed: end of block
0
1473-
1474QDomNodePrivate::~QDomNodePrivate()-
1475{-
1476 QDomNodePrivate* p = first;-
1477 QDomNodePrivate* n;-
1478-
1479 while (p) {
pDescription
TRUEevaluated 2015 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 3615 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
2015-3615
1480 n = p->next;-
1481 if (!p->ref.deref())
!p->ref.deref()Description
TRUEevaluated 2015 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
0-2015
1482 delete p;
executed 2015 times by 5 tests: delete p;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
2015
1483 else-
1484 p->setNoParent();
never executed: p->setNoParent();
0
1485 p = n;-
1486 }
executed 2015 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
2015
1487 first = 0;-
1488 last = 0;-
1489}
executed 3615 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
3615
1490-
1491void QDomNodePrivate::clear()-
1492{-
1493 QDomNodePrivate* p = first;-
1494 QDomNodePrivate* n;-
1495-
1496 while (p) {
pDescription
TRUEnever evaluated
FALSEevaluated 244 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
0-244
1497 n = p->next;-
1498 if (!p->ref.deref())
!p->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
1499 delete p;
never executed: delete p;
0
1500 p = n;-
1501 }
never executed: end of block
0
1502 first = 0;-
1503 last = 0;-
1504}
executed 244 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
244
1505-
1506QDomNodePrivate* QDomNodePrivate::namedItem(const QString &n)-
1507{-
1508 QDomNodePrivate* p = first;-
1509 while (p) {
pDescription
TRUEevaluated 51 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
FALSEnever evaluated
0-51
1510 if (p->nodeName() == n)
p->nodeName() == nDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
2-49
1511 return p;
executed 49 times by 1 test: return p;
Executed by:
  • tst_qcssparser - unknown status
49
1512 p = p->next;-
1513 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qcssparser - unknown status
2
1514 return 0;
never executed: return 0;
0
1515}-
1516-
1517-
1518QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild)-
1519{-
1520 // Error check-
1521 if (!newChild)
!newChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1522 return 0;
never executed: return 0;
0
1523-
1524 // Error check-
1525 if (newChild == refChild)
newChild == refChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1526 return 0;
never executed: return 0;
0
1527-
1528 // Error check-
1529 if (refChild && refChild->parent() != this)
refChildDescription
TRUEnever evaluated
FALSEnever evaluated
refChild->parent() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1530 return 0;
never executed: return 0;
0
1531-
1532 // "mark lists as dirty"-
1533 QDomDocumentPrivate *const doc = ownerDocument();-
1534 if(doc)
docDescription
TRUEnever evaluated
FALSEnever evaluated
0
1535 doc->nodeListTime++;
never executed: doc->nodeListTime++;
0
1536-
1537 // Special handling for inserting a fragment. We just insert-
1538 // all elements of the fragment instead of the fragment itself.-
1539 if (newChild->isDocumentFragment()) {
newChild->isDocumentFragment()Description
TRUEnever evaluated
FALSEnever evaluated
0
1540 // Fragment is empty ?-
1541 if (newChild->first == 0)
newChild->first == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1542 return newChild;
never executed: return newChild;
0
1543-
1544 // New parent-
1545 QDomNodePrivate* n = newChild->first;-
1546 while (n) {
nDescription
TRUEnever evaluated
FALSEnever evaluated
0
1547 n->setParent(this);-
1548 n = n->next;-
1549 }
never executed: end of block
0
1550-
1551 // Insert at the beginning ?-
1552 if (!refChild || refChild->prev == 0) {
!refChildDescription
TRUEnever evaluated
FALSEnever evaluated
refChild->prev == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1553 if (first)
firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
1554 first->prev = newChild->last;
never executed: first->prev = newChild->last;
0
1555 newChild->last->next = first;-
1556 if (!last)
!lastDescription
TRUEnever evaluated
FALSEnever evaluated
0
1557 last = newChild->last;
never executed: last = newChild->last;
0
1558 first = newChild->first;-
1559 } else {
never executed: end of block
0
1560 // Insert in the middle-
1561 newChild->last->next = refChild;-
1562 newChild->first->prev = refChild->prev;-
1563 refChild->prev->next = newChild->first;-
1564 refChild->prev = newChild->last;-
1565 }
never executed: end of block
0
1566-
1567 // No need to increase the reference since QDomDocumentFragment-
1568 // does not decrease the reference.-
1569-
1570 // Remove the nodes from the fragment-
1571 newChild->first = 0;-
1572 newChild->last = 0;-
1573 return newChild;
never executed: return newChild;
0
1574 }-
1575-
1576 // No more errors can occur now, so we take-
1577 // ownership of the node.-
1578 newChild->ref.ref();-
1579-
1580 if (newChild->parent())
newChild->parent()Description
TRUEnever evaluated
FALSEnever evaluated
0
1581 newChild->parent()->removeChild(newChild);
never executed: newChild->parent()->removeChild(newChild);
0
1582-
1583 newChild->setParent(this);-
1584-
1585 if (!refChild) {
!refChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1586 if (first)
firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
1587 first->prev = newChild;
never executed: first->prev = newChild;
0
1588 newChild->next = first;-
1589 if (!last)
!lastDescription
TRUEnever evaluated
FALSEnever evaluated
0
1590 last = newChild;
never executed: last = newChild;
0
1591 first = newChild;-
1592 return newChild;
never executed: return newChild;
0
1593 }-
1594-
1595 if (refChild->prev == 0) {
refChild->prev == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1596 if (first)
firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
1597 first->prev = newChild;
never executed: first->prev = newChild;
0
1598 newChild->next = first;-
1599 if (!last)
!lastDescription
TRUEnever evaluated
FALSEnever evaluated
0
1600 last = newChild;
never executed: last = newChild;
0
1601 first = newChild;-
1602 return newChild;
never executed: return newChild;
0
1603 }-
1604-
1605 newChild->next = refChild;-
1606 newChild->prev = refChild->prev;-
1607 refChild->prev->next = newChild;-
1608 refChild->prev = newChild;-
1609-
1610 return newChild;
never executed: return newChild;
0
1611}-
1612-
1613QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild)-
1614{-
1615 // Error check-
1616 if (!newChild)
!newChildDescription
TRUEnever evaluated
FALSEevaluated 2016 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
0-2016
1617 return 0;
never executed: return 0;
0
1618-
1619 // Error check-
1620 if (newChild == refChild)
newChild == refChildDescription
TRUEnever evaluated
FALSEevaluated 2016 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
0-2016
1621 return 0;
never executed: return 0;
0
1622-
1623 // Error check-
1624 if (refChild && refChild->parent() != this)
refChildDescription
TRUEnever evaluated
FALSEevaluated 2016 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
refChild->parent() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0-2016
1625 return 0;
never executed: return 0;
0
1626-
1627 // "mark lists as dirty"-
1628 QDomDocumentPrivate *const doc = ownerDocument();-
1629 if(doc)
docDescription
TRUEevaluated 2016 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
0-2016
1630 doc->nodeListTime++;
executed 2016 times by 5 tests: doc->nodeListTime++;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
2016
1631-
1632 // Special handling for inserting a fragment. We just insert-
1633 // all elements of the fragment instead of the fragment itself.-
1634 if (newChild->isDocumentFragment()) {
newChild->isDocumentFragment()Description
TRUEnever evaluated
FALSEevaluated 2016 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
0-2016
1635 // Fragment is empty ?-
1636 if (newChild->first == 0)
newChild->first == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1637 return newChild;
never executed: return newChild;
0
1638-
1639 // New parent-
1640 QDomNodePrivate* n = newChild->first;-
1641 while (n) {
nDescription
TRUEnever evaluated
FALSEnever evaluated
0
1642 n->setParent(this);-
1643 n = n->next;-
1644 }
never executed: end of block
0
1645-
1646 // Insert at the end-
1647 if (!refChild || refChild->next == 0) {
!refChildDescription
TRUEnever evaluated
FALSEnever evaluated
refChild->next == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1648 if (last)
lastDescription
TRUEnever evaluated
FALSEnever evaluated
0
1649 last->next = newChild->first;
never executed: last->next = newChild->first;
0
1650 newChild->first->prev = last;-
1651 if (!first)
!firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
1652 first = newChild->first;
never executed: first = newChild->first;
0
1653 last = newChild->last;-
1654 } else { // Insert in the middle
never executed: end of block
0
1655 newChild->first->prev = refChild;-
1656 newChild->last->next = refChild->next;-
1657 refChild->next->prev = newChild->last;-
1658 refChild->next = newChild->first;-
1659 }
never executed: end of block
0
1660-
1661 // No need to increase the reference since QDomDocumentFragment-
1662 // does not decrease the reference.-
1663-
1664 // Remove the nodes from the fragment-
1665 newChild->first = 0;-
1666 newChild->last = 0;-
1667 return newChild;
never executed: return newChild;
0
1668 }-
1669-
1670 // Release new node from its current parent-
1671 if (newChild->parent())
newChild->parent()Description
TRUEevaluated 868 times by 4 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1148 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
868-1148
1672 newChild->parent()->removeChild(newChild);
executed 868 times by 4 tests: newChild->parent()->removeChild(newChild);
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
868
1673-
1674 // No more errors can occur now, so we take-
1675 // ownership of the node-
1676 newChild->ref.ref();-
1677-
1678 newChild->setParent(this);-
1679-
1680 // Insert at the end-
1681 if (!refChild) {
!refChildDescription
TRUEevaluated 2016 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
0-2016
1682 if (last)
lastDescription
TRUEevaluated 267 times by 4 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
FALSEevaluated 1749 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
267-1749
1683 last->next = newChild;
executed 267 times by 4 tests: last->next = newChild;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
267
1684 newChild->prev = last;-
1685 if (!first)
!firstDescription
TRUEevaluated 1749 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 267 times by 4 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
267-1749
1686 first = newChild;
executed 1749 times by 5 tests: first = newChild;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
1749
1687 last = newChild;-
1688 return newChild;
executed 2016 times by 5 tests: return newChild;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
2016
1689 }-
1690-
1691 if (refChild->next == 0) {
refChild->next == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1692 if (last)
lastDescription
TRUEnever evaluated
FALSEnever evaluated
0
1693 last->next = newChild;
never executed: last->next = newChild;
0
1694 newChild->prev = last;-
1695 if (!first)
!firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
1696 first = newChild;
never executed: first = newChild;
0
1697 last = newChild;-
1698 return newChild;
never executed: return newChild;
0
1699 }-
1700-
1701 newChild->prev = refChild;-
1702 newChild->next = refChild->next;-
1703 refChild->next->prev = newChild;-
1704 refChild->next = newChild;-
1705-
1706 return newChild;
never executed: return newChild;
0
1707}-
1708-
1709QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild)-
1710{-
1711 if (!newChild || !oldChild)
!newChildDescription
TRUEnever evaluated
FALSEnever evaluated
!oldChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1712 return 0;
never executed: return 0;
0
1713 if (oldChild->parent() != this)
oldChild->parent() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1714 return 0;
never executed: return 0;
0
1715 if (newChild == oldChild)
newChild == oldChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1716 return 0;
never executed: return 0;
0
1717-
1718 // mark lists as dirty-
1719 QDomDocumentPrivate *const doc = ownerDocument();-
1720 if(doc)
docDescription
TRUEnever evaluated
FALSEnever evaluated
0
1721 doc->nodeListTime++;
never executed: doc->nodeListTime++;
0
1722-
1723 // Special handling for inserting a fragment. We just insert-
1724 // all elements of the fragment instead of the fragment itself.-
1725 if (newChild->isDocumentFragment()) {
newChild->isDocumentFragment()Description
TRUEnever evaluated
FALSEnever evaluated
0
1726 // Fragment is empty ?-
1727 if (newChild->first == 0)
newChild->first == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1728 return newChild;
never executed: return newChild;
0
1729-
1730 // New parent-
1731 QDomNodePrivate* n = newChild->first;-
1732 while (n) {
nDescription
TRUEnever evaluated
FALSEnever evaluated
0
1733 n->setParent(this);-
1734 n = n->next;-
1735 }
never executed: end of block
0
1736-
1737-
1738 if (oldChild->next)
oldChild->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1739 oldChild->next->prev = newChild->last;
never executed: oldChild->next->prev = newChild->last;
0
1740 if (oldChild->prev)
oldChild->prevDescription
TRUEnever evaluated
FALSEnever evaluated
0
1741 oldChild->prev->next = newChild->first;
never executed: oldChild->prev->next = newChild->first;
0
1742-
1743 newChild->last->next = oldChild->next;-
1744 newChild->first->prev = oldChild->prev;-
1745-
1746 if (first == oldChild)
first == oldChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1747 first = newChild->first;
never executed: first = newChild->first;
0
1748 if (last == oldChild)
last == oldChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1749 last = newChild->last;
never executed: last = newChild->last;
0
1750-
1751 oldChild->setNoParent();-
1752 oldChild->next = 0;-
1753 oldChild->prev = 0;-
1754-
1755 // No need to increase the reference since QDomDocumentFragment-
1756 // does not decrease the reference.-
1757-
1758 // Remove the nodes from the fragment-
1759 newChild->first = 0;-
1760 newChild->last = 0;-
1761-
1762 // We are no longer interested in the old node-
1763 if (oldChild)
oldChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1764 oldChild->ref.deref();
never executed: oldChild->ref.deref();
0
1765-
1766 return oldChild;
never executed: return oldChild;
0
1767 }-
1768-
1769 // No more errors can occur now, so we take-
1770 // ownership of the node-
1771 newChild->ref.ref();-
1772-
1773 // Release new node from its current parent-
1774 if (newChild->parent())
newChild->parent()Description
TRUEnever evaluated
FALSEnever evaluated
0
1775 newChild->parent()->removeChild(newChild);
never executed: newChild->parent()->removeChild(newChild);
0
1776-
1777 newChild->setParent(this);-
1778-
1779 if (oldChild->next)
oldChild->nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1780 oldChild->next->prev = newChild;
never executed: oldChild->next->prev = newChild;
0
1781 if (oldChild->prev)
oldChild->prevDescription
TRUEnever evaluated
FALSEnever evaluated
0
1782 oldChild->prev->next = newChild;
never executed: oldChild->prev->next = newChild;
0
1783-
1784 newChild->next = oldChild->next;-
1785 newChild->prev = oldChild->prev;-
1786-
1787 if (first == oldChild)
first == oldChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1788 first = newChild;
never executed: first = newChild;
0
1789 if (last == oldChild)
last == oldChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1790 last = newChild;
never executed: last = newChild;
0
1791-
1792 oldChild->setNoParent();-
1793 oldChild->next = 0;-
1794 oldChild->prev = 0;-
1795-
1796 // We are no longer interested in the old node-
1797 if (oldChild)
oldChildDescription
TRUEnever evaluated
FALSEnever evaluated
0
1798 oldChild->ref.deref();
never executed: oldChild->ref.deref();
0
1799-
1800 return oldChild;
never executed: return oldChild;
0
1801}-
1802-
1803QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild)-
1804{-
1805 // Error check-
1806 if (oldChild->parent() != this)
oldChild->parent() != thisDescription
TRUEnever evaluated
FALSEevaluated 869 times by 4 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
0-869
1807 return 0;
never executed: return 0;
0
1808-
1809 // "mark lists as dirty"-
1810 QDomDocumentPrivate *const doc = ownerDocument();-
1811 if(doc)
docDescription
TRUEevaluated 869 times by 4 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
0-869
1812 doc->nodeListTime++;
executed 869 times by 4 tests: doc->nodeListTime++;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
869
1813-
1814 // Perhaps oldChild was just created with "createElement" or that. In this case-
1815 // its parent is QDomDocument but it is not part of the documents child list.-
1816 if (oldChild->next == 0 && oldChild->prev == 0 && first != oldChild)
oldChild->next == 0Description
TRUEevaluated 869 times by 4 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
oldChild->prev == 0Description
TRUEevaluated 869 times by 4 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
first != oldChildDescription
TRUEevaluated 868 times by 4 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qtextdocument - unknown status
0-869
1817 return 0;
executed 868 times by 4 tests: return 0;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
868
1818-
1819 if (oldChild->next)
oldChild->nextDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qtextdocument - unknown status
0-1
1820 oldChild->next->prev = oldChild->prev;
never executed: oldChild->next->prev = oldChild->prev;
0
1821 if (oldChild->prev)
oldChild->prevDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qtextdocument - unknown status
0-1
1822 oldChild->prev->next = oldChild->next;
never executed: oldChild->prev->next = oldChild->next;
0
1823-
1824 if (last == oldChild)
last == oldChildDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qtextdocument - unknown status
FALSEnever evaluated
0-1
1825 last = oldChild->prev;
executed 1 time by 1 test: last = oldChild->prev;
Executed by:
  • tst_qtextdocument - unknown status
1
1826 if (first == oldChild)
first == oldChildDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qtextdocument - unknown status
FALSEnever evaluated
0-1
1827 first = oldChild->next;
executed 1 time by 1 test: first = oldChild->next;
Executed by:
  • tst_qtextdocument - unknown status
1
1828-
1829 oldChild->setNoParent();-
1830 oldChild->next = 0;-
1831 oldChild->prev = 0;-
1832-
1833 // We are no longer interested in the old node-
1834 oldChild->ref.deref();-
1835-
1836 return oldChild;
executed 1 time by 1 test: return oldChild;
Executed by:
  • tst_qtextdocument - unknown status
1
1837}-
1838-
1839QDomNodePrivate* QDomNodePrivate::appendChild(QDomNodePrivate* newChild)-
1840{-
1841 // No reference manipulation needed. Done in insertAfter.-
1842 return insertAfter(newChild, 0);
executed 2016 times by 5 tests: return insertAfter(newChild, 0);
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
2016
1843}-
1844-
1845QDomDocumentPrivate* QDomNodePrivate::ownerDocument()-
1846{-
1847 QDomNodePrivate* p = this;-
1848 while (p && !p->isDocument()) {
pDescription
TRUEevaluated 14282 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
!p->isDocument()Description
TRUEevaluated 10529 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 3753 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
0-14282
1849 if (!p->hasParent)
!p->hasParentDescription
TRUEnever evaluated
FALSEevaluated 10529 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
0-10529
1850 return (QDomDocumentPrivate*)p->ownerNode;
never executed: return (QDomDocumentPrivate*)p->ownerNode;
0
1851 p = p->parent();-
1852 }
executed 10529 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
10529
1853-
1854 return static_cast<QDomDocumentPrivate *>(p);
executed 3753 times by 5 tests: return static_cast<QDomDocumentPrivate *>(p);
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
3753
1855}-
1856-
1857QDomNodePrivate* QDomNodePrivate::cloneNode(bool deep)-
1858{-
1859 QDomNodePrivate* p = new QDomNodePrivate(this, deep);-
1860 // We are not interested in this node-
1861 p->ref.deref();-
1862 return p;
never executed: return p;
0
1863}-
1864-
1865static void qNormalizeNode(QDomNodePrivate* n)-
1866{-
1867 QDomNodePrivate* p = n->first;-
1868 QDomTextPrivate* t = 0;-
1869-
1870 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1871 if (p->isText()) {
p->isText()Description
TRUEnever evaluated
FALSEnever evaluated
0
1872 if (t) {
tDescription
TRUEnever evaluated
FALSEnever evaluated
0
1873 QDomNodePrivate* tmp = p->next;-
1874 t->appendData(p->nodeValue());-
1875 n->removeChild(p);-
1876 p = tmp;-
1877 } else {
never executed: end of block
0
1878 t = (QDomTextPrivate*)p;-
1879 p = p->next;-
1880 }
never executed: end of block
0
1881 } else {-
1882 p = p->next;-
1883 t = 0;-
1884 }
never executed: end of block
0
1885 }-
1886}
never executed: end of block
0
1887void QDomNodePrivate::normalize()-
1888{-
1889 // ### This one has moved from QDomElementPrivate to this position. It is-
1890 // not tested.-
1891 qNormalizeNode(this);-
1892}
never executed: end of block
0
1893-
1894/*! \internal-
1895 \a depth is used for indentation, it seems.-
1896 */-
1897void QDomNodePrivate::save(QTextStream& s, int depth, int indent) const-
1898{-
1899 const QDomNodePrivate* n = first;-
1900 while (n) {
nDescription
TRUEevaluated 160 times by 1 test
Evaluated by:
  • tst_qdbusxmlparser - unknown status
FALSEevaluated 94 times by 1 test
Evaluated by:
  • tst_qdbusxmlparser - unknown status
94-160
1901 n->save(s, depth, indent);-
1902 n = n->next;-
1903 }
executed 160 times by 1 test: end of block
Executed by:
  • tst_qdbusxmlparser - unknown status
160
1904}
executed 94 times by 1 test: end of block
Executed by:
  • tst_qdbusxmlparser - unknown status
94
1905-
1906void QDomNodePrivate::setLocation(int lineNumber, int columnNumber)-
1907{-
1908 this->lineNumber = lineNumber;-
1909 this->columnNumber = columnNumber;-
1910}
executed 1148 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
1148
1911-
1912/**************************************************************-
1913 *-
1914 * QDomNode-
1915 *-
1916 **************************************************************/-
1917-
1918#define IMPL ((QDomNodePrivate*)impl)-
1919-
1920/*!-
1921 \class QDomNode-
1922 \reentrant-
1923 \brief The QDomNode class is the base class for all the nodes in a DOM tree.-
1924-
1925 \inmodule QtXml-
1926 \ingroup xml-tools-
1927-
1928-
1929 Many functions in the DOM return a QDomNode.-
1930-
1931 You can find out the type of a node using isAttr(),-
1932 isCDATASection(), isDocumentFragment(), isDocument(),-
1933 isDocumentType(), isElement(), isEntityReference(), isText(),-
1934 isEntity(), isNotation(), isProcessingInstruction(),-
1935 isCharacterData() and isComment().-
1936-
1937 A QDomNode can be converted into one of its subclasses using-
1938 toAttr(), toCDATASection(), toDocumentFragment(), toDocument(),-
1939 toDocumentType(), toElement(), toEntityReference(), toText(),-
1940 toEntity(), toNotation(), toProcessingInstruction(),-
1941 toCharacterData() or toComment(). You can convert a node to a null-
1942 node with clear().-
1943-
1944 Copies of the QDomNode class share their data using explicit-
1945 sharing. This means that modifying one node will change all-
1946 copies. This is especially useful in combination with functions-
1947 which return a QDomNode, e.g. firstChild(). You can make an-
1948 independent (deep) copy of the node with cloneNode().-
1949-
1950 A QDomNode can be null, much like a null pointer. Creating a copy-
1951 of a null node results in another null node. It is not-
1952 possible to modify a null node, but it is possible to assign another,-
1953 possibly non-null node to it. In this case, the copy of the null node-
1954 will remain null. You can check if a QDomNode is null by calling isNull().-
1955 The empty constructor of a QDomNode (or any of the derived classes) creates-
1956 a null node.-
1957-
1958 Nodes are inserted with insertBefore(), insertAfter() or-
1959 appendChild(). You can replace one node with another using-
1960 replaceChild() and remove a node with removeChild().-
1961-
1962 To traverse nodes use firstChild() to get a node's first child (if-
1963 any), and nextSibling() to traverse. QDomNode also provides-
1964 lastChild(), previousSibling() and parentNode(). To find the first-
1965 child node with a particular node name use namedItem().-
1966-
1967 To find out if a node has children use hasChildNodes() and to get-
1968 a list of all of a node's children use childNodes().-
1969-
1970 The node's name and value (the meaning of which varies depending-
1971 on its type) is returned by nodeName() and nodeValue()-
1972 respectively. The node's type is returned by nodeType(). The-
1973 node's value can be set with setNodeValue().-
1974-
1975 The document to which the node belongs is returned by-
1976 ownerDocument().-
1977-
1978 Adjacent QDomText nodes can be merged into a single node with-
1979 normalize().-
1980-
1981 \l QDomElement nodes have attributes which can be retrieved with-
1982 attributes().-
1983-
1984 QDomElement and QDomAttr nodes can have namespaces which can be-
1985 retrieved with namespaceURI(). Their local name is retrieved with-
1986 localName(), and their prefix with prefix(). The prefix can be set-
1987 with setPrefix().-
1988-
1989 You can write the XML representation of the node to a text stream-
1990 with save().-
1991-
1992 The following example looks for the first element in an XML document and-
1993 prints the names of all the elements that are its direct children.-
1994-
1995 \snippet code/src_xml_dom_qdom.cpp 1-
1996-
1997 For further information about the Document Object Model see-
1998 \l{W3C DOM Level 1}{Level 1} and-
1999 \l{W3C DOM Level 2}{Level 2 Core}.-
2000 For a more general introduction of the DOM implementation see the-
2001 QDomDocument documentation.-
2002*/-
2003-
2004/*!-
2005 Constructs a \l{isNull()}{null} node.-
2006*/-
2007QDomNode::QDomNode()-
2008{-
2009 impl = 0;-
2010}
executed 247 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
247
2011-
2012/*!-
2013 Constructs a copy of \a n.-
2014-
2015 The data of the copy is shared (shallow copy): modifying one node-
2016 will also change the other. If you want to make a deep copy, use-
2017 cloneNode().-
2018*/-
2019QDomNode::QDomNode(const QDomNode &n)-
2020{-
2021 impl = n.impl;-
2022 if (impl)
implDescription
TRUEevaluated 193 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
FALSEnever evaluated
0-193
2023 impl->ref.ref();
executed 193 times by 1 test: impl->ref.ref();
Executed by:
  • tst_qcssparser - unknown status
193
2024}
executed 193 times by 1 test: end of block
Executed by:
  • tst_qcssparser - unknown status
193
2025-
2026/*! \internal-
2027 Constructs a new node for the data \a n.-
2028*/-
2029QDomNode::QDomNode(QDomNodePrivate *n)-
2030{-
2031 impl = n;-
2032 if (impl)
implDescription
TRUEevaluated 418 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
FALSEnever evaluated
0-418
2033 impl->ref.ref();
executed 418 times by 1 test: impl->ref.ref();
Executed by:
  • tst_qcssparser - unknown status
418
2034}
executed 418 times by 1 test: end of block
Executed by:
  • tst_qcssparser - unknown status
418
2035-
2036/*!-
2037 Assigns a copy of \a n to this DOM node.-
2038-
2039 The data of the copy is shared (shallow copy): modifying one node-
2040 will also change the other. If you want to make a deep copy, use-
2041 cloneNode().-
2042*/-
2043QDomNode& QDomNode::operator=(const QDomNode &n)-
2044{-
2045 if (n.impl)
n.implDescription
TRUEevaluated 71 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
FALSEnever evaluated
0-71
2046 n.impl->ref.ref();
executed 71 times by 1 test: n.impl->ref.ref();
Executed by:
  • tst_qcssparser - unknown status
71
2047 if (impl && !impl->ref.deref())
implDescription
TRUEevaluated 71 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
FALSEnever evaluated
!impl->ref.deref()Description
TRUEnever evaluated
FALSEevaluated 71 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
0-71
2048 delete impl;
never executed: delete impl;
0
2049 impl = n.impl;-
2050 return *this;
executed 71 times by 1 test: return *this;
Executed by:
  • tst_qcssparser - unknown status
71
2051}-
2052-
2053/*!-
2054 Returns \c true if \a n and this DOM node are equal; otherwise-
2055 returns \c false.-
2056-
2057 Any instance of QDomNode acts as a reference to an underlying data-
2058 structure in QDomDocument. The test for equality checks if the two-
2059 references point to the same underlying node. For example:-
2060-
2061 \snippet code/src_xml_dom_qdom.cpp 2-
2062-
2063 The two nodes (QDomElement is a QDomNode subclass) both refer to-
2064 the document's root element, and \c {element1 == element2} will-
2065 return true. On the other hand:-
2066-
2067 \snippet code/src_xml_dom_qdom.cpp 3-
2068-
2069 Even though both nodes are empty elements carrying the same name,-
2070 \c {element3 == element4} will return false because they refer to-
2071 two different nodes in the underlying data structure.-
2072*/-
2073bool QDomNode::operator== (const QDomNode& n) const-
2074{-
2075 return (impl == n.impl);
never executed: return (impl == n.impl);
0
2076}-
2077-
2078/*!-
2079 Returns \c true if \a n and this DOM node are not equal; otherwise-
2080 returns \c false.-
2081*/-
2082bool QDomNode::operator!= (const QDomNode& n) const-
2083{-
2084 return (impl != n.impl);
never executed: return (impl != n.impl);
0
2085}-
2086-
2087/*!-
2088 Destroys the object and frees its resources.-
2089*/-
2090QDomNode::~QDomNode()-
2091{-
2092 if (impl && !impl->ref.deref())
implDescription
TRUEevaluated 855 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
!impl->ref.deref()Description
TRUEevaluated 244 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 611 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
3-855
2093 delete impl;
executed 244 times by 5 tests: delete impl;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
244
2094}
executed 858 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
858
2095-
2096/*!-
2097 Returns the name of the node.-
2098-
2099 The meaning of the name depends on the subclass:-
2100-
2101 \table-
2102 \header \li Name \li Meaning-
2103 \row \li QDomAttr \li The name of the attribute-
2104 \row \li QDomCDATASection \li The string "#cdata-section"-
2105 \row \li QDomComment \li The string "#comment"-
2106 \row \li QDomDocument \li The string "#document"-
2107 \row \li QDomDocumentFragment \li The string "#document-fragment"-
2108 \row \li QDomDocumentType \li The name of the document type-
2109 \row \li QDomElement \li The tag name-
2110 \row \li QDomEntity \li The name of the entity-
2111 \row \li QDomEntityReference \li The name of the referenced entity-
2112 \row \li QDomNotation \li The name of the notation-
2113 \row \li QDomProcessingInstruction \li The target of the processing instruction-
2114 \row \li QDomText \li The string "#text"-
2115 \endtable-
2116-
2117 \b{Note:} This function does not take the presence of namespaces into account-
2118 when processing the names of element and attribute nodes. As a result, the-
2119 returned name can contain any namespace prefix that may be present.-
2120 To obtain the node name of an element or attribute, use localName(); to-
2121 obtain the namespace prefix, use namespaceURI().-
2122-
2123 \sa nodeValue()-
2124*/-
2125QString QDomNode::nodeName() const-
2126{-
2127 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
2128 return QString();
never executed: return QString();
0
2129-
2130 if (!IMPL->prefix.isEmpty())
!((QDomNodePri...efix.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2131 return IMPL->prefix + QLatin1Char(':') + IMPL->name;
never executed: return ((QDomNodePrivate*)impl)->prefix + QLatin1Char(':') + ((QDomNodePrivate*)impl)->name;
0
2132 return IMPL->name;
never executed: return ((QDomNodePrivate*)impl)->name;
0
2133}-
2134-
2135/*!-
2136 Returns the value of the node.-
2137-
2138 The meaning of the value depends on the subclass:-
2139 \table-
2140 \header \li Name \li Meaning-
2141 \row \li QDomAttr \li The attribute value-
2142 \row \li QDomCDATASection \li The content of the CDATA section-
2143 \row \li QDomComment \li The comment-
2144 \row \li QDomProcessingInstruction \li The data of the processing instruction-
2145 \row \li QDomText \li The text-
2146 \endtable-
2147-
2148 All the other subclasses do not have a node value and will return-
2149 an empty string.-
2150-
2151 \sa setNodeValue(), nodeName()-
2152*/-
2153QString QDomNode::nodeValue() const-
2154{-
2155 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
2156 return QString();
never executed: return QString();
0
2157 return IMPL->value;
never executed: return ((QDomNodePrivate*)impl)->value;
0
2158}-
2159-
2160/*!-
2161 Sets the node's value to \a v.-
2162-
2163 \sa nodeValue()-
2164*/-
2165void QDomNode::setNodeValue(const QString& v)-
2166{-
2167 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
2168 return;
never executed: return;
0
2169 IMPL->setNodeValue(v);-
2170}
never executed: end of block
0
2171-
2172/*!-
2173 \enum QDomNode::NodeType-
2174-
2175 This enum defines the type of the node:-
2176 \value ElementNode-
2177 \value AttributeNode-
2178 \value TextNode-
2179 \value CDATASectionNode-
2180 \value EntityReferenceNode-
2181 \value EntityNode-
2182 \value ProcessingInstructionNode-
2183 \value CommentNode-
2184 \value DocumentNode-
2185 \value DocumentTypeNode-
2186 \value DocumentFragmentNode-
2187 \value NotationNode-
2188 \value BaseNode A QDomNode object, i.e. not a QDomNode subclass.-
2189 \value CharacterDataNode-
2190*/-
2191-
2192/*!-
2193 Returns the type of the node.-
2194-
2195 \sa toAttr(), toCDATASection(), toDocumentFragment(),-
2196 toDocument(), toDocumentType(), toElement(), toEntityReference(),-
2197 toText(), toEntity(), toNotation(), toProcessingInstruction(),-
2198 toCharacterData(), toComment()-
2199*/-
2200QDomNode::NodeType QDomNode::nodeType() const-
2201{-
2202 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
2203 return QDomNode::BaseNode;
never executed: return QDomNode::BaseNode;
0
2204 return IMPL->nodeType();
never executed: return ((QDomNodePrivate*)impl)->nodeType();
0
2205}-
2206-
2207/*!-
2208 Returns the parent node. If this node has no parent, a null node-
2209 is returned (i.e. a node for which isNull() returns \c true).-
2210*/-
2211QDomNode QDomNode::parentNode() const-
2212{-
2213 if (!impl)
!implDescription
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
0-33
2214 return QDomNode();
never executed: return QDomNode();
0
2215 return QDomNode(IMPL->parent());
executed 33 times by 1 test: return QDomNode(((QDomNodePrivate*)impl)->parent());
Executed by:
  • tst_qcssparser - unknown status
33
2216}-
2217-
2218/*!-
2219 Returns a list of all direct child nodes.-
2220-
2221 Most often you will call this function on a QDomElement object.-
2222-
2223 For example, if the XML document looks like this:-
2224-
2225 \snippet code/src_xml_dom_qdom.cpp 4-
2226-
2227 Then the list of child nodes for the "body"-element will contain-
2228 the node created by the &lt;h1&gt; tag and the node created by the-
2229 &lt;p&gt; tag.-
2230-
2231 The nodes in the list are not copied; so changing the nodes in the-
2232 list will also change the children of this node.-
2233-
2234 \sa firstChild(), lastChild()-
2235*/-
2236QDomNodeList QDomNode::childNodes() const-
2237{-
2238 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
2239 return QDomNodeList();
never executed: return QDomNodeList();
0
2240 return QDomNodeList(new QDomNodeListPrivate(impl));
never executed: return QDomNodeList(new QDomNodeListPrivate(impl));
0
2241}-
2242-
2243/*!-
2244 Returns the first child of the node. If there is no child node, a-
2245 \l{isNull()}{null node} is returned. Changing the-
2246 returned node will also change the node in the document tree.-
2247-
2248 \sa lastChild(), childNodes()-
2249*/-
2250QDomNode QDomNode::firstChild() const-
2251{-
2252 if (!impl)
!implDescription
TRUEnever evaluated
FALSEevaluated 79 times by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
0-79
2253 return QDomNode();
never executed: return QDomNode();
0
2254 return QDomNode(IMPL->first);
executed 79 times by 1 test: return QDomNode(((QDomNodePrivate*)impl)->first);
Executed by:
  • tst_qcssparser - unknown status
79
2255}-
2256-
2257/*!-
2258 Returns the last child of the node. If there is no child node, a-
2259 \l{isNull()}{null node} is returned. Changing the-
2260 returned node will also change the node in the document tree.-
2261-
2262 \sa firstChild(), childNodes()-
2263*/-
2264QDomNode QDomNode::lastChild() const-
2265{-
2266 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
2267 return QDomNode();
never executed: return QDomNode();
0
2268 return QDomNode(IMPL->last);
never executed: return QDomNode(((QDomNodePrivate*)impl)->last);
0
2269}-
2270-
2271/*!-
2272 Returns the previous sibling in the document tree. Changing the-
2273 returned node will also change the node in the document tree.-
2274-
2275 For example, if you have XML like this:-
2276-
2277 \snippet code/src_xml_dom_qdom.cpp 5-
2278-
2279 and this QDomNode represents the &lt;p&gt; tag, previousSibling()-
2280 will return the node representing the &lt;h1&gt; tag.-
2281-
2282 \sa nextSibling()-
2283*/-
2284QDomNode QDomNode::previousSibling() const-
2285{-
2286 if (!impl)
!implDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qcssparser - unknown status
0-1
2287 return QDomNode();
never executed: return QDomNode();
0
2288 return QDomNode(IMPL->prev);
executed 1 time by 1 test: return QDomNode(((QDomNodePrivate*)impl)->prev);
Executed by:
  • tst_qcssparser - unknown status
1
2289}-
2290-
2291/*!-
2292 Returns the next sibling in the document tree. Changing the-
2293 returned node will also change the node in the document tree.-
2294-
2295 If you have XML like this:-
2296-
2297 \snippet code/src_xml_dom_qdom.cpp 6-
2298-
2299 and this QDomNode represents the <p> tag, nextSibling() will-
2300 return the node representing the <h2> tag.-
2301-
2302 \sa previousSibling()-
2303*/-
2304QDomNode QDomNode::nextSibling() const-
2305{-
2306 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
2307 return QDomNode();
never executed: return QDomNode();
0
2308 return QDomNode(IMPL->next);
never executed: return QDomNode(((QDomNodePrivate*)impl)->next);
0
2309}-
2310-
2311-
2312// ###### don't think this is part of the DOM and-
2313/*!-
2314 Returns a named node map of all attributes. Attributes are only-
2315 provided for \l{QDomElement}s.-
2316-
2317 Changing the attributes in the map will also change the attributes-
2318 of this QDomNode.-
2319*/-
2320QDomNamedNodeMap QDomNode::attributes() const-
2321{-
2322 if (!impl || !impl->isElement())
!implDescription
TRUEnever evaluated
FALSEnever evaluated
!impl->isElement()Description
TRUEnever evaluated
FALSEnever evaluated
0
2323 return QDomNamedNodeMap();
never executed: return QDomNamedNodeMap();
0
2324-
2325 return QDomNamedNodeMap(static_cast<QDomElementPrivate *>(impl)->attributes());
never executed: return QDomNamedNodeMap(static_cast<QDomElementPrivate *>(impl)->attributes());
0
2326}-
2327-
2328/*!-
2329 Returns the document to which this node belongs.-
2330*/-
2331QDomDocument QDomNode::ownerDocument() const-
2332{-
2333 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
2334 return QDomDocument();
never executed: return QDomDocument();
0
2335 return QDomDocument(IMPL->ownerDocument());
never executed: return QDomDocument(((QDomNodePrivate*)impl)->ownerDocument());
0
2336}-
2337-
2338/*!-
2339 Creates a deep (not shallow) copy of the QDomNode.-
2340-
2341 If \a deep is true, then the cloning is done recursively which-
2342 means that all the node's children are deep copied too. If \a deep-
2343 is false only the node itself is copied and the copy will have no-
2344 child nodes.-
2345*/-
2346QDomNode QDomNode::cloneNode(bool deep) const-
2347{-
2348 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
2349 return QDomNode();
never executed: return QDomNode();
0
2350 return QDomNode(IMPL->cloneNode(deep));
never executed: return QDomNode(((QDomNodePrivate*)impl)->cloneNode(deep));
0
2351}-
2352-
2353/*!-
2354 Calling normalize() on an element converts all its children into a-
2355 standard form. This means that adjacent QDomText objects will be-
2356 merged into a single text object (QDomCDATASection nodes are not-
2357 merged).-
2358*/-
2359void QDomNode::normalize()-
2360{-
2361 if (!impl)
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
2362 return;
never executed: return;
0
2363 IMPL->normalize();-
2364}
never executed: end of block
0
2365-
2366/*!