xml/qxmlstream.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 QtCore 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 "QtCore/qxmlstream.h" -
43 -
44#if defined(QT_BUILD_XML_LIB) && defined(Q_OS_MAC64) -
45// No need to define this in the 64-bit Mac libraries. -
46// Since Qt 4.4 and previous weren't supported in 64-bit, there are -
47// no QXmlStream* symbols to keep compatibility with -
48# define QT_NO_XMLSTREAM -
49#endif -
50 -
51#ifndef QT_NO_XMLSTREAM -
52 -
53#include "qxmlutils_p.h" -
54#include <qdebug.h> -
55#include <qfile.h> -
56#include <stdio.h> -
57#include <qtextcodec.h> -
58#include <qstack.h> -
59#include <qbuffer.h> -
60#ifndef QT_BOOTSTRAPPED -
61#include <qcoreapplication.h> -
62#else -
63// This specialization of Q_DECLARE_TR_FUNCTIONS is not in qcoreapplication.h, -
64// because that header depends on QObject being available, which is not the -
65// case for most bootstrapped applications. -
66#define Q_DECLARE_TR_FUNCTIONS(context) \ -
67public: \ -
68 static inline QString tr(const char *sourceText, const char *comment = 0) \ -
69 { Q_UNUSED(comment); return QString::fromLatin1(sourceText); } \ -
70 static inline QString trUtf8(const char *sourceText, const char *comment = 0) \ -
71 { Q_UNUSED(comment); return QString::fromLatin1(sourceText); } \ -
72 static inline QString tr(const char *sourceText, const char*, int) \ -
73 { return QString::fromLatin1(sourceText); } \ -
74 static inline QString trUtf8(const char *sourceText, const char*, int) \ -
75 { return QString::fromLatin1(sourceText); } \ -
76private: -
77#endif -
78QT_BEGIN_NAMESPACE -
79 -
80#include "qxmlstream_p.h" -
81 -
82/*! -
83 \enum QXmlStreamReader::TokenType -
84 -
85 This enum specifies the type of token the reader just read. -
86 -
87 \value NoToken The reader has not yet read anything. -
88 -
89 \value Invalid An error has occurred, reported in error() and -
90 errorString(). -
91 -
92 \value StartDocument The reader reports the XML version number in -
93 documentVersion(), and the encoding as specified in the XML -
94 document in documentEncoding(). If the document is declared -
95 standalone, isStandaloneDocument() returns true; otherwise it -
96 returns false. -
97 -
98 \value EndDocument The reader reports the end of the document. -
99 -
100 \value StartElement The reader reports the start of an element -
101 with namespaceUri() and name(). Empty elements are also reported -
102 as StartElement, followed directly by EndElement. The convenience -
103 function readElementText() can be called to concatenate all -
104 content until the corresponding EndElement. Attributes are -
105 reported in attributes(), namespace declarations in -
106 namespaceDeclarations(). -
107 -
108 \value EndElement The reader reports the end of an element with -
109 namespaceUri() and name(). -
110 -
111 \value Characters The reader reports characters in text(). If the -
112 characters are all white-space, isWhitespace() returns true. If -
113 the characters stem from a CDATA section, isCDATA() returns true. -
114 -
115 \value Comment The reader reports a comment in text(). -
116 -
117 \value DTD The reader reports a DTD in text(), notation -
118 declarations in notationDeclarations(), and entity declarations in -
119 entityDeclarations(). Details of the DTD declaration are reported -
120 in in dtdName(), dtdPublicId(), and dtdSystemId(). -
121 -
122 \value EntityReference The reader reports an entity reference that -
123 could not be resolved. The name of the reference is reported in -
124 name(), the replacement text in text(). -
125 -
126 \value ProcessingInstruction The reader reports a processing -
127 instruction in processingInstructionTarget() and -
128 processingInstructionData(). -
129*/ -
130 -
131/*! -
132 \enum QXmlStreamReader::ReadElementTextBehaviour -
133 -
134 This enum specifies the different behaviours of readElementText(). -
135 -
136 \value ErrorOnUnexpectedElement Raise an UnexpectedElementError and return -
137 what was read so far when a child element is encountered. -
138 -
139 \value IncludeChildElements Recursively include the text from child elements. -
140 -
141 \value SkipChildElements Skip child elements. -
142 -
143 \since 4.6 -
144*/ -
145 -
146/*! -
147 \enum QXmlStreamReader::Error -
148 -
149 This enum specifies different error cases -
150 -
151 \value NoError No error has occurred. -
152 -
153 \value CustomError A custom error has been raised with -
154 raiseError() -
155 -
156 \value NotWellFormedError The parser internally raised an error -
157 due to the read XML not being well-formed. -
158 -
159 \value PrematureEndOfDocumentError The input stream ended before a -
160 well-formed XML document was parsed. Recovery from this error is -
161 possible if more XML arrives in the stream, either by calling -
162 addData() or by waiting for it to arrive on the device(). -
163 -
164 \value UnexpectedElementError The parser encountered an element -
165 that was different to those it expected. -
166 -
167*/ -
168 -
169/*! -
170 \class QXmlStreamEntityResolver -
171 \inmodule QtCore -
172 \reentrant -
173 \since 4.4 -
174 -
175 \brief The QXmlStreamEntityResolver class provides an entity -
176 resolver for a QXmlStreamReader. -
177 -
178 \ingroup xml-tools -
179 */ -
180 -
181/*! -
182 Destroys the entity resolver. -
183 */ -
184QXmlStreamEntityResolver::~QXmlStreamEntityResolver() -
185{ -
186} -
187 -
188/*! -
189 \internal -
190 -
191This function is a stub for later functionality. -
192*/ -
193QString QXmlStreamEntityResolver::resolveEntity(const QString& /*publicId*/, const QString& /*systemId*/) -
194{ -
195 return QString();
never executed: return QString();
0
196} -
197 -
198 -
199/*! -
200 Resolves the undeclared entity \a name and returns its replacement -
201 text. If the entity is also unknown to the entity resolver, it -
202 returns an empty string. -
203 -
204 The default implementation always returns an empty string. -
205*/ -
206 -
207QString QXmlStreamEntityResolver::resolveUndeclaredEntity(const QString &/*name*/) -
208{ -
209 return QString();
never executed: return QString();
0
210} -
211 -
212#ifndef QT_NO_XMLSTREAMREADER -
213 -
214QString QXmlStreamReaderPrivate::resolveUndeclaredEntity(const QString &name) -
215{ -
216 if (entityResolver)
partially evaluated: entityResolver
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
217 return entityResolver->resolveUndeclaredEntity(name);
executed: return entityResolver->resolveUndeclaredEntity(name);
Execution Count:2
2
218 return QString();
never executed: return QString();
0
219} -
220 -
221 -
222 -
223/*! -
224 \since 4.4 -
225 -
226 Makes \a resolver the new entityResolver(). -
227 -
228 The stream reader does \e not take ownership of the resolver. It's -
229 the callers responsibility to ensure that the resolver is valid -
230 during the entire life-time of the stream reader object, or until -
231 another resolver or 0 is set. -
232 -
233 \sa entityResolver() -
234 */ -
235void QXmlStreamReader::setEntityResolver(QXmlStreamEntityResolver *resolver) -
236{ -
237 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
238 d->entityResolver = resolver;
executed (the execution status of this line is deduced): d->entityResolver = resolver;
-
239}
executed: }
Execution Count:1
1
240 -
241/*! -
242 \since 4.4 -
243 -
244 Returns the entity resolver, or 0 if there is no entity resolver. -
245 -
246 \sa setEntityResolver() -
247 */ -
248QXmlStreamEntityResolver *QXmlStreamReader::entityResolver() const -
249{ -
250 Q_D(const QXmlStreamReader);
never executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
251 return d->entityResolver;
never executed: return d->entityResolver;
0
252} -
253 -
254 -
255 -
256/*! -
257 \class QXmlStreamReader -
258 \inmodule QtCore -
259 \reentrant -
260 \since 4.3 -
261 -
262 \brief The QXmlStreamReader class provides a fast parser for reading -
263 well-formed XML via a simple streaming API. -
264 -
265 -
266 \ingroup xml-tools -
267 -
268 QXmlStreamReader is a faster and more convenient replacement for -
269 Qt's own SAX parser (see QXmlSimpleReader). In some cases it might -
270 also be a faster and more convenient alternative for use in -
271 applications that would otherwise use a DOM tree (see QDomDocument). -
272 QXmlStreamReader reads data either from a QIODevice (see -
273 setDevice()), or from a raw QByteArray (see addData()). -
274 -
275 Qt provides QXmlStreamWriter for writing XML. -
276 -
277 The basic concept of a stream reader is to report an XML document as -
278 a stream of tokens, similar to SAX. The main difference between -
279 QXmlStreamReader and SAX is \e how these XML tokens are reported. -
280 With SAX, the application must provide handlers (callback functions) -
281 that receive so-called XML \e events from the parser at the parser's -
282 convenience. With QXmlStreamReader, the application code itself -
283 drives the loop and pulls \e tokens from the reader, one after -
284 another, as it needs them. This is done by calling readNext(), where -
285 the reader reads from the input stream until it completes the next -
286 token, at which point it returns the tokenType(). A set of -
287 convenient functions including isStartElement() and text() can then -
288 be used to examine the token to obtain information about what has -
289 been read. The big advantage of this \e pulling approach is the -
290 possibility to build recursive descent parsers with it, meaning you -
291 can split your XML parsing code easily into different methods or -
292 classes. This makes it easy to keep track of the application's own -
293 state when parsing XML. -
294 -
295 A typical loop with QXmlStreamReader looks like this: -
296 -
297 \snippet code/src_corelib_xml_qxmlstream.cpp 0 -
298 -
299 -
300 QXmlStreamReader is a well-formed XML 1.0 parser that does \e not -
301 include external parsed entities. As long as no error occurs, the -
302 application code can thus be assured that the data provided by the -
303 stream reader satisfies the W3C's criteria for well-formed XML. For -
304 example, you can be certain that all tags are indeed nested and -
305 closed properly, that references to internal entities have been -
306 replaced with the correct replacement text, and that attributes have -
307 been normalized or added according to the internal subset of the -
308 DTD. -
309 -
310 If an error occurs while parsing, atEnd() and hasError() return -
311 true, and error() returns the error that occurred. The functions -
312 errorString(), lineNumber(), columnNumber(), and characterOffset() -
313 are for constructing an appropriate error or warning message. To -
314 simplify application code, QXmlStreamReader contains a raiseError() -
315 mechanism that lets you raise custom errors that trigger the same -
316 error handling described. -
317 -
318 The \l{QXmlStream Bookmarks Example} illustrates how to use the -
319 recursive descent technique to read an XML bookmark file (XBEL) with -
320 a stream reader. -
321 -
322 \section1 Namespaces -
323 -
324 QXmlStream understands and resolves XML namespaces. E.g. in case of -
325 a StartElement, namespaceUri() returns the namespace the element is -
326 in, and name() returns the element's \e local name. The combination -
327 of namespaceUri and name uniquely identifies an element. If a -
328 namespace prefix was not declared in the XML entities parsed by the -
329 reader, the namespaceUri is empty. -
330 -
331 If you parse XML data that does not utilize namespaces according to -
332 the XML specification or doesn't use namespaces at all, you can use -
333 the element's qualifiedName() instead. A qualified name is the -
334 element's prefix() followed by colon followed by the element's local -
335 name() - exactly like the element appears in the raw XML data. Since -
336 the mapping namespaceUri to prefix is neither unique nor universal, -
337 qualifiedName() should be avoided for namespace-compliant XML data. -
338 -
339 In order to parse standalone documents that do use undeclared -
340 namespace prefixes, you can turn off namespace processing completely -
341 with the \l namespaceProcessing property. -
342 -
343 \section1 Incremental parsing -
344 -
345 QXmlStreamReader is an incremental parser. It can handle the case -
346 where the document can't be parsed all at once because it arrives in -
347 chunks (e.g. from multiple files, or over a network connection). -
348 When the reader runs out of data before the complete document has -
349 been parsed, it reports a PrematureEndOfDocumentError. When more -
350 data arrives, either because of a call to addData() or because more -
351 data is available through the network device(), the reader recovers -
352 from the PrematureEndOfDocumentError error and continues parsing the -
353 new data with the next call to readNext(). -
354 -
355 For example, if your application reads data from the network using a -
356 \l{QNetworkAccessManager} {network access manager}, you would issue -
357 a \l{QNetworkRequest} {network request} to the manager and receive a -
358 \l{QNetworkReply} {network reply} in return. Since a QNetworkReply -
359 is a QIODevice, you connect its \l{QNetworkReply::readyRead()} -
360 {readyRead()} signal to a custom slot, e.g. \c{slotReadyRead()} in -
361 the code snippet shown in the discussion for QNetworkAccessManager. -
362 In this slot, you read all available data with -
363 \l{QNetworkReply::readAll()} {readAll()} and pass it to the XML -
364 stream reader using addData(). Then you call your custom parsing -
365 function that reads the XML events from the reader. -
366 -
367 \section1 Performance and memory consumption -
368 -
369 QXmlStreamReader is memory-conservative by design, since it doesn't -
370 store the entire XML document tree in memory, but only the current -
371 token at the time it is reported. In addition, QXmlStreamReader -
372 avoids the many small string allocations that it normally takes to -
373 map an XML document to a convenient and Qt-ish API. It does this by -
374 reporting all string data as QStringRef rather than real QString -
375 objects. QStringRef is a thin wrapper around QString substrings that -
376 provides a subset of the QString API without the memory allocation -
377 and reference-counting overhead. Calling -
378 \l{QStringRef::toString()}{toString()} on any of those objects -
379 returns an equivalent real QString object. -
380 -
381*/ -
382 -
383 -
384/*! -
385 Constructs a stream reader. -
386 -
387 \sa setDevice(), addData() -
388 */ -
389QXmlStreamReader::QXmlStreamReader() -
390 : d_ptr(new QXmlStreamReaderPrivate(this)) -
391{ -
392}
executed: }
Execution Count:3165
3165
393 -
394/*! Creates a new stream reader that reads from \a device. -
395 -
396\sa setDevice(), clear() -
397 */ -
398QXmlStreamReader::QXmlStreamReader(QIODevice *device) -
399 : d_ptr(new QXmlStreamReaderPrivate(this)) -
400{ -
401 setDevice(device);
executed (the execution status of this line is deduced): setDevice(device);
-
402}
executed: }
Execution Count:472
472
403 -
404/*! -
405 Creates a new stream reader that reads from \a data. -
406 -
407 \sa addData(), clear(), setDevice() -
408 */ -
409QXmlStreamReader::QXmlStreamReader(const QByteArray &data) -
410 : d_ptr(new QXmlStreamReaderPrivate(this)) -
411{ -
412 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
413 d->dataBuffer = data;
executed (the execution status of this line is deduced): d->dataBuffer = data;
-
414}
executed: }
Execution Count:812
812
415 -
416/*! -
417 Creates a new stream reader that reads from \a data. -
418 -
419 \sa addData(), clear(), setDevice() -
420 */ -
421QXmlStreamReader::QXmlStreamReader(const QString &data) -
422 : d_ptr(new QXmlStreamReaderPrivate(this)) -
423{ -
424 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
425#ifdef QT_NO_TEXTCODEC -
426 d->dataBuffer = data.toLatin1(); -
427#else -
428 d->dataBuffer = d->codec->fromUnicode(data);
executed (the execution status of this line is deduced): d->dataBuffer = d->codec->fromUnicode(data);
-
429 d->decoder = d->codec->makeDecoder();
executed (the execution status of this line is deduced): d->decoder = d->codec->makeDecoder();
-
430#endif -
431 d->lockEncoding = true;
executed (the execution status of this line is deduced): d->lockEncoding = true;
-
432 -
433}
executed: }
Execution Count:255
255
434 -
435/*! -
436 Creates a new stream reader that reads from \a data. -
437 -
438 \sa addData(), clear(), setDevice() -
439 */ -
440QXmlStreamReader::QXmlStreamReader(const char *data) -
441 : d_ptr(new QXmlStreamReaderPrivate(this)) -
442{ -
443 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
444 d->dataBuffer = QByteArray(data);
executed (the execution status of this line is deduced): d->dataBuffer = QByteArray(data);
-
445}
executed: }
Execution Count:6
6
446 -
447/*! -
448 Destructs the reader. -
449 */ -
450QXmlStreamReader::~QXmlStreamReader() -
451{ -
452 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
453 if (d->deleteDevice)
partially evaluated: d->deleteDevice
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4710
0-4710
454 delete d->device;
never executed: delete d->device;
0
455}
executed: }
Execution Count:4710
4710
456 -
457/*! \fn bool QXmlStreamReader::hasError() const -
458 Returns \c true if an error has occurred, otherwise \c false. -
459 -
460 \sa errorString(), error() -
461 */ -
462 -
463/*! -
464 Sets the current device to \a device. Setting the device resets -
465 the stream to its initial state. -
466 -
467 \sa device(), clear() -
468*/ -
469void QXmlStreamReader::setDevice(QIODevice *device) -
470{ -
471 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
472 if (d->deleteDevice) {
partially evaluated: d->deleteDevice
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2184
0-2184
473 delete d->device;
never executed (the execution status of this line is deduced): delete d->device;
-
474 d->deleteDevice = false;
never executed (the execution status of this line is deduced): d->deleteDevice = false;
-
475 }
never executed: }
0
476 d->device = device;
executed (the execution status of this line is deduced): d->device = device;
-
477 d->init();
executed (the execution status of this line is deduced): d->init();
-
478 -
479}
executed: }
Execution Count:2184
2184
480 -
481/*! -
482 Returns the current device associated with the QXmlStreamReader, -
483 or 0 if no device has been assigned. -
484 -
485 \sa setDevice() -
486*/ -
487QIODevice *QXmlStreamReader::device() const -
488{ -
489 Q_D(const QXmlStreamReader);
never executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
490 return d->device;
never executed: return d->device;
0
491} -
492 -
493 -
494/*! -
495 Adds more \a data for the reader to read. This function does -
496 nothing if the reader has a device(). -
497 -
498 \sa readNext(), clear() -
499 */ -
500void QXmlStreamReader::addData(const QByteArray &data) -
501{ -
502 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
503 if (d->device) {
partially evaluated: d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:57484
0-57484
504 qWarning("QXmlStreamReader: addData() with device()");
never executed (the execution status of this line is deduced): QMessageLogger("xml/qxmlstream.cpp", 504, __PRETTY_FUNCTION__).warning("QXmlStreamReader: addData() with device()");
-
505 return;
never executed: return;
0
506 } -
507 d->dataBuffer += data;
executed (the execution status of this line is deduced): d->dataBuffer += data;
-
508}
executed: }
Execution Count:57484
57484
509 -
510/*! -
511 Adds more \a data for the reader to read. This function does -
512 nothing if the reader has a device(). -
513 -
514 \sa readNext(), clear() -
515 */ -
516void QXmlStreamReader::addData(const QString &data) -
517{ -
518 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
519 d->lockEncoding = true;
executed (the execution status of this line is deduced): d->lockEncoding = true;
-
520#ifdef QT_NO_TEXTCODEC -
521 addData(data.toLatin1()); -
522#else -
523 addData(d->codec->fromUnicode(data));
executed (the execution status of this line is deduced): addData(d->codec->fromUnicode(data));
-
524#endif -
525}
executed: }
Execution Count:4
4
526 -
527/*! -
528 Adds more \a data for the reader to read. This function does -
529 nothing if the reader has a device(). -
530 -
531 \sa readNext(), clear() -
532 */ -
533void QXmlStreamReader::addData(const char *data) -
534{ -
535 addData(QByteArray(data));
executed (the execution status of this line is deduced): addData(QByteArray(data));
-
536}
executed: }
Execution Count:2
2
537 -
538/*! -
539 Removes any device() or data from the reader and resets its -
540 internal state to the initial state. -
541 -
542 \sa addData() -
543 */ -
544void QXmlStreamReader::clear() -
545{ -
546 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
547 d->init();
executed (the execution status of this line is deduced): d->init();
-
548 if (d->device) {
partially evaluated: d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
549 if (d->deleteDevice)
never evaluated: d->deleteDevice
0
550 delete d->device;
never executed: delete d->device;
0
551 d->device = 0;
never executed (the execution status of this line is deduced): d->device = 0;
-
552 }
never executed: }
0
553}
executed: }
Execution Count:3
3
554 -
555/*! -
556 Returns true if the reader has read until the end of the XML -
557 document, or if an error() has occurred and reading has been -
558 aborted. Otherwise, it returns false. -
559 -
560 When atEnd() and hasError() return true and error() returns -
561 PrematureEndOfDocumentError, it means the XML has been well-formed -
562 so far, but a complete XML document has not been parsed. The next -
563 chunk of XML can be added with addData(), if the XML is being read -
564 from a QByteArray, or by waiting for more data to arrive if the -
565 XML is being read from a QIODevice. Either way, atEnd() will -
566 return false once more data is available. -
567 -
568 \sa hasError(), error(), device(), QIODevice::atEnd() -
569 */ -
570bool QXmlStreamReader::atEnd() const -
571{ -
572 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
573 if (d->atEnd
evaluated: d->atEnd
TRUEFALSE
yes
Evaluation Count:118390
yes
Evaluation Count:338231
118390-338231
574 && ((d->type == QXmlStreamReader::Invalid && d->error == PrematureEndOfDocumentError)
evaluated: d->type == QXmlStreamReader::Invalid
TRUEFALSE
yes
Evaluation Count:115545
yes
Evaluation Count:2845
partially evaluated: d->error == PrematureEndOfDocumentError
TRUEFALSE
yes
Evaluation Count:115545
no
Evaluation Count:0
0-115545
575 || (d->type == QXmlStreamReader::EndDocument))) {
partially evaluated: (d->type == QXmlStreamReader::EndDocument)
TRUEFALSE
yes
Evaluation Count:2845
no
Evaluation Count:0
0-2845
576 if (d->device)
evaluated: d->device
TRUEFALSE
yes
Evaluation Count:527
yes
Evaluation Count:117863
527-117863
577 return d->device->atEnd();
executed: return d->device->atEnd();
Execution Count:527
527
578 else -
579 return !d->dataBuffer.size();
executed: return !d->dataBuffer.size();
Execution Count:117863
117863
580 } -
581 return (d->atEnd || d->type == QXmlStreamReader::Invalid);
executed: return (d->atEnd || d->type == QXmlStreamReader::Invalid);
Execution Count:338231
338231
582} -
583 -
584 -
585/*! -
586 Reads the next token and returns its type. -
587 -
588 With one exception, once an error() is reported by readNext(), -
589 further reading of the XML stream is not possible. Then atEnd() -
590 returns true, hasError() returns true, and this function returns -
591 QXmlStreamReader::Invalid. -
592 -
593 The exception is when error() returns PrematureEndOfDocumentError. -
594 This error is reported when the end of an otherwise well-formed -
595 chunk of XML is reached, but the chunk doesn't represent a complete -
596 XML document. In that case, parsing \e can be resumed by calling -
597 addData() to add the next chunk of XML, when the stream is being -
598 read from a QByteArray, or by waiting for more data to arrive when -
599 the stream is being read from a device(). -
600 -
601 \sa tokenType(), tokenString() -
602 */ -
603QXmlStreamReader::TokenType QXmlStreamReader::readNext() -
604{ -
605 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
606 if (d->type != Invalid) {
evaluated: d->type != Invalid
TRUEFALSE
yes
Evaluation Count:411630
yes
Evaluation Count:57494
57494-411630
607 if (!d->hasCheckedStartDocument)
evaluated: !d->hasCheckedStartDocument
TRUEFALSE
yes
Evaluation Count:5742
yes
Evaluation Count:405888
5742-405888
608 if (!d->checkStartDocument())
evaluated: !d->checkStartDocument()
TRUEFALSE
yes
Evaluation Count:4651
yes
Evaluation Count:1091
1091-4651
609 return d->type; // synthetic StartDocument or error
executed: return d->type;
Execution Count:4651
4651
610 d->parse();
executed (the execution status of this line is deduced): d->parse();
-
611 if (d->atEnd && d->type != EndDocument && d->type != Invalid)
evaluated: d->atEnd
TRUEFALSE
yes
Evaluation Count:58231
yes
Evaluation Count:348748
evaluated: d->type != EndDocument
TRUEFALSE
yes
Evaluation Count:56038
yes
Evaluation Count:2193
evaluated: d->type != Invalid
TRUEFALSE
yes
Evaluation Count:45171
yes
Evaluation Count:10867
2193-348748
612 d->raiseError(PrematureEndOfDocumentError);
executed: d->raiseError(PrematureEndOfDocumentError);
Execution Count:45171
45171
613 else if (!d->atEnd && d->type == EndDocument)
evaluated: !d->atEnd
TRUEFALSE
yes
Evaluation Count:348748
yes
Evaluation Count:13060
evaluated: d->type == EndDocument
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:348743
5-348748
614 d->raiseWellFormedError(QXmlStream::tr("Extra content at end of document."));
executed: d->raiseWellFormedError(QXmlStream::tr("Extra content at end of document."));
Execution Count:5
5
615 } else if (d->error == PrematureEndOfDocumentError) {
evaluated: d->error == PrematureEndOfDocumentError
TRUEFALSE
yes
Evaluation Count:57482
yes
Evaluation Count:12
12-57482
616 // resume error -
617 d->type = NoToken;
executed (the execution status of this line is deduced): d->type = NoToken;
-
618 d->atEnd = false;
executed (the execution status of this line is deduced): d->atEnd = false;
-
619 d->token = -1;
executed (the execution status of this line is deduced): d->token = -1;
-
620 return readNext();
executed: return readNext();
Execution Count:57482
57482
621 } -
622 return d->type;
executed: return d->type;
Execution Count:406991
406991
623} -
624 -
625 -
626/*! -
627 Returns the type of the current token. -
628 -
629 The current token can also be queried with the convenience functions -
630 isStartDocument(), isEndDocument(), isStartElement(), -
631 isEndElement(), isCharacters(), isComment(), isDTD(), -
632 isEntityReference(), and isProcessingInstruction(). -
633 -
634 \sa tokenString() -
635 */ -
636QXmlStreamReader::TokenType QXmlStreamReader::tokenType() const -
637{ -
638 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
639 return d->type;
executed: return d->type;
Execution Count:461403
461403
640} -
641 -
642/*! -
643 Reads until the next start element within the current element. Returns true -
644 when a start element was reached. When the end element was reached, or when -
645 an error occurred, false is returned. -
646 -
647 The current element is the element matching the most recently parsed start -
648 element of which a matching end element has not yet been reached. When the -
649 parser has reached the end element, the current element becomes the parent -
650 element. -
651 -
652 This is a convenience function for when you're only concerned with parsing -
653 XML elements. The \l{QXmlStream Bookmarks Example} makes extensive use of -
654 this function. -
655 -
656 \since 4.6 -
657 \sa readNext() -
658 */ -
659bool QXmlStreamReader::readNextStartElement() -
660{ -
661 while (readNext() != Invalid) {
evaluated: readNext() != Invalid
TRUEFALSE
yes
Evaluation Count:13186
yes
Evaluation Count:12
12-13186
662 if (isEndElement())
evaluated: isEndElement()
TRUEFALSE
yes
Evaluation Count:2272
yes
Evaluation Count:10914
2272-10914
663 return false;
executed: return false;
Execution Count:2272
2272
664 else if (isStartElement())
evaluated: isStartElement()
TRUEFALSE
yes
Evaluation Count:4635
yes
Evaluation Count:6279
4635-6279
665 return true;
executed: return true;
Execution Count:4635
4635
666 } -
667 return false;
executed: return false;
Execution Count:12
12
668} -
669 -
670/*! -
671 Reads until the end of the current element, skipping any child nodes. -
672 This function is useful for skipping unknown elements. -
673 -
674 The current element is the element matching the most recently parsed start -
675 element of which a matching end element has not yet been reached. When the -
676 parser has reached the end element, the current element becomes the parent -
677 element. -
678 -
679 \since 4.6 -
680 */ -
681void QXmlStreamReader::skipCurrentElement() -
682{ -
683 int depth = 1;
executed (the execution status of this line is deduced): int depth = 1;
-
684 while (depth && readNext() != Invalid) {
evaluated: depth
TRUEFALSE
yes
Evaluation Count:2199
yes
Evaluation Count:2155
evaluated: readNext() != Invalid
TRUEFALSE
yes
Evaluation Count:2192
yes
Evaluation Count:7
7-2199
685 if (isEndElement())
evaluated: isEndElement()
TRUEFALSE
yes
Evaluation Count:2168
yes
Evaluation Count:24
24-2168
686 --depth;
executed: --depth;
Execution Count:2168
2168
687 else if (isStartElement())
evaluated: isStartElement()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:11
11-13
688 ++depth;
executed: ++depth;
Execution Count:13
13
689 } -
690}
executed: }
Execution Count:2162
2162
691 -
692/* -
693 * Use the following Perl script to generate the error string index list: -
694===== PERL SCRIPT ==== -
695print "static const char QXmlStreamReader_tokenTypeString_string[] =\n"; -
696$counter = 0; -
697$i = 0; -
698while (<STDIN>) { -
699 chomp; -
700 print " \"$_\\0\"\n"; -
701 $sizes[$i++] = $counter; -
702 $counter += length 1 + $_; -
703} -
704print " \"\\0\";\n\nstatic const short QXmlStreamReader_tokenTypeString_indices[] = {\n "; -
705for ($j = 0; $j < $i; ++$j) { -
706 printf "$sizes[$j], "; -
707} -
708print "0\n};\n"; -
709===== PERL SCRIPT ==== -
710 -
711 * The input data is as follows (copied from qxmlstream.h): -
712NoToken -
713Invalid -
714StartDocument -
715EndDocument -
716StartElement -
717EndElement -
718Characters -
719Comment -
720DTD -
721EntityReference -
722ProcessingInstruction -
723*/ -
724static const char QXmlStreamReader_tokenTypeString_string[] = -
725 "NoToken\0" -
726 "Invalid\0" -
727 "StartDocument\0" -
728 "EndDocument\0" -
729 "StartElement\0" -
730 "EndElement\0" -
731 "Characters\0" -
732 "Comment\0" -
733 "DTD\0" -
734 "EntityReference\0" -
735 "ProcessingInstruction\0"; -
736 -
737static const short QXmlStreamReader_tokenTypeString_indices[] = { -
738 0, 8, 16, 30, 42, 55, 66, 77, 85, 89, 105, 0 -
739}; -
740 -
741 -
742/*! -
743 \property QXmlStreamReader::namespaceProcessing -
744 the namespace-processing flag of the stream reader -
745 -
746 This property controls whether or not the stream reader processes -
747 namespaces. If enabled, the reader processes namespaces, otherwise -
748 it does not. -
749 -
750 By default, namespace-processing is enabled. -
751*/ -
752 -
753 -
754void QXmlStreamReader::setNamespaceProcessing(bool enable) -
755{ -
756 Q_D(QXmlStreamReader);
never executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
757 d->namespaceProcessing = enable;
never executed (the execution status of this line is deduced): d->namespaceProcessing = enable;
-
758}
never executed: }
0
759 -
760bool QXmlStreamReader::namespaceProcessing() const -
761{ -
762 Q_D(const QXmlStreamReader);
never executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
763 return d->namespaceProcessing;
never executed: return d->namespaceProcessing;
0
764} -
765 -
766/*! Returns the reader's current token as string. -
767 -
768\sa tokenType() -
769*/ -
770QString QXmlStreamReader::tokenString() const -
771{ -
772 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
773 return QLatin1String(QXmlStreamReader_tokenTypeString_string +
executed: return QLatin1String(QXmlStreamReader_tokenTypeString_string + QXmlStreamReader_tokenTypeString_indices[d->type]);
Execution Count:1891
1891
774 QXmlStreamReader_tokenTypeString_indices[d->type]);
executed: return QLatin1String(QXmlStreamReader_tokenTypeString_string + QXmlStreamReader_tokenTypeString_indices[d->type]);
Execution Count:1891
1891
775} -
776 -
777#endif // QT_NO_XMLSTREAMREADER -
778 -
779QXmlStreamPrivateTagStack::QXmlStreamPrivateTagStack() -
780{ -
781 tagStack.reserve(16);
executed (the execution status of this line is deduced): tagStack.reserve(16);
-
782 tagStackStringStorage.reserve(32);
executed (the execution status of this line is deduced): tagStackStringStorage.reserve(32);
-
783 tagStackStringStorageSize = 0;
executed (the execution status of this line is deduced): tagStackStringStorageSize = 0;
-
784 NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
executed (the execution status of this line is deduced): NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
-
785 namespaceDeclaration.prefix = addToStringStorage(QLatin1String("xml"));
executed (the execution status of this line is deduced): namespaceDeclaration.prefix = addToStringStorage(QLatin1String("xml"));
-
786 namespaceDeclaration.namespaceUri = addToStringStorage(QLatin1String("http://www.w3.org/XML/1998/namespace"));
executed (the execution status of this line is deduced): namespaceDeclaration.namespaceUri = addToStringStorage(QLatin1String("http://www.w3.org/XML/1998/namespace"));
-
787}
executed: }
Execution Count:5532
5532
788 -
789#ifndef QT_NO_XMLSTREAMREADER -
790 -
791QXmlStreamReaderPrivate::QXmlStreamReaderPrivate(QXmlStreamReader *q) -
792 :q_ptr(q) -
793{ -
794 device = 0;
executed (the execution status of this line is deduced): device = 0;
-
795 deleteDevice = false;
executed (the execution status of this line is deduced): deleteDevice = false;
-
796#ifndef QT_NO_TEXTCODEC -
797 decoder = 0;
executed (the execution status of this line is deduced): decoder = 0;
-
798#endif -
799 stack_size = 64;
executed (the execution status of this line is deduced): stack_size = 64;
-
800 sym_stack = 0;
executed (the execution status of this line is deduced): sym_stack = 0;
-
801 state_stack = 0;
executed (the execution status of this line is deduced): state_stack = 0;
-
802 reallocateStack();
executed (the execution status of this line is deduced): reallocateStack();
-
803 entityResolver = 0;
executed (the execution status of this line is deduced): entityResolver = 0;
-
804 init();
executed (the execution status of this line is deduced): init();
-
805 entityHash.insert(QLatin1String("lt"), Entity::createLiteral(QLatin1String("<")));
executed (the execution status of this line is deduced): entityHash.insert(QLatin1String("lt"), Entity::createLiteral(QLatin1String("<")));
-
806 entityHash.insert(QLatin1String("gt"), Entity::createLiteral(QLatin1String(">")));
executed (the execution status of this line is deduced): entityHash.insert(QLatin1String("gt"), Entity::createLiteral(QLatin1String(">")));
-
807 entityHash.insert(QLatin1String("amp"), Entity::createLiteral(QLatin1String("&")));
executed (the execution status of this line is deduced): entityHash.insert(QLatin1String("amp"), Entity::createLiteral(QLatin1String("&")));
-
808 entityHash.insert(QLatin1String("apos"), Entity::createLiteral(QLatin1String("'")));
executed (the execution status of this line is deduced): entityHash.insert(QLatin1String("apos"), Entity::createLiteral(QLatin1String("'")));
-
809 entityHash.insert(QLatin1String("quot"), Entity::createLiteral(QLatin1String("\"")));
executed (the execution status of this line is deduced): entityHash.insert(QLatin1String("quot"), Entity::createLiteral(QLatin1String("\"")));
-
810}
executed: }
Execution Count:4801
4801
811 -
812void QXmlStreamReaderPrivate::init() -
813{ -
814 scanDtd = false;
executed (the execution status of this line is deduced): scanDtd = false;
-
815 token = -1;
executed (the execution status of this line is deduced): token = -1;
-
816 token_char = 0;
executed (the execution status of this line is deduced): token_char = 0;
-
817 isEmptyElement = false;
executed (the execution status of this line is deduced): isEmptyElement = false;
-
818 isWhitespace = true;
executed (the execution status of this line is deduced): isWhitespace = true;
-
819 isCDATA = false;
executed (the execution status of this line is deduced): isCDATA = false;
-
820 standalone = false;
executed (the execution status of this line is deduced): standalone = false;
-
821 tos = 0;
executed (the execution status of this line is deduced): tos = 0;
-
822 resumeReduction = 0;
executed (the execution status of this line is deduced): resumeReduction = 0;
-
823 state_stack[tos++] = 0;
executed (the execution status of this line is deduced): state_stack[tos++] = 0;
-
824 state_stack[tos] = 0;
executed (the execution status of this line is deduced): state_stack[tos] = 0;
-
825 putStack.clear();
executed (the execution status of this line is deduced): putStack.clear();
-
826 putStack.reserve(32);
executed (the execution status of this line is deduced): putStack.reserve(32);
-
827 textBuffer.clear();
executed (the execution status of this line is deduced): textBuffer.clear();
-
828 textBuffer.reserve(256);
executed (the execution status of this line is deduced): textBuffer.reserve(256);
-
829 tagStack.clear();
executed (the execution status of this line is deduced): tagStack.clear();
-
830 tagsDone = false;
executed (the execution status of this line is deduced): tagsDone = false;
-
831 attributes.clear();
executed (the execution status of this line is deduced): attributes.clear();
-
832 attributes.reserve(16);
executed (the execution status of this line is deduced): attributes.reserve(16);
-
833 lineNumber = lastLineStart = characterOffset = 0;
executed (the execution status of this line is deduced): lineNumber = lastLineStart = characterOffset = 0;
-
834 readBufferPos = 0;
executed (the execution status of this line is deduced): readBufferPos = 0;
-
835 nbytesread = 0;
executed (the execution status of this line is deduced): nbytesread = 0;
-
836#ifndef QT_NO_TEXTCODEC -
837 codec = QTextCodec::codecForMib(106); // utf8
executed (the execution status of this line is deduced): codec = QTextCodec::codecForMib(106);
-
838 delete decoder;
executed (the execution status of this line is deduced): delete decoder;
-
839 decoder = 0;
executed (the execution status of this line is deduced): decoder = 0;
-
840#endif -
841 attributeStack.clear();
executed (the execution status of this line is deduced): attributeStack.clear();
-
842 attributeStack.reserve(16);
executed (the execution status of this line is deduced): attributeStack.reserve(16);
-
843 entityParser = 0;
executed (the execution status of this line is deduced): entityParser = 0;
-
844 hasCheckedStartDocument = false;
executed (the execution status of this line is deduced): hasCheckedStartDocument = false;
-
845 normalizeLiterals = false;
executed (the execution status of this line is deduced): normalizeLiterals = false;
-
846 hasSeenTag = false;
executed (the execution status of this line is deduced): hasSeenTag = false;
-
847 atEnd = false;
executed (the execution status of this line is deduced): atEnd = false;
-
848 inParseEntity = false;
executed (the execution status of this line is deduced): inParseEntity = false;
-
849 referenceToUnparsedEntityDetected = false;
executed (the execution status of this line is deduced): referenceToUnparsedEntityDetected = false;
-
850 referenceToParameterEntityDetected = false;
executed (the execution status of this line is deduced): referenceToParameterEntityDetected = false;
-
851 hasExternalDtdSubset = false;
executed (the execution status of this line is deduced): hasExternalDtdSubset = false;
-
852 lockEncoding = false;
executed (the execution status of this line is deduced): lockEncoding = false;
-
853 namespaceProcessing = true;
executed (the execution status of this line is deduced): namespaceProcessing = true;
-
854 rawReadBuffer.clear();
executed (the execution status of this line is deduced): rawReadBuffer.clear();
-
855 dataBuffer.clear();
executed (the execution status of this line is deduced): dataBuffer.clear();
-
856 readBuffer.clear();
executed (the execution status of this line is deduced): readBuffer.clear();
-
857 -
858 type = QXmlStreamReader::NoToken;
executed (the execution status of this line is deduced): type = QXmlStreamReader::NoToken;
-
859 error = QXmlStreamReader::NoError;
executed (the execution status of this line is deduced): error = QXmlStreamReader::NoError;
-
860}
executed: }
Execution Count:7021
7021
861 -
862/* -
863 Well-formed requires that we verify entity values. We do this with a -
864 standard parser. -
865 */ -
866void QXmlStreamReaderPrivate::parseEntity(const QString &value) -
867{ -
868 Q_Q(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReader * const q = q_func();
-
869 -
870 if (value.isEmpty())
evaluated: value.isEmpty()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:124
14-124
871 return;
executed: return;
Execution Count:14
14
872 -
873 -
874 if (!entityParser)
evaluated: !entityParser
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:33
33-91
875 entityParser = new QXmlStreamReaderPrivate(q);
executed: entityParser = new QXmlStreamReaderPrivate(q);
Execution Count:91
91
876 else -
877 entityParser->init();
executed: entityParser->init();
Execution Count:33
33
878 entityParser->inParseEntity = true;
executed (the execution status of this line is deduced): entityParser->inParseEntity = true;
-
879 entityParser->readBuffer = value;
executed (the execution status of this line is deduced): entityParser->readBuffer = value;
-
880 entityParser->injectToken(PARSE_ENTITY);
executed (the execution status of this line is deduced): entityParser->injectToken(PARSE_ENTITY);
-
881 while (!entityParser->atEnd && entityParser->type != QXmlStreamReader::Invalid)
evaluated: !entityParser->atEnd
TRUEFALSE
yes
Evaluation Count:215
yes
Evaluation Count:118
evaluated: entityParser->type != QXmlStreamReader::Invalid
TRUEFALSE
yes
Evaluation Count:209
yes
Evaluation Count:6
6-215
882 entityParser->parse();
executed: entityParser->parse();
Execution Count:209
209
883 if (entityParser->type == QXmlStreamReader::Invalid || entityParser->tagStack.size())
evaluated: entityParser->type == QXmlStreamReader::Invalid
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:108
evaluated: entityParser->tagStack.size()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:106
2-108
884 raiseWellFormedError(QXmlStream::tr("Invalid entity value."));
executed: raiseWellFormedError(QXmlStream::tr("Invalid entity value."));
Execution Count:18
18
885 -
886}
executed: }
Execution Count:124
124
887 -
888inline void QXmlStreamReaderPrivate::reallocateStack() -
889{ -
890 stack_size <<= 1;
executed (the execution status of this line is deduced): stack_size <<= 1;
-
891 sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
executed (the execution status of this line is deduced): sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
-
892 Q_CHECK_PTR(sym_stack);
never executed: qBadAlloc();
executed: }
Execution Count:4802
partially evaluated: !(sym_stack)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4802
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4802
0-4802
893 state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
executed (the execution status of this line is deduced): state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
-
894 Q_CHECK_PTR(sym_stack);
never executed: qBadAlloc();
executed: }
Execution Count:4802
partially evaluated: !(sym_stack)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4802
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4802
0-4802
895}
executed: }
Execution Count:4802
4802
896 -
897 -
898QXmlStreamReaderPrivate::~QXmlStreamReaderPrivate() -
899{ -
900#ifndef QT_NO_TEXTCODEC -
901 delete decoder;
executed (the execution status of this line is deduced): delete decoder;
-
902#endif -
903 free(sym_stack);
executed (the execution status of this line is deduced): free(sym_stack);
-
904 free(state_stack);
executed (the execution status of this line is deduced): free(state_stack);
-
905 delete entityParser;
executed (the execution status of this line is deduced): delete entityParser;
-
906}
executed: }
Execution Count:4801
4801
907 -
908 -
909inline uint QXmlStreamReaderPrivate::filterCarriageReturn() -
910{ -
911 uint peekc = peekChar();
executed (the execution status of this line is deduced): uint peekc = peekChar();
-
912 if (peekc == '\n') {
evaluated: peekc == '\n'
TRUEFALSE
yes
Evaluation Count:8294
yes
Evaluation Count:2156
2156-8294
913 if (putStack.size())
partially evaluated: putStack.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8294
0-8294
914 putStack.pop();
never executed: putStack.pop();
0
915 else -
916 ++readBufferPos;
executed: ++readBufferPos;
Execution Count:8294
8294
917 return peekc;
executed: return peekc;
Execution Count:8294
8294
918 } -
919 if (peekc == 0) {
evaluated: peekc == 0
TRUEFALSE
yes
Evaluation Count:2146
yes
Evaluation Count:10
10-2146
920 putChar('\r');
executed (the execution status of this line is deduced): putChar('\r');
-
921 return 0;
executed: return 0;
Execution Count:2146
2146
922 } -
923 return '\n';
executed: return '\n';
Execution Count:10
10
924} -
925 -
926/*! -
927 \internal -
928 If the end of the file is encountered, 0 is returned. -
929 */ -
930inline uint QXmlStreamReaderPrivate::getChar() -
931{ -
932 uint c;
executed (the execution status of this line is deduced): uint c;
-
933 if (putStack.size()) {
evaluated: putStack.size()
TRUEFALSE
yes
Evaluation Count:920172
yes
Evaluation Count:4993541
920172-4993541
934 c = atEnd ? 0 : putStack.pop();
evaluated: atEnd
TRUEFALSE
yes
Evaluation Count:4857
yes
Evaluation Count:915315
4857-915315
935 } else {
executed: }
Execution Count:920172
920172
936 if (readBufferPos < readBuffer.size())
evaluated: readBufferPos < readBuffer.size()
TRUEFALSE
yes
Evaluation Count:4880341
yes
Evaluation Count:113200
113200-4880341
937 c = readBuffer.at(readBufferPos++).unicode();
executed: c = readBuffer.at(readBufferPos++).unicode();
Execution Count:4880341
4880341
938 else -
939 c = getChar_helper();
executed: c = getChar_helper();
Execution Count:113200
113200
940 } -
941 -
942 return c;
executed: return c;
Execution Count:5913713
5913713
943} -
944 -
945inline uint QXmlStreamReaderPrivate::peekChar() -
946{ -
947 uint c;
executed (the execution status of this line is deduced): uint c;
-
948 if (putStack.size()) {
evaluated: putStack.size()
TRUEFALSE
yes
Evaluation Count:13758
yes
Evaluation Count:79947
13758-79947
949 c = putStack.top();
executed (the execution status of this line is deduced): c = putStack.top();
-
950 } else if (readBufferPos < readBuffer.size()) {
executed: }
Execution Count:13758
evaluated: readBufferPos < readBuffer.size()
TRUEFALSE
yes
Evaluation Count:73265
yes
Evaluation Count:6682
6682-73265
951 c = readBuffer.at(readBufferPos).unicode();
executed (the execution status of this line is deduced): c = readBuffer.at(readBufferPos).unicode();
-
952 } else {
executed: }
Execution Count:73265
73265
953 if ((c = getChar_helper()))
evaluated: (c = getChar_helper())
TRUEFALSE
yes
Evaluation Count:3331
yes
Evaluation Count:3351
3331-3351
954 --readBufferPos;
executed: --readBufferPos;
Execution Count:3331
3331
955 }
executed: }
Execution Count:6682
6682
956 -
957 return c;
executed: return c;
Execution Count:93705
93705
958} -
959 -
960/*! -
961 \internal -
962 -
963 Scans characters until \a str is encountered, and validates the characters -
964 as according to the Char[2] production and do the line-ending normalization. -
965 If any character is invalid, false is returned, otherwise true upon success. -
966 -
967 If \a tokenToInject is not less than zero, injectToken() is called with -
968 \a tokenToInject when \a str is found. -
969 -
970 If any error occurred, false is returned, otherwise true. -
971 */ -
972bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject) -
973{ -
974 int pos = textBuffer.size();
executed (the execution status of this line is deduced): int pos = textBuffer.size();
-
975 int oldLineNumber = lineNumber;
executed (the execution status of this line is deduced): int oldLineNumber = lineNumber;
-
976 -
977 while (uint c = getChar()) {
evaluated: uint c = getChar()
TRUEFALSE
yes
Evaluation Count:1061152
yes
Evaluation Count:5871
5871-1061152
978 /* First, we do the validation & normalization. */ -
979 switch (c) { -
980 case '\r': -
981 if ((c = filterCarriageReturn()) == 0)
evaluated: (c = filterCarriageReturn()) == 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:402
3-402
982 break;
executed: break;
Execution Count:3
3
983 // fall through -
984 case '\n':
code before this statement executed: case '\n':
Execution Count:402
402
985 ++lineNumber;
executed (the execution status of this line is deduced): ++lineNumber;
-
986 lastLineStart = characterOffset + readBufferPos;
executed (the execution status of this line is deduced): lastLineStart = characterOffset + readBufferPos;
-
987 // fall through -
988 case '\t':
code before this statement executed: case '\t':
Execution Count:1645
1645
989 textBuffer += QChar(c);
executed (the execution status of this line is deduced): textBuffer += QChar(c);
-
990 continue;
executed: continue;
Execution Count:2368
2368
991 default: -
992 if (c < 0x20 || (c > 0xFFFD && c < 0x10000) || c > QChar::LastValidCodePoint ) {
evaluated: c < 0x20
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:1058751
partially evaluated: c > 0xFFFD
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1058751
never evaluated: c < 0x10000
partially evaluated: c > QChar::LastValidCodePoint
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1058751
0-1058751
993 raiseWellFormedError(QXmlStream::tr("Invalid XML character."));
executed (the execution status of this line is deduced): raiseWellFormedError(QXmlStream::tr("Invalid XML character."));
-
994 lineNumber = oldLineNumber;
executed (the execution status of this line is deduced): lineNumber = oldLineNumber;
-
995 return false;
executed: return false;
Execution Count:30
30
996 } -
997 textBuffer += QChar(c);
executed (the execution status of this line is deduced): textBuffer += QChar(c);
-
998 }
executed: }
Execution Count:1058751
1058751
999 -
1000 -
1001 /* Second, attempt to lookup str. */ -
1002 if (c == uint(*str)) {
evaluated: c == uint(*str)
TRUEFALSE
yes
Evaluation Count:63739
yes
Evaluation Count:995015
63739-995015
1003 if (!*(str + 1)) {
partially evaluated: !*(str + 1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:63739
0-63739
1004 if (tokenToInject >= 0)
never evaluated: tokenToInject >= 0
0
1005 injectToken(tokenToInject);
never executed: injectToken(tokenToInject);
0
1006 return true;
never executed: return true;
0
1007 } else { -
1008 if (scanString(str + 1, tokenToInject, false))
evaluated: scanString(str + 1, tokenToInject, false)
TRUEFALSE
yes
Evaluation Count:62699
yes
Evaluation Count:1040
1040-62699
1009 return true;
executed: return true;
Execution Count:62699
62699
1010 }
executed: }
Execution Count:1040
1040
1011 } -
1012 }
executed: }
Execution Count:996055
996055
1013 putString(textBuffer, pos);
executed (the execution status of this line is deduced): putString(textBuffer, pos);
-
1014 textBuffer.resize(pos);
executed (the execution status of this line is deduced): textBuffer.resize(pos);
-
1015 lineNumber = oldLineNumber;
executed (the execution status of this line is deduced): lineNumber = oldLineNumber;
-
1016 return false;
executed: return false;
Execution Count:5871
5871
1017} -
1018 -
1019bool QXmlStreamReaderPrivate::scanString(const char *str, short tokenToInject, bool requireSpace) -
1020{ -
1021 int n = 0;
executed (the execution status of this line is deduced): int n = 0;
-
1022 while (str[n]) {
evaluated: str[n]
TRUEFALSE
yes
Evaluation Count:585719
yes
Evaluation Count:123197
123197-585719
1023 ushort c = getChar();
executed (the execution status of this line is deduced): ushort c = getChar();
-
1024 if (c != ushort(str[n])) {
evaluated: c != ushort(str[n])
TRUEFALSE
yes
Evaluation Count:24900
yes
Evaluation Count:560819
24900-560819
1025 if (c)
evaluated: c
TRUEFALSE
yes
Evaluation Count:6731
yes
Evaluation Count:18169
6731-18169
1026 putChar(c);
executed: putChar(c);
Execution Count:6731
6731
1027 while (n--) {
evaluated: n--
TRUEFALSE
yes
Evaluation Count:39555
yes
Evaluation Count:24900
24900-39555
1028 putChar(ushort(str[n]));
executed (the execution status of this line is deduced): putChar(ushort(str[n]));
-
1029 }
executed: }
Execution Count:39555
39555
1030 return false;
executed: return false;
Execution Count:24900
24900
1031 } -
1032 ++n;
executed (the execution status of this line is deduced): ++n;
-
1033 }
executed: }
Execution Count:560819
560819
1034 for (int i = 0; i < n; ++i)
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:521264
yes
Evaluation Count:123197
123197-521264
1035 textBuffer += QChar(ushort(str[i]));
executed: textBuffer += QChar(ushort(str[i]));
Execution Count:521264
521264
1036 if (requireSpace) {
evaluated: requireSpace
TRUEFALSE
yes
Evaluation Count:10541
yes
Evaluation Count:112656
10541-112656
1037 int s = fastScanSpace();
executed (the execution status of this line is deduced): int s = fastScanSpace();
-
1038 if (!s || atEnd) {
evaluated: !s
TRUEFALSE
yes
Evaluation Count:1608
yes
Evaluation Count:8933
evaluated: atEnd
TRUEFALSE
yes
Evaluation Count:1435
yes
Evaluation Count:7498
1435-8933
1039 int pos = textBuffer.size() - n - s;
executed (the execution status of this line is deduced): int pos = textBuffer.size() - n - s;
-
1040 putString(textBuffer, pos);
executed (the execution status of this line is deduced): putString(textBuffer, pos);
-
1041 textBuffer.resize(pos);
executed (the execution status of this line is deduced): textBuffer.resize(pos);
-
1042 return false;
executed: return false;
Execution Count:3043
3043
1043 } -
1044 }
executed: }
Execution Count:7498
7498
1045 if (tokenToInject >= 0)
evaluated: tokenToInject >= 0
TRUEFALSE
yes
Evaluation Count:57455
yes
Evaluation Count:62699
57455-62699
1046 injectToken(tokenToInject);
executed: injectToken(tokenToInject);
Execution Count:57455
57455
1047 return true;
executed: return true;
Execution Count:120154
120154
1048} -
1049 -
1050bool QXmlStreamReaderPrivate::scanAfterLangleBang() -
1051{ -
1052 switch (peekChar()) { -
1053 case '[': -
1054 return scanString(spell[CDATA_START], CDATA_START, false);
executed: return scanString(spell[CDATA_START], CDATA_START, false);
Execution Count:46321
46321
1055 case 'D': -
1056 return scanString(spell[DOCTYPE], DOCTYPE);
executed: return scanString(spell[DOCTYPE], DOCTYPE);
Execution Count:3683
3683
1057 case 'A': -
1058 return scanString(spell[ATTLIST], ATTLIST);
executed: return scanString(spell[ATTLIST], ATTLIST);
Execution Count:2230
2230
1059 case 'N': -
1060 return scanString(spell[NOTATION], NOTATION);
executed: return scanString(spell[NOTATION], NOTATION);
Execution Count:382
382
1061 case 'E': -
1062 if (scanString(spell[ELEMENT], ELEMENT))
evaluated: scanString(spell[ELEMENT], ELEMENT)
TRUEFALSE
yes
Evaluation Count:2122
yes
Evaluation Count:4575
2122-4575
1063 return true;
executed: return true;
Execution Count:2122
2122
1064 return scanString(spell[ENTITY], ENTITY);
executed: return scanString(spell[ENTITY], ENTITY);
Execution Count:4575
4575
1065 -
1066 default: -
1067 ; -
1068 };
executed: }
Execution Count:17122
17122
1069 return false;
executed: return false;
Execution Count:17122
17122
1070} -
1071 -
1072bool QXmlStreamReaderPrivate::scanPublicOrSystem() -
1073{ -
1074 switch (peekChar()) { -
1075 case 'S': -
1076 return scanString(spell[SYSTEM], SYSTEM);
executed: return scanString(spell[SYSTEM], SYSTEM);
Execution Count:440
440
1077 case 'P': -
1078 return scanString(spell[PUBLIC], PUBLIC);
executed: return scanString(spell[PUBLIC], PUBLIC);
Execution Count:263
263
1079 default: -
1080 ; -
1081 }
executed: }
Execution Count:1854
1854
1082 return false;
executed: return false;
Execution Count:1854
1854
1083} -
1084 -
1085bool QXmlStreamReaderPrivate::scanNData() -
1086{ -
1087 if (fastScanSpace()) {
evaluated: fastScanSpace()
TRUEFALSE
yes
Evaluation Count:150
yes
Evaluation Count:48
48-150
1088 if (scanString(spell[NDATA], NDATA))
evaluated: scanString(spell[NDATA], NDATA)
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:103
47-103
1089 return true;
executed: return true;
Execution Count:47
47
1090 putChar(' ');
executed (the execution status of this line is deduced): putChar(' ');
-
1091 }
executed: }
Execution Count:103
103
1092 return false;
executed: return false;
Execution Count:151
151
1093} -
1094 -
1095bool QXmlStreamReaderPrivate::scanAfterDefaultDecl() -
1096{ -
1097 switch (peekChar()) { -
1098 case 'R': -
1099 return scanString(spell[REQUIRED], REQUIRED, false);
executed: return scanString(spell[REQUIRED], REQUIRED, false);
Execution Count:565
565
1100 case 'I': -
1101 return scanString(spell[IMPLIED], IMPLIED, false);
executed: return scanString(spell[IMPLIED], IMPLIED, false);
Execution Count:1317
1317
1102 case 'F': -
1103 return scanString(spell[FIXED], FIXED, false);
executed: return scanString(spell[FIXED], FIXED, false);
Execution Count:72
72
1104 default: -
1105 ; -
1106 }
executed: }
Execution Count:200
200
1107 return false;
executed: return false;
Execution Count:200
200
1108} -
1109 -
1110bool QXmlStreamReaderPrivate::scanAttType() -
1111{ -
1112 switch (peekChar()) { -
1113 case 'C': -
1114 return scanString(spell[CDATA], CDATA);
executed: return scanString(spell[CDATA], CDATA);
Execution Count:1256
1256
1115 case 'I': -
1116 if (scanString(spell[ID], ID))
evaluated: scanString(spell[ID], ID)
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:202
70-202
1117 return true;
executed: return true;
Execution Count:70
70
1118 if (scanString(spell[IDREF], IDREF))
evaluated: scanString(spell[IDREF], IDREF)
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:179
23-179
1119 return true;
executed: return true;
Execution Count:23
23
1120 return scanString(spell[IDREFS], IDREFS);
executed: return scanString(spell[IDREFS], IDREFS);
Execution Count:179
179
1121 case 'E': -
1122 if (scanString(spell[ENTITY], ENTITY))
evaluated: scanString(spell[ENTITY], ENTITY)
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:137
26-137
1123 return true;
executed: return true;
Execution Count:26
26
1124 return scanString(spell[ENTITIES], ENTITIES);
executed: return scanString(spell[ENTITIES], ENTITIES);
Execution Count:137
137
1125 case 'N': -
1126 if (scanString(spell[NOTATION], NOTATION))
evaluated: scanString(spell[NOTATION], NOTATION)
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:292
42-292
1127 return true;
executed: return true;
Execution Count:42
42
1128 if (scanString(spell[NMTOKEN], NMTOKEN))
evaluated: scanString(spell[NMTOKEN], NMTOKEN)
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:268
24-268
1129 return true;
executed: return true;
Execution Count:24
24
1130 return scanString(spell[NMTOKENS], NMTOKENS);
executed: return scanString(spell[NMTOKENS], NMTOKENS);
Execution Count:268
268
1131 default: -
1132 ; -
1133 }
executed: }
Execution Count:84
84
1134 return false;
executed: return false;
Execution Count:84
84
1135} -
1136 -
1137/*! -
1138 \internal -
1139 -
1140 Scan strings with quotes or apostrophes surround them. For instance, -
1141 attributes, the version and encoding field in the XML prolog and -
1142 entity declarations. -
1143 -
1144 If normalizeLiterals is set to true, the function also normalizes -
1145 whitespace. It is set to true when the first start tag is -
1146 encountered. -
1147 -
1148 */ -
1149inline int QXmlStreamReaderPrivate::fastScanLiteralContent() -
1150{ -
1151 int n = 0;
executed (the execution status of this line is deduced): int n = 0;
-
1152 uint c;
executed (the execution status of this line is deduced): uint c;
-
1153 while ((c = getChar())) {
evaluated: (c = getChar())
TRUEFALSE
yes
Evaluation Count:424128
yes
Evaluation Count:2235
2235-424128
1154 switch (ushort(c)) { -
1155 case 0xfffe: -
1156 case 0xffff: -
1157 case 0: -
1158 /* The putChar() call is necessary so the parser re-gets -
1159 * the character from the input source, when raising an error. */ -
1160 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1161 return n;
executed: return n;
Execution Count:82
82
1162 case '\r': -
1163 if (filterCarriageReturn() == 0)
evaluated: filterCarriageReturn() == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:23
1-23
1164 return n;
executed: return n;
Execution Count:1
1
1165 // fall through -
1166 case '\n':
code before this statement executed: case '\n':
Execution Count:23
23
1167 ++lineNumber;
executed (the execution status of this line is deduced): ++lineNumber;
-
1168 lastLineStart = characterOffset + readBufferPos;
executed (the execution status of this line is deduced): lastLineStart = characterOffset + readBufferPos;
-
1169 // fall through -
1170 case ' ':
code before this statement executed: case ' ':
Execution Count:235
235
1171 case '\t': -
1172 if (normalizeLiterals)
evaluated: normalizeLiterals
TRUEFALSE
yes
Evaluation Count:8899
yes
Evaluation Count:557
557-8899
1173 textBuffer += QLatin1Char(' ');
executed: textBuffer += QLatin1Char(' ');
Execution Count:8899
8899
1174 else -
1175 textBuffer += QChar(c);
executed: textBuffer += QChar(c);
Execution Count:557
557
1176 ++n;
executed (the execution status of this line is deduced): ++n;
-
1177 break;
executed: break;
Execution Count:9456
9456
1178 case '&': -
1179 case '<': -
1180 case '\"': -
1181 case '\'': -
1182 if (!(c & 0xff0000)) {
partially evaluated: !(c & 0xff0000)
TRUEFALSE
yes
Evaluation Count:80845
no
Evaluation Count:0
0-80845
1183 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1184 return n;
executed: return n;
Execution Count:80845
80845
1185 } -
1186 // fall through -
1187 default:
code before this statement never executed: default:
0
1188 textBuffer += QChar(c);
executed (the execution status of this line is deduced): textBuffer += QChar(c);
-
1189 ++n;
executed (the execution status of this line is deduced): ++n;
-
1190 }
executed: }
Execution Count:333744
333744
1191 }
executed: }
Execution Count:343200
343200
1192 return n;
executed: return n;
Execution Count:2235
2235
1193} -
1194 -
1195inline int QXmlStreamReaderPrivate::fastScanSpace() -
1196{ -
1197 int n = 0;
executed (the execution status of this line is deduced): int n = 0;
-
1198 ushort c;
executed (the execution status of this line is deduced): ushort c;
-
1199 while ((c = getChar())) {
evaluated: (c = getChar())
TRUEFALSE
yes
Evaluation Count:141198
yes
Evaluation Count:6683
6683-141198
1200 switch (c) { -
1201 case '\r': -
1202 if ((c = filterCarriageReturn()) == 0)
evaluated: (c = filterCarriageReturn()) == 0
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:277
45-277
1203 return n;
executed: return n;
Execution Count:45
45
1204 // fall through -
1205 case '\n':
code before this statement executed: case '\n':
Execution Count:277
277
1206 ++lineNumber;
executed (the execution status of this line is deduced): ++lineNumber;
-
1207 lastLineStart = characterOffset + readBufferPos;
executed (the execution status of this line is deduced): lastLineStart = characterOffset + readBufferPos;
-
1208 // fall through -
1209 case ' ':
code before this statement executed: case ' ':
Execution Count:343
343
1210 case '\t': -
1211 textBuffer += QChar(c);
executed (the execution status of this line is deduced): textBuffer += QChar(c);
-
1212 ++n;
executed (the execution status of this line is deduced): ++n;
-
1213 break;
executed: break;
Execution Count:13736
13736
1214 default: -
1215 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1216 return n;
executed: return n;
Execution Count:127417
127417
1217 } -
1218 }
executed: }
Execution Count:13736
13736
1219 return n;
executed: return n;
Execution Count:6683
6683
1220} -
1221 -
1222/*! -
1223 \internal -
1224 -
1225 Used for text nodes essentially. That is, characters appearing -
1226 inside elements. -
1227 */ -
1228inline int QXmlStreamReaderPrivate::fastScanContentCharList() -
1229{ -
1230 int n = 0;
executed (the execution status of this line is deduced): int n = 0;
-
1231 uint c;
executed (the execution status of this line is deduced): uint c;
-
1232 while ((c = getChar())) {
evaluated: (c = getChar())
TRUEFALSE
yes
Evaluation Count:391680
yes
Evaluation Count:8000
8000-391680
1233 switch (ushort(c)) { -
1234 case 0xfffe: -
1235 case 0xffff: -
1236 case 0: -
1237 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1238 return n;
executed: return n;
Execution Count:60
60
1239 case ']': { -
1240 isWhitespace = false;
executed (the execution status of this line is deduced): isWhitespace = false;
-
1241 int pos = textBuffer.size();
executed (the execution status of this line is deduced): int pos = textBuffer.size();
-
1242 textBuffer += QChar(ushort(c));
executed (the execution status of this line is deduced): textBuffer += QChar(ushort(c));
-
1243 ++n;
executed (the execution status of this line is deduced): ++n;
-
1244 while ((c = getChar()) == ']') {
evaluated: (c = getChar()) == ']'
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:17
11-17
1245 textBuffer += QChar(ushort(c));
executed (the execution status of this line is deduced): textBuffer += QChar(ushort(c));
-
1246 ++n;
executed (the execution status of this line is deduced): ++n;
-
1247 }
executed: }
Execution Count:11
11
1248 if (c == 0) {
evaluated: c == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:15
2-15
1249 putString(textBuffer, pos);
executed (the execution status of this line is deduced): putString(textBuffer, pos);
-
1250 textBuffer.resize(pos);
executed (the execution status of this line is deduced): textBuffer.resize(pos);
-
1251 } else if (c == '>' && textBuffer.at(textBuffer.size()-2) == QLatin1Char(']')) {
executed: }
Execution Count:2
evaluated: c == '>'
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:6
evaluated: textBuffer.at(textBuffer.size()-2) == QLatin1Char(']')
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1
1-9
1252 raiseWellFormedError(QXmlStream::tr("Sequence ']]>' not allowed in content."));
executed (the execution status of this line is deduced): raiseWellFormedError(QXmlStream::tr("Sequence ']]>' not allowed in content."));
-
1253 } else {
executed: }
Execution Count:8
8
1254 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1255 break;
executed: break;
Execution Count:7
7
1256 } -
1257 return n;
executed: return n;
Execution Count:10
10
1258 } break;
dead code: break;
-
1259 case '\r': -
1260 if ((c = filterCarriageReturn()) == 0)
evaluated: (c = filterCarriageReturn()) == 0
TRUEFALSE
yes
Evaluation Count:127
yes
Evaluation Count:262
127-262
1261 return n;
executed: return n;
Execution Count:127
127
1262 // fall through -
1263 case '\n':
code before this statement executed: case '\n':
Execution Count:262
262
1264 ++lineNumber;
executed (the execution status of this line is deduced): ++lineNumber;
-
1265 lastLineStart = characterOffset + readBufferPos;
executed (the execution status of this line is deduced): lastLineStart = characterOffset + readBufferPos;
-
1266 // fall through -
1267 case ' ':
code before this statement executed: case ' ':
Execution Count:347
347
1268 case '\t': -
1269 textBuffer += QChar(ushort(c));
executed (the execution status of this line is deduced): textBuffer += QChar(ushort(c));
-
1270 ++n;
executed (the execution status of this line is deduced): ++n;
-
1271 break;
executed: break;
Execution Count:227056
227056
1272 case '&': -
1273 case '<': -
1274 if (!(c & 0xff0000)) {
partially evaluated: !(c & 0xff0000)
TRUEFALSE
yes
Evaluation Count:137501
no
Evaluation Count:0
0-137501
1275 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1276 return n;
executed: return n;
Execution Count:137501
137501
1277 } -
1278 // fall through -
1279 default:
code before this statement never executed: default:
0
1280 if (c < 0x20) {
evaluated: c < 0x20
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:26917
2-26917
1281 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1282 return n;
executed: return n;
Execution Count:2
2
1283 } -
1284 isWhitespace = false;
executed (the execution status of this line is deduced): isWhitespace = false;
-
1285 textBuffer += QChar(ushort(c));
executed (the execution status of this line is deduced): textBuffer += QChar(ushort(c));
-
1286 ++n;
executed (the execution status of this line is deduced): ++n;
-
1287 }
executed: }
Execution Count:26917
26917
1288 }
executed: }
Execution Count:253980
253980
1289 return n;
executed: return n;
Execution Count:8000
8000
1290} -
1291 -
1292inline int QXmlStreamReaderPrivate::fastScanName(int *prefix) -
1293{ -
1294 int n = 0;
executed (the execution status of this line is deduced): int n = 0;
-
1295 ushort c;
executed (the execution status of this line is deduced): ushort c;
-
1296 while ((c = getChar())) {
evaluated: (c = getChar())
TRUEFALSE
yes
Evaluation Count:1726820
yes
Evaluation Count:9761
9761-1726820
1297 switch (c) { -
1298 case '\n': -
1299 case ' ': -
1300 case '\t': -
1301 case '\r': -
1302 case '&': -
1303 case '#': -
1304 case '\'': -
1305 case '\"': -
1306 case '<': -
1307 case '>': -
1308 case '[': -
1309 case ']': -
1310 case '=': -
1311 case '%': -
1312 case '/': -
1313 case ';': -
1314 case '?': -
1315 case '!': -
1316 case '^': -
1317 case '|': -
1318 case ',': -
1319 case '(': -
1320 case ')': -
1321 case '+': -
1322 case '*': -
1323 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1324 if (prefix && *prefix == n+1) {
evaluated: prefix
TRUEFALSE
yes
Evaluation Count:252448
yes
Evaluation Count:2521
evaluated: *prefix == n+1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:252444
4-252448
1325 *prefix = 0;
executed (the execution status of this line is deduced): *prefix = 0;
-
1326 putChar(':');
executed (the execution status of this line is deduced): putChar(':');
-
1327 --n;
executed (the execution status of this line is deduced): --n;
-
1328 }
executed: }
Execution Count:4
4
1329 return n;
executed: return n;
Execution Count:254969
254969
1330 case ':': -
1331 if (prefix) {
evaluated: prefix
TRUEFALSE
yes
Evaluation Count:1114
yes
Evaluation Count:7
7-1114
1332 if (*prefix == 0) {
evaluated: *prefix == 0
TRUEFALSE
yes
Evaluation Count:1112
yes
Evaluation Count:2
2-1112
1333 *prefix = n+2;
executed (the execution status of this line is deduced): *prefix = n+2;
-
1334 } else { // only one colon allowed according to the namespace spec.
executed: }
Execution Count:1112
1112
1335 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1336 return n;
executed: return n;
Execution Count:2
2
1337 } -
1338 } else { -
1339 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1340 return n;
executed: return n;
Execution Count:7
7
1341 } -
1342 // fall through -
1343 default:
code before this statement executed: default:
Execution Count:1112
1112
1344 textBuffer += QChar(c);
executed (the execution status of this line is deduced): textBuffer += QChar(c);
-
1345 ++n;
executed (the execution status of this line is deduced): ++n;
-
1346 }
executed: }
Execution Count:1471842
1471842
1347 }
executed: }
Execution Count:1471842
1471842
1348 -
1349 if (prefix)
evaluated: prefix
TRUEFALSE
yes
Evaluation Count:8770
yes
Evaluation Count:991
991-8770
1350 *prefix = 0;
executed: *prefix = 0;
Execution Count:8770
8770
1351 int pos = textBuffer.size() - n;
executed (the execution status of this line is deduced): int pos = textBuffer.size() - n;
-
1352 putString(textBuffer, pos);
executed (the execution status of this line is deduced): putString(textBuffer, pos);
-
1353 textBuffer.resize(pos);
executed (the execution status of this line is deduced): textBuffer.resize(pos);
-
1354 return 0;
executed: return 0;
Execution Count:9761
9761
1355} -
1356 -
1357enum NameChar { NameBeginning, NameNotBeginning, NotName }; -
1358 -
1359static const char Begi = static_cast<char>(NameBeginning); -
1360static const char NtBg = static_cast<char>(NameNotBeginning); -
1361static const char NotN = static_cast<char>(NotName); -
1362 -
1363static const char nameCharTable[128] = -
1364{ -
1365// 0x00 -
1366 NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, -
1367 NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, -
1368// 0x10 -
1369 NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, -
1370 NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, -
1371// 0x20 (0x2D is '-', 0x2E is '.') -
1372 NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, -
1373 NotN, NotN, NotN, NotN, NotN, NtBg, NtBg, NotN, -
1374// 0x30 (0x30..0x39 are '0'..'9', 0x3A is ':') -
1375 NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, -
1376 NtBg, NtBg, Begi, NotN, NotN, NotN, NotN, NotN, -
1377// 0x40 (0x41..0x5A are 'A'..'Z') -
1378 NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi, -
1379 Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, -
1380// 0x50 (0x5F is '_') -
1381 Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, -
1382 Begi, Begi, Begi, NotN, NotN, NotN, NotN, Begi, -
1383// 0x60 (0x61..0x7A are 'a'..'z') -
1384 NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi, -
1385 Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, -
1386// 0x70 -
1387 Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, -
1388 Begi, Begi, Begi, NotN, NotN, NotN, NotN, NotN -
1389}; -
1390 -
1391static inline NameChar fastDetermineNameChar(QChar ch) -
1392{ -
1393 ushort uc = ch.unicode();
executed (the execution status of this line is deduced): ushort uc = ch.unicode();
-
1394 if (!(uc & ~0x7f)) // uc < 128
partially evaluated: !(uc & ~0x7f)
TRUEFALSE
yes
Evaluation Count:1139
no
Evaluation Count:0
0-1139
1395 return static_cast<NameChar>(nameCharTable[uc]);
executed: return static_cast<NameChar>(nameCharTable[uc]);
Execution Count:1139
1139
1396 -
1397 QChar::Category cat = ch.category();
never executed (the execution status of this line is deduced): QChar::Category cat = ch.category();
-
1398 // ### some these categories might be slightly wrong -
1399 if ((cat >= QChar::Letter_Uppercase && cat <= QChar::Letter_Other)
never evaluated: cat >= QChar::Letter_Uppercase
never evaluated: cat <= QChar::Letter_Other
0
1400 || cat == QChar::Number_Letter)
never evaluated: cat == QChar::Number_Letter
0
1401 return NameBeginning;
never executed: return NameBeginning;
0
1402 if ((cat >= QChar::Number_DecimalDigit && cat <= QChar::Number_Other)
never evaluated: cat >= QChar::Number_DecimalDigit
never evaluated: cat <= QChar::Number_Other
0
1403 || (cat >= QChar::Mark_NonSpacing && cat <= QChar::Mark_Enclosing))
never evaluated: cat >= QChar::Mark_NonSpacing
never evaluated: cat <= QChar::Mark_Enclosing
0
1404 return NameNotBeginning;
never executed: return NameNotBeginning;
0
1405 return NotName;
never executed: return NotName;
0
1406} -
1407 -
1408inline int QXmlStreamReaderPrivate::fastScanNMTOKEN() -
1409{ -
1410 int n = 0;
executed (the execution status of this line is deduced): int n = 0;
-
1411 uint c;
executed (the execution status of this line is deduced): uint c;
-
1412 while ((c = getChar())) {
evaluated: (c = getChar())
TRUEFALSE
yes
Evaluation Count:1139
yes
Evaluation Count:229
229-1139
1413 if (fastDetermineNameChar(c) == NotName) {
evaluated: fastDetermineNameChar(c) == NotName
TRUEFALSE
yes
Evaluation Count:190
yes
Evaluation Count:949
190-949
1414 putChar(c);
executed (the execution status of this line is deduced): putChar(c);
-
1415 return n;
executed: return n;
Execution Count:190
190
1416 } else { -
1417 ++n;
executed (the execution status of this line is deduced): ++n;
-
1418 textBuffer += QChar(c);
executed (the execution status of this line is deduced): textBuffer += QChar(c);
-
1419 }
executed: }
Execution Count:949
949
1420 } -
1421 -
1422 int pos = textBuffer.size() - n;
executed (the execution status of this line is deduced): int pos = textBuffer.size() - n;
-
1423 putString(textBuffer, pos);
executed (the execution status of this line is deduced): putString(textBuffer, pos);
-
1424 textBuffer.resize(pos);
executed (the execution status of this line is deduced): textBuffer.resize(pos);
-
1425 -
1426 return n;
executed: return n;
Execution Count:229
229
1427} -
1428 -
1429void QXmlStreamReaderPrivate::putString(const QString &s, int from) -
1430{ -
1431 putStack.reserve(s.size());
executed (the execution status of this line is deduced): putStack.reserve(s.size());
-
1432 for (int i = s.size()-1; i >= from; --i)
evaluated: i >= from
TRUEFALSE
yes
Evaluation Count:205578
yes
Evaluation Count:18911
18911-205578
1433 putStack.rawPush() = s.at(i).unicode();
executed: putStack.rawPush() = s.at(i).unicode();
Execution Count:205578
205578
1434}
executed: }
Execution Count:18911
18911
1435 -
1436void QXmlStreamReaderPrivate::putStringLiteral(const QString &s) -
1437{ -
1438 putStack.reserve(s.size());
executed (the execution status of this line is deduced): putStack.reserve(s.size());
-
1439 for (int i = s.size()-1; i >= 0; --i)
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:1106
yes
Evaluation Count:1093
1093-1106
1440 putStack.rawPush() = ((LETTER << 16) | s.at(i).unicode());
executed: putStack.rawPush() = ((LETTER << 16) | s.at(i).unicode());
Execution Count:1106
1106
1441}
executed: }
Execution Count:1093
1093
1442 -
1443void QXmlStreamReaderPrivate::putReplacement(const QString &s) -
1444{ -
1445 putStack.reserve(s.size());
executed (the execution status of this line is deduced): putStack.reserve(s.size());
-
1446 for (int i = s.size()-1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:1077
yes
Evaluation Count:117
117-1077
1447 ushort c = s.at(i).unicode();
executed (the execution status of this line is deduced): ushort c = s.at(i).unicode();
-
1448 if (c == '\n' || c == '\r')
evaluated: c == '\n'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1075
evaluated: c == '\r'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1073
2-1075
1449 putStack.rawPush() = ((LETTER << 16) | c);
executed: putStack.rawPush() = ((LETTER << 16) | c);
Execution Count:4
4
1450 else -
1451 putStack.rawPush() = c;
executed: putStack.rawPush() = c;
Execution Count:1073
1073
1452 } -
1453}
executed: }
Execution Count:117
117
1454void QXmlStreamReaderPrivate::putReplacementInAttributeValue(const QString &s) -
1455{ -
1456 putStack.reserve(s.size());
executed (the execution status of this line is deduced): putStack.reserve(s.size());
-
1457 for (int i = s.size()-1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:990
yes
Evaluation Count:98
98-990
1458 ushort c = s.at(i).unicode();
executed (the execution status of this line is deduced): ushort c = s.at(i).unicode();
-
1459 if (c == '&' || c == ';')
evaluated: c == '&'
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:941
evaluated: c == ';'
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:881
49-941
1460 putStack.rawPush() = c;
executed: putStack.rawPush() = c;
Execution Count:109
109
1461 else if (c == '\n' || c == '\r')
evaluated: c == '\n'
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:877
evaluated: c == '\r'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:875
2-877
1462 putStack.rawPush() = ' ';
executed: putStack.rawPush() = ' ';
Execution Count:6
6
1463 else -
1464 putStack.rawPush() = ((LETTER << 16) | c);
executed: putStack.rawPush() = ((LETTER << 16) | c);
Execution Count:875
875
1465 } -
1466}
executed: }
Execution Count:98
98
1467 -
1468ushort QXmlStreamReaderPrivate::getChar_helper() -
1469{ -
1470 const int BUFFER_SIZE = 8192;
executed (the execution status of this line is deduced): const int BUFFER_SIZE = 8192;
-
1471 characterOffset += readBufferPos;
executed (the execution status of this line is deduced): characterOffset += readBufferPos;
-
1472 readBufferPos = 0;
executed (the execution status of this line is deduced): readBufferPos = 0;
-
1473 readBuffer.resize(0);
executed (the execution status of this line is deduced): readBuffer.resize(0);
-
1474#ifndef QT_NO_TEXTCODEC -
1475 if (decoder)
evaluated: decoder
TRUEFALSE
yes
Evaluation Count:114654
yes
Evaluation Count:5228
5228-114654
1476#endif -
1477 nbytesread = 0;
executed: nbytesread = 0;
Execution Count:114654
114654
1478 if (device) {
evaluated: device
TRUEFALSE
yes
Evaluation Count:2257
yes
Evaluation Count:117625
2257-117625
1479 rawReadBuffer.resize(BUFFER_SIZE);
executed (the execution status of this line is deduced): rawReadBuffer.resize(BUFFER_SIZE);
-
1480 int nbytesreadOrMinus1 = device->read(rawReadBuffer.data() + nbytesread, BUFFER_SIZE - nbytesread);
executed (the execution status of this line is deduced): int nbytesreadOrMinus1 = device->read(rawReadBuffer.data() + nbytesread, BUFFER_SIZE - nbytesread);
-
1481 nbytesread += qMax(nbytesreadOrMinus1, 0);
executed (the execution status of this line is deduced): nbytesread += qMax(nbytesreadOrMinus1, 0);
-
1482 } else {
executed: }
Execution Count:2257
2257
1483 if (nbytesread)
evaluated: nbytesread
TRUEFALSE
yes
Evaluation Count:780
yes
Evaluation Count:116845
780-116845
1484 rawReadBuffer += dataBuffer;
executed: rawReadBuffer += dataBuffer;
Execution Count:780
780
1485 else -
1486 rawReadBuffer = dataBuffer;
executed: rawReadBuffer = dataBuffer;
Execution Count:116845
116845
1487 nbytesread = rawReadBuffer.size();
executed (the execution status of this line is deduced): nbytesread = rawReadBuffer.size();
-
1488 dataBuffer.clear();
executed (the execution status of this line is deduced): dataBuffer.clear();
-
1489 }
executed: }
Execution Count:117625
117625
1490 if (!nbytesread) {
evaluated: !nbytesread
TRUEFALSE
yes
Evaluation Count:59602
yes
Evaluation Count:60280
59602-60280
1491 atEnd = true;
executed (the execution status of this line is deduced): atEnd = true;
-
1492 return 0;
executed: return 0;
Execution Count:59602
59602
1493 } -
1494 -
1495#ifndef QT_NO_TEXTCODEC -
1496 if (!decoder) {
evaluated: !decoder
TRUEFALSE
yes
Evaluation Count:3590
yes
Evaluation Count:56690
3590-56690
1497 if (nbytesread < 4) { // the 4 is to cover 0xef 0xbb 0xbf plus
evaluated: nbytesread < 4
TRUEFALSE
yes
Evaluation Count:780
yes
Evaluation Count:2810
780-2810
1498 // one extra for the utf8 codec -
1499 atEnd = true;
executed (the execution status of this line is deduced): atEnd = true;
-
1500 return 0;
executed: return 0;
Execution Count:780
780
1501 } -
1502 int mib = 106; // UTF-8
executed (the execution status of this line is deduced): int mib = 106;
-
1503 -
1504 // look for byte order mark -
1505 uchar ch1 = rawReadBuffer.at(0);
executed (the execution status of this line is deduced): uchar ch1 = rawReadBuffer.at(0);
-
1506 uchar ch2 = rawReadBuffer.at(1);
executed (the execution status of this line is deduced): uchar ch2 = rawReadBuffer.at(1);
-
1507 uchar ch3 = rawReadBuffer.at(2);
executed (the execution status of this line is deduced): uchar ch3 = rawReadBuffer.at(2);
-
1508 uchar ch4 = rawReadBuffer.at(3);
executed (the execution status of this line is deduced): uchar ch4 = rawReadBuffer.at(3);
-
1509 -
1510 if ((ch1 == 0 && ch2 == 0 && ch3 == 0xfe && ch4 == 0xff) ||
evaluated: ch1 == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2809
partially evaluated: ch2 == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: ch3 == 0xfe
never evaluated: ch4 == 0xff
0-2809
1511 (ch1 == 0xff && ch2 == 0xfe && ch3 == 0 && ch4 == 0))
evaluated: ch1 == 0xff
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:2770
partially evaluated: ch2 == 0xfe
TRUEFALSE
yes
Evaluation Count:40
no
Evaluation Count:0
partially evaluated: ch3 == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
never evaluated: ch4 == 0
0-2770
1512 mib = 1017; // UTF-32 with byte order mark
never executed: mib = 1017;
0
1513 else if (ch1 == 0x3c && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x00)
evaluated: ch1 == 0x3c
TRUEFALSE
yes
Evaluation Count:2732
yes
Evaluation Count:78
partially evaluated: ch2 == 0x00
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2732
never evaluated: ch3 == 0x00
never evaluated: ch4 == 0x00
0-2732
1514 mib = 1019; // UTF-32LE
never executed: mib = 1019;
0
1515 else if (ch1 == 0x00 && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x3c)
evaluated: ch1 == 0x00
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2809
partially evaluated: ch2 == 0x00
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: ch3 == 0x00
never evaluated: ch4 == 0x3c
0-2809
1516 mib = 1018; // UTF-32BE
never executed: mib = 1018;
0
1517 else if ((ch1 == 0xfe && ch2 == 0xff) || (ch1 == 0xff && ch2 == 0xfe))
evaluated: ch1 == 0xfe
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2809
partially evaluated: ch2 == 0xff
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
evaluated: ch1 == 0xff
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:2769
partially evaluated: ch2 == 0xfe
TRUEFALSE
yes
Evaluation Count:40
no
Evaluation Count:0
0-2809
1518 mib = 1015; // UTF-16 with byte order mark
executed: mib = 1015;
Execution Count:41
41
1519 else if (ch1 == 0x3c && ch2 == 0x00)
evaluated: ch1 == 0x3c
TRUEFALSE
yes
Evaluation Count:2732
yes
Evaluation Count:37
partially evaluated: ch2 == 0x00
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2732
0-2732
1520 mib = 1014; // UTF-16LE
never executed: mib = 1014;
0
1521 else if (ch1 == 0x00 && ch2 == 0x3c)
evaluated: ch1 == 0x00
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2768
partially evaluated: ch2 == 0x3c
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-2768
1522 mib = 1013; // UTF-16BE
executed: mib = 1013;
Execution Count:1
1
1523 codec = QTextCodec::codecForMib(mib);
executed (the execution status of this line is deduced): codec = QTextCodec::codecForMib(mib);
-
1524 Q_ASSERT(codec);
executed (the execution status of this line is deduced): qt_noop();
-
1525 decoder = codec->makeDecoder();
executed (the execution status of this line is deduced): decoder = codec->makeDecoder();
-
1526 }
executed: }
Execution Count:2810
2810
1527 -
1528 decoder->toUnicode(&readBuffer, rawReadBuffer.constData(), nbytesread);
executed (the execution status of this line is deduced): decoder->toUnicode(&readBuffer, rawReadBuffer.constData(), nbytesread);
-
1529 -
1530 if(lockEncoding && decoder->hasFailure()) {
evaluated: lockEncoding
TRUEFALSE
yes
Evaluation Count:54038
yes
Evaluation Count:5462
partially evaluated: decoder->hasFailure()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:54038
0-54038
1531 raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content."));
never executed (the execution status of this line is deduced): raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content."));
-
1532 readBuffer.clear();
never executed (the execution status of this line is deduced): readBuffer.clear();
-
1533 return 0;
never executed: return 0;
0
1534 } -
1535#else -
1536 readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread); -
1537#endif // QT_NO_TEXTCODEC -
1538 -
1539 readBuffer.reserve(1); // keep capacity when calling resize() next time
executed (the execution status of this line is deduced): readBuffer.reserve(1);
-
1540 -
1541 if (readBufferPos < readBuffer.size()) {
evaluated: readBufferPos < readBuffer.size()
TRUEFALSE
yes
Evaluation Count:59257
yes
Evaluation Count:243
243-59257
1542 ushort c = readBuffer.at(readBufferPos++).unicode();
executed (the execution status of this line is deduced): ushort c = readBuffer.at(readBufferPos++).unicode();
-
1543 return c;
executed: return c;
Execution Count:59257
59257
1544 } -
1545 -
1546 atEnd = true;
executed (the execution status of this line is deduced): atEnd = true;
-
1547 return 0;
executed: return 0;
Execution Count:243
243
1548} -
1549 -
1550QStringRef QXmlStreamReaderPrivate::namespaceForPrefix(const QStringRef &prefix) -
1551{ -
1552 for (int j = namespaceDeclarations.size() - 1; j >= 0; --j) {
evaluated: j >= 0
TRUEFALSE
yes
Evaluation Count:75420
yes
Evaluation Count:72129
72129-75420
1553 const NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(j);
executed (the execution status of this line is deduced): const NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(j);
-
1554 if (namespaceDeclaration.prefix == prefix) {
evaluated: namespaceDeclaration.prefix == prefix
TRUEFALSE
yes
Evaluation Count:1851
yes
Evaluation Count:73569
1851-73569
1555 return namespaceDeclaration.namespaceUri;
executed: return namespaceDeclaration.namespaceUri;
Execution Count:1851
1851
1556 } -
1557 }
executed: }
Execution Count:73569
73569
1558 -
1559#if 1 -
1560 if (namespaceProcessing && !prefix.isEmpty())
partially evaluated: namespaceProcessing
TRUEFALSE
yes
Evaluation Count:72129
no
Evaluation Count:0
evaluated: !prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:72123
0-72129
1561 raiseWellFormedError(QXmlStream::tr("Namespace prefix '%1' not declared").arg(prefix.toString()));
executed: raiseWellFormedError(QXmlStream::tr("Namespace prefix '%1' not declared").arg(prefix.toString()));
Execution Count:6
6
1562#endif -
1563 -
1564 return QStringRef();
executed: return QStringRef();
Execution Count:72129
72129
1565} -
1566 -
1567/* -
1568 uses namespaceForPrefix and builds the attribute vector -
1569 */ -
1570void QXmlStreamReaderPrivate::resolveTag() -
1571{ -
1572 int n = attributeStack.size();
executed (the execution status of this line is deduced): int n = attributeStack.size();
-
1573 -
1574 if (namespaceProcessing) {
partially evaluated: namespaceProcessing
TRUEFALSE
yes
Evaluation Count:73241
no
Evaluation Count:0
0-73241
1575 for (int a = 0; a < dtdAttributes.size(); ++a) {
evaluated: a < dtdAttributes.size()
TRUEFALSE
yes
Evaluation Count:1672
yes
Evaluation Count:73241
1672-73241
1576 DtdAttribute &dtdAttribute = dtdAttributes[a];
executed (the execution status of this line is deduced): DtdAttribute &dtdAttribute = dtdAttributes[a];
-
1577 if (!dtdAttribute.isNamespaceAttribute
evaluated: !dtdAttribute.isNamespaceAttribute
TRUEFALSE
yes
Evaluation Count:1248
yes
Evaluation Count:424
424-1248
1578 || dtdAttribute.defaultValue.isNull()
evaluated: dtdAttribute.defaultValue.isNull()
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:333
91-333
1579 || dtdAttribute.tagName != qualifiedName
evaluated: dtdAttribute.tagName != qualifiedName
TRUEFALSE
yes
Evaluation Count:329
yes
Evaluation Count:4
4-329
1580 || dtdAttribute.attributeQualifiedName.isNull())
partially evaluated: dtdAttribute.attributeQualifiedName.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1581 continue;
executed: continue;
Execution Count:1668
1668
1582 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
1583 while (i < n && symName(attributeStack[i].key) != dtdAttribute.attributeQualifiedName)
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
partially evaluated: symName(attributeStack[i].key) != dtdAttribute.attributeQualifiedName
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-4
1584 ++i;
executed: ++i;
Execution Count:3
3
1585 if (i != n)
partially evaluated: i != n
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1586 continue;
never executed: continue;
0
1587 if (dtdAttribute.attributePrefix.isEmpty() && dtdAttribute.attributeName == QLatin1String("xmlns")) {
evaluated: dtdAttribute.attributePrefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
partially evaluated: dtdAttribute.attributeName == QLatin1String("xmlns")
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1588 NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
executed (the execution status of this line is deduced): NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
-
1589 namespaceDeclaration.prefix.clear();
executed (the execution status of this line is deduced): namespaceDeclaration.prefix.clear();
-
1590 -
1591 const QStringRef ns(dtdAttribute.defaultValue);
executed (the execution status of this line is deduced): const QStringRef ns(dtdAttribute.defaultValue);
-
1592 if(ns == QLatin1String("http://www.w3.org/2000/xmlns/") ||
partially evaluated: ns == QLatin1String("http://www.w3.org/2000/xmlns/")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1593 ns == QLatin1String("http://www.w3.org/XML/1998/namespace"))
partially evaluated: ns == QLatin1String("http://www.w3.org/XML/1998/namespace")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1594 raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
never executed: raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
0
1595 else -
1596 namespaceDeclaration.namespaceUri = ns;
executed: namespaceDeclaration.namespaceUri = ns;
Execution Count:2
2
1597 } else if (dtdAttribute.attributePrefix == QLatin1String("xmlns")) {
partially evaluated: dtdAttribute.attributePrefix == QLatin1String("xmlns")
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1598 NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
executed (the execution status of this line is deduced): NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
-
1599 QStringRef namespacePrefix = dtdAttribute.attributeName;
executed (the execution status of this line is deduced): QStringRef namespacePrefix = dtdAttribute.attributeName;
-
1600 QStringRef namespaceUri = dtdAttribute.defaultValue;
executed (the execution status of this line is deduced): QStringRef namespaceUri = dtdAttribute.defaultValue;
-
1601 if (((namespacePrefix == QLatin1String("xml"))
partially evaluated: ((namespacePrefix == QLatin1String("xml")) ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1602 ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))
partially evaluated: ((namespacePrefix == QLatin1String("xml")) ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1603 || namespaceUri == QLatin1String("http://www.w3.org/2000/xmlns/")
partially evaluated: namespaceUri == QLatin1String("http://www.w3.org/2000/xmlns/")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1604 || namespaceUri.isEmpty()
partially evaluated: namespaceUri.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1605 || namespacePrefix == QLatin1String("xmlns"))
partially evaluated: namespacePrefix == QLatin1String("xmlns")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1606 raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
never executed: raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
0
1607 -
1608 namespaceDeclaration.prefix = namespacePrefix;
executed (the execution status of this line is deduced): namespaceDeclaration.prefix = namespacePrefix;
-
1609 namespaceDeclaration.namespaceUri = namespaceUri;
executed (the execution status of this line is deduced): namespaceDeclaration.namespaceUri = namespaceUri;
-
1610 }
executed: }
Execution Count:2
2
1611 } -
1612 }
executed: }
Execution Count:73241
73241
1613 -
1614 tagStack.top().namespaceDeclaration.namespaceUri = namespaceUri = namespaceForPrefix(prefix);
executed (the execution status of this line is deduced): tagStack.top().namespaceDeclaration.namespaceUri = namespaceUri = namespaceForPrefix(prefix);
-
1615 -
1616 attributes.resize(n);
executed (the execution status of this line is deduced): attributes.resize(n);
-
1617 -
1618 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:105034
yes
Evaluation Count:73241
73241-105034
1619 QXmlStreamAttribute &attribute = attributes[i];
executed (the execution status of this line is deduced): QXmlStreamAttribute &attribute = attributes[i];
-
1620 Attribute &attrib = attributeStack[i];
executed (the execution status of this line is deduced): Attribute &attrib = attributeStack[i];
-
1621 QStringRef prefix(symPrefix(attrib.key));
executed (the execution status of this line is deduced): QStringRef prefix(symPrefix(attrib.key));
-
1622 QStringRef name(symString(attrib.key));
executed (the execution status of this line is deduced): QStringRef name(symString(attrib.key));
-
1623 QStringRef qualifiedName(symName(attrib.key));
executed (the execution status of this line is deduced): QStringRef qualifiedName(symName(attrib.key));
-
1624 QStringRef value(symString(attrib.value));
executed (the execution status of this line is deduced): QStringRef value(symString(attrib.value));
-
1625 -
1626 attribute.m_name = QXmlStreamStringRef(name);
executed (the execution status of this line is deduced): attribute.m_name = QXmlStreamStringRef(name);
-
1627 attribute.m_qualifiedName = QXmlStreamStringRef(qualifiedName);
executed (the execution status of this line is deduced): attribute.m_qualifiedName = QXmlStreamStringRef(qualifiedName);
-
1628 attribute.m_value = QXmlStreamStringRef(value);
executed (the execution status of this line is deduced): attribute.m_value = QXmlStreamStringRef(value);
-
1629 -
1630 if (!prefix.isEmpty()) {
evaluated: !prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:739
yes
Evaluation Count:104295
739-104295
1631 QStringRef attributeNamespaceUri = namespaceForPrefix(prefix);
executed (the execution status of this line is deduced): QStringRef attributeNamespaceUri = namespaceForPrefix(prefix);
-
1632 attribute.m_namespaceUri = QXmlStreamStringRef(attributeNamespaceUri);
executed (the execution status of this line is deduced): attribute.m_namespaceUri = QXmlStreamStringRef(attributeNamespaceUri);
-
1633 }
executed: }
Execution Count:739
739
1634 -
1635 for (int j = 0; j < i; ++j) {
evaluated: j < i
TRUEFALSE
yes
Evaluation Count:97857
yes
Evaluation Count:105034
97857-105034
1636 if (attributes[j].name() == attribute.name()
evaluated: attributes[j].name() == attribute.name()
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:97819
38-97819
1637 && attributes[j].namespaceUri() == attribute.namespaceUri()
evaluated: attributes[j].namespaceUri() == attribute.namespaceUri()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:22
16-22
1638 && (namespaceProcessing || attributes[j].qualifiedName() == attribute.qualifiedName()))
partially evaluated: namespaceProcessing
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
never evaluated: attributes[j].qualifiedName() == attribute.qualifiedName()
0-16
1639 raiseWellFormedError(QXmlStream::tr("Attribute redefined."));
executed: raiseWellFormedError(QXmlStream::tr("Attribute redefined."));
Execution Count:16
16
1640 }
executed: }
Execution Count:97857
97857
1641 }
executed: }
Execution Count:105034
105034
1642 -
1643 for (int a = 0; a < dtdAttributes.size(); ++a) {
evaluated: a < dtdAttributes.size()
TRUEFALSE
yes
Evaluation Count:1672
yes
Evaluation Count:73241
1672-73241
1644 DtdAttribute &dtdAttribute = dtdAttributes[a];
executed (the execution status of this line is deduced): DtdAttribute &dtdAttribute = dtdAttributes[a];
-
1645 if (dtdAttribute.isNamespaceAttribute
evaluated: dtdAttribute.isNamespaceAttribute
TRUEFALSE
yes
Evaluation Count:424
yes
Evaluation Count:1248
424-1248
1646 || dtdAttribute.defaultValue.isNull()
evaluated: dtdAttribute.defaultValue.isNull()
TRUEFALSE
yes
Evaluation Count:1080
yes
Evaluation Count:168
168-1080
1647 || dtdAttribute.tagName != qualifiedName
evaluated: dtdAttribute.tagName != qualifiedName
TRUEFALSE
yes
Evaluation Count:75
yes
Evaluation Count:93
75-93
1648 || dtdAttribute.attributeQualifiedName.isNull())
evaluated: dtdAttribute.attributeQualifiedName.isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:91
2-91
1649 continue;
executed: continue;
Execution Count:1581
1581
1650 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
1651 while (i < n && symName(attributeStack[i].key) != dtdAttribute.attributeQualifiedName)
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:36
evaluated: symName(attributeStack[i].key) != dtdAttribute.attributeQualifiedName
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:55
36-117
1652 ++i;
executed: ++i;
Execution Count:62
62
1653 if (i != n)
evaluated: i != n
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:36
36-55
1654 continue;
executed: continue;
Execution Count:55
55
1655 -
1656 -
1657 -
1658 QXmlStreamAttribute attribute;
executed (the execution status of this line is deduced): QXmlStreamAttribute attribute;
-
1659 attribute.m_name = QXmlStreamStringRef(dtdAttribute.attributeName);
executed (the execution status of this line is deduced): attribute.m_name = QXmlStreamStringRef(dtdAttribute.attributeName);
-
1660 attribute.m_qualifiedName = QXmlStreamStringRef(dtdAttribute.attributeQualifiedName);
executed (the execution status of this line is deduced): attribute.m_qualifiedName = QXmlStreamStringRef(dtdAttribute.attributeQualifiedName);
-
1661 attribute.m_value = QXmlStreamStringRef(dtdAttribute.defaultValue);
executed (the execution status of this line is deduced): attribute.m_value = QXmlStreamStringRef(dtdAttribute.defaultValue);
-
1662 -
1663 if (!dtdAttribute.attributePrefix.isEmpty()) {
partially evaluated: !dtdAttribute.attributePrefix.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:36
0-36
1664 QStringRef attributeNamespaceUri = namespaceForPrefix(dtdAttribute.attributePrefix);
never executed (the execution status of this line is deduced): QStringRef attributeNamespaceUri = namespaceForPrefix(dtdAttribute.attributePrefix);
-
1665 attribute.m_namespaceUri = QXmlStreamStringRef(attributeNamespaceUri);
never executed (the execution status of this line is deduced): attribute.m_namespaceUri = QXmlStreamStringRef(attributeNamespaceUri);
-
1666 }
never executed: }
0
1667 attribute.m_isDefault = true;
executed (the execution status of this line is deduced): attribute.m_isDefault = true;
-
1668 attributes.append(attribute);
executed (the execution status of this line is deduced): attributes.append(attribute);
-
1669 }
executed: }
Execution Count:36
36
1670 -
1671 attributeStack.clear();
executed (the execution status of this line is deduced): attributeStack.clear();
-
1672}
executed: }
Execution Count:73241
73241
1673 -
1674void QXmlStreamReaderPrivate::resolvePublicNamespaces() -
1675{ -
1676 const Tag &tag = tagStack.top();
executed (the execution status of this line is deduced): const Tag &tag = tagStack.top();
-
1677 int n = namespaceDeclarations.size() - tag.namespaceDeclarationsSize;
executed (the execution status of this line is deduced): int n = namespaceDeclarations.size() - tag.namespaceDeclarationsSize;
-
1678 publicNamespaceDeclarations.resize(n);
executed (the execution status of this line is deduced): publicNamespaceDeclarations.resize(n);
-
1679 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:446
54-446
1680 const NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(tag.namespaceDeclarationsSize + i);
executed (the execution status of this line is deduced): const NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(tag.namespaceDeclarationsSize + i);
-
1681 QXmlStreamNamespaceDeclaration &publicNamespaceDeclaration = publicNamespaceDeclarations[i];
executed (the execution status of this line is deduced): QXmlStreamNamespaceDeclaration &publicNamespaceDeclaration = publicNamespaceDeclarations[i];
-
1682 publicNamespaceDeclaration.m_prefix = QXmlStreamStringRef(namespaceDeclaration.prefix);
executed (the execution status of this line is deduced): publicNamespaceDeclaration.m_prefix = QXmlStreamStringRef(namespaceDeclaration.prefix);
-
1683 publicNamespaceDeclaration.m_namespaceUri = QXmlStreamStringRef(namespaceDeclaration.namespaceUri);
executed (the execution status of this line is deduced): publicNamespaceDeclaration.m_namespaceUri = QXmlStreamStringRef(namespaceDeclaration.namespaceUri);
-
1684 }
executed: }
Execution Count:54
54
1685}
executed: }
Execution Count:446
446
1686 -
1687void QXmlStreamReaderPrivate::resolveDtd() -
1688{ -
1689 publicNotationDeclarations.resize(notationDeclarations.size());
executed (the execution status of this line is deduced): publicNotationDeclarations.resize(notationDeclarations.size());
-
1690 for (int i = 0; i < notationDeclarations.size(); ++i) {
evaluated: i < notationDeclarations.size()
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:52
52-79
1691 const QXmlStreamReaderPrivate::NotationDeclaration &notationDeclaration = notationDeclarations.at(i);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate::NotationDeclaration &notationDeclaration = notationDeclarations.at(i);
-
1692 QXmlStreamNotationDeclaration &publicNotationDeclaration = publicNotationDeclarations[i];
executed (the execution status of this line is deduced): QXmlStreamNotationDeclaration &publicNotationDeclaration = publicNotationDeclarations[i];
-
1693 publicNotationDeclaration.m_name = QXmlStreamStringRef(notationDeclaration.name);
executed (the execution status of this line is deduced): publicNotationDeclaration.m_name = QXmlStreamStringRef(notationDeclaration.name);
-
1694 publicNotationDeclaration.m_systemId = QXmlStreamStringRef(notationDeclaration.systemId);
executed (the execution status of this line is deduced): publicNotationDeclaration.m_systemId = QXmlStreamStringRef(notationDeclaration.systemId);
-
1695 publicNotationDeclaration.m_publicId = QXmlStreamStringRef(notationDeclaration.publicId);
executed (the execution status of this line is deduced): publicNotationDeclaration.m_publicId = QXmlStreamStringRef(notationDeclaration.publicId);
-
1696 -
1697 }
executed: }
Execution Count:79
79
1698 notationDeclarations.clear();
executed (the execution status of this line is deduced): notationDeclarations.clear();
-
1699 publicEntityDeclarations.resize(entityDeclarations.size());
executed (the execution status of this line is deduced): publicEntityDeclarations.resize(entityDeclarations.size());
-
1700 for (int i = 0; i < entityDeclarations.size(); ++i) {
evaluated: i < entityDeclarations.size()
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:52
44-52
1701 const QXmlStreamReaderPrivate::EntityDeclaration &entityDeclaration = entityDeclarations.at(i);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate::EntityDeclaration &entityDeclaration = entityDeclarations.at(i);
-
1702 QXmlStreamEntityDeclaration &publicEntityDeclaration = publicEntityDeclarations[i];
executed (the execution status of this line is deduced): QXmlStreamEntityDeclaration &publicEntityDeclaration = publicEntityDeclarations[i];
-
1703 publicEntityDeclaration.m_name = QXmlStreamStringRef(entityDeclaration.name);
executed (the execution status of this line is deduced): publicEntityDeclaration.m_name = QXmlStreamStringRef(entityDeclaration.name);
-
1704 publicEntityDeclaration.m_notationName = QXmlStreamStringRef(entityDeclaration.notationName);
executed (the execution status of this line is deduced): publicEntityDeclaration.m_notationName = QXmlStreamStringRef(entityDeclaration.notationName);
-
1705 publicEntityDeclaration.m_systemId = QXmlStreamStringRef(entityDeclaration.systemId);
executed (the execution status of this line is deduced): publicEntityDeclaration.m_systemId = QXmlStreamStringRef(entityDeclaration.systemId);
-
1706 publicEntityDeclaration.m_publicId = QXmlStreamStringRef(entityDeclaration.publicId);
executed (the execution status of this line is deduced): publicEntityDeclaration.m_publicId = QXmlStreamStringRef(entityDeclaration.publicId);
-
1707 publicEntityDeclaration.m_value = QXmlStreamStringRef(entityDeclaration.value);
executed (the execution status of this line is deduced): publicEntityDeclaration.m_value = QXmlStreamStringRef(entityDeclaration.value);
-
1708 }
executed: }
Execution Count:44
44
1709 entityDeclarations.clear();
executed (the execution status of this line is deduced): entityDeclarations.clear();
-
1710 parameterEntityHash.clear();
executed (the execution status of this line is deduced): parameterEntityHash.clear();
-
1711}
executed: }
Execution Count:52
52
1712 -
1713uint QXmlStreamReaderPrivate::resolveCharRef(int symbolIndex) -
1714{ -
1715 bool ok = true;
executed (the execution status of this line is deduced): bool ok = true;
-
1716 uint s;
executed (the execution status of this line is deduced): uint s;
-
1717 // ### add toXShort to QStringRef? -
1718 if (sym(symbolIndex).c == 'x')
evaluated: sym(symbolIndex).c == 'x'
TRUEFALSE
yes
Evaluation Count:98
yes
Evaluation Count:138
98-138
1719 s = symString(symbolIndex, 1).toString().toUInt(&ok, 16);
executed: s = symString(symbolIndex, 1).toString().toUInt(&ok, 16);
Execution Count:98
98
1720 else -
1721 s = symString(symbolIndex).toString().toUInt(&ok, 10);
executed: s = symString(symbolIndex).toString().toUInt(&ok, 10);
Execution Count:138
138
1722 -
1723 ok &= (s == 0x9 || s == 0xa || s == 0xd || (s >= 0x20 && s <= 0xd7ff)
evaluated: s == 0x9
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:222
evaluated: s == 0xa
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:204
evaluated: s == 0xd
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:191
evaluated: s >= 0x20
TRUEFALSE
yes
Evaluation Count:178
yes
Evaluation Count:13
evaluated: s <= 0xd7ff
TRUEFALSE
yes
Evaluation Count:155
yes
Evaluation Count:23
13-222
1724 || (s >= 0xe000 && s <= 0xfffd) || (s >= 0x10000 && s <= QChar::LastValidCodePoint));
evaluated: s >= 0xe000
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:15
evaluated: s <= 0xfffd
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:17
evaluated: s >= 0x10000
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:18
evaluated: s <= QChar::LastValidCodePoint
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:1
1-21
1725 -
1726 return ok ? s : 0;
executed: return ok ? s : 0;
Execution Count:236
236
1727} -
1728 -
1729 -
1730void QXmlStreamReaderPrivate::checkPublicLiteral(const QStringRef &publicId) -
1731{ -
1732//#x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] -
1733 -
1734 const ushort *data = reinterpret_cast<const ushort *>(publicId.constData());
executed (the execution status of this line is deduced): const ushort *data = reinterpret_cast<const ushort *>(publicId.constData());
-
1735 uchar c = 0;
executed (the execution status of this line is deduced): uchar c = 0;
-
1736 int i;
executed (the execution status of this line is deduced): int i;
-
1737 for (i = publicId.size() - 1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:7246
yes
Evaluation Count:172
172-7246
1738 if (data[i] < 256)
partially evaluated: data[i] < 256
TRUEFALSE
yes
Evaluation Count:7246
no
Evaluation Count:0
0-7246
1739 switch ((c = data[i])) { -
1740 case ' ': case '\n': case '\r': case '-': case '(': case ')': -
1741 case '+': case ',': case '.': case '/': case ':': case '=': -
1742 case '?': case ';': case '!': case '*': case '#': case '@': -
1743 case '$': case '_': case '%': case '\'': case '\"': -
1744 continue;
executed: continue;
Execution Count:1746
1746
1745 default: -
1746 if ((c >= 'a' && c <= 'z')
evaluated: c >= 'a'
TRUEFALSE
yes
Evaluation Count:3798
yes
Evaluation Count:1702
partially evaluated: c <= 'z'
TRUEFALSE
yes
Evaluation Count:3798
no
Evaluation Count:0
0-3798
1747 || (c >= 'A' && c <= 'Z')
evaluated: c >= 'A'
TRUEFALSE
yes
Evaluation Count:1429
yes
Evaluation Count:273
partially evaluated: c <= 'Z'
TRUEFALSE
yes
Evaluation Count:1429
no
Evaluation Count:0
0-1429
1748 || (c >= '0' && c <= '9'))
partially evaluated: c >= '0'
TRUEFALSE
yes
Evaluation Count:273
no
Evaluation Count:0
partially evaluated: c <= '9'
TRUEFALSE
yes
Evaluation Count:273
no
Evaluation Count:0
0-273
1749 continue;
executed: continue;
Execution Count:5500
5500
1750 }
never executed: }
0
1751 break;
never executed: break;
0
1752 } -
1753 if (i >= 0)
partially evaluated: i >= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:172
0-172
1754 raiseWellFormedError(QXmlStream::tr("Unexpected character '%1' in public id literal.").arg(QChar(QLatin1Char(c))));
never executed: raiseWellFormedError(QXmlStream::tr("Unexpected character '%1' in public id literal.").arg(QChar(QLatin1Char(c))));
0
1755}
executed: }
Execution Count:172
172
1756 -
1757/* -
1758 Checks whether the document starts with an xml declaration. If it -
1759 does, this function returns true; otherwise it sets up everything -
1760 for a synthetic start document event and returns false. -
1761 */ -
1762bool QXmlStreamReaderPrivate::checkStartDocument() -
1763{ -
1764 hasCheckedStartDocument = true;
executed (the execution status of this line is deduced): hasCheckedStartDocument = true;
-
1765 -
1766 if (scanString(spell[XML], XML))
evaluated: scanString(spell[XML], XML)
TRUEFALSE
yes
Evaluation Count:1091
yes
Evaluation Count:4651
1091-4651
1767 return true;
executed: return true;
Execution Count:1091
1091
1768 -
1769 type = QXmlStreamReader::StartDocument;
executed (the execution status of this line is deduced): type = QXmlStreamReader::StartDocument;
-
1770 if (atEnd) {
evaluated: atEnd
TRUEFALSE
yes
Evaluation Count:2683
yes
Evaluation Count:1968
1968-2683
1771 hasCheckedStartDocument = false;
executed (the execution status of this line is deduced): hasCheckedStartDocument = false;
-
1772 raiseError(QXmlStreamReader::PrematureEndOfDocumentError);
executed (the execution status of this line is deduced): raiseError(QXmlStreamReader::PrematureEndOfDocumentError);
-
1773 }
executed: }
Execution Count:2683
2683
1774 return false;
executed: return false;
Execution Count:4651
4651
1775} -
1776 -
1777void QXmlStreamReaderPrivate::startDocument() -
1778{ -
1779 QString err;
executed (the execution status of this line is deduced): QString err;
-
1780 if (documentVersion != QLatin1String("1.0")) {
evaluated: documentVersion != QLatin1String("1.0")
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1047
4-1047
1781 if (documentVersion.toString().contains(QLatin1Char(' ')))
evaluated: documentVersion.toString().contains(QLatin1Char(' '))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
1782 err = QXmlStream::tr("Invalid XML version string.");
executed: err = QXmlStream::tr("Invalid XML version string.");
Execution Count:1
1
1783 else -
1784 err = QXmlStream::tr("Unsupported XML version.");
executed: err = QXmlStream::tr("Unsupported XML version.");
Execution Count:3
3
1785 } -
1786 int n = attributeStack.size();
executed (the execution status of this line is deduced): int n = attributeStack.size();
-
1787 -
1788 /* We use this bool to ensure that the pesudo attributes are in the -
1789 * proper order: -
1790 * -
1791 * [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>' */ -
1792 bool hasStandalone = false;
executed (the execution status of this line is deduced): bool hasStandalone = false;
-
1793 -
1794 for (int i = 0; err.isNull() && i < n; ++i) {
evaluated: err.isNull()
TRUEFALSE
yes
Evaluation Count:1527
yes
Evaluation Count:31
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:507
yes
Evaluation Count:1020
31-1527
1795 Attribute &attrib = attributeStack[i];
executed (the execution status of this line is deduced): Attribute &attrib = attributeStack[i];
-
1796 QStringRef prefix(symPrefix(attrib.key));
executed (the execution status of this line is deduced): QStringRef prefix(symPrefix(attrib.key));
-
1797 QStringRef key(symString(attrib.key));
executed (the execution status of this line is deduced): QStringRef key(symString(attrib.key));
-
1798 QStringRef value(symString(attrib.value));
executed (the execution status of this line is deduced): QStringRef value(symString(attrib.value));
-
1799 -
1800 if (prefix.isEmpty() && key == QLatin1String("encoding")) {
partially evaluated: prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:507
no
Evaluation Count:0
evaluated: key == QLatin1String("encoding")
TRUEFALSE
yes
Evaluation Count:474
yes
Evaluation Count:33
0-507
1801 const QString name(value.toString());
executed (the execution status of this line is deduced): const QString name(value.toString());
-
1802 documentEncoding = value;
executed (the execution status of this line is deduced): documentEncoding = value;
-
1803 -
1804 if(hasStandalone)
evaluated: hasStandalone
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:473
1-473
1805 err = QXmlStream::tr("The standalone pseudo attribute must appear after the encoding.");
executed: err = QXmlStream::tr("The standalone pseudo attribute must appear after the encoding.");
Execution Count:1
1
1806 if(!QXmlUtils::isEncName(name))
evaluated: !QXmlUtils::isEncName(name)
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:458
16-458
1807 err = QXmlStream::tr("%1 is an invalid encoding name.").arg(name);
executed: err = QXmlStream::tr("%1 is an invalid encoding name.").arg(name);
Execution Count:16
16
1808 else { -
1809#ifdef QT_NO_TEXTCODEC -
1810 readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread); -
1811#else -
1812 QTextCodec *const newCodec = QTextCodec::codecForName(name.toLatin1());
executed (the execution status of this line is deduced): QTextCodec *const newCodec = QTextCodec::codecForName(name.toLatin1());
-
1813 if (!newCodec)
partially evaluated: !newCodec
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:458
0-458
1814 err = QXmlStream::tr("Encoding %1 is unsupported").arg(name);
never executed: err = QXmlStream::tr("Encoding %1 is unsupported").arg(name);
0
1815 else if (newCodec != codec && !lockEncoding) {
evaluated: newCodec != codec
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:454
partially evaluated: !lockEncoding
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-454
1816 codec = newCodec;
executed (the execution status of this line is deduced): codec = newCodec;
-
1817 delete decoder;
executed (the execution status of this line is deduced): delete decoder;
-
1818 decoder = codec->makeDecoder();
executed (the execution status of this line is deduced): decoder = codec->makeDecoder();
-
1819 decoder->toUnicode(&readBuffer, rawReadBuffer.data(), nbytesread);
executed (the execution status of this line is deduced): decoder->toUnicode(&readBuffer, rawReadBuffer.data(), nbytesread);
-
1820 }
executed: }
Execution Count:4
4
1821#endif // QT_NO_TEXTCODEC -
1822 } -
1823 } else if (prefix.isEmpty() && key == QLatin1String("standalone")) {
partially evaluated: prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:33
no
Evaluation Count:0
evaluated: key == QLatin1String("standalone")
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:4
0-33
1824 hasStandalone = true;
executed (the execution status of this line is deduced): hasStandalone = true;
-
1825 if (value == QLatin1String("yes"))
evaluated: value == QLatin1String("yes")
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:8
8-21
1826 standalone = true;
executed: standalone = true;
Execution Count:21
21
1827 else if (value == QLatin1String("no"))
evaluated: value == QLatin1String("no")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6
2-6
1828 standalone = false;
executed: standalone = false;
Execution Count:2
2
1829 else -
1830 err = QXmlStream::tr("Standalone accepts only yes or no.");
executed: err = QXmlStream::tr("Standalone accepts only yes or no.");
Execution Count:6
6
1831 } else { -
1832 err = QXmlStream::tr("Invalid attribute in XML declaration.");
executed (the execution status of this line is deduced): err = QXmlStream::tr("Invalid attribute in XML declaration.");
-
1833 }
executed: }
Execution Count:4
4
1834 } -
1835 -
1836 if (!err.isNull())
evaluated: !err.isNull()
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:1020
31-1020
1837 raiseWellFormedError(err);
executed: raiseWellFormedError(err);
Execution Count:31
31
1838 attributeStack.clear();
executed (the execution status of this line is deduced): attributeStack.clear();
-
1839}
executed: }
Execution Count:1051
1051
1840 -
1841 -
1842void QXmlStreamReaderPrivate::raiseError(QXmlStreamReader::Error error, const QString& message) -
1843{ -
1844 this->error = error;
executed (the execution status of this line is deduced): this->error = error;
-
1845 errorString = message;
executed (the execution status of this line is deduced): errorString = message;
-
1846 if (errorString.isNull()) {
evaluated: errorString.isNull()
TRUEFALSE
yes
Evaluation Count:58733
yes
Evaluation Count:1204
1204-58733
1847 if (error == QXmlStreamReader::PrematureEndOfDocumentError)
partially evaluated: error == QXmlStreamReader::PrematureEndOfDocumentError
TRUEFALSE
yes
Evaluation Count:58733
no
Evaluation Count:0
0-58733
1848 errorString = QXmlStream::tr("Premature end of document.");
executed: errorString = QXmlStream::tr("Premature end of document.");
Execution Count:58733
58733
1849 else if (error == QXmlStreamReader::CustomError)
never evaluated: error == QXmlStreamReader::CustomError
0
1850 errorString = QXmlStream::tr("Invalid document.");
never executed: errorString = QXmlStream::tr("Invalid document.");
0
1851 } -
1852 -
1853 type = QXmlStreamReader::Invalid;
executed (the execution status of this line is deduced): type = QXmlStreamReader::Invalid;
-
1854}
executed: }
Execution Count:59937
59937
1855 -
1856void QXmlStreamReaderPrivate::raiseWellFormedError(const QString &message) -
1857{ -
1858 raiseError(QXmlStreamReader::NotWellFormedError, message);
executed (the execution status of this line is deduced): raiseError(QXmlStreamReader::NotWellFormedError, message);
-
1859}
executed: }
Execution Count:1166
1166
1860 -
1861void QXmlStreamReaderPrivate::parseError() -
1862{ -
1863 -
1864 if (token == EOF_SYMBOL) {
evaluated: token == EOF_SYMBOL
TRUEFALSE
yes
Evaluation Count:6306
yes
Evaluation Count:592
592-6306
1865 raiseError(QXmlStreamReader::PrematureEndOfDocumentError);
executed (the execution status of this line is deduced): raiseError(QXmlStreamReader::PrematureEndOfDocumentError);
-
1866 return;
executed: return;
Execution Count:6306
6306
1867 } -
1868 const int nmax = 4;
executed (the execution status of this line is deduced): const int nmax = 4;
-
1869 QString error_message;
executed (the execution status of this line is deduced): QString error_message;
-
1870 int ers = state_stack[tos];
executed (the execution status of this line is deduced): int ers = state_stack[tos];
-
1871 int nexpected = 0;
executed (the execution status of this line is deduced): int nexpected = 0;
-
1872 int expected[nmax];
executed (the execution status of this line is deduced): int expected[nmax];
-
1873 if (token != ERROR)
evaluated: token != ERROR
TRUEFALSE
yes
Evaluation Count:590
yes
Evaluation Count:2
2-590
1874 for (int tk = 0; tk < TERMINAL_COUNT; ++tk) {
evaluated: tk < TERMINAL_COUNT
TRUEFALSE
yes
Evaluation Count:33630
yes
Evaluation Count:590
590-33630
1875 int k = t_action(ers, tk);
executed (the execution status of this line is deduced): int k = t_action(ers, tk);
-
1876 if (k <= 0)
evaluated: k <= 0
TRUEFALSE
yes
Evaluation Count:30589
yes
Evaluation Count:3041
3041-30589
1877 continue;
executed: continue;
Execution Count:30589
30589
1878 if (spell[tk]) {
evaluated: spell[tk]
TRUEFALSE
yes
Evaluation Count:2960
yes
Evaluation Count:81
81-2960
1879 if (nexpected < nmax)
evaluated: nexpected < nmax
TRUEFALSE
yes
Evaluation Count:1344
yes
Evaluation Count:1616
1344-1616
1880 expected[nexpected++] = tk;
executed: expected[nexpected++] = tk;
Execution Count:1344
1344
1881 }
executed: }
Execution Count:2960
2960
1882 }
executed: }
Execution Count:3041
3041
1883 -
1884 error_message.clear ();
executed (the execution status of this line is deduced): error_message.clear ();
-
1885 if (nexpected && nexpected < nmax) {
evaluated: nexpected
TRUEFALSE
yes
Evaluation Count:590
yes
Evaluation Count:2
evaluated: nexpected < nmax
TRUEFALSE
yes
Evaluation Count:442
yes
Evaluation Count:148
2-590
1886 bool first = true;
executed (the execution status of this line is deduced): bool first = true;
-
1887 -
1888 for (int s = 0; s < nexpected; ++s) {
evaluated: s < nexpected
TRUEFALSE
yes
Evaluation Count:752
yes
Evaluation Count:442
442-752
1889 if (first)
evaluated: first
TRUEFALSE
yes
Evaluation Count:442
yes
Evaluation Count:310
310-442
1890 error_message += QXmlStream::tr ("Expected ");
executed: error_message += QXmlStream::tr ("Expected ");
Execution Count:442
442
1891 else if (s == nexpected - 1)
evaluated: s == nexpected - 1
TRUEFALSE
yes
Evaluation Count:221
yes
Evaluation Count:89
89-221
1892 error_message += QLatin1String (nexpected > 2 ? ", or " : " or ");
executed: error_message += QLatin1String (nexpected > 2 ? ", or " : " or ");
Execution Count:221
221
1893 else -
1894 error_message += QLatin1String (", ");
executed: error_message += QLatin1String (", ");
Execution Count:89
89
1895 -
1896 first = false;
executed (the execution status of this line is deduced): first = false;
-
1897 error_message += QLatin1String("\'");
executed (the execution status of this line is deduced): error_message += QLatin1String("\'");
-
1898 error_message += QLatin1String (spell [expected[s]]);
executed (the execution status of this line is deduced): error_message += QLatin1String (spell [expected[s]]);
-
1899 error_message += QLatin1String("\'");
executed (the execution status of this line is deduced): error_message += QLatin1String("\'");
-
1900 }
executed: }
Execution Count:752
752
1901 error_message += QXmlStream::tr(", but got \'");
executed (the execution status of this line is deduced): error_message += QXmlStream::tr(", but got \'");
-
1902 error_message += QLatin1String(spell [token]);
executed (the execution status of this line is deduced): error_message += QLatin1String(spell [token]);
-
1903 error_message += QLatin1String("\'");
executed (the execution status of this line is deduced): error_message += QLatin1String("\'");
-
1904 } else {
executed: }
Execution Count:442
442
1905 error_message += QXmlStream::tr("Unexpected \'");
executed (the execution status of this line is deduced): error_message += QXmlStream::tr("Unexpected \'");
-
1906 error_message += QLatin1String(spell [token]);
executed (the execution status of this line is deduced): error_message += QLatin1String(spell [token]);
-
1907 error_message += QLatin1String("\'");
executed (the execution status of this line is deduced): error_message += QLatin1String("\'");
-
1908 }
executed: }
Execution Count:150
150
1909 error_message += QLatin1Char('.');
executed (the execution status of this line is deduced): error_message += QLatin1Char('.');
-
1910 -
1911 raiseWellFormedError(error_message);
executed (the execution status of this line is deduced): raiseWellFormedError(error_message);
-
1912}
executed: }
Execution Count:592
592
1913 -
1914void QXmlStreamReaderPrivate::resume(int rule) { -
1915 resumeReduction = rule;
executed (the execution status of this line is deduced): resumeReduction = rule;
-
1916 if (error == QXmlStreamReader::NoError)
evaluated: error == QXmlStreamReader::NoError
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:44562
27-44562
1917 raiseError(QXmlStreamReader::PrematureEndOfDocumentError);
executed: raiseError(QXmlStreamReader::PrematureEndOfDocumentError);
Execution Count:27
27
1918}
executed: }
Execution Count:44589
44589
1919 -
1920/*! Returns the current line number, starting with 1. -
1921 -
1922\sa columnNumber(), characterOffset() -
1923 */ -
1924qint64 QXmlStreamReader::lineNumber() const -
1925{ -
1926 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
1927 return d->lineNumber + 1; // in public we start with 1
executed: return d->lineNumber + 1;
Execution Count:551
551
1928} -
1929 -
1930/*! Returns the current column number, starting with 0. -
1931 -
1932\sa lineNumber(), characterOffset() -
1933 */ -
1934qint64 QXmlStreamReader::columnNumber() const -
1935{ -
1936 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
1937 return d->characterOffset - d->lastLineStart + d->readBufferPos;
executed: return d->characterOffset - d->lastLineStart + d->readBufferPos;
Execution Count:551
551
1938} -
1939 -
1940/*! Returns the current character offset, starting with 0. -
1941 -
1942\sa lineNumber(), columnNumber() -
1943*/ -
1944qint64 QXmlStreamReader::characterOffset() const -
1945{ -
1946 Q_D(const QXmlStreamReader);
never executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
1947 return d->characterOffset + d->readBufferPos;
never executed: return d->characterOffset + d->readBufferPos;
0
1948} -
1949 -
1950 -
1951/*! Returns the text of \l Characters, \l Comment, \l DTD, or -
1952 EntityReference. -
1953 */ -
1954QStringRef QXmlStreamReader::text() const -
1955{ -
1956 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
1957 return d->text;
executed: return d->text;
Execution Count:3544
3544
1958} -
1959 -
1960 -
1961/*! If the tokenType() is \l DTD, this function returns the DTD's -
1962 notation declarations. Otherwise an empty vector is returned. -
1963 -
1964 The QXmlStreamNotationDeclarations class is defined to be a QVector -
1965 of QXmlStreamNotationDeclaration. -
1966 */ -
1967QXmlStreamNotationDeclarations QXmlStreamReader::notationDeclarations() const -
1968{ -
1969 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
1970 if (d->notationDeclarations.size())
evaluated: d->notationDeclarations.size()
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:2533
47-2533
1971 const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd();
executed: const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd();
Execution Count:47
47
1972 return d->publicNotationDeclarations;
executed: return d->publicNotationDeclarations;
Execution Count:2580
2580
1973} -
1974 -
1975 -
1976/*! If the tokenType() is \l DTD, this function returns the DTD's -
1977 unparsed (external) entity declarations. Otherwise an empty vector is returned. -
1978 -
1979 The QXmlStreamEntityDeclarations class is defined to be a QVector -
1980 of QXmlStreamEntityDeclaration. -
1981 */ -
1982QXmlStreamEntityDeclarations QXmlStreamReader::entityDeclarations() const -
1983{ -
1984 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
1985 if (d->entityDeclarations.size())
evaluated: d->entityDeclarations.size()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1891
5-1891
1986 const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd();
executed: const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd();
Execution Count:5
5
1987 return d->publicEntityDeclarations;
executed: return d->publicEntityDeclarations;
Execution Count:1896
1896
1988} -
1989 -
1990/*! -
1991 \since 4.4 -
1992 -
1993 If the tokenType() is \l DTD, this function returns the DTD's -
1994 name. Otherwise an empty string is returned. -
1995 -
1996 */ -
1997QStringRef QXmlStreamReader::dtdName() const -
1998{ -
1999 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2000 if (d->type == QXmlStreamReader::DTD)
evaluated: d->type == QXmlStreamReader::DTD
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:1866
50-1866
2001 return d->dtdName;
executed: return d->dtdName;
Execution Count:50
50
2002 return QStringRef();
executed: return QStringRef();
Execution Count:1866
1866
2003} -
2004 -
2005/*! -
2006 \since 4.4 -
2007 -
2008 If the tokenType() is \l DTD, this function returns the DTD's -
2009 public identifier. Otherwise an empty string is returned. -
2010 -
2011 */ -
2012QStringRef QXmlStreamReader::dtdPublicId() const -
2013{ -
2014 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2015 if (d->type == QXmlStreamReader::DTD)
evaluated: d->type == QXmlStreamReader::DTD
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:1866
27-1866
2016 return d->dtdPublicId;
executed: return d->dtdPublicId;
Execution Count:27
27
2017 return QStringRef();
executed: return QStringRef();
Execution Count:1866
1866
2018} -
2019 -
2020/*! -
2021 \since 4.4 -
2022 -
2023 If the tokenType() is \l DTD, this function returns the DTD's -
2024 system identifier. Otherwise an empty string is returned. -
2025 -
2026 */ -
2027QStringRef QXmlStreamReader::dtdSystemId() const -
2028{ -
2029 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2030 if (d->type == QXmlStreamReader::DTD)
evaluated: d->type == QXmlStreamReader::DTD
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:1866
27-1866
2031 return d->dtdSystemId;
executed: return d->dtdSystemId;
Execution Count:27
27
2032 return QStringRef();
executed: return QStringRef();
Execution Count:1866
1866
2033} -
2034 -
2035/*! If the tokenType() is \l StartElement, this function returns the -
2036 element's namespace declarations. Otherwise an empty vector is -
2037 returned. -
2038 -
2039 The QXmlStreamNamespaceDeclaration class is defined to be a QVector -
2040 of QXmlStreamNamespaceDeclaration. -
2041 -
2042 \sa addExtraNamespaceDeclaration(), addExtraNamespaceDeclarations() -
2043 */ -
2044QXmlStreamNamespaceDeclarations QXmlStreamReader::namespaceDeclarations() const -
2045{ -
2046 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2047 if (d->publicNamespaceDeclarations.isEmpty() && d->type == StartElement)
evaluated: d->publicNamespaceDeclarations.isEmpty()
TRUEFALSE
yes
Evaluation Count:1895
yes
Evaluation Count:38
evaluated: d->type == StartElement
TRUEFALSE
yes
Evaluation Count:446
yes
Evaluation Count:1449
38-1895
2048 const_cast<QXmlStreamReaderPrivate *>(d)->resolvePublicNamespaces();
executed: const_cast<QXmlStreamReaderPrivate *>(d)->resolvePublicNamespaces();
Execution Count:446
446
2049 return d->publicNamespaceDeclarations;
executed: return d->publicNamespaceDeclarations;
Execution Count:1933
1933
2050} -
2051 -
2052 -
2053/*! -
2054 \since 4.4 -
2055 -
2056 Adds an \a extraNamespaceDeclaration. The declaration will be -
2057 valid for children of the current element, or - should the function -
2058 be called before any elements are read - for the entire XML -
2059 document. -
2060 -
2061 \sa namespaceDeclarations(), addExtraNamespaceDeclarations(), setNamespaceProcessing() -
2062 */ -
2063void QXmlStreamReader::addExtraNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &extraNamespaceDeclaration) -
2064{ -
2065 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
2066 QXmlStreamReaderPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
-
2067 namespaceDeclaration.prefix = d->addToStringStorage(extraNamespaceDeclaration.prefix());
executed (the execution status of this line is deduced): namespaceDeclaration.prefix = d->addToStringStorage(extraNamespaceDeclaration.prefix());
-
2068 namespaceDeclaration.namespaceUri = d->addToStringStorage(extraNamespaceDeclaration.namespaceUri());
executed (the execution status of this line is deduced): namespaceDeclaration.namespaceUri = d->addToStringStorage(extraNamespaceDeclaration.namespaceUri());
-
2069}
executed: }
Execution Count:2
2
2070 -
2071/*! -
2072 \since 4.4 -
2073 -
2074 Adds a vector of declarations specified by \a extraNamespaceDeclarations. -
2075 -
2076 \sa namespaceDeclarations(), addExtraNamespaceDeclaration() -
2077 */ -
2078void QXmlStreamReader::addExtraNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &extraNamespaceDeclarations) -
2079{ -
2080 for (int i = 0; i < extraNamespaceDeclarations.size(); ++i)
never evaluated: i < extraNamespaceDeclarations.size()
0
2081 addExtraNamespaceDeclaration(extraNamespaceDeclarations.at(i));
never executed: addExtraNamespaceDeclaration(extraNamespaceDeclarations.at(i));
0
2082}
never executed: }
0
2083 -
2084 -
2085/*! Convenience function to be called in case a StartElement was -
2086 read. Reads until the corresponding EndElement and returns all text -
2087 in-between. In case of no error, the current token (see tokenType()) -
2088 after having called this function is EndElement. -
2089 -
2090 The function concatenates text() when it reads either \l Characters -
2091 or EntityReference tokens, but skips ProcessingInstruction and \l -
2092 Comment. If the current token is not StartElement, an empty string is -
2093 returned. -
2094 -
2095 The \a behaviour defines what happens in case anything else is -
2096 read before reaching EndElement. The function can include the text from -
2097 child elements (useful for example for HTML), ignore child elements, or -
2098 raise an UnexpectedElementError and return what was read so far (default). -
2099 -
2100 \since 4.6 -
2101 */ -
2102QString QXmlStreamReader::readElementText(ReadElementTextBehaviour behaviour) -
2103{ -
2104 Q_D(QXmlStreamReader);
executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
2105 if (isStartElement()) {
partially evaluated: isStartElement()
TRUEFALSE
yes
Evaluation Count:663
no
Evaluation Count:0
0-663
2106 QString result;
executed (the execution status of this line is deduced): QString result;
-
2107 forever {
executed (the execution status of this line is deduced): for(;;) {
-
2108 switch (readNext()) { -
2109 case Characters: -
2110 case EntityReference: -
2111 result.insert(result.size(), d->text.unicode(), d->text.size());
executed (the execution status of this line is deduced): result.insert(result.size(), d->text.unicode(), d->text.size());
-
2112 break;
executed: break;
Execution Count:666
666
2113 case EndElement: -
2114 return result;
executed: return result;
Execution Count:658
658
2115 case ProcessingInstruction: -
2116 case Comment: -
2117 break;
executed: break;
Execution Count:2
2
2118 case StartElement: -
2119 if (behaviour == SkipChildElements) {
evaluated: behaviour == SkipChildElements
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
2-4
2120 skipCurrentElement();
executed (the execution status of this line is deduced): skipCurrentElement();
-
2121 break;
executed: break;
Execution Count:2
2
2122 } else if (behaviour == IncludeChildElements) {
evaluated: behaviour == IncludeChildElements
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
2123 result += readElementText(behaviour);
executed (the execution status of this line is deduced): result += readElementText(behaviour);
-
2124 break;
executed: break;
Execution Count:2
2
2125 } -
2126 // Fall through (for ErrorOnUnexpectedElement) -
2127 default:
code before this statement executed: default:
Execution Count:2
2
2128 if (d->error || behaviour == ErrorOnUnexpectedElement) {
evaluated: d->error
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
partially evaluated: behaviour == ErrorOnUnexpectedElement
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-3
2129 if (!d->error)
evaluated: !d->error
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-3
2130 d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data."));
executed: d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data."));
Execution Count:2
2
2131 return result;
executed: return result;
Execution Count:5
5
2132 } -
2133 }
never executed: }
0
2134 }
executed: }
Execution Count:672
672
2135 }
never executed: }
0
2136 return QString();
never executed: return QString();
0
2137} -
2138 -
2139/*! Raises a custom error with an optional error \a message. -
2140 -
2141 \sa error(), errorString() -
2142 */ -
2143void QXmlStreamReader::raiseError(const QString& message) -
2144{ -
2145 Q_D(QXmlStreamReader);
never executed (the execution status of this line is deduced): QXmlStreamReaderPrivate * const d = d_func();
-
2146 d->raiseError(CustomError, message);
never executed (the execution status of this line is deduced): d->raiseError(CustomError, message);
-
2147}
never executed: }
0
2148 -
2149/*! -
2150 Returns the error message that was set with raiseError(). -
2151 -
2152 \sa error(), lineNumber(), columnNumber(), characterOffset() -
2153 */ -
2154QString QXmlStreamReader::errorString() const -
2155{ -
2156 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2157 if (d->type == QXmlStreamReader::Invalid)
evaluated: d->type == QXmlStreamReader::Invalid
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:553
30-553
2158 return d->errorString;
executed: return d->errorString;
Execution Count:30
30
2159 return QString();
executed: return QString();
Execution Count:553
553
2160} -
2161 -
2162/*! Returns the type of the current error, or NoError if no error occurred. -
2163 -
2164 \sa errorString(), raiseError() -
2165 */ -
2166QXmlStreamReader::Error QXmlStreamReader::error() const -
2167{ -
2168 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2169 if (d->type == QXmlStreamReader::Invalid)
evaluated: d->type == QXmlStreamReader::Invalid
TRUEFALSE
yes
Evaluation Count:59915
yes
Evaluation Count:2743
2743-59915
2170 return d->error;
executed: return d->error;
Execution Count:59915
59915
2171 return NoError;
executed: return NoError;
Execution Count:2743
2743
2172} -
2173 -
2174/*! -
2175 Returns the target of a ProcessingInstruction. -
2176 */ -
2177QStringRef QXmlStreamReader::processingInstructionTarget() const -
2178{ -
2179 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2180 return d->processingInstructionTarget;
executed: return d->processingInstructionTarget;
Execution Count:1975
1975
2181} -
2182 -
2183/*! -
2184 Returns the data of a ProcessingInstruction. -
2185 */ -
2186QStringRef QXmlStreamReader::processingInstructionData() const -
2187{ -
2188 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2189 return d->processingInstructionData;
executed: return d->processingInstructionData;
Execution Count:2012
2012
2190} -
2191 -
2192 -
2193 -
2194/*! -
2195 Returns the local name of a StartElement, EndElement, or an EntityReference. -
2196 -
2197 \sa namespaceUri(), qualifiedName() -
2198 */ -
2199QStringRef QXmlStreamReader::name() const -
2200{ -
2201 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2202 return d->name;
executed: return d->name;
Execution Count:13063
13063
2203} -
2204 -
2205/*! -
2206 Returns the namespaceUri of a StartElement or EndElement. -
2207 -
2208 \sa name(), qualifiedName() -
2209 */ -
2210QStringRef QXmlStreamReader::namespaceUri() const -
2211{ -
2212 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2213 return d->namespaceUri;
executed: return d->namespaceUri;
Execution Count:3742
3742
2214} -
2215 -
2216/*! -
2217 Returns the qualified name of a StartElement or EndElement; -
2218 -
2219 A qualified name is the raw name of an element in the XML data. It -
2220 consists of the namespace prefix, followed by colon, followed by the -
2221 element's local name. Since the namespace prefix is not unique (the -
2222 same prefix can point to different namespaces and different prefixes -
2223 can point to the same namespace), you shouldn't use qualifiedName(), -
2224 but the resolved namespaceUri() and the attribute's local name(). -
2225 -
2226 \sa name(), prefix(), namespaceUri() -
2227 */ -
2228QStringRef QXmlStreamReader::qualifiedName() const -
2229{ -
2230 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2231 return d->qualifiedName;
executed: return d->qualifiedName;
Execution Count:3043
3043
2232} -
2233 -
2234 -
2235 -
2236/*! -
2237 \since 4.4 -
2238 -
2239 Returns the prefix of a StartElement or EndElement. -
2240 -
2241 \sa name(), qualifiedName() -
2242*/ -
2243QStringRef QXmlStreamReader::prefix() const -
2244{ -
2245 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2246 return d->prefix;
executed: return d->prefix;
Execution Count:1931
1931
2247} -
2248 -
2249/*! -
2250 Returns the attributes of a StartElement. -
2251 */ -
2252QXmlStreamAttributes QXmlStreamReader::attributes() const -
2253{ -
2254 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2255 return d->attributes;
executed: return d->attributes;
Execution Count:8594
8594
2256} -
2257 -
2258#endif // QT_NO_XMLSTREAMREADER -
2259 -
2260/*! -
2261 \class QXmlStreamAttribute -
2262 \inmodule QtCore -
2263 \since 4.3 -
2264 \reentrant -
2265 \brief The QXmlStreamAttribute class represents a single XML attribute -
2266 -
2267 \ingroup xml-tools -
2268 -
2269 An attribute consists of an optionally empty namespaceUri(), a -
2270 name(), a value(), and an isDefault() attribute. -
2271 -
2272 The raw XML attribute name is returned as qualifiedName(). -
2273*/ -
2274 -
2275/*! -
2276 Creates an empty attribute. -
2277 */ -
2278QXmlStreamAttribute::QXmlStreamAttribute() -
2279{ -
2280 m_isDefault = false;
executed (the execution status of this line is deduced): m_isDefault = false;
-
2281}
executed: }
Execution Count:105070
105070
2282 -
2283/*! -
2284 Destructs an attribute. -
2285 */ -
2286QXmlStreamAttribute::~QXmlStreamAttribute() -
2287{ -
2288} -
2289 -
2290/*! Constructs an attribute in the namespace described with \a -
2291 namespaceUri with \a name and value \a value. -
2292 */ -
2293QXmlStreamAttribute::QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value) -
2294{ -
2295 m_namespaceUri = QXmlStreamStringRef(QStringRef(&namespaceUri));
never executed (the execution status of this line is deduced): m_namespaceUri = QXmlStreamStringRef(QStringRef(&namespaceUri));
-
2296 m_name = m_qualifiedName = QXmlStreamStringRef(QStringRef(&name));
never executed (the execution status of this line is deduced): m_name = m_qualifiedName = QXmlStreamStringRef(QStringRef(&name));
-
2297 m_value = QXmlStreamStringRef(QStringRef(&value));
never executed (the execution status of this line is deduced): m_value = QXmlStreamStringRef(QStringRef(&value));
-
2298 m_namespaceUri = QXmlStreamStringRef(QStringRef(&namespaceUri));
never executed (the execution status of this line is deduced): m_namespaceUri = QXmlStreamStringRef(QStringRef(&namespaceUri));
-
2299}
never executed: }
0
2300 -
2301/*! -
2302 Constructs an attribute with qualified name \a qualifiedName and value \a value. -
2303 */ -
2304QXmlStreamAttribute::QXmlStreamAttribute(const QString &qualifiedName, const QString &value) -
2305{ -
2306 int colon = qualifiedName.indexOf(QLatin1Char(':'));
never executed (the execution status of this line is deduced): int colon = qualifiedName.indexOf(QLatin1Char(':'));
-
2307 m_name = QXmlStreamStringRef(QStringRef(&qualifiedName,
never executed (the execution status of this line is deduced): m_name = QXmlStreamStringRef(QStringRef(&qualifiedName,
-
2308 colon + 1,
never executed (the execution status of this line is deduced): colon + 1,
-
2309 qualifiedName.size() - (colon + 1)));
never executed (the execution status of this line is deduced): qualifiedName.size() - (colon + 1)));
-
2310 m_qualifiedName = QXmlStreamStringRef(QStringRef(&qualifiedName));
never executed (the execution status of this line is deduced): m_qualifiedName = QXmlStreamStringRef(QStringRef(&qualifiedName));
-
2311 m_value = QXmlStreamStringRef(QStringRef(&value));
never executed (the execution status of this line is deduced): m_value = QXmlStreamStringRef(QStringRef(&value));
-
2312}
never executed: }
0
2313 -
2314/*! \fn QStringRef QXmlStreamAttribute::namespaceUri() const -
2315 -
2316 Returns the attribute's resolved namespaceUri, or an empty string -
2317 reference if the attribute does not have a defined namespace. -
2318 */ -
2319/*! \fn QStringRef QXmlStreamAttribute::name() const -
2320 Returns the attribute's local name. -
2321 */ -
2322/*! \fn QStringRef QXmlStreamAttribute::qualifiedName() const -
2323 Returns the attribute's qualified name. -
2324 -
2325 A qualified name is the raw name of an attribute in the XML -
2326 data. It consists of the namespace prefix(), followed by colon, -
2327 followed by the attribute's local name(). Since the namespace prefix -
2328 is not unique (the same prefix can point to different namespaces -
2329 and different prefixes can point to the same namespace), you -
2330 shouldn't use qualifiedName(), but the resolved namespaceUri() and -
2331 the attribute's local name(). -
2332 */ -
2333/*! -
2334 \fn QStringRef QXmlStreamAttribute::prefix() const -
2335 \since 4.4 -
2336 Returns the attribute's namespace prefix. -
2337 -
2338 \sa name(), qualifiedName() -
2339 -
2340*/ -
2341 -
2342/*! \fn QStringRef QXmlStreamAttribute::value() const -
2343 Returns the attribute's value. -
2344 */ -
2345 -
2346/*! \fn bool QXmlStreamAttribute::isDefault() const -
2347 -
2348 Returns true if the parser added this attribute with a default -
2349 value following an ATTLIST declaration in the DTD; otherwise -
2350 returns false. -
2351*/ -
2352/*! \fn bool QXmlStreamAttribute::operator==(const QXmlStreamAttribute &other) const -
2353 -
2354 Compares this attribute with \a other and returns true if they are -
2355 equal; otherwise returns false. -
2356 */ -
2357/*! \fn bool QXmlStreamAttribute::operator!=(const QXmlStreamAttribute &other) const -
2358 -
2359 Compares this attribute with \a other and returns true if they are -
2360 not equal; otherwise returns false. -
2361 */ -
2362 -
2363 -
2364/*! -
2365 Creates a copy of \a other. -
2366 */ -
2367QXmlStreamAttribute::QXmlStreamAttribute(const QXmlStreamAttribute &other) -
2368{ -
2369 *this = other;
executed (the execution status of this line is deduced): *this = other;
-
2370}
executed: }
Execution Count:2579
2579
2371 -
2372/*! -
2373 Assigns \a other to this attribute. -
2374 */ -
2375QXmlStreamAttribute& QXmlStreamAttribute::operator=(const QXmlStreamAttribute &other) -
2376{ -
2377 m_name = other.m_name;
executed (the execution status of this line is deduced): m_name = other.m_name;
-
2378 m_namespaceUri = other.m_namespaceUri;
executed (the execution status of this line is deduced): m_namespaceUri = other.m_namespaceUri;
-
2379 m_qualifiedName = other.m_qualifiedName;
executed (the execution status of this line is deduced): m_qualifiedName = other.m_qualifiedName;
-
2380 m_value = other.m_value;
executed (the execution status of this line is deduced): m_value = other.m_value;
-
2381 m_isDefault = other.m_isDefault;
executed (the execution status of this line is deduced): m_isDefault = other.m_isDefault;
-
2382 return *this;
executed: return *this;
Execution Count:2588
2588
2383} -
2384 -
2385 -
2386/*! -
2387 \class QXmlStreamAttributes -
2388 \inmodule QtCore -
2389 \since 4.3 -
2390 \reentrant -
2391 \brief The QXmlStreamAttributes class represents a vector of QXmlStreamAttribute. -
2392 -
2393 Attributes are returned by a QXmlStreamReader in -
2394 \l{QXmlStreamReader::attributes()} {attributes()} when the reader -
2395 reports a \l {QXmlStreamReader::StartElement}{start element}. The -
2396 class can also be used with a QXmlStreamWriter as an argument to -
2397 \l {QXmlStreamWriter::writeAttributes()}{writeAttributes()}. -
2398 -
2399 The convenience function value() loops over the vector and returns -
2400 an attribute value for a given namespaceUri and an attribute's -
2401 name. -
2402 -
2403 New attributes can be added with append(). -
2404 -
2405 \ingroup xml-tools -
2406*/ -
2407 -
2408/*! -
2409 \fn void QXmlStreamAttributes::append(const QXmlStreamAttribute &attribute) -
2410 -
2411 Appends the given \a attribute to the end of the vector. -
2412 -
2413 \sa QVector::append() -
2414*/ -
2415 -
2416 -
2417/*! -
2418 \typedef QXmlStreamNotationDeclarations -
2419 \relates QXmlStreamNotationDeclaration -
2420 -
2421 Synonym for QVector<QXmlStreamNotationDeclaration>. -
2422*/ -
2423 -
2424 -
2425/*! -
2426 \class QXmlStreamNotationDeclaration -
2427 \inmodule QtCore -
2428 \since 4.3 -
2429 \reentrant -
2430 \brief The QXmlStreamNotationDeclaration class represents a DTD notation declaration. -
2431 -
2432 \ingroup xml-tools -
2433 -
2434 An notation declaration consists of a name(), a systemId(), and a publicId(). -
2435*/ -
2436 -
2437/*! -
2438 Creates an empty notation declaration. -
2439*/ -
2440QXmlStreamNotationDeclaration::QXmlStreamNotationDeclaration() -
2441{ -
2442} -
2443/*! -
2444 Creates a copy of \a other. -
2445 */ -
2446QXmlStreamNotationDeclaration::QXmlStreamNotationDeclaration(const QXmlStreamNotationDeclaration &other) -
2447{ -
2448 *this = other;
executed (the execution status of this line is deduced): *this = other;
-
2449}
executed: }
Execution Count:304
304
2450 -
2451/*! -
2452 Assigns \a other to this notation declaration. -
2453 */ -
2454QXmlStreamNotationDeclaration& QXmlStreamNotationDeclaration::operator=(const QXmlStreamNotationDeclaration &other) -
2455{ -
2456 m_name = other.m_name;
executed (the execution status of this line is deduced): m_name = other.m_name;
-
2457 m_systemId = other.m_systemId;
executed (the execution status of this line is deduced): m_systemId = other.m_systemId;
-
2458 m_publicId = other.m_publicId;
executed (the execution status of this line is deduced): m_publicId = other.m_publicId;
-
2459 return *this;
executed: return *this;
Execution Count:304
304
2460} -
2461 -
2462/*! -
2463Destructs this notation declaration. -
2464*/ -
2465QXmlStreamNotationDeclaration::~QXmlStreamNotationDeclaration() -
2466{ -
2467} -
2468 -
2469/*! \fn QStringRef QXmlStreamNotationDeclaration::name() const -
2470 -
2471Returns the notation name. -
2472*/ -
2473/*! \fn QStringRef QXmlStreamNotationDeclaration::systemId() const -
2474 -
2475Returns the system identifier. -
2476*/ -
2477/*! \fn QStringRef QXmlStreamNotationDeclaration::publicId() const -
2478 -
2479Returns the public identifier. -
2480*/ -
2481 -
2482/*! \fn inline bool QXmlStreamNotationDeclaration::operator==(const QXmlStreamNotationDeclaration &other) const -
2483 -
2484 Compares this notation declaration with \a other and returns true -
2485 if they are equal; otherwise returns false. -
2486 */ -
2487/*! \fn inline bool QXmlStreamNotationDeclaration::operator!=(const QXmlStreamNotationDeclaration &other) const -
2488 -
2489 Compares this notation declaration with \a other and returns true -
2490 if they are not equal; otherwise returns false. -
2491 */ -
2492 -
2493/*! -
2494 \typedef QXmlStreamNamespaceDeclarations -
2495 \relates QXmlStreamNamespaceDeclaration -
2496 -
2497 Synonym for QVector<QXmlStreamNamespaceDeclaration>. -
2498*/ -
2499 -
2500/*! -
2501 \class QXmlStreamNamespaceDeclaration -
2502 \inmodule QtCore -
2503 \since 4.3 -
2504 \reentrant -
2505 \brief The QXmlStreamNamespaceDeclaration class represents a namespace declaration. -
2506 -
2507 \ingroup xml-tools -
2508 -
2509 An namespace declaration consists of a prefix() and a namespaceUri(). -
2510*/ -
2511/*! \fn inline bool QXmlStreamNamespaceDeclaration::operator==(const QXmlStreamNamespaceDeclaration &other) const -
2512 -
2513 Compares this namespace declaration with \a other and returns true -
2514 if they are equal; otherwise returns false. -
2515 */ -
2516/*! \fn inline bool QXmlStreamNamespaceDeclaration::operator!=(const QXmlStreamNamespaceDeclaration &other) const -
2517 -
2518 Compares this namespace declaration with \a other and returns true -
2519 if they are not equal; otherwise returns false. -
2520 */ -
2521 -
2522/*! -
2523 Creates an empty namespace declaration. -
2524*/ -
2525QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration() -
2526{ -
2527} -
2528 -
2529/*! -
2530 \since 4.4 -
2531 -
2532 Creates a namespace declaration with \a prefix and \a namespaceUri. -
2533*/ -
2534QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration(const QString &prefix, const QString &namespaceUri) -
2535{ -
2536 m_prefix = prefix;
executed (the execution status of this line is deduced): m_prefix = prefix;
-
2537 m_namespaceUri = namespaceUri;
executed (the execution status of this line is deduced): m_namespaceUri = namespaceUri;
-
2538}
executed: }
Execution Count:2
2
2539 -
2540/*! -
2541 Creates a copy of \a other. -
2542 */ -
2543QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &other) -
2544{ -
2545 *this = other;
executed (the execution status of this line is deduced): *this = other;
-
2546}
executed: }
Execution Count:54
54
2547 -
2548/*! -
2549 Assigns \a other to this namespace declaration. -
2550 */ -
2551QXmlStreamNamespaceDeclaration& QXmlStreamNamespaceDeclaration::operator=(const QXmlStreamNamespaceDeclaration &other) -
2552{ -
2553 m_prefix = other.m_prefix;
executed (the execution status of this line is deduced): m_prefix = other.m_prefix;
-
2554 m_namespaceUri = other.m_namespaceUri;
executed (the execution status of this line is deduced): m_namespaceUri = other.m_namespaceUri;
-
2555 return *this;
executed: return *this;
Execution Count:54
54
2556} -
2557/*! -
2558Destructs this namespace declaration. -
2559*/ -
2560QXmlStreamNamespaceDeclaration::~QXmlStreamNamespaceDeclaration() -
2561{ -
2562} -
2563 -
2564/*! \fn QStringRef QXmlStreamNamespaceDeclaration::prefix() const -
2565 -
2566Returns the prefix. -
2567*/ -
2568/*! \fn QStringRef QXmlStreamNamespaceDeclaration::namespaceUri() const -
2569 -
2570Returns the namespaceUri. -
2571*/ -
2572 -
2573 -
2574 -
2575 -
2576/*! -
2577 \typedef QXmlStreamEntityDeclarations -
2578 \relates QXmlStreamEntityDeclaration -
2579 -
2580 Synonym for QVector<QXmlStreamEntityDeclaration>. -
2581*/ -
2582 -
2583/*! -
2584 \class QXmlStreamStringRef -
2585 \inmodule QtCore -
2586 \since 4.3 -
2587 \internal -
2588*/ -
2589 -
2590/*! -
2591 \class QXmlStreamEntityDeclaration -
2592 \inmodule QtCore -
2593 \since 4.3 -
2594 \reentrant -
2595 \brief The QXmlStreamEntityDeclaration class represents a DTD entity declaration. -
2596 -
2597 \ingroup xml-tools -
2598 -
2599 An entity declaration consists of a name(), a notationName(), a -
2600 systemId(), a publicId(), and a value(). -
2601*/ -
2602 -
2603/*! -
2604 Creates an empty entity declaration. -
2605*/ -
2606QXmlStreamEntityDeclaration::QXmlStreamEntityDeclaration() -
2607{ -
2608} -
2609 -
2610/*! -
2611 Creates a copy of \a other. -
2612 */ -
2613QXmlStreamEntityDeclaration::QXmlStreamEntityDeclaration(const QXmlStreamEntityDeclaration &other) -
2614{ -
2615 *this = other;
executed (the execution status of this line is deduced): *this = other;
-
2616}
executed: }
Execution Count:10
10
2617 -
2618/*! -
2619 Assigns \a other to this entity declaration. -
2620 */ -
2621QXmlStreamEntityDeclaration& QXmlStreamEntityDeclaration::operator=(const QXmlStreamEntityDeclaration &other) -
2622{ -
2623 m_name = other.m_name;
executed (the execution status of this line is deduced): m_name = other.m_name;
-
2624 m_notationName = other.m_notationName;
executed (the execution status of this line is deduced): m_notationName = other.m_notationName;
-
2625 m_systemId = other.m_systemId;
executed (the execution status of this line is deduced): m_systemId = other.m_systemId;
-
2626 m_publicId = other.m_publicId;
executed (the execution status of this line is deduced): m_publicId = other.m_publicId;
-
2627 m_value = other.m_value;
executed (the execution status of this line is deduced): m_value = other.m_value;
-
2628 return *this;
executed: return *this;
Execution Count:10
10
2629} -
2630 -
2631/*! -
2632 Destructs this entity declaration. -
2633*/ -
2634QXmlStreamEntityDeclaration::~QXmlStreamEntityDeclaration() -
2635{ -
2636} -
2637 -
2638/*! \fn QStringRef QXmlStreamEntityDeclaration::name() const -
2639 -
2640Returns the entity name. -
2641*/ -
2642/*! \fn QStringRef QXmlStreamEntityDeclaration::notationName() const -
2643 -
2644Returns the notation name. -
2645*/ -
2646/*! \fn QStringRef QXmlStreamEntityDeclaration::systemId() const -
2647 -
2648Returns the system identifier. -
2649*/ -
2650/*! \fn QStringRef QXmlStreamEntityDeclaration::publicId() const -
2651 -
2652Returns the public identifier. -
2653*/ -
2654/*! \fn QStringRef QXmlStreamEntityDeclaration::value() const -
2655 -
2656Returns the entity's value. -
2657*/ -
2658 -
2659/*! \fn bool QXmlStreamEntityDeclaration::operator==(const QXmlStreamEntityDeclaration &other) const -
2660 -
2661 Compares this entity declaration with \a other and returns true if -
2662 they are equal; otherwise returns false. -
2663 */ -
2664/*! \fn bool QXmlStreamEntityDeclaration::operator!=(const QXmlStreamEntityDeclaration &other) const -
2665 -
2666 Compares this entity declaration with \a other and returns true if -
2667 they are not equal; otherwise returns false. -
2668 */ -
2669 -
2670/*! Returns the value of the attribute \a name in the namespace -
2671 described with \a namespaceUri, or an empty string reference if the -
2672 attribute is not defined. The \a namespaceUri can be empty. -
2673 */ -
2674QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, const QString &name) const -
2675{ -
2676 for (int i = 0; i < size(); ++i) {
evaluated: i < size()
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:6
6-28
2677 const QXmlStreamAttribute &attribute = at(i);
executed (the execution status of this line is deduced): const QXmlStreamAttribute &attribute = at(i);
-
2678 if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
evaluated: attribute.name() == name
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:21
evaluated: attribute.namespaceUri() == namespaceUri
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
2-21
2679 return attribute.value();
executed: return attribute.value();
Execution Count:5
5
2680 }
executed: }
Execution Count:23
23
2681 return QStringRef();
executed: return QStringRef();
Execution Count:6
6
2682} -
2683 -
2684/*!\overload -
2685 Returns the value of the attribute \a name in the namespace -
2686 described with \a namespaceUri, or an empty string reference if the -
2687 attribute is not defined. The \a namespaceUri can be empty. -
2688 */ -
2689QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1String name) const -
2690{ -
2691 for (int i = 0; i < size(); ++i) {
never evaluated: i < size()
0
2692 const QXmlStreamAttribute &attribute = at(i);
never executed (the execution status of this line is deduced): const QXmlStreamAttribute &attribute = at(i);
-
2693 if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
never evaluated: attribute.name() == name
never evaluated: attribute.namespaceUri() == namespaceUri
0
2694 return attribute.value();
never executed: return attribute.value();
0
2695 }
never executed: }
0
2696 return QStringRef();
never executed: return QStringRef();
0
2697} -
2698 -
2699/*!\overload -
2700 Returns the value of the attribute \a name in the namespace -
2701 described with \a namespaceUri, or an empty string reference if the -
2702 attribute is not defined. The \a namespaceUri can be empty. -
2703 */ -
2704QStringRef QXmlStreamAttributes::value(QLatin1String namespaceUri, QLatin1String name) const -
2705{ -
2706 for (int i = 0; i < size(); ++i) {
never evaluated: i < size()
0
2707 const QXmlStreamAttribute &attribute = at(i);
never executed (the execution status of this line is deduced): const QXmlStreamAttribute &attribute = at(i);
-
2708 if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
never evaluated: attribute.name() == name
never evaluated: attribute.namespaceUri() == namespaceUri
0
2709 return attribute.value();
never executed: return attribute.value();
0
2710 }
never executed: }
0
2711 return QStringRef();
never executed: return QStringRef();
0
2712} -
2713 -
2714/*!\overload -
2715 -
2716 Returns the value of the attribute with qualified name \a -
2717 qualifiedName , or an empty string reference if the attribute is not -
2718 defined. A qualified name is the raw name of an attribute in the XML -
2719 data. It consists of the namespace prefix, followed by colon, -
2720 followed by the attribute's local name. Since the namespace prefix -
2721 is not unique (the same prefix can point to different namespaces and -
2722 different prefixes can point to the same namespace), you shouldn't -
2723 use qualified names, but a resolved namespaceUri and the attribute's -
2724 local name. -
2725 */ -
2726QStringRef QXmlStreamAttributes::value(const QString &qualifiedName) const -
2727{ -
2728 for (int i = 0; i < size(); ++i) {
evaluated: i < size()
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:3
3-19
2729 const QXmlStreamAttribute &attribute = at(i);
executed (the execution status of this line is deduced): const QXmlStreamAttribute &attribute = at(i);
-
2730 if (attribute.qualifiedName() == qualifiedName)
evaluated: attribute.qualifiedName() == qualifiedName
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:14
5-14
2731 return attribute.value();
executed: return attribute.value();
Execution Count:5
5
2732 }
executed: }
Execution Count:14
14
2733 return QStringRef();
executed: return QStringRef();
Execution Count:3
3
2734} -
2735 -
2736/*!\overload -
2737 -
2738 Returns the value of the attribute with qualified name \a -
2739 qualifiedName , or an empty string reference if the attribute is not -
2740 defined. A qualified name is the raw name of an attribute in the XML -
2741 data. It consists of the namespace prefix, followed by colon, -
2742 followed by the attribute's local name. Since the namespace prefix -
2743 is not unique (the same prefix can point to different namespaces and -
2744 different prefixes can point to the same namespace), you shouldn't -
2745 use qualified names, but a resolved namespaceUri and the attribute's -
2746 local name. -
2747 */ -
2748QStringRef QXmlStreamAttributes::value(QLatin1String qualifiedName) const -
2749{ -
2750 for (int i = 0; i < size(); ++i) {
evaluated: i < size()
TRUEFALSE
yes
Evaluation Count:29257
yes
Evaluation Count:857
857-29257
2751 const QXmlStreamAttribute &attribute = at(i);
executed (the execution status of this line is deduced): const QXmlStreamAttribute &attribute = at(i);
-
2752 if (attribute.qualifiedName() == qualifiedName)
evaluated: attribute.qualifiedName() == qualifiedName
TRUEFALSE
yes
Evaluation Count:14123
yes
Evaluation Count:15134
14123-15134
2753 return attribute.value();
executed: return attribute.value();
Execution Count:14123
14123
2754 }
executed: }
Execution Count:15134
15134
2755 return QStringRef();
executed: return QStringRef();
Execution Count:857
857
2756} -
2757 -
2758/*!Appends a new attribute with \a name in the namespace -
2759 described with \a namespaceUri, and value \a value. The \a -
2760 namespaceUri can be empty. -
2761 */ -
2762void QXmlStreamAttributes::append(const QString &namespaceUri, const QString &name, const QString &value) -
2763{ -
2764 append(QXmlStreamAttribute(namespaceUri, name, value));
never executed (the execution status of this line is deduced): append(QXmlStreamAttribute(namespaceUri, name, value));
-
2765}
never executed: }
0
2766 -
2767/*!\overload -
2768 Appends a new attribute with qualified name \a qualifiedName and -
2769 value \a value. -
2770 */ -
2771void QXmlStreamAttributes::append(const QString &qualifiedName, const QString &value) -
2772{ -
2773 append(QXmlStreamAttribute(qualifiedName, value));
never executed (the execution status of this line is deduced): append(QXmlStreamAttribute(qualifiedName, value));
-
2774}
never executed: }
0
2775 -
2776#ifndef QT_NO_XMLSTREAMREADER -
2777 -
2778/*! \fn bool QXmlStreamReader::isStartDocument() const -
2779 Returns true if tokenType() equals \l StartDocument; otherwise returns false. -
2780*/ -
2781/*! \fn bool QXmlStreamReader::isEndDocument() const -
2782 Returns true if tokenType() equals \l EndDocument; otherwise returns false. -
2783*/ -
2784/*! \fn bool QXmlStreamReader::isStartElement() const -
2785 Returns true if tokenType() equals \l StartElement; otherwise returns false. -
2786*/ -
2787/*! \fn bool QXmlStreamReader::isEndElement() const -
2788 Returns true if tokenType() equals \l EndElement; otherwise returns false. -
2789*/ -
2790/*! \fn bool QXmlStreamReader::isCharacters() const -
2791 Returns true if tokenType() equals \l Characters; otherwise returns false. -
2792 -
2793 \sa isWhitespace(), isCDATA() -
2794*/ -
2795/*! \fn bool QXmlStreamReader::isComment() const -
2796 Returns true if tokenType() equals \l Comment; otherwise returns false. -
2797*/ -
2798/*! \fn bool QXmlStreamReader::isDTD() const -
2799 Returns true if tokenType() equals \l DTD; otherwise returns false. -
2800*/ -
2801/*! \fn bool QXmlStreamReader::isEntityReference() const -
2802 Returns true if tokenType() equals \l EntityReference; otherwise returns false. -
2803*/ -
2804/*! \fn bool QXmlStreamReader::isProcessingInstruction() const -
2805 Returns true if tokenType() equals \l ProcessingInstruction; otherwise returns false. -
2806*/ -
2807 -
2808/*! Returns true if the reader reports characters that only consist -
2809 of white-space; otherwise returns false. -
2810 -
2811 \sa isCharacters(), text() -
2812*/ -
2813bool QXmlStreamReader::isWhitespace() const -
2814{ -
2815 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2816 return d->type == QXmlStreamReader::Characters && d->isWhitespace;
executed: return d->type == QXmlStreamReader::Characters && d->isWhitespace;
Execution Count:1891
1891
2817} -
2818 -
2819/*! Returns true if the reader reports characters that stem from a -
2820 CDATA section; otherwise returns false. -
2821 -
2822 \sa isCharacters(), text() -
2823*/ -
2824bool QXmlStreamReader::isCDATA() const -
2825{ -
2826 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2827 return d->type == QXmlStreamReader::Characters && d->isCDATA;
executed: return d->type == QXmlStreamReader::Characters && d->isCDATA;
Execution Count:1891
1891
2828} -
2829 -
2830 -
2831 -
2832/*! -
2833 Returns true if this document has been declared standalone in the -
2834 XML declaration; otherwise returns false. -
2835 -
2836 If no XML declaration has been parsed, this function returns false. -
2837 */ -
2838bool QXmlStreamReader::isStandaloneDocument() const -
2839{ -
2840 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2841 return d->standalone;
executed: return d->standalone;
Execution Count:74
74
2842} -
2843 -
2844 -
2845/*! -
2846 \since 4.4 -
2847 -
2848 If the tokenType() is \l StartDocument, this function returns the -
2849 version string as specified in the XML declaration. -
2850 Otherwise an empty string is returned. -
2851 */ -
2852QStringRef QXmlStreamReader::documentVersion() const -
2853{ -
2854 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2855 if (d->type == QXmlStreamReader::StartDocument)
evaluated: d->type == QXmlStreamReader::StartDocument
TRUEFALSE
yes
Evaluation Count:129
yes
Evaluation Count:1817
129-1817
2856 return d->documentVersion;
executed: return d->documentVersion;
Execution Count:129
129
2857 return QStringRef();
executed: return QStringRef();
Execution Count:1817
1817
2858} -
2859 -
2860/*! -
2861 \since 4.4 -
2862 -
2863 If the tokenType() is \l StartDocument, this function returns the -
2864 encoding string as specified in the XML declaration. -
2865 Otherwise an empty string is returned. -
2866 */ -
2867QStringRef QXmlStreamReader::documentEncoding() const -
2868{ -
2869 Q_D(const QXmlStreamReader);
executed (the execution status of this line is deduced): const QXmlStreamReaderPrivate * const d = d_func();
-
2870 if (d->type == QXmlStreamReader::StartDocument)
evaluated: d->type == QXmlStreamReader::StartDocument
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:1817
80-1817
2871 return d->documentEncoding;
executed: return d->documentEncoding;
Execution Count:80
80
2872 return QStringRef();
executed: return QStringRef();
Execution Count:1817
1817
2873} -
2874 -
2875#endif // QT_NO_XMLSTREAMREADER -
2876 -
2877/*! -
2878 \class QXmlStreamWriter -
2879 \inmodule QtCore -
2880 \since 4.3 -
2881 \reentrant -
2882 -
2883 \brief The QXmlStreamWriter class provides an XML writer with a -
2884 simple streaming API. -
2885 -
2886 \ingroup xml-tools -
2887 -
2888 QXmlStreamWriter is the counterpart to QXmlStreamReader for writing -
2889 XML. Like its related class, it operates on a QIODevice specified -
2890 with setDevice(). The API is simple and straightforward: for every -
2891 XML token or event you want to write, the writer provides a -
2892 specialized function. -
2893 -
2894 You start a document with writeStartDocument() and end it with -
2895 writeEndDocument(). This will implicitly close all remaining open -
2896 tags. -
2897 -
2898 Element tags are opened with writeStartElement() followed by -
2899 writeAttribute() or writeAttributes(), element content, and then -
2900 writeEndElement(). A shorter form writeEmptyElement() can be used -
2901 to write empty elements, followed by writeAttributes(). -
2902 -
2903 Element content consists of either characters, entity references or -
2904 nested elements. It is written with writeCharacters(), which also -
2905 takes care of escaping all forbidden characters and character -
2906 sequences, writeEntityReference(), or subsequent calls to -
2907 writeStartElement(). A convenience method writeTextElement() can be -
2908 used for writing terminal elements that contain nothing but text. -
2909 -
2910 The following abridged code snippet shows the basic use of the class -
2911 to write formatted XML with indentation: -
2912 -
2913 \snippet qxmlstreamwriter/main.cpp start stream -
2914 \dots -
2915 \snippet qxmlstreamwriter/main.cpp write element -
2916 \dots -
2917 \snippet qxmlstreamwriter/main.cpp finish stream -
2918 -
2919 QXmlStreamWriter takes care of prefixing namespaces, all you have to -
2920 do is specify the \c namespaceUri when writing elements or -
2921 attributes. If you must conform to certain prefixes, you can force -
2922 the writer to use them by declaring the namespaces manually with -
2923 either writeNamespace() or writeDefaultNamespace(). Alternatively, -
2924 you can bypass the stream writer's namespace support and use -
2925 overloaded methods that take a qualified name instead. The namespace -
2926 \e http://www.w3.org/XML/1998/namespace is implicit and mapped to the -
2927 prefix \e xml. -
2928 -
2929 The stream writer can automatically format the generated XML data by -
2930 adding line-breaks and indentation to empty sections between -
2931 elements, making the XML data more readable for humans and easier to -
2932 work with for most source code management systems. The feature can -
2933 be turned on with the \l autoFormatting property, and customized -
2934 with the \l autoFormattingIndent property. -
2935 -
2936 Other functions are writeCDATA(), writeComment(), -
2937 writeProcessingInstruction(), and writeDTD(). Chaining of XML -
2938 streams is supported with writeCurrentToken(). -
2939 -
2940 By default, QXmlStreamWriter encodes XML in UTF-8. Different -
2941 encodings can be enforced using setCodec(). -
2942 -
2943 If an error occurs while writing to the underlying device, hasError() -
2944 starts returning true and subsequent writes are ignored. -
2945 -
2946 The \l{QXmlStream Bookmarks Example} illustrates how to use a -
2947 stream writer to write an XML bookmark file (XBEL) that -
2948 was previously read in by a QXmlStreamReader. -
2949 -
2950*/ -
2951 -
2952#ifndef QT_NO_XMLSTREAMWRITER -
2953 -
2954class QXmlStreamWriterPrivate : public QXmlStreamPrivateTagStack { -
2955 QXmlStreamWriter *q_ptr; -
2956 Q_DECLARE_PUBLIC(QXmlStreamWriter) -
2957public: -
2958 QXmlStreamWriterPrivate(QXmlStreamWriter *q); -
2959 ~QXmlStreamWriterPrivate() { -
2960 if (deleteDevice)
evaluated: deleteDevice
TRUEFALSE
yes
Evaluation Count:710
yes
Evaluation Count:21
21-710
2961 delete device;
executed: delete device;
Execution Count:710
710
2962#ifndef QT_NO_TEXTCODEC -
2963 delete encoder;
executed (the execution status of this line is deduced): delete encoder;
-
2964#endif -
2965 }
executed: }
Execution Count:731
731
2966 -
2967 void write(const QStringRef &); -
2968 void write(const QString &); -
2969 void writeEscaped(const QString &, bool escapeWhitespace = false); -
2970 void write(const char *s, int len); -
2971 template <int N> void write(const char (&s)[N]) { write(s, N - 1); }
executed: }
Execution Count:8713
8713
2972 bool finishStartElement(bool contents = true); -
2973 void writeStartElement(const QString &namespaceUri, const QString &name); -
2974 QIODevice *device; -
2975 QString *stringDevice; -
2976 uint deleteDevice :1; -
2977 uint inStartElement :1; -
2978 uint inEmptyElement :1; -
2979 uint lastWasStartElement :1; -
2980 uint wroteSomething :1; -
2981 uint hasError :1; -
2982 uint autoFormatting :1; -
2983 uint isCodecASCIICompatible :1; -
2984 QByteArray autoFormattingIndent; -
2985 NamespaceDeclaration emptyNamespace; -
2986 int lastNamespaceDeclaration; -
2987 -
2988#ifndef QT_NO_TEXTCODEC -
2989 QTextCodec *codec; -
2990 QTextEncoder *encoder; -
2991#endif -
2992 void checkIfASCIICompatibleCodec(); -
2993 -
2994 NamespaceDeclaration &findNamespace(const QString &namespaceUri, bool writeDeclaration = false, bool noDefault = false); -
2995 void writeNamespaceDeclaration(const NamespaceDeclaration &namespaceDeclaration); -
2996 -
2997 int namespacePrefixCount; -
2998 -
2999 void indent(int level); -
3000}; -
3001 -
3002 -
3003QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) -
3004 :autoFormattingIndent(4, ' ') -
3005{ -
3006 q_ptr = q;
executed (the execution status of this line is deduced): q_ptr = q;
-
3007 device = 0;
executed (the execution status of this line is deduced): device = 0;
-
3008 stringDevice = 0;
executed (the execution status of this line is deduced): stringDevice = 0;
-
3009 deleteDevice = false;
executed (the execution status of this line is deduced): deleteDevice = false;
-
3010#ifndef QT_NO_TEXTCODEC -
3011 codec = QTextCodec::codecForMib(106); // utf8
executed (the execution status of this line is deduced): codec = QTextCodec::codecForMib(106);
-
3012 encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8
executed (the execution status of this line is deduced): encoder = codec->makeEncoder(QTextCodec::IgnoreHeader);
-
3013#endif -
3014 checkIfASCIICompatibleCodec();
executed (the execution status of this line is deduced): checkIfASCIICompatibleCodec();
-
3015 inStartElement = inEmptyElement = false;
executed (the execution status of this line is deduced): inStartElement = inEmptyElement = false;
-
3016 wroteSomething = false;
executed (the execution status of this line is deduced): wroteSomething = false;
-
3017 hasError = false;
executed (the execution status of this line is deduced): hasError = false;
-
3018 lastWasStartElement = false;
executed (the execution status of this line is deduced): lastWasStartElement = false;
-
3019 lastNamespaceDeclaration = 1;
executed (the execution status of this line is deduced): lastNamespaceDeclaration = 1;
-
3020 autoFormatting = false;
executed (the execution status of this line is deduced): autoFormatting = false;
-
3021 namespacePrefixCount = 0;
executed (the execution status of this line is deduced): namespacePrefixCount = 0;
-
3022}
executed: }
Execution Count:731
731
3023 -
3024void QXmlStreamWriterPrivate::checkIfASCIICompatibleCodec() -
3025{ -
3026#ifndef QT_NO_TEXTCODEC -
3027 Q_ASSERT(encoder);
executed (the execution status of this line is deduced): qt_noop();
-
3028 // assumes ASCII-compatibility for all 8-bit encodings -
3029 const QByteArray bytes = encoder->fromUnicode(QStringLiteral(" "));
executed (the execution status of this line is deduced): const QByteArray bytes = encoder->fromUnicode(QString::fromUtf8("" " " "", sizeof(" ") - 1));
-
3030 isCodecASCIICompatible = (bytes.count() == 1);
executed (the execution status of this line is deduced): isCodecASCIICompatible = (bytes.count() == 1);
-
3031#else -
3032 isCodecASCIICompatible = true; -
3033#endif -
3034}
executed: }
Execution Count:738
738
3035 -
3036void QXmlStreamWriterPrivate::write(const QStringRef &s) -
3037{ -
3038 if (device) {
evaluated: device
TRUEFALSE
yes
Evaluation Count:2631
yes
Evaluation Count:8
8-2631
3039 if (hasError)
evaluated: hasError
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2627
4-2627
3040 return;
executed: return;
Execution Count:4
4
3041#ifdef QT_NO_TEXTCODEC -
3042 QByteArray bytes = s.toLatin1(); -
3043#else -
3044 QByteArray bytes = encoder->fromUnicode(s.constData(), s.size());
executed (the execution status of this line is deduced): QByteArray bytes = encoder->fromUnicode(s.constData(), s.size());
-
3045#endif -
3046 if (device->write(bytes) != bytes.size())
evaluated: device->write(bytes) != bytes.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2626
1-2626
3047 hasError = true;
executed: hasError = true;
Execution Count:1
1
3048 }
executed: }
Execution Count:2627
2627
3049 else if (stringDevice)
partially evaluated: stringDevice
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
3050 s.appendTo(stringDevice);
executed: s.appendTo(stringDevice);
Execution Count:8
8
3051 else -
3052 qWarning("QXmlStreamWriter: No device");
never executed: QMessageLogger("xml/qxmlstream.cpp", 3052, __PRETTY_FUNCTION__).warning("QXmlStreamWriter: No device");
0
3053} -
3054 -
3055void QXmlStreamWriterPrivate::write(const QString &s) -
3056{ -
3057 if (device) {
evaluated: device
TRUEFALSE
yes
Evaluation Count:4898
yes
Evaluation Count:72
72-4898
3058 if (hasError)
evaluated: hasError
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4897
1-4897
3059 return;
executed: return;
Execution Count:1
1
3060#ifdef QT_NO_TEXTCODEC -
3061 QByteArray bytes = s.toLatin1(); -
3062#else -
3063 QByteArray bytes = encoder->fromUnicode(s);
executed (the execution status of this line is deduced): QByteArray bytes = encoder->fromUnicode(s);
-
3064#endif -
3065 if (device->write(bytes) != bytes.size())
evaluated: device->write(bytes) != bytes.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4896
1-4896
3066 hasError = true;
executed: hasError = true;
Execution Count:1
1
3067 }
executed: }
Execution Count:4897
4897
3068 else if (stringDevice)
partially evaluated: stringDevice
TRUEFALSE
yes
Evaluation Count:72
no
Evaluation Count:0
0-72
3069 stringDevice->append(s);
executed: stringDevice->append(s);
Execution Count:72
72
3070 else -
3071 qWarning("QXmlStreamWriter: No device");
never executed: QMessageLogger("xml/qxmlstream.cpp", 3071, __PRETTY_FUNCTION__).warning("QXmlStreamWriter: No device");
0
3072} -
3073 -
3074void QXmlStreamWriterPrivate::writeEscaped(const QString &s, bool escapeWhitespace) -
3075{ -
3076 QString escaped;
executed (the execution status of this line is deduced): QString escaped;
-
3077 escaped.reserve(s.size());
executed (the execution status of this line is deduced): escaped.reserve(s.size());
-
3078 for ( int i = 0; i < s.size(); ++i ) {
evaluated: i < s.size()
TRUEFALSE
yes
Evaluation Count:20194
yes
Evaluation Count:3310
3310-20194
3079 QChar c = s.at(i);
executed (the execution status of this line is deduced): QChar c = s.at(i);
-
3080 if (c.unicode() == '<' )
evaluated: c.unicode() == '<'
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:20144
50-20144
3081 escaped.append(QLatin1String("&lt;"));
executed: escaped.append(QLatin1String("&lt;"));
Execution Count:50
50
3082 else if (c.unicode() == '>' )
evaluated: c.unicode() == '>'
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:20092
52-20092
3083 escaped.append(QLatin1String("&gt;"));
executed: escaped.append(QLatin1String("&gt;"));
Execution Count:52
52
3084 else if (c.unicode() == '&' )
evaluated: c.unicode() == '&'
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:20063
29-20063
3085 escaped.append(QLatin1String("&amp;"));
executed: escaped.append(QLatin1String("&amp;"));
Execution Count:29
29
3086 else if (c.unicode() == '\"' )
evaluated: c.unicode() == '\"'
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:20042
21-20042
3087 escaped.append(QLatin1String("&quot;"));
executed: escaped.append(QLatin1String("&quot;"));
Execution Count:21
21
3088 else if (escapeWhitespace && c.isSpace()) {
evaluated: escapeWhitespace
TRUEFALSE
yes
Evaluation Count:3440
yes
Evaluation Count:16602
evaluated: c.isSpace()
TRUEFALSE
yes
Evaluation Count:173
yes
Evaluation Count:3267
173-16602
3089 if (c.unicode() == '\n')
evaluated: c.unicode() == '\n'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:171
2-171
3090 escaped.append(QLatin1String("&#10;"));
executed: escaped.append(QLatin1String("&#10;"));
Execution Count:2
2
3091 else if (c.unicode() == '\r')
evaluated: c.unicode() == '\r'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:169
2-169
3092 escaped.append(QLatin1String("&#13;"));
executed: escaped.append(QLatin1String("&#13;"));
Execution Count:2
2
3093 else if (c.unicode() == '\t')
evaluated: c.unicode() == '\t'
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:166
3-166
3094 escaped.append(QLatin1String("&#9;"));
executed: escaped.append(QLatin1String("&#9;"));
Execution Count:3
3
3095 else -
3096 escaped += c;
executed: escaped += c;
Execution Count:166
166
3097 } else { -
3098 escaped += QChar(c);
executed (the execution status of this line is deduced): escaped += QChar(c);
-
3099 }
executed: }
Execution Count:19869
19869
3100 } -
3101 write(escaped);
executed (the execution status of this line is deduced): write(escaped);
-
3102}
executed: }
Execution Count:3310
3310
3103 -
3104// Converts from ASCII to output encoding -
3105void QXmlStreamWriterPrivate::write(const char *s, int len) -
3106{ -
3107 if (device) {
evaluated: device
TRUEFALSE
yes
Evaluation Count:8771
yes
Evaluation Count:64
64-8771
3108 if (hasError)
evaluated: hasError
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8757
14-8757
3109 return;
executed: return;
Execution Count:14
14
3110 if (isCodecASCIICompatible) {
evaluated: isCodecASCIICompatible
TRUEFALSE
yes
Evaluation Count:8753
yes
Evaluation Count:4
4-8753
3111 if (device->write(s, len) != len)
evaluated: device->write(s, len) != len
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:8751
2-8751
3112 hasError = true;
executed: hasError = true;
Execution Count:2
2
3113 return;
executed: return;
Execution Count:8753
8753
3114 } -
3115 }
executed: }
Execution Count:4
4
3116 -
3117 write(QString::fromLatin1(s, len));
executed (the execution status of this line is deduced): write(QString::fromLatin1(s, len));
-
3118}
executed: }
Execution Count:68
68
3119 -
3120void QXmlStreamWriterPrivate::writeNamespaceDeclaration(const NamespaceDeclaration &namespaceDeclaration) { -
3121 if (namespaceDeclaration.prefix.isEmpty()) {
partially evaluated: namespaceDeclaration.prefix.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:48
0-48
3122 write(" xmlns=\"");
never executed (the execution status of this line is deduced): write(" xmlns=\"");
-
3123 write(namespaceDeclaration.namespaceUri);
never executed (the execution status of this line is deduced): write(namespaceDeclaration.namespaceUri);
-
3124 write("\"");
never executed (the execution status of this line is deduced): write("\"");
-
3125 } else {
never executed: }
0
3126 write(" xmlns:");
executed (the execution status of this line is deduced): write(" xmlns:");
-
3127 write(namespaceDeclaration.prefix);
executed (the execution status of this line is deduced): write(namespaceDeclaration.prefix);
-
3128 write("=\"");
executed (the execution status of this line is deduced): write("=\"");
-
3129 write(namespaceDeclaration.namespaceUri);
executed (the execution status of this line is deduced): write(namespaceDeclaration.namespaceUri);
-
3130 write("\"");
executed (the execution status of this line is deduced): write("\"");
-
3131 }
executed: }
Execution Count:48
48
3132} -
3133 -
3134bool QXmlStreamWriterPrivate::finishStartElement(bool contents) -
3135{ -
3136 bool hadSomethingWritten = wroteSomething;
executed (the execution status of this line is deduced): bool hadSomethingWritten = wroteSomething;
-
3137 wroteSomething = contents;
executed (the execution status of this line is deduced): wroteSomething = contents;
-
3138 if (!inStartElement)
evaluated: !inStartElement
TRUEFALSE
yes
Evaluation Count:4993
yes
Evaluation Count:1189
1189-4993
3139 return hadSomethingWritten;
executed: return hadSomethingWritten;
Execution Count:4993
4993
3140 -
3141 if (inEmptyElement) {
evaluated: inEmptyElement
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:1175
14-1175
3142 write("/>");
executed (the execution status of this line is deduced): write("/>");
-
3143 QXmlStreamWriterPrivate::Tag &tag = tagStack_pop();
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate::Tag &tag = tagStack_pop();
-
3144 lastNamespaceDeclaration = tag.namespaceDeclarationsSize;
executed (the execution status of this line is deduced): lastNamespaceDeclaration = tag.namespaceDeclarationsSize;
-
3145 lastWasStartElement = false;
executed (the execution status of this line is deduced): lastWasStartElement = false;
-
3146 } else {
executed: }
Execution Count:14
14
3147 write(">");
executed (the execution status of this line is deduced): write(">");
-
3148 }
executed: }
Execution Count:1175
1175
3149 inStartElement = inEmptyElement = false;
executed (the execution status of this line is deduced): inStartElement = inEmptyElement = false;
-
3150 lastNamespaceDeclaration = namespaceDeclarations.size();
executed (the execution status of this line is deduced): lastNamespaceDeclaration = namespaceDeclarations.size();
-
3151 return hadSomethingWritten;
executed: return hadSomethingWritten;
Execution Count:1189
1189
3152} -
3153 -
3154QXmlStreamPrivateTagStack::NamespaceDeclaration &QXmlStreamWriterPrivate::findNamespace(const QString &namespaceUri, bool writeDeclaration, bool noDefault) -
3155{ -
3156 for (int j = namespaceDeclarations.size() - 1; j >= 0; --j) {
evaluated: j >= 0
TRUEFALSE
yes
Evaluation Count:1583
yes
Evaluation Count:1161
1161-1583
3157 NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations[j];
executed (the execution status of this line is deduced): NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations[j];
-
3158 if (namespaceDeclaration.namespaceUri == namespaceUri) {
evaluated: namespaceDeclaration.namespaceUri == namespaceUri
TRUEFALSE
yes
Evaluation Count:109
yes
Evaluation Count:1474
109-1474
3159 if (!noDefault || !namespaceDeclaration.prefix.isEmpty())
evaluated: !noDefault
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:69
partially evaluated: !namespaceDeclaration.prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:69
no
Evaluation Count:0
0-69
3160 return namespaceDeclaration;
executed: return namespaceDeclaration;
Execution Count:109
109
3161 }
never executed: }
0
3162 }
executed: }
Execution Count:1474
1474
3163 if (namespaceUri.isEmpty())
evaluated: namespaceUri.isEmpty()
TRUEFALSE
yes
Evaluation Count:1142
yes
Evaluation Count:19
19-1142
3164 return emptyNamespace;
executed: return emptyNamespace;
Execution Count:1142
1142
3165 NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
executed (the execution status of this line is deduced): NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
-
3166 if (namespaceUri.isEmpty()) {
partially evaluated: namespaceUri.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
3167 namespaceDeclaration.prefix.clear();
never executed (the execution status of this line is deduced): namespaceDeclaration.prefix.clear();
-
3168 } else {
never executed: }
0
3169 QString s;
executed (the execution status of this line is deduced): QString s;
-
3170 int n = ++namespacePrefixCount;
executed (the execution status of this line is deduced): int n = ++namespacePrefixCount;
-
3171 forever {
executed (the execution status of this line is deduced): for(;;) {
-
3172 s = QLatin1Char('n') + QString::number(n++);
executed (the execution status of this line is deduced): s = QLatin1Char('n') + QString::number(n++);
-
3173 int j = namespaceDeclarations.size() - 2;
executed (the execution status of this line is deduced): int j = namespaceDeclarations.size() - 2;
-
3174 while (j >= 0 && namespaceDeclarations.at(j).prefix != s)
evaluated: j >= 0
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:19
partially evaluated: namespaceDeclarations.at(j).prefix != s
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
0-22
3175 --j;
executed: --j;
Execution Count:22
22
3176 if (j < 0)
partially evaluated: j < 0
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
3177 break;
executed: break;
Execution Count:19
19
3178 }
never executed: }
0
3179 namespaceDeclaration.prefix = addToStringStorage(s);
executed (the execution status of this line is deduced): namespaceDeclaration.prefix = addToStringStorage(s);
-
3180 }
executed: }
Execution Count:19
19
3181 namespaceDeclaration.namespaceUri = addToStringStorage(namespaceUri);
executed (the execution status of this line is deduced): namespaceDeclaration.namespaceUri = addToStringStorage(namespaceUri);
-
3182 if (writeDeclaration)
evaluated: writeDeclaration
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:15
4-15
3183 writeNamespaceDeclaration(namespaceDeclaration);
executed: writeNamespaceDeclaration(namespaceDeclaration);
Execution Count:4
4
3184 return namespaceDeclaration;
executed: return namespaceDeclaration;
Execution Count:19
19
3185} -
3186 -
3187 -
3188 -
3189void QXmlStreamWriterPrivate::indent(int level) -
3190{ -
3191 write("\n");
executed (the execution status of this line is deduced): write("\n");
-
3192 for (int i = level; i > 0; --i)
evaluated: i > 0
TRUEFALSE
yes
Evaluation Count:98
yes
Evaluation Count:80
80-98
3193 write(autoFormattingIndent.constData(), autoFormattingIndent.length());
executed: write(autoFormattingIndent.constData(), autoFormattingIndent.length());
Execution Count:98
98
3194}
executed: }
Execution Count:80
80
3195 -
3196 -
3197/*! -
3198 Constructs a stream writer. -
3199 -
3200 \sa setDevice() -
3201 */ -
3202QXmlStreamWriter::QXmlStreamWriter() -
3203 : d_ptr(new QXmlStreamWriterPrivate(this)) -
3204{ -
3205}
never executed: }
0
3206 -
3207/*! -
3208 Constructs a stream writer that writes into \a device; -
3209 */ -
3210QXmlStreamWriter::QXmlStreamWriter(QIODevice *device) -
3211 : d_ptr(new QXmlStreamWriterPrivate(this)) -
3212{ -
3213 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3214 d->device = device;
executed (the execution status of this line is deduced): d->device = device;
-
3215}
executed: }
Execution Count:19
19
3216 -
3217/*! Constructs a stream writer that writes into \a array. This is the -
3218 same as creating an xml writer that operates on a QBuffer device -
3219 which in turn operates on \a array. -
3220 */ -
3221QXmlStreamWriter::QXmlStreamWriter(QByteArray *array) -
3222 : d_ptr(new QXmlStreamWriterPrivate(this)) -
3223{ -
3224 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3225 d->device = new QBuffer(array);
executed (the execution status of this line is deduced): d->device = new QBuffer(array);
-
3226 d->device->open(QIODevice::WriteOnly);
executed (the execution status of this line is deduced): d->device->open(QIODevice::WriteOnly);
-
3227 d->deleteDevice = true;
executed (the execution status of this line is deduced): d->deleteDevice = true;
-
3228}
executed: }
Execution Count:710
710
3229 -
3230 -
3231/*! Constructs a stream writer that writes into \a string. -
3232 */ -
3233QXmlStreamWriter::QXmlStreamWriter(QString *string) -
3234 : d_ptr(new QXmlStreamWriterPrivate(this)) -
3235{ -
3236 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3237 d->stringDevice = string;
executed (the execution status of this line is deduced): d->stringDevice = string;
-
3238}
executed: }
Execution Count:2
2
3239 -
3240/*! -
3241 Destructor. -
3242*/ -
3243QXmlStreamWriter::~QXmlStreamWriter() -
3244{ -
3245} -
3246 -
3247 -
3248/*! -
3249 Sets the current device to \a device. If you want the stream to -
3250 write into a QByteArray, you can create a QBuffer device. -
3251 -
3252 \sa device() -
3253*/ -
3254void QXmlStreamWriter::setDevice(QIODevice *device) -
3255{ -
3256 Q_D(QXmlStreamWriter);
never executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3257 if (device == d->device)
never evaluated: device == d->device
0
3258 return;
never executed: return;
0
3259 d->stringDevice = 0;
never executed (the execution status of this line is deduced): d->stringDevice = 0;
-
3260 if (d->deleteDevice) {
never evaluated: d->deleteDevice
0
3261 delete d->device;
never executed (the execution status of this line is deduced): delete d->device;
-
3262 d->deleteDevice = false;
never executed (the execution status of this line is deduced): d->deleteDevice = false;
-
3263 }
never executed: }
0
3264 d->device = device;
never executed (the execution status of this line is deduced): d->device = device;
-
3265}
never executed: }
0
3266 -
3267/*! -
3268 Returns the current device associated with the QXmlStreamWriter, -
3269 or 0 if no device has been assigned. -
3270 -
3271 \sa setDevice() -
3272*/ -
3273QIODevice *QXmlStreamWriter::device() const -
3274{ -
3275 Q_D(const QXmlStreamWriter);
never executed (the execution status of this line is deduced): const QXmlStreamWriterPrivate * const d = d_func();
-
3276 return d->device;
never executed: return d->device;
0
3277} -
3278 -
3279 -
3280#ifndef QT_NO_TEXTCODEC -
3281/*! -
3282 Sets the codec for this stream to \a codec. The codec is used for -
3283 encoding any data that is written. By default, QXmlStreamWriter -
3284 uses UTF-8. -
3285 -
3286 The encoding information is stored in the initial xml tag which -
3287 gets written when you call writeStartDocument(). Call this -
3288 function before calling writeStartDocument(). -
3289 -
3290 \sa codec() -
3291*/ -
3292void QXmlStreamWriter::setCodec(QTextCodec *codec) -
3293{ -
3294 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3295 if (codec) {
partially evaluated: codec
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
3296 d->codec = codec;
executed (the execution status of this line is deduced): d->codec = codec;
-
3297 delete d->encoder;
executed (the execution status of this line is deduced): delete d->encoder;
-
3298 d->encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8
executed (the execution status of this line is deduced): d->encoder = codec->makeEncoder(QTextCodec::IgnoreHeader);
-
3299 d->checkIfASCIICompatibleCodec();
executed (the execution status of this line is deduced): d->checkIfASCIICompatibleCodec();
-
3300 }
executed: }
Execution Count:7
7
3301}
executed: }
Execution Count:7
7
3302 -
3303/*! -
3304 Sets the codec for this stream to the QTextCodec for the encoding -
3305 specified by \a codecName. Common values for \c codecName include -
3306 "ISO 8859-1", "UTF-8", and "UTF-16". If the encoding isn't -
3307 recognized, nothing happens. -
3308 -
3309 \sa QTextCodec::codecForName() -
3310*/ -
3311void QXmlStreamWriter::setCodec(const char *codecName) -
3312{ -
3313 setCodec(QTextCodec::codecForName(codecName));
executed (the execution status of this line is deduced): setCodec(QTextCodec::codecForName(codecName));
-
3314}
executed: }
Execution Count:1
1
3315 -
3316/*! -
3317 Returns the codec that is currently assigned to the stream. -
3318 -
3319 \sa setCodec() -
3320*/ -
3321QTextCodec *QXmlStreamWriter::codec() const -
3322{ -
3323 Q_D(const QXmlStreamWriter);
never executed (the execution status of this line is deduced): const QXmlStreamWriterPrivate * const d = d_func();
-
3324 return d->codec;
never executed: return d->codec;
0
3325} -
3326#endif // QT_NO_TEXTCODEC -
3327 -
3328/*! -
3329 \property QXmlStreamWriter::autoFormatting -
3330 \since 4.4 -
3331 the auto-formatting flag of the stream writer -
3332 -
3333 This property controls whether or not the stream writer -
3334 automatically formats the generated XML data. If enabled, the -
3335 writer automatically adds line-breaks and indentation to empty -
3336 sections between elements (ignorable whitespace). The main purpose -
3337 of auto-formatting is to split the data into several lines, and to -
3338 increase readability for a human reader. The indentation depth can -
3339 be controlled through the \l autoFormattingIndent property. -
3340 -
3341 By default, auto-formatting is disabled. -
3342*/ -
3343 -
3344/*! -
3345 \since 4.4 -
3346 -
3347 Enables auto formatting if \a enable is \c true, otherwise -
3348 disables it. -
3349 -
3350 The default value is \c false. -
3351 */ -
3352void QXmlStreamWriter::setAutoFormatting(bool enable) -
3353{ -
3354 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3355 d->autoFormatting = enable;
executed (the execution status of this line is deduced): d->autoFormatting = enable;
-
3356}
executed: }
Execution Count:15
15
3357 -
3358/*! -
3359 \since 4.4 -
3360 -
3361 Returns \c true if auto formattting is enabled, otherwise \c false. -
3362 */ -
3363bool QXmlStreamWriter::autoFormatting() const -
3364{ -
3365 Q_D(const QXmlStreamWriter);
never executed (the execution status of this line is deduced): const QXmlStreamWriterPrivate * const d = d_func();
-
3366 return d->autoFormatting;
never executed: return d->autoFormatting;
0
3367} -
3368 -
3369/*! -
3370 \property QXmlStreamWriter::autoFormattingIndent -
3371 \since 4.4 -
3372 -
3373 \brief the number of spaces or tabs used for indentation when -
3374 auto-formatting is enabled. Positive numbers indicate spaces, -
3375 negative numbers tabs. -
3376 -
3377 The default indentation is 4. -
3378 -
3379 \sa autoFormatting -
3380*/ -
3381 -
3382 -
3383void QXmlStreamWriter::setAutoFormattingIndent(int spacesOrTabs) -
3384{ -
3385 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3386 d->autoFormattingIndent = QByteArray(qAbs(spacesOrTabs), spacesOrTabs >= 0 ? ' ' : '\t');
executed (the execution status of this line is deduced): d->autoFormattingIndent = QByteArray(qAbs(spacesOrTabs), spacesOrTabs >= 0 ? ' ' : '\t');
-
3387}
executed: }
Execution Count:9
9
3388 -
3389int QXmlStreamWriter::autoFormattingIndent() const -
3390{ -
3391 Q_D(const QXmlStreamWriter);
executed (the execution status of this line is deduced): const QXmlStreamWriterPrivate * const d = d_func();
-
3392 return d->autoFormattingIndent.count(' ') - d->autoFormattingIndent.count('\t');
executed: return d->autoFormattingIndent.count(' ') - d->autoFormattingIndent.count('\t');
Execution Count:1
1
3393} -
3394 -
3395/*! -
3396 Returns \c true if the stream failed to write to the underlying device. -
3397 -
3398 The error status is never reset. Writes happening after the error -
3399 occurred are ignored, even if the error condition is cleared. -
3400 */ -
3401bool QXmlStreamWriter::hasError() const -
3402{ -
3403 Q_D(const QXmlStreamWriter);
executed (the execution status of this line is deduced): const QXmlStreamWriterPrivate * const d = d_func();
-
3404 return d->hasError;
executed: return d->hasError;
Execution Count:6
6
3405} -
3406 -
3407/*! -
3408 \overload -
3409 Writes an attribute with \a qualifiedName and \a value. -
3410 -
3411 -
3412 This function can only be called after writeStartElement() before -
3413 any content is written, or after writeEmptyElement(). -
3414 */ -
3415void QXmlStreamWriter::writeAttribute(const QString &qualifiedName, const QString &value) -
3416{ -
3417 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3418 Q_ASSERT(d->inStartElement);
executed (the execution status of this line is deduced): qt_noop();
-
3419 Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1);
executed (the execution status of this line is deduced): qt_noop();
-
3420 d->write(" ");
executed (the execution status of this line is deduced): d->write(" ");
-
3421 d->write(qualifiedName);
executed (the execution status of this line is deduced): d->write(qualifiedName);
-
3422 d->write("=\"");
executed (the execution status of this line is deduced): d->write("=\"");
-
3423 d->writeEscaped(value, true);
executed (the execution status of this line is deduced): d->writeEscaped(value, true);
-
3424 d->write("\"");
executed (the execution status of this line is deduced): d->write("\"");
-
3425}
executed: }
Execution Count:439
439
3426 -
3427/*! Writes an attribute with \a name and \a value, prefixed for -
3428 the specified \a namespaceUri. If the namespace has not been -
3429 declared yet, QXmlStreamWriter will generate a namespace declaration -
3430 for it. -
3431 -
3432 This function can only be called after writeStartElement() before -
3433 any content is written, or after writeEmptyElement(). -
3434 */ -
3435void QXmlStreamWriter::writeAttribute(const QString &namespaceUri, const QString &name, const QString &value) -
3436{ -
3437 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3438 Q_ASSERT(d->inStartElement);
executed (the execution status of this line is deduced): qt_noop();
-
3439 Q_ASSERT(!name.contains(QLatin1Char(':')));
executed (the execution status of this line is deduced): qt_noop();
-
3440 QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->findNamespace(namespaceUri, true, true);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->findNamespace(namespaceUri, true, true);
-
3441 d->write(" ");
executed (the execution status of this line is deduced): d->write(" ");
-
3442 if (!namespaceDeclaration.prefix.isEmpty()) {
partially evaluated: !namespaceDeclaration.prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:73
no
Evaluation Count:0
0-73
3443 d->write(namespaceDeclaration.prefix);
executed (the execution status of this line is deduced): d->write(namespaceDeclaration.prefix);
-
3444 d->write(":");
executed (the execution status of this line is deduced): d->write(":");
-
3445 }
executed: }
Execution Count:73
73
3446 d->write(name);
executed (the execution status of this line is deduced): d->write(name);
-
3447 d->write("=\"");
executed (the execution status of this line is deduced): d->write("=\"");
-
3448 d->writeEscaped(value, true);
executed (the execution status of this line is deduced): d->writeEscaped(value, true);
-
3449 d->write("\"");
executed (the execution status of this line is deduced): d->write("\"");
-
3450}
executed: }
Execution Count:73
73
3451 -
3452/*! -
3453 \overload -
3454 -
3455 Writes the \a attribute. -
3456 -
3457 This function can only be called after writeStartElement() before -
3458 any content is written, or after writeEmptyElement(). -
3459 */ -
3460void QXmlStreamWriter::writeAttribute(const QXmlStreamAttribute& attribute) -
3461{ -
3462 if (attribute.namespaceUri().isEmpty())
evaluated: attribute.namespaceUri().isEmpty()
TRUEFALSE
yes
Evaluation Count:433
yes
Evaluation Count:34
34-433
3463 writeAttribute(attribute.qualifiedName().toString(),
executed: writeAttribute(attribute.qualifiedName().toString(), attribute.value().toString());
Execution Count:433
433
3464 attribute.value().toString());
executed: writeAttribute(attribute.qualifiedName().toString(), attribute.value().toString());
Execution Count:433
433
3465 else -
3466 writeAttribute(attribute.namespaceUri().toString(),
executed: writeAttribute(attribute.namespaceUri().toString(), attribute.name().toString(), attribute.value().toString());
Execution Count:34
34
3467 attribute.name().toString(),
executed: writeAttribute(attribute.namespaceUri().toString(), attribute.name().toString(), attribute.value().toString());
Execution Count:34
34
3468 attribute.value().toString());
executed: writeAttribute(attribute.namespaceUri().toString(), attribute.name().toString(), attribute.value().toString());
Execution Count:34
34
3469} -
3470 -
3471 -
3472/*! Writes the attribute vector \a attributes. If a namespace -
3473 referenced in an attribute not been declared yet, QXmlStreamWriter -
3474 will generate a namespace declaration for it. -
3475 -
3476 This function can only be called after writeStartElement() before -
3477 any content is written, or after writeEmptyElement(). -
3478 -
3479 \sa writeAttribute(), writeNamespace() -
3480 */ -
3481void QXmlStreamWriter::writeAttributes(const QXmlStreamAttributes& attributes) -
3482{ -
3483 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3484 Q_ASSERT(d->inStartElement);
executed (the execution status of this line is deduced): qt_noop();
-
3485 Q_UNUSED(d);
executed (the execution status of this line is deduced): (void)d;;
-
3486 for (int i = 0; i < attributes.size(); ++i)
partially evaluated: i < attributes.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
3487 writeAttribute(attributes.at(i));
never executed: writeAttribute(attributes.at(i));
0
3488}
executed: }
Execution Count:4
4
3489 -
3490 -
3491/*! Writes \a text as CDATA section. If \a text contains the -
3492 forbidden character sequence "]]>", it is split into different CDATA -
3493 sections. -
3494 -
3495 This function mainly exists for completeness. Normally you should -
3496 not need use it, because writeCharacters() automatically escapes all -
3497 non-content characters. -
3498 */ -
3499void QXmlStreamWriter::writeCDATA(const QString &text) -
3500{ -
3501 Q_D(QXmlStreamWriter);
never executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3502 d->finishStartElement();
never executed (the execution status of this line is deduced): d->finishStartElement();
-
3503 QString copy(text);
never executed (the execution status of this line is deduced): QString copy(text);
-
3504 copy.replace(QLatin1String("]]>"), QLatin1String("]]]]><![CDATA[>"));
never executed (the execution status of this line is deduced): copy.replace(QLatin1String("]]>"), QLatin1String("]]]]><![CDATA[>"));
-
3505 d->write("<![CDATA[");
never executed (the execution status of this line is deduced): d->write("<![CDATA[");
-
3506 d->write(copy);
never executed (the execution status of this line is deduced): d->write(copy);
-
3507 d->write("]]>");
never executed (the execution status of this line is deduced): d->write("]]>");
-
3508}
never executed: }
0
3509 -
3510 -
3511/*! Writes \a text. The characters "<", "&", and "\"" are escaped as entity -
3512 references "&lt;", "&amp;, and "&quot;". To avoid the forbidden sequence -
3513 "]]>", ">" is also escaped as "&gt;". -
3514 -
3515 \sa writeEntityReference() -
3516 */ -
3517void QXmlStreamWriter::writeCharacters(const QString &text) -
3518{ -
3519 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3520 d->finishStartElement();
executed (the execution status of this line is deduced): d->finishStartElement();
-
3521 d->writeEscaped(text);
executed (the execution status of this line is deduced): d->writeEscaped(text);
-
3522}
executed: }
Execution Count:2798
2798
3523 -
3524 -
3525/*! Writes \a text as XML comment, where \a text must not contain the -
3526 forbidden sequence "--" or end with "-". Note that XML does not -
3527 provide any way to escape "-" in a comment. -
3528 */ -
3529void QXmlStreamWriter::writeComment(const QString &text) -
3530{ -
3531 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3532 Q_ASSERT(!text.contains(QLatin1String("--")) && !text.endsWith(QLatin1Char('-')));
executed (the execution status of this line is deduced): qt_noop();
-
3533 if (!d->finishStartElement(false) && d->autoFormatting)
partially evaluated: !d->finishStartElement(false)
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
partially evaluated: d->autoFormatting
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
3534 d->indent(d->tagStack.size());
executed: d->indent(d->tagStack.size());
Execution Count:7
7
3535 d->write("<!--");
executed (the execution status of this line is deduced): d->write("<!--");
-
3536 d->write(text);
executed (the execution status of this line is deduced): d->write(text);
-
3537 d->write("-->");
executed (the execution status of this line is deduced): d->write("-->");
-
3538 d->inStartElement = d->lastWasStartElement = false;
executed (the execution status of this line is deduced): d->inStartElement = d->lastWasStartElement = false;
-
3539}
executed: }
Execution Count:7
7
3540 -
3541 -
3542/*! Writes a DTD section. The \a dtd represents the entire -
3543 doctypedecl production from the XML 1.0 specification. -
3544 */ -
3545void QXmlStreamWriter::writeDTD(const QString &dtd) -
3546{ -
3547 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3548 d->finishStartElement();
executed (the execution status of this line is deduced): d->finishStartElement();
-
3549 if (d->autoFormatting)
partially evaluated: d->autoFormatting
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
3550 d->write("\n");
never executed: d->write("\n");
0
3551 d->write(dtd);
executed (the execution status of this line is deduced): d->write(dtd);
-
3552 if (d->autoFormatting)
partially evaluated: d->autoFormatting
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
3553 d->write("\n");
never executed: d->write("\n");
0
3554}
executed: }
Execution Count:46
46
3555 -
3556 -
3557 -
3558/*! \overload -
3559 Writes an empty element with qualified name \a qualifiedName. -
3560 Subsequent calls to writeAttribute() will add attributes to this element. -
3561*/ -
3562void QXmlStreamWriter::writeEmptyElement(const QString &qualifiedName) -
3563{ -
3564 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3565 Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1);
executed (the execution status of this line is deduced): qt_noop();
-
3566 d->writeStartElement(QString(), qualifiedName);
executed (the execution status of this line is deduced): d->writeStartElement(QString(), qualifiedName);
-
3567 d->inEmptyElement = true;
executed (the execution status of this line is deduced): d->inEmptyElement = true;
-
3568}
executed: }
Execution Count:5
5
3569 -
3570 -
3571/*! Writes an empty element with \a name, prefixed for the specified -
3572 \a namespaceUri. If the namespace has not been declared, -
3573 QXmlStreamWriter will generate a namespace declaration for it. -
3574 Subsequent calls to writeAttribute() will add attributes to this element. -
3575 -
3576 \sa writeNamespace() -
3577 */ -
3578void QXmlStreamWriter::writeEmptyElement(const QString &namespaceUri, const QString &name) -
3579{ -
3580 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3581 Q_ASSERT(!name.contains(QLatin1Char(':')));
executed (the execution status of this line is deduced): qt_noop();
-
3582 d->writeStartElement(namespaceUri, name);
executed (the execution status of this line is deduced): d->writeStartElement(namespaceUri, name);
-
3583 d->inEmptyElement = true;
executed (the execution status of this line is deduced): d->inEmptyElement = true;
-
3584}
executed: }
Execution Count:9
9
3585 -
3586 -
3587/*!\overload -
3588 Writes a text element with \a qualifiedName and \a text. -
3589 -
3590 -
3591 This is a convenience function equivalent to: -
3592 \snippet code/src_corelib_xml_qxmlstream.cpp 1 -
3593 -
3594*/ -
3595void QXmlStreamWriter::writeTextElement(const QString &qualifiedName, const QString &text) -
3596{ -
3597 writeStartElement(qualifiedName);
executed (the execution status of this line is deduced): writeStartElement(qualifiedName);
-
3598 writeCharacters(text);
executed (the execution status of this line is deduced): writeCharacters(text);
-
3599 writeEndElement();
executed (the execution status of this line is deduced): writeEndElement();
-
3600}
executed: }
Execution Count:1
1
3601 -
3602/*! Writes a text element with \a name, prefixed for the specified \a -
3603 namespaceUri, and \a text. If the namespace has not been -
3604 declared, QXmlStreamWriter will generate a namespace declaration -
3605 for it. -
3606 -
3607 -
3608 This is a convenience function equivalent to: -
3609 \snippet code/src_corelib_xml_qxmlstream.cpp 2 -
3610 -
3611*/ -
3612void QXmlStreamWriter::writeTextElement(const QString &namespaceUri, const QString &name, const QString &text) -
3613{ -
3614 writeStartElement(namespaceUri, name);
never executed (the execution status of this line is deduced): writeStartElement(namespaceUri, name);
-
3615 writeCharacters(text);
never executed (the execution status of this line is deduced): writeCharacters(text);
-
3616 writeEndElement();
never executed (the execution status of this line is deduced): writeEndElement();
-
3617}
never executed: }
0
3618 -
3619 -
3620/*! -
3621 Closes all remaining open start elements and writes a newline. -
3622 -
3623 \sa writeStartDocument() -
3624 */ -
3625void QXmlStreamWriter::writeEndDocument() -
3626{ -
3627 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3628 while (d->tagStack.size())
evaluated: d->tagStack.size()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:20
8-20
3629 writeEndElement();
executed: writeEndElement();
Execution Count:8
8
3630 d->write("\n");
executed (the execution status of this line is deduced): d->write("\n");
-
3631}
executed: }
Execution Count:20
20
3632 -
3633/*! -
3634 Closes the previous start element. -
3635 -
3636 \sa writeStartElement() -
3637 */ -
3638void QXmlStreamWriter::writeEndElement() -
3639{ -
3640 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3641 if (d->tagStack.isEmpty())
evaluated: d->tagStack.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1185
1-1185
3642 return;
executed: return;
Execution Count:1
1
3643 -
3644 // shortcut: if nothing was written, close as empty tag -
3645 if (d->inStartElement && !d->inEmptyElement) {
evaluated: d->inStartElement
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:1168
evaluated: !d->inEmptyElement
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:11
6-1168
3646 d->write("/>");
executed (the execution status of this line is deduced): d->write("/>");
-
3647 d->lastWasStartElement = d->inStartElement = false;
executed (the execution status of this line is deduced): d->lastWasStartElement = d->inStartElement = false;
-
3648 QXmlStreamWriterPrivate::Tag &tag = d->tagStack_pop();
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate::Tag &tag = d->tagStack_pop();
-
3649 d->lastNamespaceDeclaration = tag.namespaceDeclarationsSize;
executed (the execution status of this line is deduced): d->lastNamespaceDeclaration = tag.namespaceDeclarationsSize;
-
3650 return;
executed: return;
Execution Count:6
6
3651 } -
3652 -
3653 if (!d->finishStartElement(false) && !d->lastWasStartElement && d->autoFormatting)
evaluated: !d->finishStartElement(false)
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:1084
evaluated: !d->lastWasStartElement
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:7
evaluated: d->autoFormatting
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:61
7-1084
3654 d->indent(d->tagStack.size()-1);
executed: d->indent(d->tagStack.size()-1);
Execution Count:27
27
3655 if (d->tagStack.isEmpty())
evaluated: d->tagStack.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1175
4-1175
3656 return;
executed: return;
Execution Count:4
4
3657 d->lastWasStartElement = false;
executed (the execution status of this line is deduced): d->lastWasStartElement = false;
-
3658 QXmlStreamWriterPrivate::Tag &tag = d->tagStack_pop();
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate::Tag &tag = d->tagStack_pop();
-
3659 d->lastNamespaceDeclaration = tag.namespaceDeclarationsSize;
executed (the execution status of this line is deduced): d->lastNamespaceDeclaration = tag.namespaceDeclarationsSize;
-
3660 d->write("</");
executed (the execution status of this line is deduced): d->write("</");
-
3661 if (!tag.namespaceDeclaration.prefix.isEmpty()) {
evaluated: !tag.namespaceDeclaration.prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:1132
43-1132
3662 d->write(tag.namespaceDeclaration.prefix);
executed (the execution status of this line is deduced): d->write(tag.namespaceDeclaration.prefix);
-
3663 d->write(":");
executed (the execution status of this line is deduced): d->write(":");
-
3664 }
executed: }
Execution Count:43
43
3665 d->write(tag.name);
executed (the execution status of this line is deduced): d->write(tag.name);
-
3666 d->write(">");
executed (the execution status of this line is deduced): d->write(">");
-
3667}
executed: }
Execution Count:1175
1175
3668 -
3669 -
3670 -
3671/*! -
3672 Writes the entity reference \a name to the stream, as "&\a{name};". -
3673 */ -
3674void QXmlStreamWriter::writeEntityReference(const QString &name) -
3675{ -
3676 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3677 d->finishStartElement();
executed (the execution status of this line is deduced): d->finishStartElement();
-
3678 d->write("&");
executed (the execution status of this line is deduced): d->write("&");
-
3679 d->write(name);
executed (the execution status of this line is deduced): d->write(name);
-
3680 d->write(";");
executed (the execution status of this line is deduced): d->write(";");
-
3681}
executed: }
Execution Count:857
857
3682 -
3683 -
3684/*! Writes a namespace declaration for \a namespaceUri with \a -
3685 prefix. If \a prefix is empty, QXmlStreamWriter assigns a unique -
3686 prefix consisting of the letter 'n' followed by a number. -
3687 -
3688 If writeStartElement() or writeEmptyElement() was called, the -
3689 declaration applies to the current element; otherwise it applies to -
3690 the next child element. -
3691 -
3692 Note that the prefix \e xml is both predefined and reserved for -
3693 \e http://www.w3.org/XML/1998/namespace, which in turn cannot be -
3694 bound to any other prefix. The prefix \e xmlns and its URI -
3695 \e http://www.w3.org/2000/xmlns/ are used for the namespace mechanism -
3696 itself and thus completely forbidden in declarations. -
3697 -
3698 */ -
3699void QXmlStreamWriter::writeNamespace(const QString &namespaceUri, const QString &prefix) -
3700{ -
3701 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3702 Q_ASSERT(!namespaceUri.isEmpty());
executed (the execution status of this line is deduced): qt_noop();
-
3703 Q_ASSERT(prefix != QLatin1String("xmlns"));
executed (the execution status of this line is deduced): qt_noop();
-
3704 if (prefix.isEmpty()) {
partially evaluated: prefix.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29
0-29
3705 d->findNamespace(namespaceUri, d->inStartElement);
never executed (the execution status of this line is deduced): d->findNamespace(namespaceUri, d->inStartElement);
-
3706 } else {
never executed: }
0
3707 Q_ASSERT(!((prefix == QLatin1String("xml")) ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace"))));
executed (the execution status of this line is deduced): qt_noop();
-
3708 Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/2000/xmlns/"));
executed (the execution status of this line is deduced): qt_noop();
-
3709 QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
-
3710 namespaceDeclaration.prefix = d->addToStringStorage(prefix);
executed (the execution status of this line is deduced): namespaceDeclaration.prefix = d->addToStringStorage(prefix);
-
3711 namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri);
executed (the execution status of this line is deduced): namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri);
-
3712 if (d->inStartElement)
evaluated: d->inStartElement
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:27
2-27
3713 d->writeNamespaceDeclaration(namespaceDeclaration);
executed: d->writeNamespaceDeclaration(namespaceDeclaration);
Execution Count:2
2
3714 }
executed: }
Execution Count:29
29
3715} -
3716 -
3717 -
3718/*! Writes a default namespace declaration for \a namespaceUri. -
3719 -
3720 If writeStartElement() or writeEmptyElement() was called, the -
3721 declaration applies to the current element; otherwise it applies to -
3722 the next child element. -
3723 -
3724 Note that the namespaces \e http://www.w3.org/XML/1998/namespace -
3725 (bound to \e xmlns) and \e http://www.w3.org/2000/xmlns/ (bound to -
3726 \e xml) by definition cannot be declared as default. -
3727 */ -
3728void QXmlStreamWriter::writeDefaultNamespace(const QString &namespaceUri) -
3729{ -
3730 Q_D(QXmlStreamWriter);
never executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3731 Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/XML/1998/namespace"));
never executed (the execution status of this line is deduced): qt_noop();
-
3732 Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/2000/xmlns/"));
never executed (the execution status of this line is deduced): qt_noop();
-
3733 QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
never executed (the execution status of this line is deduced): QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
-
3734 namespaceDeclaration.prefix.clear();
never executed (the execution status of this line is deduced): namespaceDeclaration.prefix.clear();
-
3735 namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri);
never executed (the execution status of this line is deduced): namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri);
-
3736 if (d->inStartElement)
never evaluated: d->inStartElement
0
3737 d->writeNamespaceDeclaration(namespaceDeclaration);
never executed: d->writeNamespaceDeclaration(namespaceDeclaration);
0
3738}
never executed: }
0
3739 -
3740 -
3741/*! -
3742 Writes an XML processing instruction with \a target and \a data, -
3743 where \a data must not contain the sequence "?>". -
3744 */ -
3745void QXmlStreamWriter::writeProcessingInstruction(const QString &target, const QString &data) -
3746{ -
3747 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3748 Q_ASSERT(!data.contains(QLatin1String("?>")));
executed (the execution status of this line is deduced): qt_noop();
-
3749 if (!d->finishStartElement(false) && d->autoFormatting)
evaluated: !d->finishStartElement(false)
TRUEFALSE
yes
Evaluation Count:61
yes
Evaluation Count:11
evaluated: d->autoFormatting
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:60
1-61
3750 d->indent(d->tagStack.size());
executed: d->indent(d->tagStack.size());
Execution Count:1
1
3751 d->write("<?");
executed (the execution status of this line is deduced): d->write("<?");
-
3752 d->write(target);
executed (the execution status of this line is deduced): d->write(target);
-
3753 if (!data.isNull()) {
partially evaluated: !data.isNull()
TRUEFALSE
yes
Evaluation Count:72
no
Evaluation Count:0
0-72
3754 d->write(" ");
executed (the execution status of this line is deduced): d->write(" ");
-
3755 d->write(data);
executed (the execution status of this line is deduced): d->write(data);
-
3756 }
executed: }
Execution Count:72
72
3757 d->write("?>");
executed (the execution status of this line is deduced): d->write("?>");
-
3758}
executed: }
Execution Count:72
72
3759 -
3760 -
3761 -
3762/*!\overload -
3763 -
3764 Writes a document start with XML version number "1.0". This also -
3765 writes the encoding information. -
3766 -
3767 \sa writeEndDocument(), setCodec() -
3768 \since 4.5 -
3769 */ -
3770void QXmlStreamWriter::writeStartDocument() -
3771{ -
3772 writeStartDocument(QLatin1String("1.0"));
executed (the execution status of this line is deduced): writeStartDocument(QLatin1String("1.0"));
-
3773}
executed: }
Execution Count:21
21
3774 -
3775 -
3776/*! -
3777 Writes a document start with the XML version number \a version. -
3778 -
3779 \sa writeEndDocument() -
3780 */ -
3781void QXmlStreamWriter::writeStartDocument(const QString &version) -
3782{ -
3783 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3784 d->finishStartElement(false);
executed (the execution status of this line is deduced): d->finishStartElement(false);
-
3785 d->write("<?xml version=\"");
executed (the execution status of this line is deduced): d->write("<?xml version=\"");
-
3786 d->write(version);
executed (the execution status of this line is deduced): d->write(version);
-
3787 if (d->device) { // stringDevice does not get any encoding
evaluated: d->device
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:2
2-22
3788 d->write("\" encoding=\"");
executed (the execution status of this line is deduced): d->write("\" encoding=\"");
-
3789#ifdef QT_NO_TEXTCODEC -
3790 d->write("iso-8859-1"); -
3791#else -
3792 d->write(d->codec->name().constData(), d->codec->name().length());
executed (the execution status of this line is deduced): d->write(d->codec->name().constData(), d->codec->name().length());
-
3793#endif -
3794 }
executed: }
Execution Count:22
22
3795 d->write("\"?>");
executed (the execution status of this line is deduced): d->write("\"?>");
-
3796}
executed: }
Execution Count:24
24
3797 -
3798/*! Writes a document start with the XML version number \a version -
3799 and a standalone attribute \a standalone. -
3800 -
3801 \sa writeEndDocument() -
3802 \since 4.5 -
3803 */ -
3804void QXmlStreamWriter::writeStartDocument(const QString &version, bool standalone) -
3805{ -
3806 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3807 d->finishStartElement(false);
executed (the execution status of this line is deduced): d->finishStartElement(false);
-
3808 d->write("<?xml version=\"");
executed (the execution status of this line is deduced): d->write("<?xml version=\"");
-
3809 d->write(version);
executed (the execution status of this line is deduced): d->write(version);
-
3810 if (d->device) { // stringDevice does not get any encoding
partially evaluated: d->device
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
3811 d->write("\" encoding=\"");
executed (the execution status of this line is deduced): d->write("\" encoding=\"");
-
3812#ifdef QT_NO_TEXTCODEC -
3813 d->write("iso-8859-1"); -
3814#else -
3815 d->write(d->codec->name().constData(), d->codec->name().length());
executed (the execution status of this line is deduced): d->write(d->codec->name().constData(), d->codec->name().length());
-
3816#endif -
3817 }
executed: }
Execution Count:2
2
3818 if (standalone)
evaluated: standalone
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
3819 d->write("\" standalone=\"yes\"?>");
executed: d->write("\" standalone=\"yes\"?>");
Execution Count:1
1
3820 else -
3821 d->write("\" standalone=\"no\"?>");
executed: d->write("\" standalone=\"no\"?>");
Execution Count:1
1
3822} -
3823 -
3824 -
3825/*!\overload -
3826 -
3827 Writes a start element with \a qualifiedName. Subsequent calls to -
3828 writeAttribute() will add attributes to this element. -
3829 -
3830 \sa writeEndElement(), writeEmptyElement() -
3831 */ -
3832void QXmlStreamWriter::writeStartElement(const QString &qualifiedName) -
3833{ -
3834 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3835 Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1);
executed (the execution status of this line is deduced): qt_noop();
-
3836 d->writeStartElement(QString(), qualifiedName);
executed (the execution status of this line is deduced): d->writeStartElement(QString(), qualifiedName);
-
3837}
executed: }
Execution Count:9
9
3838 -
3839 -
3840/*! Writes a start element with \a name, prefixed for the specified -
3841 \a namespaceUri. If the namespace has not been declared yet, -
3842 QXmlStreamWriter will generate a namespace declaration for -
3843 it. Subsequent calls to writeAttribute() will add attributes to this -
3844 element. -
3845 -
3846 \sa writeNamespace(), writeEndElement(), writeEmptyElement() -
3847 */ -
3848void QXmlStreamWriter::writeStartElement(const QString &namespaceUri, const QString &name) -
3849{ -
3850 Q_D(QXmlStreamWriter);
executed (the execution status of this line is deduced): QXmlStreamWriterPrivate * const d = d_func();
-
3851 Q_ASSERT(!name.contains(QLatin1Char(':')));
executed (the execution status of this line is deduced): qt_noop();
-
3852 d->writeStartElement(namespaceUri, name);
executed (the execution status of this line is deduced): d->writeStartElement(namespaceUri, name);
-
3853}
executed: }
Execution Count:1174
1174
3854 -
3855void QXmlStreamWriterPrivate::writeStartElement(const QString &namespaceUri, const QString &name) -
3856{ -
3857 if (!finishStartElement(false) && autoFormatting)
evaluated: !finishStartElement(false)
TRUEFALSE
yes
Evaluation Count:756
yes
Evaluation Count:441
evaluated: autoFormatting
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:711
45-756
3858 indent(tagStack.size());
executed: indent(tagStack.size());
Execution Count:45
45
3859 -
3860 Tag &tag = tagStack_push();
executed (the execution status of this line is deduced): Tag &tag = tagStack_push();
-
3861 tag.name = addToStringStorage(name);
executed (the execution status of this line is deduced): tag.name = addToStringStorage(name);
-
3862 tag.namespaceDeclaration = findNamespace(namespaceUri);
executed (the execution status of this line is deduced): tag.namespaceDeclaration = findNamespace(namespaceUri);
-
3863 write("<");
executed (the execution status of this line is deduced): write("<");
-
3864 if (!tag.namespaceDeclaration.prefix.isEmpty()) {
evaluated: !tag.namespaceDeclaration.prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:1142
55-1142
3865 write(tag.namespaceDeclaration.prefix);
executed (the execution status of this line is deduced): write(tag.namespaceDeclaration.prefix);
-
3866 write(":");
executed (the execution status of this line is deduced): write(":");
-
3867 }
executed: }
Execution Count:55
55
3868 write(tag.name);
executed (the execution status of this line is deduced): write(tag.name);
-
3869 inStartElement = lastWasStartElement = true;
executed (the execution status of this line is deduced): inStartElement = lastWasStartElement = true;
-
3870 -
3871 for (int i = lastNamespaceDeclaration; i < namespaceDeclarations.size(); ++i)
evaluated: i < namespaceDeclarations.size()
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:1197
42-1197
3872 writeNamespaceDeclaration(namespaceDeclarations[i]);
executed: writeNamespaceDeclaration(namespaceDeclarations[i]);
Execution Count:42
42
3873 tag.namespaceDeclarationsSize = lastNamespaceDeclaration;
executed (the execution status of this line is deduced): tag.namespaceDeclarationsSize = lastNamespaceDeclaration;
-
3874}
executed: }
Execution Count:1197
1197
3875 -
3876#ifndef QT_NO_XMLSTREAMREADER -
3877/*! Writes the current state of the \a reader. All possible valid -
3878 states are supported. -
3879 -
3880 The purpose of this function is to support chained processing of XML data. -
3881 -
3882 \sa QXmlStreamReader::tokenType() -
3883 */ -
3884void QXmlStreamWriter::writeCurrentToken(const QXmlStreamReader &reader) -
3885{ -
3886 switch (reader.tokenType()) { -
3887 case QXmlStreamReader::NoToken: -
3888 break;
never executed: break;
0
3889 case QXmlStreamReader::StartDocument: -
3890 writeStartDocument();
executed (the execution status of this line is deduced): writeStartDocument();
-
3891 break;
executed: break;
Execution Count:2
2
3892 case QXmlStreamReader::EndDocument: -
3893 writeEndDocument();
executed (the execution status of this line is deduced): writeEndDocument();
-
3894 break;
executed: break;
Execution Count:2
2
3895 case QXmlStreamReader::StartElement: { -
3896 QXmlStreamNamespaceDeclarations namespaceDeclarations = reader.namespaceDeclarations();
executed (the execution status of this line is deduced): QXmlStreamNamespaceDeclarations namespaceDeclarations = reader.namespaceDeclarations();
-
3897 for (int i = 0; i < namespaceDeclarations.size(); ++i) {
partially evaluated: i < namespaceDeclarations.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
3898 const QXmlStreamNamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(i);
never executed (the execution status of this line is deduced): const QXmlStreamNamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(i);
-
3899 writeNamespace(namespaceDeclaration.namespaceUri().toString(),
never executed (the execution status of this line is deduced): writeNamespace(namespaceDeclaration.namespaceUri().toString(),
-
3900 namespaceDeclaration.prefix().toString());
never executed (the execution status of this line is deduced): namespaceDeclaration.prefix().toString());
-
3901 }
never executed: }
0
3902 writeStartElement(reader.namespaceUri().toString(), reader.name().toString());
executed (the execution status of this line is deduced): writeStartElement(reader.namespaceUri().toString(), reader.name().toString());
-
3903 writeAttributes(reader.attributes());
executed (the execution status of this line is deduced): writeAttributes(reader.attributes());
-
3904 } break;
executed: break;
Execution Count:4
4
3905 case QXmlStreamReader::EndElement: -
3906 writeEndElement();
executed (the execution status of this line is deduced): writeEndElement();
-
3907 break;
executed: break;
Execution Count:1144
1144
3908 case QXmlStreamReader::Characters: -
3909 if (reader.isCDATA())
never evaluated: reader.isCDATA()
0
3910 writeCDATA(reader.text().toString());
never executed: writeCDATA(reader.text().toString());
0
3911 else -
3912 writeCharacters(reader.text().toString());
never executed: writeCharacters(reader.text().toString());
0
3913 break;
never executed: break;
0
3914 case QXmlStreamReader::Comment: -
3915 writeComment(reader.text().toString());
executed (the execution status of this line is deduced): writeComment(reader.text().toString());
-
3916 break;
executed: break;
Execution Count:6
6
3917 case QXmlStreamReader::DTD: -
3918 writeDTD(reader.text().toString());
never executed (the execution status of this line is deduced): writeDTD(reader.text().toString());
-
3919 break;
never executed: break;
0
3920 case QXmlStreamReader::EntityReference: -
3921 writeEntityReference(reader.name().toString());
executed (the execution status of this line is deduced): writeEntityReference(reader.name().toString());
-
3922 break;
executed: break;
Execution Count:1
1
3923 case QXmlStreamReader::ProcessingInstruction: -
3924 writeProcessingInstruction(reader.processingInstructionTarget().toString(),
executed (the execution status of this line is deduced): writeProcessingInstruction(reader.processingInstructionTarget().toString(),
-
3925 reader.processingInstructionData().toString());
executed (the execution status of this line is deduced): reader.processingInstructionData().toString());
-
3926 break;
executed: break;
Execution Count:48
48
3927 default: -
3928 Q_ASSERT(reader.tokenType() != QXmlStreamReader::Invalid);
never executed (the execution status of this line is deduced): qt_noop();
-
3929 qWarning("QXmlStreamWriter: writeCurrentToken() with invalid state.");
never executed (the execution status of this line is deduced): QMessageLogger("xml/qxmlstream.cpp", 3929, __PRETTY_FUNCTION__).warning("QXmlStreamWriter: writeCurrentToken() with invalid state.");
-
3930 break;
never executed: break;
0
3931 } -
3932}
executed: }
Execution Count:1207
1207
3933 -
3934/*! -
3935 \fn bool QXmlStreamAttributes::hasAttribute(const QString &qualifiedName) const -
3936 \since 4.5 -
3937 -
3938 Returns true if this QXmlStreamAttributes has an attribute whose -
3939 qualified name is \a qualifiedName; otherwise returns false. -
3940 -
3941 Note that this is not namespace aware. For instance, if this -
3942 QXmlStreamAttributes contains an attribute whose lexical name is "xlink:href" -
3943 this doesn't tell that an attribute named \c href in the XLink namespace is -
3944 present, since the \c xlink prefix can be bound to any namespace. Use the -
3945 overload that takes a namespace URI and a local name as parameter, for -
3946 namespace aware code. -
3947*/ -
3948 -
3949/*! -
3950 \fn bool QXmlStreamAttributes::hasAttribute(QLatin1String qualifiedName) const -
3951 \overload -
3952 \since 4.5 -
3953*/ -
3954 -
3955/*! -
3956 \fn bool QXmlStreamAttributes::hasAttribute(const QString &namespaceUri, -
3957 const QString &name) const -
3958 \overload -
3959 \since 4.5 -
3960 -
3961 Returns true if this QXmlStreamAttributes has an attribute whose -
3962 namespace URI and name correspond to \a namespaceUri and \a name; -
3963 otherwise returns false. -
3964*/ -
3965 -
3966#endif // QT_NO_XMLSTREAMREADER -
3967#endif // QT_NO_XMLSTREAMWRITER -
3968 -
3969QT_END_NAMESPACE -
3970 -
3971#endif // QT_NO_XMLSTREAM -
3972 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial