dom/qdom.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include <qplatformdefs.h> -
43#include <qdom.h> -
44#include "private/qxmlutils_p.h" -
45 -
46#ifndef QT_NO_DOM -
47 -
48#include <qatomic.h> -
49#include <qbuffer.h> -
50#include <qhash.h> -
51#include <qiodevice.h> -
52#include <qlist.h> -
53#include <qregexp.h> -
54#include <qtextcodec.h> -
55#include <qtextstream.h> -
56#include <qxml.h> -
57#include <qvariant.h> -
58#include <qmap.h> -
59#include <qshareddata.h> -
60#include <qdebug.h> -
61#include <stdio.h> -
62 -
63QT_BEGIN_NAMESPACE -
64 -
65/* -
66 ### old todo comments -- I don't know if they still apply... -
67 -
68 If the document dies, remove all pointers to it from children -
69 which can not be deleted at this time. -
70 -
71 If a node dies and has direct children which can not be deleted, -
72 then remove the pointer to the parent. -
73 -
74 createElement and friends create double reference counts. -
75*/ -
76 -
77/* ##### new TODOs: -
78 -
79 Remove emtpy emthods in the *Private classes -
80 -
81 Make a lot of the (mostly empty) methods in the public classes inline. -
82 Specially constructors assignment operators and comparison operators are candidates. -
83*/ -
84 -
85/* -
86 Reference counting: -
87 -
88 Some simple rules: -
89 1) If an intern object returns a pointer to another intern object -
90 then the reference count of the returned object is not increased. -
91 2) If an extern object is created and gets a pointer to some intern -
92 object, then the extern object increases the intern objects reference count. -
93 3) If an extern object is deleted, then it decreases the reference count -
94 on its associated intern object and deletes it if nobody else hold references -
95 on the intern object. -
96*/ -
97 -
98 -
99/* -
100 Helper to split a qualified name in the prefix and local name. -
101*/ -
102static void qt_split_namespace(QString& prefix, QString& name, const QString& qName, bool hasURI) -
103{ -
104 int i = qName.indexOf(QLatin1Char(':'));
executed (the execution status of this line is deduced): int i = qName.indexOf(QLatin1Char(':'));
-
105 if (i == -1) {
evaluated: i == -1
TRUEFALSE
yes
Evaluation Count:223
yes
Evaluation Count:194
194-223
106 if (hasURI)
evaluated: hasURI
TRUEFALSE
yes
Evaluation Count:171
yes
Evaluation Count:52
52-171
107 prefix = QLatin1String("");
executed: prefix = QLatin1String("");
Execution Count:171
171
108 else -
109 prefix.clear();
executed: prefix.clear();
Execution Count:52
52
110 name = qName;
executed (the execution status of this line is deduced): name = qName;
-
111 } else {
executed: }
Execution Count:223
223
112 prefix = qName.left(i);
executed (the execution status of this line is deduced): prefix = qName.left(i);
-
113 name = qName.mid(i + 1);
executed (the execution status of this line is deduced): name = qName.mid(i + 1);
-
114 }
executed: }
Execution Count:194
194
115} -
116 -
117/************************************************************** -
118 * -
119 * Private class declerations -
120 * -
121 **************************************************************/ -
122 -
123class QDomImplementationPrivate -
124{ -
125public: -
126 inline QDomImplementationPrivate() {} -
127 -
128 QDomImplementationPrivate* clone(); -
129 QAtomicInt ref; -
130 static QDomImplementation::InvalidDataPolicy invalidDataPolicy; -
131}; -
132 -
133class QDomNodePrivate -
134{ -
135public: -
136 QDomNodePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0); -
137 QDomNodePrivate(QDomNodePrivate* n, bool deep); -
138 virtual ~QDomNodePrivate(); -
139 -
140 QString nodeName() const { return name; }
executed: return name;
Execution Count:33732
33732
141 QString nodeValue() const { return value; }
executed: return value;
Execution Count:40
40
142 virtual void setNodeValue(const QString& v) { value = v; }
never executed: }
0
143 -
144 QDomDocumentPrivate* ownerDocument(); -
145 void setOwnerDocument(QDomDocumentPrivate* doc); -
146 -
147 virtual QDomNodePrivate* insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild); -
148 virtual QDomNodePrivate* insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild); -
149 virtual QDomNodePrivate* replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild); -
150 virtual QDomNodePrivate* removeChild(QDomNodePrivate* oldChild); -
151 virtual QDomNodePrivate* appendChild(QDomNodePrivate* newChild); -
152 -
153 QDomNodePrivate* namedItem(const QString& name); -
154 -
155 virtual QDomNodePrivate* cloneNode(bool deep = true); -
156 virtual void normalize(); -
157 virtual void clear(); -
158 -
159 inline QDomNodePrivate* parent() const { return hasParent ? ownerNode : 0; }
executed: return hasParent ? ownerNode : 0;
Execution Count:4157131
4157131
160 inline void setParent(QDomNodePrivate *p) { ownerNode = p; hasParent = true; }
executed: }
Execution Count:127721
127721
161 -
162 void setNoParent() { -
163 ownerNode = hasParent ? (QDomNodePrivate*)ownerDocument() : 0;
partially evaluated: hasParent
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-17
164 hasParent = false;
executed (the execution status of this line is deduced): hasParent = false;
-
165 }
executed: }
Execution Count:17
17
166 -
167 // Dynamic cast -
168 bool isAttr() const { return nodeType() == QDomNode::AttributeNode; }
executed: return nodeType() == QDomNode::AttributeNode;
Execution Count:1
1
169 bool isCDATASection() const { return nodeType() == QDomNode::CDATASectionNode; }
executed: return nodeType() == QDomNode::CDATASectionNode;
Execution Count:1
1
170 bool isDocumentFragment() const { return nodeType() == QDomNode::DocumentFragmentNode; }
executed: return nodeType() == QDomNode::DocumentFragmentNode;
Execution Count:93365
93365
171 bool isDocument() const { return nodeType() == QDomNode::DocumentNode; }
executed: return nodeType() == QDomNode::DocumentNode;
Execution Count:4500614
4500614
172 bool isDocumentType() const { return nodeType() == QDomNode::DocumentTypeNode; }
never executed: return nodeType() == QDomNode::DocumentTypeNode;
0
173 bool isElement() const { return nodeType() == QDomNode::ElementNode; }
executed: return nodeType() == QDomNode::ElementNode;
Execution Count:30723
30723
174 bool isEntityReference() const { return nodeType() == QDomNode::EntityReferenceNode; }
never executed: return nodeType() == QDomNode::EntityReferenceNode;
0
175 bool isText() const { const QDomNode::NodeType nt = nodeType();
executed (the execution status of this line is deduced): bool isText() const { const QDomNode::NodeType nt = nodeType();
-
176 return (nt == QDomNode::TextNode)
executed: return (nt == QDomNode::TextNode) || (nt == QDomNode::CDATASectionNode);
Execution Count:107741
107741
177 || (nt == QDomNode::CDATASectionNode); }
executed: return (nt == QDomNode::TextNode) || (nt == QDomNode::CDATASectionNode);
Execution Count:107741
107741
178 bool isEntity() const { return nodeType() == QDomNode::EntityNode; }
executed: return nodeType() == QDomNode::EntityNode;
Execution Count:16
16
179 bool isNotation() const { return nodeType() == QDomNode::NotationNode; }
executed: return nodeType() == QDomNode::NotationNode;
Execution Count:8
8
180 bool isProcessingInstruction() const { return nodeType() == QDomNode::ProcessingInstructionNode; }
executed: return nodeType() == QDomNode::ProcessingInstructionNode;
Execution Count:60748
60748
181 bool isCharacterData() const { const QDomNode::NodeType nt = nodeType();
never executed (the execution status of this line is deduced): bool isCharacterData() const { const QDomNode::NodeType nt = nodeType();
-
182 return (nt == QDomNode::CharacterDataNode)
never executed: return (nt == QDomNode::CharacterDataNode) || (nt == QDomNode::TextNode) || (nt == QDomNode::CommentNode);
0
183 || (nt == QDomNode::TextNode)
never executed: return (nt == QDomNode::CharacterDataNode) || (nt == QDomNode::TextNode) || (nt == QDomNode::CommentNode);
0
184 || (nt == QDomNode::CommentNode); }
never executed: return (nt == QDomNode::CharacterDataNode) || (nt == QDomNode::TextNode) || (nt == QDomNode::CommentNode);
0
185 bool isComment() const { return nodeType() == QDomNode::CommentNode; }
never executed: return nodeType() == QDomNode::CommentNode;
0
186 -
187 virtual QDomNode::NodeType nodeType() const { return QDomNode::BaseNode; }
executed: return QDomNode::BaseNode;
Execution Count:35
35
188 -
189 virtual void save(QTextStream&, int, int) const; -
190 -
191 void setLocation(int lineNumber, int columnNumber); -
192 -
193 // Variables -
194 QAtomicInt ref; -
195 QDomNodePrivate* prev; -
196 QDomNodePrivate* next; -
197 QDomNodePrivate* ownerNode; // either the node's parent or the node's owner document -
198 QDomNodePrivate* first; -
199 QDomNodePrivate* last; -
200 -
201 QString name; // this is the local name if prefix != null -
202 QString value; -
203 QString prefix; // set this only for ElementNode and AttributeNode -
204 QString namespaceURI; // set this only for ElementNode and AttributeNode -
205 bool createdWithDom1Interface : 1; -
206 bool hasParent : 1; -
207 -
208 int lineNumber; -
209 int columnNumber; -
210}; -
211 -
212class QDomNodeListPrivate -
213{ -
214public: -
215 QDomNodeListPrivate(QDomNodePrivate*); -
216 QDomNodeListPrivate(QDomNodePrivate*, const QString& ); -
217 QDomNodeListPrivate(QDomNodePrivate*, const QString&, const QString& ); -
218 ~QDomNodeListPrivate(); -
219 -
220 bool operator== (const QDomNodeListPrivate&) const; -
221 bool operator!= (const QDomNodeListPrivate&) const; -
222 -
223 void createList(); -
224 QDomNodePrivate* item(int index); -
225 int length() const; -
226 -
227 QAtomicInt ref; -
228 /* -
229 This list contains the children of this node. -
230 */ -
231 QDomNodePrivate* node_impl; -
232 QString tagname; -
233 QString nsURI; -
234 QList<QDomNodePrivate*> list; -
235 long timestamp; -
236}; -
237 -
238class QDomNamedNodeMapPrivate -
239{ -
240public: -
241 QDomNamedNodeMapPrivate(QDomNodePrivate*); -
242 ~QDomNamedNodeMapPrivate(); -
243 -
244 QDomNodePrivate* namedItem(const QString& name) const; -
245 QDomNodePrivate* namedItemNS(const QString& nsURI, const QString& localName) const; -
246 QDomNodePrivate* setNamedItem(QDomNodePrivate* arg); -
247 QDomNodePrivate* setNamedItemNS(QDomNodePrivate* arg); -
248 QDomNodePrivate* removeNamedItem(const QString& name); -
249 QDomNodePrivate* item(int index) const; -
250 int length() const; -
251 bool contains(const QString& name) const; -
252 bool containsNS(const QString& nsURI, const QString & localName) const; -
253 -
254 /** -
255 * Remove all children from the map. -
256 */ -
257 void clearMap(); -
258 bool isReadOnly() { return readonly; }
never executed: return readonly;
0
259 void setReadOnly(bool r) { readonly = r; }
never executed: }
0
260 bool isAppendToParent() { return appendToParent; }
never executed: return appendToParent;
0
261 /** -
262 * If true, then the node will redirect insert/remove calls -
263 * to its parent by calling QDomNodePrivate::appendChild or removeChild. -
264 * In addition the map won't increase or decrease the reference count -
265 * of the nodes it contains. -
266 * -
267 * By default this value is false and the map will handle reference counting -
268 * by itself. -
269 */ -
270 void setAppendToParent(bool b) { appendToParent = b; }
executed: }
Execution Count:1714
1714
271 -
272 /** -
273 * Creates a copy of the map. It is a deep copy -
274 * that means that all children are cloned. -
275 */ -
276 QDomNamedNodeMapPrivate* clone(QDomNodePrivate* parent); -
277 -
278 // Variables -
279 QAtomicInt ref; -
280 QHash<QString, QDomNodePrivate *> map; -
281 QDomNodePrivate* parent; -
282 bool readonly; -
283 bool appendToParent; -
284}; -
285 -
286class QDomDocumentTypePrivate : public QDomNodePrivate -
287{ -
288public: -
289 QDomDocumentTypePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0); -
290 QDomDocumentTypePrivate(QDomDocumentTypePrivate* n, bool deep); -
291 ~QDomDocumentTypePrivate(); -
292 void init(); -
293 -
294 // Reimplemented from QDomNodePrivate -
295 QDomNodePrivate* cloneNode(bool deep = true); -
296 QDomNodePrivate* insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild); -
297 QDomNodePrivate* insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild); -
298 QDomNodePrivate* replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild); -
299 QDomNodePrivate* removeChild(QDomNodePrivate* oldChild); -
300 QDomNodePrivate* appendChild(QDomNodePrivate* newChild); -
301 -
302 QDomNode::NodeType nodeType() const { return QDomNode::DocumentTypeNode; }
executed: return QDomNode::DocumentTypeNode;
Execution Count:11
11
303 -
304 void save(QTextStream& s, int, int) const; -
305 -
306 // Variables -
307 QDomNamedNodeMapPrivate* entities; -
308 QDomNamedNodeMapPrivate* notations; -
309 QString publicId; -
310 QString systemId; -
311 QString internalSubset; -
312}; -
313 -
314class QDomDocumentFragmentPrivate : public QDomNodePrivate -
315{ -
316public: -
317 QDomDocumentFragmentPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0); -
318 QDomDocumentFragmentPrivate(QDomNodePrivate* n, bool deep); -
319 -
320 // Reimplemented from QDomNodePrivate -
321 virtual QDomNodePrivate* cloneNode(bool deep = true); -
322 QDomNode::NodeType nodeType() const { return QDomNode::DocumentFragmentNode; }
executed: return QDomNode::DocumentFragmentNode;
Execution Count:36
36
323}; -
324 -
325class QDomCharacterDataPrivate : public QDomNodePrivate -
326{ -
327public: -
328 QDomCharacterDataPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& data); -
329 QDomCharacterDataPrivate(QDomCharacterDataPrivate* n, bool deep); -
330 -
331 int dataLength() const; -
332 QString substringData(unsigned long offset, unsigned long count) const; -
333 void appendData(const QString& arg); -
334 void insertData(unsigned long offset, const QString& arg); -
335 void deleteData(unsigned long offset, unsigned long count); -
336 void replaceData(unsigned long offset, unsigned long count, const QString& arg); -
337 -
338 // Reimplemented from QDomNodePrivate -
339 QDomNode::NodeType nodeType() const { return QDomNode::CharacterDataNode; }
never executed: return QDomNode::CharacterDataNode;
0
340 QDomNodePrivate* cloneNode(bool deep = true); -
341}; -
342 -
343class QDomTextPrivate : public QDomCharacterDataPrivate -
344{ -
345public: -
346 QDomTextPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val); -
347 QDomTextPrivate(QDomTextPrivate* n, bool deep); -
348 -
349 QDomTextPrivate* splitText(int offset); -
350 -
351 // Reimplemented from QDomNodePrivate -
352 QDomNodePrivate* cloneNode(bool deep = true); -
353 QDomNode::NodeType nodeType() const { return QDomNode::TextNode; }
executed: return QDomNode::TextNode;
Execution Count:339176
339176
354 virtual void save(QTextStream& s, int, int) const; -
355}; -
356 -
357class QDomAttrPrivate : public QDomNodePrivate -
358{ -
359public: -
360 QDomAttrPrivate(QDomDocumentPrivate*, QDomNodePrivate*, const QString& name); -
361 QDomAttrPrivate(QDomDocumentPrivate*, QDomNodePrivate*, const QString& nsURI, const QString& qName); -
362 QDomAttrPrivate(QDomAttrPrivate* n, bool deep); -
363 -
364 bool specified() const; -
365 -
366 // Reimplemented from QDomNodePrivate -
367 void setNodeValue(const QString& v); -
368 QDomNodePrivate* cloneNode(bool deep = true); -
369 QDomNode::NodeType nodeType() const { return QDomNode::AttributeNode; }
executed: return QDomNode::AttributeNode;
Execution Count:33591
33591
370 virtual void save(QTextStream& s, int, int) const; -
371 -
372 // Variables -
373 bool m_specified; -
374}; -
375 -
376class QDomElementPrivate : public QDomNodePrivate -
377{ -
378public: -
379 QDomElementPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name); -
380 QDomElementPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& nsURI, const QString& qName); -
381 QDomElementPrivate(QDomElementPrivate* n, bool deep); -
382 ~QDomElementPrivate(); -
383 -
384 QString attribute(const QString& name, const QString& defValue) const; -
385 QString attributeNS(const QString& nsURI, const QString& localName, const QString& defValue) const; -
386 void setAttribute(const QString& name, const QString& value); -
387 void setAttributeNS(const QString& nsURI, const QString& qName, const QString& newValue); -
388 void removeAttribute(const QString& name); -
389 QDomAttrPrivate* attributeNode(const QString& name); -
390 QDomAttrPrivate* attributeNodeNS(const QString& nsURI, const QString& localName); -
391 QDomAttrPrivate* setAttributeNode(QDomAttrPrivate* newAttr); -
392 QDomAttrPrivate* setAttributeNodeNS(QDomAttrPrivate* newAttr); -
393 QDomAttrPrivate* removeAttributeNode(QDomAttrPrivate* oldAttr); -
394 bool hasAttribute(const QString& name); -
395 bool hasAttributeNS(const QString& nsURI, const QString& localName); -
396 -
397 QString text(); -
398 -
399 // Reimplemented from QDomNodePrivate -
400 QDomNamedNodeMapPrivate* attributes() { return m_attr; }
executed: return m_attr;
Execution Count:11
11
401 bool hasAttributes() { return (m_attr->length() > 0); }
executed: return (m_attr->length() > 0);
Execution Count:9
9
402 QDomNode::NodeType nodeType() const { return QDomNode::ElementNode; }
executed: return QDomNode::ElementNode;
Execution Count:3961443
3961443
403 QDomNodePrivate* cloneNode(bool deep = true); -
404 virtual void save(QTextStream& s, int, int) const; -
405 -
406 // Variables -
407 QDomNamedNodeMapPrivate* m_attr; -
408}; -
409 -
410 -
411class QDomCommentPrivate : public QDomCharacterDataPrivate -
412{ -
413public: -
414 QDomCommentPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val); -
415 QDomCommentPrivate(QDomCommentPrivate* n, bool deep); -
416 -
417 // Reimplemented from QDomNodePrivate -
418 QDomNodePrivate* cloneNode(bool deep = true); -
419 QDomNode::NodeType nodeType() const { return QDomNode::CommentNode; }
executed: return QDomNode::CommentNode;
Execution Count:14491
14491
420 virtual void save(QTextStream& s, int, int) const; -
421}; -
422 -
423class QDomCDATASectionPrivate : public QDomTextPrivate -
424{ -
425public: -
426 QDomCDATASectionPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val); -
427 QDomCDATASectionPrivate(QDomCDATASectionPrivate* n, bool deep); -
428 -
429 // Reimplemented from QDomNodePrivate -
430 QDomNodePrivate* cloneNode(bool deep = true); -
431 QDomNode::NodeType nodeType() const { return QDomNode::CDATASectionNode; }
executed: return QDomNode::CDATASectionNode;
Execution Count:1735
1735
432 virtual void save(QTextStream& s, int, int) const; -
433}; -
434 -
435class QDomNotationPrivate : public QDomNodePrivate -
436{ -
437public: -
438 QDomNotationPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name, -
439 const QString& pub, const QString& sys); -
440 QDomNotationPrivate(QDomNotationPrivate* n, bool deep); -
441 -
442 // Reimplemented from QDomNodePrivate -
443 QDomNodePrivate* cloneNode(bool deep = true); -
444 QDomNode::NodeType nodeType() const { return QDomNode::NotationNode; }
executed: return QDomNode::NotationNode;
Execution Count:10
10
445 virtual void save(QTextStream& s, int, int) const; -
446 -
447 // Variables -
448 QString m_sys; -
449 QString m_pub; -
450}; -
451 -
452class QDomEntityPrivate : public QDomNodePrivate -
453{ -
454public: -
455 QDomEntityPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name, -
456 const QString& pub, const QString& sys, const QString& notation); -
457 QDomEntityPrivate(QDomEntityPrivate* n, bool deep); -
458 -
459 // Reimplemented from QDomNodePrivate -
460 QDomNodePrivate* cloneNode(bool deep = true); -
461 QDomNode::NodeType nodeType() const { return QDomNode::EntityNode; }
executed: return QDomNode::EntityNode;
Execution Count:26
26
462 virtual void save(QTextStream& s, int, int) const; -
463 -
464 // Variables -
465 QString m_sys; -
466 QString m_pub; -
467 QString m_notationName; -
468}; -
469 -
470class QDomEntityReferencePrivate : public QDomNodePrivate -
471{ -
472public: -
473 QDomEntityReferencePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name); -
474 QDomEntityReferencePrivate(QDomNodePrivate* n, bool deep); -
475 -
476 // Reimplemented from QDomNodePrivate -
477 QDomNodePrivate* cloneNode(bool deep = true); -
478 QDomNode::NodeType nodeType() const { return QDomNode::EntityReferenceNode; }
executed: return QDomNode::EntityReferenceNode;
Execution Count:38
38
479 virtual void save(QTextStream& s, int, int) const; -
480}; -
481 -
482class QDomProcessingInstructionPrivate : public QDomNodePrivate -
483{ -
484public: -
485 QDomProcessingInstructionPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& target, -
486 const QString& data); -
487 QDomProcessingInstructionPrivate(QDomProcessingInstructionPrivate* n, bool deep); -
488 -
489 // Reimplemented from QDomNodePrivate -
490 QDomNodePrivate* cloneNode(bool deep = true); -
491 QDomNode::NodeType nodeType() const { return QDomNode::ProcessingInstructionNode; }
executed: return QDomNode::ProcessingInstructionNode;
Execution Count:639
639
492 virtual void save(QTextStream& s, int, int) const; -
493}; -
494 -
495class QDomDocumentPrivate : public QDomNodePrivate -
496{ -
497public: -
498 QDomDocumentPrivate(); -
499 QDomDocumentPrivate(const QString& name); -
500 QDomDocumentPrivate(QDomDocumentTypePrivate* dt); -
501 QDomDocumentPrivate(QDomDocumentPrivate* n, bool deep); -
502 ~QDomDocumentPrivate(); -
503 -
504 bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn); -
505 bool setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn); -
506 -
507 // Attributes -
508 QDomDocumentTypePrivate* doctype() { return type.data(); }
executed: return type.data();
Execution Count:382
382
509 QDomImplementationPrivate* implementation() { return impl.data(); }
never executed: return impl.data();
0
510 QDomElementPrivate* documentElement(); -
511 -
512 // Factories -
513 QDomElementPrivate* createElement(const QString& tagName); -
514 QDomElementPrivate* createElementNS(const QString& nsURI, const QString& qName); -
515 QDomDocumentFragmentPrivate* createDocumentFragment(); -
516 QDomTextPrivate* createTextNode(const QString& data); -
517 QDomCommentPrivate* createComment(const QString& data); -
518 QDomCDATASectionPrivate* createCDATASection(const QString& data); -
519 QDomProcessingInstructionPrivate* createProcessingInstruction(const QString& target, const QString& data); -
520 QDomAttrPrivate* createAttribute(const QString& name); -
521 QDomAttrPrivate* createAttributeNS(const QString& nsURI, const QString& qName); -
522 QDomEntityReferencePrivate* createEntityReference(const QString& name); -
523 -
524 QDomNodePrivate* importNode(const QDomNodePrivate* importedNode, bool deep); -
525 -
526 // Reimplemented from QDomNodePrivate -
527 QDomNodePrivate* cloneNode(bool deep = true); -
528 QDomNode::NodeType nodeType() const { return QDomNode::DocumentNode; }
executed: return QDomNode::DocumentNode;
Execution Count:569241
569241
529 void clear(); -
530 -
531 // Variables -
532 QExplicitlySharedDataPointer<QDomImplementationPrivate> impl; -
533 QExplicitlySharedDataPointer<QDomDocumentTypePrivate> type; -
534 -
535 void saveDocument(QTextStream& stream, const int indent, QDomNode::EncodingPolicy encUsed) const; -
536 -
537 /* \internal -
538 Counter for the QDomNodeListPrivate timestamps. -
539 -
540 This is a cache optimization, that might in some cases be effective. The -
541 dilemma is that QDomNode::childNodes() returns a list, but the -
542 implementation stores the children in a linked list. Hence, in order to -
543 get the children out through childNodes(), a list must be populated each -
544 time, which is O(N). -
545 -
546 DOM has the requirement of node references being live, see DOM Core -
547 Level 3, 1.1.1 The DOM Structure Model, which means that changes to the -
548 underlying documents must be reflected in node lists. -
549 -
550 This mechanism, nodeListTime, is a caching optimization that reduces the -
551 amount of times the node list is rebuilt, by only doing so when the -
552 document actually changes. However, a change to anywhere in any document -
553 invalidate all lists, since no dependency tracking is done. -
554 -
555 It functions by that all modifying functions(insertBefore() and so on) -
556 increment the count; each QDomNodeListPrivate copies nodeListTime on -
557 construction, and compares its own value to nodeListTime in order to -
558 determine whether it needs to rebuild. -
559 -
560 This is reentrant. The nodeListTime may overflow, but that's ok since we -
561 check for equalness, not whether nodeListTime is smaller than the list's -
562 stored timestamp. -
563 */ -
564 long nodeListTime; -
565}; -
566 -
567/************************************************************** -
568 * -
569 * QDomHandler -
570 * -
571 **************************************************************/ -
572 -
573class QDomHandler : public QXmlDefaultHandler -
574{ -
575public: -
576 QDomHandler(QDomDocumentPrivate* d, bool namespaceProcessing); -
577 ~QDomHandler(); -
578 -
579 // content handler -
580 bool endDocument(); -
581 bool startElement(const QString& nsURI, const QString& localName, const QString& qName, const QXmlAttributes& atts); -
582 bool endElement(const QString& nsURI, const QString& localName, const QString& qName); -
583 bool characters(const QString& ch); -
584 bool processingInstruction(const QString& target, const QString& data); -
585 bool skippedEntity(const QString& name); -
586 -
587 // error handler -
588 bool fatalError(const QXmlParseException& exception); -
589 -
590 // lexical handler -
591 bool startCDATA(); -
592 bool endCDATA(); -
593 bool startEntity(const QString &); -
594 bool endEntity(const QString &); -
595 bool startDTD(const QString& name, const QString& publicId, const QString& systemId); -
596 bool comment(const QString& ch); -
597 -
598 // decl handler -
599 bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId) ; -
600 -
601 // DTD handler -
602 bool notationDecl(const QString & name, const QString & publicId, const QString & systemId); -
603 bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString &notationName) ; -
604 -
605 void setDocumentLocator(QXmlLocator *locator); -
606 -
607 QString errorMsg; -
608 int errorLine; -
609 int errorColumn; -
610 -
611private: -
612 QDomDocumentPrivate *doc; -
613 QDomNodePrivate *node; -
614 QString entityName; -
615 bool cdata; -
616 bool nsProcessing; -
617 QXmlLocator *locator; -
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;
executed (the execution status of this line is deduced): QString name, prefix;
-
633 if (namespaces)
evaluated: namespaces
TRUEFALSE
yes
Evaluation Count:238
yes
Evaluation Count:38162
238-38162
634 qt_split_namespace(prefix, name, _name, true);
executed: qt_split_namespace(prefix, name, _name, true);
Execution Count:238
238
635 else -
636 name = _name;
executed: name = _name;
Execution Count:38162
38162
637 -
638 if (name.isEmpty()) {
evaluated: name.isEmpty()
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:38348
52-38348
639 *ok = false;
executed (the execution status of this line is deduced): *ok = false;
-
640 return QString();
executed: return QString();
Execution Count:52
52
641 } -
642 -
643 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars
TRUEFALSE
yes
Evaluation Count:38187
yes
Evaluation Count:161
161-38187
644 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
645 return _name;
executed: return _name;
Execution Count:38187
38187
646 } -
647 -
648 QString result;
executed (the execution status of this line is deduced): QString result;
-
649 bool firstChar = true;
executed (the execution status of this line is deduced): bool firstChar = true;
-
650 for (int i = 0; i < name.size(); ++i) {
evaluated: i < name.size()
TRUEFALSE
yes
Evaluation Count:520
yes
Evaluation Count:128
128-520
651 QChar c = name.at(i);
executed (the execution status of this line is deduced): QChar c = name.at(i);
-
652 if (firstChar) {
evaluated: firstChar
TRUEFALSE
yes
Evaluation Count:207
yes
Evaluation Count:313
207-313
653 if (QXmlUtils::isLetter(c) || c.unicode() == '_' || c.unicode() == ':') {
evaluated: QXmlUtils::isLetter(c)
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:115
evaluated: c.unicode() == '_'
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:105
evaluated: c.unicode() == ':'
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:96
9-115
654 result.append(c);
executed (the execution status of this line is deduced): result.append(c);
-
655 firstChar = false;
executed (the execution status of this line is deduced): firstChar = false;
-
656 } else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
executed: }
Execution Count:111
evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:64
32-111
657 *ok = false;
executed (the execution status of this line is deduced): *ok = false;
-
658 return QString();
executed: return QString();
Execution Count:32
32
659 } -
660 } else { -
661 if (QXmlUtils::isNameChar(c))
evaluated: QXmlUtils::isNameChar(c)
TRUEFALSE
yes
Evaluation Count:297
yes
Evaluation Count:16
16-297
662 result.append(c);
executed: result.append(c);
Execution Count:297
297
663 else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:15
1-15
664 *ok = false;
executed (the execution status of this line is deduced): *ok = false;
-
665 return QString();
executed: return QString();
Execution Count:1
1
666 } -
667 } -
668 } -
669 -
670 if (result.isEmpty()) {
evaluated: result.isEmpty()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:110
18-110
671 *ok = false;
executed (the execution status of this line is deduced): *ok = false;
-
672 return QString();
executed: return QString();
Execution Count:18
18
673 } -
674 -
675 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
676 if (namespaces && !prefix.isEmpty())
evaluated: namespaces
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:61
evaluated: !prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:20
20-61
677 return prefix + QLatin1Char(':') + result;
executed: return prefix + QLatin1Char(':') + result;
Execution Count:29
29
678 return result;
executed: return result;
Execution Count:81
81
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) {
evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars
TRUEFALSE
yes
Evaluation Count:36351
yes
Evaluation Count:25
25-36351
687 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
688 return data;
executed: return data;
Execution Count:36351
36351
689 } -
690 -
691 QString result;
executed (the execution status of this line is deduced): QString result;
-
692 for (int i = 0; i < data.size(); ++i) {
evaluated: i < data.size()
TRUEFALSE
yes
Evaluation Count:316
yes
Evaluation Count:24
24-316
693 QChar c = data.at(i);
executed (the execution status of this line is deduced): QChar c = data.at(i);
-
694 if (QXmlUtils::isChar(c)) {
evaluated: QXmlUtils::isChar(c)
TRUEFALSE
yes
Evaluation Count:313
yes
Evaluation Count:3
3-313
695 result.append(c);
executed (the execution status of this line is deduced): result.append(c);
-
696 } else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
executed: }
Execution Count:313
evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-313
697 *ok = false;
executed (the execution status of this line is deduced): *ok = false;
-
698 return QString();
executed: return QString();
Execution Count:1
1
699 } -
700 } -
701 -
702 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
703 return result;
executed: return result;
Execution Count:24
24
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) {
evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars
TRUEFALSE
yes
Evaluation Count:1958
yes
Evaluation Count:4
4-1958
712 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
713 return data;
executed: return data;
Execution Count:1958
1958
714 } -
715 -
716 QString fixedData = fixedCharData(data, ok);
executed (the execution status of this line is deduced): QString fixedData = fixedCharData(data, ok);
-
717 if (!*ok)
partially evaluated: !*ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
718 return QString();
never executed: return QString();
0
719 -
720 for (;;) {
executed (the execution status of this line is deduced): for (;;) {
-
721 int idx = fixedData.indexOf(QLatin1String("--"));
executed (the execution status of this line is deduced): int idx = fixedData.indexOf(QLatin1String("--"));
-
722 if (idx == -1)
partially evaluated: idx == -1
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
723 break;
executed: break;
Execution Count:4
4
724 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
never evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode
0
725 *ok = false;
never executed (the execution status of this line is deduced): *ok = false;
-
726 return QString();
never executed: return QString();
0
727 } -
728 fixedData.remove(idx, 2);
never executed (the execution status of this line is deduced): fixedData.remove(idx, 2);
-
729 }
never executed: }
0
730 -
731 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
732 return fixedData;
executed: return fixedData;
Execution Count:4
4
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) {
evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars
TRUEFALSE
yes
Evaluation Count:202
yes
Evaluation Count:1
1-202
741 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
742 return data;
executed: return data;
Execution Count:202
202
743 } -
744 -
745 QString fixedData = fixedCharData(data, ok);
executed (the execution status of this line is deduced): QString fixedData = fixedCharData(data, ok);
-
746 if (!*ok)
partially evaluated: !*ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
747 return QString();
never executed: return QString();
0
748 -
749 for (;;) {
executed (the execution status of this line is deduced): for (;;) {
-
750 int idx = fixedData.indexOf(QLatin1String("]]>"));
executed (the execution status of this line is deduced): int idx = fixedData.indexOf(QLatin1String("]]>"));
-
751 if (idx == -1)
partially evaluated: idx == -1
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
752 break;
executed: break;
Execution Count:1
1
753 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
never evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode
0
754 *ok = false;
never executed (the execution status of this line is deduced): *ok = false;
-
755 return QString();
never executed: return QString();
0
756 } -
757 fixedData.remove(idx, 3);
never executed (the execution status of this line is deduced): fixedData.remove(idx, 3);
-
758 }
never executed: }
0
759 -
760 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
761 return fixedData;
executed: return fixedData;
Execution Count:1
1
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) {
evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars
TRUEFALSE
yes
Evaluation Count:145
yes
Evaluation Count:6
6-145
769 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
770 return data;
executed: return data;
Execution Count:145
145
771 } -
772 -
773 QString fixedData = fixedCharData(data, ok);
executed (the execution status of this line is deduced): QString fixedData = fixedCharData(data, ok);
-
774 if (!*ok)
partially evaluated: !*ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
775 return QString();
never executed: return QString();
0
776 -
777 for (;;) {
executed (the execution status of this line is deduced): for (;;) {
-
778 int idx = fixedData.indexOf(QLatin1String("?>"));
executed (the execution status of this line is deduced): int idx = fixedData.indexOf(QLatin1String("?>"));
-
779 if (idx == -1)
partially evaluated: idx == -1
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
780 break;
executed: break;
Execution Count:6
6
781 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
never evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode
0
782 *ok = false;
never executed (the execution status of this line is deduced): *ok = false;
-
783 return QString();
never executed: return QString();
0
784 } -
785 fixedData.remove(idx, 2);
never executed (the execution status of this line is deduced): fixedData.remove(idx, 2);
-
786 }
never executed: }
0
787 -
788 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
789 return fixedData;
executed: return fixedData;
Execution Count:6
6
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) {
evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
5
798 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
799 return data;
executed: return data;
Execution Count:5
5
800 } -
801 -
802 QString result;
never executed (the execution status of this line is deduced): QString result;
-
803 -
804 if(QXmlUtils::isPublicID(data))
partially evaluated: QXmlUtils::isPublicID(data)
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
805 result = data;
executed: result = data;
Execution Count:5
5
806 else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
never evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode
0
807 *ok = false;
never executed (the execution status of this line is deduced): *ok = false;
-
808 return QString();
never executed: return QString();
0
809 } -
810 -
811 if (result.indexOf(QLatin1Char('\'')) != -1
partially evaluated: result.indexOf(QLatin1Char('\'')) != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
812 && result.indexOf(QLatin1Char('"')) != -1) {
never evaluated: result.indexOf(QLatin1Char('"')) != -1
0
813 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
never evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode
0
814 *ok = false;
never executed (the execution status of this line is deduced): *ok = false;
-
815 return QString();
never executed: return QString();
0
816 } else { -
817 result.remove(QLatin1Char('\''));
never executed (the execution status of this line is deduced): result.remove(QLatin1Char('\''));
-
818 }
never executed: }
0
819 } -
820 -
821 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
822 return result;
executed: return result;
Execution Count:5
5
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) {
evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
5
831 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
832 return data;
executed: return data;
Execution Count:5
5
833 } -
834 -
835 QString result = data;
executed (the execution status of this line is deduced): QString result = data;
-
836 -
837 if (result.indexOf(QLatin1Char('\'')) != -1
partially evaluated: result.indexOf(QLatin1Char('\'')) != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
838 && result.indexOf(QLatin1Char('"')) != -1) {
never evaluated: result.indexOf(QLatin1Char('"')) != -1
0
839 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
never evaluated: QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode
0
840 *ok = false;
never executed (the execution status of this line is deduced): *ok = false;
-
841 return QString();
never executed: return QString();
0
842 } else { -
843 result.remove(QLatin1Char('\''));
never executed (the execution status of this line is deduced): result.remove(QLatin1Char('\''));
-
844 }
never executed: }
0
845 } -
846 -
847 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
848 return result;
executed: return result;
Execution Count:5
5
849} -
850 -
851/************************************************************** -
852 * -
853 * QDomImplementationPrivate -
854 * -
855 **************************************************************/ -
856 -
857QDomImplementationPrivate* QDomImplementationPrivate::clone() -
858{ -
859 return new QDomImplementationPrivate;
executed: return new QDomImplementationPrivate;
Execution Count:1
1
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;
executed (the execution status of this line is deduced): impl = 0;
-
907}
executed: }
Execution Count:19
19
908 -
909/*! -
910 Constructs a copy of \a x. -
911*/ -
912QDomImplementation::QDomImplementation(const QDomImplementation &x) -
913{ -
914 impl = x.impl;
never executed (the execution status of this line is deduced): impl = x.impl;
-
915 if (impl)
never evaluated: impl
0
916 impl->ref.ref();
never executed: impl->ref.ref();
0
917}
never executed: }
0
918 -
919QDomImplementation::QDomImplementation(QDomImplementationPrivate *p) -
920{ -
921 // We want to be co-owners, so increase the reference count -
922 impl = p;
never executed (the execution status of this line is deduced): impl = p;
-
923 if (impl)
never evaluated: impl
0
924 impl->ref.ref();
never executed: impl->ref.ref();
0
925}
never executed: }
0
926 -
927/*! -
928 Assigns \a x to this DOM implementation. -
929*/ -
930QDomImplementation& QDomImplementation::operator=(const QDomImplementation &x) -
931{ -
932 if (x.impl)
never evaluated: x.impl
0
933 x.impl->ref.ref();
never executed: x.impl->ref.ref();
0
934 if (impl && !impl->ref.deref())
never evaluated: impl
never evaluated: !impl->ref.deref()
0
935 delete impl;
never executed: delete impl;
0
936 impl = x.impl;
never executed (the execution status of this line is deduced): impl = x.impl;
-
937 return *this;
never executed: return *this;
0
938} -
939 -
940/*! -
941 Returns true if \a x and this DOM implementation object were -
942 created from the same QDomDocument; otherwise returns 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 true if \a x and this DOM implementation object were -
951 created from different QDomDocuments; otherwise returns 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())
partially evaluated: impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
never evaluated: !impl->ref.deref()
0-19
964 delete impl;
never executed: delete impl;
0
965}
executed: }
Execution Count:19
19
966 -
967/*! -
968 The function returns true if QDom implements the requested \a -
969 version of a \a feature; otherwise returns 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")) {
never evaluated: feature == QLatin1String("XML")
0
980 if (version.isEmpty() || version == QLatin1String("1.0")) {
never evaluated: version.isEmpty()
never evaluated: version == QLatin1String("1.0")
0
981 return true;
never executed: return true;
0
982 } -
983 }
never executed: }
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;
executed (the execution status of this line is deduced): bool ok;
-
1023 QString fixedName = fixedXmlName(qName, &ok, true);
executed (the execution status of this line is deduced): QString fixedName = fixedXmlName(qName, &ok, true);
-
1024 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:10
10-14
1025 return QDomDocumentType();
executed: return QDomDocumentType();
Execution Count:14
14
1026 -
1027 QString fixedPublicId = fixedPubidLiteral(publicId, &ok);
executed (the execution status of this line is deduced): QString fixedPublicId = fixedPubidLiteral(publicId, &ok);
-
1028 if (!ok)
partially evaluated: !ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1029 return QDomDocumentType();
never executed: return QDomDocumentType();
0
1030 -
1031 QString fixedSystemId = fixedSystemLiteral(systemId, &ok);
executed (the execution status of this line is deduced): QString fixedSystemId = fixedSystemLiteral(systemId, &ok);
-
1032 if (!ok)
partially evaluated: !ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1033 return QDomDocumentType();
never executed: return QDomDocumentType();
0
1034 -
1035 QDomDocumentTypePrivate *dt = new QDomDocumentTypePrivate(0);
executed (the execution status of this line is deduced): QDomDocumentTypePrivate *dt = new QDomDocumentTypePrivate(0);
-
1036 dt->name = fixedName;
executed (the execution status of this line is deduced): dt->name = fixedName;
-
1037 if (systemId.isNull()) {
partially evaluated: systemId.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1038 dt->publicId.clear();
never executed (the execution status of this line is deduced): dt->publicId.clear();
-
1039 dt->systemId.clear();
never executed (the execution status of this line is deduced): dt->systemId.clear();
-
1040 } else {
never executed: }
0
1041 dt->publicId = fixedPublicId;
executed (the execution status of this line is deduced): dt->publicId = fixedPublicId;
-
1042 dt->systemId = fixedSystemId;
executed (the execution status of this line is deduced): dt->systemId = fixedSystemId;
-
1043 }
executed: }
Execution Count:10
10
1044 dt->ref.deref();
executed (the execution status of this line is deduced): dt->ref.deref();
-
1045 return QDomDocumentType(dt);
executed: return QDomDocumentType(dt);
Execution Count:10
10
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);
executed (the execution status of this line is deduced): QDomDocument doc(doctype);
-
1056 QDomElement root = doc.createElementNS(nsURI, qName);
executed (the execution status of this line is deduced): QDomElement root = doc.createElementNS(nsURI, qName);
-
1057 if (root.isNull())
evaluated: root.isNull()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:14
14
1058 return QDomDocument();
executed: return QDomDocument();
Execution Count:14
14
1059 doc.appendChild(root);
executed (the execution status of this line is deduced): doc.appendChild(root);
-
1060 return doc;
executed: return doc;
Execution Count:14
14
1061} -
1062 -
1063/*! -
1064 Returns false if the object was created by -
1065 QDomDocument::implementation(); otherwise returns 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;
executed (the execution status of this line is deduced): QDomImplementationPrivate::invalidDataPolicy = policy;
-
1133}
executed: }
Execution Count:59
59
1134 -
1135/************************************************************** -
1136 * -
1137 * QDomNodeListPrivate -
1138 * -
1139 **************************************************************/ -
1140 -
1141QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl) : ref(1) -
1142{ -
1143 node_impl = n_impl;
executed (the execution status of this line is deduced): node_impl = n_impl;
-
1144 if (node_impl)
partially evaluated: node_impl
TRUEFALSE
yes
Evaluation Count:127242
no
Evaluation Count:0
0-127242
1145 node_impl->ref.ref();
executed: node_impl->ref.ref();
Execution Count:127242
127242
1146 timestamp = 0;
executed (the execution status of this line is deduced): timestamp = 0;
-
1147}
executed: }
Execution Count:127242
127242
1148 -
1149QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &name) : -
1150 ref(1) -
1151{ -
1152 node_impl = n_impl;
executed (the execution status of this line is deduced): node_impl = n_impl;
-
1153 if (node_impl)
partially evaluated: node_impl
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1154 node_impl->ref.ref();
executed: node_impl->ref.ref();
Execution Count:1
1
1155 tagname = name;
executed (the execution status of this line is deduced): tagname = name;
-
1156 timestamp = 0;
executed (the execution status of this line is deduced): timestamp = 0;
-
1157}
executed: }
Execution Count:1
1
1158 -
1159QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &_nsURI, const QString &localName) : -
1160 ref(1) -
1161{ -
1162 node_impl = n_impl;
never executed (the execution status of this line is deduced): node_impl = n_impl;
-
1163 if (node_impl)
never evaluated: node_impl
0
1164 node_impl->ref.ref();
never executed: node_impl->ref.ref();
0
1165 tagname = localName;
never executed (the execution status of this line is deduced): tagname = localName;
-
1166 nsURI = _nsURI;
never executed (the execution status of this line is deduced): nsURI = _nsURI;
-
1167 timestamp = 0;
never executed (the execution status of this line is deduced): timestamp = 0;
-
1168}
never executed: }
0
1169 -
1170QDomNodeListPrivate::~QDomNodeListPrivate() -
1171{ -
1172 if (node_impl && !node_impl->ref.deref())
partially evaluated: node_impl
TRUEFALSE
yes
Evaluation Count:127243
no
Evaluation Count:0
partially evaluated: !node_impl->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127243
0-127243
1173 delete node_impl;
never executed: delete node_impl;
0
1174}
executed: }
Execution Count:127243
127243
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)
partially evaluated: !node_impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127244
0-127244
1189 return;
never executed: return;
0
1190 -
1191 const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
executed (the execution status of this line is deduced): const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
-
1192 if (doc && timestamp != doc->nodeListTime)
partially evaluated: doc
TRUEFALSE
yes
Evaluation Count:127244
no
Evaluation Count:0
partially evaluated: timestamp != doc->nodeListTime
TRUEFALSE
yes
Evaluation Count:127244
no
Evaluation Count:0
0-127244
1193 timestamp = doc->nodeListTime;
executed: timestamp = doc->nodeListTime;
Execution Count:127244
127244
1194 -
1195 QDomNodePrivate* p = node_impl->first;
executed (the execution status of this line is deduced): QDomNodePrivate* p = node_impl->first;
-
1196 -
1197 list.clear();
executed (the execution status of this line is deduced): list.clear();
-
1198 if (tagname.isNull()) {
evaluated: tagname.isNull()
TRUEFALSE
yes
Evaluation Count:127243
yes
Evaluation Count:1
1-127243
1199 while (p) {
evaluated: p
TRUEFALSE
yes
Evaluation Count:127189
yes
Evaluation Count:127243
127189-127243
1200 list.append(p);
executed (the execution status of this line is deduced): list.append(p);
-
1201 p = p->next;
executed (the execution status of this line is deduced): p = p->next;
-
1202 }
executed: }
Execution Count:127189
127189
1203 } else if (nsURI.isNull()) {
executed: }
Execution Count:127243
partially evaluated: nsURI.isNull()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-127243
1204 while (p && p != node_impl) {
partially evaluated: p
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
evaluated: p != node_impl
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
0-2
1205 if (p->isElement() && p->nodeName() == tagname) {
partially evaluated: p->isElement()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: p->nodeName() == tagname
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1206 list.append(p);
executed (the execution status of this line is deduced): list.append(p);
-
1207 }
executed: }
Execution Count:1
1
1208 if (p->first)
partially evaluated: p->first
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1209 p = p->first;
never executed: p = p->first;
0
1210 else if (p->next)
partially evaluated: p->next
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1211 p = p->next;
never executed: p = p->next;
0
1212 else { -
1213 p = p->parent();
executed (the execution status of this line is deduced): p = p->parent();
-
1214 while (p && p != node_impl && !p->next)
partially evaluated: p
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: p != node_impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: !p->next
0-1
1215 p = p->parent();
never executed: p = p->parent();
0
1216 if (p && p != node_impl)
partially evaluated: p
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: p != node_impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1217 p = p->next;
never executed: p = p->next;
0
1218 }
executed: }
Execution Count:1
1
1219 } -
1220 } else {
executed: }
Execution Count:1
1
1221 while (p && p != node_impl) {
never evaluated: p
never evaluated: p != node_impl
0
1222 if (p->isElement() && p->name==tagname && p->namespaceURI==nsURI) {
never evaluated: p->isElement()
never evaluated: p->name==tagname
never evaluated: p->namespaceURI==nsURI
0
1223 list.append(p);
never executed (the execution status of this line is deduced): list.append(p);
-
1224 }
never executed: }
0
1225 if (p->first)
never evaluated: p->first
0
1226 p = p->first;
never executed: p = p->first;
0
1227 else if (p->next)
never evaluated: p->next
0
1228 p = p->next;
never executed: p = p->next;
0
1229 else { -
1230 p = p->parent();
never executed (the execution status of this line is deduced): p = p->parent();
-
1231 while (p && p != node_impl && !p->next)
never evaluated: p
never evaluated: p != node_impl
never evaluated: !p->next
0
1232 p = p->parent();
never executed: p = p->parent();
0
1233 if (p && p != node_impl)
never evaluated: p
never evaluated: p != node_impl
0
1234 p = p->next;
never executed: p = p->next;
0
1235 }
never executed: }
0
1236 } -
1237 }
never executed: }
0
1238} -
1239 -
1240QDomNodePrivate* QDomNodeListPrivate::item(int index) -
1241{ -
1242 if (!node_impl)
partially evaluated: !node_impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:187306
0-187306
1243 return 0;
never executed: return 0;
0
1244 -
1245 const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
executed (the execution status of this line is deduced): const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
-
1246 if (!doc || timestamp != doc->nodeListTime)
partially evaluated: !doc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:187306
evaluated: timestamp != doc->nodeListTime
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:187273
0-187306
1247 createList();
executed: createList();
Execution Count:33
33
1248 -
1249 if (index >= list.size())
evaluated: index >= list.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:187305
1-187305
1250 return 0;
executed: return 0;
Execution Count:1
1
1251 -
1252 return list.at(index);
executed: return list.at(index);
Execution Count:187305
187305
1253} -
1254 -
1255int QDomNodeListPrivate::length() const -
1256{ -
1257 if (!node_impl)
partially evaluated: !node_impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127233
0-127233
1258 return 0;
never executed: return 0;
0
1259 -
1260 const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
executed (the execution status of this line is deduced): const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
-
1261 if (!doc || timestamp != doc->nodeListTime) {
partially evaluated: !doc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127233
evaluated: timestamp != doc->nodeListTime
TRUEFALSE
yes
Evaluation Count:127211
yes
Evaluation Count:22
0-127233
1262 QDomNodeListPrivate *that = const_cast<QDomNodeListPrivate *>(this);
executed (the execution status of this line is deduced): QDomNodeListPrivate *that = const_cast<QDomNodeListPrivate *>(this);
-
1263 that->createList();
executed (the execution status of this line is deduced): that->createList();
-
1264 }
executed: }
Execution Count:127211
127211
1265 -
1266 return list.count();
executed: return list.count();
Execution Count:127233
127233
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;
never executed (the execution status of this line is deduced): impl = 0;
-
1306}
never executed: }
0
1307 -
1308QDomNodeList::QDomNodeList(QDomNodeListPrivate* p) -
1309{ -
1310 impl = p;
executed (the execution status of this line is deduced): impl = p;
-
1311}
executed: }
Execution Count:127243
127243
1312 -
1313/*! -
1314 Constructs a copy of \a n. -
1315*/ -
1316QDomNodeList::QDomNodeList(const QDomNodeList& n) -
1317{ -
1318 impl = n.impl;
never executed (the execution status of this line is deduced): impl = n.impl;
-
1319 if (impl)
never evaluated: impl
0
1320 impl->ref.ref();
never executed: impl->ref.ref();
0
1321}
never executed: }
0
1322 -
1323/*! -
1324 Assigns \a n to this node list. -
1325*/ -
1326QDomNodeList& QDomNodeList::operator=(const QDomNodeList &n) -
1327{ -
1328 if (n.impl)
never evaluated: n.impl
0
1329 n.impl->ref.ref();
never executed: n.impl->ref.ref();
0
1330 if (impl && !impl->ref.deref())
never evaluated: impl
never evaluated: !impl->ref.deref()
0
1331 delete impl;
never executed: delete impl;
0
1332 impl = n.impl;
never executed (the execution status of this line is deduced): impl = n.impl;
-
1333 return *this;
never executed: return *this;
0
1334} -
1335 -
1336/*! -
1337 Returns true if the node list \a n and this node list are equal; -
1338 otherwise returns false. -
1339*/ -
1340bool QDomNodeList::operator==(const QDomNodeList &n) const -
1341{ -
1342 if (impl == n.impl)
never evaluated: impl == n.impl
0
1343 return true;
never executed: return true;
0
1344 if (!impl || !n.impl)
never evaluated: !impl
never evaluated: !n.impl
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 true the node list \a n and this node list are not equal; -
1351 otherwise returns 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())
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:127243
no
Evaluation Count:0
partially evaluated: !impl->ref.deref()
TRUEFALSE
yes
Evaluation Count:127243
no
Evaluation Count:0
0-127243
1364 delete impl;
executed: delete impl;
Execution Count:127243
127243
1365}
executed: }
Execution Count:127243
127243
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)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:187306
0-187306
1379 return QDomNode();
never executed: return QDomNode();
0
1380 -
1381 return QDomNode(impl->item(index));
executed: return QDomNode(impl->item(index));
Execution Count:187306
187306
1382} -
1383 -
1384/*! -
1385 Returns the number of nodes in the list. -
1386*/ -
1387int QDomNodeList::length() const -
1388{ -
1389 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127233
0-127233
1390 return 0;
never executed: return 0;
0
1391 return impl->length();
executed: return impl->length();
Execution Count:127233
127233
1392} -
1393 -
1394/*! -
1395 \fn bool QDomNodeList::isEmpty() const -
1396 -
1397 Returns true if the list contains no items; otherwise returns 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;
executed (the execution status of this line is deduced): ownerNode = doc;
-
1433 hasParent = false;
executed (the execution status of this line is deduced): hasParent = false;
-
1434}
executed: }
Execution Count:77503
77503
1435 -
1436QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) : ref(1) -
1437{ -
1438 if (par)
evaluated: par
TRUEFALSE
yes
Evaluation Count:34353
yes
Evaluation Count:77324
34353-77324
1439 setParent(par);
executed: setParent(par);
Execution Count:34353
34353
1440 else -
1441 setOwnerDocument(doc);
executed: setOwnerDocument(doc);
Execution Count:77324
77324
1442 prev = 0;
executed (the execution status of this line is deduced): prev = 0;
-
1443 next = 0;
executed (the execution status of this line is deduced): next = 0;
-
1444 first = 0;
executed (the execution status of this line is deduced): first = 0;
-
1445 last = 0;
executed (the execution status of this line is deduced): last = 0;
-
1446 createdWithDom1Interface = true;
executed (the execution status of this line is deduced): createdWithDom1Interface = true;
-
1447 lineNumber = -1;
executed (the execution status of this line is deduced): lineNumber = -1;
-
1448 columnNumber = -1;
executed (the execution status of this line is deduced): columnNumber = -1;
-
1449}
executed: }
Execution Count:111677
111677
1450 -
1451QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n, bool deep) : ref(1) -
1452{ -
1453 setOwnerDocument(n->ownerDocument());
executed (the execution status of this line is deduced): setOwnerDocument(n->ownerDocument());
-
1454 prev = 0;
executed (the execution status of this line is deduced): prev = 0;
-
1455 next = 0;
executed (the execution status of this line is deduced): next = 0;
-
1456 first = 0;
executed (the execution status of this line is deduced): first = 0;
-
1457 last = 0;
executed (the execution status of this line is deduced): last = 0;
-
1458 -
1459 name = n->name;
executed (the execution status of this line is deduced): name = n->name;
-
1460 value = n->value;
executed (the execution status of this line is deduced): value = n->value;
-
1461 prefix = n->prefix;
executed (the execution status of this line is deduced): prefix = n->prefix;
-
1462 namespaceURI = n->namespaceURI;
executed (the execution status of this line is deduced): namespaceURI = n->namespaceURI;
-
1463 createdWithDom1Interface = n->createdWithDom1Interface;
executed (the execution status of this line is deduced): createdWithDom1Interface = n->createdWithDom1Interface;
-
1464 lineNumber = -1;
executed (the execution status of this line is deduced): lineNumber = -1;
-
1465 columnNumber = -1;
executed (the execution status of this line is deduced): columnNumber = -1;
-
1466 -
1467 if (!deep)
evaluated: !deep
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:81
37-81
1468 return;
executed: return;
Execution Count:37
37
1469 -
1470 for (QDomNodePrivate* x = n->first; x; x = x->next)
evaluated: x
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:81
35-81
1471 appendChild(x->cloneNode(true));
executed: appendChild(x->cloneNode(true));
Execution Count:35
35
1472}
executed: }
Execution Count:81
81
1473 -
1474QDomNodePrivate::~QDomNodePrivate() -
1475{ -
1476 QDomNodePrivate* p = first;
executed (the execution status of this line is deduced): QDomNodePrivate* p = first;
-
1477 QDomNodePrivate* n;
executed (the execution status of this line is deduced): QDomNodePrivate* n;
-
1478 -
1479 while (p) {
evaluated: p
TRUEFALSE
yes
Evaluation Count:93348
yes
Evaluation Count:111795
93348-111795
1480 n = p->next;
executed (the execution status of this line is deduced): n = p->next;
-
1481 if (!p->ref.deref())
partially evaluated: !p->ref.deref()
TRUEFALSE
yes
Evaluation Count:93348
no
Evaluation Count:0
0-93348
1482 delete p;
executed: delete p;
Execution Count:93348
93348
1483 else -
1484 p->setNoParent();
never executed: p->setNoParent();
0
1485 p = n;
executed (the execution status of this line is deduced): p = n;
-
1486 }
executed: }
Execution Count:93348
93348
1487 first = 0;
executed (the execution status of this line is deduced): first = 0;
-
1488 last = 0;
executed (the execution status of this line is deduced): last = 0;
-
1489}
executed: }
Execution Count:111795
111795
1490 -
1491void QDomNodePrivate::clear() -
1492{ -
1493 QDomNodePrivate* p = first;
executed (the execution status of this line is deduced): QDomNodePrivate* p = first;
-
1494 QDomNodePrivate* n;
executed (the execution status of this line is deduced): QDomNodePrivate* n;
-
1495 -
1496 while (p) {
partially evaluated: p
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:385
0-385
1497 n = p->next;
never executed (the execution status of this line is deduced): n = p->next;
-
1498 if (!p->ref.deref())
never evaluated: !p->ref.deref()
0
1499 delete p;
never executed: delete p;
0
1500 p = n;
never executed (the execution status of this line is deduced): p = n;
-
1501 }
never executed: }
0
1502 first = 0;
executed (the execution status of this line is deduced): first = 0;
-
1503 last = 0;
executed (the execution status of this line is deduced): last = 0;
-
1504}
executed: }
Execution Count:385
385
1505 -
1506QDomNodePrivate* QDomNodePrivate::namedItem(const QString &n) -
1507{ -
1508 QDomNodePrivate* p = first;
executed (the execution status of this line is deduced): QDomNodePrivate* p = first;
-
1509 while (p) {
partially evaluated: p
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-15
1510 if (p->nodeName() == n)
evaluated: p->nodeName() == n
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:5
5-10
1511 return p;
executed: return p;
Execution Count:10
10
1512 p = p->next;
executed (the execution status of this line is deduced): p = p->next;
-
1513 }
executed: }
Execution Count:5
5
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)
never evaluated: !newChild
0
1522 return 0;
never executed: return 0;
0
1523 -
1524 // Error check -
1525 if (newChild == refChild)
never evaluated: newChild == refChild
0
1526 return 0;
never executed: return 0;
0
1527 -
1528 // Error check -
1529 if (refChild && refChild->parent() != this)
never evaluated: refChild
never evaluated: refChild->parent() != this
0
1530 return 0;
never executed: return 0;
0
1531 -
1532 // "mark lists as dirty" -
1533 QDomDocumentPrivate *const doc = ownerDocument();
never executed (the execution status of this line is deduced): QDomDocumentPrivate *const doc = ownerDocument();
-
1534 if(doc)
never evaluated: doc
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()) {
never evaluated: newChild->isDocumentFragment()
0
1540 // Fragment is empty ? -
1541 if (newChild->first == 0)
never evaluated: newChild->first == 0
0
1542 return newChild;
never executed: return newChild;
0
1543 -
1544 // New parent -
1545 QDomNodePrivate* n = newChild->first;
never executed (the execution status of this line is deduced): QDomNodePrivate* n = newChild->first;
-
1546 while (n) {
never evaluated: n
0
1547 n->setParent(this);
never executed (the execution status of this line is deduced): n->setParent(this);
-
1548 n = n->next;
never executed (the execution status of this line is deduced): n = n->next;
-
1549 }
never executed: }
0
1550 -
1551 // Insert at the beginning ? -
1552 if (!refChild || refChild->prev == 0) {
never evaluated: !refChild
never evaluated: refChild->prev == 0
0
1553 if (first)
never evaluated: first
0
1554 first->prev = newChild->last;
never executed: first->prev = newChild->last;
0
1555 newChild->last->next = first;
never executed (the execution status of this line is deduced): newChild->last->next = first;
-
1556 if (!last)
never evaluated: !last
0
1557 last = newChild->last;
never executed: last = newChild->last;
0
1558 first = newChild->first;
never executed (the execution status of this line is deduced): first = newChild->first;
-
1559 } else {
never executed: }
0
1560 // Insert in the middle -
1561 newChild->last->next = refChild;
never executed (the execution status of this line is deduced): newChild->last->next = refChild;
-
1562 newChild->first->prev = refChild->prev;
never executed (the execution status of this line is deduced): newChild->first->prev = refChild->prev;
-
1563 refChild->prev->next = newChild->first;
never executed (the execution status of this line is deduced): refChild->prev->next = newChild->first;
-
1564 refChild->prev = newChild->last;
never executed (the execution status of this line is deduced): refChild->prev = newChild->last;
-
1565 }
never executed: }
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;
never executed (the execution status of this line is deduced): newChild->first = 0;
-
1572 newChild->last = 0;
never executed (the execution status of this line is deduced): 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();
never executed (the execution status of this line is deduced): newChild->ref.ref();
-
1579 -
1580 if (newChild->parent())
never evaluated: newChild->parent()
0
1581 newChild->parent()->removeChild(newChild);
never executed: newChild->parent()->removeChild(newChild);
0
1582 -
1583 newChild->setParent(this);
never executed (the execution status of this line is deduced): newChild->setParent(this);
-
1584 -
1585 if (!refChild) {
never evaluated: !refChild
0
1586 if (first)
never evaluated: first
0
1587 first->prev = newChild;
never executed: first->prev = newChild;
0
1588 newChild->next = first;
never executed (the execution status of this line is deduced): newChild->next = first;
-
1589 if (!last)
never evaluated: !last
0
1590 last = newChild;
never executed: last = newChild;
0
1591 first = newChild;
never executed (the execution status of this line is deduced): first = newChild;
-
1592 return newChild;
never executed: return newChild;
0
1593 } -
1594 -
1595 if (refChild->prev == 0) {
never evaluated: refChild->prev == 0
0
1596 if (first)
never evaluated: first
0
1597 first->prev = newChild;
never executed: first->prev = newChild;
0
1598 newChild->next = first;
never executed (the execution status of this line is deduced): newChild->next = first;
-
1599 if (!last)
never evaluated: !last
0
1600 last = newChild;
never executed: last = newChild;
0
1601 first = newChild;
never executed (the execution status of this line is deduced): first = newChild;
-
1602 return newChild;
never executed: return newChild;
0
1603 } -
1604 -
1605 newChild->next = refChild;
never executed (the execution status of this line is deduced): newChild->next = refChild;
-
1606 newChild->prev = refChild->prev;
never executed (the execution status of this line is deduced): newChild->prev = refChild->prev;
-
1607 refChild->prev->next = newChild;
never executed (the execution status of this line is deduced): refChild->prev->next = newChild;
-
1608 refChild->prev = newChild;
never executed (the execution status of this line is deduced): 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)
partially evaluated: !newChild
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:93353
0-93353
1617 return 0;
never executed: return 0;
0
1618 -
1619 // Error check -
1620 if (newChild == refChild)
partially evaluated: newChild == refChild
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:93353
0-93353
1621 return 0;
never executed: return 0;
0
1622 -
1623 // Error check -
1624 if (refChild && refChild->parent() != this)
partially evaluated: refChild
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:93353
never evaluated: refChild->parent() != this
0-93353
1625 return 0;
never executed: return 0;
0
1626 -
1627 // "mark lists as dirty" -
1628 QDomDocumentPrivate *const doc = ownerDocument();
executed (the execution status of this line is deduced): QDomDocumentPrivate *const doc = ownerDocument();
-
1629 if(doc)
partially evaluated: doc
TRUEFALSE
yes
Evaluation Count:93353
no
Evaluation Count:0
0-93353
1630 doc->nodeListTime++;
executed: doc->nodeListTime++;
Execution Count:93353
93353
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()) {
partially evaluated: newChild->isDocumentFragment()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:93353
0-93353
1635 // Fragment is empty ? -
1636 if (newChild->first == 0)
never evaluated: newChild->first == 0
0
1637 return newChild;
never executed: return newChild;
0
1638 -
1639 // New parent -
1640 QDomNodePrivate* n = newChild->first;
never executed (the execution status of this line is deduced): QDomNodePrivate* n = newChild->first;
-
1641 while (n) {
never evaluated: n
0
1642 n->setParent(this);
never executed (the execution status of this line is deduced): n->setParent(this);
-
1643 n = n->next;
never executed (the execution status of this line is deduced): n = n->next;
-
1644 }
never executed: }
0
1645 -
1646 // Insert at the end -
1647 if (!refChild || refChild->next == 0) {
never evaluated: !refChild
never evaluated: refChild->next == 0
0
1648 if (last)
never evaluated: last
0
1649 last->next = newChild->first;
never executed: last->next = newChild->first;
0
1650 newChild->first->prev = last;
never executed (the execution status of this line is deduced): newChild->first->prev = last;
-
1651 if (!first)
never evaluated: !first
0
1652 first = newChild->first;
never executed: first = newChild->first;
0
1653 last = newChild->last;
never executed (the execution status of this line is deduced): last = newChild->last;
-
1654 } else { // Insert in the middle
never executed: }
0
1655 newChild->first->prev = refChild;
never executed (the execution status of this line is deduced): newChild->first->prev = refChild;
-
1656 newChild->last->next = refChild->next;
never executed (the execution status of this line is deduced): newChild->last->next = refChild->next;
-
1657 refChild->next->prev = newChild->last;
never executed (the execution status of this line is deduced): refChild->next->prev = newChild->last;
-
1658 refChild->next = newChild->first;
never executed (the execution status of this line is deduced): refChild->next = newChild->first;
-
1659 }
never executed: }
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;
never executed (the execution status of this line is deduced): newChild->first = 0;
-
1666 newChild->last = 0;
never executed (the execution status of this line is deduced): 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())
evaluated: newChild->parent()
TRUEFALSE
yes
Evaluation Count:16756
yes
Evaluation Count:76597
16756-76597
1672 newChild->parent()->removeChild(newChild);
executed: newChild->parent()->removeChild(newChild);
Execution Count:16756
16756
1673 -
1674 // No more errors can occur now, so we take -
1675 // ownership of the node -
1676 newChild->ref.ref();
executed (the execution status of this line is deduced): newChild->ref.ref();
-
1677 -
1678 newChild->setParent(this);
executed (the execution status of this line is deduced): newChild->setParent(this);
-
1679 -
1680 // Insert at the end -
1681 if (!refChild) {
partially evaluated: !refChild
TRUEFALSE
yes
Evaluation Count:93353
no
Evaluation Count:0
0-93353
1682 if (last)
evaluated: last
TRUEFALSE
yes
Evaluation Count:39928
yes
Evaluation Count:53425
39928-53425
1683 last->next = newChild;
executed: last->next = newChild;
Execution Count:39928
39928
1684 newChild->prev = last;
executed (the execution status of this line is deduced): newChild->prev = last;
-
1685 if (!first)
evaluated: !first
TRUEFALSE
yes
Evaluation Count:53425
yes
Evaluation Count:39928
39928-53425
1686 first = newChild;
executed: first = newChild;
Execution Count:53425
53425
1687 last = newChild;
executed (the execution status of this line is deduced): last = newChild;
-
1688 return newChild;
executed: return newChild;
Execution Count:93353
93353
1689 } -
1690 -
1691 if (refChild->next == 0) {
never evaluated: refChild->next == 0
0
1692 if (last)
never evaluated: last
0
1693 last->next = newChild;
never executed: last->next = newChild;
0
1694 newChild->prev = last;
never executed (the execution status of this line is deduced): newChild->prev = last;
-
1695 if (!first)
never evaluated: !first
0
1696 first = newChild;
never executed: first = newChild;
0
1697 last = newChild;
never executed (the execution status of this line is deduced): last = newChild;
-
1698 return newChild;
never executed: return newChild;
0
1699 } -
1700 -
1701 newChild->prev = refChild;
never executed (the execution status of this line is deduced): newChild->prev = refChild;
-
1702 newChild->next = refChild->next;
never executed (the execution status of this line is deduced): newChild->next = refChild->next;
-
1703 refChild->next->prev = newChild;
never executed (the execution status of this line is deduced): refChild->next->prev = newChild;
-
1704 refChild->next = newChild;
never executed (the execution status of this line is deduced): 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)
partially evaluated: !newChild
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
partially evaluated: !oldChild
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1712 return 0;
never executed: return 0;
0
1713 if (oldChild->parent() != this)
partially evaluated: oldChild->parent() != this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1714 return 0;
never executed: return 0;
0
1715 if (newChild == oldChild)
partially evaluated: newChild == oldChild
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1716 return 0;
never executed: return 0;
0
1717 -
1718 // mark lists as dirty -
1719 QDomDocumentPrivate *const doc = ownerDocument();
executed (the execution status of this line is deduced): QDomDocumentPrivate *const doc = ownerDocument();
-
1720 if(doc)
partially evaluated: doc
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
1721 doc->nodeListTime++;
executed: doc->nodeListTime++;
Execution Count:12
12
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()) {
partially evaluated: newChild->isDocumentFragment()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1726 // Fragment is empty ? -
1727 if (newChild->first == 0)
never evaluated: newChild->first == 0
0
1728 return newChild;
never executed: return newChild;
0
1729 -
1730 // New parent -
1731 QDomNodePrivate* n = newChild->first;
never executed (the execution status of this line is deduced): QDomNodePrivate* n = newChild->first;
-
1732 while (n) {
never evaluated: n
0
1733 n->setParent(this);
never executed (the execution status of this line is deduced): n->setParent(this);
-
1734 n = n->next;
never executed (the execution status of this line is deduced): n = n->next;
-
1735 }
never executed: }
0
1736 -
1737 -
1738 if (oldChild->next)
never evaluated: oldChild->next
0
1739 oldChild->next->prev = newChild->last;
never executed: oldChild->next->prev = newChild->last;
0
1740 if (oldChild->prev)
never evaluated: oldChild->prev
0
1741 oldChild->prev->next = newChild->first;
never executed: oldChild->prev->next = newChild->first;
0
1742 -
1743 newChild->last->next = oldChild->next;
never executed (the execution status of this line is deduced): newChild->last->next = oldChild->next;
-
1744 newChild->first->prev = oldChild->prev;
never executed (the execution status of this line is deduced): newChild->first->prev = oldChild->prev;
-
1745 -
1746 if (first == oldChild)
never evaluated: first == oldChild
0
1747 first = newChild->first;
never executed: first = newChild->first;
0
1748 if (last == oldChild)
never evaluated: last == oldChild
0
1749 last = newChild->last;
never executed: last = newChild->last;
0
1750 -
1751 oldChild->setNoParent();
never executed (the execution status of this line is deduced): oldChild->setNoParent();
-
1752 oldChild->next = 0;
never executed (the execution status of this line is deduced): oldChild->next = 0;
-
1753 oldChild->prev = 0;
never executed (the execution status of this line is deduced): 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;
never executed (the execution status of this line is deduced): newChild->first = 0;
-
1760 newChild->last = 0;
never executed (the execution status of this line is deduced): newChild->last = 0;
-
1761 -
1762 // We are no longer interested in the old node -
1763 if (oldChild)
never evaluated: oldChild
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();
executed (the execution status of this line is deduced): newChild->ref.ref();
-
1772 -
1773 // Release new node from its current parent -
1774 if (newChild->parent())
partially evaluated: newChild->parent()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1775 newChild->parent()->removeChild(newChild);
never executed: newChild->parent()->removeChild(newChild);
0
1776 -
1777 newChild->setParent(this);
executed (the execution status of this line is deduced): newChild->setParent(this);
-
1778 -
1779 if (oldChild->next)
evaluated: oldChild->next
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:4
4-8
1780 oldChild->next->prev = newChild;
executed: oldChild->next->prev = newChild;
Execution Count:8
8
1781 if (oldChild->prev)
evaluated: oldChild->prev
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:8
4-8
1782 oldChild->prev->next = newChild;
executed: oldChild->prev->next = newChild;
Execution Count:4
4
1783 -
1784 newChild->next = oldChild->next;
executed (the execution status of this line is deduced): newChild->next = oldChild->next;
-
1785 newChild->prev = oldChild->prev;
executed (the execution status of this line is deduced): newChild->prev = oldChild->prev;
-
1786 -
1787 if (first == oldChild)
evaluated: first == oldChild
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:4
4-8
1788 first = newChild;
executed: first = newChild;
Execution Count:8
8
1789 if (last == oldChild)
evaluated: last == oldChild
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:8
4-8
1790 last = newChild;
executed: last = newChild;
Execution Count:4
4
1791 -
1792 oldChild->setNoParent();
executed (the execution status of this line is deduced): oldChild->setNoParent();
-
1793 oldChild->next = 0;
executed (the execution status of this line is deduced): oldChild->next = 0;
-
1794 oldChild->prev = 0;
executed (the execution status of this line is deduced): oldChild->prev = 0;
-
1795 -
1796 // We are no longer interested in the old node -
1797 if (oldChild)
partially evaluated: oldChild
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
1798 oldChild->ref.deref();
executed: oldChild->ref.deref();
Execution Count:12
12
1799 -
1800 return oldChild;
executed: return oldChild;
Execution Count:12
12
1801} -
1802 -
1803QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) -
1804{ -
1805 // Error check -
1806 if (oldChild->parent() != this)
partially evaluated: oldChild->parent() != this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16760
0-16760
1807 return 0;
never executed: return 0;
0
1808 -
1809 // "mark lists as dirty" -
1810 QDomDocumentPrivate *const doc = ownerDocument();
executed (the execution status of this line is deduced): QDomDocumentPrivate *const doc = ownerDocument();
-
1811 if(doc)
partially evaluated: doc
TRUEFALSE
yes
Evaluation Count:16760
no
Evaluation Count:0
0-16760
1812 doc->nodeListTime++;
executed: doc->nodeListTime++;
Execution Count:16760
16760
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)
evaluated: oldChild->next == 0
TRUEFALSE
yes
Evaluation Count:16759
yes
Evaluation Count:1
partially evaluated: oldChild->prev == 0
TRUEFALSE
yes
Evaluation Count:16759
no
Evaluation Count:0
evaluated: first != oldChild
TRUEFALSE
yes
Evaluation Count:16755
yes
Evaluation Count:4
0-16759
1817 return 0;
executed: return 0;
Execution Count:16755
16755
1818 -
1819 if (oldChild->next)
evaluated: oldChild->next
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
1820 oldChild->next->prev = oldChild->prev;
executed: oldChild->next->prev = oldChild->prev;
Execution Count:1
1
1821 if (oldChild->prev)
partially evaluated: oldChild->prev
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1822 oldChild->prev->next = oldChild->next;
never executed: oldChild->prev->next = oldChild->next;
0
1823 -
1824 if (last == oldChild)
evaluated: last == oldChild
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
1825 last = oldChild->prev;
executed: last = oldChild->prev;
Execution Count:4
4
1826 if (first == oldChild)
partially evaluated: first == oldChild
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1827 first = oldChild->next;
executed: first = oldChild->next;
Execution Count:5
5
1828 -
1829 oldChild->setNoParent();
executed (the execution status of this line is deduced): oldChild->setNoParent();
-
1830 oldChild->next = 0;
executed (the execution status of this line is deduced): oldChild->next = 0;
-
1831 oldChild->prev = 0;
executed (the execution status of this line is deduced): oldChild->prev = 0;
-
1832 -
1833 // We are no longer interested in the old node -
1834 oldChild->ref.deref();
executed (the execution status of this line is deduced): oldChild->ref.deref();
-
1835 -
1836 return oldChild;
executed: return oldChild;
Execution Count:5
5
1837} -
1838 -
1839QDomNodePrivate* QDomNodePrivate::appendChild(QDomNodePrivate* newChild) -
1840{ -
1841 // No reference manipulation needed. Done in insertAfter. -
1842 return insertAfter(newChild, 0);
executed: return insertAfter(newChild, 0);
Execution Count:93345
93345
1843} -
1844 -
1845QDomDocumentPrivate* QDomNodePrivate::ownerDocument() -
1846{ -
1847 QDomNodePrivate* p = this;
executed (the execution status of this line is deduced): QDomNodePrivate* p = this;
-
1848 while (p && !p->isDocument()) {
partially evaluated: p
TRUEFALSE
yes
Evaluation Count:4500374
no
Evaluation Count:0
evaluated: !p->isDocument()
TRUEFALSE
yes
Evaluation Count:3931623
yes
Evaluation Count:568751
0-4500374
1849 if (!p->hasParent)
evaluated: !p->hasParent
TRUEFALSE
yes
Evaluation Count:522
yes
Evaluation Count:3931101
522-3931101
1850 return (QDomDocumentPrivate*)p->ownerNode;
executed: return (QDomDocumentPrivate*)p->ownerNode;
Execution Count:522
522
1851 p = p->parent();
executed (the execution status of this line is deduced): p = p->parent();
-
1852 }
executed: }
Execution Count:3931101
3931101
1853 -
1854 return static_cast<QDomDocumentPrivate *>(p);
executed: return static_cast<QDomDocumentPrivate *>(p);
Execution Count:568751
568751
1855} -
1856 -
1857QDomNodePrivate* QDomNodePrivate::cloneNode(bool deep) -
1858{ -
1859 QDomNodePrivate* p = new QDomNodePrivate(this, deep);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomNodePrivate(this, deep);
-
1860 // We are not interested in this node -
1861 p->ref.deref();
never executed (the execution status of this line is deduced): p->ref.deref();
-
1862 return p;
never executed: return p;
0
1863} -
1864 -
1865static void qNormalizeNode(QDomNodePrivate* n) -
1866{ -
1867 QDomNodePrivate* p = n->first;
never executed (the execution status of this line is deduced): QDomNodePrivate* p = n->first;
-
1868 QDomTextPrivate* t = 0;
never executed (the execution status of this line is deduced): QDomTextPrivate* t = 0;
-
1869 -
1870 while (p) {
never evaluated: p
0
1871 if (p->isText()) {
never evaluated: p->isText()
0
1872 if (t) {
never evaluated: t
0
1873 QDomNodePrivate* tmp = p->next;
never executed (the execution status of this line is deduced): QDomNodePrivate* tmp = p->next;
-
1874 t->appendData(p->nodeValue());
never executed (the execution status of this line is deduced): t->appendData(p->nodeValue());
-
1875 n->removeChild(p);
never executed (the execution status of this line is deduced): n->removeChild(p);
-
1876 p = tmp;
never executed (the execution status of this line is deduced): p = tmp;
-
1877 } else {
never executed: }
0
1878 t = (QDomTextPrivate*)p;
never executed (the execution status of this line is deduced): t = (QDomTextPrivate*)p;
-
1879 p = p->next;
never executed (the execution status of this line is deduced): p = p->next;
-
1880 }
never executed: }
0
1881 } else { -
1882 p = p->next;
never executed (the execution status of this line is deduced): p = p->next;
-
1883 t = 0;
never executed (the execution status of this line is deduced): t = 0;
-
1884 }
never executed: }
0
1885 } -
1886}
never executed: }
0
1887void QDomNodePrivate::normalize() -
1888{ -
1889 // ### This one has moved from QDomElementPrivate to this position. It is -
1890 // not tested. -
1891 qNormalizeNode(this);
never executed (the execution status of this line is deduced): qNormalizeNode(this);
-
1892}
never executed: }
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;
executed (the execution status of this line is deduced): const QDomNodePrivate* n = first;
-
1900 while (n) {
evaluated: n
TRUEFALSE
yes
Evaluation Count:63280
yes
Evaluation Count:30174
30174-63280
1901 n->save(s, depth, indent);
executed (the execution status of this line is deduced): n->save(s, depth, indent);
-
1902 n = n->next;
executed (the execution status of this line is deduced): n = n->next;
-
1903 }
executed: }
Execution Count:63280
63280
1904}
executed: }
Execution Count:30174
30174
1905 -
1906void QDomNodePrivate::setLocation(int lineNumber, int columnNumber) -
1907{ -
1908 this->lineNumber = lineNumber;
executed (the execution status of this line is deduced): this->lineNumber = lineNumber;
-
1909 this->columnNumber = columnNumber;
executed (the execution status of this line is deduced): this->columnNumber = columnNumber;
-
1910}
executed: }
Execution Count:76460
76460
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;
executed (the execution status of this line is deduced): impl = 0;
-
2010}
executed: }
Execution Count:573
573
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;
executed (the execution status of this line is deduced): impl = n.impl;
-
2022 if (impl)
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:60
no
Evaluation Count:0
0-60
2023 impl->ref.ref();
executed: impl->ref.ref();
Execution Count:60
60
2024}
executed: }
Execution Count:60
60
2025 -
2026/*! \internal -
2027 Constructs a new node for the data \a n. -
2028*/ -
2029QDomNode::QDomNode(QDomNodePrivate *n) -
2030{ -
2031 impl = n;
executed (the execution status of this line is deduced): impl = n;
-
2032 if (impl)
evaluated: impl
TRUEFALSE
yes
Evaluation Count:188475
yes
Evaluation Count:161
161-188475
2033 impl->ref.ref();
executed: impl->ref.ref();
Execution Count:188475
188475
2034}
executed: }
Execution Count:188636
188636
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)
evaluated: n.impl
TRUEFALSE
yes
Evaluation Count:109
yes
Evaluation Count:3
3-109
2046 n.impl->ref.ref();
executed: n.impl->ref.ref();
Execution Count:109
109
2047 if (impl && !impl->ref.deref())
evaluated: impl
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:60
partially evaluated: !impl->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:52
0-60
2048 delete impl;
never executed: delete impl;
0
2049 impl = n.impl;
executed (the execution status of this line is deduced): impl = n.impl;
-
2050 return *this;
executed: return *this;
Execution Count:112
112
2051} -
2052 -
2053/*! -
2054 Returns true if \a n and this DOM node are equal; otherwise -
2055 returns 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);
executed: return (impl == n.impl);
Execution Count:319
319
2076} -
2077 -
2078/*! -
2079 Returns true if \a n and this DOM node are not equal; otherwise -
2080 returns false. -
2081*/ -
2082bool QDomNode::operator!= (const QDomNode& n) const -
2083{ -
2084 return (impl != n.impl);
executed: return (impl != n.impl);
Execution Count:120
120
2085} -
2086 -
2087/*! -
2088 Destroys the object and frees its resources. -
2089*/ -
2090QDomNode::~QDomNode() -
2091{ -
2092 if (impl && !impl->ref.deref())
evaluated: impl
TRUEFALSE
yes
Evaluation Count:189063
yes
Evaluation Count:206
evaluated: !impl->ref.deref()
TRUEFALSE
yes
Evaluation Count:843
yes
Evaluation Count:188220
206-189063
2093 delete impl;
executed: delete impl;
Execution Count:843
843
2094}
executed: }
Execution Count:189269
189269
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)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:127426
2-127426
2128 return QString();
executed: return QString();
Execution Count:2
2
2129 -
2130 if (!IMPL->prefix.isEmpty())
evaluated: !((QDomNodePrivate*)impl)->prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:127399
27-127399
2131 return IMPL->prefix + QLatin1Char(':') + IMPL->name;
executed: return ((QDomNodePrivate*)impl)->prefix + QLatin1Char(':') + ((QDomNodePrivate*)impl)->name;
Execution Count:27
27
2132 return IMPL->name;
executed: return ((QDomNodePrivate*)impl)->name;
Execution Count:127399
127399
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)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127205
0-127205
2156 return QString();
never executed: return QString();
0
2157 return IMPL->value;
executed: return ((QDomNodePrivate*)impl)->value;
Execution Count:127205
127205
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)
never evaluated: !impl
0
2168 return;
never executed: return;
0
2169 IMPL->setNodeValue(v);
never executed (the execution status of this line is deduced): ((QDomNodePrivate*)impl)->setNodeValue(v);
-
2170}
never executed: }
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)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127194
0-127194
2203 return QDomNode::BaseNode;
never executed: return QDomNode::BaseNode;
0
2204 return IMPL->nodeType();
executed: return ((QDomNodePrivate*)impl)->nodeType();
Execution Count:127194
127194
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 true). -
2210*/ -
2211QDomNode QDomNode::parentNode() const -
2212{ -
2213 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:73
0-73
2214 return QDomNode();
never executed: return QDomNode();
0
2215 return QDomNode(IMPL->parent());
executed: return QDomNode(((QDomNodePrivate*)impl)->parent());
Execution Count:73
73
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)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127242
0-127242
2239 return QDomNodeList();
never executed: return QDomNodeList();
0
2240 return QDomNodeList(new QDomNodeListPrivate(impl));
executed: return QDomNodeList(new QDomNodeListPrivate(impl));
Execution Count:127242
127242
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)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
2253 return QDomNode();
never executed: return QDomNode();
0
2254 return QDomNode(IMPL->first);
executed: return QDomNode(((QDomNodePrivate*)impl)->first);
Execution Count:9
9
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)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2267 return QDomNode();
never executed: return QDomNode();
0
2268 return QDomNode(IMPL->last);
executed: return QDomNode(((QDomNodePrivate*)impl)->last);
Execution Count:1
1
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)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2287 return QDomNode();
never executed: return QDomNode();
0
2288 return QDomNode(IMPL->prev);
executed: return QDomNode(((QDomNodePrivate*)impl)->prev);
Execution Count:6
6
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)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
2307 return QDomNode();
never executed: return QDomNode();
0
2308 return QDomNode(IMPL->next);
executed: return QDomNode(((QDomNodePrivate*)impl)->next);
Execution Count:17
17
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())
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
evaluated: !impl->isElement()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:10
0-26
2323 return QDomNamedNodeMap();
executed: return QDomNamedNodeMap();
Execution Count:16
16
2324 -
2325 return QDomNamedNodeMap(static_cast<QDomElementPrivate *>(impl)->attributes());
executed: return QDomNamedNodeMap(static_cast<QDomElementPrivate *>(impl)->attributes());
Execution Count:10
10
2326} -
2327 -
2328/*! -
2329 Returns the document to which this node belongs. -
2330*/ -
2331QDomDocument QDomNode::ownerDocument() const -
2332{ -
2333 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:478
0-478
2334 return QDomDocument();
never executed: return QDomDocument();
0
2335 return QDomDocument(IMPL->ownerDocument());
executed: return QDomDocument(((QDomNodePrivate*)impl)->ownerDocument());
Execution Count:478
478
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)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
2349 return QDomNode();
never executed: return QDomNode();
0
2350 return QDomNode(IMPL->cloneNode(deep));
executed: return QDomNode(((QDomNodePrivate*)impl)->cloneNode(deep));
Execution Count:20
20
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)
never evaluated: !impl
0
2362 return;
never executed: return;
0
2363 IMPL->normalize();
never executed (the execution status of this line is deduced): ((QDomNodePrivate*)impl)->normalize();
-
2364}
never executed: }
0
2365 -
2366/*! -
2367 Returns true if the DOM implementation implements the feature \a -
2368 feature and this feature is supported by this node in the version -
2369 \a version; otherwise returns false. -
2370 -
2371 \sa QDomImplementation::hasFeature() -
2372*/ -
2373bool QDomNode::isSupported(const QString& feature, const QString& version) const -
2374{ -
2375 QDomImplementation i;
never executed (the execution status of this line is deduced): QDomImplementation i;
-
2376 return i.hasFeature(feature, version);
never executed: return i.hasFeature(feature, version);
0
2377} -
2378 -
2379/*! -
2380 Returns the namespace URI of this node or an empty string if the -
2381 node has no namespace URI. -
2382 -
2383 Only nodes of type \l{QDomNode::NodeType}{ElementNode} or -
2384 \l{QDomNode::NodeType}{AttributeNode} can have -
2385 namespaces. A namespace URI must be specified at creation time and -
2386 cannot be changed later. -
2387 -
2388 \sa prefix(), localName(), QDomDocument::createElementNS(), -
2389 QDomDocument::createAttributeNS() -
2390*/ -
2391QString QDomNode::namespaceURI() const -
2392{ -
2393 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127182
0-127182
2394 return QString();
never executed: return QString();
0
2395 return IMPL->namespaceURI;
executed: return ((QDomNodePrivate*)impl)->namespaceURI;
Execution Count:127182
127182
2396} -
2397 -
2398/*! -
2399 Returns the namespace prefix of the node or an empty string if the -
2400 node has no namespace prefix. -
2401 -
2402 Only nodes of type \l{QDomNode::NodeType}{ElementNode} or -
2403 \l{QDomNode::NodeType}{AttributeNode} can have -
2404 namespaces. A namespace prefix must be specified at creation time. -
2405 If a node was created with a namespace prefix, you can change it -
2406 later with setPrefix(). -
2407 -
2408 If you create an element or attribute with -
2409 QDomDocument::createElement() or QDomDocument::createAttribute(), -
2410 the prefix will be an empty string. If you use -
2411 QDomDocument::createElementNS() or -
2412 QDomDocument::createAttributeNS() instead, the prefix will not be -
2413 an empty string; but it might be an empty string if the name does -
2414 not have a prefix. -
2415 -
2416 \sa setPrefix(), localName(), namespaceURI(), -
2417 QDomDocument::createElementNS(), -
2418 QDomDocument::createAttributeNS() -
2419*/ -
2420QString QDomNode::prefix() const -
2421{ -
2422 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
2423 return QString();
never executed: return QString();
0
2424 return IMPL->prefix;
executed: return ((QDomNodePrivate*)impl)->prefix;
Execution Count:12
12
2425} -
2426 -
2427/*! -
2428 If the node has a namespace prefix, this function changes the -
2429 namespace prefix of the node to \a pre. Otherwise this function -
2430 does nothing. -
2431 -
2432 Only nodes of type \l{QDomNode::NodeType}{ElementNode} or -
2433 \l{QDomNode::NodeType}{AttributeNode} can have -
2434 namespaces. A namespace prefix must have be specified at creation -
2435 time; it is not possible to add a namespace prefix afterwards. -
2436 -
2437 \sa prefix(), localName(), namespaceURI(), -
2438 QDomDocument::createElementNS(), -
2439 QDomDocument::createAttributeNS() -
2440*/ -
2441void QDomNode::setPrefix(const QString& pre) -
2442{ -
2443 if (!impl || IMPL->prefix.isNull())
never evaluated: !impl
never evaluated: ((QDomNodePrivate*)impl)->prefix.isNull()
0
2444 return;
never executed: return;
0
2445 if (isAttr() || isElement())
never evaluated: isAttr()
never evaluated: isElement()
0
2446 IMPL->prefix = pre;
never executed: ((QDomNodePrivate*)impl)->prefix = pre;
0
2447}
never executed: }
0
2448 -
2449/*! -
2450 If the node uses namespaces, this function returns the local name -
2451 of the node; otherwise it returns an empty string. -
2452 -
2453 Only nodes of type \l{QDomNode::NodeType}{ElementNode} or -
2454 \l{QDomNode::NodeType}{AttributeNode} can have -
2455 namespaces. A namespace must have been specified at creation time; -
2456 it is not possible to add a namespace afterwards. -
2457 -
2458 \sa prefix(), namespaceURI(), QDomDocument::createElementNS(), -
2459 QDomDocument::createAttributeNS() -
2460*/ -
2461QString QDomNode::localName() const -
2462{ -
2463 if (!impl || IMPL->createdWithDom1Interface)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
partially evaluated: ((QDomNodePrivate*)impl)->createdWithDom1Interface
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
2464 return QString();
executed: return QString();
Execution Count:12
12
2465 return IMPL->name;
never executed: return ((QDomNodePrivate*)impl)->name;
0
2466} -
2467 -
2468/*! -
2469 Returns true if the node has attributes; otherwise returns false. -
2470 -
2471 \sa attributes() -
2472*/ -
2473bool QDomNode::hasAttributes() const -
2474{ -
2475 if (!impl || !impl->isElement())
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
evaluated: !impl->isElement()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:9
0-25
2476 return false;
executed: return false;
Execution Count:16
16
2477 return static_cast<QDomElementPrivate *>(impl)->hasAttributes();
executed: return static_cast<QDomElementPrivate *>(impl)->hasAttributes();
Execution Count:9
9
2478} -
2479 -
2480/*! -
2481 Inserts the node \a newChild before the child node \a refChild. -
2482 \a refChild must be a direct child of this node. If \a refChild is -
2483 \l{isNull()}{null} then \a newChild is inserted as the -
2484 node's first child. -
2485 -
2486 If \a newChild is the child of another node, it is reparented to -
2487 this node. If \a newChild is a child of this node, then its -
2488 position in the list of children is changed. -
2489 -
2490 If \a newChild is a QDomDocumentFragment, then the children of the -
2491 fragment are removed from the fragment and inserted before \a -
2492 refChild. -
2493 -
2494 Returns a new reference to \a newChild on success or a \l{isNull()}{null node} on failure. -
2495 -
2496 The DOM specification disallow inserting attribute nodes, but due -
2497 to historical reasons QDom accept them nevertheless. -
2498 -
2499 \sa insertAfter(), replaceChild(), removeChild(), appendChild() -
2500*/ -
2501QDomNode QDomNode::insertBefore(const QDomNode& newChild, const QDomNode& refChild) -
2502{ -
2503 if (!impl)
never evaluated: !impl
0
2504 return QDomNode();
never executed: return QDomNode();
0
2505 return QDomNode(IMPL->insertBefore(newChild.impl, refChild.impl));
never executed: return QDomNode(((QDomNodePrivate*)impl)->insertBefore(newChild.impl, refChild.impl));
0
2506} -
2507 -
2508/*! -
2509 Inserts the node \a newChild after the child node \a refChild. \a -
2510 refChild must be a direct child of this node. If \a refChild is -
2511 \l{isNull()}{null} then \a newChild is appended as this -
2512 node's last child. -
2513 -
2514 If \a newChild is the child of another node, it is reparented to -
2515 this node. If \a newChild is a child of this node, then its -
2516 position in the list of children is changed. -
2517 -
2518 If \a newChild is a QDomDocumentFragment, then the children of the -
2519 fragment are removed from the fragment and inserted after \a -
2520 refChild. -
2521 -
2522 Returns a new reference to \a newChild on success or a \l{isNull()}{null node} on failure. -
2523 -
2524 The DOM specification disallow inserting attribute nodes, but due -
2525 to historical reasons QDom accept them nevertheless. -
2526 -
2527 \sa insertBefore(), replaceChild(), removeChild(), appendChild() -
2528*/ -
2529QDomNode QDomNode::insertAfter(const QDomNode& newChild, const QDomNode& refChild) -
2530{ -
2531 if (!impl)
never evaluated: !impl
0
2532 return QDomNode();
never executed: return QDomNode();
0
2533 return QDomNode(IMPL->insertAfter(newChild.impl, refChild.impl));
never executed: return QDomNode(((QDomNodePrivate*)impl)->insertAfter(newChild.impl, refChild.impl));
0
2534} -
2535 -
2536/*! -
2537 Replaces \a oldChild with \a newChild. \a oldChild must be a -
2538 direct child of this node. -
2539 -
2540 If \a newChild is the child of another node, it is reparented to -
2541 this node. If \a newChild is a child of this node, then its -
2542 position in the list of children is changed. -
2543 -
2544 If \a newChild is a QDomDocumentFragment, then \a oldChild is -
2545 replaced by all of the children of the fragment. -
2546 -
2547 Returns a new reference to \a oldChild on success or a \l{isNull()}{null node} an failure. -
2548 -
2549 \sa insertBefore(), insertAfter(), removeChild(), appendChild() -
2550*/ -
2551QDomNode QDomNode::replaceChild(const QDomNode& newChild, const QDomNode& oldChild) -
2552{ -
2553 if (!impl || !newChild.impl || !oldChild.impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
partially evaluated: !newChild.impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
partially evaluated: !oldChild.impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
2554 return QDomNode();
never executed: return QDomNode();
0
2555 return QDomNode(IMPL->replaceChild(newChild.impl, oldChild.impl));
executed: return QDomNode(((QDomNodePrivate*)impl)->replaceChild(newChild.impl, oldChild.impl));
Execution Count:12
12
2556} -
2557 -
2558/*! -
2559 Removes \a oldChild from the list of children. \a oldChild must be -
2560 a direct child of this node. -
2561 -
2562 Returns a new reference to \a oldChild on success or a \l{isNull()}{null node} on failure. -
2563 -
2564 \sa insertBefore(), insertAfter(), replaceChild(), appendChild() -
2565*/ -
2566QDomNode QDomNode::removeChild(const QDomNode& oldChild) -
2567{ -
2568 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2569 return QDomNode();
never executed: return QDomNode();
0
2570 -
2571 if (oldChild.isNull())
partially evaluated: oldChild.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2572 return QDomNode();
never executed: return QDomNode();
0
2573 -
2574 return QDomNode(IMPL->removeChild(oldChild.impl));
executed: return QDomNode(((QDomNodePrivate*)impl)->removeChild(oldChild.impl));
Execution Count:1
1
2575} -
2576 -
2577/*! -
2578 Appends \a newChild as the node's last child. -
2579 -
2580 If \a newChild is the child of another node, it is reparented to -
2581 this node. If \a newChild is a child of this node, then its -
2582 position in the list of children is changed. -
2583 -
2584 If \a newChild is a QDomDocumentFragment, then the children of the -
2585 fragment are removed from the fragment and appended. -
2586 -
2587 If \a newChild is a QDomElement and this node is a QDomDocument that -
2588 already has an element node as a child, \a newChild is not added as -
2589 a child and a null node is returned. -
2590 -
2591 Returns a new reference to \a newChild on success or a \l{isNull()}{null node} on failure. -
2592 -
2593 Calling this function on a null node(created, for example, with -
2594 the default constructor) does nothing and returns a \l{isNull()}{null node}. -
2595 -
2596 The DOM specification disallow inserting attribute nodes, but for -
2597 historical reasons, QDom accepts them anyway. -
2598 -
2599 \sa insertBefore(), insertAfter(), replaceChild(), removeChild() -
2600*/ -
2601QDomNode QDomNode::appendChild(const QDomNode& newChild) -
2602{ -
2603 if (!impl) {
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:95
0-95
2604 qWarning("Calling appendChild() on a null node does nothing.");
never executed (the execution status of this line is deduced): QMessageLogger("dom/qdom.cpp", 2604, __PRETTY_FUNCTION__).warning("Calling appendChild() on a null node does nothing.");
-
2605 return QDomNode();
never executed: return QDomNode();
0
2606 } -
2607 return QDomNode(IMPL->appendChild(newChild.impl));
executed: return QDomNode(((QDomNodePrivate*)impl)->appendChild(newChild.impl));
Execution Count:95
95
2608} -
2609 -
2610/*! -
2611 Returns true if the node has one or more children; otherwise -
2612 returns false. -
2613*/ -
2614bool QDomNode::hasChildNodes() const -
2615{ -
2616 if (!impl)
never evaluated: !impl
0
2617 return false;
never executed: return false;
0
2618 return IMPL->first != 0;
never executed: return ((QDomNodePrivate*)impl)->first != 0;
0
2619} -
2620 -
2621/*! -
2622 Returns true if this node is null (i.e. if it has no type or -
2623 contents); otherwise returns false. -
2624*/ -
2625bool QDomNode::isNull() const -
2626{ -
2627 return (impl == 0);
executed: return (impl == 0);
Execution Count:424
424
2628} -
2629 -
2630/*! -
2631 Converts the node into a null node; if it was not a null node -
2632 before, its type and contents are deleted. -
2633 -
2634 \sa isNull() -
2635*/ -
2636void QDomNode::clear() -
2637{ -
2638 if (impl && !impl->ref.deref())
never evaluated: impl
never evaluated: !impl->ref.deref()
0
2639 delete impl;
never executed: delete impl;
0
2640 impl = 0;
never executed (the execution status of this line is deduced): impl = 0;
-
2641}
never executed: }
0
2642 -
2643/*! -
2644 Returns the first direct child node for which nodeName() equals \a -
2645 name. -
2646 -
2647 If no such direct child exists, a \l{isNull()}{null node} -
2648 is returned. -
2649 -
2650 \sa nodeName() -
2651*/ -
2652QDomNode QDomNode::namedItem(const QString& name) const -
2653{ -
2654 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
2655 return QDomNode();
never executed: return QDomNode();
0
2656 return QDomNode(impl->namedItem(name));
executed: return QDomNode(impl->namedItem(name));
Execution Count:10
10
2657} -
2658 -
2659/*! -
2660 Writes the XML representation of the node and all its children to -
2661 the stream \a stream. This function uses \a indent as the amount of -
2662 space to indent the node. -
2663 -
2664 If the document contains invalid XML characters or characters that cannot be -
2665 encoded in the given encoding, the result and behavior is undefined. -
2666 -
2667 If \a encodingPolicy is QDomNode::EncodingFromDocument and this node is a -
2668 document node, the encoding of text stream \a stream's encoding is set by -
2669 treating a processing instruction by name "xml" as an XML declaration, if -
2670 one exists, and otherwise defaults to UTF-8. XML declarations are not -
2671 processing instructions, but this behavior exists for historical -
2672 reasons. If this node is not a document node, the text stream's encoding -
2673 is used. -
2674 -
2675 If \a encodingPolicy is EncodingFromTextStream and this node is a document node, this -
2676 function behaves as save(QTextStream &str, int indent) with the exception that the encoding -
2677 specified in the text stream \a stream is used. -
2678 -
2679 If the document contains invalid XML characters or characters that cannot be -
2680 encoded in the given encoding, the result and behavior is undefined. -
2681 -
2682 \since 4.2 -
2683 */ -
2684void QDomNode::save(QTextStream& stream, int indent, EncodingPolicy encodingPolicy) const -
2685{ -
2686 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:238
0-238
2687 return;
never executed: return;
0
2688 -
2689 if(isDocument())
evaluated: isDocument()
TRUEFALSE
yes
Evaluation Count:226
yes
Evaluation Count:12
12-226
2690 static_cast<const QDomDocumentPrivate *>(impl)->saveDocument(stream, indent, encodingPolicy);
executed: static_cast<const QDomDocumentPrivate *>(impl)->saveDocument(stream, indent, encodingPolicy);
Execution Count:226
226
2691 else -
2692 IMPL->save(stream, 1, indent);
executed: ((QDomNodePrivate*)impl)->save(stream, 1, indent);
Execution Count:12
12
2693} -
2694 -
2695/*! -
2696 \relates QDomNode -
2697 -
2698 Writes the XML representation of the node \a node and all its -
2699 children to the stream \a str. -
2700*/ -
2701QTextStream& operator<<(QTextStream& str, const QDomNode& node) -
2702{ -
2703 node.save(str, 1);
executed (the execution status of this line is deduced): node.save(str, 1);
-
2704 -
2705 return str;
executed: return str;
Execution Count:12
12
2706} -
2707 -
2708/*! -
2709 Returns true if the node is an attribute; otherwise returns false. -
2710 -
2711 If this function returns true, it does not imply that this object -
2712 is a QDomAttribute; you can get the QDomAttribute with -
2713 toAttribute(). -
2714 -
2715 \sa toAttr() -
2716*/ -
2717bool QDomNode::isAttr() const -
2718{ -
2719 if(impl)
never evaluated: impl
0
2720 return impl->isAttr();
never executed: return impl->isAttr();
0
2721 return false;
never executed: return false;
0
2722} -
2723 -
2724/*! -
2725 Returns true if the node is a CDATA section; otherwise returns -
2726 false. -
2727 -
2728 If this function returns true, it does not imply that this object -
2729 is a QDomCDATASection; you can get the QDomCDATASection with -
2730 toCDATASection(). -
2731 -
2732 \sa toCDATASection() -
2733*/ -
2734bool QDomNode::isCDATASection() const -
2735{ -
2736 if(impl)
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2737 return impl->isCDATASection();
executed: return impl->isCDATASection();
Execution Count:1
1
2738 return false;
never executed: return false;
0
2739} -
2740 -
2741/*! -
2742 Returns true if the node is a document fragment; otherwise returns -
2743 false. -
2744 -
2745 If this function returns true, it does not imply that this object -
2746 is a QDomDocumentFragment; you can get the QDomDocumentFragment -
2747 with toDocumentFragment(). -
2748 -
2749 \sa toDocumentFragment() -
2750*/ -
2751bool QDomNode::isDocumentFragment() const -
2752{ -
2753 if(impl)
never evaluated: impl
0
2754 return impl->isDocumentFragment();
never executed: return impl->isDocumentFragment();
0
2755 return false;
never executed: return false;
0
2756} -
2757 -
2758/*! -
2759 Returns true if the node is a document; otherwise returns false. -
2760 -
2761 If this function returns true, it does not imply that this object -
2762 is a QDomDocument; you can get the QDomDocument with toDocument(). -
2763 -
2764 \sa toDocument() -
2765*/ -
2766bool QDomNode::isDocument() const -
2767{ -
2768 if(impl)
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:238
no
Evaluation Count:0
0-238
2769 return impl->isDocument();
executed: return impl->isDocument();
Execution Count:238
238
2770 return false;
never executed: return false;
0
2771} -
2772 -
2773/*! -
2774 Returns true if the node is a document type; otherwise returns -
2775 false. -
2776 -
2777 If this function returns true, it does not imply that this object -
2778 is a QDomDocumentType; you can get the QDomDocumentType with -
2779 toDocumentType(). -
2780 -
2781 \sa toDocumentType() -
2782*/ -
2783bool QDomNode::isDocumentType() const -
2784{ -
2785 if(impl)
never evaluated: impl
0
2786 return impl->isDocumentType();
never executed: return impl->isDocumentType();
0
2787 return false;
never executed: return false;
0
2788} -
2789 -
2790/*! -
2791 Returns true if the node is an element; otherwise returns false. -
2792 -
2793 If this function returns true, it does not imply that this object -
2794 is a QDomElement; you can get the QDomElement with toElement(). -
2795 -
2796 \sa toElement() -
2797*/ -
2798bool QDomNode::isElement() const -
2799{ -
2800 if(impl)
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
0-22
2801 return impl->isElement();
executed: return impl->isElement();
Execution Count:22
22
2802 return false;
never executed: return false;
0
2803} -
2804 -
2805/*! -
2806 Returns true if the node is an entity reference; otherwise returns -
2807 false. -
2808 -
2809 If this function returns true, it does not imply that this object -
2810 is a QDomEntityReference; you can get the QDomEntityReference with -
2811 toEntityReference(). -
2812 -
2813 \sa toEntityReference() -
2814*/ -
2815bool QDomNode::isEntityReference() const -
2816{ -
2817 if(impl)
never evaluated: impl
0
2818 return impl->isEntityReference();
never executed: return impl->isEntityReference();
0
2819 return false;
never executed: return false;
0
2820} -
2821 -
2822/*! -
2823 Returns true if the node is a text node; otherwise returns false. -
2824 -
2825 If this function returns true, it does not imply that this object -
2826 is a QDomText; you can get the QDomText with toText(). -
2827 -
2828 \sa toText() -
2829*/ -
2830bool QDomNode::isText() const -
2831{ -
2832 if(impl)
never evaluated: impl
0
2833 return impl->isText();
never executed: return impl->isText();
0
2834 return false;
never executed: return false;
0
2835} -
2836 -
2837/*! -
2838 Returns true if the node is an entity; otherwise returns false. -
2839 -
2840 If this function returns true, it does not imply that this object -
2841 is a QDomEntity; you can get the QDomEntity with toEntity(). -
2842 -
2843 \sa toEntity() -
2844*/ -
2845bool QDomNode::isEntity() const -
2846{ -
2847 if(impl)
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2848 return impl->isEntity();
executed: return impl->isEntity();
Execution Count:2
2
2849 return false;
never executed: return false;
0
2850} -
2851 -
2852/*! -
2853 Returns true if the node is a notation; otherwise returns false. -
2854 -
2855 If this function returns true, it does not imply that this object -
2856 is a QDomNotation; you can get the QDomNotation with toNotation(). -
2857 -
2858 \sa toNotation() -
2859*/ -
2860bool QDomNode::isNotation() const -
2861{ -
2862 if(impl)
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2863 return impl->isNotation();
executed: return impl->isNotation();
Execution Count:2
2
2864 return false;
never executed: return false;
0
2865} -
2866 -
2867/*! -
2868 Returns true if the node is a processing instruction; otherwise -
2869 returns false. -
2870 -
2871 If this function returns true, it does not imply that this object -
2872 is a QDomProcessingInstruction; you can get the -
2873 QProcessingInstruction with toProcessingInstruction(). -
2874 -
2875 \sa toProcessingInstruction() -
2876*/ -
2877bool QDomNode::isProcessingInstruction() const -
2878{ -
2879 if(impl)
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:60318
no
Evaluation Count:0
0-60318
2880 return impl->isProcessingInstruction();
executed: return impl->isProcessingInstruction();
Execution Count:60318
60318
2881 return false;
never executed: return false;
0
2882} -
2883 -
2884/*! -
2885 Returns true if the node is a character data node; otherwise -
2886 returns false. -
2887 -
2888 If this function returns true, it does not imply that this object -
2889 is a QDomCharacterData; you can get the QDomCharacterData with -
2890 toCharacterData(). -
2891 -
2892 \sa toCharacterData() -
2893*/ -
2894bool QDomNode::isCharacterData() const -
2895{ -
2896 if (impl)
never evaluated: impl
0
2897 return impl->isCharacterData();
never executed: return impl->isCharacterData();
0
2898 return false;
never executed: return false;
0
2899} -
2900 -
2901/*! -
2902 Returns true if the node is a comment; otherwise returns false. -
2903 -
2904 If this function returns true, it does not imply that this object -
2905 is a QDomComment; you can get the QDomComment with toComment(). -
2906 -
2907 \sa toComment() -
2908*/ -
2909bool QDomNode::isComment() const -
2910{ -
2911 if (impl)
never evaluated: impl
0
2912 return impl->isComment();
never executed: return impl->isComment();
0
2913 return false;
never executed: return false;
0
2914} -
2915 -
2916#undef IMPL -
2917 -
2918/*! -
2919 Returns the first child element with tag name \a tagName if tagName is non-empty; -
2920 otherwise returns the first child element. Returns a null element if no -
2921 such child exists. -
2922 -
2923 \sa lastChildElement(), previousSiblingElement(), nextSiblingElement() -
2924*/ -
2925 -
2926QDomElement QDomNode::firstChildElement(const QString &tagName) const -
2927{ -
2928 for (QDomNode child = firstChild(); !child.isNull(); child = child.nextSibling()) {
evaluated: !child.isNull()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:2
2-11
2929 if (child.isElement()) {
partially evaluated: child.isElement()
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
2930 QDomElement elt = child.toElement();
executed (the execution status of this line is deduced): QDomElement elt = child.toElement();
-
2931 if (tagName.isEmpty() || elt.tagName() == tagName)
evaluated: tagName.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
evaluated: elt.tagName() == tagName
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:6
1-10
2932 return elt;
executed: return elt;
Execution Count:5
5
2933 }
executed: }
Execution Count:6
6
2934 }
executed: }
Execution Count:6
6
2935 return QDomElement();
executed: return QDomElement();
Execution Count:2
2
2936} -
2937 -
2938/*! -
2939 Returns the last child element with tag name \a tagName if tagName is non-empty; -
2940 otherwise returns the last child element. Returns a null element if no -
2941 such child exists. -
2942 -
2943 \sa firstChildElement(), previousSiblingElement(), nextSiblingElement() -
2944*/ -
2945 -
2946QDomElement QDomNode::lastChildElement(const QString &tagName) const -
2947{ -
2948 for (QDomNode child = lastChild(); !child.isNull(); child = child.previousSibling()) {
partially evaluated: !child.isNull()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2949 if (child.isElement()) {
partially evaluated: child.isElement()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2950 QDomElement elt = child.toElement();
executed (the execution status of this line is deduced): QDomElement elt = child.toElement();
-
2951 if (tagName.isEmpty() || elt.tagName() == tagName)
partially evaluated: tagName.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: elt.tagName() == tagName
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2952 return elt;
executed: return elt;
Execution Count:1
1
2953 }
never executed: }
0
2954 }
never executed: }
0
2955 return QDomElement();
never executed: return QDomElement();
0
2956} -
2957 -
2958/*! -
2959 Returns the next sibling element with tag name \a tagName if \a tagName -
2960 is non-empty; otherwise returns any next sibling element. -
2961 Returns a null element if no such sibling exists. -
2962 -
2963 \sa firstChildElement(), previousSiblingElement(), lastChildElement() -
2964*/ -
2965 -
2966QDomElement QDomNode::nextSiblingElement(const QString &tagName) const -
2967{ -
2968 for (QDomNode sib = nextSibling(); !sib.isNull(); sib = sib.nextSibling()) {
evaluated: !sib.isNull()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:3
3-8
2969 if (sib.isElement()) {
partially evaluated: sib.isElement()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
2970 QDomElement elt = sib.toElement();
executed (the execution status of this line is deduced): QDomElement elt = sib.toElement();
-
2971 if (tagName.isEmpty() || elt.tagName() == tagName)
evaluated: tagName.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
evaluated: elt.tagName() == tagName
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
1-7
2972 return elt;
executed: return elt;
Execution Count:4
4
2973 }
executed: }
Execution Count:4
4
2974 }
executed: }
Execution Count:4
4
2975 return QDomElement();
executed: return QDomElement();
Execution Count:3
3
2976} -
2977 -
2978/*! -
2979 Returns the previous sibilng element with tag name \a tagName if \a tagName -
2980 is non-empty; otherwise returns any previous sibling element. -
2981 Returns a null element if no such sibling exists. -
2982 -
2983 \sa firstChildElement(), nextSiblingElement(), lastChildElement() -
2984*/ -
2985 -
2986QDomElement QDomNode::previousSiblingElement(const QString &tagName) const -
2987{ -
2988 for (QDomNode sib = previousSibling(); !sib.isNull(); sib = sib.previousSibling()) {
evaluated: !sib.isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
2-4
2989 if (sib.isElement()) {
partially evaluated: sib.isElement()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2990 QDomElement elt = sib.toElement();
executed (the execution status of this line is deduced): QDomElement elt = sib.toElement();
-
2991 if (tagName.isEmpty() || elt.tagName() == tagName)
partially evaluated: tagName.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: elt.tagName() == tagName
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2992 return elt;
executed: return elt;
Execution Count:2
2
2993 }
never executed: }
0
2994 }
never executed: }
0
2995 return QDomElement();
executed: return QDomElement();
Execution Count:4
4
2996} -
2997 -
2998/*! -
2999 \since 4.1 -
3000 -
3001 For nodes created by QDomDocument::setContent(), this function -
3002 returns the line number in the XML document where the node was parsed. -
3003 Otherwise, -1 is returned. -
3004 -
3005 \sa columnNumber(), QDomDocument::setContent() -
3006*/ -
3007int QDomNode::lineNumber() const -
3008{ -
3009 return impl ? impl->lineNumber : -1;
never executed: return impl ? impl->lineNumber : -1;
0
3010} -
3011 -
3012/*! -
3013 \since 4.1 -
3014 -
3015 For nodes created by QDomDocument::setContent(), this function -
3016 returns the column number in the XML document where the node was parsed. -
3017 Otherwise, -1 is returned. -
3018 -
3019 \sa lineNumber(), QDomDocument::setContent() -
3020*/ -
3021int QDomNode::columnNumber() const -
3022{ -
3023 return impl ? impl->columnNumber : -1;
never executed: return impl ? impl->columnNumber : -1;
0
3024} -
3025 -
3026 -
3027/************************************************************** -
3028 * -
3029 * QDomNamedNodeMapPrivate -
3030 * -
3031 **************************************************************/ -
3032 -
3033QDomNamedNodeMapPrivate::QDomNamedNodeMapPrivate(QDomNodePrivate* n) : ref(1) -
3034{ -
3035 readonly = false;
executed (the execution status of this line is deduced): readonly = false;
-
3036 parent = n;
executed (the execution status of this line is deduced): parent = n;
-
3037 appendToParent = false;
executed (the execution status of this line is deduced): appendToParent = false;
-
3038}
executed: }
Execution Count:39807
39807
3039 -
3040QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate() -
3041{ -
3042 clearMap();
executed (the execution status of this line is deduced): clearMap();
-
3043}
executed: }
Execution Count:39807
39807
3044 -
3045QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate* p) -
3046{ -
3047 QScopedPointer<QDomNamedNodeMapPrivate> m(new QDomNamedNodeMapPrivate(p));
executed (the execution status of this line is deduced): QScopedPointer<QDomNamedNodeMapPrivate> m(new QDomNamedNodeMapPrivate(p));
-
3048 m->readonly = readonly;
executed (the execution status of this line is deduced): m->readonly = readonly;
-
3049 m->appendToParent = appendToParent;
executed (the execution status of this line is deduced): m->appendToParent = appendToParent;
-
3050 -
3051 QHash<QString, QDomNodePrivate*>::const_iterator it = map.constBegin();
executed (the execution status of this line is deduced): QHash<QString, QDomNodePrivate*>::const_iterator it = map.constBegin();
-
3052 for (; it != map.constEnd(); ++it) {
evaluated: it != map.constEnd()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:63
1-63
3053 QDomNodePrivate *new_node = (*it)->cloneNode();
executed (the execution status of this line is deduced): QDomNodePrivate *new_node = (*it)->cloneNode();
-
3054 new_node->setParent(p);
executed (the execution status of this line is deduced): new_node->setParent(p);
-
3055 m->setNamedItem(new_node);
executed (the execution status of this line is deduced): m->setNamedItem(new_node);
-
3056 }
executed: }
Execution Count:1
1
3057 -
3058 // we are no longer interested in ownership -
3059 m->ref.deref();
executed (the execution status of this line is deduced): m->ref.deref();
-
3060 return m.take();
executed: return m.take();
Execution Count:63
63
3061} -
3062 -
3063void QDomNamedNodeMapPrivate::clearMap() -
3064{ -
3065 // Dereference all of our children if we took references -
3066 if (!appendToParent) {
evaluated: !appendToParent
TRUEFALSE
yes
Evaluation Count:38093
yes
Evaluation Count:1714
1714-38093
3067 QHash<QString, QDomNodePrivate *>::const_iterator it = map.constBegin();
executed (the execution status of this line is deduced): QHash<QString, QDomNodePrivate *>::const_iterator it = map.constBegin();
-
3068 for (; it != map.constEnd(); ++it)
evaluated: it != map.constEnd()
TRUEFALSE
yes
Evaluation Count:16754
yes
Evaluation Count:38093
16754-38093
3069 if (!(*it)->ref.deref())
partially evaluated: !(*it)->ref.deref()
TRUEFALSE
yes
Evaluation Count:16754
no
Evaluation Count:0
0-16754
3070 delete *it;
executed: delete *it;
Execution Count:16754
16754
3071 }
executed: }
Execution Count:38093
38093
3072 map.clear();
executed (the execution status of this line is deduced): map.clear();
-
3073}
executed: }
Execution Count:39807
39807
3074 -
3075QDomNodePrivate* QDomNamedNodeMapPrivate::namedItem(const QString& name) const -
3076{ -
3077 QDomNodePrivate* p = map[name];
executed (the execution status of this line is deduced): QDomNodePrivate* p = map[name];
-
3078 return p;
executed: return p;
Execution Count:16745
16745
3079} -
3080 -
3081QDomNodePrivate* QDomNamedNodeMapPrivate::namedItemNS(const QString& nsURI, const QString& localName) const -
3082{ -
3083 QHash<QString, QDomNodePrivate *>::const_iterator it = map.constBegin();
executed (the execution status of this line is deduced): QHash<QString, QDomNodePrivate *>::const_iterator it = map.constBegin();
-
3084 QDomNodePrivate *n;
executed (the execution status of this line is deduced): QDomNodePrivate *n;
-
3085 for (; it != map.constEnd(); ++it) {
evaluated: it != map.constEnd()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
3086 n = *it;
executed (the execution status of this line is deduced): n = *it;
-
3087 if (!n->prefix.isNull()) {
partially evaluated: !n->prefix.isNull()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
3088 // node has a namespace -
3089 if (n->namespaceURI == nsURI && n->name == localName)
partially evaluated: n->namespaceURI == nsURI
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: n->name == localName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
3090 return n;
never executed: return n;
0
3091 }
executed: }
Execution Count:1
1
3092 }
executed: }
Execution Count:1
1
3093 return 0;
executed: return 0;
Execution Count:13
13
3094} -
3095 -
3096QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItem(QDomNodePrivate* arg) -
3097{ -
3098 if (readonly || !arg)
partially evaluated: readonly
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16754
partially evaluated: !arg
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16754
0-16754
3099 return 0;
never executed: return 0;
0
3100 -
3101 if (appendToParent)
partially evaluated: appendToParent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16754
0-16754
3102 return parent->appendChild(arg);
never executed: return parent->appendChild(arg);
0
3103 -
3104 QDomNodePrivate *n = map.value(arg->nodeName());
executed (the execution status of this line is deduced): QDomNodePrivate *n = map.value(arg->nodeName());
-
3105 // We take a reference -
3106 arg->ref.ref();
executed (the execution status of this line is deduced): arg->ref.ref();
-
3107 map.insertMulti(arg->nodeName(), arg);
executed (the execution status of this line is deduced): map.insertMulti(arg->nodeName(), arg);
-
3108 return n;
executed: return n;
Execution Count:16754
16754
3109} -
3110 -
3111QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItemNS(QDomNodePrivate* arg) -
3112{ -
3113 if (readonly || !arg)
never evaluated: readonly
never evaluated: !arg
0
3114 return 0;
never executed: return 0;
0
3115 -
3116 if (appendToParent)
never evaluated: appendToParent
0
3117 return parent->appendChild(arg);
never executed: return parent->appendChild(arg);
0
3118 -
3119 if (!arg->prefix.isNull()) {
never evaluated: !arg->prefix.isNull()
0
3120 // node has a namespace -
3121 QDomNodePrivate *n = namedItemNS(arg->namespaceURI, arg->name);
never executed (the execution status of this line is deduced): QDomNodePrivate *n = namedItemNS(arg->namespaceURI, arg->name);
-
3122 // We take a reference -
3123 arg->ref.ref();
never executed (the execution status of this line is deduced): arg->ref.ref();
-
3124 map.insertMulti(arg->nodeName(), arg);
never executed (the execution status of this line is deduced): map.insertMulti(arg->nodeName(), arg);
-
3125 return n;
never executed: return n;
0
3126 } else { -
3127 // ### check the following code if it is ok -
3128 return setNamedItem(arg);
never executed: return setNamedItem(arg);
0
3129 } -
3130} -
3131 -
3132QDomNodePrivate* QDomNamedNodeMapPrivate::removeNamedItem(const QString& name) -
3133{ -
3134 if (readonly)
never evaluated: readonly
0
3135 return 0;
never executed: return 0;
0
3136 -
3137 QDomNodePrivate* p = namedItem(name);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = namedItem(name);
-
3138 if (p == 0)
never evaluated: p == 0
0
3139 return 0;
never executed: return 0;
0
3140 if (appendToParent)
never evaluated: appendToParent
0
3141 return parent->removeChild(p);
never executed: return parent->removeChild(p);
0
3142 -
3143 map.remove(p->nodeName());
never executed (the execution status of this line is deduced): map.remove(p->nodeName());
-
3144 // We took a reference, so we have to free one here -
3145 p->ref.deref();
never executed (the execution status of this line is deduced): p->ref.deref();
-
3146 return p;
never executed: return p;
0
3147} -
3148 -
3149QDomNodePrivate* QDomNamedNodeMapPrivate::item(int index) const -
3150{ -
3151 if (index >= length())
evaluated: index >= length()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
3152 return 0;
executed: return 0;
Execution Count:1
1
3153 return *(map.constBegin() + index);
executed: return *(map.constBegin() + index);
Execution Count:1
1
3154} -
3155 -
3156int QDomNamedNodeMapPrivate::length() const -
3157{ -
3158 return map.count();
executed: return map.count();
Execution Count:83
83
3159} -
3160 -
3161bool QDomNamedNodeMapPrivate::contains(const QString& name) const -
3162{ -
3163 return map.value(name) != 0;
never executed: return map.value(name) != 0;
0
3164} -
3165 -
3166bool QDomNamedNodeMapPrivate::containsNS(const QString& nsURI, const QString & localName) const -
3167{ -
3168 return namedItemNS(nsURI, localName) != 0;
never executed: return namedItemNS(nsURI, localName) != 0;
0
3169} -
3170 -
3171/************************************************************** -
3172 * -
3173 * QDomNamedNodeMap -
3174 * -
3175 **************************************************************/ -
3176 -
3177#define IMPL ((QDomNamedNodeMapPrivate*)impl) -
3178 -
3179/*! -
3180 \class QDomNamedNodeMap -
3181 \reentrant -
3182 \brief The QDomNamedNodeMap class contains a collection of nodes -
3183 that can be accessed by name. -
3184 -
3185 \inmodule QtXml -
3186 \ingroup xml-tools -
3187 -
3188 Note that QDomNamedNodeMap does not inherit from QDomNodeList. -
3189 QDomNamedNodeMaps do not provide any specific node ordering. -
3190 Although nodes in a QDomNamedNodeMap may be accessed by an ordinal -
3191 index, this is simply to allow a convenient enumeration of the -
3192 contents of a QDomNamedNodeMap, and does not imply that the DOM -
3193 specifies an ordering of the nodes. -
3194 -
3195 The QDomNamedNodeMap is used in three places: -
3196 \list 1 -
3197 \li QDomDocumentType::entities() returns a map of all entities -
3198 described in the DTD. -
3199 \li QDomDocumentType::notations() returns a map of all notations -
3200 described in the DTD. -
3201 \li QDomNode::attributes() returns a map of all attributes of an -
3202 element. -
3203 \endlist -
3204 -
3205 Items in the map are identified by the name which QDomNode::name() -
3206 returns. Nodes are retrieved using namedItem(), namedItemNS() or -
3207 item(). New nodes are inserted with setNamedItem() or -
3208 setNamedItemNS() and removed with removeNamedItem() or -
3209 removeNamedItemNS(). Use contains() to see if an item with the -
3210 given name is in the named node map. The number of items is -
3211 returned by length(). -
3212 -
3213 Terminology: in this class we use "item" and "node" -
3214 interchangeably. -
3215*/ -
3216 -
3217/*! -
3218 Constructs an empty named node map. -
3219*/ -
3220QDomNamedNodeMap::QDomNamedNodeMap() -
3221{ -
3222 impl = 0;
executed (the execution status of this line is deduced): impl = 0;
-
3223}
executed: }
Execution Count:16
16
3224 -
3225/*! -
3226 Constructs a copy of \a n. -
3227*/ -
3228QDomNamedNodeMap::QDomNamedNodeMap(const QDomNamedNodeMap &n) -
3229{ -
3230 impl = n.impl;
never executed (the execution status of this line is deduced): impl = n.impl;
-
3231 if (impl)
never evaluated: impl
0
3232 impl->ref.ref();
never executed: impl->ref.ref();
0
3233}
never executed: }
0
3234 -
3235QDomNamedNodeMap::QDomNamedNodeMap(QDomNamedNodeMapPrivate *n) -
3236{ -
3237 impl = n;
executed (the execution status of this line is deduced): impl = n;
-
3238 if (impl)
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
3239 impl->ref.ref();
executed: impl->ref.ref();
Execution Count:13
13
3240}
executed: }
Execution Count:13
13
3241 -
3242/*! -
3243 Assigns \a n to this named node map. -
3244*/ -
3245QDomNamedNodeMap& QDomNamedNodeMap::operator=(const QDomNamedNodeMap &n) -
3246{ -
3247 if (n.impl)
never evaluated: n.impl
0
3248 n.impl->ref.ref();
never executed: n.impl->ref.ref();
0
3249 if (impl && !impl->ref.deref())
never evaluated: impl
never evaluated: !impl->ref.deref()
0
3250 delete impl;
never executed: delete impl;
0
3251 impl = n.impl;
never executed (the execution status of this line is deduced): impl = n.impl;
-
3252 return *this;
never executed: return *this;
0
3253} -
3254 -
3255/*! -
3256 Returns true if \a n and this named node map are equal; otherwise -
3257 returns false. -
3258*/ -
3259bool QDomNamedNodeMap::operator== (const QDomNamedNodeMap& n) const -
3260{ -
3261 return (impl == n.impl);
never executed: return (impl == n.impl);
0
3262} -
3263 -
3264/*! -
3265 Returns true if \a n and this named node map are not equal; -
3266 otherwise returns false. -
3267*/ -
3268bool QDomNamedNodeMap::operator!= (const QDomNamedNodeMap& n) const -
3269{ -
3270 return (impl != n.impl);
never executed: return (impl != n.impl);
0
3271} -
3272 -
3273/*! -
3274 Destroys the object and frees its resources. -
3275*/ -
3276QDomNamedNodeMap::~QDomNamedNodeMap() -
3277{ -
3278 if (impl && !impl->ref.deref())
evaluated: impl
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:16
partially evaluated: !impl->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-16
3279 delete impl;
never executed: delete impl;
0
3280}
executed: }
Execution Count:29
29
3281 -
3282/*! -
3283 Returns the node called \a name. -
3284 -
3285 If the named node map does not contain such a node, a -
3286 \l{QDomNode::isNull()}{null node} is returned. A node's name is -
3287 the name returned by QDomNode::nodeName(). -
3288 -
3289 \sa setNamedItem(), namedItemNS() -
3290*/ -
3291QDomNode QDomNamedNodeMap::namedItem(const QString& name) const -
3292{ -
3293 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
3294 return QDomNode();
never executed: return QDomNode();
0
3295 return QDomNode(IMPL->namedItem(name));
executed: return QDomNode(((QDomNamedNodeMapPrivate*)impl)->namedItem(name));
Execution Count:1
1
3296} -
3297 -
3298/*! -
3299 Inserts the node \a newNode into the named node map. The name used -
3300 by the map is the node name of \a newNode as returned by -
3301 QDomNode::nodeName(). -
3302 -
3303 If the new node replaces an existing node, i.e. the map contains a -
3304 node with the same name, the replaced node is returned. -
3305 -
3306 \sa namedItem(), removeNamedItem(), setNamedItemNS() -
3307*/ -
3308QDomNode QDomNamedNodeMap::setNamedItem(const QDomNode& newNode) -
3309{ -
3310 if (!impl)
never evaluated: !impl
0
3311 return QDomNode();
never executed: return QDomNode();
0
3312 return QDomNode(IMPL->setNamedItem((QDomNodePrivate*)newNode.impl));
never executed: return QDomNode(((QDomNamedNodeMapPrivate*)impl)->setNamedItem((QDomNodePrivate*)newNode.impl));
0
3313} -
3314 -
3315/*! -
3316 Removes the node called \a name from the map. -
3317 -
3318 The function returns the removed node or a -
3319 \l{QDomNode::isNull()}{null node} if the map did not contain a -
3320 node called \a name. -
3321 -
3322 \sa setNamedItem(), namedItem(), removeNamedItemNS() -
3323*/ -
3324QDomNode QDomNamedNodeMap::removeNamedItem(const QString& name) -
3325{ -
3326 if (!impl)
never evaluated: !impl
0
3327 return QDomNode();
never executed: return QDomNode();
0
3328 return QDomNode(IMPL->removeNamedItem(name));
never executed: return QDomNode(((QDomNamedNodeMapPrivate*)impl)->removeNamedItem(name));
0
3329} -
3330 -
3331/*! -
3332 Retrieves the node at position \a index. -
3333 -
3334 This can be used to iterate over the map. Note that the nodes in -
3335 the map are ordered arbitrarily. -
3336 -
3337 \sa length() -
3338*/ -
3339QDomNode QDomNamedNodeMap::item(int index) const -
3340{ -
3341 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
3342 return QDomNode();
never executed: return QDomNode();
0
3343 return QDomNode(IMPL->item(index));
executed: return QDomNode(((QDomNamedNodeMapPrivate*)impl)->item(index));
Execution Count:2
2
3344} -
3345 -
3346/*! -
3347 Returns the node associated with the local name \a localName and -
3348 the namespace URI \a nsURI. -
3349 -
3350 If the map does not contain such a node, -
3351 a \l{QDomNode::isNull()}{null node} is returned. -
3352 -
3353 \sa setNamedItemNS(), namedItem() -
3354*/ -
3355QDomNode QDomNamedNodeMap::namedItemNS(const QString& nsURI, const QString& localName) const -
3356{ -
3357 if (!impl)
never evaluated: !impl
0
3358 return QDomNode();
never executed: return QDomNode();
0
3359 return QDomNode(IMPL->namedItemNS(nsURI, localName));
never executed: return QDomNode(((QDomNamedNodeMapPrivate*)impl)->namedItemNS(nsURI, localName));
0
3360} -
3361 -
3362/*! -
3363 Inserts the node \a newNode in the map. If a node with the same -
3364 namespace URI and the same local name already exists in the map, -
3365 it is replaced by \a newNode. If the new node replaces an existing -
3366 node, the replaced node is returned. -
3367 -
3368 \sa namedItemNS(), removeNamedItemNS(), setNamedItem() -
3369*/ -
3370QDomNode QDomNamedNodeMap::setNamedItemNS(const QDomNode& newNode) -
3371{ -
3372 if (!impl)
never evaluated: !impl
0
3373 return QDomNode();
never executed: return QDomNode();
0
3374 return QDomNode(IMPL->setNamedItemNS((QDomNodePrivate*)newNode.impl));
never executed: return QDomNode(((QDomNamedNodeMapPrivate*)impl)->setNamedItemNS((QDomNodePrivate*)newNode.impl));
0
3375} -
3376 -
3377/*! -
3378 Removes the node with the local name \a localName and the -
3379 namespace URI \a nsURI from the map. -
3380 -
3381 The function returns the removed node or a -
3382 \l{QDomNode::isNull()}{null node} if the map did not contain a -
3383 node with the local name \a localName and the namespace URI \a -
3384 nsURI. -
3385 -
3386 \sa setNamedItemNS(), namedItemNS(), removeNamedItem() -
3387*/ -
3388QDomNode QDomNamedNodeMap::removeNamedItemNS(const QString& nsURI, const QString& localName) -
3389{ -
3390 if (!impl)
never evaluated: !impl
0
3391 return QDomNode();
never executed: return QDomNode();
0
3392 QDomNodePrivate *n = IMPL->namedItemNS(nsURI, localName);
never executed (the execution status of this line is deduced): QDomNodePrivate *n = ((QDomNamedNodeMapPrivate*)impl)->namedItemNS(nsURI, localName);
-
3393 if (!n)
never evaluated: !n
0
3394 return QDomNode();
never executed: return QDomNode();
0
3395 return QDomNode(IMPL->removeNamedItem(n->name));
never executed: return QDomNode(((QDomNamedNodeMapPrivate*)impl)->removeNamedItem(n->name));
0
3396} -
3397 -
3398/*! -
3399 Returns the number of nodes in the map. -
3400 -
3401 \sa item() -
3402*/ -
3403int QDomNamedNodeMap::length() const -
3404{ -
3405 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:11
11-16
3406 return 0;
executed: return 0;
Execution Count:16
16
3407 return IMPL->length();
executed: return ((QDomNamedNodeMapPrivate*)impl)->length();
Execution Count:11
11
3408} -
3409 -
3410/*! -
3411 \fn bool QDomNamedNodeMap::isEmpty() const -
3412 -
3413 Returns true if the map is empty; otherwise returns false. This function is -
3414 provided for Qt API consistency. -
3415*/ -
3416 -
3417/*! -
3418 \fn int QDomNamedNodeMap::count() const -
3419 -
3420 This function is provided for Qt API consistency. It is equivalent to length(). -
3421*/ -
3422 -
3423/*! -
3424 \fn int QDomNamedNodeMap::size() const -
3425 -
3426 This function is provided for Qt API consistency. It is equivalent to length(). -
3427*/ -
3428 -
3429/*! -
3430 Returns true if the map contains a node called \a name; otherwise -
3431 returns false. -
3432 -
3433 \b{Note:} This function does not take the presence of namespaces into account. -
3434 Use namedItemNS() to test whether the map contains a node with a specific namespace -
3435 URI and name. -
3436*/ -
3437bool QDomNamedNodeMap::contains(const QString& name) const -
3438{ -
3439 if (!impl)
never evaluated: !impl
0
3440 return false;
never executed: return false;
0
3441 return IMPL->contains(name);
never executed: return ((QDomNamedNodeMapPrivate*)impl)->contains(name);
0
3442} -
3443 -
3444#undef IMPL -
3445 -
3446/************************************************************** -
3447 * -
3448 * QDomDocumentTypePrivate -
3449 * -
3450 **************************************************************/ -
3451 -
3452QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentPrivate* doc, QDomNodePrivate* parent) -
3453 : QDomNodePrivate(doc, parent) -
3454{ -
3455 init();
executed (the execution status of this line is deduced): init();
-
3456}
executed: }
Execution Count:856
856
3457 -
3458QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentTypePrivate* n, bool deep) -
3459 : QDomNodePrivate(n, deep) -
3460{ -
3461 init();
executed (the execution status of this line is deduced): init();
-
3462 // Refill the maps with our new children -
3463 QDomNodePrivate* p = first;
executed (the execution status of this line is deduced): QDomNodePrivate* p = first;
-
3464 while (p) {
evaluated: p
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
3465 if (p->isEntity())
partially evaluated: p->isEntity()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
3466 // Don't use normal insert function since we would create infinite recursion -
3467 entities->map.insertMulti(p->nodeName(), p);
executed: entities->map.insertMulti(p->nodeName(), p);
Execution Count:2
2
3468 if (p->isNotation())
partially evaluated: p->isNotation()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
3469 // Don't use normal insert function since we would create infinite recursion -
3470 notations->map.insertMulti(p->nodeName(), p);
never executed: notations->map.insertMulti(p->nodeName(), p);
0
3471 p = p->next;
executed (the execution status of this line is deduced): p = p->next;
-
3472 }
executed: }
Execution Count:2
2
3473}
executed: }
Execution Count:1
1
3474 -
3475QDomDocumentTypePrivate::~QDomDocumentTypePrivate() -
3476{ -
3477 if (!entities->ref.deref())
partially evaluated: !entities->ref.deref()
TRUEFALSE
yes
Evaluation Count:857
no
Evaluation Count:0
0-857
3478 delete entities;
executed: delete entities;
Execution Count:857
857
3479 if (!notations->ref.deref())
partially evaluated: !notations->ref.deref()
TRUEFALSE
yes
Evaluation Count:857
no
Evaluation Count:0
0-857
3480 delete notations;
executed: delete notations;
Execution Count:857
857
3481}
executed: }
Execution Count:857
857
3482 -
3483void QDomDocumentTypePrivate::init() -
3484{ -
3485 entities = new QDomNamedNodeMapPrivate(this);
executed (the execution status of this line is deduced): entities = new QDomNamedNodeMapPrivate(this);
-
3486 QT_TRY {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:857
no
Evaluation Count:0
0-857
3487 notations = new QDomNamedNodeMapPrivate(this);
executed (the execution status of this line is deduced): notations = new QDomNamedNodeMapPrivate(this);
-
3488 publicId.clear();
executed (the execution status of this line is deduced): publicId.clear();
-
3489 systemId.clear();
executed (the execution status of this line is deduced): systemId.clear();
-
3490 internalSubset.clear();
executed (the execution status of this line is deduced): internalSubset.clear();
-
3491 -
3492 entities->setAppendToParent(true);
executed (the execution status of this line is deduced): entities->setAppendToParent(true);
-
3493 notations->setAppendToParent(true);
executed (the execution status of this line is deduced): notations->setAppendToParent(true);
-
3494 } QT_CATCH(...) {
executed: }
Execution Count:857
857
3495 delete entities;
never executed (the execution status of this line is deduced): delete entities;
-
3496 QT_RETHROW;
never executed (the execution status of this line is deduced): qt_noop();
-
3497 }
never executed: }
0
3498} -
3499 -
3500QDomNodePrivate* QDomDocumentTypePrivate::cloneNode(bool deep) -
3501{ -
3502 QDomNodePrivate* p = new QDomDocumentTypePrivate(this, deep);
executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomDocumentTypePrivate(this, deep);
-
3503 // We are not interested in this node -
3504 p->ref.deref();
executed (the execution status of this line is deduced): p->ref.deref();
-
3505 return p;
executed: return p;
Execution Count:1
1
3506} -
3507 -
3508QDomNodePrivate* QDomDocumentTypePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild) -
3509{ -
3510 // Call the origianl implementation -
3511 QDomNodePrivate* p = QDomNodePrivate::insertBefore(newChild, refChild);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = QDomNodePrivate::insertBefore(newChild, refChild);
-
3512 // Update the maps -
3513 if (p && p->isEntity())
never evaluated: p
never evaluated: p->isEntity()
0
3514 entities->map.insertMulti(p->nodeName(), p);
never executed: entities->map.insertMulti(p->nodeName(), p);
0
3515 else if (p && p->isNotation())
never evaluated: p
never evaluated: p->isNotation()
0
3516 notations->map.insertMulti(p->nodeName(), p);
never executed: notations->map.insertMulti(p->nodeName(), p);
0
3517 -
3518 return p;
never executed: return p;
0
3519} -
3520 -
3521QDomNodePrivate* QDomDocumentTypePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild) -
3522{ -
3523 // Call the origianl implementation -
3524 QDomNodePrivate* p = QDomNodePrivate::insertAfter(newChild, refChild);
executed (the execution status of this line is deduced): QDomNodePrivate* p = QDomNodePrivate::insertAfter(newChild, refChild);
-
3525 // Update the maps -
3526 if (p && p->isEntity())
partially evaluated: p
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
evaluated: p->isEntity()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
0-8
3527 entities->map.insertMulti(p->nodeName(), p);
executed: entities->map.insertMulti(p->nodeName(), p);
Execution Count:6
6
3528 else if (p && p->isNotation())
partially evaluated: p
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: p->isNotation()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
3529 notations->map.insertMulti(p->nodeName(), p);
executed: notations->map.insertMulti(p->nodeName(), p);
Execution Count:2
2
3530 -
3531 return p;
executed: return p;
Execution Count:8
8
3532} -
3533 -
3534QDomNodePrivate* QDomDocumentTypePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild) -
3535{ -
3536 // Call the origianl implementation -
3537 QDomNodePrivate* p = QDomNodePrivate::replaceChild(newChild, oldChild);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = QDomNodePrivate::replaceChild(newChild, oldChild);
-
3538 // Update the maps -
3539 if (p) {
never evaluated: p
0
3540 if (oldChild && oldChild->isEntity())
never evaluated: oldChild
never evaluated: oldChild->isEntity()
0
3541 entities->map.remove(oldChild->nodeName());
never executed: entities->map.remove(oldChild->nodeName());
0
3542 else if (oldChild && oldChild->isNotation())
never evaluated: oldChild
never evaluated: oldChild->isNotation()
0
3543 notations->map.remove(oldChild->nodeName());
never executed: notations->map.remove(oldChild->nodeName());
0
3544 -
3545 if (p->isEntity())
never evaluated: p->isEntity()
0
3546 entities->map.insertMulti(p->nodeName(), p);
never executed: entities->map.insertMulti(p->nodeName(), p);
0
3547 else if (p->isNotation())
never evaluated: p->isNotation()
0
3548 notations->map.insertMulti(p->nodeName(), p);
never executed: notations->map.insertMulti(p->nodeName(), p);
0
3549 } -
3550 -
3551 return p;
never executed: return p;
0
3552} -
3553 -
3554QDomNodePrivate* QDomDocumentTypePrivate::removeChild(QDomNodePrivate* oldChild) -
3555{ -
3556 // Call the origianl implementation -
3557 QDomNodePrivate* p = QDomNodePrivate::removeChild( oldChild);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = QDomNodePrivate::removeChild( oldChild);
-
3558 // Update the maps -
3559 if (p && p->isEntity())
never evaluated: p
never evaluated: p->isEntity()
0
3560 entities->map.remove(p->nodeName());
never executed: entities->map.remove(p->nodeName());
0
3561 else if (p && p->isNotation())
never evaluated: p
never evaluated: p->isNotation()
0
3562 notations->map.remove(p ->nodeName());
never executed: notations->map.remove(p ->nodeName());
0
3563 -
3564 return p;
never executed: return p;
0
3565} -
3566 -
3567QDomNodePrivate* QDomDocumentTypePrivate::appendChild(QDomNodePrivate* newChild) -
3568{ -
3569 return insertAfter(newChild, 0);
executed: return insertAfter(newChild, 0);
Execution Count:8
8
3570} -
3571 -
3572static QString quotedValue(const QString &data) -
3573{ -
3574 QChar quote = data.indexOf(QLatin1Char('\'')) == -1
partially evaluated: data.indexOf(QLatin1Char('\'')) == -1
TRUEFALSE
yes
Evaluation Count:27
no
Evaluation Count:0
0-27
3575 ? QLatin1Char('\'')
executed (the execution status of this line is deduced): ? QLatin1Char('\'')
-
3576 : QLatin1Char('"');
executed (the execution status of this line is deduced): : QLatin1Char('"');
-
3577 return quote + data + quote;
executed: return quote + data + quote;
Execution Count:27
27
3578} -
3579 -
3580void QDomDocumentTypePrivate::save(QTextStream& s, int, int indent) const -
3581{ -
3582 if (name.isEmpty())
evaluated: name.isEmpty()
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:32
32-134
3583 return;
executed: return;
Execution Count:134
134
3584 -
3585 s << "<!DOCTYPE " << name;
executed (the execution status of this line is deduced): s << "<!DOCTYPE " << name;
-
3586 -
3587 if (!publicId.isNull()) {
partially evaluated: !publicId.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
3588 s << " PUBLIC " << quotedValue(publicId);
never executed (the execution status of this line is deduced): s << " PUBLIC " << quotedValue(publicId);
-
3589 if (!systemId.isNull()) {
never evaluated: !systemId.isNull()
0
3590 s << ' ' << quotedValue(systemId);
never executed (the execution status of this line is deduced): s << ' ' << quotedValue(systemId);
-
3591 }
never executed: }
0
3592 } else if (!systemId.isNull()) {
never executed: }
evaluated: !systemId.isNull()
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:7
0-25
3593 s << " SYSTEM " << quotedValue(systemId);
executed (the execution status of this line is deduced): s << " SYSTEM " << quotedValue(systemId);
-
3594 }
executed: }
Execution Count:25
25
3595 -
3596 if (entities->length()>0 || notations->length()>0) {
evaluated: entities->length()>0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:29
partially evaluated: notations->length()>0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29
0-29
3597 s << " [" << endl;
executed (the execution status of this line is deduced): s << " [" << endl;
-
3598 -
3599 QHash<QString, QDomNodePrivate *>::const_iterator it2 = notations->map.constBegin();
executed (the execution status of this line is deduced): QHash<QString, QDomNodePrivate *>::const_iterator it2 = notations->map.constBegin();
-
3600 for (; it2 != notations->map.constEnd(); ++it2)
partially evaluated: it2 != notations->map.constEnd()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
3601 (*it2)->save(s, 0, indent);
never executed: (*it2)->save(s, 0, indent);
0
3602 -
3603 QHash<QString, QDomNodePrivate *>::const_iterator it = entities->map.constBegin();
executed (the execution status of this line is deduced): QHash<QString, QDomNodePrivate *>::const_iterator it = entities->map.constBegin();
-
3604 for (; it != entities->map.constEnd(); ++it)
evaluated: it != entities->map.constEnd()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3
3-4
3605 (*it)->save(s, 0, indent);
executed: (*it)->save(s, 0, indent);
Execution Count:4
4
3606 -
3607 s << ']';
executed (the execution status of this line is deduced): s << ']';
-
3608 }
executed: }
Execution Count:3
3
3609 -
3610 s << '>' << endl;
executed (the execution status of this line is deduced): s << '>' << endl;
-
3611}
executed: }
Execution Count:32
32
3612 -
3613/************************************************************** -
3614 * -
3615 * QDomDocumentType -
3616 * -
3617 **************************************************************/ -
3618 -
3619#define IMPL ((QDomDocumentTypePrivate*)impl) -
3620 -
3621/*! -
3622 \class QDomDocumentType -
3623 \reentrant -
3624 \brief The QDomDocumentType class is the representation of the DTD -
3625 in the document tree. -
3626 -
3627 \inmodule QtXml -
3628 \ingroup xml-tools -
3629 -
3630 The QDomDocumentType class allows read-only access to some of the -
3631 data structures in the DTD: it can return a map of all entities() -
3632 and notations(). In addition the function name() returns the name -
3633 of the document type as specified in the &lt;!DOCTYPE name&gt; -
3634 tag. This class also provides the publicId(), systemId() and -
3635 internalSubset() functions. -
3636 -
3637 \sa QDomDocument -
3638*/ -
3639 -
3640/*! -
3641 Creates an empty QDomDocumentType object. -
3642*/ -
3643QDomDocumentType::QDomDocumentType() : QDomNode() -
3644{ -
3645}
executed: }
Execution Count:18
18
3646 -
3647/*! -
3648 Constructs a copy of \a n. -
3649 -
3650 The data of the copy is shared (shallow copy): modifying one node -
3651 will also change the other. If you want to make a deep copy, use -
3652 cloneNode(). -
3653*/ -
3654QDomDocumentType::QDomDocumentType(const QDomDocumentType& n) -
3655 : QDomNode(n) -
3656{ -
3657}
never executed: }
0
3658 -
3659QDomDocumentType::QDomDocumentType(QDomDocumentTypePrivate* n) -
3660 : QDomNode(n) -
3661{ -
3662}
executed: }
Execution Count:12
12
3663 -
3664/*! -
3665 Assigns \a n to this document type. -
3666 -
3667 The data of the copy is shared (shallow copy): modifying one node -
3668 will also change the other. If you want to make a deep copy, use -
3669 cloneNode(). -
3670*/ -
3671QDomDocumentType& QDomDocumentType::operator= (const QDomDocumentType& n) -
3672{ -
3673 return (QDomDocumentType&) QDomNode::operator=(n);
never executed: return (QDomDocumentType&) QDomNode::operator=(n);
0
3674} -
3675 -
3676/*! -
3677 Returns the name of the document type as specified in the -
3678 &lt;!DOCTYPE name&gt; tag. -
3679 -
3680 \sa nodeName() -
3681*/ -
3682QString QDomDocumentType::name() const -
3683{ -
3684 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
3685 return QString();
never executed: return QString();
0
3686 return IMPL->nodeName();
executed: return ((QDomDocumentTypePrivate*)impl)->nodeName();
Execution Count:10
10
3687} -
3688 -
3689/*! -
3690 Returns a map of all entities described in the DTD. -
3691*/ -
3692QDomNamedNodeMap QDomDocumentType::entities() const -
3693{ -
3694 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
3695 return QDomNamedNodeMap();
never executed: return QDomNamedNodeMap();
0
3696 return QDomNamedNodeMap(IMPL->entities);
executed: return QDomNamedNodeMap(((QDomDocumentTypePrivate*)impl)->entities);
Execution Count:1
1
3697} -
3698 -
3699/*! -
3700 Returns a map of all notations described in the DTD. -
3701*/ -
3702QDomNamedNodeMap QDomDocumentType::notations() const -
3703{ -
3704 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
3705 return QDomNamedNodeMap();
never executed: return QDomNamedNodeMap();
0
3706 return QDomNamedNodeMap(IMPL->notations);
executed: return QDomNamedNodeMap(((QDomDocumentTypePrivate*)impl)->notations);
Execution Count:1
1
3707} -
3708 -
3709/*! -
3710 Returns the public identifier of the external DTD subset or -
3711 an empty string if there is no public identifier. -
3712 -
3713 \sa systemId(), internalSubset(), QDomImplementation::createDocumentType() -
3714*/ -
3715QString QDomDocumentType::publicId() const -
3716{ -
3717 if (!impl)
never evaluated: !impl
0
3718 return QString();
never executed: return QString();
0
3719 return IMPL->publicId;
never executed: return ((QDomDocumentTypePrivate*)impl)->publicId;
0
3720} -
3721 -
3722/*! -
3723 Returns the system identifier of the external DTD subset or -
3724 an empty string if there is no system identifier. -
3725 -
3726 \sa publicId(), internalSubset(), QDomImplementation::createDocumentType() -
3727*/ -
3728QString QDomDocumentType::systemId() const -
3729{ -
3730 if (!impl)
never evaluated: !impl
0
3731 return QString();
never executed: return QString();
0
3732 return IMPL->systemId;
never executed: return ((QDomDocumentTypePrivate*)impl)->systemId;
0
3733} -
3734 -
3735/*! -
3736 Returns the internal subset of the document type or an empty -
3737 string if there is no internal subset. -
3738 -
3739 \sa publicId(), systemId() -
3740*/ -
3741QString QDomDocumentType::internalSubset() const -
3742{ -
3743 if (!impl)
never evaluated: !impl
0
3744 return QString();
never executed: return QString();
0
3745 return IMPL->internalSubset;
never executed: return ((QDomDocumentTypePrivate*)impl)->internalSubset;
0
3746} -
3747 -
3748/* -
3749 Are these needed at all? The only difference when removing these -
3750 two methods in all subclasses is that we'd get a different type -
3751 for null nodes. -
3752*/ -
3753 -
3754/*! -
3755 \fn QDomNode::NodeType QDomDocumentType::nodeType() const -
3756 -
3757 Returns \c DocumentTypeNode. -
3758 -
3759 \sa isDocumentType(), QDomNode::toDocumentType() -
3760*/ -
3761 -
3762#undef IMPL -
3763 -
3764/************************************************************** -
3765 * -
3766 * QDomDocumentFragmentPrivate -
3767 * -
3768 **************************************************************/ -
3769 -
3770QDomDocumentFragmentPrivate::QDomDocumentFragmentPrivate(QDomDocumentPrivate* doc, QDomNodePrivate* parent) -
3771 : QDomNodePrivate(doc, parent) -
3772{ -
3773 name = QLatin1String("#document-fragment");
executed (the execution status of this line is deduced): name = QLatin1String("#document-fragment");
-
3774}
executed: }
Execution Count:19
19
3775 -
3776QDomDocumentFragmentPrivate::QDomDocumentFragmentPrivate(QDomNodePrivate* n, bool deep) -
3777 : QDomNodePrivate(n, deep) -
3778{ -
3779}
executed: }
Execution Count:6
6
3780 -
3781QDomNodePrivate* QDomDocumentFragmentPrivate::cloneNode(bool deep) -
3782{ -
3783 QDomNodePrivate* p = new QDomDocumentFragmentPrivate(this, deep);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomDocumentFragmentPrivate(this, deep);
-
3784 // We are not interested in this node -
3785 p->ref.deref();
never executed (the execution status of this line is deduced): p->ref.deref();
-
3786 return p;
never executed: return p;
0
3787} -
3788 -
3789/************************************************************** -
3790 * -
3791 * QDomDocumentFragment -
3792 * -
3793 **************************************************************/ -
3794 -
3795/*! -
3796 \class QDomDocumentFragment -
3797 \reentrant -
3798 \brief The QDomDocumentFragment class is a tree of QDomNodes which is not usually a complete QDomDocument. -
3799 -
3800 \inmodule QtXml -
3801 \ingroup xml-tools -
3802 -
3803 If you want to do complex tree operations it is useful to have a -
3804 lightweight class to store nodes and their relations. -
3805 QDomDocumentFragment stores a subtree of a document which does not -
3806 necessarily represent a well-formed XML document. -
3807 -
3808 QDomDocumentFragment is also useful if you want to group several -
3809 nodes in a list and insert them all together as children of some -
3810 node. In these cases QDomDocumentFragment can be used as a -
3811 temporary container for this list of children. -
3812 -
3813 The most important feature of QDomDocumentFragment is that it is -
3814 treated in a special way by QDomNode::insertAfter(), -
3815 QDomNode::insertBefore(), QDomNode::replaceChild() and -
3816 QDomNode::appendChild(): instead of inserting the fragment itself, all -
3817 the fragment's children are inserted. -
3818*/ -
3819 -
3820/*! -
3821 Constructs an empty document fragment. -
3822*/ -
3823QDomDocumentFragment::QDomDocumentFragment() -
3824{ -
3825} -
3826 -
3827QDomDocumentFragment::QDomDocumentFragment(QDomDocumentFragmentPrivate* n) -
3828 : QDomNode(n) -
3829{ -
3830}
executed: }
Execution Count:19
19
3831 -
3832/*! -
3833 Constructs a copy of \a x. -
3834 -
3835 The data of the copy is shared (shallow copy): modifying one node -
3836 will also change the other. If you want to make a deep copy, use -
3837 cloneNode(). -
3838*/ -
3839QDomDocumentFragment::QDomDocumentFragment(const QDomDocumentFragment& x) -
3840 : QDomNode(x) -
3841{ -
3842}
never executed: }
0
3843 -
3844/*! -
3845 Assigns \a x to this DOM document fragment. -
3846 -
3847 The data of the copy is shared (shallow copy): modifying one node -
3848 will also change the other. If you want to make a deep copy, use -
3849 cloneNode(). -
3850*/ -
3851QDomDocumentFragment& QDomDocumentFragment::operator= (const QDomDocumentFragment& x) -
3852{ -
3853 return (QDomDocumentFragment&) QDomNode::operator=(x);
never executed: return (QDomDocumentFragment&) QDomNode::operator=(x);
0
3854} -
3855 -
3856/*! -
3857 \fn QDomNode::NodeType QDomDocumentFragment::nodeType() const -
3858 -
3859 Returns \c DocumentFragment. -
3860 -
3861 \sa isDocumentFragment(), QDomNode::toDocumentFragment() -
3862*/ -
3863 -
3864/************************************************************** -
3865 * -
3866 * QDomCharacterDataPrivate -
3867 * -
3868 **************************************************************/ -
3869 -
3870QDomCharacterDataPrivate::QDomCharacterDataPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p, -
3871 const QString& data) -
3872 : QDomNodePrivate(d, p) -
3873{ -
3874 value = data;
executed (the execution status of this line is deduced): value = data;
-
3875 name = QLatin1String("#character-data");
executed (the execution status of this line is deduced): name = QLatin1String("#character-data");
-
3876}
executed: }
Execution Count:55284
55284
3877 -
3878QDomCharacterDataPrivate::QDomCharacterDataPrivate(QDomCharacterDataPrivate* n, bool deep) -
3879 : QDomNodePrivate(n, deep) -
3880{ -
3881}
executed: }
Execution Count:19
19
3882 -
3883QDomNodePrivate* QDomCharacterDataPrivate::cloneNode(bool deep) -
3884{ -
3885 QDomNodePrivate* p = new QDomCharacterDataPrivate(this, deep);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomCharacterDataPrivate(this, deep);
-
3886 // We are not interested in this node -
3887 p->ref.deref();
never executed (the execution status of this line is deduced): p->ref.deref();
-
3888 return p;
never executed: return p;
0
3889} -
3890 -
3891int QDomCharacterDataPrivate::dataLength() const -
3892{ -
3893 return value.length();
never executed: return value.length();
0
3894} -
3895 -
3896QString QDomCharacterDataPrivate::substringData(unsigned long offset, unsigned long n) const -
3897{ -
3898 return value.mid(offset, n);
never executed: return value.mid(offset, n);
0
3899} -
3900 -
3901void QDomCharacterDataPrivate::insertData(unsigned long offset, const QString& arg) -
3902{ -
3903 value.insert(offset, arg);
never executed (the execution status of this line is deduced): value.insert(offset, arg);
-
3904}
never executed: }
0
3905 -
3906void QDomCharacterDataPrivate::deleteData(unsigned long offset, unsigned long n) -
3907{ -
3908 value.remove(offset, n);
never executed (the execution status of this line is deduced): value.remove(offset, n);
-
3909}
never executed: }
0
3910 -
3911void QDomCharacterDataPrivate::replaceData(unsigned long offset, unsigned long n, const QString& arg) -
3912{ -
3913 value.replace(offset, n, arg);
never executed (the execution status of this line is deduced): value.replace(offset, n, arg);
-
3914}
never executed: }
0
3915 -
3916void QDomCharacterDataPrivate::appendData(const QString& arg) -
3917{ -
3918 value += arg;
never executed (the execution status of this line is deduced): value += arg;
-
3919}
never executed: }
0
3920 -
3921/************************************************************** -
3922 * -
3923 * QDomCharacterData -
3924 * -
3925 **************************************************************/ -
3926 -
3927#define IMPL ((QDomCharacterDataPrivate*)impl) -
3928 -
3929/*! -
3930 \class QDomCharacterData -
3931 \reentrant -
3932 \brief The QDomCharacterData class represents a generic string in the DOM. -
3933 -
3934 \inmodule QtXml -
3935 \ingroup xml-tools -
3936 -
3937 Character data as used in XML specifies a generic data string. -
3938 More specialized versions of this class are QDomText, QDomComment -
3939 and QDomCDATASection. -
3940 -
3941 The data string is set with setData() and retrieved with data(). -
3942 You can retrieve a portion of the data string using -
3943 substringData(). Extra data can be appended with appendData(), or -
3944 inserted with insertData(). Portions of the data string can be -
3945 deleted with deleteData() or replaced with replaceData(). The -
3946 length of the data string is returned by length(). -
3947 -
3948 The node type of the node containing this character data is -
3949 returned by nodeType(). -
3950 -
3951 \sa QDomText, QDomComment, QDomCDATASection -
3952*/ -
3953 -
3954/*! -
3955 Constructs an empty character data object. -
3956*/ -
3957QDomCharacterData::QDomCharacterData() -
3958{ -
3959} -
3960 -
3961/*! -
3962 Constructs a copy of \a x. -
3963 -
3964 The data of the copy is shared (shallow copy): modifying one node -
3965 will also change the other. If you want to make a deep copy, use -
3966 cloneNode(). -
3967*/ -
3968QDomCharacterData::QDomCharacterData(const QDomCharacterData& x) -
3969 : QDomNode(x) -
3970{ -
3971}
never executed: }
0
3972 -
3973QDomCharacterData::QDomCharacterData(QDomCharacterDataPrivate* n) -
3974 : QDomNode(n) -
3975{ -
3976}
executed: }
Execution Count:87
87
3977 -
3978/*! -
3979 Assigns \a x to this character data. -
3980 -
3981 The data of the copy is shared (shallow copy): modifying one node -
3982 will also change the other. If you want to make a deep copy, use -
3983 cloneNode(). -
3984*/ -
3985QDomCharacterData& QDomCharacterData::operator= (const QDomCharacterData& x) -
3986{ -
3987 return (QDomCharacterData&) QDomNode::operator=(x);
never executed: return (QDomCharacterData&) QDomNode::operator=(x);
0
3988} -
3989 -
3990/*! -
3991 Returns the string stored in this object. -
3992 -
3993 If the node is a \l{isNull()}{null node}, it will return -
3994 an empty string. -
3995*/ -
3996QString QDomCharacterData::data() const -
3997{ -
3998 if (!impl)
never evaluated: !impl
0
3999 return QString();
never executed: return QString();
0
4000 return impl->nodeValue();
never executed: return impl->nodeValue();
0
4001} -
4002 -
4003/*! -
4004 Sets this object's string to \a v. -
4005*/ -
4006void QDomCharacterData::setData(const QString& v) -
4007{ -
4008 if (impl)
never evaluated: impl
0
4009 impl->setNodeValue(v);
never executed: impl->setNodeValue(v);
0
4010}
never executed: }
0
4011 -
4012/*! -
4013 Returns the length of the stored string. -
4014*/ -
4015int QDomCharacterData::length() const -
4016{ -
4017 if (impl)
never evaluated: impl
0
4018 return IMPL->dataLength();
never executed: return ((QDomCharacterDataPrivate*)impl)->dataLength();
0
4019 return 0;
never executed: return 0;
0
4020} -
4021 -
4022/*! -
4023 Returns the substring of length \a count from position \a offset. -
4024*/ -
4025QString QDomCharacterData::substringData(unsigned long offset, unsigned long count) -
4026{ -
4027 if (!impl)
never evaluated: !impl
0
4028 return QString();
never executed: return QString();
0
4029 return IMPL->substringData(offset, count);
never executed: return ((QDomCharacterDataPrivate*)impl)->substringData(offset, count);
0
4030} -
4031 -
4032/*! -
4033 Appends the string \a arg to the stored string. -
4034*/ -
4035void QDomCharacterData::appendData(const QString& arg) -
4036{ -
4037 if (impl)
never evaluated: impl
0
4038 IMPL->appendData(arg);
never executed: ((QDomCharacterDataPrivate*)impl)->appendData(arg);
0
4039}
never executed: }
0
4040 -
4041/*! -
4042 Inserts the string \a arg into the stored string at position \a offset. -
4043*/ -
4044void QDomCharacterData::insertData(unsigned long offset, const QString& arg) -
4045{ -
4046 if (impl)
never evaluated: impl
0
4047 IMPL->insertData(offset, arg);
never executed: ((QDomCharacterDataPrivate*)impl)->insertData(offset, arg);
0
4048}
never executed: }
0
4049 -
4050/*! -
4051 Deletes a substring of length \a count from position \a offset. -
4052*/ -
4053void QDomCharacterData::deleteData(unsigned long offset, unsigned long count) -
4054{ -
4055 if (impl)
never evaluated: impl
0
4056 IMPL->deleteData(offset, count);
never executed: ((QDomCharacterDataPrivate*)impl)->deleteData(offset, count);
0
4057}
never executed: }
0
4058 -
4059/*! -
4060 Replaces the substring of length \a count starting at position \a -
4061 offset with the string \a arg. -
4062*/ -
4063void QDomCharacterData::replaceData(unsigned long offset, unsigned long count, const QString& arg) -
4064{ -
4065 if (impl)
never evaluated: impl
0
4066 IMPL->replaceData(offset, count, arg);
never executed: ((QDomCharacterDataPrivate*)impl)->replaceData(offset, count, arg);
0
4067}
never executed: }
0
4068 -
4069/*! -
4070 Returns the type of node this object refers to (i.e. \c TextNode, -
4071 \c CDATASectionNode, \c CommentNode or \c CharacterDataNode). For -
4072 a \l{isNull()}{null node}, returns \c CharacterDataNode. -
4073*/ -
4074QDomNode::NodeType QDomCharacterData::nodeType() const -
4075{ -
4076 if (!impl)
never evaluated: !impl
0
4077 return CharacterDataNode;
never executed: return CharacterDataNode;
0
4078 return QDomNode::nodeType();
never executed: return QDomNode::nodeType();
0
4079} -
4080 -
4081#undef IMPL -
4082 -
4083/************************************************************** -
4084 * -
4085 * QDomAttrPrivate -
4086 * -
4087 **************************************************************/ -
4088 -
4089QDomAttrPrivate::QDomAttrPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& name_) -
4090 : QDomNodePrivate(d, parent) -
4091{ -
4092 name = name_;
executed (the execution status of this line is deduced): name = name_;
-
4093 m_specified = false;
executed (the execution status of this line is deduced): m_specified = false;
-
4094}
executed: }
Execution Count:16771
16771
4095 -
4096QDomAttrPrivate::QDomAttrPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p, const QString& nsURI, const QString& qName) -
4097 : QDomNodePrivate(d, p) -
4098{ -
4099 qt_split_namespace(prefix, name, qName, !nsURI.isNull());
executed (the execution status of this line is deduced): qt_split_namespace(prefix, name, qName, !nsURI.isNull());
-
4100 namespaceURI = nsURI;
executed (the execution status of this line is deduced): namespaceURI = nsURI;
-
4101 createdWithDom1Interface = false;
executed (the execution status of this line is deduced): createdWithDom1Interface = false;
-
4102 m_specified = false;
executed (the execution status of this line is deduced): m_specified = false;
-
4103}
executed: }
Execution Count:54
54
4104 -
4105QDomAttrPrivate::QDomAttrPrivate(QDomAttrPrivate* n, bool deep) -
4106 : QDomNodePrivate(n, deep) -
4107{ -
4108 m_specified = n->specified();
executed (the execution status of this line is deduced): m_specified = n->specified();
-
4109}
executed: }
Execution Count:13
13
4110 -
4111void QDomAttrPrivate::setNodeValue(const QString& v) -
4112{ -
4113 value = v;
executed (the execution status of this line is deduced): value = v;
-
4114 QDomTextPrivate *t = new QDomTextPrivate(0, this, v);
executed (the execution status of this line is deduced): QDomTextPrivate *t = new QDomTextPrivate(0, this, v);
-
4115 // keep the refcount balanced: appendChild() does a ref anyway. -
4116 t->ref.deref();
executed (the execution status of this line is deduced): t->ref.deref();
-
4117 if (first) {
evaluated: first
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:16752
3-16752
4118 delete removeChild(first);
executed (the execution status of this line is deduced): delete removeChild(first);
-
4119 }
executed: }
Execution Count:3
3
4120 appendChild(t);
executed (the execution status of this line is deduced): appendChild(t);
-
4121}
executed: }
Execution Count:16755
16755
4122 -
4123QDomNodePrivate* QDomAttrPrivate::cloneNode(bool deep) -
4124{ -
4125 QDomNodePrivate* p = new QDomAttrPrivate(this, deep);
executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomAttrPrivate(this, deep);
-
4126 // We are not interested in this node -
4127 p->ref.deref();
executed (the execution status of this line is deduced): p->ref.deref();
-
4128 return p;
executed: return p;
Execution Count:1
1
4129} -
4130 -
4131bool QDomAttrPrivate::specified() const -
4132{ -
4133 return m_specified;
executed: return m_specified;
Execution Count:13
13
4134} -
4135 -
4136/* \internal -
4137 Encode & escape \a str. Yes, it makes no sense to return a QString, -
4138 but is so for legacy reasons. -
4139 -
4140 Remember that content produced should be able to roundtrip with 2.11 End-of-Line Handling -
4141 and 3.3.3 Attribute-Value Normalization. -
4142 -
4143 If \a performAVN is true, characters will be escaped to survive Attribute Value Normalization. -
4144 If \a encodeEOLs is true, characters will be escaped to survive End-of-Line Handling. -
4145*/ -
4146static QString encodeText(const QString &str, -
4147 QTextStream &s, -
4148 const bool encodeQuotes = true, -
4149 const bool performAVN = false, -
4150 const bool encodeEOLs = false) -
4151{ -
4152#ifdef QT_NO_TEXTCODEC -
4153 Q_UNUSED(s); -
4154#else -
4155 const QTextCodec *const codec = s.codec();
executed (the execution status of this line is deduced): const QTextCodec *const codec = s.codec();
-
4156 Q_ASSERT(codec);
executed (the execution status of this line is deduced): qt_noop();
-
4157#endif -
4158 QString retval(str);
executed (the execution status of this line is deduced): QString retval(str);
-
4159 int len = retval.length();
executed (the execution status of this line is deduced): int len = retval.length();
-
4160 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
4161 -
4162 while (i < len) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:927050
yes
Evaluation Count:44443
44443-927050
4163 const QChar ati(retval.at(i));
executed (the execution status of this line is deduced): const QChar ati(retval.at(i));
-
4164 -
4165 if (ati == QLatin1Char('<')) {
evaluated: ati == QLatin1Char('<')
TRUEFALSE
yes
Evaluation Count:904
yes
Evaluation Count:926146
904-926146
4166 retval.replace(i, 1, QLatin1String("&lt;"));
executed (the execution status of this line is deduced): retval.replace(i, 1, QLatin1String("&lt;"));
-
4167 len += 3;
executed (the execution status of this line is deduced): len += 3;
-
4168 i += 4;
executed (the execution status of this line is deduced): i += 4;
-
4169 } else if (encodeQuotes && (ati == QLatin1Char('"'))) {
executed: }
Execution Count:904
evaluated: encodeQuotes
TRUEFALSE
yes
Evaluation Count:135279
yes
Evaluation Count:790867
partially evaluated: (ati == QLatin1Char('"'))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:135279
0-790867
4170 retval.replace(i, 1, QLatin1String("&quot;"));
never executed (the execution status of this line is deduced): retval.replace(i, 1, QLatin1String("&quot;"));
-
4171 len += 5;
never executed (the execution status of this line is deduced): len += 5;
-
4172 i += 6;
never executed (the execution status of this line is deduced): i += 6;
-
4173 } else if (ati == QLatin1Char('&')) {
never executed: }
evaluated: ati == QLatin1Char('&')
TRUEFALSE
yes
Evaluation Count:466
yes
Evaluation Count:925680
0-925680
4174 retval.replace(i, 1, QLatin1String("&amp;"));
executed (the execution status of this line is deduced): retval.replace(i, 1, QLatin1String("&amp;"));
-
4175 len += 4;
executed (the execution status of this line is deduced): len += 4;
-
4176 i += 5;
executed (the execution status of this line is deduced): i += 5;
-
4177 } else if (ati == QLatin1Char('>') && i >= 2 && retval[i - 1] == QLatin1Char(']') && retval[i - 2] == QLatin1Char(']')) {
executed: }
Execution Count:466
evaluated: ati == QLatin1Char('>')
TRUEFALSE
yes
Evaluation Count:821
yes
Evaluation Count:924859
evaluated: i >= 2
TRUEFALSE
yes
Evaluation Count:819
yes
Evaluation Count:2
evaluated: retval[i - 1] == QLatin1Char(']')
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:675
partially evaluated: retval[i - 2] == QLatin1Char(']')
TRUEFALSE
yes
Evaluation Count:144
no
Evaluation Count:0
0-924859
4178 retval.replace(i, 1, QLatin1String("&gt;"));
executed (the execution status of this line is deduced): retval.replace(i, 1, QLatin1String("&gt;"));
-
4179 len += 3;
executed (the execution status of this line is deduced): len += 3;
-
4180 i += 4;
executed (the execution status of this line is deduced): i += 4;
-
4181 } else if (performAVN &&
executed: }
Execution Count:144
evaluated: performAVN
TRUEFALSE
yes
Evaluation Count:135177
yes
Evaluation Count:790359
144-790359
4182 (ati == QChar(0xA) ||
evaluated: ati == QChar(0xA)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:135165
12-135165
4183 ati == QChar(0xD) ||
evaluated: ati == QChar(0xD)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:135164
1-135164
4184 ati == QChar(0x9))) {
evaluated: ati == QChar(0x9)
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:135130
34-135130
4185 const QString replacement(QLatin1String("&#x") + QString::number(ati.unicode(), 16) + QLatin1Char(';'));
executed (the execution status of this line is deduced): const QString replacement(QLatin1String("&#x") + QString::number(ati.unicode(), 16) + QLatin1Char(';'));
-
4186 retval.replace(i, 1, replacement);
executed (the execution status of this line is deduced): retval.replace(i, 1, replacement);
-
4187 i += replacement.length();
executed (the execution status of this line is deduced): i += replacement.length();
-
4188 len += replacement.length() - 1;
executed (the execution status of this line is deduced): len += replacement.length() - 1;
-
4189 } else if (encodeEOLs && ati == QChar(0xD)) {
executed: }
Execution Count:47
evaluated: encodeEOLs
TRUEFALSE
yes
Evaluation Count:790257
yes
Evaluation Count:135232
evaluated: ati == QChar(0xD)
TRUEFALSE
yes
Evaluation Count:11794
yes
Evaluation Count:778463
47-790257
4190 retval.replace(i, 1, QLatin1String("&#xd;")); // Replace a single 0xD with a ref for 0xD
executed (the execution status of this line is deduced): retval.replace(i, 1, QLatin1String("&#xd;"));
-
4191 len += 4;
executed (the execution status of this line is deduced): len += 4;
-
4192 i += 5;
executed (the execution status of this line is deduced): i += 5;
-
4193 } else {
executed: }
Execution Count:11794
11794
4194#ifndef QT_NO_TEXTCODEC -
4195 if(codec->canEncode(ati))
partially evaluated: codec->canEncode(ati)
TRUEFALSE
yes
Evaluation Count:913695
no
Evaluation Count:0
0-913695
4196 ++i;
executed: ++i;
Execution Count:913695
913695
4197 else -
4198#endif -
4199 { -
4200 // We have to use a character reference to get it through. -
4201 const ushort codepoint(ati.unicode());
never executed (the execution status of this line is deduced): const ushort codepoint(ati.unicode());
-
4202 const QString replacement(QLatin1String("&#x") + QString::number(codepoint, 16) + QLatin1Char(';'));
never executed (the execution status of this line is deduced): const QString replacement(QLatin1String("&#x") + QString::number(codepoint, 16) + QLatin1Char(';'));
-
4203 retval.replace(i, 1, replacement);
never executed (the execution status of this line is deduced): retval.replace(i, 1, replacement);
-
4204 i += replacement.length();
never executed (the execution status of this line is deduced): i += replacement.length();
-
4205 len += replacement.length() - 1;
never executed (the execution status of this line is deduced): len += replacement.length() - 1;
-
4206 }
never executed: }
0
4207 } -
4208 } -
4209 -
4210 return retval;
executed: return retval;
Execution Count:44443
44443
4211} -
4212 -
4213void QDomAttrPrivate::save(QTextStream& s, int, int) const -
4214{ -
4215 if (namespaceURI.isNull()) {
never evaluated: namespaceURI.isNull()
0
4216 s << name << "=\"" << encodeText(value, s, true, true) << '\"';
never executed (the execution status of this line is deduced): s << name << "=\"" << encodeText(value, s, true, true) << '\"';
-
4217 } else {
never executed: }
0
4218 s << prefix << ':' << name << "=\"" << encodeText(value, s, true, true) << '\"';
never executed (the execution status of this line is deduced): s << prefix << ':' << name << "=\"" << encodeText(value, s, true, true) << '\"';
-
4219 /* This is a fix for 138243, as good as it gets. -
4220 * -
4221 * QDomElementPrivate::save() output a namespace declaration if -
4222 * the element is in a namespace, no matter what. This function do as well, meaning -
4223 * that we get two identical namespace declaration if we don't have the if- -
4224 * statement below. -
4225 * -
4226 * This doesn't work when the parent element has the same prefix as us but -
4227 * a different namespace. However, this can only occur by the user modifying the element, -
4228 * and we don't do fixups by that anyway, and hence it's the user responsibility to not -
4229 * arrive in those situations. */ -
4230 if(!ownerNode ||
never evaluated: !ownerNode
0
4231 ownerNode->prefix != prefix) {
never evaluated: ownerNode->prefix != prefix
0
4232 s << " xmlns:" << prefix << "=\"" << encodeText(namespaceURI, s, true, true) << '\"';
never executed (the execution status of this line is deduced): s << " xmlns:" << prefix << "=\"" << encodeText(namespaceURI, s, true, true) << '\"';
-
4233 }
never executed: }
0
4234 }
never executed: }
0
4235} -
4236 -
4237/************************************************************** -
4238 * -
4239 * QDomAttr -
4240 * -
4241 **************************************************************/ -
4242 -
4243#define IMPL ((QDomAttrPrivate*)impl) -
4244 -
4245/*! -
4246 \class QDomAttr -
4247 \reentrant -
4248 \brief The QDomAttr class represents one attribute of a QDomElement. -
4249 -
4250 \inmodule QtXml -
4251 \ingroup xml-tools -
4252 -
4253 For example, the following piece of XML produces an element with -
4254 no children, but two attributes: -
4255 -
4256 \snippet code/src_xml_dom_qdom.cpp 7 -
4257 -
4258 You can access the attributes of an element with code like this: -
4259 -
4260 \snippet code/src_xml_dom_qdom.cpp 8 -
4261 -
4262 This example also shows that changing an attribute received from -
4263 an element changes the attribute of the element. If you do not -
4264 want to change the value of the element's attribute you must -
4265 use cloneNode() to get an independent copy of the attribute. -
4266 -
4267 QDomAttr can return the name() and value() of an attribute. An -
4268 attribute's value is set with setValue(). If specified() returns -
4269 true the value was set with setValue(). The node this -
4270 attribute is attached to (if any) is returned by ownerElement(). -
4271 -
4272 For further information about the Document Object Model see -
4273 \l{http://www.w3.org/TR/REC-DOM-Level-1/} and -
4274 \l{http://www.w3.org/TR/DOM-Level-2-Core/}. -
4275 For a more general introduction of the DOM implementation see the -
4276 QDomDocument documentation. -
4277*/ -
4278 -
4279 -
4280/*! -
4281 Constructs an empty attribute. -
4282*/ -
4283QDomAttr::QDomAttr() -
4284{ -
4285} -
4286 -
4287/*! -
4288 Constructs a copy of \a x. -
4289 -
4290 The data of the copy is shared (shallow copy): modifying one node -
4291 will also change the other. If you want to make a deep copy, use -
4292 cloneNode(). -
4293*/ -
4294QDomAttr::QDomAttr(const QDomAttr& x) -
4295 : QDomNode(x) -
4296{ -
4297}
never executed: }
0
4298 -
4299QDomAttr::QDomAttr(QDomAttrPrivate* n) -
4300 : QDomNode(n) -
4301{ -
4302}
executed: }
Execution Count:107
107
4303 -
4304/*! -
4305 Assigns \a x to this DOM attribute. -
4306 -
4307 The data of the copy is shared (shallow copy): modifying one node -
4308 will also change the other. If you want to make a deep copy, use -
4309 cloneNode(). -
4310*/ -
4311QDomAttr& QDomAttr::operator= (const QDomAttr& x) -
4312{ -
4313 return (QDomAttr&) QDomNode::operator=(x);
never executed: return (QDomAttr&) QDomNode::operator=(x);
0
4314} -
4315 -
4316/*! -
4317 Returns the attribute's name. -
4318*/ -
4319QString QDomAttr::name() const -
4320{ -
4321 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
4322 return QString();
never executed: return QString();
0
4323 return impl->nodeName();
executed: return impl->nodeName();
Execution Count:24
24
4324} -
4325 -
4326/*! -
4327 Returns true if the attribute has been set by the user with setValue(). -
4328 Returns false if the value hasn't been specified or set. -
4329 -
4330 \sa setValue() -
4331*/ -
4332bool QDomAttr::specified() const -
4333{ -
4334 if (!impl)
never evaluated: !impl
0
4335 return false;
never executed: return false;
0
4336 return IMPL->specified();
never executed: return ((QDomAttrPrivate*)impl)->specified();
0
4337} -
4338 -
4339/*! -
4340 Returns the element node this attribute is attached to or a -
4341 \l{QDomNode::isNull()}{null node} if this attribute is not -
4342 attached to any element. -
4343*/ -
4344QDomElement QDomAttr::ownerElement() const -
4345{ -
4346 Q_ASSERT(impl->parent());
executed (the execution status of this line is deduced): qt_noop();
-
4347 if (!impl->parent()->isElement())
partially evaluated: !impl->parent()->isElement()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
4348 return QDomElement();
never executed: return QDomElement();
0
4349 return QDomElement((QDomElementPrivate*)(impl->parent()));
executed: return QDomElement((QDomElementPrivate*)(impl->parent()));
Execution Count:2
2
4350} -
4351 -
4352/*! -
4353 Returns the value of the attribute or an empty string if the -
4354 attribute has not been specified. -
4355 -
4356 \sa specified(), setValue() -
4357*/ -
4358QString QDomAttr::value() const -
4359{ -
4360 if (!impl)
never evaluated: !impl
0
4361 return QString();
never executed: return QString();
0
4362 return impl->nodeValue();
never executed: return impl->nodeValue();
0
4363} -
4364 -
4365/*! -
4366 Sets the attribute's value to \a v. -
4367 -
4368 \sa value() -
4369*/ -
4370void QDomAttr::setValue(const QString& v) -
4371{ -
4372 if (!impl)
never evaluated: !impl
0
4373 return;
never executed: return;
0
4374 impl->setNodeValue(v);
never executed (the execution status of this line is deduced): impl->setNodeValue(v);
-
4375 IMPL->m_specified = true;
never executed (the execution status of this line is deduced): ((QDomAttrPrivate*)impl)->m_specified = true;
-
4376}
never executed: }
0
4377 -
4378/*! -
4379 \fn QDomNode::NodeType QDomAttr::nodeType() const -
4380 -
4381 Returns \l{QDomNode::NodeType}{AttributeNode}. -
4382*/ -
4383 -
4384#undef IMPL -
4385 -
4386/************************************************************** -
4387 * -
4388 * QDomElementPrivate -
4389 * -
4390 **************************************************************/ -
4391 -
4392QDomElementPrivate::QDomElementPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p, -
4393 const QString& tagname) -
4394 : QDomNodePrivate(d, p) -
4395{ -
4396 name = tagname;
executed (the execution status of this line is deduced): name = tagname;
-
4397 m_attr = new QDomNamedNodeMapPrivate(this);
executed (the execution status of this line is deduced): m_attr = new QDomNamedNodeMapPrivate(this);
-
4398}
executed: }
Execution Count:37918
37918
4399 -
4400QDomElementPrivate::QDomElementPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p, -
4401 const QString& nsURI, const QString& qName) -
4402 : QDomNodePrivate(d, p) -
4403{ -
4404 qt_split_namespace(prefix, name, qName, !nsURI.isNull());
executed (the execution status of this line is deduced): qt_split_namespace(prefix, name, qName, !nsURI.isNull());
-
4405 namespaceURI = nsURI;
executed (the execution status of this line is deduced): namespaceURI = nsURI;
-
4406 createdWithDom1Interface = false;
executed (the execution status of this line is deduced): createdWithDom1Interface = false;
-
4407 m_attr = new QDomNamedNodeMapPrivate(this);
executed (the execution status of this line is deduced): m_attr = new QDomNamedNodeMapPrivate(this);
-
4408}
executed: }
Execution Count:112
112
4409 -
4410QDomElementPrivate::QDomElementPrivate(QDomElementPrivate* n, bool deep) : -
4411 QDomNodePrivate(n, deep) -
4412{ -
4413 m_attr = n->m_attr->clone(this);
executed (the execution status of this line is deduced): m_attr = n->m_attr->clone(this);
-
4414 // Reference is down to 0, so we set it to 1 here. -
4415 m_attr->ref.ref();
executed (the execution status of this line is deduced): m_attr->ref.ref();
-
4416}
executed: }
Execution Count:63
63
4417 -
4418QDomElementPrivate::~QDomElementPrivate() -
4419{ -
4420 if (!m_attr->ref.deref())
partially evaluated: !m_attr->ref.deref()
TRUEFALSE
yes
Evaluation Count:38093
no
Evaluation Count:0
0-38093
4421 delete m_attr;
executed: delete m_attr;
Execution Count:38093
38093
4422}
executed: }
Execution Count:38093
38093
4423 -
4424QDomNodePrivate* QDomElementPrivate::cloneNode(bool deep) -
4425{ -
4426 QDomNodePrivate* p = new QDomElementPrivate(this, deep);
executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomElementPrivate(this, deep);
-
4427 // We are not interested in this node -
4428 p->ref.deref();
executed (the execution status of this line is deduced): p->ref.deref();
-
4429 return p;
executed: return p;
Execution Count:50
50
4430} -
4431 -
4432QString QDomElementPrivate::attribute(const QString& name_, const QString& defValue) const -
4433{ -
4434 QDomNodePrivate* n = m_attr->namedItem(name_);
executed (the execution status of this line is deduced): QDomNodePrivate* n = m_attr->namedItem(name_);
-
4435 if (!n)
partially evaluated: !n
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
4436 return defValue;
never executed: return defValue;
0
4437 -
4438 return n->nodeValue();
executed: return n->nodeValue();
Execution Count:1
1
4439} -
4440 -
4441QString QDomElementPrivate::attributeNS(const QString& nsURI, const QString& localName, const QString& defValue) const -
4442{ -
4443 QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
never executed (the execution status of this line is deduced): QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
-
4444 if (!n)
never evaluated: !n
0
4445 return defValue;
never executed: return defValue;
0
4446 -
4447 return n->nodeValue();
never executed: return n->nodeValue();
0
4448} -
4449 -
4450void QDomElementPrivate::setAttribute(const QString& aname, const QString& newValue) -
4451{ -
4452 QDomNodePrivate* n = m_attr->namedItem(aname);
executed (the execution status of this line is deduced): QDomNodePrivate* n = m_attr->namedItem(aname);
-
4453 if (!n) {
evaluated: !n
TRUEFALSE
yes
Evaluation Count:16739
yes
Evaluation Count:3
3-16739
4454 n = new QDomAttrPrivate(ownerDocument(), this, aname);
executed (the execution status of this line is deduced): n = new QDomAttrPrivate(ownerDocument(), this, aname);
-
4455 n->setNodeValue(newValue);
executed (the execution status of this line is deduced): n->setNodeValue(newValue);
-
4456 -
4457 // Referencing is done by the map, so we set the reference counter back -
4458 // to 0 here. This is ok since we created the QDomAttrPrivate. -
4459 n->ref.deref();
executed (the execution status of this line is deduced): n->ref.deref();
-
4460 m_attr->setNamedItem(n);
executed (the execution status of this line is deduced): m_attr->setNamedItem(n);
-
4461 } else {
executed: }
Execution Count:16739
16739
4462 n->setNodeValue(newValue);
executed (the execution status of this line is deduced): n->setNodeValue(newValue);
-
4463 }
executed: }
Execution Count:3
3
4464} -
4465 -
4466void QDomElementPrivate::setAttributeNS(const QString& nsURI, const QString& qName, const QString& newValue) -
4467{ -
4468 QString prefix, localName;
executed (the execution status of this line is deduced): QString prefix, localName;
-
4469 qt_split_namespace(prefix, localName, qName, true);
executed (the execution status of this line is deduced): qt_split_namespace(prefix, localName, qName, true);
-
4470 QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
executed (the execution status of this line is deduced): QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
-
4471 if (!n) {
partially evaluated: !n
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
4472 n = new QDomAttrPrivate(ownerDocument(), this, nsURI, qName);
executed (the execution status of this line is deduced): n = new QDomAttrPrivate(ownerDocument(), this, nsURI, qName);
-
4473 n->setNodeValue(newValue);
executed (the execution status of this line is deduced): n->setNodeValue(newValue);
-
4474 -
4475 // Referencing is done by the map, so we set the reference counter back -
4476 // to 0 here. This is ok since we created the QDomAttrPrivate. -
4477 n->ref.deref();
executed (the execution status of this line is deduced): n->ref.deref();
-
4478 m_attr->setNamedItem(n);
executed (the execution status of this line is deduced): m_attr->setNamedItem(n);
-
4479 } else {
executed: }
Execution Count:13
13
4480 n->setNodeValue(newValue);
never executed (the execution status of this line is deduced): n->setNodeValue(newValue);
-
4481 n->prefix = prefix;
never executed (the execution status of this line is deduced): n->prefix = prefix;
-
4482 }
never executed: }
0
4483} -
4484 -
4485void QDomElementPrivate::removeAttribute(const QString& aname) -
4486{ -
4487 QDomNodePrivate* p = m_attr->removeNamedItem(aname);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = m_attr->removeNamedItem(aname);
-
4488 if (p && p->ref.load() == 0)
never evaluated: p
never evaluated: p->ref.load() == 0
0
4489 delete p;
never executed: delete p;
0
4490}
never executed: }
0
4491 -
4492QDomAttrPrivate* QDomElementPrivate::attributeNode(const QString& aname) -
4493{ -
4494 return (QDomAttrPrivate*)m_attr->namedItem(aname);
never executed: return (QDomAttrPrivate*)m_attr->namedItem(aname);
0
4495} -
4496 -
4497QDomAttrPrivate* QDomElementPrivate::attributeNodeNS(const QString& nsURI, const QString& localName) -
4498{ -
4499 return (QDomAttrPrivate*)m_attr->namedItemNS(nsURI, localName);
never executed: return (QDomAttrPrivate*)m_attr->namedItemNS(nsURI, localName);
0
4500} -
4501 -
4502QDomAttrPrivate* QDomElementPrivate::setAttributeNode(QDomAttrPrivate* newAttr) -
4503{ -
4504 QDomNodePrivate* n = m_attr->namedItem(newAttr->nodeName());
executed (the execution status of this line is deduced): QDomNodePrivate* n = m_attr->namedItem(newAttr->nodeName());
-
4505 -
4506 // Referencing is done by the maps -
4507 m_attr->setNamedItem(newAttr);
executed (the execution status of this line is deduced): m_attr->setNamedItem(newAttr);
-
4508 -
4509 newAttr->setParent(this);
executed (the execution status of this line is deduced): newAttr->setParent(this);
-
4510 -
4511 return (QDomAttrPrivate*)n;
executed: return (QDomAttrPrivate*)n;
Execution Count:1
1
4512} -
4513 -
4514QDomAttrPrivate* QDomElementPrivate::setAttributeNodeNS(QDomAttrPrivate* newAttr) -
4515{ -
4516 QDomNodePrivate* n = 0;
never executed (the execution status of this line is deduced): QDomNodePrivate* n = 0;
-
4517 if (!newAttr->prefix.isNull())
never evaluated: !newAttr->prefix.isNull()
0
4518 n = m_attr->namedItemNS(newAttr->namespaceURI, newAttr->name);
never executed: n = m_attr->namedItemNS(newAttr->namespaceURI, newAttr->name);
0
4519 -
4520 // Referencing is done by the maps -
4521 m_attr->setNamedItem(newAttr);
never executed (the execution status of this line is deduced): m_attr->setNamedItem(newAttr);
-
4522 -
4523 return (QDomAttrPrivate*)n;
never executed: return (QDomAttrPrivate*)n;
0
4524} -
4525 -
4526QDomAttrPrivate* QDomElementPrivate::removeAttributeNode(QDomAttrPrivate* oldAttr) -
4527{ -
4528 return (QDomAttrPrivate*)m_attr->removeNamedItem(oldAttr->nodeName());
never executed: return (QDomAttrPrivate*)m_attr->removeNamedItem(oldAttr->nodeName());
0
4529} -
4530 -
4531bool QDomElementPrivate::hasAttribute(const QString& aname) -
4532{ -
4533 return m_attr->contains(aname);
never executed: return m_attr->contains(aname);
0
4534} -
4535 -
4536bool QDomElementPrivate::hasAttributeNS(const QString& nsURI, const QString& localName) -
4537{ -
4538 return m_attr->containsNS(nsURI, localName);
never executed: return m_attr->containsNS(nsURI, localName);
0
4539} -
4540 -
4541QString QDomElementPrivate::text() -
4542{ -
4543 QString t(QLatin1String(""));
executed (the execution status of this line is deduced): QString t(QLatin1String(""));
-
4544 -
4545 QDomNodePrivate* p = first;
executed (the execution status of this line is deduced): QDomNodePrivate* p = first;
-
4546 while (p) {
evaluated: p
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
4547 if (p->isText() || p->isCDATASection())
partially evaluated: p->isText()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
never evaluated: p->isCDATASection()
0-1
4548 t += p->nodeValue();
executed: t += p->nodeValue();
Execution Count:1
1
4549 else if (p->isElement())
never evaluated: p->isElement()
0
4550 t += ((QDomElementPrivate*)p)->text();
never executed: t += ((QDomElementPrivate*)p)->text();
0
4551 p = p->next;
executed (the execution status of this line is deduced): p = p->next;
-
4552 }
executed: }
Execution Count:1
1
4553 -
4554 return t;
executed: return t;
Execution Count:1
1
4555} -
4556 -
4557void QDomElementPrivate::save(QTextStream& s, int depth, int indent) const -
4558{ -
4559 if (!(prev && prev->isText()))
evaluated: prev
TRUEFALSE
yes
Evaluation Count:22096
yes
Evaluation Count:9362
evaluated: prev->isText()
TRUEFALSE
yes
Evaluation Count:9268
yes
Evaluation Count:12828
9268-22096
4560 s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
executed: s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
Execution Count:22190
22190
4561 -
4562 QString qName(name);
executed (the execution status of this line is deduced): QString qName(name);
-
4563 QString nsDecl(QLatin1String(""));
executed (the execution status of this line is deduced): QString nsDecl(QLatin1String(""));
-
4564 if (!namespaceURI.isNull()) {
evaluated: !namespaceURI.isNull()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:31452
6-31452
4565 /** ### -
4566 * -
4567 * If we still have QDom, optimize this so that we only declare namespaces that are not -
4568 * yet declared. We loose default namespace mappings, so maybe we should rather store -
4569 * the information that we get from startPrefixMapping()/endPrefixMapping() and use them. -
4570 * Modifications becomes more complex then, however. -
4571 * -
4572 * We cannot do this in a patch release because it would require too invasive changes, and -
4573 * hence possibly behavioral changes. -
4574 */ -
4575 if (prefix.isEmpty()) {
evaluated: prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
4576 nsDecl = QLatin1String(" xmlns");
executed (the execution status of this line is deduced): nsDecl = QLatin1String(" xmlns");
-
4577 } else {
executed: }
Execution Count:3
3
4578 qName = prefix + QLatin1Char(':') + name;
executed (the execution status of this line is deduced): qName = prefix + QLatin1Char(':') + name;
-
4579 nsDecl = QLatin1String(" xmlns:") + prefix;
executed (the execution status of this line is deduced): nsDecl = QLatin1String(" xmlns:") + prefix;
-
4580 }
executed: }
Execution Count:3
3
4581 nsDecl += QLatin1String("=\"") + encodeText(namespaceURI, s) + QLatin1Char('\"');
executed (the execution status of this line is deduced): nsDecl += QLatin1String("=\"") + encodeText(namespaceURI, s) + QLatin1Char('\"');
-
4582 }
executed: }
Execution Count:6
6
4583 s << '<' << qName << nsDecl;
executed (the execution status of this line is deduced): s << '<' << qName << nsDecl;
-
4584 -
4585 QSet<QString> outputtedPrefixes;
executed (the execution status of this line is deduced): QSet<QString> outputtedPrefixes;
-
4586 -
4587 /* Write out attributes. */ -
4588 if (!m_attr->map.isEmpty()) {
evaluated: !m_attr->map.isEmpty()
TRUEFALSE
yes
Evaluation Count:12068
yes
Evaluation Count:19390
12068-19390
4589 QHash<QString, QDomNodePrivate *>::const_iterator it = m_attr->map.constBegin();
executed (the execution status of this line is deduced): QHash<QString, QDomNodePrivate *>::const_iterator it = m_attr->map.constBegin();
-
4590 for (; it != m_attr->map.constEnd(); ++it) {
evaluated: it != m_attr->map.constEnd()
TRUEFALSE
yes
Evaluation Count:13845
yes
Evaluation Count:12068
12068-13845
4591 s << ' ';
executed (the execution status of this line is deduced): s << ' ';
-
4592 if (it.value()->namespaceURI.isNull()) {
evaluated: it.value()->namespaceURI.isNull()
TRUEFALSE
yes
Evaluation Count:13838
yes
Evaluation Count:7
7-13838
4593 s << it.value()->name << "=\"" << encodeText(it.value()->value, s, true, true) << '\"';
executed (the execution status of this line is deduced): s << it.value()->name << "=\"" << encodeText(it.value()->value, s, true, true) << '\"';
-
4594 } else {
executed: }
Execution Count:13838
13838
4595 s << it.value()->prefix << ':' << it.value()->name << "=\"" << encodeText(it.value()->value, s, true, true) << '\"';
executed (the execution status of this line is deduced): s << it.value()->prefix << ':' << it.value()->name << "=\"" << encodeText(it.value()->value, s, true, true) << '\"';
-
4596 /* This is a fix for 138243, as good as it gets. -
4597 * -
4598 * QDomElementPrivate::save() output a namespace declaration if -
4599 * the element is in a namespace, no matter what. This function do as well, meaning -
4600 * that we get two identical namespace declaration if we don't have the if- -
4601 * statement below. -
4602 * -
4603 * This doesn't work when the parent element has the same prefix as us but -
4604 * a different namespace. However, this can only occur by the user modifying the element, -
4605 * and we don't do fixups by that anyway, and hence it's the user responsibility to not -
4606 * arrive in those situations. */ -
4607 if((!it.value()->ownerNode ||
partially evaluated: !it.value()->ownerNode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
4608 it.value()->ownerNode->prefix != it.value()->prefix) &&
evaluated: it.value()->ownerNode->prefix != it.value()->prefix
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
2-5
4609 !outputtedPrefixes.contains(it.value()->prefix)) {
evaluated: !outputtedPrefixes.contains(it.value()->prefix)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
4610 s << " xmlns:" << it.value()->prefix << "=\"" << encodeText(it.value()->namespaceURI, s, true, true) << '\"';
executed (the execution status of this line is deduced): s << " xmlns:" << it.value()->prefix << "=\"" << encodeText(it.value()->namespaceURI, s, true, true) << '\"';
-
4611 outputtedPrefixes.insert(it.value()->prefix);
executed (the execution status of this line is deduced): outputtedPrefixes.insert(it.value()->prefix);
-
4612 }
executed: }
Execution Count:4
4
4613 }
executed: }
Execution Count:7
7
4614 } -
4615 }
executed: }
Execution Count:12068
12068
4616 -
4617 if (last) {
evaluated: last
TRUEFALSE
yes
Evaluation Count:30172
yes
Evaluation Count:1286
1286-30172
4618 // has child nodes -
4619 if (first->isText())
evaluated: first->isText()
TRUEFALSE
yes
Evaluation Count:20875
yes
Evaluation Count:9297
9297-20875
4620 s << '>';
executed: s << '>';
Execution Count:20875
20875
4621 else { -
4622 s << '>';
executed (the execution status of this line is deduced): s << '>';
-
4623 -
4624 /* -1 disables new lines. */ -
4625 if (indent != -1)
evaluated: indent != -1
TRUEFALSE
yes
Evaluation Count:9296
yes
Evaluation Count:1
1-9296
4626 s << endl;
executed: s << endl;
Execution Count:9296
9296
4627 }
executed: }
Execution Count:9297
9297
4628 QDomNodePrivate::save(s, depth + 1, indent); if (!last->isText())
evaluated: !last->isText()
TRUEFALSE
yes
Evaluation Count:9120
yes
Evaluation Count:21052
9120-21052
4629 s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
executed: s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
Execution Count:9120
9120
4630 -
4631 s << "</" << qName << '>';
executed (the execution status of this line is deduced): s << "</" << qName << '>';
-
4632 } else {
executed: }
Execution Count:30172
30172
4633 s << "/>";
executed (the execution status of this line is deduced): s << "/>";
-
4634 }
executed: }
Execution Count:1286
1286
4635 if (!(next && next->isText())) {
evaluated: next
TRUEFALSE
yes
Evaluation Count:22424
yes
Evaluation Count:9034
evaluated: next->isText()
TRUEFALSE
yes
Evaluation Count:9533
yes
Evaluation Count:12891
9034-22424
4636 /* -1 disables new lines. */ -
4637 if (indent != -1)
evaluated: indent != -1
TRUEFALSE
yes
Evaluation Count:21923
yes
Evaluation Count:2
2-21923
4638 s << endl;
executed: s << endl;
Execution Count:21923
21923
4639 }
executed: }
Execution Count:21925
21925
4640}
executed: }
Execution Count:31458
31458
4641 -
4642/************************************************************** -
4643 * -
4644 * QDomElement -
4645 * -
4646 **************************************************************/ -
4647 -
4648#define IMPL ((QDomElementPrivate*)impl) -
4649 -
4650/*! -
4651 \class QDomElement -
4652 \reentrant -
4653 \brief The QDomElement class represents one element in the DOM tree. -
4654 -
4655 \inmodule QtXml -
4656 \ingroup xml-tools -
4657 -
4658 Elements have a tagName() and zero or more attributes associated -
4659 with them. The tag name can be changed with setTagName(). -
4660 -
4661 Element attributes are represented by QDomAttr objects that can -
4662 be queried using the attribute() and attributeNode() functions. -
4663 You can set attributes with the setAttribute() and -
4664 setAttributeNode() functions. Attributes can be removed with -
4665 removeAttribute(). There are namespace-aware equivalents to these -
4666 functions, i.e. setAttributeNS(), setAttributeNodeNS() and -
4667 removeAttributeNS(). -
4668 -
4669 If you want to access the text of a node use text(), e.g. -
4670 -
4671 \snippet code/src_xml_dom_qdom.cpp 9 -
4672 -
4673 The text() function operates recursively to find the text (since -
4674 not all elements contain text). If you want to find all the text -
4675 in all of a node's children, iterate over the children looking for -
4676 QDomText nodes, e.g. -
4677 -
4678 \snippet code/src_xml_dom_qdom.cpp 10 -
4679 -
4680 Note that we attempt to convert each node to a text node and use -
4681 text() rather than using firstChild().toText().data() or -
4682 n.toText().data() directly on the node, because the node may not -
4683 be a text element. -
4684 -
4685 You can get a list of all the decendents of an element which have -
4686 a specified tag name with elementsByTagName() or -
4687 elementsByTagNameNS(). -
4688 -
4689 To browse the elements of a dom document use firstChildElement(), lastChildElement(), -
4690 nextSiblingElement() and previousSiblingElement(). For example, to iterate over all -
4691 child elements called "entry" in a root element called "database", you can use: -
4692 -
4693 \snippet code/src_xml_dom_qdom.cpp 11 -
4694 -
4695 For further information about the Document Object Model see -
4696 \l{W3C DOM Level 1}{Level 1} and -
4697 \l{W3C DOM Level 2}{Level 2 Core}. -
4698 For a more general introduction of the DOM implementation see the -
4699 QDomDocument documentation. -
4700*/ -
4701 -
4702/*! -
4703 Constructs an empty element. Use the QDomDocument::createElement() -
4704 function to construct elements with content. -
4705*/ -
4706QDomElement::QDomElement() -
4707 : QDomNode() -
4708{ -
4709}
executed: }
Execution Count:10
10
4710 -
4711/*! -
4712 Constructs a copy of \a x. -
4713 -
4714 The data of the copy is shared (shallow copy): modifying one node -
4715 will also change the other. If you want to make a deep copy, use -
4716 cloneNode(). -
4717*/ -
4718QDomElement::QDomElement(const QDomElement& x) -
4719 : QDomNode(x) -
4720{ -
4721}
executed: }
Execution Count:12
12
4722 -
4723QDomElement::QDomElement(QDomElementPrivate* n) -
4724 : QDomNode(n) -
4725{ -
4726}
executed: }
Execution Count:253
253
4727 -
4728/*! -
4729 Assigns \a x to this DOM element. -
4730 -
4731 The data of the copy is shared (shallow copy): modifying one node -
4732 will also change the other. If you want to make a deep copy, use -
4733 cloneNode(). -
4734*/ -
4735QDomElement& QDomElement::operator= (const QDomElement& x) -
4736{ -
4737 return (QDomElement&) QDomNode::operator=(x);
never executed: return (QDomElement&) QDomNode::operator=(x);
0
4738} -
4739 -
4740/*! -
4741 \fn QDomNode::NodeType QDomElement::nodeType() const -
4742 -
4743 Returns \c ElementNode. -
4744*/ -
4745 -
4746/*! -
4747 Sets this element's tag name to \a name. -
4748 -
4749 \sa tagName() -
4750*/ -
4751void QDomElement::setTagName(const QString& name) -
4752{ -
4753 if (impl)
never evaluated: impl
0
4754 impl->name = name;
never executed: impl->name = name;
0
4755}
never executed: }
0
4756 -
4757/*! -
4758 Returns the tag name of this element. For an XML element like this: -
4759 -
4760 \snippet code/src_xml_dom_qdom.cpp 12 -
4761 -
4762 the tagname would return "img". -
4763 -
4764 \sa setTagName() -
4765*/ -
4766QString QDomElement::tagName() const -
4767{ -
4768 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:45
0-45
4769 return QString();
never executed: return QString();
0
4770 return impl->nodeName();
executed: return impl->nodeName();
Execution Count:45
45
4771} -
4772 -
4773 -
4774/*! -
4775 Returns a QDomNamedNodeMap containing all this element's attributes. -
4776 -
4777 \sa attribute(), setAttribute(), attributeNode(), setAttributeNode() -
4778*/ -
4779QDomNamedNodeMap QDomElement::attributes() const -
4780{ -
4781 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
4782 return QDomNamedNodeMap();
never executed: return QDomNamedNodeMap();
0
4783 return QDomNamedNodeMap(IMPL->attributes());
executed: return QDomNamedNodeMap(((QDomElementPrivate*)impl)->attributes());
Execution Count:1
1
4784} -
4785 -
4786/*! -
4787 Returns the attribute called \a name. If the attribute does not -
4788 exist \a defValue is returned. -
4789 -
4790 \sa setAttribute(), attributeNode(), setAttributeNode(), attributeNS() -
4791*/ -
4792QString QDomElement::attribute(const QString& name, const QString& defValue) const -
4793{ -
4794 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
4795 return defValue;
never executed: return defValue;
0
4796 return IMPL->attribute(name, defValue);
executed: return ((QDomElementPrivate*)impl)->attribute(name, defValue);
Execution Count:1
1
4797} -
4798 -
4799/*! -
4800 Adds an attribute called \a name with value \a value. If an -
4801 attribute with the same name exists, its value is replaced by \a -
4802 value. -
4803 -
4804 \sa attribute(), setAttributeNode(), setAttributeNS() -
4805*/ -
4806void QDomElement::setAttribute(const QString& name, const QString& value) -
4807{ -
4808 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
4809 return;
never executed: return;
0
4810 IMPL->setAttribute(name, value);
executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->setAttribute(name, value);
-
4811}
executed: }
Execution Count:3
3
4812 -
4813/*! -
4814 \fn void QDomElement::setAttribute(const QString& name, int value) -
4815 -
4816 \overload -
4817 The number is formatted according to the current locale. -
4818*/ -
4819 -
4820/*! -
4821 \fn void QDomElement::setAttribute(const QString& name, uint value) -
4822 -
4823 \overload -
4824 The number is formatted according to the current locale. -
4825*/ -
4826 -
4827/*! -
4828 \overload -
4829 -
4830 The number is formatted according to the current locale. -
4831*/ -
4832void QDomElement::setAttribute(const QString& name, qlonglong value) -
4833{ -
4834 if (!impl)
never evaluated: !impl
0
4835 return;
never executed: return;
0
4836 QString x;
never executed (the execution status of this line is deduced): QString x;
-
4837 x.setNum(value);
never executed (the execution status of this line is deduced): x.setNum(value);
-
4838 IMPL->setAttribute(name, x);
never executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->setAttribute(name, x);
-
4839}
never executed: }
0
4840 -
4841/*! -
4842 \overload -
4843 -
4844 The number is formatted according to the current locale. -
4845*/ -
4846void QDomElement::setAttribute(const QString& name, qulonglong value) -
4847{ -
4848 if (!impl)
never evaluated: !impl
0
4849 return;
never executed: return;
0
4850 QString x;
never executed (the execution status of this line is deduced): QString x;
-
4851 x.setNum(value);
never executed (the execution status of this line is deduced): x.setNum(value);
-
4852 IMPL->setAttribute(name, x);
never executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->setAttribute(name, x);
-
4853}
never executed: }
0
4854 -
4855/*! -
4856 \overload -
4857 -
4858 The number is formatted according to the current locale. -
4859*/ -
4860void QDomElement::setAttribute(const QString& name, float value) -
4861{ -
4862 if (!impl)
never evaluated: !impl
0
4863 return;
never executed: return;
0
4864 QString x;
never executed (the execution status of this line is deduced): QString x;
-
4865 x.setNum(value);
never executed (the execution status of this line is deduced): x.setNum(value);
-
4866 IMPL->setAttribute(name, x);
never executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->setAttribute(name, x);
-
4867}
never executed: }
0
4868 -
4869/*! -
4870 \overload -
4871 -
4872 The number is formatted according to the current locale. -
4873*/ -
4874void QDomElement::setAttribute(const QString& name, double value) -
4875{ -
4876 if (!impl)
never evaluated: !impl
0
4877 return;
never executed: return;
0
4878 QString x;
never executed (the execution status of this line is deduced): QString x;
-
4879 char buf[256];
never executed (the execution status of this line is deduced): char buf[256];
-
4880 int count = qsnprintf(buf, sizeof(buf), "%.16g", value);
never executed (the execution status of this line is deduced): int count = qsnprintf(buf, sizeof(buf), "%.16g", value);
-
4881 if (count > 0)
never evaluated: count > 0
0
4882 x = QString::fromLatin1(buf, count);
never executed: x = QString::fromLatin1(buf, count);
0
4883 else -
4884 x.setNum(value); // Fallback
never executed: x.setNum(value);
0
4885 IMPL->setAttribute(name, x);
never executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->setAttribute(name, x);
-
4886}
never executed: }
0
4887 -
4888/*! -
4889 Removes the attribute called name \a name from this element. -
4890 -
4891 \sa setAttribute(), attribute(), removeAttributeNS() -
4892*/ -
4893void QDomElement::removeAttribute(const QString& name) -
4894{ -
4895 if (!impl)
never evaluated: !impl
0
4896 return;
never executed: return;
0
4897 IMPL->removeAttribute(name);
never executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->removeAttribute(name);
-
4898}
never executed: }
0
4899 -
4900/*! -
4901 Returns the QDomAttr object that corresponds to the attribute -
4902 called \a name. If no such attribute exists a -
4903 \l{QDomNode::isNull()}{null attribute} is returned. -
4904 -
4905 \sa setAttributeNode(), attribute(), setAttribute(), attributeNodeNS() -
4906*/ -
4907QDomAttr QDomElement::attributeNode(const QString& name) -
4908{ -
4909 if (!impl)
never evaluated: !impl
0
4910 return QDomAttr();
never executed: return QDomAttr();
0
4911 return QDomAttr(IMPL->attributeNode(name));
never executed: return QDomAttr(((QDomElementPrivate*)impl)->attributeNode(name));
0
4912} -
4913 -
4914/*! -
4915 Adds the attribute \a newAttr to this element. -
4916 -
4917 If the element has another attribute that has the same name as \a -
4918 newAttr, this function replaces that attribute and returns it; -
4919 otherwise the function returns a -
4920 \l{QDomNode::isNull()}{null attribute}. -
4921 -
4922 \sa attributeNode(), setAttribute(), setAttributeNodeNS() -
4923*/ -
4924QDomAttr QDomElement::setAttributeNode(const QDomAttr& newAttr) -
4925{ -
4926 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
4927 return QDomAttr();
never executed: return QDomAttr();
0
4928 return QDomAttr(IMPL->setAttributeNode(((QDomAttrPrivate*)newAttr.impl)));
executed: return QDomAttr(((QDomElementPrivate*)impl)->setAttributeNode(((QDomAttrPrivate*)newAttr.impl)));
Execution Count:1
1
4929} -
4930 -
4931/*! -
4932 Removes the attribute \a oldAttr from the element and returns it. -
4933 -
4934 \sa attributeNode(), setAttributeNode() -
4935*/ -
4936QDomAttr QDomElement::removeAttributeNode(const QDomAttr& oldAttr) -
4937{ -
4938 if (!impl)
never evaluated: !impl
0
4939 return QDomAttr(); // ### should this return oldAttr?
never executed: return QDomAttr();
0
4940 return QDomAttr(IMPL->removeAttributeNode(((QDomAttrPrivate*)oldAttr.impl)));
never executed: return QDomAttr(((QDomElementPrivate*)impl)->removeAttributeNode(((QDomAttrPrivate*)oldAttr.impl)));
0
4941} -
4942 -
4943/*! -
4944 Returns a QDomNodeList containing all descendants of this element -
4945 named \a tagname encountered during a preorder traversal of the -
4946 element subtree with this element as its root. The order of the -
4947 elements in the returned list is the order they are encountered -
4948 during the preorder traversal. -
4949 -
4950 \sa elementsByTagNameNS(), QDomDocument::elementsByTagName() -
4951*/ -
4952QDomNodeList QDomElement::elementsByTagName(const QString& tagname) const -
4953{ -
4954 return QDomNodeList(new QDomNodeListPrivate(impl, tagname));
never executed: return QDomNodeList(new QDomNodeListPrivate(impl, tagname));
0
4955} -
4956 -
4957/*! -
4958 Returns true if this element has an attribute called \a name; -
4959 otherwise returns false. -
4960 -
4961 \b{Note:} This function does not take the presence of namespaces -
4962 into account. As a result, the specified name will be tested -
4963 against fully-qualified attribute names that include any namespace -
4964 prefixes that may be present. -
4965 -
4966 Use hasAttributeNS() to explicitly test for attributes with specific -
4967 namespaces and names. -
4968*/ -
4969bool QDomElement::hasAttribute(const QString& name) const -
4970{ -
4971 if (!impl)
never evaluated: !impl
0
4972 return false;
never executed: return false;
0
4973 return IMPL->hasAttribute(name);
never executed: return ((QDomElementPrivate*)impl)->hasAttribute(name);
0
4974} -
4975 -
4976/*! -
4977 Returns the attribute with the local name \a localName and the -
4978 namespace URI \a nsURI. If the attribute does not exist \a -
4979 defValue is returned. -
4980 -
4981 \sa setAttributeNS(), attributeNodeNS(), setAttributeNodeNS(), attribute() -
4982*/ -
4983QString QDomElement::attributeNS(const QString nsURI, const QString& localName, const QString& defValue) const -
4984{ -
4985 if (!impl)
never evaluated: !impl
0
4986 return defValue;
never executed: return defValue;
0
4987 return IMPL->attributeNS(nsURI, localName, defValue);
never executed: return ((QDomElementPrivate*)impl)->attributeNS(nsURI, localName, defValue);
0
4988} -
4989 -
4990/*! -
4991 Adds an attribute with the qualified name \a qName and the -
4992 namespace URI \a nsURI with the value \a value. If an attribute -
4993 with the same local name and namespace URI exists, its prefix is -
4994 replaced by the prefix of \a qName and its value is repaced by \a -
4995 value. -
4996 -
4997 Although \a qName is the qualified name, the local name is used to -
4998 decide if an existing attribute's value should be replaced. -
4999 -
5000 \sa attributeNS(), setAttributeNodeNS(), setAttribute() -
5001*/ -
5002void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, const QString& value) -
5003{ -
5004 if (!impl)
never evaluated: !impl
0
5005 return;
never executed: return;
0
5006 IMPL->setAttributeNS(nsURI, qName, value);
never executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->setAttributeNS(nsURI, qName, value);
-
5007}
never executed: }
0
5008 -
5009/*! -
5010 \fn void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, int value) -
5011 -
5012 \overload -
5013*/ -
5014 -
5015/*! -
5016 \fn void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, uint value) -
5017 -
5018 \overload -
5019*/ -
5020 -
5021/*! -
5022 \overload -
5023*/ -
5024void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, qlonglong value) -
5025{ -
5026 if (!impl)
never evaluated: !impl
0
5027 return;
never executed: return;
0
5028 QString x;
never executed (the execution status of this line is deduced): QString x;
-
5029 x.setNum(value);
never executed (the execution status of this line is deduced): x.setNum(value);
-
5030 IMPL->setAttributeNS(nsURI, qName, x);
never executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->setAttributeNS(nsURI, qName, x);
-
5031}
never executed: }
0
5032 -
5033/*! -
5034 \overload -
5035*/ -
5036void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, qulonglong value) -
5037{ -
5038 if (!impl)
never evaluated: !impl
0
5039 return;
never executed: return;
0
5040 QString x;
never executed (the execution status of this line is deduced): QString x;
-
5041 x.setNum(value);
never executed (the execution status of this line is deduced): x.setNum(value);
-
5042 IMPL->setAttributeNS(nsURI, qName, x);
never executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->setAttributeNS(nsURI, qName, x);
-
5043}
never executed: }
0
5044 -
5045/*! -
5046 \overload -
5047*/ -
5048void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, double value) -
5049{ -
5050 if (!impl)
never evaluated: !impl
0
5051 return;
never executed: return;
0
5052 QString x;
never executed (the execution status of this line is deduced): QString x;
-
5053 x.setNum(value);
never executed (the execution status of this line is deduced): x.setNum(value);
-
5054 IMPL->setAttributeNS(nsURI, qName, x);
never executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->setAttributeNS(nsURI, qName, x);
-
5055}
never executed: }
0
5056 -
5057/*! -
5058 Removes the attribute with the local name \a localName and the -
5059 namespace URI \a nsURI from this element. -
5060 -
5061 \sa setAttributeNS(), attributeNS(), removeAttribute() -
5062*/ -
5063void QDomElement::removeAttributeNS(const QString& nsURI, const QString& localName) -
5064{ -
5065 if (!impl)
never evaluated: !impl
0
5066 return;
never executed: return;
0
5067 QDomNodePrivate *n = IMPL->attributeNodeNS(nsURI, localName);
never executed (the execution status of this line is deduced): QDomNodePrivate *n = ((QDomElementPrivate*)impl)->attributeNodeNS(nsURI, localName);
-
5068 if (!n)
never evaluated: !n
0
5069 return;
never executed: return;
0
5070 IMPL->removeAttribute(n->nodeName());
never executed (the execution status of this line is deduced): ((QDomElementPrivate*)impl)->removeAttribute(n->nodeName());
-
5071}
never executed: }
0
5072 -
5073/*! -
5074 Returns the QDomAttr object that corresponds to the attribute -
5075 with the local name \a localName and the namespace URI \a nsURI. -
5076 If no such attribute exists a \l{QDomNode::isNull()}{null -
5077 attribute} is returned. -
5078 -
5079 \sa setAttributeNode(), attribute(), setAttribute() -
5080*/ -
5081QDomAttr QDomElement::attributeNodeNS(const QString& nsURI, const QString& localName) -
5082{ -
5083 if (!impl)
never evaluated: !impl
0
5084 return QDomAttr();
never executed: return QDomAttr();
0
5085 return QDomAttr(IMPL->attributeNodeNS(nsURI, localName));
never executed: return QDomAttr(((QDomElementPrivate*)impl)->attributeNodeNS(nsURI, localName));
0
5086} -
5087 -
5088/*! -
5089 Adds the attribute \a newAttr to this element. -
5090 -
5091 If the element has another attribute that has the same local name -
5092 and namespace URI as \a newAttr, this function replaces that -
5093 attribute and returns it; otherwise the function returns a -
5094 \l{QDomNode::isNull()}{null attribute}. -
5095 -
5096 \sa attributeNodeNS(), setAttributeNS(), setAttributeNode() -
5097*/ -
5098QDomAttr QDomElement::setAttributeNodeNS(const QDomAttr& newAttr) -
5099{ -
5100 if (!impl)
never evaluated: !impl
0
5101 return QDomAttr();
never executed: return QDomAttr();
0
5102 return QDomAttr(IMPL->setAttributeNodeNS(((QDomAttrPrivate*)newAttr.impl)));
never executed: return QDomAttr(((QDomElementPrivate*)impl)->setAttributeNodeNS(((QDomAttrPrivate*)newAttr.impl)));
0
5103} -
5104 -
5105/*! -
5106 Returns a QDomNodeList containing all descendants of this element -
5107 with local name \a localName and namespace URI \a nsURI encountered -
5108 during a preorder traversal of the element subtree with this element -
5109 as its root. The order of the elements in the returned list is the -
5110 order they are encountered during the preorder traversal. -
5111 -
5112 \sa elementsByTagName(), QDomDocument::elementsByTagNameNS() -
5113*/ -
5114QDomNodeList QDomElement::elementsByTagNameNS(const QString& nsURI, const QString& localName) const -
5115{ -
5116 return QDomNodeList(new QDomNodeListPrivate(impl, nsURI, localName));
never executed: return QDomNodeList(new QDomNodeListPrivate(impl, nsURI, localName));
0
5117} -
5118 -
5119/*! -
5120 Returns true if this element has an attribute with the local name -
5121 \a localName and the namespace URI \a nsURI; otherwise returns -
5122 false. -
5123*/ -
5124bool QDomElement::hasAttributeNS(const QString& nsURI, const QString& localName) const -
5125{ -
5126 if (!impl)
never evaluated: !impl
0
5127 return false;
never executed: return false;
0
5128 return IMPL->hasAttributeNS(nsURI, localName);
never executed: return ((QDomElementPrivate*)impl)->hasAttributeNS(nsURI, localName);
0
5129} -
5130 -
5131/*! -
5132 Returns the element's text or an empty string. -
5133 -
5134 Example: -
5135 \snippet code/src_xml_dom_qdom.cpp 13 -
5136 -
5137 The function text() of the QDomElement for the \c{<h1>} tag, -
5138 will return the following text: -
5139 -
5140 \snippet code/src_xml_dom_qdom.cpp 14 -
5141 -
5142 Comments are ignored by this function. It only evaluates QDomText -
5143 and QDomCDATASection objects. -
5144*/ -
5145QString QDomElement::text() const -
5146{ -
5147 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
5148 return QString();
never executed: return QString();
0
5149 return IMPL->text();
executed: return ((QDomElementPrivate*)impl)->text();
Execution Count:1
1
5150} -
5151 -
5152#undef IMPL -
5153 -
5154/************************************************************** -
5155 * -
5156 * QDomTextPrivate -
5157 * -
5158 **************************************************************/ -
5159 -
5160QDomTextPrivate::QDomTextPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& val) -
5161 : QDomCharacterDataPrivate(d, parent, val) -
5162{ -
5163 name = QLatin1String("#text");
executed (the execution status of this line is deduced): name = QLatin1String("#text");
-
5164}
executed: }
Execution Count:53322
53322
5165 -
5166QDomTextPrivate::QDomTextPrivate(QDomTextPrivate* n, bool deep) -
5167 : QDomCharacterDataPrivate(n, deep) -
5168{ -
5169}
executed: }
Execution Count:13
13
5170 -
5171QDomNodePrivate* QDomTextPrivate::cloneNode(bool deep) -
5172{ -
5173 QDomNodePrivate* p = new QDomTextPrivate(this, deep);
executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomTextPrivate(this, deep);
-
5174 // We are not interested in this node -
5175 p->ref.deref();
executed (the execution status of this line is deduced): p->ref.deref();
-
5176 return p;
executed: return p;
Execution Count:1
1
5177} -
5178 -
5179QDomTextPrivate* QDomTextPrivate::splitText(int offset) -
5180{ -
5181 if (!parent()) {
never evaluated: !parent()
0
5182 qWarning("QDomText::splitText The node has no parent. So I can not split");
never executed (the execution status of this line is deduced): QMessageLogger("dom/qdom.cpp", 5182, __PRETTY_FUNCTION__).warning("QDomText::splitText The node has no parent. So I can not split");
-
5183 return 0;
never executed: return 0;
0
5184 } -
5185 -
5186 QDomTextPrivate* t = new QDomTextPrivate(ownerDocument(), 0, value.mid(offset));
never executed (the execution status of this line is deduced): QDomTextPrivate* t = new QDomTextPrivate(ownerDocument(), 0, value.mid(offset));
-
5187 value.truncate(offset);
never executed (the execution status of this line is deduced): value.truncate(offset);
-
5188 -
5189 parent()->insertAfter(t, this);
never executed (the execution status of this line is deduced): parent()->insertAfter(t, this);
-
5190 -
5191 return t;
never executed: return t;
0
5192} -
5193 -
5194void QDomTextPrivate::save(QTextStream& s, int, int) const -
5195{ -
5196 QDomTextPrivate *that = const_cast<QDomTextPrivate*>(this);
executed (the execution status of this line is deduced): QDomTextPrivate *that = const_cast<QDomTextPrivate*>(this);
-
5197 s << encodeText(value, s, !(that->parent() && that->parent()->isElement()), false, true);
executed (the execution status of this line is deduced): s << encodeText(value, s, !(that->parent() && that->parent()->isElement()), false, true);
-
5198}
executed: }
Execution Count:30588
30588
5199 -
5200/************************************************************** -
5201 * -
5202 * QDomText -
5203 * -
5204 **************************************************************/ -
5205 -
5206#define IMPL ((QDomTextPrivate*)impl) -
5207 -
5208/*! -
5209 \class QDomText -
5210 \reentrant -
5211 \brief The QDomText class represents text data in the parsed XML document. -
5212 -
5213 \inmodule QtXml -
5214 \ingroup xml-tools -
5215 -
5216 You can split the text in a QDomText object over two QDomText -
5217 objecs with splitText(). -
5218 -
5219 For further information about the Document Object Model see -
5220 \l{http://www.w3.org/TR/REC-DOM-Level-1/}{Level 1} and -
5221 \l{http://www.w3.org/TR/DOM-Level-2-Core/}{Level 2 Core}. -
5222 For a more general introduction of the DOM implementation see the -
5223 QDomDocument documentation. -
5224*/ -
5225 -
5226/*! -
5227 Constructs an empty QDomText object. -
5228 -
5229 To construct a QDomText with content, use QDomDocument::createTextNode(). -
5230*/ -
5231QDomText::QDomText() -
5232 : QDomCharacterData() -
5233{ -
5234}
never executed: }
0
5235 -
5236/*! -
5237 Constructs a copy of \a x. -
5238 -
5239 The data of the copy is shared (shallow copy): modifying one node -
5240 will also change the other. If you want to make a deep copy, use -
5241 cloneNode(). -
5242*/ -
5243QDomText::QDomText(const QDomText& x) -
5244 : QDomCharacterData(x) -
5245{ -
5246}
never executed: }
0
5247 -
5248QDomText::QDomText(QDomTextPrivate* n) -
5249 : QDomCharacterData(n) -
5250{ -
5251}
executed: }
Execution Count:68
68
5252 -
5253/*! -
5254 Assigns \a x to this DOM text. -
5255 -
5256 The data of the copy is shared (shallow copy): modifying one node -
5257 will also change the other. If you want to make a deep copy, use -
5258 cloneNode(). -
5259*/ -
5260QDomText& QDomText::operator= (const QDomText& x) -
5261{ -
5262 return (QDomText&) QDomNode::operator=(x);
never executed: return (QDomText&) QDomNode::operator=(x);
0
5263} -
5264 -
5265/*! -
5266 \fn QDomNode::NodeType QDomText::nodeType() const -
5267 -
5268 Returns \c TextNode. -
5269*/ -
5270 -
5271/*! -
5272 Splits this DOM text object into two QDomText objects. This object -
5273 keeps its first \a offset characters and the second (newly -
5274 created) object is inserted into the document tree after this -
5275 object with the remaining characters. -
5276 -
5277 The function returns the newly created object. -
5278 -
5279 \sa QDomNode::normalize() -
5280*/ -
5281QDomText QDomText::splitText(int offset) -
5282{ -
5283 if (!impl)
never evaluated: !impl
0
5284 return QDomText();
never executed: return QDomText();
0
5285 return QDomText(IMPL->splitText(offset));
never executed: return QDomText(((QDomTextPrivate*)impl)->splitText(offset));
0
5286} -
5287 -
5288#undef IMPL -
5289 -
5290/************************************************************** -
5291 * -
5292 * QDomCommentPrivate -
5293 * -
5294 **************************************************************/ -
5295 -
5296QDomCommentPrivate::QDomCommentPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& val) -
5297 : QDomCharacterDataPrivate(d, parent, val) -
5298{ -
5299 name = QLatin1String("#comment");
executed (the execution status of this line is deduced): name = QLatin1String("#comment");
-
5300}
executed: }
Execution Count:1962
1962
5301 -
5302QDomCommentPrivate::QDomCommentPrivate(QDomCommentPrivate* n, bool deep) -
5303 : QDomCharacterDataPrivate(n, deep) -
5304{ -
5305}
executed: }
Execution Count:6
6
5306 -
5307 -
5308QDomNodePrivate* QDomCommentPrivate::cloneNode(bool deep) -
5309{ -
5310 QDomNodePrivate* p = new QDomCommentPrivate(this, deep);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomCommentPrivate(this, deep);
-
5311 // We are not interested in this node -
5312 p->ref.deref();
never executed (the execution status of this line is deduced): p->ref.deref();
-
5313 return p;
never executed: return p;
0
5314} -
5315 -
5316void QDomCommentPrivate::save(QTextStream& s, int depth, int indent) const -
5317{ -
5318 /* We don't output whitespace if we would pollute a text node. */ -
5319 if (!(prev && prev->isText()))
evaluated: prev
TRUEFALSE
yes
Evaluation Count:1553
yes
Evaluation Count:90
evaluated: prev->isText()
TRUEFALSE
yes
Evaluation Count:408
yes
Evaluation Count:1145
90-1553
5320 s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
executed: s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
Execution Count:1235
1235
5321 -
5322 s << "<!--" << value;
executed (the execution status of this line is deduced): s << "<!--" << value;
-
5323 if (value.endsWith(QLatin1Char('-')))
partially evaluated: value.endsWith(QLatin1Char('-'))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1643
0-1643
5324 s << ' '; // Ensures that XML comment doesn't end with --->
never executed: s << ' ';
0
5325 s << "-->";
executed (the execution status of this line is deduced): s << "-->";
-
5326 -
5327 if (!(next && next->isText()))
evaluated: next
TRUEFALSE
yes
Evaluation Count:1323
yes
Evaluation Count:320
evaluated: next->isText()
TRUEFALSE
yes
Evaluation Count:320
yes
Evaluation Count:1003
320-1323
5328 s << endl;
executed: s << endl;
Execution Count:1323
1323
5329}
executed: }
Execution Count:1643
1643
5330 -
5331/************************************************************** -
5332 * -
5333 * QDomComment -
5334 * -
5335 **************************************************************/ -
5336 -
5337/*! -
5338 \class QDomComment -
5339 \reentrant -
5340 \brief The QDomComment class represents an XML comment. -
5341 -
5342 \inmodule QtXml -
5343 \ingroup xml-tools -
5344 -
5345 A comment in the parsed XML such as this: -
5346 -
5347 \snippet code/src_xml_dom_qdom.cpp 15 -
5348 -
5349 is represented by QDomComment objects in the parsed Dom tree. -
5350 -
5351 For further information about the Document Object Model see -
5352 \l{W3C DOM Level 1}{Level 1} and -
5353 \l{W3C DOM Level 2}{Level 2 Core}. -
5354 For a more general introduction of the DOM implementation see the -
5355 QDomDocument documentation. -
5356*/ -
5357 -
5358/*! -
5359 Constructs an empty comment. To construct a comment with content, -
5360 use the QDomDocument::createComment() function. -
5361*/ -
5362QDomComment::QDomComment() -
5363 : QDomCharacterData() -
5364{ -
5365}
never executed: }
0
5366 -
5367/*! -
5368 Constructs a copy of \a x. -
5369 -
5370 The data of the copy is shared (shallow copy): modifying one node -
5371 will also change the other. If you want to make a deep copy, use -
5372 cloneNode(). -
5373*/ -
5374QDomComment::QDomComment(const QDomComment& x) -
5375 : QDomCharacterData(x) -
5376{ -
5377}
never executed: }
0
5378 -
5379QDomComment::QDomComment(QDomCommentPrivate* n) -
5380 : QDomCharacterData(n) -
5381{ -
5382}
executed: }
Execution Count:19
19
5383 -
5384/*! -
5385 Assigns \a x to this DOM comment. -
5386 -
5387 The data of the copy is shared (shallow copy): modifying one node -
5388 will also change the other. If you want to make a deep copy, use -
5389 cloneNode(). -
5390*/ -
5391QDomComment& QDomComment::operator= (const QDomComment& x) -
5392{ -
5393 return (QDomComment&) QDomNode::operator=(x);
never executed: return (QDomComment&) QDomNode::operator=(x);
0
5394} -
5395 -
5396/*! -
5397 \fn QDomNode::NodeType QDomComment::nodeType() const -
5398 -
5399 Returns \c CommentNode. -
5400*/ -
5401 -
5402/************************************************************** -
5403 * -
5404 * QDomCDATASectionPrivate -
5405 * -
5406 **************************************************************/ -
5407 -
5408QDomCDATASectionPrivate::QDomCDATASectionPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, -
5409 const QString& val) -
5410 : QDomTextPrivate(d, parent, val) -
5411{ -
5412 name = QLatin1String("#cdata-section");
executed (the execution status of this line is deduced): name = QLatin1String("#cdata-section");
-
5413}
executed: }
Execution Count:203
203
5414 -
5415QDomCDATASectionPrivate::QDomCDATASectionPrivate(QDomCDATASectionPrivate* n, bool deep) -
5416 : QDomTextPrivate(n, deep) -
5417{ -
5418}
executed: }
Execution Count:6
6
5419 -
5420QDomNodePrivate* QDomCDATASectionPrivate::cloneNode(bool deep) -
5421{ -
5422 QDomNodePrivate* p = new QDomCDATASectionPrivate(this, deep);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomCDATASectionPrivate(this, deep);
-
5423 // We are not interested in this node -
5424 p->ref.deref();
never executed (the execution status of this line is deduced): p->ref.deref();
-
5425 return p;
never executed: return p;
0
5426} -
5427 -
5428void QDomCDATASectionPrivate::save(QTextStream& s, int, int) const -
5429{ -
5430 // ### How do we escape "]]>" ? -
5431 // "]]>" is not allowed; so there should be none in value anyway -
5432 s << "<![CDATA[" << value << "]]>";
executed (the execution status of this line is deduced): s << "<![CDATA[" << value << "]]>";
-
5433}
executed: }
Execution Count:155
155
5434 -
5435/************************************************************** -
5436 * -
5437 * QDomCDATASection -
5438 * -
5439 **************************************************************/ -
5440 -
5441/*! -
5442 \class QDomCDATASection -
5443 \reentrant -
5444 \brief The QDomCDATASection class represents an XML CDATA section. -
5445 -
5446 \inmodule QtXml -
5447 \ingroup xml-tools -
5448 -
5449 CDATA sections are used to escape blocks of text containing -
5450 characters that would otherwise be regarded as markup. The only -
5451 delimiter that is recognized in a CDATA section is the "]]&gt;" -
5452 string that terminates the CDATA section. CDATA sections cannot be -
5453 nested. Their primary purpose is for including material such as -
5454 XML fragments, without needing to escape all the delimiters. -
5455 -
5456 Adjacent QDomCDATASection nodes are not merged by the -
5457 QDomNode::normalize() function. -
5458 -
5459 For further information about the Document Object Model see -
5460 \l{http://www.w3.org/TR/REC-DOM-Level-1/} and -
5461 \l{http://www.w3.org/TR/DOM-Level-2-Core/}. -
5462 For a more general introduction of the DOM implementation see the -
5463 QDomDocument documentation. -
5464*/ -
5465 -
5466/*! -
5467 Constructs an empty CDATA section. To create a CDATA section with -
5468 content, use the QDomDocument::createCDATASection() function. -
5469*/ -
5470QDomCDATASection::QDomCDATASection() -
5471 : QDomText() -
5472{ -
5473}
never executed: }
0
5474 -
5475/*! -
5476 Constructs a copy of \a x. -
5477 -
5478 The data of the copy is shared (shallow copy): modifying one node -
5479 will also change the other. If you want to make a deep copy, use -
5480 cloneNode(). -
5481*/ -
5482QDomCDATASection::QDomCDATASection(const QDomCDATASection& x) -
5483 : QDomText(x) -
5484{ -
5485}
never executed: }
0
5486 -
5487QDomCDATASection::QDomCDATASection(QDomCDATASectionPrivate* n) -
5488 : QDomText(n) -
5489{ -
5490}
executed: }
Execution Count:19
19
5491 -
5492/*! -
5493 Assigns \a x to this CDATA section. -
5494 -
5495 The data of the copy is shared (shallow copy): modifying one node -
5496 will also change the other. If you want to make a deep copy, use -
5497 cloneNode(). -
5498*/ -
5499QDomCDATASection& QDomCDATASection::operator= (const QDomCDATASection& x) -
5500{ -
5501 return (QDomCDATASection&) QDomNode::operator=(x);
never executed: return (QDomCDATASection&) QDomNode::operator=(x);
0
5502} -
5503 -
5504/*! -
5505 \fn QDomNode::NodeType QDomCDATASection::nodeType() const -
5506 -
5507 Returns \c CDATASection. -
5508*/ -
5509 -
5510/************************************************************** -
5511 * -
5512 * QDomNotationPrivate -
5513 * -
5514 **************************************************************/ -
5515 -
5516QDomNotationPrivate::QDomNotationPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, -
5517 const QString& aname, -
5518 const QString& pub, const QString& sys) -
5519 : QDomNodePrivate(d, parent) -
5520{ -
5521 name = aname;
executed (the execution status of this line is deduced): name = aname;
-
5522 m_pub = pub;
executed (the execution status of this line is deduced): m_pub = pub;
-
5523 m_sys = sys;
executed (the execution status of this line is deduced): m_sys = sys;
-
5524}
executed: }
Execution Count:2
2
5525 -
5526QDomNotationPrivate::QDomNotationPrivate(QDomNotationPrivate* n, bool deep) -
5527 : QDomNodePrivate(n, deep) -
5528{ -
5529 m_sys = n->m_sys;
never executed (the execution status of this line is deduced): m_sys = n->m_sys;
-
5530 m_pub = n->m_pub;
never executed (the execution status of this line is deduced): m_pub = n->m_pub;
-
5531}
never executed: }
0
5532 -
5533QDomNodePrivate* QDomNotationPrivate::cloneNode(bool deep) -
5534{ -
5535 QDomNodePrivate* p = new QDomNotationPrivate(this, deep);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomNotationPrivate(this, deep);
-
5536 // We are not interested in this node -
5537 p->ref.deref();
never executed (the execution status of this line is deduced): p->ref.deref();
-
5538 return p;
never executed: return p;
0
5539} -
5540 -
5541void QDomNotationPrivate::save(QTextStream& s, int, int) const -
5542{ -
5543 s << "<!NOTATION " << name << ' ';
never executed (the execution status of this line is deduced): s << "<!NOTATION " << name << ' ';
-
5544 if (!m_pub.isNull()) {
never evaluated: !m_pub.isNull()
0
5545 s << "PUBLIC " << quotedValue(m_pub);
never executed (the execution status of this line is deduced): s << "PUBLIC " << quotedValue(m_pub);
-
5546 if (!m_sys.isNull())
never evaluated: !m_sys.isNull()
0
5547 s << ' ' << quotedValue(m_sys);
never executed: s << ' ' << quotedValue(m_sys);
0
5548 } else {
never executed: }
0
5549 s << "SYSTEM " << quotedValue(m_sys);
never executed (the execution status of this line is deduced): s << "SYSTEM " << quotedValue(m_sys);
-
5550 }
never executed: }
0
5551 s << '>' << endl;
never executed (the execution status of this line is deduced): s << '>' << endl;
-
5552}
never executed: }
0
5553 -
5554/************************************************************** -
5555 * -
5556 * QDomNotation -
5557 * -
5558 **************************************************************/ -
5559 -
5560#define IMPL ((QDomNotationPrivate*)impl) -
5561 -
5562/*! -
5563 \class QDomNotation -
5564 \reentrant -
5565 \brief The QDomNotation class represents an XML notation. -
5566 -
5567 \inmodule QtXml -
5568 \ingroup xml-tools -
5569 -
5570 A notation either declares, by name, the format of an unparsed -
5571 entity (see section 4.7 of the XML 1.0 specification), or is used -
5572 for formal declaration of processing instruction targets (see -
5573 section 2.6 of the XML 1.0 specification). -
5574 -
5575 DOM does not support editing notation nodes; they are therefore -
5576 read-only. -
5577 -
5578 A notation node does not have any parent. -
5579 -
5580 You can retrieve the publicId() and systemId() from a notation -
5581 node. -
5582 -
5583 For further information about the Document Object Model see -
5584 \l{http://www.w3.org/TR/REC-DOM-Level-1/}{Level 1} and -
5585 \l{http://www.w3.org/TR/DOM-Level-2-Core/}{Level 2 Core}. -
5586 For a more general introduction of the DOM implementation see the -
5587 QDomDocument documentation. -
5588*/ -
5589 -
5590 -
5591/*! -
5592 Constructor. -
5593*/ -
5594QDomNotation::QDomNotation() -
5595 : QDomNode() -
5596{ -
5597}
never executed: }
0
5598 -
5599/*! -
5600 Constructs a copy of \a x. -
5601 -
5602 The data of the copy is shared (shallow copy): modifying one node -
5603 will also change the other. If you want to make a deep copy, use -
5604 cloneNode(). -
5605*/ -
5606QDomNotation::QDomNotation(const QDomNotation& x) -
5607 : QDomNode(x) -
5608{ -
5609}
never executed: }
0
5610 -
5611QDomNotation::QDomNotation(QDomNotationPrivate* n) -
5612 : QDomNode(n) -
5613{ -
5614}
executed: }
Execution Count:2
2
5615 -
5616/*! -
5617 Assigns \a x to this DOM notation. -
5618 -
5619 The data of the copy is shared (shallow copy): modifying one node -
5620 will also change the other. If you want to make a deep copy, use -
5621 cloneNode(). -
5622*/ -
5623QDomNotation& QDomNotation::operator= (const QDomNotation& x) -
5624{ -
5625 return (QDomNotation&) QDomNode::operator=(x);
never executed: return (QDomNotation&) QDomNode::operator=(x);
0
5626} -
5627 -
5628/*! -
5629 \fn QDomNode::NodeType QDomNotation::nodeType() const -
5630 -
5631 Returns \c NotationNode. -
5632*/ -
5633 -
5634/*! -
5635 Returns the public identifier of this notation. -
5636*/ -
5637QString QDomNotation::publicId() const -
5638{ -
5639 if (!impl)
never evaluated: !impl
0
5640 return QString();
never executed: return QString();
0
5641 return IMPL->m_pub;
never executed: return ((QDomNotationPrivate*)impl)->m_pub;
0
5642} -
5643 -
5644/*! -
5645 Returns the system identifier of this notation. -
5646*/ -
5647QString QDomNotation::systemId() const -
5648{ -
5649 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5650 return QString();
never executed: return QString();
0
5651 return IMPL->m_sys;
executed: return ((QDomNotationPrivate*)impl)->m_sys;
Execution Count:2
2
5652} -
5653 -
5654#undef IMPL -
5655 -
5656/************************************************************** -
5657 * -
5658 * QDomEntityPrivate -
5659 * -
5660 **************************************************************/ -
5661 -
5662QDomEntityPrivate::QDomEntityPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, -
5663 const QString& aname, -
5664 const QString& pub, const QString& sys, const QString& notation) -
5665 : QDomNodePrivate(d, parent) -
5666{ -
5667 name = aname;
executed (the execution status of this line is deduced): name = aname;
-
5668 m_pub = pub;
executed (the execution status of this line is deduced): m_pub = pub;
-
5669 m_sys = sys;
executed (the execution status of this line is deduced): m_sys = sys;
-
5670 m_notationName = notation;
executed (the execution status of this line is deduced): m_notationName = notation;
-
5671}
executed: }
Execution Count:6
6
5672 -
5673QDomEntityPrivate::QDomEntityPrivate(QDomEntityPrivate* n, bool deep) -
5674 : QDomNodePrivate(n, deep) -
5675{ -
5676 m_sys = n->m_sys;
executed (the execution status of this line is deduced): m_sys = n->m_sys;
-
5677 m_pub = n->m_pub;
executed (the execution status of this line is deduced): m_pub = n->m_pub;
-
5678 m_notationName = n->m_notationName;
executed (the execution status of this line is deduced): m_notationName = n->m_notationName;
-
5679}
executed: }
Execution Count:2
2
5680 -
5681QDomNodePrivate* QDomEntityPrivate::cloneNode(bool deep) -
5682{ -
5683 QDomNodePrivate* p = new QDomEntityPrivate(this, deep);
executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomEntityPrivate(this, deep);
-
5684 // We are not interested in this node -
5685 p->ref.deref();
executed (the execution status of this line is deduced): p->ref.deref();
-
5686 return p;
executed: return p;
Execution Count:2
2
5687} -
5688 -
5689/* -
5690 Encode an entity value upon saving. -
5691*/ -
5692static QByteArray encodeEntity(const QByteArray& str) -
5693{ -
5694 QByteArray tmp(str);
executed (the execution status of this line is deduced): QByteArray tmp(str);
-
5695 int len = tmp.size();
executed (the execution status of this line is deduced): int len = tmp.size();
-
5696 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
5697 const char* d = tmp.constData();
executed (the execution status of this line is deduced): const char* d = tmp.constData();
-
5698 while (i < len) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
5699 if (d[i] == '%'){
partially evaluated: d[i] == '%'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
5700 tmp.replace(i, 1, "&#60;");
never executed (the execution status of this line is deduced): tmp.replace(i, 1, "&#60;");
-
5701 d = tmp.constData();
never executed (the execution status of this line is deduced): d = tmp.constData();
-
5702 len += 4;
never executed (the execution status of this line is deduced): len += 4;
-
5703 i += 5;
never executed (the execution status of this line is deduced): i += 5;
-
5704 }
never executed: }
0
5705 else if (d[i] == '"') {
partially evaluated: d[i] == '"'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
5706 tmp.replace(i, 1, "&#34;");
never executed (the execution status of this line is deduced): tmp.replace(i, 1, "&#34;");
-
5707 d = tmp.constData();
never executed (the execution status of this line is deduced): d = tmp.constData();
-
5708 len += 4;
never executed (the execution status of this line is deduced): len += 4;
-
5709 i += 5;
never executed (the execution status of this line is deduced): i += 5;
-
5710 } else if (d[i] == '&' && i + 1 < len && d[i+1] == '#') {
never executed: }
partially evaluated: d[i] == '&'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
never evaluated: i + 1 < len
never evaluated: d[i+1] == '#'
0-6
5711 // Don't encode &lt; or &quot; or &custom;. -
5712 // Only encode character references -
5713 tmp.replace(i, 1, "&#38;");
never executed (the execution status of this line is deduced): tmp.replace(i, 1, "&#38;");
-
5714 d = tmp.constData();
never executed (the execution status of this line is deduced): d = tmp.constData();
-
5715 len += 4;
never executed (the execution status of this line is deduced): len += 4;
-
5716 i += 5;
never executed (the execution status of this line is deduced): i += 5;
-
5717 } else {
never executed: }
0
5718 ++i;
executed (the execution status of this line is deduced): ++i;
-
5719 }
executed: }
Execution Count:6
6
5720 } -
5721 -
5722 return tmp;
executed: return tmp;
Execution Count:2
2
5723} -
5724 -
5725void QDomEntityPrivate::save(QTextStream& s, int, int) const -
5726{ -
5727 QString _name = name;
executed (the execution status of this line is deduced): QString _name = name;
-
5728 if (_name.startsWith(QLatin1Char('%')))
partially evaluated: _name.startsWith(QLatin1Char('%'))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
5729 _name = QLatin1String("% ") + _name.mid(1);
never executed: _name = QLatin1String("% ") + _name.mid(1);
0
5730 -
5731 if (m_sys.isNull() && m_pub.isNull()) {
evaluated: m_sys.isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
partially evaluated: m_pub.isNull()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
5732 s << "<!ENTITY " << _name << " \"" << encodeEntity(value.toUtf8()) << "\">" << endl;
executed (the execution status of this line is deduced): s << "<!ENTITY " << _name << " \"" << encodeEntity(value.toUtf8()) << "\">" << endl;
-
5733 } else {
executed: }
Execution Count:2
2
5734 s << "<!ENTITY " << _name << ' ';
executed (the execution status of this line is deduced): s << "<!ENTITY " << _name << ' ';
-
5735 if (m_pub.isNull()) {
partially evaluated: m_pub.isNull()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
5736 s << "SYSTEM " << quotedValue(m_sys);
executed (the execution status of this line is deduced): s << "SYSTEM " << quotedValue(m_sys);
-
5737 } else {
executed: }
Execution Count:2
2
5738 s << "PUBLIC " << quotedValue(m_pub) << ' ' << quotedValue(m_sys);
never executed (the execution status of this line is deduced): s << "PUBLIC " << quotedValue(m_pub) << ' ' << quotedValue(m_sys);
-
5739 }
never executed: }
0
5740 if (! m_notationName.isNull()) {
partially evaluated: ! m_notationName.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5741 s << " NDATA " << m_notationName;
never executed (the execution status of this line is deduced): s << " NDATA " << m_notationName;
-
5742 }
never executed: }
0
5743 s << '>' << endl;
executed (the execution status of this line is deduced): s << '>' << endl;
-
5744 }
executed: }
Execution Count:2
2
5745} -
5746 -
5747/************************************************************** -
5748 * -
5749 * QDomEntity -
5750 * -
5751 **************************************************************/ -
5752 -
5753#define IMPL ((QDomEntityPrivate*)impl) -
5754 -
5755/*! -
5756 \class QDomEntity -
5757 \reentrant -
5758 \brief The QDomEntity class represents an XML entity. -
5759 -
5760 \inmodule QtXml -
5761 \ingroup xml-tools -
5762 -
5763 This class represents an entity in an XML document, either parsed -
5764 or unparsed. Note that this models the entity itself not the -
5765 entity declaration. -
5766 -
5767 DOM does not support editing entity nodes; if a user wants to make -
5768 changes to the contents of an entity, every related -
5769 QDomEntityReference node must be replaced in the DOM tree by a -
5770 clone of the entity's contents, and then the desired changes must -
5771 be made to each of the clones instead. All the descendants of an -
5772 entity node are read-only. -
5773 -
5774 An entity node does not have any parent. -
5775 -
5776 You can access the entity's publicId(), systemId() and -
5777 notationName() when available. -
5778 -
5779 For further information about the Document Object Model see -
5780 \l{http://www.w3.org/TR/REC-DOM-Level-1/}{Level 1} and -
5781 \l{http://www.w3.org/TR/DOM-Level-2-Core/}{Level 2 Core}. -
5782 For a more general introduction of the DOM implementation see the -
5783 QDomDocument documentation. -
5784*/ -
5785 -
5786 -
5787/*! -
5788 Constructs an empty entity. -
5789*/ -
5790QDomEntity::QDomEntity() -
5791 : QDomNode() -
5792{ -
5793}
never executed: }
0
5794 -
5795 -
5796/*! -
5797 Constructs a copy of \a x. -
5798 -
5799 The data of the copy is shared (shallow copy): modifying one node -
5800 will also change the other. If you want to make a deep copy, use -
5801 cloneNode(). -
5802*/ -
5803QDomEntity::QDomEntity(const QDomEntity& x) -
5804 : QDomNode(x) -
5805{ -
5806}
never executed: }
0
5807 -
5808QDomEntity::QDomEntity(QDomEntityPrivate* n) -
5809 : QDomNode(n) -
5810{ -
5811}
executed: }
Execution Count:4
4
5812 -
5813/*! -
5814 Assigns \a x to this DOM entity. -
5815 -
5816 The data of the copy is shared (shallow copy): modifying one node -
5817 will also change the other. If you want to make a deep copy, use -
5818 cloneNode(). -
5819*/ -
5820QDomEntity& QDomEntity::operator= (const QDomEntity& x) -
5821{ -
5822 return (QDomEntity&) QDomNode::operator=(x);
never executed: return (QDomEntity&) QDomNode::operator=(x);
0
5823} -
5824 -
5825/*! -
5826 \fn QDomNode::NodeType QDomEntity::nodeType() const -
5827 -
5828 Returns \c EntityNode. -
5829*/ -
5830 -
5831/*! -
5832 Returns the public identifier associated with this entity. If the -
5833 public identifier was not specified an empty string is returned. -
5834*/ -
5835QString QDomEntity::publicId() const -
5836{ -
5837 if (!impl)
never evaluated: !impl
0
5838 return QString();
never executed: return QString();
0
5839 return IMPL->m_pub;
never executed: return ((QDomEntityPrivate*)impl)->m_pub;
0
5840} -
5841 -
5842/*! -
5843 Returns the system identifier associated with this entity. If the -
5844 system identifier was not specified an empty string is returned. -
5845*/ -
5846QString QDomEntity::systemId() const -
5847{ -
5848 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5849 return QString();
never executed: return QString();
0
5850 return IMPL->m_sys;
executed: return ((QDomEntityPrivate*)impl)->m_sys;
Execution Count:2
2
5851} -
5852 -
5853/*! -
5854 For unparsed entities this function returns the name of the -
5855 notation for the entity. For parsed entities this function returns -
5856 an empty string. -
5857*/ -
5858QString QDomEntity::notationName() const -
5859{ -
5860 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5861 return QString();
never executed: return QString();
0
5862 return IMPL->m_notationName;
executed: return ((QDomEntityPrivate*)impl)->m_notationName;
Execution Count:2
2
5863} -
5864 -
5865#undef IMPL -
5866 -
5867/************************************************************** -
5868 * -
5869 * QDomEntityReferencePrivate -
5870 * -
5871 **************************************************************/ -
5872 -
5873QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& aname) -
5874 : QDomNodePrivate(d, parent) -
5875{ -
5876 name = aname;
executed (the execution status of this line is deduced): name = aname;
-
5877}
executed: }
Execution Count:33
33
5878 -
5879QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomNodePrivate* n, bool deep) -
5880 : QDomNodePrivate(n, deep) -
5881{ -
5882}
executed: }
Execution Count:6
6
5883 -
5884QDomNodePrivate* QDomEntityReferencePrivate::cloneNode(bool deep) -
5885{ -
5886 QDomNodePrivate* p = new QDomEntityReferencePrivate(this, deep);
never executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomEntityReferencePrivate(this, deep);
-
5887 // We are not interested in this node -
5888 p->ref.deref();
never executed (the execution status of this line is deduced): p->ref.deref();
-
5889 return p;
never executed: return p;
0
5890} -
5891 -
5892void QDomEntityReferencePrivate::save(QTextStream& s, int, int) const -
5893{ -
5894 s << '&' << name << ';';
executed (the execution status of this line is deduced): s << '&' << name << ';';
-
5895}
executed: }
Execution Count:2
2
5896 -
5897/************************************************************** -
5898 * -
5899 * QDomEntityReference -
5900 * -
5901 **************************************************************/ -
5902 -
5903/*! -
5904 \class QDomEntityReference -
5905 \reentrant -
5906 \brief The QDomEntityReference class represents an XML entity reference. -
5907 -
5908 \inmodule QtXml -
5909 \ingroup xml-tools -
5910 -
5911 A QDomEntityReference object may be inserted into the DOM tree -
5912 when an entity reference is in the source document, or when the -
5913 user wishes to insert an entity reference. -
5914 -
5915 Note that character references and references to predefined -
5916 entities are expanded by the XML processor so that characters are -
5917 represented by their Unicode equivalent rather than by an entity -
5918 reference. -
5919 -
5920 Moreover, the XML processor may completely expand references to -
5921 entities while building the DOM tree, instead of providing -
5922 QDomEntityReference objects. -
5923 -
5924 If it does provide such objects, then for a given entity reference -
5925 node, it may be that there is no entity node representing the -
5926 referenced entity; but if such an entity exists, then the child -
5927 list of the entity reference node is the same as that of the -
5928 entity node. As with the entity node, all descendants of the -
5929 entity reference are read-only. -
5930 -
5931 For further information about the Document Object Model see -
5932 \l{http://www.w3.org/TR/REC-DOM-Level-1/}{Level 1} and -
5933 \l{http://www.w3.org/TR/DOM-Level-2-Core/}{Level 2 Core}. -
5934 For a more general introduction of the DOM implementation see the -
5935 QDomDocument documentation. -
5936*/ -
5937 -
5938/*! -
5939 Constructs an empty entity reference. Use -
5940 QDomDocument::createEntityReference() to create a entity reference -
5941 with content. -
5942*/ -
5943QDomEntityReference::QDomEntityReference() -
5944 : QDomNode() -
5945{ -
5946}
never executed: }
0
5947 -
5948/*! -
5949 Constructs a copy of \a x. -
5950 -
5951 The data of the copy is shared (shallow copy): modifying one node -
5952 will also change the other. If you want to make a deep copy, use -
5953 cloneNode(). -
5954*/ -
5955QDomEntityReference::QDomEntityReference(const QDomEntityReference& x) -
5956 : QDomNode(x) -
5957{ -
5958}
never executed: }
0
5959 -
5960QDomEntityReference::QDomEntityReference(QDomEntityReferencePrivate* n) -
5961 : QDomNode(n) -
5962{ -
5963}
executed: }
Execution Count:40
40
5964 -
5965/*! -
5966 Assigns \a x to this entity reference. -
5967 -
5968 The data of the copy is shared (shallow copy): modifying one node -
5969 will also change the other. If you want to make a deep copy, use -
5970 cloneNode(). -
5971*/ -
5972QDomEntityReference& QDomEntityReference::operator= (const QDomEntityReference& x) -
5973{ -
5974 return (QDomEntityReference&) QDomNode::operator=(x);
never executed: return (QDomEntityReference&) QDomNode::operator=(x);
0
5975} -
5976 -
5977/*! -
5978 \fn QDomNode::NodeType QDomEntityReference::nodeType() const -
5979 -
5980 Returns \c EntityReference. -
5981*/ -
5982 -
5983/************************************************************** -
5984 * -
5985 * QDomProcessingInstructionPrivate -
5986 * -
5987 **************************************************************/ -
5988 -
5989QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomDocumentPrivate* d, -
5990 QDomNodePrivate* parent, const QString& target, const QString& data) -
5991 : QDomNodePrivate(d, parent) -
5992{ -
5993 name = target;
executed (the execution status of this line is deduced): name = target;
-
5994 value = data;
executed (the execution status of this line is deduced): value = data;
-
5995}
executed: }
Execution Count:151
151
5996 -
5997QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomProcessingInstructionPrivate* n, bool deep) -
5998 : QDomNodePrivate(n, deep) -
5999{ -
6000}
executed: }
Execution Count:7
7
6001 -
6002 -
6003QDomNodePrivate* QDomProcessingInstructionPrivate::cloneNode(bool deep) -
6004{ -
6005 QDomNodePrivate* p = new QDomProcessingInstructionPrivate(this, deep);
executed (the execution status of this line is deduced): QDomNodePrivate* p = new QDomProcessingInstructionPrivate(this, deep);
-
6006 // We are not interested in this node -
6007 p->ref.deref();
executed (the execution status of this line is deduced): p->ref.deref();
-
6008 return p;
executed: return p;
Execution Count:1
1
6009} -
6010 -
6011void QDomProcessingInstructionPrivate::save(QTextStream& s, int, int) const -
6012{ -
6013 s << "<?" << name << ' ' << value << "?>" << endl;
executed (the execution status of this line is deduced): s << "<?" << name << ' ' << value << "?>" << endl;
-
6014}
executed: }
Execution Count:49
49
6015 -
6016/************************************************************** -
6017 * -
6018 * QDomProcessingInstruction -
6019 * -
6020 **************************************************************/ -
6021 -
6022/*! -
6023 \class QDomProcessingInstruction -
6024 \reentrant -
6025 \brief The QDomProcessingInstruction class represents an XML processing -
6026 instruction. -
6027 -
6028 \inmodule QtXml -
6029 \ingroup xml-tools -
6030 -
6031 Processing instructions are used in XML to keep processor-specific -
6032 information in the text of the document. -
6033 -
6034 The XML declaration that appears at the top of an XML document, -
6035 typically \tt{<?xml version='1.0' encoding='UTF-8'?>}, is treated by QDom as a -
6036 processing instruction. This is unfortunate, since the XML declaration is -
6037 not a processing instruction; among other differences, it cannot be -
6038 inserted into a document anywhere but on the first line. -
6039 -
6040 Do not use this function to create an xml declaration, since although it -
6041 has the same syntax as a processing instruction, it isn't, and might not -
6042 be treated by QDom as such. -
6043 -
6044 The content of the processing instruction is retrieved with data() -
6045 and set with setData(). The processing instruction's target is -
6046 retrieved with target(). -
6047 -
6048 For further information about the Document Object Model see -
6049 \l{http://www.w3.org/TR/REC-DOM-Level-1/}{Level 1} and -
6050 \l{http://www.w3.org/TR/DOM-Level-2-Core/}{Level 2 Core}. -
6051 For a more general introduction of the DOM implementation see the -
6052 QDomDocument documentation. -
6053*/ -
6054 -
6055/*! -
6056 Constructs an empty processing instruction. Use -
6057 QDomDocument::createProcessingInstruction() to create a processing -
6058 instruction with content. -
6059*/ -
6060QDomProcessingInstruction::QDomProcessingInstruction() -
6061 : QDomNode() -
6062{ -
6063}
never executed: }
0
6064 -
6065/*! -
6066 Constructs a copy of \a x. -
6067 -
6068 The data of the copy is shared (shallow copy): modifying one node -
6069 will also change the other. If you want to make a deep copy, use -
6070 cloneNode(). -
6071*/ -
6072QDomProcessingInstruction::QDomProcessingInstruction(const QDomProcessingInstruction& x) -
6073 : QDomNode(x) -
6074{ -
6075}
never executed: }
0
6076 -
6077QDomProcessingInstruction::QDomProcessingInstruction(QDomProcessingInstructionPrivate* n) -
6078 : QDomNode(n) -
6079{ -
6080}
executed: }
Execution Count:19
19
6081 -
6082/*! -
6083 Assigns \a x to this processing instruction. -
6084 -
6085 The data of the copy is shared (shallow copy): modifying one node -
6086 will also change the other. If you want to make a deep copy, use -
6087 cloneNode(). -
6088*/ -
6089QDomProcessingInstruction& QDomProcessingInstruction::operator= (const QDomProcessingInstruction& x) -
6090{ -
6091 return (QDomProcessingInstruction&) QDomNode::operator=(x);
never executed: return (QDomProcessingInstruction&) QDomNode::operator=(x);
0
6092} -
6093 -
6094/*! -
6095 \fn QDomNode::NodeType QDomProcessingInstruction::nodeType() const -
6096 -
6097 Returns \c ProcessingInstructionNode. -
6098*/ -
6099 -
6100/*! -
6101 Returns the target of this processing instruction. -
6102 -
6103 \sa data() -
6104*/ -
6105QString QDomProcessingInstruction::target() const -
6106{ -
6107 if (!impl)
never evaluated: !impl
0
6108 return QString();
never executed: return QString();
0
6109 return impl->nodeName();
never executed: return impl->nodeName();
0
6110} -
6111 -
6112/*! -
6113 Returns the content of this processing instruction. -
6114 -
6115 \sa setData(), target() -
6116*/ -
6117QString QDomProcessingInstruction::data() const -
6118{ -
6119 if (!impl)
never evaluated: !impl
0
6120 return QString();
never executed: return QString();
0
6121 return impl->nodeValue();
never executed: return impl->nodeValue();
0
6122} -
6123 -
6124/*! -
6125 Sets the data contained in the processing instruction to \a d. -
6126 -
6127 \sa data() -
6128*/ -
6129void QDomProcessingInstruction::setData(const QString& d) -
6130{ -
6131 if (!impl)
never evaluated: !impl
0
6132 return;
never executed: return;
0
6133 impl->setNodeValue(d);
never executed (the execution status of this line is deduced): impl->setNodeValue(d);
-
6134}
never executed: }
0
6135 -
6136/************************************************************** -
6137 * -
6138 * QDomDocumentPrivate -
6139 * -
6140 **************************************************************/ -
6141 -
6142QDomDocumentPrivate::QDomDocumentPrivate() -
6143 : QDomNodePrivate(0), -
6144 impl(new QDomImplementationPrivate), -
6145 nodeListTime(1) -
6146{ -
6147 type = new QDomDocumentTypePrivate(this, this);
executed (the execution status of this line is deduced): type = new QDomDocumentTypePrivate(this, this);
-
6148 type->ref.deref();
executed (the execution status of this line is deduced): type->ref.deref();
-
6149 -
6150 name = QLatin1String("#document");
executed (the execution status of this line is deduced): name = QLatin1String("#document");
-
6151}
executed: }
Execution Count:422
422
6152 -
6153QDomDocumentPrivate::QDomDocumentPrivate(const QString& aname) -
6154 : QDomNodePrivate(0), -
6155 impl(new QDomImplementationPrivate), -
6156 nodeListTime(1) -
6157{ -
6158 type = new QDomDocumentTypePrivate(this, this);
executed (the execution status of this line is deduced): type = new QDomDocumentTypePrivate(this, this);
-
6159 type->ref.deref();
executed (the execution status of this line is deduced): type->ref.deref();
-
6160 type->name = aname;
executed (the execution status of this line is deduced): type->name = aname;
-
6161 -
6162 name = QLatin1String("#document");
executed (the execution status of this line is deduced): name = QLatin1String("#document");
-
6163}
executed: }
Execution Count:21
21
6164 -
6165QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentTypePrivate* dt) -
6166 : QDomNodePrivate(0), -
6167 impl(new QDomImplementationPrivate), -
6168 nodeListTime(1) -
6169{ -
6170 if (dt != 0) {
evaluated: dt != 0
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:18
10-18
6171 type = dt;
executed (the execution status of this line is deduced): type = dt;
-
6172 } else {
executed: }
Execution Count:10
10
6173 type = new QDomDocumentTypePrivate(this, this);
executed (the execution status of this line is deduced): type = new QDomDocumentTypePrivate(this, this);
-
6174 type->ref.deref();
executed (the execution status of this line is deduced): type->ref.deref();
-
6175 }
executed: }
Execution Count:18
18
6176 -
6177 name = QLatin1String("#document");
executed (the execution status of this line is deduced): name = QLatin1String("#document");
-
6178}
executed: }
Execution Count:28
28
6179 -
6180QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentPrivate* n, bool deep) -
6181 : QDomNodePrivate(n, deep), -
6182 impl(n->impl->clone()), -
6183 nodeListTime(1) -
6184{ -
6185 type = static_cast<QDomDocumentTypePrivate*>(n->type->cloneNode());
executed (the execution status of this line is deduced): type = static_cast<QDomDocumentTypePrivate*>(n->type->cloneNode());
-
6186 type->setParent(this);
executed (the execution status of this line is deduced): type->setParent(this);
-
6187}
executed: }
Execution Count:1
1
6188 -
6189QDomDocumentPrivate::~QDomDocumentPrivate() -
6190{ -
6191} -
6192 -
6193void QDomDocumentPrivate::clear() -
6194{ -
6195 impl.reset();
executed (the execution status of this line is deduced): impl.reset();
-
6196 type.reset();
executed (the execution status of this line is deduced): type.reset();
-
6197 QDomNodePrivate::clear();
executed (the execution status of this line is deduced): QDomNodePrivate::clear();
-
6198}
executed: }
Execution Count:385
385
6199 -
6200static void initializeReader(QXmlSimpleReader &reader, bool namespaceProcessing) -
6201{ -
6202 reader.setFeature(QLatin1String("http://xml.org/sax/features/namespaces"), namespaceProcessing);
executed (the execution status of this line is deduced): reader.setFeature(QLatin1String("http://xml.org/sax/features/namespaces"), namespaceProcessing);
-
6203 reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), !namespaceProcessing);
executed (the execution status of this line is deduced): reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), !namespaceProcessing);
-
6204 reader.setFeature(QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData"), false); // Shouldn't change in Qt 4
executed (the execution status of this line is deduced): reader.setFeature(QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData"), false);
-
6205}
executed: }
Execution Count:377
377
6206 -
6207bool QDomDocumentPrivate::setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn) -
6208{ -
6209 QXmlSimpleReader reader;
executed (the execution status of this line is deduced): QXmlSimpleReader reader;
-
6210 initializeReader(reader, namespaceProcessing);
executed (the execution status of this line is deduced): initializeReader(reader, namespaceProcessing);
-
6211 return setContent(source, &reader, errorMsg, errorLine, errorColumn);
executed: return setContent(source, &reader, errorMsg, errorLine, errorColumn);
Execution Count:376
376
6212} -
6213 -
6214bool QDomDocumentPrivate::setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn) -
6215{ -
6216 clear();
executed (the execution status of this line is deduced): clear();
-
6217 impl = new QDomImplementationPrivate;
executed (the execution status of this line is deduced): impl = new QDomImplementationPrivate;
-
6218 type = new QDomDocumentTypePrivate(this, this);
executed (the execution status of this line is deduced): type = new QDomDocumentTypePrivate(this, this);
-
6219 type->ref.deref();
executed (the execution status of this line is deduced): type->ref.deref();
-
6220 -
6221 bool namespaceProcessing = reader->feature(QLatin1String("http://xml.org/sax/features/namespaces"))
evaluated: reader->feature(QLatin1String("http://xml.org/sax/features/namespaces"))
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:367
18-367
6222 && !reader->feature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"));
partially evaluated: !reader->feature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"))
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
6223 -
6224 QDomHandler hnd(this, namespaceProcessing);
executed (the execution status of this line is deduced): QDomHandler hnd(this, namespaceProcessing);
-
6225 reader->setContentHandler(&hnd);
executed (the execution status of this line is deduced): reader->setContentHandler(&hnd);
-
6226 reader->setErrorHandler(&hnd);
executed (the execution status of this line is deduced): reader->setErrorHandler(&hnd);
-
6227 reader->setLexicalHandler(&hnd);
executed (the execution status of this line is deduced): reader->setLexicalHandler(&hnd);
-
6228 reader->setDeclHandler(&hnd);
executed (the execution status of this line is deduced): reader->setDeclHandler(&hnd);
-
6229 reader->setDTDHandler(&hnd);
executed (the execution status of this line is deduced): reader->setDTDHandler(&hnd);
-
6230 -
6231 if (!reader->parse(source)) {
evaluated: !reader->parse(source)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:371
14-371
6232 if (errorMsg)
partially evaluated: errorMsg
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
6233 *errorMsg = hnd.errorMsg;
never executed: *errorMsg = hnd.errorMsg;
0
6234 if (errorLine)
partially evaluated: errorLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
6235 *errorLine = hnd.errorLine;
never executed: *errorLine = hnd.errorLine;
0
6236 if (errorColumn)
partially evaluated: errorColumn
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
6237 *errorColumn = hnd.errorColumn;
never executed: *errorColumn = hnd.errorColumn;
0
6238 return false;
executed: return false;
Execution Count:14
14
6239 } -
6240 -
6241 return true;
executed: return true;
Execution Count:371
371
6242} -
6243 -
6244QDomNodePrivate* QDomDocumentPrivate::cloneNode(bool deep) -
6245{ -
6246 QDomNodePrivate *p = new QDomDocumentPrivate(this, deep);
executed (the execution status of this line is deduced): QDomNodePrivate *p = new QDomDocumentPrivate(this, deep);
-
6247 // We are not interested in this node -
6248 p->ref.deref();
executed (the execution status of this line is deduced): p->ref.deref();
-
6249 return p;
executed: return p;
Execution Count:1
1
6250} -
6251 -
6252QDomElementPrivate* QDomDocumentPrivate::documentElement() -
6253{ -
6254 QDomNodePrivate *p = first;
executed (the execution status of this line is deduced): QDomNodePrivate *p = first;
-
6255 while (p && !p->isElement())
partially evaluated: p
TRUEFALSE
yes
Evaluation Count:36
no
Evaluation Count:0
evaluated: !p->isElement()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:35
0-36
6256 p = p->next;
executed: p = p->next;
Execution Count:1
1
6257 -
6258 return static_cast<QDomElementPrivate *>(p);
executed: return static_cast<QDomElementPrivate *>(p);
Execution Count:35
35
6259} -
6260 -
6261QDomElementPrivate* QDomDocumentPrivate::createElement(const QString &tagName) -
6262{ -
6263 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
6264 QString fixedName = fixedXmlName(tagName, &ok);
executed (the execution status of this line is deduced): QString fixedName = fixedXmlName(tagName, &ok);
-
6265 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:37918
10-37918
6266 return 0;
executed: return 0;
Execution Count:10
10
6267 -
6268 QDomElementPrivate *e = new QDomElementPrivate(this, 0, fixedName);
executed (the execution status of this line is deduced): QDomElementPrivate *e = new QDomElementPrivate(this, 0, fixedName);
-
6269 e->ref.deref();
executed (the execution status of this line is deduced): e->ref.deref();
-
6270 return e;
executed: return e;
Execution Count:37918
37918
6271} -
6272 -
6273QDomElementPrivate* QDomDocumentPrivate::createElementNS(const QString &nsURI, const QString &qName) -
6274{ -
6275 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
6276 QString fixedName = fixedXmlName(qName, &ok, true);
executed (the execution status of this line is deduced): QString fixedName = fixedXmlName(qName, &ok, true);
-
6277 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:112
38-112
6278 return 0;
executed: return 0;
Execution Count:38
38
6279 -
6280 QDomElementPrivate *e = new QDomElementPrivate(this, 0, nsURI, fixedName);
executed (the execution status of this line is deduced): QDomElementPrivate *e = new QDomElementPrivate(this, 0, nsURI, fixedName);
-
6281 e->ref.deref();
executed (the execution status of this line is deduced): e->ref.deref();
-
6282 return e;
executed: return e;
Execution Count:112
112
6283} -
6284 -
6285QDomDocumentFragmentPrivate* QDomDocumentPrivate::createDocumentFragment() -
6286{ -
6287 QDomDocumentFragmentPrivate *f = new QDomDocumentFragmentPrivate(this, (QDomNodePrivate*)0);
executed (the execution status of this line is deduced): QDomDocumentFragmentPrivate *f = new QDomDocumentFragmentPrivate(this, (QDomNodePrivate*)0);
-
6288 f->ref.deref();
executed (the execution status of this line is deduced): f->ref.deref();
-
6289 return f;
executed: return f;
Execution Count:19
19
6290} -
6291 -
6292QDomTextPrivate* QDomDocumentPrivate::createTextNode(const QString &data) -
6293{ -
6294 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
6295 QString fixedData = fixedCharData(data, &ok);
executed (the execution status of this line is deduced): QString fixedData = fixedCharData(data, &ok);
-
6296 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:36364
1-36364
6297 return 0;
executed: return 0;
Execution Count:1
1
6298 -
6299 QDomTextPrivate *t = new QDomTextPrivate(this, 0, fixedData);
executed (the execution status of this line is deduced): QDomTextPrivate *t = new QDomTextPrivate(this, 0, fixedData);
-
6300 t->ref.deref();
executed (the execution status of this line is deduced): t->ref.deref();
-
6301 return t;
executed: return t;
Execution Count:36364
36364
6302} -
6303 -
6304QDomCommentPrivate* QDomDocumentPrivate::createComment(const QString &data) -
6305{ -
6306 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
6307 QString fixedData = fixedComment(data, &ok);
executed (the execution status of this line is deduced): QString fixedData = fixedComment(data, &ok);
-
6308 if (!ok)
partially evaluated: !ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1962
0-1962
6309 return 0;
never executed: return 0;
0
6310 -
6311 QDomCommentPrivate *c = new QDomCommentPrivate(this, 0, fixedData);
executed (the execution status of this line is deduced): QDomCommentPrivate *c = new QDomCommentPrivate(this, 0, fixedData);
-
6312 c->ref.deref();
executed (the execution status of this line is deduced): c->ref.deref();
-
6313 return c;
executed: return c;
Execution Count:1962
1962
6314} -
6315 -
6316QDomCDATASectionPrivate* QDomDocumentPrivate::createCDATASection(const QString &data) -
6317{ -
6318 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
6319 QString fixedData = fixedCDataSection(data, &ok);
executed (the execution status of this line is deduced): QString fixedData = fixedCDataSection(data, &ok);
-
6320 if (!ok)
partially evaluated: !ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:203
0-203
6321 return 0;
never executed: return 0;
0
6322 -
6323 QDomCDATASectionPrivate *c = new QDomCDATASectionPrivate(this, 0, fixedData);
executed (the execution status of this line is deduced): QDomCDATASectionPrivate *c = new QDomCDATASectionPrivate(this, 0, fixedData);
-
6324 c->ref.deref();
executed (the execution status of this line is deduced): c->ref.deref();
-
6325 return c;
executed: return c;
Execution Count:203
203
6326} -
6327 -
6328QDomProcessingInstructionPrivate* QDomDocumentPrivate::createProcessingInstruction(const QString &target, -
6329 const QString &data) -
6330{ -
6331 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
6332 QString fixedData = fixedPIData(data, &ok);
executed (the execution status of this line is deduced): QString fixedData = fixedPIData(data, &ok);
-
6333 if (!ok)
partially evaluated: !ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:151
0-151
6334 return 0;
never executed: return 0;
0
6335 // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l')) -
6336 QString fixedTarget = fixedXmlName(target, &ok);
executed (the execution status of this line is deduced): QString fixedTarget = fixedXmlName(target, &ok);
-
6337 if (!ok)
partially evaluated: !ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:151
0-151
6338 return 0;
never executed: return 0;
0
6339 -
6340 QDomProcessingInstructionPrivate *p = new QDomProcessingInstructionPrivate(this, 0, fixedTarget, fixedData);
executed (the execution status of this line is deduced): QDomProcessingInstructionPrivate *p = new QDomProcessingInstructionPrivate(this, 0, fixedTarget, fixedData);
-
6341 p->ref.deref();
executed (the execution status of this line is deduced): p->ref.deref();
-
6342 return p;
executed: return p;
Execution Count:151
151
6343} -
6344QDomAttrPrivate* QDomDocumentPrivate::createAttribute(const QString &aname) -
6345{ -
6346 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
6347 QString fixedName = fixedXmlName(aname, &ok);
executed (the execution status of this line is deduced): QString fixedName = fixedXmlName(aname, &ok);
-
6348 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:32
9-32
6349 return 0;
executed: return 0;
Execution Count:9
9
6350 -
6351 QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, fixedName);
executed (the execution status of this line is deduced): QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, fixedName);
-
6352 a->ref.deref();
executed (the execution status of this line is deduced): a->ref.deref();
-
6353 return a;
executed: return a;
Execution Count:32
32
6354} -
6355 -
6356QDomAttrPrivate* QDomDocumentPrivate::createAttributeNS(const QString &nsURI, const QString &qName) -
6357{ -
6358 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
6359 QString fixedName = fixedXmlName(qName, &ok, true);
executed (the execution status of this line is deduced): QString fixedName = fixedXmlName(qName, &ok, true);
-
6360 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:41
23-41
6361 return 0;
executed: return 0;
Execution Count:23
23
6362 -
6363 QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, nsURI, fixedName);
executed (the execution status of this line is deduced): QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, nsURI, fixedName);
-
6364 a->ref.deref();
executed (the execution status of this line is deduced): a->ref.deref();
-
6365 return a;
executed: return a;
Execution Count:41
41
6366} -
6367 -
6368QDomEntityReferencePrivate* QDomDocumentPrivate::createEntityReference(const QString &aname) -
6369{ -
6370 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
6371 QString fixedName = fixedXmlName(aname, &ok);
executed (the execution status of this line is deduced): QString fixedName = fixedXmlName(aname, &ok);
-
6372 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:33
9-33
6373 return 0;
executed: return 0;
Execution Count:9
9
6374 -
6375 QDomEntityReferencePrivate *e = new QDomEntityReferencePrivate(this, 0, fixedName);
executed (the execution status of this line is deduced): QDomEntityReferencePrivate *e = new QDomEntityReferencePrivate(this, 0, fixedName);
-
6376 e->ref.deref();
executed (the execution status of this line is deduced): e->ref.deref();
-
6377 return e;
executed: return e;
Execution Count:33
33
6378} -
6379 -
6380QDomNodePrivate* QDomDocumentPrivate::importNode(const QDomNodePrivate *importedNode, bool deep) -
6381{ -
6382 QDomNodePrivate *node = 0;
executed (the execution status of this line is deduced): QDomNodePrivate *node = 0;
-
6383 switch (importedNode->nodeType()) { -
6384 case QDomNode::AttributeNode: -
6385 node = new QDomAttrPrivate((QDomAttrPrivate*)importedNode, true);
executed (the execution status of this line is deduced): node = new QDomAttrPrivate((QDomAttrPrivate*)importedNode, true);
-
6386 break;
executed: break;
Execution Count:12
12
6387 case QDomNode::DocumentFragmentNode: -
6388 node = new QDomDocumentFragmentPrivate((QDomDocumentFragmentPrivate*)importedNode, deep);
executed (the execution status of this line is deduced): node = new QDomDocumentFragmentPrivate((QDomDocumentFragmentPrivate*)importedNode, deep);
-
6389 break;
executed: break;
Execution Count:6
6
6390 case QDomNode::ElementNode: -
6391 node = new QDomElementPrivate((QDomElementPrivate*)importedNode, deep);
executed (the execution status of this line is deduced): node = new QDomElementPrivate((QDomElementPrivate*)importedNode, deep);
-
6392 break;
executed: break;
Execution Count:13
13
6393 case QDomNode::EntityNode: -
6394 node = new QDomEntityPrivate((QDomEntityPrivate*)importedNode, deep);
never executed (the execution status of this line is deduced): node = new QDomEntityPrivate((QDomEntityPrivate*)importedNode, deep);
-
6395 break;
never executed: break;
0
6396 case QDomNode::EntityReferenceNode: -
6397 node = new QDomEntityReferencePrivate((QDomEntityReferencePrivate*)importedNode, false);
executed (the execution status of this line is deduced): node = new QDomEntityReferencePrivate((QDomEntityReferencePrivate*)importedNode, false);
-
6398 break;
executed: break;
Execution Count:6
6
6399 case QDomNode::NotationNode: -
6400 node = new QDomNotationPrivate((QDomNotationPrivate*)importedNode, deep);
never executed (the execution status of this line is deduced): node = new QDomNotationPrivate((QDomNotationPrivate*)importedNode, deep);
-
6401 break;
never executed: break;
0
6402 case QDomNode::ProcessingInstructionNode: -
6403 node = new QDomProcessingInstructionPrivate((QDomProcessingInstructionPrivate*)importedNode, deep);
executed (the execution status of this line is deduced): node = new QDomProcessingInstructionPrivate((QDomProcessingInstructionPrivate*)importedNode, deep);
-
6404 break;
executed: break;
Execution Count:6
6
6405 case QDomNode::TextNode: -
6406 node = new QDomTextPrivate((QDomTextPrivate*)importedNode, deep);
executed (the execution status of this line is deduced): node = new QDomTextPrivate((QDomTextPrivate*)importedNode, deep);
-
6407 break;
executed: break;
Execution Count:6
6
6408 case QDomNode::CDATASectionNode: -
6409 node = new QDomCDATASectionPrivate((QDomCDATASectionPrivate*)importedNode, deep);
executed (the execution status of this line is deduced): node = new QDomCDATASectionPrivate((QDomCDATASectionPrivate*)importedNode, deep);
-
6410 break;
executed: break;
Execution Count:6
6
6411 case QDomNode::CommentNode: -
6412 node = new QDomCommentPrivate((QDomCommentPrivate*)importedNode, deep);
executed (the execution status of this line is deduced): node = new QDomCommentPrivate((QDomCommentPrivate*)importedNode, deep);
-
6413 break;
executed: break;
Execution Count:6
6
6414 default: -
6415 break;
never executed: break;
0
6416 } -
6417 if (node) {
partially evaluated: node
TRUEFALSE
yes
Evaluation Count:61
no
Evaluation Count:0
0-61
6418 node->setOwnerDocument(this);
executed (the execution status of this line is deduced): node->setOwnerDocument(this);
-
6419 // The QDomNode constructor increases the refcount, so deref first to -
6420 // keep refcount balanced. -
6421 node->ref.deref();
executed (the execution status of this line is deduced): node->ref.deref();
-
6422 }
executed: }
Execution Count:61
61
6423 return node;
executed: return node;
Execution Count:61
61
6424} -
6425 -
6426void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNode::EncodingPolicy encUsed) const -
6427{ -
6428 const QDomNodePrivate* n = first;
executed (the execution status of this line is deduced): const QDomNodePrivate* n = first;
-
6429 -
6430 if(encUsed == QDomNode::EncodingFromDocument) {
evaluated: encUsed == QDomNode::EncodingFromDocument
TRUEFALSE
yes
Evaluation Count:166
yes
Evaluation Count:60
60-166
6431#ifndef QT_NO_TEXTCODEC -
6432 const QDomNodePrivate* n = first;
executed (the execution status of this line is deduced): const QDomNodePrivate* n = first;
-
6433 -
6434 QTextCodec *codec = 0;
executed (the execution status of this line is deduced): QTextCodec *codec = 0;
-
6435 -
6436 if (n && n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) {
partially evaluated: n
TRUEFALSE
yes
Evaluation Count:166
no
Evaluation Count:0
evaluated: n->isProcessingInstruction()
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:128
partially evaluated: n->nodeName() == QLatin1String("xml")
TRUEFALSE
yes
Evaluation Count:38
no
Evaluation Count:0
0-166
6437 // we have an XML declaration -
6438 QString data = n->nodeValue();
executed (the execution status of this line is deduced): QString data = n->nodeValue();
-
6439 QRegExp encoding(QString::fromLatin1("encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))"));
executed (the execution status of this line is deduced): QRegExp encoding(QString::fromLatin1("encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))"));
-
6440 encoding.indexIn(data);
executed (the execution status of this line is deduced): encoding.indexIn(data);
-
6441 QString enc = encoding.cap(3);
executed (the execution status of this line is deduced): QString enc = encoding.cap(3);
-
6442 if (enc.isEmpty())
partially evaluated: enc.isEmpty()
TRUEFALSE
yes
Evaluation Count:38
no
Evaluation Count:0
0-38
6443 enc = encoding.cap(5);
executed: enc = encoding.cap(5);
Execution Count:38
38
6444 if (!enc.isEmpty())
evaluated: !enc.isEmpty()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:25
13-25
6445 codec = QTextCodec::codecForName(enc.toLatin1().data());
executed: codec = QTextCodec::codecForName(enc.toLatin1().data());
Execution Count:13
13
6446 }
executed: }
Execution Count:38
38
6447 if (!codec)
evaluated: !codec
TRUEFALSE
yes
Evaluation Count:154
yes
Evaluation Count:12
12-154
6448 codec = QTextCodec::codecForName("UTF-8");
executed: codec = QTextCodec::codecForName("UTF-8");
Execution Count:154
154
6449 if (codec)
partially evaluated: codec
TRUEFALSE
yes
Evaluation Count:166
no
Evaluation Count:0
0-166
6450 s.setCodec(codec);
executed: s.setCodec(codec);
Execution Count:166
166
6451#endif -
6452 bool doc = false;
executed (the execution status of this line is deduced): bool doc = false;
-
6453 -
6454 while (n) {
evaluated: n
TRUEFALSE
yes
Evaluation Count:359
yes
Evaluation Count:166
166-359
6455 if (!doc && !(n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml"))) {
evaluated: !doc
TRUEFALSE
yes
Evaluation Count:204
yes
Evaluation Count:155
evaluated: n->isProcessingInstruction()
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:166
partially evaluated: n->nodeName() == QLatin1String("xml")
TRUEFALSE
yes
Evaluation Count:38
no
Evaluation Count:0
0-204
6456 // save doctype after XML declaration -
6457 type->save(s, 0, indent);
executed (the execution status of this line is deduced): type->save(s, 0, indent);
-
6458 doc = true;
executed (the execution status of this line is deduced): doc = true;
-
6459 }
executed: }
Execution Count:166
166
6460 n->save(s, 0, indent);
executed (the execution status of this line is deduced): n->save(s, 0, indent);
-
6461 n = n->next;
executed (the execution status of this line is deduced): n = n->next;
-
6462 }
executed: }
Execution Count:359
359
6463 }
executed: }
Execution Count:166
166
6464 else { -
6465 -
6466 // Write out the XML declaration. -
6467#ifdef QT_NO_TEXTCODEC -
6468 const QLatin1String codecName("iso-8859-1"); -
6469#else -
6470 const QTextCodec *const codec = s.codec();
executed (the execution status of this line is deduced): const QTextCodec *const codec = s.codec();
-
6471 Q_ASSERT_X(codec, "QDomNode::save()", "A codec must be specified in the text stream.");
executed (the execution status of this line is deduced): qt_noop();
-
6472 const QByteArray codecName = codec->name();
executed (the execution status of this line is deduced): const QByteArray codecName = codec->name();
-
6473#endif -
6474 -
6475 s << "<?xml version=\"1.0\" encoding=\""
executed (the execution status of this line is deduced): s << "<?xml version=\"1.0\" encoding=\""
-
6476 << codecName
executed (the execution status of this line is deduced): << codecName
-
6477 << "\"?>\n";
executed (the execution status of this line is deduced): << "\"?>\n";
-
6478 -
6479 // Skip the first processing instruction by name "xml", if any such exists. -
6480 const QDomNodePrivate* startNode = n;
executed (the execution status of this line is deduced): const QDomNodePrivate* startNode = n;
-
6481 -
6482 // First, we try to find the PI and sets the startNode to the one appearing after it. -
6483 while (n) {
evaluated: n
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:18
18-60
6484 if(n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) {
evaluated: n->isProcessingInstruction()
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:18
partially evaluated: n->nodeName() == QLatin1String("xml")
TRUEFALSE
yes
Evaluation Count:42
no
Evaluation Count:0
0-42
6485 startNode = n->next;
executed (the execution status of this line is deduced): startNode = n->next;
-
6486 break;
executed: break;
Execution Count:42
42
6487 } -
6488 else -
6489 n = n->next;
executed: n = n->next;
Execution Count:18
18
6490 } -
6491 -
6492 // Now we serialize all the nodes after the faked XML declaration(the PI). -
6493 while(startNode) {
evaluated: startNode
TRUEFALSE
yes
Evaluation Count:246
yes
Evaluation Count:60
60-246
6494 startNode->save(s, 0, indent);
executed (the execution status of this line is deduced): startNode->save(s, 0, indent);
-
6495 startNode = startNode->next;
executed (the execution status of this line is deduced): startNode = startNode->next;
-
6496 }
executed: }
Execution Count:246
246
6497 }
executed: }
Execution Count:60
60
6498} -
6499 -
6500/************************************************************** -
6501 * -
6502 * QDomDocument -
6503 * -
6504 **************************************************************/ -
6505 -
6506#define IMPL ((QDomDocumentPrivate*)impl) -
6507 -
6508/*! -
6509 \class QDomDocument -
6510 \reentrant -
6511 \brief The QDomDocument class represents an XML document. -
6512 -
6513 \inmodule QtXml -
6514 -
6515 \ingroup xml-tools -
6516 -
6517 The QDomDocument class represents the entire XML document. -
6518 Conceptually, it is the root of the document tree, and provides -
6519 the primary access to the document's data. -
6520 -
6521 Since elements, text nodes, comments, processing instructions, -
6522 etc., cannot exist outside the context of a document, the document -
6523 class also contains the factory functions needed to create these -
6524 objects. The node objects created have an ownerDocument() function -
6525 which associates them with the document within whose context they -
6526 were created. The DOM classes that will be used most often are -
6527 QDomNode, QDomDocument, QDomElement and QDomText. -
6528 -
6529 The parsed XML is represented internally by a tree of objects that -
6530 can be accessed using the various QDom classes. All QDom classes -
6531 only \e reference objects in the internal tree. The internal -
6532 objects in the DOM tree will get deleted once the last QDom -
6533 object referencing them or the QDomDocument itself is deleted. -
6534 -
6535 Creation of elements, text nodes, etc. is done using the various -
6536 factory functions provided in this class. Using the default -
6537 constructors of the QDom classes will only result in empty -
6538 objects that cannot be manipulated or inserted into the Document. -
6539 -
6540 The QDomDocument class has several functions for creating document -
6541 data, for example, createElement(), createTextNode(), -
6542 createComment(), createCDATASection(), -
6543 createProcessingInstruction(), createAttribute() and -
6544 createEntityReference(). Some of these functions have versions -
6545 that support namespaces, i.e. createElementNS() and -
6546 createAttributeNS(). The createDocumentFragment() function is used -
6547 to hold parts of the document; this is useful for manipulating for -
6548 complex documents. -
6549 -
6550 The entire content of the document is set with setContent(). This -
6551 function parses the string it is passed as an XML document and -
6552 creates the DOM tree that represents the document. The root -
6553 element is available using documentElement(). The textual -
6554 representation of the document can be obtained using toString(). -
6555 -
6556 \note The DOM tree might end up reserving a lot of memory if the XML -
6557 document is big. For such documents, the QXmlStreamReader or the -
6558 QXmlQuery classes might be better solutions. -
6559 -
6560 It is possible to insert a node from another document into the -
6561 document using importNode(). -
6562 -
6563 You can obtain a list of all the elements that have a particular -
6564 tag with elementsByTagName() or with elementsByTagNameNS(). -
6565 -
6566 The QDom classes are typically used as follows: -
6567 -
6568 \snippet code/src_xml_dom_qdom.cpp 16 -
6569 -
6570 Once \c doc and \c elem go out of scope, the whole internal tree -
6571 representing the XML document is deleted. -
6572 -
6573 To create a document using DOM use code like this: -
6574 -
6575 \snippet code/src_xml_dom_qdom.cpp 17 -
6576 -
6577 For further information about the Document Object Model see -
6578 the Document Object Model (DOM) -
6579 \l{http://www.w3.org/TR/REC-DOM-Level-1/}{Level 1} and -
6580 \l{http://www.w3.org/TR/DOM-Level-2-Core/}{Level 2 Core} -
6581 Specifications. -
6582 -
6583 \sa {DOM Bookmarks Example}, {Simple DOM Model Example} -
6584*/ -
6585 -
6586 -
6587/*! -
6588 Constructs an empty document. -
6589*/ -
6590QDomDocument::QDomDocument() -
6591{ -
6592 impl = 0;
executed (the execution status of this line is deduced): impl = 0;
-
6593}
executed: }
Execution Count:436
436
6594 -
6595/*! -
6596 Creates a document and sets the name of the document type to \a -
6597 name. -
6598*/ -
6599QDomDocument::QDomDocument(const QString& name) -
6600{ -
6601 // We take over ownership -
6602 impl = new QDomDocumentPrivate(name);
executed (the execution status of this line is deduced): impl = new QDomDocumentPrivate(name);
-
6603}
executed: }
Execution Count:21
21
6604 -
6605/*! -
6606 Creates a document with the document type \a doctype. -
6607 -
6608 \sa QDomImplementation::createDocumentType() -
6609*/ -
6610QDomDocument::QDomDocument(const QDomDocumentType& doctype) -
6611{ -
6612 impl = new QDomDocumentPrivate((QDomDocumentTypePrivate*)(doctype.impl));
executed (the execution status of this line is deduced): impl = new QDomDocumentPrivate((QDomDocumentTypePrivate*)(doctype.impl));
-
6613}
executed: }
Execution Count:28
28
6614 -
6615/*! -
6616 Constructs a copy of \a x. -
6617 -
6618 The data of the copy is shared (shallow copy): modifying one node -
6619 will also change the other. If you want to make a deep copy, use -
6620 cloneNode(). -
6621*/ -
6622QDomDocument::QDomDocument(const QDomDocument& x) -
6623 : QDomNode(x) -
6624{ -
6625}
executed: }
Execution Count:14
14
6626 -
6627QDomDocument::QDomDocument(QDomDocumentPrivate* x) -
6628 : QDomNode(x) -
6629{ -
6630}
executed: }
Execution Count:479
479
6631 -
6632/*! -
6633 Assigns \a x to this DOM document. -
6634 -
6635 The data of the copy is shared (shallow copy): modifying one node -
6636 will also change the other. If you want to make a deep copy, use -
6637 cloneNode(). -
6638*/ -
6639QDomDocument& QDomDocument::operator= (const QDomDocument& x) -
6640{ -
6641 return (QDomDocument&) QDomNode::operator=(x);
never executed: return (QDomDocument&) QDomNode::operator=(x);
0
6642} -
6643 -
6644/*! -
6645 Destroys the object and frees its resources. -
6646*/ -
6647QDomDocument::~QDomDocument() -
6648{ -
6649} -
6650 -
6651/*! -
6652 \overload -
6653 -
6654 This function reads the XML document from the string \a text, returning -
6655 true if the content was successfully parsed; otherwise returns false. -
6656 Since \a text is already a Unicode string, no encoding detection -
6657 is done. -
6658*/ -
6659bool QDomDocument::setContent(const QString& text, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn) -
6660{ -
6661 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:281
yes
Evaluation Count:2
2-281
6662 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:281
281
6663 QXmlInputSource source;
executed (the execution status of this line is deduced): QXmlInputSource source;
-
6664 source.setData(text);
executed (the execution status of this line is deduced): source.setData(text);
-
6665 return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
executed: return ((QDomDocumentPrivate*)impl)->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
Execution Count:283
283
6666} -
6667 -
6668/*! -
6669 \nonreentrant -
6670 -
6671 This function parses the XML document from the byte array \a -
6672 data and sets it as the content of the document. It tries to -
6673 detect the encoding of the document as required by the XML -
6674 specification. -
6675 -
6676 If \a namespaceProcessing is true, the parser recognizes -
6677 namespaces in the XML file and sets the prefix name, local name -
6678 and namespace URI to appropriate values. If \a namespaceProcessing -
6679 is false, the parser does no namespace processing when it reads -
6680 the XML file. -
6681 -
6682 If a parse error occurs, this function returns false and the error -
6683 message is placed in \c{*}\a{errorMsg}, the line number in -
6684 \c{*}\a{errorLine} and the column number in \c{*}\a{errorColumn} -
6685 (unless the associated pointer is set to 0); otherwise this -
6686 function returns true. The various error messages are described in -
6687 the QXmlParseException class documentation. Note that, if you -
6688 want to display these error messages to your application's users, -
6689 they will be displayed in English unless they are explicitly -
6690 translated. -
6691 -
6692 If \a namespaceProcessing is true, the function QDomNode::prefix() -
6693 returns a string for all elements and attributes. It returns an -
6694 empty string if the element or attribute has no prefix. -
6695 -
6696 Text nodes consisting only of whitespace are stripped and won't -
6697 appear in the QDomDocument. If this behavior is not desired, -
6698 one can use the setContent() overload that allows a QXmlReader to be -
6699 supplied. -
6700 -
6701 If \a namespaceProcessing is false, the functions -
6702 QDomNode::prefix(), QDomNode::localName() and -
6703 QDomNode::namespaceURI() return an empty string. -
6704 -
6705 Entity references are handled as follows: -
6706 \list -
6707 \li References to internal general entities and character entities occurring in the -
6708 content are included. The result is a QDomText node with the references replaced -
6709 by their corresponding entity values. -
6710 \li References to parameter entities occurring in the internal subset are included. -
6711 The result is a QDomDocumentType node which contains entity and notation declarations -
6712 with the references replaced by their corresponding entity values. -
6713 \li Any general parsed entity reference which is not defined in the internal subset and -
6714 which occurs in the content is represented as a QDomEntityReference node. -
6715 \li Any parsed entity reference which is not defined in the internal subset and which -
6716 occurs outside of the content is replaced with an empty string. -
6717 \li Any unparsed entity reference is replaced with an empty string. -
6718 \endlist -
6719 -
6720 \sa QDomNode::namespaceURI(), QDomNode::localName(), -
6721 QDomNode::prefix(), QString::isNull(), QString::isEmpty() -
6722*/ -
6723bool QDomDocument::setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn) -
6724{ -
6725 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4
4-6
6726 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:6
6
6727 QBuffer buf;
executed (the execution status of this line is deduced): QBuffer buf;
-
6728 buf.setData(data);
executed (the execution status of this line is deduced): buf.setData(data);
-
6729 QXmlInputSource source(&buf);
executed (the execution status of this line is deduced): QXmlInputSource source(&buf);
-
6730 return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
executed: return ((QDomDocumentPrivate*)impl)->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
Execution Count:10
10
6731} -
6732 -
6733/*! -
6734 \overload -
6735 -
6736 This function reads the XML document from the IO device \a dev, returning -
6737 true if the content was successfully parsed; otherwise returns false. -
6738*/ -
6739bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn) -
6740{ -
6741 if (!impl)
partially evaluated: !impl
TRUEFALSE
yes
Evaluation Count:83
no
Evaluation Count:0
0-83
6742 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:83
83
6743 QXmlInputSource source(dev);
executed (the execution status of this line is deduced): QXmlInputSource source(dev);
-
6744 return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
executed: return ((QDomDocumentPrivate*)impl)->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
Execution Count:83
83
6745} -
6746 -
6747/*! -
6748 \overload -
6749 \since 4.5 -
6750 -
6751 This function reads the XML document from the QXmlInputSource \a source, -
6752 returning true if the content was successfully parsed; otherwise returns false. -
6753 -
6754*/ -
6755bool QDomDocument::setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn ) -
6756{ -
6757 if (!impl)
partially evaluated: !impl
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
6758 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:1
1
6759 QXmlSimpleReader reader;
executed (the execution status of this line is deduced): QXmlSimpleReader reader;
-
6760 initializeReader(reader, namespaceProcessing);
executed (the execution status of this line is deduced): initializeReader(reader, namespaceProcessing);
-
6761 return IMPL->setContent(source, &reader, errorMsg, errorLine, errorColumn);
executed: return ((QDomDocumentPrivate*)impl)->setContent(source, &reader, errorMsg, errorLine, errorColumn);
Execution Count:1
1
6762} -
6763 -
6764/*! -
6765 \overload -
6766 -
6767 This function reads the XML document from the string \a text, returning -
6768 true if the content was successfully parsed; otherwise returns false. -
6769 Since \a text is already a Unicode string, no encoding detection -
6770 is performed. -
6771 -
6772 No namespace processing is performed either. -
6773*/ -
6774bool QDomDocument::setContent(const QString& text, QString *errorMsg, int *errorLine, int *errorColumn) -
6775{ -
6776 return setContent(text, false, errorMsg, errorLine, errorColumn);
executed: return setContent(text, false, errorMsg, errorLine, errorColumn);
Execution Count:280
280
6777} -
6778 -
6779/*! -
6780 \overload -
6781 -
6782 This function reads the XML document from the byte array \a buffer, -
6783 returning true if the content was successfully parsed; otherwise returns -
6784 false. -
6785 -
6786 No namespace processing is performed. -
6787*/ -
6788bool QDomDocument::setContent(const QByteArray& buffer, QString *errorMsg, int *errorLine, int *errorColumn ) -
6789{ -
6790 return setContent(buffer, false, errorMsg, errorLine, errorColumn);
executed: return setContent(buffer, false, errorMsg, errorLine, errorColumn);
Execution Count:6
6
6791} -
6792 -
6793/*! -
6794 \overload -
6795 -
6796 This function reads the XML document from the IO device \a dev, returning -
6797 true if the content was successfully parsed; otherwise returns false. -
6798 -
6799 No namespace processing is performed. -
6800*/ -
6801bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg, int *errorLine, int *errorColumn ) -
6802{ -
6803 return setContent(dev, false, errorMsg, errorLine, errorColumn);
executed: return setContent(dev, false, errorMsg, errorLine, errorColumn);
Execution Count:81
81
6804} -
6805 -
6806/*! -
6807 \overload -
6808 -
6809 This function reads the XML document from the QXmlInputSource \a source and -
6810 parses it with the QXmlReader \a reader, returning true if the content was -
6811 successfully parsed; otherwise returns false. -
6812 -
6813 This function doesn't change the features of the \a reader. If you want to -
6814 use certain features for parsing you can use this function to set up the -
6815 reader appropriately. -
6816 -
6817 \sa QXmlSimpleReader -
6818*/ -
6819bool QDomDocument::setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn ) -
6820{ -
6821 if (!impl)
partially evaluated: !impl
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
6822 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:8
8
6823 return IMPL->setContent(source, reader, errorMsg, errorLine, errorColumn);
executed: return ((QDomDocumentPrivate*)impl)->setContent(source, reader, errorMsg, errorLine, errorColumn);
Execution Count:8
8
6824} -
6825 -
6826/*! -
6827 Converts the parsed document back to its textual representation. -
6828 -
6829 This function uses \a indent as the amount of space to indent -
6830 subelements. -
6831 -
6832 If \a indent is -1, no whitespace at all is added. -
6833*/ -
6834QString QDomDocument::toString(int indent) const -
6835{ -
6836 QString str;
executed (the execution status of this line is deduced): QString str;
-
6837 QTextStream s(&str, QIODevice::WriteOnly);
executed (the execution status of this line is deduced): QTextStream s(&str, QIODevice::WriteOnly);
-
6838 save(s, indent);
executed (the execution status of this line is deduced): save(s, indent);
-
6839 return str;
executed: return str;
Execution Count:154
154
6840} -
6841 -
6842/*! -
6843 Converts the parsed document back to its textual representation -
6844 and returns a QByteArray containing the data encoded as UTF-8. -
6845 -
6846 This function uses \a indent as the amount of space to indent -
6847 subelements. -
6848 -
6849 \sa toString() -
6850*/ -
6851QByteArray QDomDocument::toByteArray(int indent) const -
6852{ -
6853 // ### if there is an encoding specified in the xml declaration, this -
6854 // encoding declaration should be changed to utf8 -
6855 return toString(indent).toUtf8();
executed: return toString(indent).toUtf8();
Execution Count:4
4
6856} -
6857 -
6858 -
6859/*! -
6860 Returns the document type of this document. -
6861*/ -
6862QDomDocumentType QDomDocument::doctype() const -
6863{ -
6864 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
6865 return QDomDocumentType();
never executed: return QDomDocumentType();
0
6866 return QDomDocumentType(IMPL->doctype());
executed: return QDomDocumentType(((QDomDocumentPrivate*)impl)->doctype());
Execution Count:2
2
6867} -
6868 -
6869/*! -
6870 Returns a QDomImplementation object. -
6871*/ -
6872QDomImplementation QDomDocument::implementation() const -
6873{ -
6874 if (!impl)
never evaluated: !impl
0
6875 return QDomImplementation();
never executed: return QDomImplementation();
0
6876 return QDomImplementation(IMPL->implementation());
never executed: return QDomImplementation(((QDomDocumentPrivate*)impl)->implementation());
0
6877} -
6878 -
6879/*! -
6880 Returns the root element of the document. -
6881*/ -
6882QDomElement QDomDocument::documentElement() const -
6883{ -
6884 if (!impl)
partially evaluated: !impl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
0-35
6885 return QDomElement();
never executed: return QDomElement();
0
6886 return QDomElement(IMPL->documentElement());
executed: return QDomElement(((QDomDocumentPrivate*)impl)->documentElement());
Execution Count:35
35
6887} -
6888 -
6889/*! -
6890 Creates a new element called \a tagName that can be inserted into -
6891 the DOM tree, e.g. using QDomNode::appendChild(). -
6892 -
6893 If \a tagName is not a valid XML name, the behavior of this function is governed -
6894 by QDomImplementation::InvalidDataPolicy. -
6895 -
6896 \sa createElementNS(), QDomNode::appendChild(), QDomNode::insertBefore(), -
6897 QDomNode::insertAfter() -
6898*/ -
6899QDomElement QDomDocument::createElement(const QString& tagName) -
6900{ -
6901 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:87
15-87
6902 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:15
15
6903 return QDomElement(IMPL->createElement(tagName));
executed: return QDomElement(((QDomDocumentPrivate*)impl)->createElement(tagName));
Execution Count:102
102
6904} -
6905 -
6906/*! -
6907 Creates a new document fragment, that can be used to hold parts of -
6908 the document, e.g. when doing complex manipulations of the -
6909 document tree. -
6910*/ -
6911QDomDocumentFragment QDomDocument::createDocumentFragment() -
6912{ -
6913 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
1-18
6914 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:1
1
6915 return QDomDocumentFragment(IMPL->createDocumentFragment());
executed: return QDomDocumentFragment(((QDomDocumentPrivate*)impl)->createDocumentFragment());
Execution Count:19
19
6916} -
6917 -
6918/*! -
6919 Creates a text node for the string \a value that can be inserted -
6920 into the document tree, e.g. using QDomNode::appendChild(). -
6921 -
6922 If \a value contains characters which cannot be stored as character -
6923 data of an XML document (even in the form of character references), the -
6924 behavior of this function is governed by QDomImplementation::InvalidDataPolicy. -
6925 -
6926 \sa QDomNode::appendChild(), QDomNode::insertBefore(), QDomNode::insertAfter() -
6927*/ -
6928QDomText QDomDocument::createTextNode(const QString& value) -
6929{ -
6930 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:44
5-44
6931 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:5
5
6932 return QDomText(IMPL->createTextNode(value));
executed: return QDomText(((QDomDocumentPrivate*)impl)->createTextNode(value));
Execution Count:49
49
6933} -
6934 -
6935/*! -
6936 Creates a new comment for the string \a value that can be inserted -
6937 into the document, e.g. using QDomNode::appendChild(). -
6938 -
6939 If \a value contains characters which cannot be stored in an XML comment, -
6940 the behavior of this function is governed by QDomImplementation::InvalidDataPolicy. -
6941 -
6942 \sa QDomNode::appendChild(), QDomNode::insertBefore(), QDomNode::insertAfter() -
6943*/ -
6944QDomComment QDomDocument::createComment(const QString& value) -
6945{ -
6946 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
1-18
6947 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:1
1
6948 return QDomComment(IMPL->createComment(value));
executed: return QDomComment(((QDomDocumentPrivate*)impl)->createComment(value));
Execution Count:19
19
6949} -
6950 -
6951/*! -
6952 Creates a new CDATA section for the string \a value that can be -
6953 inserted into the document, e.g. using QDomNode::appendChild(). -
6954 -
6955 If \a value contains characters which cannot be stored in a CDATA section, -
6956 the behavior of this function is governed by -
6957 QDomImplementation::InvalidDataPolicy. -
6958 -
6959 \sa QDomNode::appendChild(), QDomNode::insertBefore(), QDomNode::insertAfter() -
6960*/ -
6961QDomCDATASection QDomDocument::createCDATASection(const QString& value) -
6962{ -
6963 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
1-18
6964 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:1
1
6965 return QDomCDATASection(IMPL->createCDATASection(value));
executed: return QDomCDATASection(((QDomDocumentPrivate*)impl)->createCDATASection(value));
Execution Count:19
19
6966} -
6967 -
6968/*! -
6969 Creates a new processing instruction that can be inserted into the -
6970 document, e.g. using QDomNode::appendChild(). This function sets -
6971 the target for the processing instruction to \a target and the -
6972 data to \a data. -
6973 -
6974 If \a target is not a valid XML name, or data if contains characters which cannot -
6975 appear in a processing instruction, the behavior of this function is governed by -
6976 QDomImplementation::InvalidDataPolicy. -
6977 -
6978 \sa QDomNode::appendChild(), QDomNode::insertBefore(), QDomNode::insertAfter() -
6979*/ -
6980QDomProcessingInstruction QDomDocument::createProcessingInstruction(const QString& target, -
6981 const QString& data) -
6982{ -
6983 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
1-18
6984 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:1
1
6985 return QDomProcessingInstruction(IMPL->createProcessingInstruction(target, data));
executed: return QDomProcessingInstruction(((QDomDocumentPrivate*)impl)->createProcessingInstruction(target, data));
Execution Count:19
19
6986} -
6987 -
6988 -
6989/*! -
6990 Creates a new attribute called \a name that can be inserted into -
6991 an element, e.g. using QDomElement::setAttributeNode(). -
6992 -
6993 If \a name is not a valid XML name, the behavior of this function is governed by -
6994 QDomImplementation::InvalidDataPolicy. -
6995 -
6996 \sa createAttributeNS() -
6997*/ -
6998QDomAttr QDomDocument::createAttribute(const QString& name) -
6999{ -
7000 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:34
7-34
7001 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:7
7
7002 return QDomAttr(IMPL->createAttribute(name));
executed: return QDomAttr(((QDomDocumentPrivate*)impl)->createAttribute(name));
Execution Count:41
41
7003} -
7004 -
7005/*! -
7006 Creates a new entity reference called \a name that can be inserted -
7007 into the document, e.g. using QDomNode::appendChild(). -
7008 -
7009 If \a name is not a valid XML name, the behavior of this function is governed by -
7010 QDomImplementation::InvalidDataPolicy. -
7011 -
7012 \sa QDomNode::appendChild(), QDomNode::insertBefore(), QDomNode::insertAfter() -
7013*/ -
7014QDomEntityReference QDomDocument::createEntityReference(const QString& name) -
7015{ -
7016 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:39
1-39
7017 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:1
1
7018 return QDomEntityReference(IMPL->createEntityReference(name));
executed: return QDomEntityReference(((QDomDocumentPrivate*)impl)->createEntityReference(name));
Execution Count:40
40
7019} -
7020 -
7021/*! -
7022 Returns a QDomNodeList, that contains all the elements in the -
7023 document with the name \a tagname. The order of the node list is -
7024 the order they are encountered in a preorder traversal of the -
7025 element tree. -
7026 -
7027 \sa elementsByTagNameNS(), QDomElement::elementsByTagName() -
7028*/ -
7029QDomNodeList QDomDocument::elementsByTagName(const QString& tagname) const -
7030{ -
7031 return QDomNodeList(new QDomNodeListPrivate(impl, tagname));
executed: return QDomNodeList(new QDomNodeListPrivate(impl, tagname));
Execution Count:1
1
7032} -
7033 -
7034/*! -
7035 Imports the node \a importedNode from another document to this -
7036 document. \a importedNode remains in the original document; this -
7037 function creates a copy that can be used within this document. -
7038 -
7039 This function returns the imported node that belongs to this -
7040 document. The returned node has no parent. It is not possible to -
7041 import QDomDocument and QDomDocumentType nodes. In those cases -
7042 this function returns a \l{QDomNode::isNull()}{null node}. -
7043 -
7044 If \a deep is true, this function imports not only the node \a -
7045 importedNode but its whole subtree; if it is false, only the \a -
7046 importedNode is imported. The argument \a deep has no effect on -
7047 QDomAttr and QDomEntityReference nodes, since the descendants of -
7048 QDomAttr nodes are always imported and those of -
7049 QDomEntityReference nodes are never imported. -
7050 -
7051 The behavior of this function is slightly different depending on -
7052 the node types: -
7053 \table -
7054 \header \li Node Type \li Behavior -
7055 \row \li QDomAttr -
7056 \li The owner element is set to 0 and the specified flag is -
7057 set to true in the generated attribute. The whole subtree -
7058 of \a importedNode is always imported for attribute nodes: -
7059 \a deep has no effect. -
7060 \row \li QDomDocument -
7061 \li Document nodes cannot be imported. -
7062 \row \li QDomDocumentFragment -
7063 \li If \a deep is true, this function imports the whole -
7064 document fragment; otherwise it only generates an empty -
7065 document fragment. -
7066 \row \li QDomDocumentType -
7067 \li Document type nodes cannot be imported. -
7068 \row \li QDomElement -
7069 \li Attributes for which QDomAttr::specified() is true are -
7070 also imported, other attributes are not imported. If \a -
7071 deep is true, this function also imports the subtree of \a -
7072 importedNode; otherwise it imports only the element node -
7073 (and some attributes, see above). -
7074 \row \li QDomEntity -
7075 \li Entity nodes can be imported, but at the moment there is -
7076 no way to use them since the document type is read-only in -
7077 DOM level 2. -
7078 \row \li QDomEntityReference -
7079 \li Descendants of entity reference nodes are never imported: -
7080 \a deep has no effect. -
7081 \row \li QDomNotation -
7082 \li Notation nodes can be imported, but at the moment there is -
7083 no way to use them since the document type is read-only in -
7084 DOM level 2. -
7085 \row \li QDomProcessingInstruction -
7086 \li The target and value of the processing instruction is -
7087 copied to the new node. -
7088 \row \li QDomText -
7089 \li The text is copied to the new node. -
7090 \row \li QDomCDATASection -
7091 \li The text is copied to the new node. -
7092 \row \li QDomComment -
7093 \li The text is copied to the new node. -
7094 \endtable -
7095 -
7096 \sa QDomElement::setAttribute(), QDomNode::insertBefore(), -
7097 QDomNode::insertAfter(), QDomNode::replaceChild(), QDomNode::removeChild(), -
7098 QDomNode::appendChild() -
7099*/ -
7100QDomNode QDomDocument::importNode(const QDomNode& importedNode, bool deep) -
7101{ -
7102 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:60
1-60
7103 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:1
1
7104 return QDomNode(IMPL->importNode(importedNode.impl, deep));
executed: return QDomNode(((QDomDocumentPrivate*)impl)->importNode(importedNode.impl, deep));
Execution Count:61
61
7105} -
7106 -
7107/*! -
7108 Creates a new element with namespace support that can be inserted -
7109 into the DOM tree. The name of the element is \a qName and the -
7110 namespace URI is \a nsURI. This function also sets -
7111 QDomNode::prefix() and QDomNode::localName() to appropriate values -
7112 (depending on \a qName). -
7113 -
7114 If \a qName is an empty string, returns a null element regardless of -
7115 whether the invalid data policy is set. -
7116 -
7117 \sa createElement() -
7118*/ -
7119QDomElement QDomDocument::createElementNS(const QString& nsURI, const QString& qName) -
7120{ -
7121 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:83
9-83
7122 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:9
9
7123 return QDomElement(IMPL->createElementNS(nsURI, qName));
executed: return QDomElement(((QDomDocumentPrivate*)impl)->createElementNS(nsURI, qName));
Execution Count:92
92
7124} -
7125 -
7126/*! -
7127 Creates a new attribute with namespace support that can be -
7128 inserted into an element. The name of the attribute is \a qName -
7129 and the namespace URI is \a nsURI. This function also sets -
7130 QDomNode::prefix() and QDomNode::localName() to appropriate values -
7131 (depending on \a qName). -
7132 -
7133 If \a qName is not a valid XML name, the behavior of this function is governed by -
7134 QDomImplementation::InvalidDataPolicy. -
7135 -
7136 \sa createAttribute() -
7137*/ -
7138QDomAttr QDomDocument::createAttributeNS(const QString& nsURI, const QString& qName) -
7139{ -
7140 if (!impl)
evaluated: !impl
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:63
1-63
7141 impl = new QDomDocumentPrivate();
executed: impl = new QDomDocumentPrivate();
Execution Count:1
1
7142 return QDomAttr(IMPL->createAttributeNS(nsURI, qName));
executed: return QDomAttr(((QDomDocumentPrivate*)impl)->createAttributeNS(nsURI, qName));
Execution Count:64
64
7143} -
7144 -
7145/*! -
7146 Returns a QDomNodeList that contains all the elements in the -
7147 document with the local name \a localName and a namespace URI of -
7148 \a nsURI. The order of the node list is the order they are -
7149 encountered in a preorder traversal of the element tree. -
7150 -
7151 \sa elementsByTagName(), QDomElement::elementsByTagNameNS() -
7152*/ -
7153QDomNodeList QDomDocument::elementsByTagNameNS(const QString& nsURI, const QString& localName) -
7154{ -
7155 return QDomNodeList(new QDomNodeListPrivate(impl, nsURI, localName));
never executed: return QDomNodeList(new QDomNodeListPrivate(impl, nsURI, localName));
0
7156} -
7157 -
7158/*! -
7159 Returns the element whose ID is equal to \a elementId. If no -
7160 element with the ID was found, this function returns a -
7161 \l{QDomNode::isNull()}{null element}. -
7162 -
7163 Since the QDomClasses do not know which attributes are element -
7164 IDs, this function returns always a -
7165 \l{QDomNode::isNull()}{null element}. -
7166 This may change in a future version. -
7167*/ -
7168QDomElement QDomDocument::elementById(const QString& /*elementId*/) -
7169{ -
7170 qWarning("elementById() is not implemented and will always return a null node.");
never executed (the execution status of this line is deduced): QMessageLogger("dom/qdom.cpp", 7170, __PRETTY_FUNCTION__).warning("elementById() is not implemented and will always return a null node.");
-
7171 return QDomElement();
never executed: return QDomElement();
0
7172} -
7173 -
7174/*! -
7175 \fn QDomNode::NodeType QDomDocument::nodeType() const -
7176 -
7177 Returns \c DocumentNode. -
7178*/ -
7179 -
7180#undef IMPL -
7181 -
7182/************************************************************** -
7183 * -
7184 * Node casting functions -
7185 * -
7186 **************************************************************/ -
7187 -
7188/*! -
7189 Converts a QDomNode into a QDomAttr. If the node is not an -
7190 attribute, the returned object will be \l{QDomNode::isNull()}{null}. -
7191 -
7192 \sa isAttr() -
7193*/ -
7194QDomAttr QDomNode::toAttr() const -
7195{ -
7196 if (impl && impl->isAttr())
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: impl->isAttr()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
7197 return QDomAttr(((QDomAttrPrivate*)impl));
executed: return QDomAttr(((QDomAttrPrivate*)impl));
Execution Count:1
1
7198 return QDomAttr();
never executed: return QDomAttr();
0
7199} -
7200 -
7201/*! -
7202 Converts a QDomNode into a QDomCDATASection. If the node is not a -
7203 CDATA section, the returned object will be \l{QDomNode::isNull()}{null}. -
7204 -
7205 \sa isCDATASection() -
7206*/ -
7207QDomCDATASection QDomNode::toCDATASection() const -
7208{ -
7209 if (impl && impl->isCDATASection())
never evaluated: impl
never evaluated: impl->isCDATASection()
0
7210 return QDomCDATASection(((QDomCDATASectionPrivate*)impl));
never executed: return QDomCDATASection(((QDomCDATASectionPrivate*)impl));
0
7211 return QDomCDATASection();
never executed: return QDomCDATASection();
0
7212} -
7213 -
7214/*! -
7215 Converts a QDomNode into a QDomDocumentFragment. If the node is -
7216 not a document fragment the returned object will be \l{QDomNode::isNull()}{null}. -
7217 -
7218 \sa isDocumentFragment() -
7219*/ -
7220QDomDocumentFragment QDomNode::toDocumentFragment() const -
7221{ -
7222 if (impl && impl->isDocumentFragment())
never evaluated: impl
never evaluated: impl->isDocumentFragment()
0
7223 return QDomDocumentFragment(((QDomDocumentFragmentPrivate*)impl));
never executed: return QDomDocumentFragment(((QDomDocumentFragmentPrivate*)impl));
0
7224 return QDomDocumentFragment();
never executed: return QDomDocumentFragment();
0
7225} -
7226 -
7227/*! -
7228 Converts a QDomNode into a QDomDocument. If the node is not a -
7229 document the returned object will be \l{QDomNode::isNull()}{null}. -
7230 -
7231 \sa isDocument() -
7232*/ -
7233QDomDocument QDomNode::toDocument() const -
7234{ -
7235 if (impl && impl->isDocument())
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
evaluated: impl->isDocument()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
0-2
7236 return QDomDocument(((QDomDocumentPrivate*)impl));
executed: return QDomDocument(((QDomDocumentPrivate*)impl));
Execution Count:1
1
7237 return QDomDocument();
executed: return QDomDocument();
Execution Count:1
1
7238} -
7239 -
7240/*! -
7241 Converts a QDomNode into a QDomDocumentType. If the node is not a -
7242 document type the returned object will be \l{QDomNode::isNull()}{null}. -
7243 -
7244 \sa isDocumentType() -
7245*/ -
7246QDomDocumentType QDomNode::toDocumentType() const -
7247{ -
7248 if (impl && impl->isDocumentType())
never evaluated: impl
never evaluated: impl->isDocumentType()
0
7249 return QDomDocumentType(((QDomDocumentTypePrivate*)impl));
never executed: return QDomDocumentType(((QDomDocumentTypePrivate*)impl));
0
7250 return QDomDocumentType();
never executed: return QDomDocumentType();
0
7251} -
7252 -
7253/*! -
7254 Converts a QDomNode into a QDomElement. If the node is not an -
7255 element the returned object will be \l{QDomNode::isNull()}{null}. -
7256 -
7257 \sa isElement() -
7258*/ -
7259QDomElement QDomNode::toElement() const -
7260{ -
7261 if (impl && impl->isElement())
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
evaluated: impl->isElement()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:1
0-23
7262 return QDomElement(((QDomElementPrivate*)impl));
executed: return QDomElement(((QDomElementPrivate*)impl));
Execution Count:22
22
7263 return QDomElement();
executed: return QDomElement();
Execution Count:1
1
7264} -
7265 -
7266/*! -
7267 Converts a QDomNode into a QDomEntityReference. If the node is not -
7268 an entity reference, the returned object will be \l{QDomNode::isNull()}{null}. -
7269 -
7270 \sa isEntityReference() -
7271*/ -
7272QDomEntityReference QDomNode::toEntityReference() const -
7273{ -
7274 if (impl && impl->isEntityReference())
never evaluated: impl
never evaluated: impl->isEntityReference()
0
7275 return QDomEntityReference(((QDomEntityReferencePrivate*)impl));
never executed: return QDomEntityReference(((QDomEntityReferencePrivate*)impl));
0
7276 return QDomEntityReference();
never executed: return QDomEntityReference();
0
7277} -
7278 -
7279/*! -
7280 Converts a QDomNode into a QDomText. If the node is not a text, -
7281 the returned object will be \l{QDomNode::isNull()}{null}. -
7282 -
7283 \sa isText() -
7284*/ -
7285QDomText QDomNode::toText() const -
7286{ -
7287 if (impl && impl->isText())
never evaluated: impl
never evaluated: impl->isText()
0
7288 return QDomText(((QDomTextPrivate*)impl));
never executed: return QDomText(((QDomTextPrivate*)impl));
0
7289 return QDomText();
never executed: return QDomText();
0
7290} -
7291 -
7292/*! -
7293 Converts a QDomNode into a QDomEntity. If the node is not an -
7294 entity the returned object will be \l{QDomNode::isNull()}{null}. -
7295 -
7296 \sa isEntity() -
7297*/ -
7298QDomEntity QDomNode::toEntity() const -
7299{ -
7300 if (impl && impl->isEntity())
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
partially evaluated: impl->isEntity()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
7301 return QDomEntity(((QDomEntityPrivate*)impl));
executed: return QDomEntity(((QDomEntityPrivate*)impl));
Execution Count:4
4
7302 return QDomEntity();
never executed: return QDomEntity();
0
7303} -
7304 -
7305/*! -
7306 Converts a QDomNode into a QDomNotation. If the node is not a -
7307 notation the returned object will be \l{QDomNode::isNull()}{null}. -
7308 -
7309 \sa isNotation() -
7310*/ -
7311QDomNotation QDomNode::toNotation() const -
7312{ -
7313 if (impl && impl->isNotation())
partially evaluated: impl
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: impl->isNotation()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
7314 return QDomNotation(((QDomNotationPrivate*)impl));
executed: return QDomNotation(((QDomNotationPrivate*)impl));
Execution Count:2
2
7315 return QDomNotation();
never executed: return QDomNotation();
0
7316} -
7317 -
7318/*! -
7319 Converts a QDomNode into a QDomProcessingInstruction. If the node -
7320 is not a processing instruction the returned object will be \l{QDomNode::isNull()}{null}. -
7321 -
7322 \sa isProcessingInstruction() -
7323*/ -
7324QDomProcessingInstruction QDomNode::toProcessingInstruction() const -
7325{ -
7326 if (impl && impl->isProcessingInstruction())
never evaluated: impl
never evaluated: impl->isProcessingInstruction()
0
7327 return QDomProcessingInstruction(((QDomProcessingInstructionPrivate*)impl));
never executed: return QDomProcessingInstruction(((QDomProcessingInstructionPrivate*)impl));
0
7328 return QDomProcessingInstruction();
never executed: return QDomProcessingInstruction();
0
7329} -
7330 -
7331/*! -
7332 Converts a QDomNode into a QDomCharacterData. If the node is not a -
7333 character data node the returned object will be \l{QDomNode::isNull()}{null}. -
7334 -
7335 \sa isCharacterData() -
7336*/ -
7337QDomCharacterData QDomNode::toCharacterData() const -
7338{ -
7339 if (impl && impl->isCharacterData())
never evaluated: impl
never evaluated: impl->isCharacterData()
0
7340 return QDomCharacterData(((QDomCharacterDataPrivate*)impl));
never executed: return QDomCharacterData(((QDomCharacterDataPrivate*)impl));
0
7341 return QDomCharacterData();
never executed: return QDomCharacterData();
0
7342} -
7343 -
7344/*! -
7345 Converts a QDomNode into a QDomComment. If the node is not a -
7346 comment the returned object will be \l{QDomNode::isNull()}{null}. -
7347 -
7348 \sa isComment() -
7349*/ -
7350QDomComment QDomNode::toComment() const -
7351{ -
7352 if (impl && impl->isComment())
never evaluated: impl
never evaluated: impl->isComment()
0
7353 return QDomComment(((QDomCommentPrivate*)impl));
never executed: return QDomComment(((QDomCommentPrivate*)impl));
0
7354 return QDomComment();
never executed: return QDomComment();
0
7355} -
7356 -
7357/************************************************************** -
7358 * -
7359 * QDomHandler -
7360 * -
7361 **************************************************************/ -
7362 -
7363QDomHandler::QDomHandler(QDomDocumentPrivate* adoc, bool namespaceProcessing) -
7364 : errorLine(0), errorColumn(0), doc(adoc), node(adoc), cdata(false), -
7365 nsProcessing(namespaceProcessing), locator(0) -
7366{ -
7367}
executed: }
Execution Count:385
385
7368 -
7369QDomHandler::~QDomHandler() -
7370{ -
7371} -
7372 -
7373bool QDomHandler::endDocument() -
7374{ -
7375 // ### is this really necessary? (rms) -
7376 if (node != doc)
partially evaluated: node != doc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:371
0-371
7377 return false;
never executed: return false;
0
7378 return true;
executed: return true;
Execution Count:371
371
7379} -
7380 -
7381bool QDomHandler::startDTD(const QString& name, const QString& publicId, const QString& systemId) -
7382{ -
7383 doc->doctype()->name = name;
executed (the execution status of this line is deduced): doc->doctype()->name = name;
-
7384 doc->doctype()->publicId = publicId;
executed (the execution status of this line is deduced): doc->doctype()->publicId = publicId;
-
7385 doc->doctype()->systemId = systemId;
executed (the execution status of this line is deduced): doc->doctype()->systemId = systemId;
-
7386 return true;
executed: return true;
Execution Count:124
124
7387} -
7388 -
7389bool QDomHandler::startElement(const QString& nsURI, const QString&, const QString& qName, const QXmlAttributes& atts) -
7390{ -
7391 // tag name -
7392 QDomNodePrivate* n;
executed (the execution status of this line is deduced): QDomNodePrivate* n;
-
7393 if (nsProcessing) {
evaluated: nsProcessing
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:37826
58-37826
7394 n = doc->createElementNS(nsURI, qName);
executed (the execution status of this line is deduced): n = doc->createElementNS(nsURI, qName);
-
7395 } else {
executed: }
Execution Count:58
58
7396 n = doc->createElement(qName);
executed (the execution status of this line is deduced): n = doc->createElement(qName);
-
7397 }
executed: }
Execution Count:37826
37826
7398 -
7399 if (!n)
evaluated: !n
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:37883
1-37883
7400 return false;
executed: return false;
Execution Count:1
1
7401 -
7402 n->setLocation(locator->lineNumber(), locator->columnNumber());
executed (the execution status of this line is deduced): n->setLocation(locator->lineNumber(), locator->columnNumber());
-
7403 -
7404 node->appendChild(n);
executed (the execution status of this line is deduced): node->appendChild(n);
-
7405 node = n;
executed (the execution status of this line is deduced): node = n;
-
7406 -
7407 // attributes -
7408 for (int i=0; i<atts.length(); i++)
evaluated: i<atts.length()
TRUEFALSE
yes
Evaluation Count:16752
yes
Evaluation Count:37883
16752-37883
7409 { -
7410 if (nsProcessing) {
evaluated: nsProcessing
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:16739
13-16739
7411 ((QDomElementPrivate*)node)->setAttributeNS(atts.uri(i), atts.qName(i), atts.value(i));
executed (the execution status of this line is deduced): ((QDomElementPrivate*)node)->setAttributeNS(atts.uri(i), atts.qName(i), atts.value(i));
-
7412 } else {
executed: }
Execution Count:13
13
7413 ((QDomElementPrivate*)node)->setAttribute(atts.qName(i), atts.value(i));
executed (the execution status of this line is deduced): ((QDomElementPrivate*)node)->setAttribute(atts.qName(i), atts.value(i));
-
7414 }
executed: }
Execution Count:16739
16739
7415 } -
7416 -
7417 return true;
executed: return true;
Execution Count:37883
37883
7418} -
7419 -
7420bool QDomHandler::endElement(const QString&, const QString&, const QString&) -
7421{ -
7422 if (!node || node == doc)
partially evaluated: !node
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37883
partially evaluated: node == doc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37883
0-37883
7423 return false;
never executed: return false;
0
7424 node = node->parent();
executed (the execution status of this line is deduced): node = node->parent();
-
7425 -
7426 return true;
executed: return true;
Execution Count:37883
37883
7427} -
7428 -
7429bool QDomHandler::characters(const QString& ch) -
7430{ -
7431 // No text as child of some document -
7432 if (node == doc)
partially evaluated: node == doc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:36502
0-36502
7433 return false;
never executed: return false;
0
7434 -
7435 QScopedPointer<QDomNodePrivate> n;
executed (the execution status of this line is deduced): QScopedPointer<QDomNodePrivate> n;
-
7436 if (cdata) {
evaluated: cdata
TRUEFALSE
yes
Evaluation Count:184
yes
Evaluation Count:36318
184-36318
7437 n.reset(doc->createCDATASection(ch));
executed (the execution status of this line is deduced): n.reset(doc->createCDATASection(ch));
-
7438 } else if (!entityName.isEmpty()) {
executed: }
Execution Count:184
evaluated: !entityName.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:36316
2-36316
7439 QScopedPointer<QDomEntityPrivate> e(new QDomEntityPrivate(doc, 0, entityName,
executed (the execution status of this line is deduced): QScopedPointer<QDomEntityPrivate> e(new QDomEntityPrivate(doc, 0, entityName,
-
7440 QString(), QString(), QString()));
executed (the execution status of this line is deduced): QString(), QString(), QString()));
-
7441 e->value = ch;
executed (the execution status of this line is deduced): e->value = ch;
-
7442 e->ref.deref();
executed (the execution status of this line is deduced): e->ref.deref();
-
7443 doc->doctype()->appendChild(e.data());
executed (the execution status of this line is deduced): doc->doctype()->appendChild(e.data());
-
7444 e.take();
executed (the execution status of this line is deduced): e.take();
-
7445 n.reset(doc->createEntityReference(entityName));
executed (the execution status of this line is deduced): n.reset(doc->createEntityReference(entityName));
-
7446 } else {
executed: }
Execution Count:2
2
7447 n.reset(doc->createTextNode(ch));
executed (the execution status of this line is deduced): n.reset(doc->createTextNode(ch));
-
7448 }
executed: }
Execution Count:36316
36316
7449 n->setLocation(locator->lineNumber(), locator->columnNumber());
executed (the execution status of this line is deduced): n->setLocation(locator->lineNumber(), locator->columnNumber());
-
7450 node->appendChild(n.data());
executed (the execution status of this line is deduced): node->appendChild(n.data());
-
7451 n.take();
executed (the execution status of this line is deduced): n.take();
-
7452 -
7453 return true;
executed: return true;
Execution Count:36502
36502
7454} -
7455 -
7456bool QDomHandler::processingInstruction(const QString& target, const QString& data) -
7457{ -
7458 QDomNodePrivate *n;
executed (the execution status of this line is deduced): QDomNodePrivate *n;
-
7459 n = doc->createProcessingInstruction(target, data);
executed (the execution status of this line is deduced): n = doc->createProcessingInstruction(target, data);
-
7460 if (n) {
partially evaluated: n
TRUEFALSE
yes
Evaluation Count:132
no
Evaluation Count:0
0-132
7461 n->setLocation(locator->lineNumber(), locator->columnNumber());
executed (the execution status of this line is deduced): n->setLocation(locator->lineNumber(), locator->columnNumber());
-
7462 node->appendChild(n);
executed (the execution status of this line is deduced): node->appendChild(n);
-
7463 return true;
executed: return true;
Execution Count:132
132
7464 } -
7465 else -
7466 return false;
never executed: return false;
0
7467} -
7468 -
7469extern bool qt_xml_skipped_entity_in_content; -
7470bool QDomHandler::skippedEntity(const QString& name) -
7471{ -
7472 // we can only handle inserting entity references into content -
7473 if (!qt_xml_skipped_entity_in_content)
never evaluated: !qt_xml_skipped_entity_in_content
0
7474 return true;
never executed: return true;
0
7475 -
7476 QDomNodePrivate *n = doc->createEntityReference(name);
never executed (the execution status of this line is deduced): QDomNodePrivate *n = doc->createEntityReference(name);
-
7477 n->setLocation(locator->lineNumber(), locator->columnNumber());
never executed (the execution status of this line is deduced): n->setLocation(locator->lineNumber(), locator->columnNumber());
-
7478 node->appendChild(n);
never executed (the execution status of this line is deduced): node->appendChild(n);
-
7479 return true;
never executed: return true;
0
7480} -
7481 -
7482bool QDomHandler::fatalError(const QXmlParseException& exception) -
7483{ -
7484 errorMsg = exception.message();
executed (the execution status of this line is deduced): errorMsg = exception.message();
-
7485 errorLine = exception.lineNumber();
executed (the execution status of this line is deduced): errorLine = exception.lineNumber();
-
7486 errorColumn = exception.columnNumber();
executed (the execution status of this line is deduced): errorColumn = exception.columnNumber();
-
7487 return QXmlDefaultHandler::fatalError(exception);
executed: return QXmlDefaultHandler::fatalError(exception);
Execution Count:14
14
7488} -
7489 -
7490bool QDomHandler::startCDATA() -
7491{ -
7492 cdata = true;
executed (the execution status of this line is deduced): cdata = true;
-
7493 return true;
executed: return true;
Execution Count:184
184
7494} -
7495 -
7496bool QDomHandler::endCDATA() -
7497{ -
7498 cdata = false;
executed (the execution status of this line is deduced): cdata = false;
-
7499 return true;
executed: return true;
Execution Count:184
184
7500} -
7501 -
7502bool QDomHandler::startEntity(const QString &name) -
7503{ -
7504 entityName = name;
executed (the execution status of this line is deduced): entityName = name;
-
7505 return true;
executed: return true;
Execution Count:2
2
7506} -
7507 -
7508bool QDomHandler::endEntity(const QString &) -
7509{ -
7510 entityName.clear();
executed (the execution status of this line is deduced): entityName.clear();
-
7511 return true;
executed: return true;
Execution Count:2
2
7512} -
7513 -
7514bool QDomHandler::comment(const QString& ch) -
7515{ -
7516 QDomNodePrivate *n;
executed (the execution status of this line is deduced): QDomNodePrivate *n;
-
7517 n = doc->createComment(ch);
executed (the execution status of this line is deduced): n = doc->createComment(ch);
-
7518 n->setLocation(locator->lineNumber(), locator->columnNumber());
executed (the execution status of this line is deduced): n->setLocation(locator->lineNumber(), locator->columnNumber());
-
7519 node->appendChild(n);
executed (the execution status of this line is deduced): node->appendChild(n);
-
7520 return true;
executed: return true;
Execution Count:1943
1943
7521} -
7522 -
7523bool QDomHandler::unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString &notationName) -
7524{ -
7525 QDomEntityPrivate* e = new QDomEntityPrivate(doc, 0, name,
executed (the execution status of this line is deduced): QDomEntityPrivate* e = new QDomEntityPrivate(doc, 0, name,
-
7526 publicId, systemId, notationName);
executed (the execution status of this line is deduced): publicId, systemId, notationName);
-
7527 // keep the refcount balanced: appendChild() does a ref anyway. -
7528 e->ref.deref();
executed (the execution status of this line is deduced): e->ref.deref();
-
7529 doc->doctype()->appendChild(e);
executed (the execution status of this line is deduced): doc->doctype()->appendChild(e);
-
7530 return true;
executed: return true;
Execution Count:4
4
7531} -
7532 -
7533bool QDomHandler::externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId) -
7534{ -
7535 return unparsedEntityDecl(name, publicId, systemId, QString());
executed: return unparsedEntityDecl(name, publicId, systemId, QString());
Execution Count:3
3
7536} -
7537 -
7538bool QDomHandler::notationDecl(const QString & name, const QString & publicId, const QString & systemId) -
7539{ -
7540 QDomNotationPrivate* n = new QDomNotationPrivate(doc, 0, name, publicId, systemId);
executed (the execution status of this line is deduced): QDomNotationPrivate* n = new QDomNotationPrivate(doc, 0, name, publicId, systemId);
-
7541 // keep the refcount balanced: appendChild() does a ref anyway. -
7542 n->ref.deref();
executed (the execution status of this line is deduced): n->ref.deref();
-
7543 doc->doctype()->appendChild(n);
executed (the execution status of this line is deduced): doc->doctype()->appendChild(n);
-
7544 return true;
executed: return true;
Execution Count:2
2
7545} -
7546 -
7547void QDomHandler::setDocumentLocator(QXmlLocator *locator) -
7548{ -
7549 this->locator = locator;
executed (the execution status of this line is deduced): this->locator = locator;
-
7550}
executed: }
Execution Count:385
385
7551 -
7552QT_END_NAMESPACE -
7553 -
7554#endif // QT_NO_DOM -
7555 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial