OpenCoverage

qxml.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/xml/sax/qxml.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtXml module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qxml.h"-
41#include "qxml_p.h"-
42#include "qtextcodec.h"-
43#include "qbuffer.h"-
44#include "qregexp.h"-
45#include "qmap.h"-
46#include "qhash.h"-
47#include "qstack.h"-
48#include <qdebug.h>-
49-
50-
51#ifdef Q_CC_BOR // borland 6 finds bogus warnings when building this file in uic3-
52# pragma warn -8080-
53#endif-
54-
55//#define QT_QXML_DEBUG-
56-
57// Error strings for the XML reader-
58#define XMLERR_OK QT_TRANSLATE_NOOP("QXml", "no error occurred")-
59#define XMLERR_ERRORBYCONSUMER QT_TRANSLATE_NOOP("QXml", "error triggered by consumer")-
60#define XMLERR_UNEXPECTEDEOF QT_TRANSLATE_NOOP("QXml", "unexpected end of file")-
61#define XMLERR_MORETHANONEDOCTYPE QT_TRANSLATE_NOOP("QXml", "more than one document type definition")-
62#define XMLERR_ERRORPARSINGELEMENT QT_TRANSLATE_NOOP("QXml", "error occurred while parsing element")-
63#define XMLERR_TAGMISMATCH QT_TRANSLATE_NOOP("QXml", "tag mismatch")-
64#define XMLERR_ERRORPARSINGCONTENT QT_TRANSLATE_NOOP("QXml", "error occurred while parsing content")-
65#define XMLERR_UNEXPECTEDCHARACTER QT_TRANSLATE_NOOP("QXml", "unexpected character")-
66#define XMLERR_INVALIDNAMEFORPI QT_TRANSLATE_NOOP("QXml", "invalid name for processing instruction")-
67#define XMLERR_VERSIONEXPECTED QT_TRANSLATE_NOOP("QXml", "version expected while reading the XML declaration")-
68#define XMLERR_WRONGVALUEFORSDECL QT_TRANSLATE_NOOP("QXml", "wrong value for standalone declaration")-
69#define XMLERR_EDECLORSDDECLEXPECTED QT_TRANSLATE_NOOP("QXml", "encoding declaration or standalone declaration expected while reading the XML declaration")-
70#define XMLERR_SDDECLEXPECTED QT_TRANSLATE_NOOP("QXml", "standalone declaration expected while reading the XML declaration")-
71#define XMLERR_ERRORPARSINGDOCTYPE QT_TRANSLATE_NOOP("QXml", "error occurred while parsing document type definition")-
72#define XMLERR_LETTEREXPECTED QT_TRANSLATE_NOOP("QXml", "letter is expected")-
73#define XMLERR_ERRORPARSINGCOMMENT QT_TRANSLATE_NOOP("QXml", "error occurred while parsing comment")-
74#define XMLERR_ERRORPARSINGREFERENCE QT_TRANSLATE_NOOP("QXml", "error occurred while parsing reference")-
75#define XMLERR_INTERNALGENERALENTITYINDTD QT_TRANSLATE_NOOP("QXml", "internal general entity reference not allowed in DTD")-
76#define XMLERR_EXTERNALGENERALENTITYINAV QT_TRANSLATE_NOOP("QXml", "external parsed general entity reference not allowed in attribute value")-
77#define XMLERR_EXTERNALGENERALENTITYINDTD QT_TRANSLATE_NOOP("QXml", "external parsed general entity reference not allowed in DTD")-
78#define XMLERR_UNPARSEDENTITYREFERENCE QT_TRANSLATE_NOOP("QXml", "unparsed entity reference in wrong context")-
79#define XMLERR_RECURSIVEENTITIES QT_TRANSLATE_NOOP("QXml", "recursive entities")-
80#define XMLERR_ERRORINTEXTDECL QT_TRANSLATE_NOOP("QXml", "error in the text declaration of an external entity")-
81-
82QT_BEGIN_NAMESPACE-
83-
84namespace {-
85-
86// work around missing std::stack::clear()-
87template <typename Container>-
88void clear(Container &c) { c = Container(); }
executed 2261 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2261
89-
90}-
91-
92// the constants for the lookup table-
93static const signed char cltWS = 0; // white space-
94static const signed char cltPer = 1; // %-
95static const signed char cltAmp = 2; // &-
96static const signed char cltGt = 3; // >-
97static const signed char cltLt = 4; // <-
98static const signed char cltSlash = 5; // /-
99static const signed char cltQm = 6; // ?-
100static const signed char cltEm = 7; // !-
101static const signed char cltDash = 8; // --
102static const signed char cltCB = 9; // ]-
103static const signed char cltOB = 10; // [-
104static const signed char cltEq = 11; // =-
105static const signed char cltDq = 12; // "-
106static const signed char cltSq = 13; // '-
107static const signed char cltUnknown = 14;-
108-
109// character lookup table-
110static const signed char charLookupTable[256]={-
111 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x00 - 0x07-
112 cltUnknown, // 0x08-
113 cltWS, // 0x09 \t-
114 cltWS, // 0x0A \n-
115 cltUnknown, // 0x0B-
116 cltUnknown, // 0x0C-
117 cltWS, // 0x0D \r-
118 cltUnknown, // 0x0E-
119 cltUnknown, // 0x0F-
120 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x17 - 0x16-
121 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x18 - 0x1F-
122 cltWS, // 0x20 Space-
123 cltEm, // 0x21 !-
124 cltDq, // 0x22 "-
125 cltUnknown, // 0x23-
126 cltUnknown, // 0x24-
127 cltPer, // 0x25 %-
128 cltAmp, // 0x26 &-
129 cltSq, // 0x27 '-
130 cltUnknown, // 0x28-
131 cltUnknown, // 0x29-
132 cltUnknown, // 0x2A-
133 cltUnknown, // 0x2B-
134 cltUnknown, // 0x2C-
135 cltDash, // 0x2D --
136 cltUnknown, // 0x2E-
137 cltSlash, // 0x2F /-
138 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x30 - 0x37-
139 cltUnknown, // 0x38-
140 cltUnknown, // 0x39-
141 cltUnknown, // 0x3A-
142 cltUnknown, // 0x3B-
143 cltLt, // 0x3C <-
144 cltEq, // 0x3D =-
145 cltGt, // 0x3E >-
146 cltQm, // 0x3F ?-
147 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x40 - 0x47-
148 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x48 - 0x4F-
149 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x50 - 0x57-
150 cltUnknown, // 0x58-
151 cltUnknown, // 0x59-
152 cltUnknown, // 0x5A-
153 cltOB, // 0x5B [-
154 cltUnknown, // 0x5C-
155 cltCB, // 0x5D]-
156 cltUnknown, // 0x5E-
157 cltUnknown, // 0x5F-
158 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x60 - 0x67-
159 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x68 - 0x6F-
160 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x70 - 0x77-
161 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x78 - 0x7F-
162 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x80 - 0x87-
163 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x88 - 0x8F-
164 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x90 - 0x97-
165 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x98 - 0x9F-
166 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xA0 - 0xA7-
167 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xA8 - 0xAF-
168 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xB0 - 0xB7-
169 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xB8 - 0xBF-
170 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xC0 - 0xC7-
171 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xC8 - 0xCF-
172 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xD0 - 0xD7-
173 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xD8 - 0xDF-
174 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xE0 - 0xE7-
175 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xE8 - 0xEF-
176 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xF0 - 0xF7-
177 cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown // 0xF8 - 0xFF-
178};-
179-
180//-
181// local helper functions-
182//-
183-
184/*-
185 This function strips the TextDecl [77] ("<?xml ...?>") from the string \a-
186 str. The stripped version is stored in \a str. If this function finds an-
187 invalid TextDecl, it returns \c false, otherwise true.-
188-
189 This function is used for external entities since those can include an-
190 TextDecl that must be stripped before inserting the entity.-
191*/-
192static bool stripTextDecl(QString& str)-
193{-
194 QString textDeclStart(QLatin1String("<?xml"));-
195 if (str.startsWith(textDeclStart)) {
str.startsWith(textDeclStart)Description
TRUEnever evaluated
FALSEnever evaluated
0
196 QRegExp textDecl(QString::fromLatin1(-
197 "^<\\?xml\\s+"-
198 "(version\\s*=\\s*((['\"])[-a-zA-Z0-9_.:]+\\3))?"-
199 "\\s*"-
200 "(encoding\\s*=\\s*((['\"])[A-Za-z][-a-zA-Z0-9_.]*\\6))?"-
201 "\\s*\\?>"-
202 ));-
203 QString strTmp = str.replace(textDecl, QLatin1String(""));-
204 if (strTmp.length() != str.length())
strTmp.length(...= str.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
205 return false; // external entity has wrong TextDecl
never executed: return false;
0
206 str = strTmp;-
207 }
never executed: end of block
0
208 return true;
never executed: return true;
0
209}-
210-
211-
212class QXmlAttributesPrivate-
213{-
214};-
215-
216/* \class QXmlInputSourcePrivate-
217 \internal-
218-
219 There's a slight misdesign in this class that can-
220 be worth to keep in mind: the `str' member is-
221 a buffer which QXmlInputSource::next() returns from,-
222 and which is populated from the input device or input-
223 stream. However, when the input is a QString(the user called-
224 QXmlInputSource::setData()), `str' has two roles: it's the-
225 buffer, but also the source. This /seems/ to be no problem-
226 because in the case of having no device or stream, the QString-
227 is read in one go.-
228 */-
229class QXmlInputSourcePrivate-
230{-
231public:-
232 QIODevice *inputDevice;-
233 QTextStream *inputStream;-
234-
235 QString str;-
236 const QChar *unicode;-
237 int pos;-
238 int length;-
239 bool nextReturnedEndOfData;-
240#ifndef QT_NO_TEXTCODEC-
241 QTextDecoder *encMapper;-
242#endif-
243-
244 QByteArray encodingDeclBytes;-
245 QString encodingDeclChars;-
246 bool lookingForEncodingDecl;-
247};-
248class QXmlParseExceptionPrivate-
249{-
250public:-
251 QXmlParseExceptionPrivate()-
252 : column(-1), line(-1)-
253 {-
254 }
executed 155 times by 1 test: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
155
255 QXmlParseExceptionPrivate(const QXmlParseExceptionPrivate &other)-
256 : msg(other.msg), column(other.column), line(other.line),-
257 pub(other.pub), sys(other.sys)-
258 {-
259 }
never executed: end of block
0
260-
261 QString msg;-
262 int column;-
263 int line;-
264 QString pub;-
265 QString sys;-
266-
267};-
268-
269class QXmlLocatorPrivate-
270{-
271};-
272-
273class QXmlDefaultHandlerPrivate-
274{-
275};-
276-
277/*!-
278 \class QXmlParseException-
279 \reentrant-
280 \brief The QXmlParseException class is used to report errors with-
281 the QXmlErrorHandler interface.-
282-
283 \inmodule QtXml-
284 \ingroup xml-tools-
285-
286 The XML subsystem constructs an instance of this class when it-
287 detects an error. You can retrieve the place where the error-
288 occurred using systemId(), publicId(), lineNumber() and-
289 columnNumber(), along with the error message(). The possible error-
290 messages are:-
291-
292-
293 \list-
294 \li "no error occurred"-
295 \li "error triggered by consumer"-
296 \li "unexpected end of file"-
297 \li "more than one document type definition"-
298 \li "error occurred while parsing element"-
299 \li "tag mismatch"-
300 \li "error occurred while parsing content"-
301 \li "unexpected character"-
302 \li "invalid name for processing instruction"-
303 \li "version expected while reading the XML declaration"-
304 \li "wrong value for standalone declaration"-
305 \li "encoding declaration or standalone declaration expected while reading the XML declaration"-
306 \li "standalone declaration expected while reading the XML declaration"-
307 \li "error occurred while parsing document type definition"-
308 \li "letter is expected"-
309 \li "error occurred while parsing comment"-
310 \li "error occurred while parsing reference"-
311 \li "internal general entity reference not allowed in DTD"-
312 \li "external parsed general entity reference not allowed in attribute value"-
313 \li "external parsed general entity reference not allowed in DTD"-
314 \li "unparsed entity reference n wrong context"-
315 \li "recursive entities"-
316 \li "error in the text declaration of an external entity"-
317 \endlist-
318-
319 Note that, if you want to display these error messages to your-
320 application's users, they will be displayed in English unless-
321 they are explicitly translated.-
322-
323 \sa QXmlErrorHandler, QXmlReader-
324*/-
325-
326/*!-
327 Constructs a parse exception with the error string \a name for-
328 column \a c and line \a l for the public identifier \a p and the-
329 system identifier \a s.-
330*/-
331-
332QXmlParseException::QXmlParseException(const QString& name, int c, int l,-
333 const QString& p, const QString& s)-
334 : d(new QXmlParseExceptionPrivate)-
335{-
336 d->msg = name;-
337 d->column = c;-
338 d->line = l;-
339 d->pub = p;-
340 d->sys = s;-
341}
executed 155 times by 1 test: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
155
342-
343/*!-
344 Creates a copy of \a other.-
345*/-
346QXmlParseException::QXmlParseException(const QXmlParseException& other) :-
347 d(new QXmlParseExceptionPrivate(*other.d))-
348{-
349-
350}
never executed: end of block
0
351-
352/*!-
353 Destroys the QXmlParseException.-
354*/-
355QXmlParseException::~QXmlParseException()-
356{-
357}-
358-
359/*!-
360 Returns the error message.-
361*/-
362QString QXmlParseException::message() const-
363{-
364 return d->msg;
executed 300 times by 1 test: return d->msg;
Executed by:
  • tst_qxmlsimplereader - unknown status
300
365}-
366/*!-
367 Returns the column number where the error occurred.-
368*/-
369int QXmlParseException::columnNumber() const-
370{-
371 return d->column;
executed 300 times by 1 test: return d->column;
Executed by:
  • tst_qxmlsimplereader - unknown status
300
372}-
373/*!-
374 Returns the line number where the error occurred.-
375*/-
376int QXmlParseException::lineNumber() const-
377{-
378 return d->line;
executed 300 times by 1 test: return d->line;
Executed by:
  • tst_qxmlsimplereader - unknown status
300
379}-
380/*!-
381 Returns the public identifier where the error occurred.-
382*/-
383QString QXmlParseException::publicId() const-
384{-
385 return d->pub;
executed 152 times by 1 test: return d->pub;
Executed by:
  • tst_qxmlsimplereader - unknown status
152
386}-
387/*!-
388 Returns the system identifier where the error occurred.-
389*/-
390QString QXmlParseException::systemId() const-
391{-
392 return d->sys;
executed 152 times by 1 test: return d->sys;
Executed by:
  • tst_qxmlsimplereader - unknown status
152
393}-
394-
395-
396/*!-
397 \class QXmlLocator-
398 \reentrant-
399 \brief The QXmlLocator class provides the XML handler classes with-
400 information about the parsing position within a file.-
401-
402 \inmodule QtXml-
403 \ingroup xml-tools-
404-
405 The reader reports a QXmlLocator to the content handler before it-
406 starts to parse the document. This is done with the-
407 QXmlContentHandler::setDocumentLocator() function. The handler-
408 classes can now use this locator to get the position (lineNumber()-
409 and columnNumber()) that the reader has reached.-
410*/-
411-
412/*!-
413 Constructor.-
414*/-
415QXmlLocator::QXmlLocator()-
416{-
417}-
418-
419/*!-
420 Destructor.-
421*/-
422QXmlLocator::~QXmlLocator()-
423{-
424}-
425-
426/*!-
427 \fn int QXmlLocator::columnNumber() const-
428-
429 Returns the column number (starting at 1) or -1 if there is no-
430 column number available.-
431*/-
432-
433/*!-
434 \fn int QXmlLocator::lineNumber() const-
435-
436 Returns the line number (starting at 1) or -1 if there is no line-
437 number available.-
438*/-
439-
440class QXmlSimpleReaderLocator : public QXmlLocator-
441{-
442public:-
443 QXmlSimpleReaderLocator(QXmlSimpleReader* parent)-
444 {-
445 reader = parent;-
446 }
executed 2104 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2104
447 ~QXmlSimpleReaderLocator()-
448 {-
449 }-
450-
451 int columnNumber() const Q_DECL_OVERRIDE-
452 {-
453 return (reader->d_ptr->columnNr == -1 ? -1 : reader->d_ptr->columnNr + 1);
executed 2993 times by 5 tests: return (reader->d_ptr->columnNr == -1 ? -1 : reader->d_ptr->columnNr + 1);
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
2993
454 }-
455 int lineNumber() const Q_DECL_OVERRIDE-
456 {-
457 return (reader->d_ptr->lineNr == -1 ? -1 : reader->d_ptr->lineNr + 1);
executed 2993 times by 5 tests: return (reader->d_ptr->lineNr == -1 ? -1 : reader->d_ptr->lineNr + 1);
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
2993
458 }-
459// QString getPublicId()-
460// QString getSystemId()-
461-
462private:-
463 QXmlSimpleReader *reader;-
464};-
465-
466/*********************************************-
467 *-
468 * QXmlNamespaceSupport-
469 *-
470 *********************************************/-
471-
472typedef QMap<QString, QString> NamespaceMap;-
473-
474class QXmlNamespaceSupportPrivate-
475{-
476public:-
477 QXmlNamespaceSupportPrivate()-
478 {-
479 ns.insert(QLatin1String("xml"), QLatin1String("http://www.w3.org/XML/1998/namespace")); // the XML namespace-
480 }
executed 2104 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2104
481-
482 ~QXmlNamespaceSupportPrivate()-
483 {-
484 }-
485-
486 QStack<NamespaceMap> nsStack;-
487 NamespaceMap ns;-
488};-
489-
490/*!-
491 \class QXmlNamespaceSupport-
492 \since 4.4-
493 \reentrant-
494 \brief The QXmlNamespaceSupport class is a helper class for XML-
495 readers which want to include namespace support.-
496-
497 \inmodule QtXml-
498 \ingroup xml-tools-
499-
500 You can set the prefix for the current namespace with setPrefix(),-
501 and get the list of current prefixes (or those for a given URI)-
502 with prefixes(). The namespace URI is available from uri(). Use-
503 pushContext() to start a new namespace context, and popContext()-
504 to return to the previous namespace context. Use splitName() or-
505 processName() to split a name into its prefix and local name.-
506-
507 \sa {Namespace Support via Features}-
508*/-
509-
510/*!-
511 Constructs a QXmlNamespaceSupport.-
512*/-
513QXmlNamespaceSupport::QXmlNamespaceSupport()-
514{-
515 d = new QXmlNamespaceSupportPrivate;-
516}
executed 2104 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2104
517-
518/*!-
519 Destroys a QXmlNamespaceSupport.-
520*/-
521QXmlNamespaceSupport::~QXmlNamespaceSupport()-
522{-
523 delete d;-
524}
executed 2104 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2104
525-
526/*!-
527 This function declares a prefix \a pre in the current namespace-
528 context to be the namespace URI \a uri. The prefix remains in-
529 force until this context is popped, unless it is shadowed in a-
530 descendant context.-
531-
532 Note that there is an asymmetry in this library. prefix() does not-
533 return the default "" prefix, even if you have declared one; to-
534 check for a default prefix, you must look it up explicitly using-
535 uri(). This asymmetry exists to make it easier to look up prefixes-
536 for attribute names, where the default prefix is not allowed.-
537*/-
538void QXmlNamespaceSupport::setPrefix(const QString& pre, const QString& uri)-
539{-
540 if(pre.isNull()) {
pre.isNull()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
3-4
541 d->ns.insert(QLatin1String(""), uri);-
542 } else {
executed 3 times by 1 test: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
3
543 d->ns.insert(pre, uri);-
544 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
4
545}-
546-
547/*!-
548 Returns one of the prefixes mapped to the namespace URI \a uri.-
549-
550 If more than one prefix is currently mapped to the same URI, this-
551 function makes an arbitrary selection; if you want all of the-
552 prefixes, use prefixes() instead.-
553-
554 Note: to check for a default prefix, use the uri() function with-
555 an argument of "".-
556*/-
557QString QXmlNamespaceSupport::prefix(const QString& uri) const-
558{-
559 NamespaceMap::const_iterator itc, it = d->ns.constBegin();-
560 while ((itc=it) != d->ns.constEnd()) {
(itc=it) != d->ns.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
561 ++it;-
562 if (*itc == uri && !itc.key().isEmpty())
*itc == uriDescription
TRUEnever evaluated
FALSEnever evaluated
!itc.key().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
563 return itc.key();
never executed: return itc.key();
0
564 }
never executed: end of block
0
565 return QLatin1String("");
never executed: return QLatin1String("");
0
566}-
567-
568/*!-
569 Looks up the prefix \a prefix in the current context and returns-
570 the currently-mapped namespace URI. Use the empty string ("") for-
571 the default namespace.-
572*/-
573QString QXmlNamespaceSupport::uri(const QString& prefix) const-
574{-
575 return d->ns[prefix];
executed 27 times by 2 tests: return d->ns[prefix];
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
27
576}-
577-
578/*!-
579 Splits the name \a qname at the ':' and returns the prefix in \a-
580 prefix and the local name in \a localname.-
581-
582 \sa processName()-
583*/-
584void QXmlNamespaceSupport::splitName(const QString& qname, QString& prefix,-
585 QString& localname) const-
586{-
587 int pos = qname.indexOf(QLatin1Char(':'));-
588 if (pos == -1)
pos == -1Description
TRUEevaluated 11998 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
30-11998
589 pos = qname.size();
executed 11998 times by 3 tests: pos = qname.size();
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
11998
590-
591 prefix = qname.left(pos);-
592 localname = qname.mid(pos+1);-
593}
executed 12028 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
12028
594-
595/*!-
596 Processes a raw XML 1.0 name in the current context by removing-
597 the prefix and looking it up among the prefixes currently-
598 declared.-
599-
600 \a qname is the raw XML 1.0 name to be processed. \a isAttribute-
601 is true if the name is an attribute name.-
602-
603 This function stores the namespace URI in \a nsuri (which will be-
604 set to an empty string if the raw name has an undeclared prefix),-
605 and stores the local name (without prefix) in \a localname (which-
606 will be set to an empty string if no namespace is in use).-
607-
608 Note that attribute names are processed differently than element-
609 names: an unprefixed element name gets the default namespace (if-
610 any), while an unprefixed attribute name does not.-
611*/-
612void QXmlNamespaceSupport::processName(const QString& qname,-
613 bool isAttribute,-
614 QString& nsuri, QString& localname) const-
615{-
616 int len = qname.size();-
617 const QChar *data = qname.constData();-
618 for (int pos = 0; pos < len; ++pos) {
pos < lenDescription
TRUEevaluated 96470 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 21219 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
21219-96470
619 if (data[pos] == QLatin1Char(':')) {
data[pos] == QLatin1Char(':')Description
TRUEevaluated 27 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 96443 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
27-96443
620 nsuri = uri(qname.left(pos));-
621 localname = qname.mid(pos + 1);-
622 return;
executed 27 times by 2 tests: return;
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
27
623 }-
624 }
executed 96443 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
96443
625-
626 // there was no ':'-
627 nsuri.clear();-
628 // attributes don't take default namespace-
629 if (!isAttribute && !d->ns.isEmpty()) {
!isAttributeDescription
TRUEevaluated 9224 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 11995 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
!d->ns.isEmpty()Description
TRUEevaluated 9224 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEnever evaluated
0-11995
630 /*-
631 We want to access d->ns.value(""), but as an optimization-
632 we use the fact that "" compares less than any other-
633 string, so it's either first in the map or not there.-
634 */-
635 NamespaceMap::const_iterator first = d->ns.constBegin();-
636 if (first.key().isEmpty())
first.key().isEmpty()Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 9203 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
21-9203
637 nsuri = first.value(); // get default namespace
executed 21 times by 1 test: nsuri = first.value();
Executed by:
  • tst_qxmlsimplereader - unknown status
21
638 }
executed 9224 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
9224
639 localname = qname;-
640}
executed 21219 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
21219
641-
642/*!-
643 Returns a list of all the prefixes currently declared.-
644-
645 If there is a default prefix, this function does not return it in-
646 the list; check for the default prefix using uri() with an-
647 argument of "".-
648*/-
649QStringList QXmlNamespaceSupport::prefixes() const-
650{-
651 QStringList list;-
652-
653 NamespaceMap::const_iterator itc, it = d->ns.constBegin();-
654 while ((itc=it) != d->ns.constEnd()) {
(itc=it) != d->ns.constEnd()Description
TRUEevaluated 439 times by 2 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 434 times by 2 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
434-439
655 ++it;-
656 if (!itc.key().isEmpty())
!itc.key().isEmpty()Description
TRUEevaluated 438 times by 2 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
1-438
657 list.append(itc.key());
executed 438 times by 2 tests: list.append(itc.key());
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
438
658 }
executed 439 times by 2 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
439
659 return list;
executed 434 times by 2 tests: return list;
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
434
660}-
661-
662/*!-
663 \overload-
664-
665 Returns a list of all prefixes currently declared for the-
666 namespace URI \a uri.-
667-
668 The "xml:" prefix is included. If you only want one prefix that is-
669 mapped to the namespace URI, and you don't care which one you get,-
670 use the prefix() function instead.-
671-
672 Note: The empty (default) prefix is never included in this list;-
673 to check for the presence of a default namespace, call uri() with-
674 "" as the argument.-
675*/-
676QStringList QXmlNamespaceSupport::prefixes(const QString& uri) const-
677{-
678 QStringList list;-
679-
680 NamespaceMap::const_iterator itc, it = d->ns.constBegin();-
681 while ((itc=it) != d->ns.constEnd()) {
(itc=it) != d->ns.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
682 ++it;-
683 if (*itc == uri && !itc.key().isEmpty())
*itc == uriDescription
TRUEnever evaluated
FALSEnever evaluated
!itc.key().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
684 list.append(itc.key());
never executed: list.append(itc.key());
0
685 }
never executed: end of block
0
686 return list;
never executed: return list;
0
687}-
688-
689/*!-
690 Starts a new namespace context.-
691-
692 Normally, you should push a new context at the beginning of each-
693 XML element: the new context automatically inherits the-
694 declarations of its parent context, and it also keeps track of-
695 which declarations were made within this context.-
696-
697 \sa popContext()-
698*/-
699void QXmlNamespaceSupport::pushContext()-
700{-
701 d->nsStack.push(d->ns);-
702}
executed 4781 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
4781
703-
704/*!-
705 Reverts to the previous namespace context.-
706-
707 Normally, you should pop the context at the end of each XML-
708 element. After popping the context, all namespace prefix mappings-
709 that were previously in force are restored.-
710-
711 \sa pushContext()-
712*/-
713void QXmlNamespaceSupport::popContext()-
714{-
715 d->ns.clear();-
716 if(!d->nsStack.isEmpty())
!d->nsStack.isEmpty()Description
TRUEevaluated 4705 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEnever evaluated
0-4705
717 d->ns = d->nsStack.pop();
executed 4705 times by 3 tests: d->ns = d->nsStack.pop();
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
4705
718}
executed 4705 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
4705
719-
720/*!-
721 Resets this namespace support object ready for reuse.-
722*/-
723void QXmlNamespaceSupport::reset()-
724{-
725 QXmlNamespaceSupportPrivate *newD = new QXmlNamespaceSupportPrivate;-
726 delete d;-
727 d = newD;-
728}
never executed: end of block
0
729-
730-
731-
732/*********************************************-
733 *-
734 * QXmlAttributes-
735 *-
736 *********************************************/-
737-
738/*!-
739 \class QXmlAttributes-
740 \reentrant-
741 \brief The QXmlAttributes class provides XML attributes.-
742-
743 \inmodule QtXml-
744 \ingroup xml-tools-
745-
746 If attributes are reported by QXmlContentHandler::startElement()-
747 this class is used to pass the attribute values.-
748-
749 Use index() to locate the position of an attribute in the list,-
750 count() to retrieve the number of attributes, and clear() to-
751 remove the attributes. New attributes can be added with append().-
752 Use type() to get an attribute's type and value() to get its-
753 value. The attribute's name is available from localName() or-
754 qName(), and its namespace URI from uri().-
755-
756*/-
757-
758/*!-
759 \fn QXmlAttributes::QXmlAttributes()-
760-
761 Constructs an empty attribute list.-
762*/-
763QXmlAttributes::QXmlAttributes()-
764{-
765 // ### In Qt 5.0, this function was inlined and d was not initialized-
766 // The member cannot be used until Qt 6.0-
767 Q_UNUSED(d);-
768}
executed 2104 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2104
769-
770/*!-
771 \fn QXmlAttributes::~QXmlAttributes()-
772-
773 Destroys the attributes object.-
774*/-
775QXmlAttributes::~QXmlAttributes()-
776{-
777}-
778-
779-
780/*!-
781 Looks up the index of an attribute by the qualified name \a qName.-
782-
783 Returns the index of the attribute or -1 if it wasn't found.-
784-
785 \sa {Namespace Support via Features}-
786*/-
787int QXmlAttributes::index(const QString& qName) const-
788{-
789 for (int i = 0; i < attList.size(); ++i) {
i < attList.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
790 if (attList.at(i).qname == qName)
attList.at(i).qname == qNameDescription
TRUEnever evaluated
FALSEnever evaluated
0
791 return i;
never executed: return i;
0
792 }
never executed: end of block
0
793 return -1;
never executed: return -1;
0
794}-
795-
796/*! \overload-
797 */-
798int QXmlAttributes::index(QLatin1String qName) const-
799{-
800 for (int i = 0; i < attList.size(); ++i) {
i < attList.size()Description
TRUEevaluated 11810 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
FALSEevaluated 2589 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
2589-11810
801 if (attList.at(i).qname == qName)
attList.at(i).qname == qNameDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
FALSEevaluated 11786 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
24-11786
802 return i;
executed 24 times by 1 test: return i;
Executed by:
  • tst_qxmlstream - unknown status
24
803 }
executed 11786 times by 1 test: end of block
Executed by:
  • tst_qxmlstream - unknown status
11786
804 return -1;
executed 2589 times by 1 test: return -1;
Executed by:
  • tst_qxmlstream - unknown status
2589
805}-
806-
807/*!-
808 \overload-
809-
810 Looks up the index of an attribute by a namespace name.-
811-
812 \a uri specifies the namespace URI, or an empty string if the name-
813 has no namespace URI. \a localPart specifies the attribute's local-
814 name.-
815-
816 Returns the index of the attribute, or -1 if it wasn't found.-
817-
818 \sa {Namespace Support via Features}-
819*/-
820int QXmlAttributes::index(const QString& uri, const QString& localPart) const-
821{-
822 for (int i = 0; i < attList.size(); ++i) {
i < attList.size()Description
TRUEevaluated 51512 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
FALSEevaluated 5843 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
5843-51512
823 const Attribute &att = attList.at(i);-
824 if (att.uri == uri && att.localname == localPart)
att.uri == uriDescription
TRUEevaluated 51512 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
FALSEnever evaluated
att.localname == localPartDescription
TRUEevaluated 8130 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
FALSEevaluated 43382 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
0-51512
825 return i;
executed 8130 times by 1 test: return i;
Executed by:
  • tst_qxmlstream - unknown status
8130
826 }
executed 43382 times by 1 test: end of block
Executed by:
  • tst_qxmlstream - unknown status
43382
827 return -1;
executed 5843 times by 1 test: return -1;
Executed by:
  • tst_qxmlstream - unknown status
5843
828}-
829-
830/*!-
831 Returns the number of attributes in the list.-
832-
833 \sa count()-
834*/-
835int QXmlAttributes::length() const-
836{-
837 return attList.count();
executed 4017 times by 5 tests: return attList.count();
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
4017
838}-
839-
840/*!-
841 \fn int QXmlAttributes::count() const-
842-
843 Returns the number of attributes in the list. This function is-
844 equivalent to length().-
845*/-
846-
847/*!-
848 Looks up an attribute's local name for the attribute at position-
849 \a index. If no namespace processing is done, the local name is-
850 an empty string.-
851-
852 \sa {Namespace Support via Features}-
853*/-
854QString QXmlAttributes::localName(int index) const-
855{-
856 return attList.at(index).localname;
executed 407 times by 1 test: return attList.at(index).localname;
Executed by:
  • tst_qxmlsimplereader - unknown status
407
857}-
858-
859/*!-
860 Looks up an attribute's XML 1.0 qualified name for the attribute-
861 at position \a index.-
862-
863 \sa {Namespace Support via Features}-
864*/-
865QString QXmlAttributes::qName(int index) const-
866{-
867 return attList.at(index).qname;
executed 1275 times by 4 tests: return attList.at(index).qname;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
1275
868}-
869-
870/*!-
871 Looks up an attribute's namespace URI for the attribute at-
872 position \a index. If no namespace processing is done or if the-
873 attribute has no namespace, the namespace URI is an empty string.-
874-
875 \sa {Namespace Support via Features}-
876*/-
877QString QXmlAttributes::uri(int index) const-
878{-
879 return attList.at(index).uri;
executed 409 times by 1 test: return attList.at(index).uri;
Executed by:
  • tst_qxmlsimplereader - unknown status
409
880}-
881-
882/*!-
883 Looks up an attribute's type for the attribute at position \a-
884 index.-
885-
886 Currently only "CDATA" is returned.-
887*/-
888QString QXmlAttributes::type(int) const-
889{-
890 return QLatin1String("CDATA");
executed 407 times by 1 test: return QLatin1String("CDATA");
Executed by:
  • tst_qxmlsimplereader - unknown status
407
891}-
892-
893/*!-
894 \overload-
895-
896 Looks up an attribute's type for the qualified name \a qName.-
897-
898 Currently only "CDATA" is returned.-
899*/-
900QString QXmlAttributes::type(const QString&) const-
901{-
902 return QLatin1String("CDATA");
never executed: return QLatin1String("CDATA");
0
903}-
904-
905/*!-
906 \overload-
907-
908 Looks up an attribute's type by namespace name.-
909-
910 \a uri specifies the namespace URI and \a localName specifies the-
911 local name. If the name has no namespace URI, use an empty string-
912 for \a uri.-
913-
914 Currently only "CDATA" is returned.-
915*/-
916QString QXmlAttributes::type(const QString&, const QString&) const-
917{-
918 return QLatin1String("CDATA");
never executed: return QLatin1String("CDATA");
0
919}-
920-
921/*!-
922 Returns an attribute's value for the attribute at position \a-
923 index. The index must be a valid position-
924 (i.e., 0 <= \a index < count()).-
925*/-
926QString QXmlAttributes::value(int index) const-
927{-
928 return attList.at(index).value;
executed 1287 times by 5 tests: return attList.at(index).value;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1287
929}-
930-
931/*!-
932 \overload-
933-
934 Returns an attribute's value for the qualified name \a qName, or an-
935 empty string if no attribute exists for the name given.-
936-
937 \sa {Namespace Support via Features}-
938*/-
939QString QXmlAttributes::value(const QString& qName) const-
940{-
941 int i = index(qName);-
942 if (i == -1)
i == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
943 return QString();
never executed: return QString();
0
944 return attList.at(i).value;
never executed: return attList.at(i).value;
0
945}-
946-
947/*!-
948 \overload-
949-
950 Returns an attribute's value for the qualified name \a qName, or an-
951 empty string if no attribute exists for the name given.-
952-
953 \sa {Namespace Support via Features}-
954*/-
955QString QXmlAttributes::value(QLatin1String qName) const-
956{-
957 int i = index(qName);-
958 if (i == -1)
i == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
959 return QString();
never executed: return QString();
0
960 return attList.at(i).value;
never executed: return attList.at(i).value;
0
961}-
962-
963/*!-
964 \overload-
965-
966 Returns an attribute's value by namespace name.-
967-
968 \a uri specifies the namespace URI, or an empty string if the name-
969 has no namespace URI. \a localName specifies the attribute's local-
970 name.-
971*/-
972QString QXmlAttributes::value(const QString& uri, const QString& localName) const-
973{-
974 int i = index(uri, localName);-
975 if (i == -1)
i == -1Description
TRUEevaluated 4320 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
FALSEevaluated 7751 times by 1 test
Evaluated by:
  • tst_qxmlstream - unknown status
4320-7751
976 return QString();
executed 4320 times by 1 test: return QString();
Executed by:
  • tst_qxmlstream - unknown status
4320
977 return attList.at(i).value;
executed 7751 times by 1 test: return attList.at(i).value;
Executed by:
  • tst_qxmlstream - unknown status
7751
978}-
979-
980/*!-
981 Clears the list of attributes.-
982-
983 \sa append()-
984*/-
985void QXmlAttributes::clear()-
986{-
987 attList.clear();-
988}
executed 5802 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
5802
989-
990/*!-
991 Appends a new attribute entry to the list of attributes. The-
992 qualified name of the attribute is \a qName, the namespace URI is-
993 \a uri and the local name is \a localPart. The value of the-
994 attribute is \a value.-
995-
996 \sa qName(), uri(), localName(), value()-
997*/-
998void QXmlAttributes::append(const QString &qName, const QString &uri, const QString &localPart, const QString &value)-
999{-
1000 Attribute att;-
1001 att.qname = qName;-
1002 att.uri = uri;-
1003 att.localname = localPart;-
1004 att.value = value;-
1005-
1006 attList.append(att);-
1007}
executed 12887 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
12887
1008-
1009-
1010/*********************************************-
1011 *-
1012 * QXmlInputSource-
1013 *-
1014 *********************************************/-
1015-
1016/*!-
1017 \class QXmlInputSource-
1018 \reentrant-
1019 \brief The QXmlInputSource class provides the input data for the-
1020 QXmlReader subclasses.-
1021-
1022 \inmodule QtXml-
1023 \ingroup xml-tools-
1024-
1025 All subclasses of QXmlReader read the input XML document from this-
1026 class.-
1027-
1028 This class recognizes the encoding of the data by reading the-
1029 encoding declaration in the XML file if it finds one, and reading-
1030 the data using the corresponding encoding. If it does not find an-
1031 encoding declaration, then it assumes that the data is either in-
1032 UTF-8 or UTF-16, depending on whether it can find a byte-order-
1033 mark.-
1034-
1035 There are two ways to populate the input source with data: you can-
1036 construct it with a QIODevice* so that the input source reads the-
1037 data from that device. Or you can set the data explicitly with one-
1038 of the setData() functions.-
1039-
1040 Usually you either construct a QXmlInputSource that works on a-
1041 QIODevice* or you construct an empty QXmlInputSource and set the-
1042 data with setData(). There are only rare occasions where you would-
1043 want to mix both methods.-
1044-
1045 The QXmlReader subclasses use the next() function to read the-
1046 input character by character. If you want to start from the-
1047 beginning again, use reset().-
1048-
1049 The functions data() and fetchData() are useful if you want to do-
1050 something with the data other than parsing, e.g. displaying the-
1051 raw XML file. The benefit of using the QXmlInputClass in such-
1052 cases is that it tries to use the correct encoding.-
1053-
1054 \sa QXmlReader, QXmlSimpleReader-
1055*/-
1056-
1057// the following two are guaranteed not to be a character-
1058const ushort QXmlInputSource::EndOfData = 0xfffe;-
1059const ushort QXmlInputSource::EndOfDocument = 0xffff;-
1060-
1061/*-
1062 Common part of the constructors.-
1063*/-
1064void QXmlInputSource::init()-
1065{-
1066 d = new QXmlInputSourcePrivate;-
1067-
1068 QT_TRY {-
1069 d->inputDevice = 0;-
1070 d->inputStream = 0;-
1071-
1072 setData(QString());-
1073#ifndef QT_NO_TEXTCODEC-
1074 d->encMapper = 0;-
1075#endif-
1076 d->nextReturnedEndOfData = true; // first call to next() will call fetchData()-
1077-
1078 d->encodingDeclBytes.clear();-
1079 d->encodingDeclChars.clear();-
1080 d->lookingForEncodingDecl = true;-
1081 } QT_CATCH(...) {
executed 2106 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
dead code: { delete(d); qt_noop(); }
-
1082 delete(d);
dead code: { delete(d); qt_noop(); }
-
1083 QT_RETHROW;
dead code: { delete(d); qt_noop(); }
-
1084 }
dead code: { delete(d); qt_noop(); }
-
1085}-
1086-
1087/*!-
1088 Constructs an input source which contains no data.-
1089-
1090 \sa setData()-
1091*/-
1092QXmlInputSource::QXmlInputSource()-
1093{-
1094 init();-
1095}
executed 1734 times by 5 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
1734
1096-
1097/*!-
1098 Constructs an input source and gets the data from device \a dev.-
1099 If \a dev is not open, it is opened in read-only mode. If \a dev-
1100 is 0 or it is not possible to read from the device, the input-
1101 source will contain no data.-
1102-
1103 \sa setData(), fetchData(), QIODevice-
1104*/-
1105QXmlInputSource::QXmlInputSource(QIODevice *dev)-
1106{-
1107 init();-
1108 d->inputDevice = dev;-
1109 if (dev->isOpen())
dev->isOpen()Description
TRUEevaluated 363 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
9-363
1110 d->inputDevice->setTextModeEnabled(false);
executed 363 times by 2 tests: d->inputDevice->setTextModeEnabled(false);
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
363
1111}
executed 372 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
372
1112-
1113/*!-
1114 Destructor.-
1115*/-
1116QXmlInputSource::~QXmlInputSource()-
1117{-
1118 // ### close the input device.-
1119#ifndef QT_NO_TEXTCODEC-
1120 delete d->encMapper;-
1121#endif-
1122 delete d;-
1123}
executed 2106 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2106
1124-
1125/*!-
1126Returns the next character of the input source. If this function-
1127reaches the end of available data, it returns-
1128QXmlInputSource::EndOfData. If you call next() after that, it-
1129tries to fetch more data by calling fetchData(). If the-
1130fetchData() call results in new data, this function returns the-
1131first character of that data; otherwise it returns-
1132QXmlInputSource::EndOfDocument.-
1133-
1134Readers, such as QXmlSimpleReader, will assume that the end of-
1135the XML document has been reached if the this function returns-
1136QXmlInputSource::EndOfDocument, and will check that the-
1137supplied input is well-formed. Therefore, when reimplementing-
1138this function, it is important to ensure that this behavior is-
1139duplicated.-
1140-
1141\sa reset(), fetchData(), QXmlSimpleReader::parse(),-
1142 QXmlSimpleReader::parseContinue()-
1143*/-
1144QChar QXmlInputSource::next()-
1145{-
1146 if (d->pos >= d->length) {
d->pos >= d->lengthDescription
TRUEevaluated 48748 times by 6 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 744723 times by 6 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
48748-744723
1147 if (d->nextReturnedEndOfData) {
d->nextReturnedEndOfDataDescription
TRUEevaluated 2851 times by 6 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 45897 times by 6 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2851-45897
1148 d->nextReturnedEndOfData = false;-
1149 fetchData();-
1150 if (d->pos >= d->length) {
d->pos >= d->lengthDescription
TRUEevaluated 1961 times by 6 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 890 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
890-1961
1151 return EndOfDocument;
executed 1961 times by 6 tests: return EndOfDocument;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1961
1152 }-
1153 return next();
executed 890 times by 3 tests: return next();
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
890
1154 }-
1155 d->nextReturnedEndOfData = true;-
1156 return EndOfData;
executed 45897 times by 6 tests: return EndOfData;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
45897
1157 }-
1158-
1159 // QXmlInputSource has no way to signal encoding errors. The best we can do-
1160 // is return EndOfDocument. We do *not* return EndOfData, because the reader-
1161 // will then just call this function again to get the next char.-
1162 QChar c = d->unicode[d->pos++];-
1163 if (c.unicode() == EndOfData)
c.unicode() == EndOfDataDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 744722 times by 6 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1-744722
1164 c = EndOfDocument;
executed 1 time by 1 test: c = EndOfDocument;
Executed by:
  • tst_qxmlsimplereader - unknown status
1
1165 return c;
executed 744723 times by 6 tests: return c;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
744723
1166}-
1167-
1168/*!-
1169 This function sets the position used by next() to the beginning of-
1170 the data returned by data(). This is useful if you want to use the-
1171 input source for more than one parse.-
1172-
1173 \note In the case that the underlying data source is a QIODevice,-
1174 the current position in the device is not automatically set to the-
1175 start of input. Call QIODevice::seek(0) on the device to do this.-
1176-
1177 \sa next()-
1178*/-
1179void QXmlInputSource::reset()-
1180{-
1181 d->nextReturnedEndOfData = false;-
1182 d->pos = 0;-
1183}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
4
1184-
1185/*!-
1186 Returns the data the input source contains or an empty string if the-
1187 input source does not contain any data.-
1188-
1189 \sa setData(), QXmlInputSource(), fetchData()-
1190*/-
1191QString QXmlInputSource::data() const-
1192{-
1193 if (d->nextReturnedEndOfData) {
d->nextReturnedEndOfDataDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qxmlinputsource - unknown status
0-4
1194 QXmlInputSource *that = const_cast<QXmlInputSource*>(this);-
1195 that->d->nextReturnedEndOfData = false;-
1196 that->fetchData();-
1197 }
never executed: end of block
0
1198 return d->str;
executed 4 times by 1 test: return d->str;
Executed by:
  • tst_qxmlinputsource - unknown status
4
1199}-
1200-
1201/*!-
1202 Sets the data of the input source to \a dat.-
1203-
1204 If the input source already contains data, this function deletes-
1205 that data first.-
1206-
1207 \sa data()-
1208*/-
1209void QXmlInputSource::setData(const QString& dat)-
1210{-
1211 d->str = dat;-
1212 d->unicode = dat.unicode();-
1213 d->pos = 0;-
1214 d->length = d->str.length();-
1215 d->nextReturnedEndOfData = false;-
1216}
executed 48375 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
48375
1217-
1218/*!-
1219 \overload-
1220-
1221 The data \a dat is passed through the correct text-codec, before-
1222 it is set.-
1223*/-
1224void QXmlInputSource::setData(const QByteArray& dat)-
1225{-
1226 setData(fromRawData(dat));-
1227}
executed 44908 times by 1 test: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
44908
1228-
1229/*!-
1230 This function reads more data from the device that was set during-
1231 construction. If the input source already contained data, this-
1232 function deletes that data first.-
1233-
1234 This object contains no data after a call to this function if the-
1235 object was constructed without a device to read data from or if-
1236 this function was not able to get more data from the device.-
1237-
1238 There are two occasions where a fetch is done implicitly by-
1239 another function call: during construction (so that the object-
1240 starts out with some initial data where available), and during a-
1241 call to next() (if the data had run out).-
1242-
1243 You don't normally need to use this function if you use next().-
1244-
1245 \sa data(), next(), QXmlInputSource()-
1246*/-
1247-
1248void QXmlInputSource::fetchData()-
1249{-
1250 enum-
1251 {-
1252 BufferSize = 1024-
1253 };-
1254-
1255 QByteArray rawData;-
1256-
1257 if (d->inputDevice || d->inputStream) {
d->inputDeviceDescription
TRUEevaluated 1117 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 1734 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
d->inputStreamDescription
TRUEnever evaluated
FALSEevaluated 1734 times by 5 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
0-1734
1258 QIODevice *device = d->inputDevice ? d->inputDevice : d->inputStream->device();
d->inputDeviceDescription
TRUEevaluated 1117 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEnever evaluated
0-1117
1259-
1260 if (!device) {
!deviceDescription
TRUEnever evaluated
FALSEevaluated 1117 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
0-1117
1261 if (d->inputStream && d->inputStream->string()) {
d->inputStreamDescription
TRUEnever evaluated
FALSEnever evaluated
d->inputStream->string()Description
TRUEnever evaluated
FALSEnever evaluated
0
1262 QString *s = d->inputStream->string();-
1263 rawData = QByteArray((const char *) s->constData(), s->size() * sizeof(QChar));-
1264 }
never executed: end of block
0
1265 } else if (device->isOpen() || device->open(QIODevice::ReadOnly)) {
never executed: end of block
device->isOpen()Description
TRUEevaluated 1108 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
device->open(Q...ice::ReadOnly)Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
0-1108
1266 rawData.resize(BufferSize);-
1267 qint64 size = device->read(rawData.data(), BufferSize);-
1268-
1269 if (size != -1) {
size != -1Description
TRUEevaluated 1117 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEnever evaluated
0-1117
1270 // We don't want to give fromRawData() less than four bytes if we can avoid it.-
1271 while (size < 4) {
size < 4Description
TRUEevaluated 235 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 890 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
235-890
1272 if (!device->waitForReadyRead(-1))
!device->waitForReadyRead(-1)Description
TRUEevaluated 227 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
8-227
1273 break;
executed 227 times by 3 tests: break;
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
227
1274 int ret = device->read(rawData.data() + size, BufferSize - size);-
1275 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
0-8
1276 break;
never executed: break;
0
1277 size += ret;-
1278 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
8
1279 }
executed 1117 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1117
1280-
1281 rawData.resize(qMax(qint64(0), size));-
1282 }
executed 1117 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1117
1283-
1284 /* We do this inside the "if (d->inputDevice ..." scope-
1285 * because if we're not using a stream or device, that is,-
1286 * the user set a QString manually, we don't want to set-
1287 * d->str. */-
1288 setData(fromRawData(rawData));-
1289 }
executed 1117 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1117
1290}
executed 2851 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2851
1291-
1292#ifndef QT_NO_TEXTCODEC-
1293static QString extractEncodingDecl(const QString &text, bool *needMoreText)-
1294{-
1295 *needMoreText = false;-
1296-
1297 int l = text.length();-
1298 const QLatin1String snip("<?xml", std::min(l, 5));-
1299 if (l > 0 && !text.startsWith(snip))
l > 0Description
TRUEevaluated 3097 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
!text.startsWith(snip)Description
TRUEevaluated 1742 times by 2 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1355 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
6-3097
1300 return QString();
executed 1742 times by 2 tests: return QString();
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
1742
1301-
1302 int endPos = text.indexOf(QLatin1Char('>'));-
1303 if (endPos == -1) {
endPos == -1Description
TRUEevaluated 1242 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 119 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
119-1242
1304 *needMoreText = l < 255; // we won't look forever-
1305 return QString();
executed 1242 times by 1 test: return QString();
Executed by:
  • tst_qxmlsimplereader - unknown status
1242
1306 }-
1307-
1308 int pos = text.indexOf(QLatin1String("encoding"));-
1309 if (pos == -1 || pos >= endPos)
pos == -1Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 67 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
pos >= endPosDescription
TRUEnever evaluated
FALSEevaluated 67 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
0-67
1310 return QString();
executed 52 times by 1 test: return QString();
Executed by:
  • tst_qxmlsimplereader - unknown status
52
1311-
1312 while (pos < endPos) {
pos < endPosDescription
TRUEevaluated 670 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEnever evaluated
0-670
1313 ushort uc = text.at(pos).unicode();-
1314 if (uc == '\'' || uc == '"')
uc == '\''Description
TRUEnever evaluated
FALSEevaluated 670 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
uc == '"'Description
TRUEevaluated 67 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 603 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
0-670
1315 break;
executed 67 times by 2 tests: break;
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
67
1316 ++pos;-
1317 }
executed 603 times by 2 tests: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
603
1318-
1319 if (pos == endPos)
pos == endPosDescription
TRUEnever evaluated
FALSEevaluated 67 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
0-67
1320 return QString();
never executed: return QString();
0
1321-
1322 QString encoding;-
1323 ++pos;-
1324 while (pos < endPos) {
pos < endPosDescription
TRUEevaluated 404 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEnever evaluated
0-404
1325 ushort uc = text.at(pos).unicode();-
1326 if (uc == '\'' || uc == '"')
uc == '\''Description
TRUEnever evaluated
FALSEevaluated 404 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
uc == '"'Description
TRUEevaluated 67 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 337 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
0-404
1327 break;
executed 67 times by 2 tests: break;
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
67
1328 encoding.append(uc);-
1329 ++pos;-
1330 }
executed 337 times by 2 tests: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
337
1331-
1332 return encoding;
executed 67 times by 2 tests: return encoding;
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
67
1333}-
1334#endif // QT_NO_TEXTCODEC-
1335-
1336/*!-
1337 This function reads the XML file from \a data and tries to-
1338 recognize the encoding. It converts the raw data \a data into a-
1339 QString and returns it. It tries its best to get the correct-
1340 encoding for the XML file.-
1341-
1342 If \a beginning is true, this function assumes that the data-
1343 starts at the beginning of a new XML document and looks for an-
1344 encoding declaration. If \a beginning is false, it converts the-
1345 raw data using the encoding determined from prior calls.-
1346*/-
1347QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning)-
1348{-
1349#ifdef QT_NO_TEXTCODEC-
1350 Q_UNUSED(beginning);-
1351 return QString::fromLatin1(data.constData(), data.size());-
1352#else-
1353 if (data.size() == 0)
data.size() == 0Description
TRUEevaluated 227 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 45798 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
227-45798
1354 return QString();
executed 227 times by 3 tests: return QString();
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
227
1355 if (beginning) {
beginningDescription
TRUEnever evaluated
FALSEevaluated 45798 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
0-45798
1356 delete d->encMapper;-
1357 d->encMapper = 0;-
1358 }
never executed: end of block
0
1359-
1360 int mib = 106; // UTF-8-
1361-
1362 // This is the initial UTF codec we will read the encoding declaration with-
1363 if (d->encMapper == 0) {
d->encMapper == 0Description
TRUEevaluated 1861 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 43937 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1861-43937
1364 d->encodingDeclBytes.clear();-
1365 d->encodingDeclChars.clear();-
1366 d->lookingForEncodingDecl = true;-
1367-
1368 // look for byte order mark and read the first 5 characters-
1369 if (data.size() >= 4) {
data.size() >= 4Description
TRUEevaluated 1367 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 494 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
494-1367
1370 uchar ch1 = data.at(0);-
1371 uchar ch2 = data.at(1);-
1372 uchar ch3 = data.at(2);-
1373 uchar ch4 = data.at(3);-
1374-
1375 if ((ch1 == 0 && ch2 == 0 && ch3 == 0xfe && ch4 == 0xff) ||
ch1 == 0Description
TRUEnever evaluated
FALSEevaluated 1367 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
ch2 == 0Description
TRUEnever evaluated
FALSEnever evaluated
ch3 == 0xfeDescription
TRUEnever evaluated
FALSEnever evaluated
ch4 == 0xffDescription
TRUEnever evaluated
FALSEnever evaluated
0-1367
1376 (ch1 == 0xff && ch2 == 0xfe && ch3 == 0 && ch4 == 0))
ch1 == 0xffDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1345 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
ch2 == 0xfeDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
ch3 == 0Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
ch4 == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-1345
1377 mib = 1017; // UTF-32 with byte order mark
never executed: mib = 1017;
0
1378 else if (ch1 == 0x3c && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x00)
ch1 == 0x3cDescription
TRUEevaluated 1343 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
ch2 == 0x00Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1342 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
ch3 == 0x00Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
ch4 == 0x00Description
TRUEnever evaluated
FALSEnever evaluated
0-1343
1379 mib = 1019; // UTF-32LE
never executed: mib = 1019;
0
1380 else if (ch1 == 0x00 && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x3c)
ch1 == 0x00Description
TRUEnever evaluated
FALSEevaluated 1367 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
ch2 == 0x00Description
TRUEnever evaluated
FALSEnever evaluated
ch3 == 0x00Description
TRUEnever evaluated
FALSEnever evaluated
ch4 == 0x3cDescription
TRUEnever evaluated
FALSEnever evaluated
0-1367
1381 mib = 1018; // UTF-32BE
never executed: mib = 1018;
0
1382 }
executed 1367 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1367
1383 if (mib == 106 && data.size() >= 2) {
mib == 106Description
TRUEevaluated 1861 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEnever evaluated
data.size() >= 2Description
TRUEevaluated 1699 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 162 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
0-1861
1384 uchar ch1 = data.at(0);-
1385 uchar ch2 = data.at(1);-
1386-
1387 if ((ch1 == 0xfe && ch2 == 0xff) || (ch1 == 0xff && ch2 == 0xfe))
ch1 == 0xfeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1698 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
ch2 == 0xffDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
ch1 == 0xffDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1670 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
ch2 == 0xfeDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEnever evaluated
0-1698
1388 mib = 1015; // UTF-16 with byte order mark
executed 29 times by 1 test: mib = 1015;
Executed by:
  • tst_qxmlsimplereader - unknown status
29
1389 else if (ch1 == 0x3c && ch2 == 0x00)
ch1 == 0x3cDescription
TRUEevaluated 1669 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
ch2 == 0x00Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 1668 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1-1669
1390 mib = 1014; // UTF-16LE
executed 1 time by 1 test: mib = 1014;
Executed by:
  • tst_qxmlsimplereader - unknown status
1
1391 else if (ch1 == 0x00 && ch2 == 0x3c)
ch1 == 0x00Description
TRUEnever evaluated
FALSEevaluated 1669 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
ch2 == 0x3cDescription
TRUEnever evaluated
FALSEnever evaluated
0-1669
1392 mib = 1013; // UTF-16BE
never executed: mib = 1013;
0
1393 }
executed 1699 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1699
1394-
1395 QTextCodec *codec = QTextCodec::codecForMib(mib);-
1396 Q_ASSERT(codec);-
1397-
1398 d->encMapper = codec->makeDecoder();-
1399 }
executed 1861 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1861
1400-
1401 QString input = d->encMapper->toUnicode(data.constData(), data.size());-
1402-
1403 if (d->lookingForEncodingDecl) {
d->lookingForEncodingDeclDescription
TRUEevaluated 3103 times by 3 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 42695 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
3103-42695
1404 d->encodingDeclChars += input;-
1405-
1406 bool needMoreText;-
1407 QString encoding = extractEncodingDecl(d->encodingDeclChars, &needMoreText);-
1408-
1409 if (!encoding.isEmpty()) {
!encoding.isEmpty()Description
TRUEevaluated 67 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 3036 times by 2 tests
Evaluated by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
67-3036
1410 if (QTextCodec *codec = QTextCodec::codecForName(encoding.toLatin1())) {
QTextCodec *co...ng.toLatin1())Description
TRUEevaluated 67 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEnever evaluated
0-67
1411 /* If the encoding is the same, we don't have to do toUnicode() all over again. */-
1412 if(codec->mibEnum() != mib) {
codec->mibEnum() != mibDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 66 times by 2 tests
Evaluated by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1-66
1413 delete d->encMapper;-
1414 d->encMapper = codec->makeDecoder();-
1415-
1416 /* The variable input can potentially be large, so we deallocate-
1417 * it before calling toUnicode() in order to avoid having two-
1418 * large QStrings in memory simultaneously. */-
1419 input.clear();-
1420-
1421 // prime the decoder with the data so far-
1422 d->encMapper->toUnicode(d->encodingDeclBytes.constData(), d->encodingDeclBytes.size());-
1423 // now feed it the new data-
1424 input = d->encMapper->toUnicode(data.constData(), data.size());-
1425 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
1
1426 }
executed 67 times by 2 tests: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
67
1427 }
executed 67 times by 2 tests: end of block
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
67
1428-
1429 d->encodingDeclBytes += data;-
1430 d->lookingForEncodingDecl = needMoreText;-
1431 }
executed 3103 times by 3 tests: end of block
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
3103
1432-
1433 return input;
executed 45798 times by 3 tests: return input;
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
45798
1434#endif-
1435}-
1436-
1437-
1438/*********************************************-
1439 *-
1440 * QXmlDefaultHandler-
1441 *-
1442 *********************************************/-
1443-
1444/*!-
1445 \class QXmlContentHandler-
1446 \reentrant-
1447 \brief The QXmlContentHandler class provides an interface to-
1448 report the logical content of XML data.-
1449-
1450 \inmodule QtXml-
1451 \ingroup xml-tools-
1452-
1453 If the application needs to be informed of basic parsing events,-
1454 it can implement this interface and activate it using-
1455 QXmlReader::setContentHandler(). The reader can then report basic-
1456 document-related events like the start and end of elements and-
1457 character data through this interface.-
1458-
1459 The order of events in this interface is very important, and-
1460 mirrors the order of information in the document itself. For-
1461 example, all of an element's content (character data, processing-
1462 instructions, and sub-elements) appears, in order, between the-
1463 startElement() event and the corresponding endElement() event.-
1464-
1465 The class QXmlDefaultHandler provides a default implementation for-
1466 this interface; subclassing from the QXmlDefaultHandler class is-
1467 very convenient if you only want to be informed of some parsing-
1468 events.-
1469-
1470 The startDocument() function is called at the start of the-
1471 document, and endDocument() is called at the end. Before parsing-
1472 begins setDocumentLocator() is called. For each element-
1473 startElement() is called, with endElement() being called at the-
1474 end of each element. The characters() function is called with-
1475 chunks of character data; ignorableWhitespace() is called with-
1476 chunks of whitespace and processingInstruction() is called with-
1477 processing instructions. If an entity is skipped skippedEntity()-
1478 is called. At the beginning of prefix-URI scopes-
1479 startPrefixMapping() is called.-
1480-
1481 \sa QXmlDTDHandler, QXmlDeclHandler, QXmlEntityResolver, QXmlErrorHandler,-
1482 QXmlLexicalHandler, {Introduction to SAX2}-
1483*/-
1484-
1485/*!-
1486 \fn QXmlContentHandler::~QXmlContentHandler()-
1487-
1488 Destroys the content handler.-
1489*/-
1490-
1491/*!-
1492 \fn void QXmlContentHandler::setDocumentLocator(QXmlLocator* locator)-
1493-
1494 The reader calls this function before it starts parsing the-
1495 document. The argument \a locator is a pointer to a QXmlLocator-
1496 which allows the application to get the parsing position within-
1497 the document.-
1498-
1499 Do not destroy the \a locator; it is destroyed when the reader is-
1500 destroyed. (Do not use the \a locator after the reader is-
1501 destroyed).-
1502*/-
1503-
1504/*!-
1505 \fn bool QXmlContentHandler::startDocument()-
1506-
1507 The reader calls this function when it starts parsing the-
1508 document. The reader calls this function just once, after the call-
1509 to setDocumentLocator(), and before any other functions in this-
1510 class or in the QXmlDTDHandler class are called.-
1511-
1512 If this function returns \c false the reader stops parsing and-
1513 reports an error. The reader uses the function errorString() to-
1514 get the error message.-
1515-
1516 \sa endDocument()-
1517*/-
1518-
1519/*!-
1520 \fn bool QXmlContentHandler::endDocument()-
1521-
1522 The reader calls this function after it has finished parsing. It-
1523 is called just once, and is the last handler function called. It-
1524 is called after the reader has read all input or has abandoned-
1525 parsing because of a fatal error.-
1526-
1527 If this function returns \c false the reader stops parsing and-
1528 reports an error. The reader uses the function errorString() to-
1529 get the error message.-
1530-
1531 \sa startDocument()-
1532*/-
1533-
1534/*!-
1535 \fn bool QXmlContentHandler::startPrefixMapping(const QString& prefix, const QString& uri)-
1536-
1537 The reader calls this function to signal the begin of a prefix-URI-
1538 namespace mapping scope. This information is not necessary for-
1539 normal namespace processing since the reader automatically-
1540 replaces prefixes for element and attribute names.-
1541-
1542 Note that startPrefixMapping() and endPrefixMapping() calls are-
1543 not guaranteed to be properly nested relative to each other: all-
1544 startPrefixMapping() events occur before the corresponding-
1545 startElement() event, and all endPrefixMapping() events occur-
1546 after the corresponding endElement() event, but their order is not-
1547 otherwise guaranteed.-
1548-
1549 The argument \a prefix is the namespace prefix being declared and-
1550 the argument \a uri is the namespace URI the prefix is mapped to.-
1551-
1552 If this function returns \c false the reader stops parsing and-
1553 reports an error. The reader uses the function errorString() to-
1554 get the error message.-
1555-
1556 \sa endPrefixMapping(), {Namespace Support via Features}-
1557*/-
1558-
1559/*!-
1560 \fn bool QXmlContentHandler::endPrefixMapping(const QString& prefix)-
1561-
1562 The reader calls this function to signal the end of a prefix-
1563 mapping for the prefix \a prefix.-
1564-
1565 If this function returns \c false the reader stops parsing and-
1566 reports an error. The reader uses the function errorString() to-
1567 get the error message.-
1568-
1569 \sa startPrefixMapping(), {Namespace Support via Features}-
1570*/-
1571-
1572/*!-
1573 \fn bool QXmlContentHandler::startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts)-
1574-
1575 The reader calls this function when it has parsed a start element-
1576 tag.-
1577-
1578 There is a corresponding endElement() call when the corresponding-
1579 end element tag is read. The startElement() and endElement() calls-
1580 are always nested correctly. Empty element tags (e.g. \c{<x/>})-
1581 cause a startElement() call to be immediately followed by an-
1582 endElement() call.-
1583-
1584 The attribute list provided only contains attributes with explicit-
1585 values. The attribute list contains attributes used for namespace-
1586 declaration (i.e. attributes starting with xmlns) only if the-
1587 namespace-prefix property of the reader is true.-
1588-
1589 The argument \a namespaceURI is the namespace URI, or-
1590 an empty string if the element has no namespace URI or if no-
1591 namespace processing is done. \a localName is the local name-
1592 (without prefix), or an empty string if no namespace processing is-
1593 done, \a qName is the qualified name (with prefix) and \a atts are-
1594 the attributes attached to the element. If there are no-
1595 attributes, \a atts is an empty attributes object.-
1596-
1597 If this function returns \c false the reader stops parsing and-
1598 reports an error. The reader uses the function errorString() to-
1599 get the error message.-
1600-
1601 \sa endElement(), {Namespace Support via Features}-
1602*/-
1603-
1604/*!-
1605 \fn bool QXmlContentHandler::endElement(const QString& namespaceURI, const QString& localName, const QString& qName)-
1606-
1607 The reader calls this function when it has parsed an end element-
1608 tag with the qualified name \a qName, the local name \a localName-
1609 and the namespace URI \a namespaceURI.-
1610-
1611 If this function returns \c false the reader stops parsing and-
1612 reports an error. The reader uses the function errorString() to-
1613 get the error message.-
1614-
1615 \sa startElement(), {Namespace Support via Features}-
1616*/-
1617-
1618/*!-
1619 \fn bool QXmlContentHandler::characters(const QString& ch)-
1620-
1621 The reader calls this function when it has parsed a chunk of-
1622 character data (either normal character data or character data-
1623 inside a CDATA section; if you need to distinguish between those-
1624 two types you must use QXmlLexicalHandler::startCDATA() and-
1625 QXmlLexicalHandler::endCDATA()). The character data is reported in-
1626 \a ch.-
1627-
1628 Some readers report whitespace in element content using the-
1629 ignorableWhitespace() function rather than using this one.-
1630-
1631 A reader may report the character data of an element in more than-
1632 one chunk; e.g. a reader might want to report "a\<b" in three-
1633 characters() events ("a ", "\<" and " b").-
1634-
1635 If this function returns \c false the reader stops parsing and-
1636 reports an error. The reader uses the function errorString() to-
1637 get the error message.-
1638*/-
1639-
1640/*!-
1641 \fn bool QXmlContentHandler::ignorableWhitespace(const QString& ch)-
1642-
1643 Some readers may use this function to report each chunk of-
1644 whitespace in element content. The whitespace is reported in \a ch.-
1645-
1646 If this function returns \c false the reader stops parsing and-
1647 reports an error. The reader uses the function errorString() to-
1648 get the error message.-
1649*/-
1650-
1651/*!-
1652 \fn bool QXmlContentHandler::processingInstruction(const QString& target, const QString& data)-
1653-
1654 The reader calls this function when it has parsed a processing-
1655 instruction.-
1656-
1657 \a target is the target name of the processing instruction and \a-
1658 data is the data in the processing instruction.-
1659-
1660 If this function returns \c false the reader stops parsing and-
1661 reports an error. The reader uses the function errorString() to-
1662 get the error message.-
1663*/-
1664-
1665/*!-
1666 \fn bool QXmlContentHandler::skippedEntity(const QString& name)-
1667-
1668 Some readers may skip entities if they have not seen the-
1669 declarations (e.g. because they are in an external DTD). If they-
1670 do so they report that they skipped the entity called \a name by-
1671 calling this function.-
1672-
1673 If this function returns \c false the reader stops parsing and-
1674 reports an error. The reader uses the function errorString() to-
1675 get the error message.-
1676*/-
1677-
1678/*!-
1679 \fn QString QXmlContentHandler::errorString() const-
1680-
1681 The reader calls this function to get an error string, e.g. if any-
1682 of the handler functions returns \c false.-
1683*/-
1684-
1685-
1686/*!-
1687 \class QXmlErrorHandler-
1688 \reentrant-
1689 \brief The QXmlErrorHandler class provides an interface to report-
1690 errors in XML data.-
1691-
1692 \inmodule QtXml-
1693 \ingroup xml-tools-
1694-
1695 If you want your application to report errors to the user or to-
1696 perform customized error handling, you should subclass this class.-
1697-
1698 You can set the error handler with QXmlReader::setErrorHandler().-
1699-
1700 Errors can be reported using warning(), error() and fatalError(),-
1701 with the error text being reported with errorString().-
1702-
1703 \sa QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver,-
1704 QXmlLexicalHandler, {Introduction to SAX2}-
1705*/-
1706-
1707/*!-
1708 \fn QXmlErrorHandler::~QXmlErrorHandler()-
1709-
1710 Destroys the error handler.-
1711*/-
1712-
1713/*!-
1714 \fn bool QXmlErrorHandler::warning(const QXmlParseException& exception)-
1715-
1716 A reader might use this function to report a warning. Warnings are-
1717 conditions that are not errors or fatal errors as defined by the-
1718 XML 1.0 specification. Details of the warning are stored in \a-
1719 exception.-
1720-
1721 If this function returns \c false the reader stops parsing and-
1722 reports an error. The reader uses the function errorString() to-
1723 get the error message.-
1724*/-
1725-
1726/*!-
1727 \fn bool QXmlErrorHandler::error(const QXmlParseException& exception)-
1728-
1729 A reader might use this function to report a recoverable error. A-
1730 recoverable error corresponds to the definiton of "error" in-
1731 section 1.2 of the XML 1.0 specification. Details of the error are-
1732 stored in \a exception.-
1733-
1734 The reader must continue to provide normal parsing events after-
1735 invoking this function.-
1736-
1737 If this function returns \c false the reader stops parsing and-
1738 reports an error. The reader uses the function errorString() to-
1739 get the error message.-
1740*/-
1741-
1742/*!-
1743\fn bool QXmlErrorHandler::fatalError(const QXmlParseException& exception)-
1744-
1745A reader must use this function to report a non-recoverable error.-
1746Details of the error are stored in \a exception.-
1747-
1748If this function returns \c true the reader might try to go on-
1749parsing and reporting further errors, but no regular parsing-
1750events are reported.-
1751*/-
1752-
1753/*!-
1754 \fn QString QXmlErrorHandler::errorString() const-
1755-
1756 The reader calls this function to get an error string if any of-
1757 the handler functions returns \c false.-
1758*/-
1759-
1760-
1761/*!-
1762 \class QXmlDTDHandler-
1763 \reentrant-
1764 \brief The QXmlDTDHandler class provides an interface to report-
1765 DTD content of XML data.-
1766-
1767 \inmodule QtXml-
1768 \ingroup xml-tools-
1769-
1770 If an application needs information about notations and unparsed-
1771 entities, it can implement this interface and register an instance-
1772 with QXmlReader::setDTDHandler().-
1773-
1774 Note that this interface includes only those DTD events that the-
1775 XML recommendation requires processors to report, i.e. notation-
1776 and unparsed entity declarations using notationDecl() and-
1777 unparsedEntityDecl() respectively.-
1778-
1779 \sa QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver, QXmlErrorHandler,-
1780 QXmlLexicalHandler, {Introduction to SAX2}-
1781*/-
1782-
1783/*!-
1784 \fn QXmlDTDHandler::~QXmlDTDHandler()-
1785-
1786 Destroys the DTD handler.-
1787*/-
1788-
1789/*!-
1790 \fn bool QXmlDTDHandler::notationDecl(const QString& name, const QString& publicId, const QString& systemId)-
1791-
1792 The reader calls this function when it has parsed a notation-
1793 declaration.-
1794-
1795 The argument \a name is the notation name, \a publicId is the-
1796 notation's public identifier and \a systemId is the notation's-
1797 system identifier.-
1798-
1799 If this function returns \c false the reader stops parsing and-
1800 reports an error. The reader uses the function errorString() to-
1801 get the error message.-
1802*/-
1803-
1804/*!-
1805 \fn bool QXmlDTDHandler::unparsedEntityDecl(const QString& name, const QString& publicId, const QString& systemId, const QString& notationName)-
1806-
1807 The reader calls this function when it finds an unparsed entity-
1808 declaration.-
1809-
1810 The argument \a name is the unparsed entity's name, \a publicId is-
1811 the entity's public identifier, \a systemId is the entity's system-
1812 identifier and \a notationName is the name of the associated-
1813 notation.-
1814-
1815 If this function returns \c false the reader stops parsing and-
1816 reports an error. The reader uses the function errorString() to-
1817 get the error message.-
1818*/-
1819-
1820/*!-
1821 \fn QString QXmlDTDHandler::errorString() const-
1822-
1823 The reader calls this function to get an error string if any of-
1824 the handler functions returns \c false.-
1825*/-
1826-
1827-
1828/*!-
1829 \class QXmlEntityResolver-
1830 \reentrant-
1831 \brief The QXmlEntityResolver class provides an interface to-
1832 resolve external entities contained in XML data.-
1833-
1834 \inmodule QtXml-
1835 \ingroup xml-tools-
1836-
1837 If an application needs to implement customized handling for-
1838 external entities, it must implement this interface, i.e.-
1839 resolveEntity(), and register it with-
1840 QXmlReader::setEntityResolver().-
1841-
1842 \sa QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlErrorHandler,-
1843 QXmlLexicalHandler, {Introduction to SAX2}-
1844*/-
1845-
1846/*!-
1847 \fn QXmlEntityResolver::~QXmlEntityResolver()-
1848-
1849 Destroys the entity resolver.-
1850*/-
1851-
1852/*!-
1853 \fn bool QXmlEntityResolver::resolveEntity(const QString& publicId, const QString& systemId, QXmlInputSource*& ret)-
1854-
1855 The reader calls this function before it opens any external-
1856 entity, except the top-level document entity. The application may-
1857 request the reader to resolve the entity itself (\a ret is 0) or-
1858 to use an entirely different input source (\a ret points to the-
1859 input source).-
1860-
1861 The reader deletes the input source \a ret when it no longer needs-
1862 it, so you should allocate it on the heap with \c new.-
1863-
1864 The argument \a publicId is the public identifier of the external-
1865 entity, \a systemId is the system identifier of the external-
1866 entity and \a ret is the return value of this function. If \a ret-
1867 is 0 the reader should resolve the entity itself, if it is-
1868 non-zero it must point to an input source which the reader uses-
1869 instead.-
1870-
1871 If this function returns \c false the reader stops parsing and-
1872 reports an error. The reader uses the function errorString() to-
1873 get the error message.-
1874*/-
1875-
1876/*!-
1877 \fn QString QXmlEntityResolver::errorString() const-
1878-
1879 The reader calls this function to get an error string if any of-
1880 the handler functions returns \c false.-
1881*/-
1882-
1883-
1884/*!-
1885 \class QXmlLexicalHandler-
1886 \reentrant-
1887 \brief The QXmlLexicalHandler class provides an interface to-
1888 report the lexical content of XML data.-
1889-
1890 \inmodule QtXml-
1891 \ingroup xml-tools-
1892-
1893 The events in the lexical handler apply to the entire document,-
1894 not just to the document element, and all lexical handler events-
1895 appear between the content handler's startDocument and endDocument-
1896 events.-
1897-
1898 You can set the lexical handler with-
1899 QXmlReader::setLexicalHandler().-
1900-
1901 This interface's design is based on the SAX2 extension-
1902 LexicalHandler.-
1903-
1904 The interface provides the startDTD(), endDTD(), startEntity(),-
1905 endEntity(), startCDATA(), endCDATA() and comment() functions.-
1906-
1907 \sa QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver,-
1908 QXmlErrorHandler, {Introduction to SAX2}-
1909*/-
1910-
1911/*!-
1912 \fn QXmlLexicalHandler::~QXmlLexicalHandler()-
1913-
1914 Destroys the lexical handler.-
1915*/-
1916-
1917/*!-
1918 \fn bool QXmlLexicalHandler::startDTD(const QString& name, const QString& publicId, const QString& systemId)-
1919-
1920 The reader calls this function to report the start of a DTD-
1921 declaration, if any. It reports the name of the document type in-
1922 \a name, the public identifier in \a publicId and the system-
1923 identifier in \a systemId.-
1924-
1925 If the public identifier is missing, \a publicId is set to-
1926 an empty string. If the system identifier is missing, \a systemId is-
1927 set to an empty string. Note that it is not valid XML to have a-
1928 public identifier but no system identifier; in such cases a parse-
1929 error will occur.-
1930-
1931 All declarations reported through QXmlDTDHandler or-
1932 QXmlDeclHandler appear between the startDTD() and endDTD() calls.-
1933-
1934 If this function returns \c false the reader stops parsing and-
1935 reports an error. The reader uses the function errorString() to-
1936 get the error message.-
1937-
1938 \sa endDTD()-
1939*/-
1940-
1941/*!-
1942 \fn bool QXmlLexicalHandler::endDTD()-
1943-
1944 The reader calls this function to report the end of a DTD-
1945 declaration, if any.-
1946-
1947 If this function returns \c false the reader stops parsing and-
1948 reports an error. The reader uses the function errorString() to-
1949 get the error message.-
1950-
1951 \sa startDTD()-
1952*/-
1953-
1954/*!-
1955 \fn bool QXmlLexicalHandler::startEntity(const QString& name)-
1956-
1957 The reader calls this function to report the start of an entity-
1958 called \a name.-
1959-
1960 Note that if the entity is unknown, the reader reports it through-
1961 QXmlContentHandler::skippedEntity() and not through this-
1962 function.-
1963-
1964 If this function returns \c false the reader stops parsing and-
1965 reports an error. The reader uses the function errorString() to-
1966 get the error message.-
1967-
1968 \sa endEntity(), QXmlSimpleReader::setFeature()-
1969*/-
1970-
1971/*!-
1972 \fn bool QXmlLexicalHandler::endEntity(const QString& name)-
1973-
1974 The reader calls this function to report the end of an entity-
1975 called \a name.-
1976-
1977 For every startEntity() call, there is a corresponding endEntity()-
1978 call. The calls to startEntity() and endEntity() are properly-
1979 nested.-
1980-
1981 If this function returns \c false the reader stops parsing and-
1982 reports an error. The reader uses the function errorString() to-
1983 get the error message.-
1984-
1985 \sa startEntity(), QXmlContentHandler::skippedEntity(), QXmlSimpleReader::setFeature()-
1986*/-
1987-
1988/*!-
1989 \fn bool QXmlLexicalHandler::startCDATA()-
1990-
1991 The reader calls this function to report the start of a CDATA-
1992 section. The content of the CDATA section is reported through the-
1993 QXmlContentHandler::characters() function. This function is-
1994 intended only to report the boundary.-
1995-
1996 If this function returns \c false the reader stops parsing and-
1997 reports an error. The reader uses the function errorString() to-
1998 get the error message.-
1999-
2000 \sa endCDATA()-
2001*/-
2002-
2003/*!-
2004 \fn bool QXmlLexicalHandler::endCDATA()-
2005-
2006 The reader calls this function to report the end of a CDATA-
2007 section.-
2008-
2009 If this function returns \c false the reader stops parsing and reports-
2010 an error. The reader uses the function errorString() to get the error-
2011 message.-
2012-
2013 \sa startCDATA(), QXmlContentHandler::characters()-
2014*/-
2015-
2016/*!-
2017 \fn bool QXmlLexicalHandler::comment(const QString& ch)-
2018-
2019 The reader calls this function to report an XML comment anywhere-
2020 in the document. It reports the text of the comment in \a ch.-
2021-
2022 If this function returns \c false the reader stops parsing and-
2023 reports an error. The reader uses the function errorString() to-
2024 get the error message.-
2025*/-
2026-
2027/*!-
2028 \fn QString QXmlLexicalHandler::errorString() const-
2029-
2030 The reader calls this function to get an error string if any of-
2031 the handler functions returns \c false.-
2032*/-
2033-
2034-
2035/*!-
2036 \class QXmlDeclHandler-
2037 \reentrant-
2038 \brief The QXmlDeclHandler class provides an interface to report declaration-
2039 content of XML data.-
2040-
2041 \inmodule QtXml-
2042 \ingroup xml-tools-
2043-
2044 You can set the declaration handler with-
2045 QXmlReader::setDeclHandler().-
2046-
2047 This interface is based on the SAX2 extension DeclHandler.-
2048-
2049 The interface provides attributeDecl(), internalEntityDecl() and-
2050 externalEntityDecl() functions.-
2051-
2052 \sa QXmlDTDHandler, QXmlContentHandler, QXmlEntityResolver, QXmlErrorHandler,-
2053 QXmlLexicalHandler, {Introduction to SAX2}-
2054*/-
2055-
2056/*!-
2057 \fn QXmlDeclHandler::~QXmlDeclHandler()-
2058-
2059 Destroys the declaration handler.-
2060*/-
2061-
2062/*!-
2063 \fn bool QXmlDeclHandler::attributeDecl(const QString& eName, const QString& aName, const QString& type, const QString& valueDefault, const QString& value)-
2064-
2065 The reader calls this function to report an attribute type-
2066 declaration. Only the effective (first) declaration for an-
2067 attribute is reported.-
2068-
2069 The reader passes the name of the associated element in \a eName-
2070 and the name of the attribute in \a aName. It passes a string that-
2071 represents the attribute type in \a type and a string that-
2072 represents the attribute default in \a valueDefault. This string-
2073 is one of "#IMPLIED", "#REQUIRED", "#FIXED" or an empty string (if-
2074 none of the others applies). The reader passes the attribute's-
2075 default value in \a value. If no default value is specified in the-
2076 XML file, \a value is an empty string.-
2077-
2078 If this function returns \c false the reader stops parsing and-
2079 reports an error. The reader uses the function errorString() to-
2080 get the error message.-
2081*/-
2082-
2083/*!-
2084 \fn bool QXmlDeclHandler::internalEntityDecl(const QString& name, const QString& value)-
2085-
2086 The reader calls this function to report an internal entity-
2087 declaration. Only the effective (first) declaration is reported.-
2088-
2089 The reader passes the name of the entity in \a name and the value-
2090 of the entity in \a value.-
2091-
2092 If this function returns \c false the reader stops parsing and-
2093 reports an error. The reader uses the function errorString() to-
2094 get the error message.-
2095*/-
2096-
2097/*!-
2098 \fn bool QXmlDeclHandler::externalEntityDecl(const QString& name, const QString& publicId, const QString& systemId)-
2099-
2100 The reader calls this function to report a parsed external entity-
2101 declaration. Only the effective (first) declaration for each-
2102 entity is reported.-
2103-
2104 The reader passes the name of the entity in \a name, the public-
2105 identifier in \a publicId and the system identifier in \a-
2106 systemId. If there is no public identifier specified, it passes-
2107 an empty string in \a publicId.-
2108-
2109 If this function returns \c false the reader stops parsing and-
2110 reports an error. The reader uses the function errorString() to-
2111 get the error message.-
2112*/-
2113-
2114/*!-
2115 \fn QString QXmlDeclHandler::errorString() const-
2116-
2117 The reader calls this function to get an error string if any of-
2118 the handler functions returns \c false.-
2119*/-
2120-
2121-
2122/*!-
2123 \class QXmlDefaultHandler-
2124 \reentrant-
2125 \brief The QXmlDefaultHandler class provides a default implementation of all-
2126 the XML handler classes.-
2127-
2128 \inmodule QtXml-
2129 \ingroup xml-tools-
2130-
2131 This class gathers together the features of-
2132 the specialized handler classes, making it a convenient-
2133 starting point when implementing custom handlers for-
2134 subclasses of QXmlReader, particularly QXmlSimpleReader.-
2135 The virtual functions from each of the base classes are-
2136 reimplemented in this class, providing sensible default behavior-
2137 for many common cases. By subclassing this class, and-
2138 overriding these functions, you can concentrate-
2139 on implementing the parts of the handler relevant to your-
2140 application.-
2141-
2142 The XML reader must be told which handler to use for different-
2143 kinds of events during parsing. This means that, although-
2144 QXmlDefaultHandler provides default implementations of functions-
2145 inherited from all its base classes, we can still use specialized-
2146 handlers for particular kinds of events.-
2147-
2148 For example, QXmlDefaultHandler subclasses both-
2149 QXmlContentHandler and QXmlErrorHandler, so by subclassing-
2150 it we can use the same handler for both of the following-
2151 reader functions:-
2152-
2153 \snippet rsslisting/listing.cpp 0-
2154-
2155 Since the reader will inform the handler of parsing errors, it is-
2156 necessary to reimplement QXmlErrorHandler::fatalError() if, for-
2157 example, we want to stop parsing when such an error occurs:-
2158-
2159 \snippet rsslisting/handler.cpp 0-
2160-
2161 The above function returns \c false, which tells the reader to stop-
2162 parsing. To continue to use the same reader,-
2163 it is necessary to create a new handler instance, and set up the-
2164 reader to use it in the manner described above.-
2165-
2166 It is useful to examine some of the functions inherited by-
2167 QXmlDefaultHandler, and consider why they might be-
2168 reimplemented in a custom handler.-
2169 Custom handlers will typically reimplement-
2170 QXmlContentHandler::startDocument() to prepare the handler for-
2171 new content. Document elements and the text within them can be-
2172 processed by reimplementing QXmlContentHandler::startElement(),-
2173 QXmlContentHandler::endElement(), and-
2174 QXmlContentHandler::characters().-
2175 You may want to reimplement QXmlContentHandler::endDocument()-
2176 to perform some finalization or validation on the content once the-
2177 document has been read completely.-
2178-
2179 \sa QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver,-
2180 QXmlErrorHandler, QXmlLexicalHandler, {Introduction to SAX2}-
2181*/-
2182-
2183/*!-
2184 \fn QXmlDefaultHandler::QXmlDefaultHandler()-
2185-
2186 Constructs a handler for use with subclasses of QXmlReader.-
2187*/-
2188QXmlDefaultHandler::QXmlDefaultHandler()-
2189{-
2190 // ### In Qt 5.0, this function was inlined and d was not initialized-
2191 // The member cannot be used until Qt 6.0-
2192 Q_UNUSED(d);-
2193}
executed 2103 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2103
2194-
2195/*!-
2196 \fn QXmlDefaultHandler::~QXmlDefaultHandler()-
2197-
2198 Destroys the handler.-
2199*/-
2200QXmlDefaultHandler::~QXmlDefaultHandler()-
2201{-
2202}-
2203-
2204/*!-
2205 \reimp-
2206-
2207 This reimplementation does nothing.-
2208*/-
2209void QXmlDefaultHandler::setDocumentLocator(QXmlLocator*)-
2210{-
2211}-
2212-
2213/*!-
2214 \reimp-
2215-
2216 This reimplementation does nothing.-
2217*/-
2218bool QXmlDefaultHandler::startDocument()-
2219{-
2220 return true;
executed 255 times by 6 tests: return true;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
255
2221}-
2222-
2223/*!-
2224 \reimp-
2225-
2226 This reimplementation does nothing.-
2227*/-
2228bool QXmlDefaultHandler::endDocument()-
2229{-
2230 return true;
executed 11 times by 3 tests: return true;
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
11
2231}-
2232-
2233/*!-
2234 \reimp-
2235-
2236 This reimplementation does nothing.-
2237*/-
2238bool QXmlDefaultHandler::startPrefixMapping(const QString&, const QString&)-
2239{-
2240 return true;
executed 5 times by 1 test: return true;
Executed by:
  • tst_qxmlsimplereader - unknown status
5
2241}-
2242-
2243/*!-
2244 \reimp-
2245-
2246 This reimplementation does nothing.-
2247*/-
2248bool QXmlDefaultHandler::endPrefixMapping(const QString&)-
2249{-
2250 return true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_qxmlsimplereader - unknown status
4
2251}-
2252-
2253/*!-
2254 \reimp-
2255-
2256 This reimplementation does nothing.-
2257*/-
2258bool QXmlDefaultHandler::startElement(const QString&, const QString&,-
2259 const QString&, const QXmlAttributes&)-
2260{-
2261 return true;
executed 206 times by 2 tests: return true;
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
206
2262}-
2263-
2264/*!-
2265 \reimp-
2266-
2267 This reimplementation does nothing.-
2268*/-
2269bool QXmlDefaultHandler::endElement(const QString&, const QString&,-
2270 const QString&)-
2271{-
2272 return true;
executed 206 times by 2 tests: return true;
Executed by:
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
206
2273}-
2274-
2275/*!-
2276 \reimp-
2277-
2278 This reimplementation does nothing.-
2279*/-
2280bool QXmlDefaultHandler::characters(const QString&)-
2281{-
2282 return true;
executed 394 times by 1 test: return true;
Executed by:
  • tst_qxmlsimplereader - unknown status
394
2283}-
2284-
2285/*!-
2286 \reimp-
2287-
2288 This reimplementation does nothing.-
2289*/-
2290bool QXmlDefaultHandler::ignorableWhitespace(const QString&)-
2291{-
2292 return true;
never executed: return true;
0
2293}-
2294-
2295/*!-
2296 \reimp-
2297-
2298 This reimplementation does nothing.-
2299*/-
2300bool QXmlDefaultHandler::processingInstruction(const QString&,-
2301 const QString&)-
2302{-
2303 return true;
executed 6 times by 2 tests: return true;
Executed by:
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
6
2304}-
2305-
2306/*!-
2307 \reimp-
2308-
2309 This reimplementation does nothing.-
2310*/-
2311bool QXmlDefaultHandler::skippedEntity(const QString&)-
2312{-
2313 return true;
never executed: return true;
0
2314}-
2315-
2316/*!-
2317 \reimp-
2318-
2319 This reimplementation does nothing.-
2320*/-
2321bool QXmlDefaultHandler::warning(const QXmlParseException&)-
2322{-
2323 return true;
never executed: return true;
0
2324}-
2325-
2326/*!-
2327 \reimp-
2328-
2329 This reimplementation does nothing.-
2330*/-
2331bool QXmlDefaultHandler::error(const QXmlParseException&)-
2332{-
2333 return true;
never executed: return true;
0
2334}-
2335-
2336/*!-
2337 \reimp-
2338-
2339 This reimplementation does nothing.-
2340*/-
2341bool QXmlDefaultHandler::fatalError(const QXmlParseException&)-
2342{-
2343 return true;
executed 3 times by 1 test: return true;
Executed by:
  • tst_qxmlsimplereader - unknown status
3
2344}-
2345-
2346/*!-
2347 \reimp-
2348-
2349 This reimplementation does nothing.-
2350*/-
2351bool QXmlDefaultHandler::notationDecl(const QString&, const QString&,-
2352 const QString&)-
2353{-
2354 return true;
never executed: return true;
0
2355}-
2356-
2357/*!-
2358 \reimp-
2359-
2360 This reimplementation does nothing.-
2361*/-
2362bool QXmlDefaultHandler::unparsedEntityDecl(const QString&, const QString&,-
2363 const QString&, const QString&)-
2364{-
2365 return true;
never executed: return true;
0
2366}-
2367-
2368/*!-
2369 \reimp-
2370-
2371 Sets \a ret to 0, so that the reader uses the system identifier-
2372 provided in the XML document.-
2373*/-
2374bool QXmlDefaultHandler::resolveEntity(const QString&, const QString&,-
2375 QXmlInputSource*& ret)-
2376{-
2377 ret = 0;-
2378 return true;
never executed: return true;
0
2379}-
2380-
2381/*!-
2382 \reimp-
2383-
2384 Returns the default error string.-
2385*/-
2386QString QXmlDefaultHandler::errorString() const-
2387{-
2388 return QString::fromLatin1(XMLERR_ERRORBYCONSUMER);
never executed: return QString::fromLatin1("error triggered by consumer");
0
2389}-
2390-
2391/*!-
2392 \reimp-
2393-
2394 This reimplementation does nothing.-
2395*/-
2396bool QXmlDefaultHandler::startDTD(const QString&, const QString&, const QString&)-
2397{-
2398 return true;
never executed: return true;
0
2399}-
2400-
2401/*!-
2402 \reimp-
2403-
2404 This reimplementation does nothing.-
2405*/-
2406bool QXmlDefaultHandler::endDTD()-
2407{-
2408 return true;
executed 157 times by 2 tests: return true;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qtextdocument - unknown status
157
2409}-
2410-
2411/*!-
2412 \reimp-
2413-
2414 This reimplementation does nothing.-
2415*/-
2416bool QXmlDefaultHandler::startEntity(const QString&)-
2417{-
2418 return true;
never executed: return true;
0
2419}-
2420-
2421/*!-
2422 \reimp-
2423-
2424 This reimplementation does nothing.-
2425*/-
2426bool QXmlDefaultHandler::endEntity(const QString&)-
2427{-
2428 return true;
never executed: return true;
0
2429}-
2430-
2431/*!-
2432 \reimp-
2433-
2434 This reimplementation does nothing.-
2435*/-
2436bool QXmlDefaultHandler::startCDATA()-
2437{-
2438 return true;
never executed: return true;
0
2439}-
2440-
2441/*!-
2442 \reimp-
2443-
2444 This reimplementation does nothing.-
2445*/-
2446bool QXmlDefaultHandler::endCDATA()-
2447{-
2448 return true;
never executed: return true;
0
2449}-
2450-
2451/*!-
2452 \reimp-
2453-
2454 This reimplementation does nothing.-
2455*/-
2456bool QXmlDefaultHandler::comment(const QString&)-
2457{-
2458 return true;
never executed: return true;
0
2459}-
2460-
2461/*!-
2462 \reimp-
2463-
2464 This reimplementation does nothing.-
2465*/-
2466bool QXmlDefaultHandler::attributeDecl(const QString&, const QString&, const QString&, const QString&, const QString&)-
2467{-
2468 return true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_qxmlsimplereader - unknown status
1
2469}-
2470-
2471/*!-
2472 \reimp-
2473-
2474 This reimplementation does nothing.-
2475*/-
2476bool QXmlDefaultHandler::internalEntityDecl(const QString&, const QString&)-
2477{-
2478 return true;
executed 5 times by 1 test: return true;
Executed by:
  • tst_qxmlsimplereader - unknown status
5
2479}-
2480-
2481/*!-
2482 \reimp-
2483-
2484 This reimplementation does nothing.-
2485*/-
2486bool QXmlDefaultHandler::externalEntityDecl(const QString&, const QString&, const QString&)-
2487{-
2488 return true;
never executed: return true;
0
2489}-
2490-
2491-
2492/*********************************************-
2493 *-
2494 * QXmlSimpleReaderPrivate-
2495 *-
2496 *********************************************/-
2497-
2498inline bool QXmlSimpleReaderPrivate::atEnd()-
2499{-
2500 return (c.unicode()|0x0001) == 0xffff;
executed 1050513 times by 6 tests: return (c.unicode()|0x0001) == 0xffff;
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
1050513
2501}-
2502-
2503inline void QXmlSimpleReaderPrivate::stringClear()-
2504{-
2505 stringValueLen = 0; stringArrayPos = 0;-
2506}
executed 21975 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
21975
2507inline void QXmlSimpleReaderPrivate::nameClear()-
2508{-
2509 nameValueLen = 0; nameArrayPos = 0;-
2510}
executed 30021 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
30021
2511-
2512inline void QXmlSimpleReaderPrivate::refClear()-
2513{-
2514 refValueLen = 0; refArrayPos = 0;-
2515}
executed 2957 times by 3 tests: end of block
Executed by:
  • tst_qtextdocument - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2957
2516-
2517QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate(QXmlSimpleReader *reader)-
2518{-
2519 q_ptr = reader;-
2520 parseStack = 0;-
2521-
2522 locator.reset(new QXmlSimpleReaderLocator(reader));-
2523 entityRes = 0;-
2524 dtdHnd = 0;-
2525 contentHnd = 0;-
2526 errorHnd = 0;-
2527 lexicalHnd = 0;-
2528 declHnd = 0;-
2529-
2530 // default feature settings-
2531 useNamespaces = true;-
2532 useNamespacePrefixes = false;-
2533 reportWhitespaceCharData = true;-
2534 reportEntities = false;-
2535}
executed 2104 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2104
2536-
2537QXmlSimpleReaderPrivate::~QXmlSimpleReaderPrivate()-
2538{-
2539 delete parseStack;-
2540}
executed 2104 times by 6 tests: end of block
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
2104
2541-
2542void QXmlSimpleReaderPrivate::initIncrementalParsing()-
2543{-
2544 if(parseStack)
parseStackDescription
TRUEnever evaluated
FALSEevaluated 1490 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
0-1490
2545 parseStack->clear();
never executed: parseStack->clear();
0
2546 else-
2547 parseStack = new QStack<ParseState>;
executed 1490 times by 1 test: parseStack = new QStack<ParseState>;
Executed by:
  • tst_qxmlsimplereader - unknown status
1490
2548}-
2549-
2550/*********************************************-
2551 *-
2552 * QXmlSimpleReader-
2553 *-
2554 *********************************************/-
2555-
2556/*!-
2557 \class QXmlReader-
2558 \reentrant-
2559 \brief The QXmlReader class provides an interface for XML readers (i.e.-
2560 parsers).-
2561-
2562 \inmodule QtXml-
2563 \ingroup xml-tools-
2564-
2565 This abstract class provides an interface for all of Qt's XML-
2566 readers. Currently there is only one implementation of a reader-
2567 included in Qt's XML module: QXmlSimpleReader. In future releases-
2568 there might be more readers with different properties available-
2569 (e.g. a validating parser).-
2570-
2571 The design of the XML classes follows the \l{SAX2 Java interface}, with-
2572 the names adapted to fit Qt naming conventions. It should be very-
2573 easy for anybody who has worked with SAX2 to get started with the-
2574 Qt XML classes.-
2575-
2576 All readers use the class QXmlInputSource to read the input-
2577 document. Since you are normally interested in particular content-
2578 in the XML document, the reader reports the content through-
2579 special handler classes (QXmlDTDHandler, QXmlDeclHandler,-
2580 QXmlContentHandler, QXmlEntityResolver, QXmlErrorHandler and-
2581 QXmlLexicalHandler), which you must subclass, if you want to-
2582 process the contents.-
2583-
2584 Since the handler classes only describe interfaces you must-
2585 implement all the functions. We provide the QXmlDefaultHandler-
2586 class to make this easier: it implements a default behavior (do-
2587 nothing) for all functions, so you can subclass it and just-
2588 implement the functions you are interested in.-
2589-
2590 Features and properties of the reader can be set with setFeature()-
2591 and setProperty() respectively. You can set the reader to use your-
2592 own subclasses with setEntityResolver(), setDTDHandler(),-
2593 setContentHandler(), setErrorHandler(), setLexicalHandler() and-
2594 setDeclHandler(). The parse itself is started with a call to-
2595 parse().-
2596-
2597 \sa QXmlSimpleReader-
2598*/-
2599-
2600/*!-
2601 \fn QXmlReader::~QXmlReader()-
2602-
2603 Destroys the reader.-
2604*/-
2605-
2606/*!-
2607 \fn bool QXmlReader::feature(const QString& name, bool *ok) const-
2608-
2609 If the reader has the feature called \a name, the feature's value-
2610 is returned. If no such feature exists the return value is-
2611 undefined.-
2612-
2613 If \a ok is not 0: \c{*}\a{ok} is set to true if the reader has the-
2614 feature called \a name; otherwise \c{*}\a{ok} is set to false.-
2615-
2616 \sa setFeature(), hasFeature()-
2617*/-
2618-
2619/*!-
2620 \fn void QXmlReader::setFeature(const QString& name, bool value)-
2621-
2622 Sets the feature called \a name to the given \a value. If the-
2623 reader doesn't have the feature nothing happens.-
2624-
2625 \sa feature(), hasFeature()-
2626*/-
2627-
2628/*!-
2629 \fn bool QXmlReader::hasFeature(const QString& name) const-
2630-
2631 Returns \c true if the reader has the feature called \a name;-
2632 otherwise returns \c false.-
2633-
2634 \sa feature(), setFeature()-
2635*/-
2636-
2637/*!-
2638 \fn void* QXmlReader::property(const QString& name, bool *ok) const-
2639-
2640 If the reader has the property \a name, this function returns the-
2641 value of the property; otherwise the return value is undefined.-
2642-
2643 If \a ok is not 0: if the reader has the \a name property-
2644 \c{*}\a{ok} is set to true; otherwise \c{*}\a{ok} is set to false.-
2645-
2646 \sa setProperty(), hasProperty()-
2647*/-
2648-
2649/*!-
2650 \fn void QXmlReader::setProperty(const QString& name, void* value)-
2651-
2652 Sets the property \a name to \a value. If the reader doesn't have-
2653 the property nothing happens.-
2654-
2655 \sa property(), hasProperty()-
2656*/-
2657-
2658/*!-
2659 \fn bool QXmlReader::hasProperty(const QString& name) const-
2660-
2661 Returns \c true if the reader has the property \a name; otherwise-
2662 returns \c false.-
2663-
2664 \sa property(), setProperty()-
2665*/-
2666-
2667/*!-
2668 \fn void QXmlReader::setEntityResolver(QXmlEntityResolver* handler)-
2669-
2670 Sets the entity resolver to \a handler.-
2671-
2672 \sa entityResolver()-
2673*/-
2674-
2675/*!-
2676 \fn QXmlEntityResolver* QXmlReader::entityResolver() const-
2677-
2678 Returns the entity resolver or 0 if none was set.-
2679-
2680 \sa setEntityResolver()-
2681*/-
2682-
2683/*!-
2684 \fn void QXmlReader::setDTDHandler(QXmlDTDHandler* handler)-
2685-
2686 Sets the DTD handler to \a handler.-
2687-
2688 \sa DTDHandler()-
2689*/-
2690-
2691/*!-
2692 \fn QXmlDTDHandler* QXmlReader::DTDHandler() const-
2693-
2694 Returns the DTD handler or 0 if none was set.-
2695-
2696 \sa setDTDHandler()-
2697*/-
2698-
2699/*!-
2700 \fn void QXmlReader::setContentHandler(QXmlContentHandler* handler)-
2701-
2702 Sets the content handler to \a handler.-
2703-
2704 \sa contentHandler()-
2705*/-
2706-
2707/*!-
2708 \fn QXmlContentHandler* QXmlReader::contentHandler() const-
2709-
2710 Returns the content handler or 0 if none was set.-
2711-
2712 \sa setContentHandler()-
2713*/-
2714-
2715/*!-
2716 \fn void QXmlReader::setErrorHandler(QXmlErrorHandler* handler)-
2717-
2718 Sets the error handler to \a handler. Clears the error handler if-
2719 \a handler is 0.-
2720-
2721 \sa errorHandler()-
2722*/-
2723-
2724/*!-
2725 \fn QXmlErrorHandler* QXmlReader::errorHandler() const-
2726-
2727 Returns the error handler or 0 if none is set.-
2728-
2729 \sa setErrorHandler()-
2730*/-
2731-
2732/*!-
2733 \fn void QXmlReader::setLexicalHandler(QXmlLexicalHandler* handler)-
2734-
2735 Sets the lexical handler to \a handler.-
2736-
2737 \sa lexicalHandler()-
2738*/-
2739-
2740/*!-
2741 \fn QXmlLexicalHandler* QXmlReader::lexicalHandler() const-
2742-
2743 Returns the lexical handler or 0 if none was set.-
2744-
2745 \sa setLexicalHandler()-
2746*/-
2747-
2748/*!-
2749 \fn void QXmlReader::setDeclHandler(QXmlDeclHandler* handler)-
2750-
2751 Sets the declaration handler to \a handler.-
2752-
2753 \sa declHandler()-
2754*/-
2755-
2756/*!-
2757 \fn QXmlDeclHandler* QXmlReader::declHandler() const-
2758-
2759 Returns the declaration handler or 0 if none was set.-
2760-
2761 \sa setDeclHandler()-
2762*/-
2763-
2764/*!-
2765 \fn bool QXmlReader::parse(const QXmlInputSource &input)-
2766-
2767 \obsolete-
2768-
2769 Parses the given \a input.-
2770*/-
2771-
2772/*!-
2773 \fn bool QXmlReader::parse(const QXmlInputSource *input)-
2774-
2775 Reads an XML document from \a input and parses it. Returns \c true if-
2776 the parsing was successful; otherwise returns \c false.-
2777*/-
2778-
2779-
2780/*!-
2781 \class QXmlSimpleReader-
2782 \nonreentrant-
2783 \brief The QXmlSimpleReader class provides an implementation of a-
2784 simple XML parser.-
2785-
2786 \inmodule QtXml-
2787 \ingroup xml-tools-
2788-
2789-
2790 This XML reader is suitable for a wide range of applications. It-
2791 is able to parse well-formed XML and can report the namespaces of-
2792 elements to a content handler; however, it does not parse any-
2793 external entities. For historical reasons, Attribute Value-
2794 Normalization and End-of-Line Handling as described in the XML 1.0-
2795 specification is not performed.-
2796-
2797 The easiest pattern of use for this class is to create a reader-
2798 instance, define an input source, specify the handlers to be used-
2799 by the reader, and parse the data.-
2800-
2801 For example, we could use a QFile to supply the input. Here, we-
2802 create a reader, and define an input source to be used by the-
2803 reader:-
2804-
2805 \snippet simpleparse/main.cpp 0-
2806-
2807 A handler lets us perform actions when the reader encounters-
2808 certain types of content, or if errors in the input are found. The-
2809 reader must be told which handler to use for each type of-
2810 event. For many common applications, we can create a custom-
2811 handler by subclassing QXmlDefaultHandler, and use this to handle-
2812 both error and content events:-
2813-
2814 \snippet simpleparse/main.cpp 1-
2815-
2816 If you don't set at least the content and error handlers, the-
2817 parser will fall back on its default behavior---and will do-
2818 nothing.-
2819-
2820 The most convenient way to handle the input is to read it in a-
2821 single pass using the parse() function with an argument that-
2822 specifies the input source:-
2823-
2824 \snippet simpleparse/main.cpp 2-
2825-
2826 If you can't parse the entire input in one go (for example, it is-
2827 huge, or is being delivered over a network connection), data can-
2828 be fed to the parser in pieces. This is achieved by telling-
2829 parse() to work incrementally, and making subsequent calls to the-
2830 parseContinue() function, until all the data has been processed.-
2831-
2832 A common way to perform incremental parsing is to connect the \c-
2833 readyRead() signal of a \l{QNetworkReply} {network reply} a slot,-
2834 and handle the incoming data there. See QNetworkAccessManager.-
2835-
2836 Aspects of the parsing behavior can be adapted using setFeature()-
2837 and setProperty().-
2838-
2839 \snippet code/src_xml_sax_qxml.cpp 0-
2840-
2841 QXmlSimpleReader is not reentrant. If you want to use the class-
2842 in threaded code, lock the code using QXmlSimpleReader with a-
2843 locking mechanism, such as a QMutex.-
2844*/-
2845-
2846static inline bool is_S(QChar ch)-
2847{-
2848 ushort uc = ch.unicode();-
2849 return (uc == ' ' || uc == '\t' || uc == '\n' || uc == '\r');
executed 187992 times by 6 tests: return (uc == ' ' || uc == '\t' || uc == '\n' || uc == '\r');
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
187992
2850}-
2851-
2852enum NameChar { NameBeginning, NameNotBeginning, NotName };-
2853-
2854static const char Begi = (char)NameBeginning;-
2855static const char NtBg = (char)NameNotBeginning;-
2856static const char NotN = (char)NotName;-
2857-
2858static const char nameCharTable[128] =-
2859{-
2860// 0x00-
2861 NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN,-
2862 NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN,-
2863// 0x10-
2864 NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN,-
2865 NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN,-
2866// 0x20 (0x2D is '-', 0x2E is '.')-
2867 NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN,-
2868 NotN, NotN, NotN, NotN, NotN, NtBg, NtBg, NotN,-
2869// 0x30 (0x30..0x39 are '0'..'9', 0x3A is ':')-
2870 NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg,-
2871 NtBg, NtBg, Begi, NotN, NotN, NotN, NotN, NotN,-
2872// 0x40 (0x41..0x5A are 'A'..'Z')-
2873 NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi,-
2874 Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi,-
2875// 0x50 (0x5F is '_')-
2876 Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi,-
2877 Begi, Begi, Begi, NotN, NotN, NotN, NotN, Begi,-
2878// 0x60 (0x61..0x7A are 'a'..'z')-
2879 NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi,-
2880 Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi,-
2881// 0x70-
2882 Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi,-
2883 Begi, Begi, Begi, NotN, NotN, NotN, NotN, NotN-
2884};-
2885-
2886static inline NameChar fastDetermineNameChar(QChar ch)-
2887{-
2888 ushort uc = ch.unicode();-
2889 if (!(uc & ~0x7f)) // uc < 128
!(uc & ~0x7f)Description
TRUEevaluated 258018 times by 6 tests
Evaluated by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
FALSEevaluated 2385 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
2385-258018
2890 return (NameChar)nameCharTable[uc];
executed 258018 times by 6 tests: return (NameChar)nameCharTable[uc];
Executed by:
  • tst_qcssparser - unknown status
  • tst_qdbusxmlparser - unknown status
  • tst_qtextdocument - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlsimplereader - unknown status
  • tst_qxmlstream - unknown status
258018
2891-
2892 QChar::Category cat = ch.category();-
2893 // ### some these categories might be slightly wrong-
2894 if ((cat >= QChar::Letter_Uppercase && cat <= QChar::Letter_Other)
cat >= QChar::Letter_UppercaseDescription
TRUEevaluated 2297 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 88 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
cat <= QChar::Letter_OtherDescription
TRUEevaluated 2285 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
12-2297
2895 || cat == QChar::Number_Letter)
cat == QChar::Number_LetterDescription
TRUEnever evaluated
FALSEevaluated 100 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
0-100
2896 return NameBeginning;
executed 2285 times by 1 test: return NameBeginning;
Executed by:
  • tst_qxmlsimplereader - unknown status
2285
2897 if ((cat >= QChar::Number_DecimalDigit && cat <= QChar::Number_Other)
cat >= QChar::...r_DecimalDigitDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
FALSEevaluated 77 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
cat <= QChar::Number_OtherDescription
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • tst_qxmlsimplereader - unknown status
0-77
2898 || (cat >= QChar::Mark_NonSpacing && cat <= QChar::Mark_Enclosing))
cat >= QChar::Mark_NonSpacingDescription
TRUE