| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/xml/qxmlstream.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 QtCore module of the Qt Toolkit. | - | ||||||||||||||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||||||||
| 13 | ** a written agreement between you and 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 "QtCore/qxmlstream.h" | - | ||||||||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||||||||
| 42 | #ifndef QT_NO_XMLSTREAM | - | ||||||||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||||||||
| 44 | #include "qxmlutils_p.h" | - | ||||||||||||||||||||||||||||||
| 45 | #include <qdebug.h> | - | ||||||||||||||||||||||||||||||
| 46 | #include <qfile.h> | - | ||||||||||||||||||||||||||||||
| 47 | #include <stdio.h> | - | ||||||||||||||||||||||||||||||
| 48 | #include <qtextcodec.h> | - | ||||||||||||||||||||||||||||||
| 49 | #include <qstack.h> | - | ||||||||||||||||||||||||||||||
| 50 | #include <qbuffer.h> | - | ||||||||||||||||||||||||||||||
| 51 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||||||||
| 52 | #include <qcoreapplication.h> | - | ||||||||||||||||||||||||||||||
| 53 | #else | - | ||||||||||||||||||||||||||||||
| 54 | // This specialization of Q_DECLARE_TR_FUNCTIONS is not in qcoreapplication.h, | - | ||||||||||||||||||||||||||||||
| 55 | // because that header depends on QObject being available, which is not the | - | ||||||||||||||||||||||||||||||
| 56 | // case for most bootstrapped applications. | - | ||||||||||||||||||||||||||||||
| 57 | #define Q_DECLARE_TR_FUNCTIONS(context) \ | - | ||||||||||||||||||||||||||||||
| 58 | public: \ | - | ||||||||||||||||||||||||||||||
| 59 | static inline QString tr(const char *sourceText, const char *comment = 0) \ | - | ||||||||||||||||||||||||||||||
| 60 | { Q_UNUSED(comment); return QString::fromLatin1(sourceText); } \ | - | ||||||||||||||||||||||||||||||
| 61 | static inline QString trUtf8(const char *sourceText, const char *comment = 0) \ | - | ||||||||||||||||||||||||||||||
| 62 | { Q_UNUSED(comment); return QString::fromLatin1(sourceText); } \ | - | ||||||||||||||||||||||||||||||
| 63 | static inline QString tr(const char *sourceText, const char*, int) \ | - | ||||||||||||||||||||||||||||||
| 64 | { return QString::fromLatin1(sourceText); } \ | - | ||||||||||||||||||||||||||||||
| 65 | static inline QString trUtf8(const char *sourceText, const char*, int) \ | - | ||||||||||||||||||||||||||||||
| 66 | { return QString::fromLatin1(sourceText); } \ | - | ||||||||||||||||||||||||||||||
| 67 | private: | - | ||||||||||||||||||||||||||||||
| 68 | #endif | - | ||||||||||||||||||||||||||||||
| 69 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||||||||
| 71 | #include "qxmlstream_p.h" | - | ||||||||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||||||||
| 73 | enum { StreamEOF = ~0U }; | - | ||||||||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||||||||
| 75 | /*! | - | ||||||||||||||||||||||||||||||
| 76 | \enum QXmlStreamReader::TokenType | - | ||||||||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||||||||
| 78 | This enum specifies the type of token the reader just read. | - | ||||||||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||||||||
| 80 | \value NoToken The reader has not yet read anything. | - | ||||||||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||||||||
| 82 | \value Invalid An error has occurred, reported in error() and | - | ||||||||||||||||||||||||||||||
| 83 | errorString(). | - | ||||||||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||||||||
| 85 | \value StartDocument The reader reports the XML version number in | - | ||||||||||||||||||||||||||||||
| 86 | documentVersion(), and the encoding as specified in the XML | - | ||||||||||||||||||||||||||||||
| 87 | document in documentEncoding(). If the document is declared | - | ||||||||||||||||||||||||||||||
| 88 | standalone, isStandaloneDocument() returns \c true; otherwise it | - | ||||||||||||||||||||||||||||||
| 89 | returns \c false. | - | ||||||||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||||||||
| 91 | \value EndDocument The reader reports the end of the document. | - | ||||||||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||||||||
| 93 | \value StartElement The reader reports the start of an element | - | ||||||||||||||||||||||||||||||
| 94 | with namespaceUri() and name(). Empty elements are also reported | - | ||||||||||||||||||||||||||||||
| 95 | as StartElement, followed directly by EndElement. The convenience | - | ||||||||||||||||||||||||||||||
| 96 | function readElementText() can be called to concatenate all | - | ||||||||||||||||||||||||||||||
| 97 | content until the corresponding EndElement. Attributes are | - | ||||||||||||||||||||||||||||||
| 98 | reported in attributes(), namespace declarations in | - | ||||||||||||||||||||||||||||||
| 99 | namespaceDeclarations(). | - | ||||||||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||||||||
| 101 | \value EndElement The reader reports the end of an element with | - | ||||||||||||||||||||||||||||||
| 102 | namespaceUri() and name(). | - | ||||||||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||||||||
| 104 | \value Characters The reader reports characters in text(). If the | - | ||||||||||||||||||||||||||||||
| 105 | characters are all white-space, isWhitespace() returns \c true. If | - | ||||||||||||||||||||||||||||||
| 106 | the characters stem from a CDATA section, isCDATA() returns \c true. | - | ||||||||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||||||||
| 108 | \value Comment The reader reports a comment in text(). | - | ||||||||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||||||||
| 110 | \value DTD The reader reports a DTD in text(), notation | - | ||||||||||||||||||||||||||||||
| 111 | declarations in notationDeclarations(), and entity declarations in | - | ||||||||||||||||||||||||||||||
| 112 | entityDeclarations(). Details of the DTD declaration are reported | - | ||||||||||||||||||||||||||||||
| 113 | in in dtdName(), dtdPublicId(), and dtdSystemId(). | - | ||||||||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||||||||
| 115 | \value EntityReference The reader reports an entity reference that | - | ||||||||||||||||||||||||||||||
| 116 | could not be resolved. The name of the reference is reported in | - | ||||||||||||||||||||||||||||||
| 117 | name(), the replacement text in text(). | - | ||||||||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||||||||
| 119 | \value ProcessingInstruction The reader reports a processing | - | ||||||||||||||||||||||||||||||
| 120 | instruction in processingInstructionTarget() and | - | ||||||||||||||||||||||||||||||
| 121 | processingInstructionData(). | - | ||||||||||||||||||||||||||||||
| 122 | */ | - | ||||||||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||||||||
| 124 | /*! | - | ||||||||||||||||||||||||||||||
| 125 | \enum QXmlStreamReader::ReadElementTextBehaviour | - | ||||||||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||||||||
| 127 | This enum specifies the different behaviours of readElementText(). | - | ||||||||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||||||||
| 129 | \value ErrorOnUnexpectedElement Raise an UnexpectedElementError and return | - | ||||||||||||||||||||||||||||||
| 130 | what was read so far when a child element is encountered. | - | ||||||||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||||||||
| 132 | \value IncludeChildElements Recursively include the text from child elements. | - | ||||||||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||||||||
| 134 | \value SkipChildElements Skip child elements. | - | ||||||||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||||||||
| 136 | \since 4.6 | - | ||||||||||||||||||||||||||||||
| 137 | */ | - | ||||||||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||||||||
| 139 | /*! | - | ||||||||||||||||||||||||||||||
| 140 | \enum QXmlStreamReader::Error | - | ||||||||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||||||||
| 142 | This enum specifies different error cases | - | ||||||||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||||||||
| 144 | \value NoError No error has occurred. | - | ||||||||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||||||||
| 146 | \value CustomError A custom error has been raised with | - | ||||||||||||||||||||||||||||||
| 147 | raiseError() | - | ||||||||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||||||||
| 149 | \value NotWellFormedError The parser internally raised an error | - | ||||||||||||||||||||||||||||||
| 150 | due to the read XML not being well-formed. | - | ||||||||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||||||||
| 152 | \value PrematureEndOfDocumentError The input stream ended before a | - | ||||||||||||||||||||||||||||||
| 153 | well-formed XML document was parsed. Recovery from this error is | - | ||||||||||||||||||||||||||||||
| 154 | possible if more XML arrives in the stream, either by calling | - | ||||||||||||||||||||||||||||||
| 155 | addData() or by waiting for it to arrive on the device(). | - | ||||||||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||||||||
| 157 | \value UnexpectedElementError The parser encountered an element | - | ||||||||||||||||||||||||||||||
| 158 | that was different to those it expected. | - | ||||||||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||||||||
| 160 | */ | - | ||||||||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||||||||
| 162 | /*! | - | ||||||||||||||||||||||||||||||
| 163 | \class QXmlStreamEntityResolver | - | ||||||||||||||||||||||||||||||
| 164 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 165 | \reentrant | - | ||||||||||||||||||||||||||||||
| 166 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||||||||
| 168 | \brief The QXmlStreamEntityResolver class provides an entity | - | ||||||||||||||||||||||||||||||
| 169 | resolver for a QXmlStreamReader. | - | ||||||||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||||||||
| 171 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 172 | */ | - | ||||||||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||||||||
| 174 | /*! | - | ||||||||||||||||||||||||||||||
| 175 | Destroys the entity resolver. | - | ||||||||||||||||||||||||||||||
| 176 | */ | - | ||||||||||||||||||||||||||||||
| 177 | QXmlStreamEntityResolver::~QXmlStreamEntityResolver() | - | ||||||||||||||||||||||||||||||
| 178 | { | - | ||||||||||||||||||||||||||||||
| 179 | } | - | ||||||||||||||||||||||||||||||
| 180 | - | |||||||||||||||||||||||||||||||
| 181 | /*! | - | ||||||||||||||||||||||||||||||
| 182 | \internal | - | ||||||||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||||||||
| 184 | This function is a stub for later functionality. | - | ||||||||||||||||||||||||||||||
| 185 | */ | - | ||||||||||||||||||||||||||||||
| 186 | QString QXmlStreamEntityResolver::resolveEntity(const QString& /*publicId*/, const QString& /*systemId*/) | - | ||||||||||||||||||||||||||||||
| 187 | { | - | ||||||||||||||||||||||||||||||
| 188 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||
| 189 | } | - | ||||||||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||||||||
| 192 | /*! | - | ||||||||||||||||||||||||||||||
| 193 | Resolves the undeclared entity \a name and returns its replacement | - | ||||||||||||||||||||||||||||||
| 194 | text. If the entity is also unknown to the entity resolver, it | - | ||||||||||||||||||||||||||||||
| 195 | returns an empty string. | - | ||||||||||||||||||||||||||||||
| 196 | - | |||||||||||||||||||||||||||||||
| 197 | The default implementation always returns an empty string. | - | ||||||||||||||||||||||||||||||
| 198 | */ | - | ||||||||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||||||||
| 200 | QString QXmlStreamEntityResolver::resolveUndeclaredEntity(const QString &/*name*/) | - | ||||||||||||||||||||||||||||||
| 201 | { | - | ||||||||||||||||||||||||||||||
| 202 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||
| 203 | } | - | ||||||||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||||||||
| 205 | #ifndef QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||||||||
| 207 | QString QXmlStreamReaderPrivate::resolveUndeclaredEntity(const QString &name) | - | ||||||||||||||||||||||||||||||
| 208 | { | - | ||||||||||||||||||||||||||||||
| 209 | if (entityResolver)
| 0-2 | ||||||||||||||||||||||||||||||
| 210 | return entityResolver->resolveUndeclaredEntity(name); executed 2 times by 1 test: return entityResolver->resolveUndeclaredEntity(name);Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 211 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||
| 212 | } | - | ||||||||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||||||||
| 216 | /*! | - | ||||||||||||||||||||||||||||||
| 217 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||||||||
| 219 | Makes \a resolver the new entityResolver(). | - | ||||||||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||||||||
| 221 | The stream reader does \e not take ownership of the resolver. It's | - | ||||||||||||||||||||||||||||||
| 222 | the callers responsibility to ensure that the resolver is valid | - | ||||||||||||||||||||||||||||||
| 223 | during the entire life-time of the stream reader object, or until | - | ||||||||||||||||||||||||||||||
| 224 | another resolver or 0 is set. | - | ||||||||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||||||||
| 226 | \sa entityResolver() | - | ||||||||||||||||||||||||||||||
| 227 | */ | - | ||||||||||||||||||||||||||||||
| 228 | void QXmlStreamReader::setEntityResolver(QXmlStreamEntityResolver *resolver) | - | ||||||||||||||||||||||||||||||
| 229 | { | - | ||||||||||||||||||||||||||||||
| 230 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 231 | d->entityResolver = resolver; | - | ||||||||||||||||||||||||||||||
| 232 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||
| 234 | /*! | - | ||||||||||||||||||||||||||||||
| 235 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||||||||
| 237 | Returns the entity resolver, or 0 if there is no entity resolver. | - | ||||||||||||||||||||||||||||||
| 238 | - | |||||||||||||||||||||||||||||||
| 239 | \sa setEntityResolver() | - | ||||||||||||||||||||||||||||||
| 240 | */ | - | ||||||||||||||||||||||||||||||
| 241 | QXmlStreamEntityResolver *QXmlStreamReader::entityResolver() const | - | ||||||||||||||||||||||||||||||
| 242 | { | - | ||||||||||||||||||||||||||||||
| 243 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 244 | return d->entityResolver; never executed: return d->entityResolver; | 0 | ||||||||||||||||||||||||||||||
| 245 | } | - | ||||||||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||||||||
| 249 | /*! | - | ||||||||||||||||||||||||||||||
| 250 | \class QXmlStreamReader | - | ||||||||||||||||||||||||||||||
| 251 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 252 | \reentrant | - | ||||||||||||||||||||||||||||||
| 253 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||||||||
| 255 | \brief The QXmlStreamReader class provides a fast parser for reading | - | ||||||||||||||||||||||||||||||
| 256 | well-formed XML via a simple streaming API. | - | ||||||||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||||||||
| 259 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||||||||
| 261 | QXmlStreamReader is a faster and more convenient replacement for | - | ||||||||||||||||||||||||||||||
| 262 | Qt's own SAX parser (see QXmlSimpleReader). In some cases it might | - | ||||||||||||||||||||||||||||||
| 263 | also be a faster and more convenient alternative for use in | - | ||||||||||||||||||||||||||||||
| 264 | applications that would otherwise use a DOM tree (see QDomDocument). | - | ||||||||||||||||||||||||||||||
| 265 | QXmlStreamReader reads data either from a QIODevice (see | - | ||||||||||||||||||||||||||||||
| 266 | setDevice()), or from a raw QByteArray (see addData()). | - | ||||||||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||||||||
| 268 | Qt provides QXmlStreamWriter for writing XML. | - | ||||||||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||||||||
| 270 | The basic concept of a stream reader is to report an XML document as | - | ||||||||||||||||||||||||||||||
| 271 | a stream of tokens, similar to SAX. The main difference between | - | ||||||||||||||||||||||||||||||
| 272 | QXmlStreamReader and SAX is \e how these XML tokens are reported. | - | ||||||||||||||||||||||||||||||
| 273 | With SAX, the application must provide handlers (callback functions) | - | ||||||||||||||||||||||||||||||
| 274 | that receive so-called XML \e events from the parser at the parser's | - | ||||||||||||||||||||||||||||||
| 275 | convenience. With QXmlStreamReader, the application code itself | - | ||||||||||||||||||||||||||||||
| 276 | drives the loop and pulls \e tokens from the reader, one after | - | ||||||||||||||||||||||||||||||
| 277 | another, as it needs them. This is done by calling readNext(), where | - | ||||||||||||||||||||||||||||||
| 278 | the reader reads from the input stream until it completes the next | - | ||||||||||||||||||||||||||||||
| 279 | token, at which point it returns the tokenType(). A set of | - | ||||||||||||||||||||||||||||||
| 280 | convenient functions including isStartElement() and text() can then | - | ||||||||||||||||||||||||||||||
| 281 | be used to examine the token to obtain information about what has | - | ||||||||||||||||||||||||||||||
| 282 | been read. The big advantage of this \e pulling approach is the | - | ||||||||||||||||||||||||||||||
| 283 | possibility to build recursive descent parsers with it, meaning you | - | ||||||||||||||||||||||||||||||
| 284 | can split your XML parsing code easily into different methods or | - | ||||||||||||||||||||||||||||||
| 285 | classes. This makes it easy to keep track of the application's own | - | ||||||||||||||||||||||||||||||
| 286 | state when parsing XML. | - | ||||||||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||||||||
| 288 | A typical loop with QXmlStreamReader looks like this: | - | ||||||||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||||||||
| 290 | \snippet code/src_corelib_xml_qxmlstream.cpp 0 | - | ||||||||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||||||||
| 293 | QXmlStreamReader is a well-formed XML 1.0 parser that does \e not | - | ||||||||||||||||||||||||||||||
| 294 | include external parsed entities. As long as no error occurs, the | - | ||||||||||||||||||||||||||||||
| 295 | application code can thus be assured that the data provided by the | - | ||||||||||||||||||||||||||||||
| 296 | stream reader satisfies the W3C's criteria for well-formed XML. For | - | ||||||||||||||||||||||||||||||
| 297 | example, you can be certain that all tags are indeed nested and | - | ||||||||||||||||||||||||||||||
| 298 | closed properly, that references to internal entities have been | - | ||||||||||||||||||||||||||||||
| 299 | replaced with the correct replacement text, and that attributes have | - | ||||||||||||||||||||||||||||||
| 300 | been normalized or added according to the internal subset of the | - | ||||||||||||||||||||||||||||||
| 301 | DTD. | - | ||||||||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||||||||
| 303 | If an error occurs while parsing, atEnd() and hasError() return | - | ||||||||||||||||||||||||||||||
| 304 | true, and error() returns the error that occurred. The functions | - | ||||||||||||||||||||||||||||||
| 305 | errorString(), lineNumber(), columnNumber(), and characterOffset() | - | ||||||||||||||||||||||||||||||
| 306 | are for constructing an appropriate error or warning message. To | - | ||||||||||||||||||||||||||||||
| 307 | simplify application code, QXmlStreamReader contains a raiseError() | - | ||||||||||||||||||||||||||||||
| 308 | mechanism that lets you raise custom errors that trigger the same | - | ||||||||||||||||||||||||||||||
| 309 | error handling described. | - | ||||||||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||||||||
| 311 | The \l{QXmlStream Bookmarks Example} illustrates how to use the | - | ||||||||||||||||||||||||||||||
| 312 | recursive descent technique to read an XML bookmark file (XBEL) with | - | ||||||||||||||||||||||||||||||
| 313 | a stream reader. | - | ||||||||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||||||||
| 315 | \section1 Namespaces | - | ||||||||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||||||||
| 317 | QXmlStream understands and resolves XML namespaces. E.g. in case of | - | ||||||||||||||||||||||||||||||
| 318 | a StartElement, namespaceUri() returns the namespace the element is | - | ||||||||||||||||||||||||||||||
| 319 | in, and name() returns the element's \e local name. The combination | - | ||||||||||||||||||||||||||||||
| 320 | of namespaceUri and name uniquely identifies an element. If a | - | ||||||||||||||||||||||||||||||
| 321 | namespace prefix was not declared in the XML entities parsed by the | - | ||||||||||||||||||||||||||||||
| 322 | reader, the namespaceUri is empty. | - | ||||||||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||||||||
| 324 | If you parse XML data that does not utilize namespaces according to | - | ||||||||||||||||||||||||||||||
| 325 | the XML specification or doesn't use namespaces at all, you can use | - | ||||||||||||||||||||||||||||||
| 326 | the element's qualifiedName() instead. A qualified name is the | - | ||||||||||||||||||||||||||||||
| 327 | element's prefix() followed by colon followed by the element's local | - | ||||||||||||||||||||||||||||||
| 328 | name() - exactly like the element appears in the raw XML data. Since | - | ||||||||||||||||||||||||||||||
| 329 | the mapping namespaceUri to prefix is neither unique nor universal, | - | ||||||||||||||||||||||||||||||
| 330 | qualifiedName() should be avoided for namespace-compliant XML data. | - | ||||||||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||||||||
| 332 | In order to parse standalone documents that do use undeclared | - | ||||||||||||||||||||||||||||||
| 333 | namespace prefixes, you can turn off namespace processing completely | - | ||||||||||||||||||||||||||||||
| 334 | with the \l namespaceProcessing property. | - | ||||||||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||||||||
| 336 | \section1 Incremental Parsing | - | ||||||||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||||||||
| 338 | QXmlStreamReader is an incremental parser. It can handle the case | - | ||||||||||||||||||||||||||||||
| 339 | where the document can't be parsed all at once because it arrives in | - | ||||||||||||||||||||||||||||||
| 340 | chunks (e.g. from multiple files, or over a network connection). | - | ||||||||||||||||||||||||||||||
| 341 | When the reader runs out of data before the complete document has | - | ||||||||||||||||||||||||||||||
| 342 | been parsed, it reports a PrematureEndOfDocumentError. When more | - | ||||||||||||||||||||||||||||||
| 343 | data arrives, either because of a call to addData() or because more | - | ||||||||||||||||||||||||||||||
| 344 | data is available through the network device(), the reader recovers | - | ||||||||||||||||||||||||||||||
| 345 | from the PrematureEndOfDocumentError error and continues parsing the | - | ||||||||||||||||||||||||||||||
| 346 | new data with the next call to readNext(). | - | ||||||||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||||||||
| 348 | For example, if your application reads data from the network using a | - | ||||||||||||||||||||||||||||||
| 349 | \l{QNetworkAccessManager} {network access manager}, you would issue | - | ||||||||||||||||||||||||||||||
| 350 | a \l{QNetworkRequest} {network request} to the manager and receive a | - | ||||||||||||||||||||||||||||||
| 351 | \l{QNetworkReply} {network reply} in return. Since a QNetworkReply | - | ||||||||||||||||||||||||||||||
| 352 | is a QIODevice, you connect its \l{QIODevice::readyRead()} | - | ||||||||||||||||||||||||||||||
| 353 | {readyRead()} signal to a custom slot, e.g. \c{slotReadyRead()} in | - | ||||||||||||||||||||||||||||||
| 354 | the code snippet shown in the discussion for QNetworkAccessManager. | - | ||||||||||||||||||||||||||||||
| 355 | In this slot, you read all available data with | - | ||||||||||||||||||||||||||||||
| 356 | \l{QIODevice::readAll()} {readAll()} and pass it to the XML | - | ||||||||||||||||||||||||||||||
| 357 | stream reader using addData(). Then you call your custom parsing | - | ||||||||||||||||||||||||||||||
| 358 | function that reads the XML events from the reader. | - | ||||||||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||||||||
| 360 | \section1 Performance and Memory Consumption | - | ||||||||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||||||||
| 362 | QXmlStreamReader is memory-conservative by design, since it doesn't | - | ||||||||||||||||||||||||||||||
| 363 | store the entire XML document tree in memory, but only the current | - | ||||||||||||||||||||||||||||||
| 364 | token at the time it is reported. In addition, QXmlStreamReader | - | ||||||||||||||||||||||||||||||
| 365 | avoids the many small string allocations that it normally takes to | - | ||||||||||||||||||||||||||||||
| 366 | map an XML document to a convenient and Qt-ish API. It does this by | - | ||||||||||||||||||||||||||||||
| 367 | reporting all string data as QStringRef rather than real QString | - | ||||||||||||||||||||||||||||||
| 368 | objects. QStringRef is a thin wrapper around QString substrings that | - | ||||||||||||||||||||||||||||||
| 369 | provides a subset of the QString API without the memory allocation | - | ||||||||||||||||||||||||||||||
| 370 | and reference-counting overhead. Calling | - | ||||||||||||||||||||||||||||||
| 371 | \l{QStringRef::toString()}{toString()} on any of those objects | - | ||||||||||||||||||||||||||||||
| 372 | returns an equivalent real QString object. | - | ||||||||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||||||||
| 374 | */ | - | ||||||||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||||||||
| 377 | /*! | - | ||||||||||||||||||||||||||||||
| 378 | Constructs a stream reader. | - | ||||||||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||||||||
| 380 | \sa setDevice(), addData() | - | ||||||||||||||||||||||||||||||
| 381 | */ | - | ||||||||||||||||||||||||||||||
| 382 | QXmlStreamReader::QXmlStreamReader() | - | ||||||||||||||||||||||||||||||
| 383 | : d_ptr(new QXmlStreamReaderPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 384 | { | - | ||||||||||||||||||||||||||||||
| 385 | } executed 3174 times by 1 test: end of blockExecuted by:
| 3174 | ||||||||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||||||||
| 387 | /*! Creates a new stream reader that reads from \a device. | - | ||||||||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||||||||
| 389 | \sa setDevice(), clear() | - | ||||||||||||||||||||||||||||||
| 390 | */ | - | ||||||||||||||||||||||||||||||
| 391 | QXmlStreamReader::QXmlStreamReader(QIODevice *device) | - | ||||||||||||||||||||||||||||||
| 392 | : d_ptr(new QXmlStreamReaderPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 393 | { | - | ||||||||||||||||||||||||||||||
| 394 | setDevice(device); | - | ||||||||||||||||||||||||||||||
| 395 | } executed 2948 times by 23 tests: end of blockExecuted by:
| 2948 | ||||||||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||||||||
| 397 | /*! | - | ||||||||||||||||||||||||||||||
| 398 | Creates a new stream reader that reads from \a data. | - | ||||||||||||||||||||||||||||||
| 399 | - | |||||||||||||||||||||||||||||||
| 400 | \sa addData(), clear(), setDevice() | - | ||||||||||||||||||||||||||||||
| 401 | */ | - | ||||||||||||||||||||||||||||||
| 402 | QXmlStreamReader::QXmlStreamReader(const QByteArray &data) | - | ||||||||||||||||||||||||||||||
| 403 | : d_ptr(new QXmlStreamReaderPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 404 | { | - | ||||||||||||||||||||||||||||||
| 405 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 406 | d->dataBuffer = data; | - | ||||||||||||||||||||||||||||||
| 407 | } executed 845 times by 2 tests: end of blockExecuted by:
| 845 | ||||||||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||||||||
| 409 | /*! | - | ||||||||||||||||||||||||||||||
| 410 | Creates a new stream reader that reads from \a data. | - | ||||||||||||||||||||||||||||||
| 411 | - | |||||||||||||||||||||||||||||||
| 412 | \sa addData(), clear(), setDevice() | - | ||||||||||||||||||||||||||||||
| 413 | */ | - | ||||||||||||||||||||||||||||||
| 414 | QXmlStreamReader::QXmlStreamReader(const QString &data) | - | ||||||||||||||||||||||||||||||
| 415 | : d_ptr(new QXmlStreamReaderPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 416 | { | - | ||||||||||||||||||||||||||||||
| 417 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 418 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 419 | d->dataBuffer = data.toLatin1(); | - | ||||||||||||||||||||||||||||||
| 420 | #else | - | ||||||||||||||||||||||||||||||
| 421 | d->dataBuffer = d->codec->fromUnicode(data); | - | ||||||||||||||||||||||||||||||
| 422 | d->decoder = d->codec->makeDecoder(); | - | ||||||||||||||||||||||||||||||
| 423 | #endif | - | ||||||||||||||||||||||||||||||
| 424 | d->lockEncoding = true; | - | ||||||||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||||||||
| 426 | } executed 378 times by 13 tests: end of blockExecuted by:
| 378 | ||||||||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||||||||
| 428 | /*! | - | ||||||||||||||||||||||||||||||
| 429 | Creates a new stream reader that reads from \a data. | - | ||||||||||||||||||||||||||||||
| 430 | - | |||||||||||||||||||||||||||||||
| 431 | \sa addData(), clear(), setDevice() | - | ||||||||||||||||||||||||||||||
| 432 | */ | - | ||||||||||||||||||||||||||||||
| 433 | QXmlStreamReader::QXmlStreamReader(const char *data) | - | ||||||||||||||||||||||||||||||
| 434 | : d_ptr(new QXmlStreamReaderPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 435 | { | - | ||||||||||||||||||||||||||||||
| 436 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 437 | d->dataBuffer = QByteArray(data); | - | ||||||||||||||||||||||||||||||
| 438 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||||||||
| 440 | /*! | - | ||||||||||||||||||||||||||||||
| 441 | Destructs the reader. | - | ||||||||||||||||||||||||||||||
| 442 | */ | - | ||||||||||||||||||||||||||||||
| 443 | QXmlStreamReader::~QXmlStreamReader() | - | ||||||||||||||||||||||||||||||
| 444 | { | - | ||||||||||||||||||||||||||||||
| 445 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 446 | if (d->deleteDevice)
| 0-7351 | ||||||||||||||||||||||||||||||
| 447 | delete d->device; never executed: delete d->device; | 0 | ||||||||||||||||||||||||||||||
| 448 | } executed 7351 times by 36 tests: end of blockExecuted by:
| 7351 | ||||||||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||||||||
| 450 | /*! \fn bool QXmlStreamReader::hasError() const | - | ||||||||||||||||||||||||||||||
| 451 | Returns \c true if an error has occurred, otherwise \c false. | - | ||||||||||||||||||||||||||||||
| 452 | - | |||||||||||||||||||||||||||||||
| 453 | \sa errorString(), error() | - | ||||||||||||||||||||||||||||||
| 454 | */ | - | ||||||||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||||||||
| 456 | /*! | - | ||||||||||||||||||||||||||||||
| 457 | Sets the current device to \a device. Setting the device resets | - | ||||||||||||||||||||||||||||||
| 458 | the stream to its initial state. | - | ||||||||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||||||||
| 460 | \sa device(), clear() | - | ||||||||||||||||||||||||||||||
| 461 | */ | - | ||||||||||||||||||||||||||||||
| 462 | void QXmlStreamReader::setDevice(QIODevice *device) | - | ||||||||||||||||||||||||||||||
| 463 | { | - | ||||||||||||||||||||||||||||||
| 464 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 465 | if (d->deleteDevice) {
| 0-4669 | ||||||||||||||||||||||||||||||
| 466 | delete d->device; | - | ||||||||||||||||||||||||||||||
| 467 | d->deleteDevice = false; | - | ||||||||||||||||||||||||||||||
| 468 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 469 | d->device = device; | - | ||||||||||||||||||||||||||||||
| 470 | d->init(); | - | ||||||||||||||||||||||||||||||
| 471 | - | |||||||||||||||||||||||||||||||
| 472 | } executed 4669 times by 23 tests: end of blockExecuted by:
| 4669 | ||||||||||||||||||||||||||||||
| 473 | - | |||||||||||||||||||||||||||||||
| 474 | /*! | - | ||||||||||||||||||||||||||||||
| 475 | Returns the current device associated with the QXmlStreamReader, | - | ||||||||||||||||||||||||||||||
| 476 | or 0 if no device has been assigned. | - | ||||||||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||||||||
| 478 | \sa setDevice() | - | ||||||||||||||||||||||||||||||
| 479 | */ | - | ||||||||||||||||||||||||||||||
| 480 | QIODevice *QXmlStreamReader::device() const | - | ||||||||||||||||||||||||||||||
| 481 | { | - | ||||||||||||||||||||||||||||||
| 482 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 483 | return d->device; never executed: return d->device; | 0 | ||||||||||||||||||||||||||||||
| 484 | } | - | ||||||||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||||||||
| 486 | - | |||||||||||||||||||||||||||||||
| 487 | /*! | - | ||||||||||||||||||||||||||||||
| 488 | Adds more \a data for the reader to read. This function does | - | ||||||||||||||||||||||||||||||
| 489 | nothing if the reader has a device(). | - | ||||||||||||||||||||||||||||||
| 490 | - | |||||||||||||||||||||||||||||||
| 491 | \sa readNext(), clear() | - | ||||||||||||||||||||||||||||||
| 492 | */ | - | ||||||||||||||||||||||||||||||
| 493 | void QXmlStreamReader::addData(const QByteArray &data) | - | ||||||||||||||||||||||||||||||
| 494 | { | - | ||||||||||||||||||||||||||||||
| 495 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 496 | if (d->device) {
| 0-57484 | ||||||||||||||||||||||||||||||
| 497 | qWarning("QXmlStreamReader: addData() with device()"); | - | ||||||||||||||||||||||||||||||
| 498 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 499 | } | - | ||||||||||||||||||||||||||||||
| 500 | d->dataBuffer += data; | - | ||||||||||||||||||||||||||||||
| 501 | } executed 57484 times by 1 test: end of blockExecuted by:
| 57484 | ||||||||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||||||||
| 503 | /*! | - | ||||||||||||||||||||||||||||||
| 504 | Adds more \a data for the reader to read. This function does | - | ||||||||||||||||||||||||||||||
| 505 | nothing if the reader has a device(). | - | ||||||||||||||||||||||||||||||
| 506 | - | |||||||||||||||||||||||||||||||
| 507 | \sa readNext(), clear() | - | ||||||||||||||||||||||||||||||
| 508 | */ | - | ||||||||||||||||||||||||||||||
| 509 | void QXmlStreamReader::addData(const QString &data) | - | ||||||||||||||||||||||||||||||
| 510 | { | - | ||||||||||||||||||||||||||||||
| 511 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 512 | d->lockEncoding = true; | - | ||||||||||||||||||||||||||||||
| 513 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 514 | addData(data.toLatin1()); | - | ||||||||||||||||||||||||||||||
| 515 | #else | - | ||||||||||||||||||||||||||||||
| 516 | addData(d->codec->fromUnicode(data)); | - | ||||||||||||||||||||||||||||||
| 517 | #endif | - | ||||||||||||||||||||||||||||||
| 518 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||||||||
| 520 | /*! | - | ||||||||||||||||||||||||||||||
| 521 | Adds more \a data for the reader to read. This function does | - | ||||||||||||||||||||||||||||||
| 522 | nothing if the reader has a device(). | - | ||||||||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||||||||
| 524 | \sa readNext(), clear() | - | ||||||||||||||||||||||||||||||
| 525 | */ | - | ||||||||||||||||||||||||||||||
| 526 | void QXmlStreamReader::addData(const char *data) | - | ||||||||||||||||||||||||||||||
| 527 | { | - | ||||||||||||||||||||||||||||||
| 528 | addData(QByteArray(data)); | - | ||||||||||||||||||||||||||||||
| 529 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 530 | - | |||||||||||||||||||||||||||||||
| 531 | /*! | - | ||||||||||||||||||||||||||||||
| 532 | Removes any device() or data from the reader and resets its | - | ||||||||||||||||||||||||||||||
| 533 | internal state to the initial state. | - | ||||||||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||||||||
| 535 | \sa addData() | - | ||||||||||||||||||||||||||||||
| 536 | */ | - | ||||||||||||||||||||||||||||||
| 537 | void QXmlStreamReader::clear() | - | ||||||||||||||||||||||||||||||
| 538 | { | - | ||||||||||||||||||||||||||||||
| 539 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 540 | d->init(); | - | ||||||||||||||||||||||||||||||
| 541 | if (d->device) {
| 0-3 | ||||||||||||||||||||||||||||||
| 542 | if (d->deleteDevice)
| 0 | ||||||||||||||||||||||||||||||
| 543 | delete d->device; never executed: delete d->device; | 0 | ||||||||||||||||||||||||||||||
| 544 | d->device = 0; | - | ||||||||||||||||||||||||||||||
| 545 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 546 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||||||||
| 548 | /*! | - | ||||||||||||||||||||||||||||||
| 549 | Returns \c true if the reader has read until the end of the XML | - | ||||||||||||||||||||||||||||||
| 550 | document, or if an error() has occurred and reading has been | - | ||||||||||||||||||||||||||||||
| 551 | aborted. Otherwise, it returns \c false. | - | ||||||||||||||||||||||||||||||
| 552 | - | |||||||||||||||||||||||||||||||
| 553 | When atEnd() and hasError() return true and error() returns | - | ||||||||||||||||||||||||||||||
| 554 | PrematureEndOfDocumentError, it means the XML has been well-formed | - | ||||||||||||||||||||||||||||||
| 555 | so far, but a complete XML document has not been parsed. The next | - | ||||||||||||||||||||||||||||||
| 556 | chunk of XML can be added with addData(), if the XML is being read | - | ||||||||||||||||||||||||||||||
| 557 | from a QByteArray, or by waiting for more data to arrive if the | - | ||||||||||||||||||||||||||||||
| 558 | XML is being read from a QIODevice. Either way, atEnd() will | - | ||||||||||||||||||||||||||||||
| 559 | return false once more data is available. | - | ||||||||||||||||||||||||||||||
| 560 | - | |||||||||||||||||||||||||||||||
| 561 | \sa hasError(), error(), device(), QIODevice::atEnd() | - | ||||||||||||||||||||||||||||||
| 562 | */ | - | ||||||||||||||||||||||||||||||
| 563 | bool QXmlStreamReader::atEnd() const | - | ||||||||||||||||||||||||||||||
| 564 | { | - | ||||||||||||||||||||||||||||||
| 565 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 566 | if (d->atEnd
| 118570-691847 | ||||||||||||||||||||||||||||||
| 567 | && ((d->type == QXmlStreamReader::Invalid && d->error == PrematureEndOfDocumentError)
| 0-115547 | ||||||||||||||||||||||||||||||
| 568 | || (d->type == QXmlStreamReader::EndDocument))) {
| 0-3023 | ||||||||||||||||||||||||||||||
| 569 | if (d->device)
| 551-118019 | ||||||||||||||||||||||||||||||
| 570 | return d->device->atEnd(); executed 551 times by 2 tests: return d->device->atEnd();Executed by:
| 551 | ||||||||||||||||||||||||||||||
| 571 | else | - | ||||||||||||||||||||||||||||||
| 572 | return !d->dataBuffer.size(); executed 118019 times by 14 tests: return !d->dataBuffer.size();Executed by:
| 118019 | ||||||||||||||||||||||||||||||
| 573 | } | - | ||||||||||||||||||||||||||||||
| 574 | return (d->atEnd || d->type == QXmlStreamReader::Invalid); executed 691847 times by 15 tests: return (d->atEnd || d->type == QXmlStreamReader::Invalid);Executed by:
| 691847 | ||||||||||||||||||||||||||||||
| 575 | } | - | ||||||||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||||||||
| 578 | /*! | - | ||||||||||||||||||||||||||||||
| 579 | Reads the next token and returns its type. | - | ||||||||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||||||||
| 581 | With one exception, once an error() is reported by readNext(), | - | ||||||||||||||||||||||||||||||
| 582 | further reading of the XML stream is not possible. Then atEnd() | - | ||||||||||||||||||||||||||||||
| 583 | returns \c true, hasError() returns \c true, and this function returns | - | ||||||||||||||||||||||||||||||
| 584 | QXmlStreamReader::Invalid. | - | ||||||||||||||||||||||||||||||
| 585 | - | |||||||||||||||||||||||||||||||
| 586 | The exception is when error() returns PrematureEndOfDocumentError. | - | ||||||||||||||||||||||||||||||
| 587 | This error is reported when the end of an otherwise well-formed | - | ||||||||||||||||||||||||||||||
| 588 | chunk of XML is reached, but the chunk doesn't represent a complete | - | ||||||||||||||||||||||||||||||
| 589 | XML document. In that case, parsing \e can be resumed by calling | - | ||||||||||||||||||||||||||||||
| 590 | addData() to add the next chunk of XML, when the stream is being | - | ||||||||||||||||||||||||||||||
| 591 | read from a QByteArray, or by waiting for more data to arrive when | - | ||||||||||||||||||||||||||||||
| 592 | the stream is being read from a device(). | - | ||||||||||||||||||||||||||||||
| 593 | - | |||||||||||||||||||||||||||||||
| 594 | \sa tokenType(), tokenString() | - | ||||||||||||||||||||||||||||||
| 595 | */ | - | ||||||||||||||||||||||||||||||
| 596 | QXmlStreamReader::TokenType QXmlStreamReader::readNext() | - | ||||||||||||||||||||||||||||||
| 597 | { | - | ||||||||||||||||||||||||||||||
| 598 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 599 | if (d->type != Invalid) {
| 57494-1515198 | ||||||||||||||||||||||||||||||
| 600 | if (!d->hasCheckedStartDocument)
| 8383-1506815 | ||||||||||||||||||||||||||||||
| 601 | if (!d->checkStartDocument())
| 3714-4669 | ||||||||||||||||||||||||||||||
| 602 | return d->type; // synthetic StartDocument or error executed 4669 times by 13 tests: return d->type;Executed by:
| 4669 | ||||||||||||||||||||||||||||||
| 603 | d->parse(); | - | ||||||||||||||||||||||||||||||
| 604 | if (d->atEnd && d->type != EndDocument && d->type != Invalid)
| 2371-1452120 | ||||||||||||||||||||||||||||||
| 605 | d->raiseError(PrematureEndOfDocumentError); executed 45171 times by 1 test: d->raiseError(PrematureEndOfDocumentError);Executed by:
| 45171 | ||||||||||||||||||||||||||||||
| 606 | else if (!d->atEnd && d->type == EndDocument)
| 5-1452120 | ||||||||||||||||||||||||||||||
| 607 | d->raiseWellFormedError(QXmlStream::tr("Extra content at end of document.")); executed 5 times by 1 test: d->raiseWellFormedError(QXmlStream::tr("Extra content at end of document."));Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 608 | } else if (d->error == PrematureEndOfDocumentError) { executed 1510529 times by 36 tests: end of blockExecuted by:
| 12-1510529 | ||||||||||||||||||||||||||||||
| 609 | // resume error | - | ||||||||||||||||||||||||||||||
| 610 | d->type = NoToken; | - | ||||||||||||||||||||||||||||||
| 611 | d->atEnd = false; | - | ||||||||||||||||||||||||||||||
| 612 | d->token = -1; | - | ||||||||||||||||||||||||||||||
| 613 | return readNext(); executed 57482 times by 1 test: return readNext();Executed by:
| 57482 | ||||||||||||||||||||||||||||||
| 614 | } | - | ||||||||||||||||||||||||||||||
| 615 | return d->type; executed 1510541 times by 36 tests: return d->type;Executed by:
| 1510541 | ||||||||||||||||||||||||||||||
| 616 | } | - | ||||||||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||||||||
| 619 | /*! | - | ||||||||||||||||||||||||||||||
| 620 | Returns the type of the current token. | - | ||||||||||||||||||||||||||||||
| 621 | - | |||||||||||||||||||||||||||||||
| 622 | The current token can also be queried with the convenience functions | - | ||||||||||||||||||||||||||||||
| 623 | isStartDocument(), isEndDocument(), isStartElement(), | - | ||||||||||||||||||||||||||||||
| 624 | isEndElement(), isCharacters(), isComment(), isDTD(), | - | ||||||||||||||||||||||||||||||
| 625 | isEntityReference(), and isProcessingInstruction(). | - | ||||||||||||||||||||||||||||||
| 626 | - | |||||||||||||||||||||||||||||||
| 627 | \sa tokenString() | - | ||||||||||||||||||||||||||||||
| 628 | */ | - | ||||||||||||||||||||||||||||||
| 629 | QXmlStreamReader::TokenType QXmlStreamReader::tokenType() const | - | ||||||||||||||||||||||||||||||
| 630 | { | - | ||||||||||||||||||||||||||||||
| 631 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 632 | return d->type; executed 1214190 times by 35 tests: return d->type;Executed by:
| 1214190 | ||||||||||||||||||||||||||||||
| 633 | } | - | ||||||||||||||||||||||||||||||
| 634 | - | |||||||||||||||||||||||||||||||
| 635 | /*! | - | ||||||||||||||||||||||||||||||
| 636 | Reads until the next start element within the current element. Returns \c true | - | ||||||||||||||||||||||||||||||
| 637 | when a start element was reached. When the end element was reached, or when | - | ||||||||||||||||||||||||||||||
| 638 | an error occurred, false is returned. | - | ||||||||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||||||||
| 640 | The current element is the element matching the most recently parsed start | - | ||||||||||||||||||||||||||||||
| 641 | element of which a matching end element has not yet been reached. When the | - | ||||||||||||||||||||||||||||||
| 642 | parser has reached the end element, the current element becomes the parent | - | ||||||||||||||||||||||||||||||
| 643 | element. | - | ||||||||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||||||||
| 645 | This is a convenience function for when you're only concerned with parsing | - | ||||||||||||||||||||||||||||||
| 646 | XML elements. The \l{QXmlStream Bookmarks Example} makes extensive use of | - | ||||||||||||||||||||||||||||||
| 647 | this function. | - | ||||||||||||||||||||||||||||||
| 648 | - | |||||||||||||||||||||||||||||||
| 649 | \since 4.6 | - | ||||||||||||||||||||||||||||||
| 650 | \sa readNext() | - | ||||||||||||||||||||||||||||||
| 651 | */ | - | ||||||||||||||||||||||||||||||
| 652 | bool QXmlStreamReader::readNextStartElement() | - | ||||||||||||||||||||||||||||||
| 653 | { | - | ||||||||||||||||||||||||||||||
| 654 | while (readNext() != Invalid) {
| 12-263503 | ||||||||||||||||||||||||||||||
| 655 | if (isEndElement())
| 5055-258448 | ||||||||||||||||||||||||||||||
| 656 | return false; executed 5055 times by 35 tests: return false;Executed by:
| 5055 | ||||||||||||||||||||||||||||||
| 657 | else if (isStartElement())
| 124463-133985 | ||||||||||||||||||||||||||||||
| 658 | return true; executed 124463 times by 35 tests: return true;Executed by:
| 124463 | ||||||||||||||||||||||||||||||
| 659 | } executed 133985 times by 33 tests: end of blockExecuted by:
| 133985 | ||||||||||||||||||||||||||||||
| 660 | return false; executed 12 times by 1 test: return false;Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 661 | } | - | ||||||||||||||||||||||||||||||
| 662 | - | |||||||||||||||||||||||||||||||
| 663 | /*! | - | ||||||||||||||||||||||||||||||
| 664 | Reads until the end of the current element, skipping any child nodes. | - | ||||||||||||||||||||||||||||||
| 665 | This function is useful for skipping unknown elements. | - | ||||||||||||||||||||||||||||||
| 666 | - | |||||||||||||||||||||||||||||||
| 667 | The current element is the element matching the most recently parsed start | - | ||||||||||||||||||||||||||||||
| 668 | element of which a matching end element has not yet been reached. When the | - | ||||||||||||||||||||||||||||||
| 669 | parser has reached the end element, the current element becomes the parent | - | ||||||||||||||||||||||||||||||
| 670 | element. | - | ||||||||||||||||||||||||||||||
| 671 | - | |||||||||||||||||||||||||||||||
| 672 | \since 4.6 | - | ||||||||||||||||||||||||||||||
| 673 | */ | - | ||||||||||||||||||||||||||||||
| 674 | void QXmlStreamReader::skipCurrentElement() | - | ||||||||||||||||||||||||||||||
| 675 | { | - | ||||||||||||||||||||||||||||||
| 676 | int depth = 1; | - | ||||||||||||||||||||||||||||||
| 677 | while (depth && readNext() != Invalid) {
| 7-5120 | ||||||||||||||||||||||||||||||
| 678 | if (isEndElement())
| 24-5089 | ||||||||||||||||||||||||||||||
| 679 | --depth; executed 5089 times by 35 tests: --depth;Executed by:
| 5089 | ||||||||||||||||||||||||||||||
| 680 | else if (isStartElement())
| 11-13 | ||||||||||||||||||||||||||||||
| 681 | ++depth; executed 13 times by 2 tests: ++depth;Executed by:
| 13 | ||||||||||||||||||||||||||||||
| 682 | } executed 5113 times by 35 tests: end of blockExecuted by:
| 5113 | ||||||||||||||||||||||||||||||
| 683 | } executed 5083 times by 35 tests: end of blockExecuted by:
| 5083 | ||||||||||||||||||||||||||||||
| 684 | - | |||||||||||||||||||||||||||||||
| 685 | /* | - | ||||||||||||||||||||||||||||||
| 686 | * Use the following Perl script to generate the error string index list: | - | ||||||||||||||||||||||||||||||
| 687 | ===== PERL SCRIPT ==== | - | ||||||||||||||||||||||||||||||
| 688 | print "static const char QXmlStreamReader_tokenTypeString_string[] =\n"; | - | ||||||||||||||||||||||||||||||
| 689 | $counter = 0; | - | ||||||||||||||||||||||||||||||
| 690 | $i = 0; | - | ||||||||||||||||||||||||||||||
| 691 | while (<STDIN>) { | - | ||||||||||||||||||||||||||||||
| 692 | chomp; | - | ||||||||||||||||||||||||||||||
| 693 | print " \"$_\\0\"\n"; | - | ||||||||||||||||||||||||||||||
| 694 | $sizes[$i++] = $counter; | - | ||||||||||||||||||||||||||||||
| 695 | $counter += length 1 + $_; | - | ||||||||||||||||||||||||||||||
| 696 | } | - | ||||||||||||||||||||||||||||||
| 697 | print " \"\\0\";\n\nstatic const short QXmlStreamReader_tokenTypeString_indices[] = {\n "; | - | ||||||||||||||||||||||||||||||
| 698 | for ($j = 0; $j < $i; ++$j) { | - | ||||||||||||||||||||||||||||||
| 699 | printf "$sizes[$j], "; | - | ||||||||||||||||||||||||||||||
| 700 | } | - | ||||||||||||||||||||||||||||||
| 701 | print "0\n};\n"; | - | ||||||||||||||||||||||||||||||
| 702 | ===== PERL SCRIPT ==== | - | ||||||||||||||||||||||||||||||
| 703 | - | |||||||||||||||||||||||||||||||
| 704 | * The input data is as follows (copied from qxmlstream.h): | - | ||||||||||||||||||||||||||||||
| 705 | NoToken | - | ||||||||||||||||||||||||||||||
| 706 | Invalid | - | ||||||||||||||||||||||||||||||
| 707 | StartDocument | - | ||||||||||||||||||||||||||||||
| 708 | EndDocument | - | ||||||||||||||||||||||||||||||
| 709 | StartElement | - | ||||||||||||||||||||||||||||||
| 710 | EndElement | - | ||||||||||||||||||||||||||||||
| 711 | Characters | - | ||||||||||||||||||||||||||||||
| 712 | Comment | - | ||||||||||||||||||||||||||||||
| 713 | DTD | - | ||||||||||||||||||||||||||||||
| 714 | EntityReference | - | ||||||||||||||||||||||||||||||
| 715 | ProcessingInstruction | - | ||||||||||||||||||||||||||||||
| 716 | */ | - | ||||||||||||||||||||||||||||||
| 717 | static const char QXmlStreamReader_tokenTypeString_string[] = | - | ||||||||||||||||||||||||||||||
| 718 | "NoToken\0" | - | ||||||||||||||||||||||||||||||
| 719 | "Invalid\0" | - | ||||||||||||||||||||||||||||||
| 720 | "StartDocument\0" | - | ||||||||||||||||||||||||||||||
| 721 | "EndDocument\0" | - | ||||||||||||||||||||||||||||||
| 722 | "StartElement\0" | - | ||||||||||||||||||||||||||||||
| 723 | "EndElement\0" | - | ||||||||||||||||||||||||||||||
| 724 | "Characters\0" | - | ||||||||||||||||||||||||||||||
| 725 | "Comment\0" | - | ||||||||||||||||||||||||||||||
| 726 | "DTD\0" | - | ||||||||||||||||||||||||||||||
| 727 | "EntityReference\0" | - | ||||||||||||||||||||||||||||||
| 728 | "ProcessingInstruction\0"; | - | ||||||||||||||||||||||||||||||
| 729 | - | |||||||||||||||||||||||||||||||
| 730 | static const short QXmlStreamReader_tokenTypeString_indices[] = { | - | ||||||||||||||||||||||||||||||
| 731 | 0, 8, 16, 30, 42, 55, 66, 77, 85, 89, 105, 0 | - | ||||||||||||||||||||||||||||||
| 732 | }; | - | ||||||||||||||||||||||||||||||
| 733 | - | |||||||||||||||||||||||||||||||
| 734 | - | |||||||||||||||||||||||||||||||
| 735 | /*! | - | ||||||||||||||||||||||||||||||
| 736 | \property QXmlStreamReader::namespaceProcessing | - | ||||||||||||||||||||||||||||||
| 737 | The namespace-processing flag of the stream reader | - | ||||||||||||||||||||||||||||||
| 738 | - | |||||||||||||||||||||||||||||||
| 739 | This property controls whether or not the stream reader processes | - | ||||||||||||||||||||||||||||||
| 740 | namespaces. If enabled, the reader processes namespaces, otherwise | - | ||||||||||||||||||||||||||||||
| 741 | it does not. | - | ||||||||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||||||||
| 743 | By default, namespace-processing is enabled. | - | ||||||||||||||||||||||||||||||
| 744 | */ | - | ||||||||||||||||||||||||||||||
| 745 | - | |||||||||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||||||||
| 747 | void QXmlStreamReader::setNamespaceProcessing(bool enable) | - | ||||||||||||||||||||||||||||||
| 748 | { | - | ||||||||||||||||||||||||||||||
| 749 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 750 | d->namespaceProcessing = enable; | - | ||||||||||||||||||||||||||||||
| 751 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||||||||
| 753 | bool QXmlStreamReader::namespaceProcessing() const | - | ||||||||||||||||||||||||||||||
| 754 | { | - | ||||||||||||||||||||||||||||||
| 755 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 756 | return d->namespaceProcessing; never executed: return d->namespaceProcessing; | 0 | ||||||||||||||||||||||||||||||
| 757 | } | - | ||||||||||||||||||||||||||||||
| 758 | - | |||||||||||||||||||||||||||||||
| 759 | /*! Returns the reader's current token as string. | - | ||||||||||||||||||||||||||||||
| 760 | - | |||||||||||||||||||||||||||||||
| 761 | \sa tokenType() | - | ||||||||||||||||||||||||||||||
| 762 | */ | - | ||||||||||||||||||||||||||||||
| 763 | QString QXmlStreamReader::tokenString() const | - | ||||||||||||||||||||||||||||||
| 764 | { | - | ||||||||||||||||||||||||||||||
| 765 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 766 | return QLatin1String(QXmlStreamReader_tokenTypeString_string + executed 1903 times by 1 test: return QLatin1String(QXmlStreamReader_tokenTypeString_string + QXmlStreamReader_tokenTypeString_indices[d->type]);Executed by:
| 1903 | ||||||||||||||||||||||||||||||
| 767 | QXmlStreamReader_tokenTypeString_indices[d->type]); executed 1903 times by 1 test: return QLatin1String(QXmlStreamReader_tokenTypeString_string + QXmlStreamReader_tokenTypeString_indices[d->type]);Executed by:
| 1903 | ||||||||||||||||||||||||||||||
| 768 | } | - | ||||||||||||||||||||||||||||||
| 769 | - | |||||||||||||||||||||||||||||||
| 770 | #endif // QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 771 | - | |||||||||||||||||||||||||||||||
| 772 | QXmlStreamPrivateTagStack::QXmlStreamPrivateTagStack() | - | ||||||||||||||||||||||||||||||
| 773 | { | - | ||||||||||||||||||||||||||||||
| 774 | tagStack.reserve(16); | - | ||||||||||||||||||||||||||||||
| 775 | tagStackStringStorage.reserve(32); | - | ||||||||||||||||||||||||||||||
| 776 | tagStackStringStorageSize = 0; | - | ||||||||||||||||||||||||||||||
| 777 | NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 778 | namespaceDeclaration.prefix = addToStringStorage(QLatin1String("xml")); | - | ||||||||||||||||||||||||||||||
| 779 | namespaceDeclaration.namespaceUri = addToStringStorage(QLatin1String("http://www.w3.org/XML/1998/namespace")); | - | ||||||||||||||||||||||||||||||
| 780 | initialTagStackStringStorageSize = tagStackStringStorageSize; | - | ||||||||||||||||||||||||||||||
| 781 | } executed 8186 times by 38 tests: end of blockExecuted by:
| 8186 | ||||||||||||||||||||||||||||||
| 782 | - | |||||||||||||||||||||||||||||||
| 783 | #ifndef QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 784 | - | |||||||||||||||||||||||||||||||
| 785 | QXmlStreamReaderPrivate::QXmlStreamReaderPrivate(QXmlStreamReader *q) | - | ||||||||||||||||||||||||||||||
| 786 | :q_ptr(q) | - | ||||||||||||||||||||||||||||||
| 787 | { | - | ||||||||||||||||||||||||||||||
| 788 | device = 0; | - | ||||||||||||||||||||||||||||||
| 789 | deleteDevice = false; | - | ||||||||||||||||||||||||||||||
| 790 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 791 | decoder = 0; | - | ||||||||||||||||||||||||||||||
| 792 | #endif | - | ||||||||||||||||||||||||||||||
| 793 | stack_size = 64; | - | ||||||||||||||||||||||||||||||
| 794 | sym_stack = 0; | - | ||||||||||||||||||||||||||||||
| 795 | state_stack = 0; | - | ||||||||||||||||||||||||||||||
| 796 | reallocateStack(); | - | ||||||||||||||||||||||||||||||
| 797 | entityResolver = 0; | - | ||||||||||||||||||||||||||||||
| 798 | init(); | - | ||||||||||||||||||||||||||||||
| 799 | entityHash.insert(QLatin1String("lt"), Entity::createLiteral(QLatin1String("<"))); | - | ||||||||||||||||||||||||||||||
| 800 | entityHash.insert(QLatin1String("gt"), Entity::createLiteral(QLatin1String(">"))); | - | ||||||||||||||||||||||||||||||
| 801 | entityHash.insert(QLatin1String("amp"), Entity::createLiteral(QLatin1String("&"))); | - | ||||||||||||||||||||||||||||||
| 802 | entityHash.insert(QLatin1String("apos"), Entity::createLiteral(QLatin1String("'"))); | - | ||||||||||||||||||||||||||||||
| 803 | entityHash.insert(QLatin1String("quot"), Entity::createLiteral(QLatin1String("\""))); | - | ||||||||||||||||||||||||||||||
| 804 | } executed 7442 times by 36 tests: end of blockExecuted by:
| 7442 | ||||||||||||||||||||||||||||||
| 805 | - | |||||||||||||||||||||||||||||||
| 806 | void QXmlStreamReaderPrivate::init() | - | ||||||||||||||||||||||||||||||
| 807 | { | - | ||||||||||||||||||||||||||||||
| 808 | scanDtd = false; | - | ||||||||||||||||||||||||||||||
| 809 | token = -1; | - | ||||||||||||||||||||||||||||||
| 810 | token_char = 0; | - | ||||||||||||||||||||||||||||||
| 811 | isEmptyElement = false; | - | ||||||||||||||||||||||||||||||
| 812 | isWhitespace = true; | - | ||||||||||||||||||||||||||||||
| 813 | isCDATA = false; | - | ||||||||||||||||||||||||||||||
| 814 | standalone = false; | - | ||||||||||||||||||||||||||||||
| 815 | tos = 0; | - | ||||||||||||||||||||||||||||||
| 816 | resumeReduction = 0; | - | ||||||||||||||||||||||||||||||
| 817 | state_stack[tos++] = 0; | - | ||||||||||||||||||||||||||||||
| 818 | state_stack[tos] = 0; | - | ||||||||||||||||||||||||||||||
| 819 | putStack.clear(); | - | ||||||||||||||||||||||||||||||
| 820 | putStack.reserve(32); | - | ||||||||||||||||||||||||||||||
| 821 | textBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 822 | textBuffer.reserve(256); | - | ||||||||||||||||||||||||||||||
| 823 | tagStack.clear(); | - | ||||||||||||||||||||||||||||||
| 824 | tagsDone = false; | - | ||||||||||||||||||||||||||||||
| 825 | attributes.clear(); | - | ||||||||||||||||||||||||||||||
| 826 | attributes.reserve(16); | - | ||||||||||||||||||||||||||||||
| 827 | lineNumber = lastLineStart = characterOffset = 0; | - | ||||||||||||||||||||||||||||||
| 828 | readBufferPos = 0; | - | ||||||||||||||||||||||||||||||
| 829 | nbytesread = 0; | - | ||||||||||||||||||||||||||||||
| 830 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 831 | codec = QTextCodec::codecForMib(106); // utf8 | - | ||||||||||||||||||||||||||||||
| 832 | delete decoder; | - | ||||||||||||||||||||||||||||||
| 833 | decoder = 0; | - | ||||||||||||||||||||||||||||||
| 834 | #endif | - | ||||||||||||||||||||||||||||||
| 835 | attributeStack.clear(); | - | ||||||||||||||||||||||||||||||
| 836 | attributeStack.reserve(16); | - | ||||||||||||||||||||||||||||||
| 837 | entityParser = 0; | - | ||||||||||||||||||||||||||||||
| 838 | hasCheckedStartDocument = false; | - | ||||||||||||||||||||||||||||||
| 839 | normalizeLiterals = false; | - | ||||||||||||||||||||||||||||||
| 840 | hasSeenTag = false; | - | ||||||||||||||||||||||||||||||
| 841 | atEnd = false; | - | ||||||||||||||||||||||||||||||
| 842 | inParseEntity = false; | - | ||||||||||||||||||||||||||||||
| 843 | referenceToUnparsedEntityDetected = false; | - | ||||||||||||||||||||||||||||||
| 844 | referenceToParameterEntityDetected = false; | - | ||||||||||||||||||||||||||||||
| 845 | hasExternalDtdSubset = false; | - | ||||||||||||||||||||||||||||||
| 846 | lockEncoding = false; | - | ||||||||||||||||||||||||||||||
| 847 | namespaceProcessing = true; | - | ||||||||||||||||||||||||||||||
| 848 | rawReadBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 849 | dataBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 850 | readBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 851 | tagStackStringStorageSize = initialTagStackStringStorageSize; | - | ||||||||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||||||||
| 853 | type = QXmlStreamReader::NoToken; | - | ||||||||||||||||||||||||||||||
| 854 | error = QXmlStreamReader::NoError; | - | ||||||||||||||||||||||||||||||
| 855 | } executed 12147 times by 36 tests: end of blockExecuted by:
| 12147 | ||||||||||||||||||||||||||||||
| 856 | - | |||||||||||||||||||||||||||||||
| 857 | /* | - | ||||||||||||||||||||||||||||||
| 858 | Well-formed requires that we verify entity values. We do this with a | - | ||||||||||||||||||||||||||||||
| 859 | standard parser. | - | ||||||||||||||||||||||||||||||
| 860 | */ | - | ||||||||||||||||||||||||||||||
| 861 | void QXmlStreamReaderPrivate::parseEntity(const QString &value) | - | ||||||||||||||||||||||||||||||
| 862 | { | - | ||||||||||||||||||||||||||||||
| 863 | Q_Q(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||||||||
| 865 | if (value.isEmpty())
| 14-124 | ||||||||||||||||||||||||||||||
| 866 | return; executed 14 times by 1 test: return;Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||||||||
| 868 | - | |||||||||||||||||||||||||||||||
| 869 | if (!entityParser)
| 33-91 | ||||||||||||||||||||||||||||||
| 870 | entityParser = new QXmlStreamReaderPrivate(q); executed 91 times by 1 test: entityParser = new QXmlStreamReaderPrivate(q);Executed by:
| 91 | ||||||||||||||||||||||||||||||
| 871 | else | - | ||||||||||||||||||||||||||||||
| 872 | entityParser->init(); executed 33 times by 1 test: entityParser->init();Executed by:
| 33 | ||||||||||||||||||||||||||||||
| 873 | entityParser->inParseEntity = true; | - | ||||||||||||||||||||||||||||||
| 874 | entityParser->readBuffer = value; | - | ||||||||||||||||||||||||||||||
| 875 | entityParser->injectToken(PARSE_ENTITY); | - | ||||||||||||||||||||||||||||||
| 876 | while (!entityParser->atEnd && entityParser->type != QXmlStreamReader::Invalid)
| 6-215 | ||||||||||||||||||||||||||||||
| 877 | entityParser->parse(); executed 209 times by 1 test: entityParser->parse();Executed by:
| 209 | ||||||||||||||||||||||||||||||
| 878 | if (entityParser->type == QXmlStreamReader::Invalid || entityParser->tagStack.size())
| 2-108 | ||||||||||||||||||||||||||||||
| 879 | raiseWellFormedError(QXmlStream::tr("Invalid entity value.")); executed 18 times by 1 test: raiseWellFormedError(QXmlStream::tr("Invalid entity value."));Executed by:
| 18 | ||||||||||||||||||||||||||||||
| 880 | - | |||||||||||||||||||||||||||||||
| 881 | } executed 124 times by 1 test: end of blockExecuted by:
| 124 | ||||||||||||||||||||||||||||||
| 882 | - | |||||||||||||||||||||||||||||||
| 883 | inline void QXmlStreamReaderPrivate::reallocateStack() | - | ||||||||||||||||||||||||||||||
| 884 | { | - | ||||||||||||||||||||||||||||||
| 885 | stack_size <<= 1; | - | ||||||||||||||||||||||||||||||
| 886 | sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value))); | - | ||||||||||||||||||||||||||||||
| 887 | Q_CHECK_PTR(sym_stack); never executed: qBadAlloc();
| 0-7443 | ||||||||||||||||||||||||||||||
| 888 | state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int))); | - | ||||||||||||||||||||||||||||||
| 889 | Q_CHECK_PTR(state_stack); never executed: qBadAlloc();
| 0-7443 | ||||||||||||||||||||||||||||||
| 890 | } executed 7443 times by 36 tests: end of blockExecuted by:
| 7443 | ||||||||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||||||||
| 892 | - | |||||||||||||||||||||||||||||||
| 893 | QXmlStreamReaderPrivate::~QXmlStreamReaderPrivate() | - | ||||||||||||||||||||||||||||||
| 894 | { | - | ||||||||||||||||||||||||||||||
| 895 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 896 | delete decoder; | - | ||||||||||||||||||||||||||||||
| 897 | #endif | - | ||||||||||||||||||||||||||||||
| 898 | free(sym_stack); | - | ||||||||||||||||||||||||||||||
| 899 | free(state_stack); | - | ||||||||||||||||||||||||||||||
| 900 | delete entityParser; | - | ||||||||||||||||||||||||||||||
| 901 | } executed 7442 times by 36 tests: end of blockExecuted by:
| 7442 | ||||||||||||||||||||||||||||||
| 902 | - | |||||||||||||||||||||||||||||||
| 903 | - | |||||||||||||||||||||||||||||||
| 904 | inline uint QXmlStreamReaderPrivate::filterCarriageReturn() | - | ||||||||||||||||||||||||||||||
| 905 | { | - | ||||||||||||||||||||||||||||||
| 906 | uint peekc = peekChar(); | - | ||||||||||||||||||||||||||||||
| 907 | if (peekc == '\n') {
| 2158-8307 | ||||||||||||||||||||||||||||||
| 908 | if (putStack.size())
| 0-8307 | ||||||||||||||||||||||||||||||
| 909 | putStack.pop(); never executed: putStack.pop(); | 0 | ||||||||||||||||||||||||||||||
| 910 | else | - | ||||||||||||||||||||||||||||||
| 911 | ++readBufferPos; executed 8307 times by 1 test: ++readBufferPos;Executed by:
| 8307 | ||||||||||||||||||||||||||||||
| 912 | return peekc; executed 8307 times by 1 test: return peekc;Executed by:
| 8307 | ||||||||||||||||||||||||||||||
| 913 | } | - | ||||||||||||||||||||||||||||||
| 914 | if (peekc == StreamEOF) {
| 12-2146 | ||||||||||||||||||||||||||||||
| 915 | putChar('\r'); | - | ||||||||||||||||||||||||||||||
| 916 | return 0; executed 2146 times by 1 test: return 0;Executed by:
| 2146 | ||||||||||||||||||||||||||||||
| 917 | } | - | ||||||||||||||||||||||||||||||
| 918 | return '\n'; executed 12 times by 1 test: return '\n';Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 919 | } | - | ||||||||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||||||||
| 921 | /*! | - | ||||||||||||||||||||||||||||||
| 922 | \internal | - | ||||||||||||||||||||||||||||||
| 923 | If the end of the file is encountered, ~0 is returned. | - | ||||||||||||||||||||||||||||||
| 924 | */ | - | ||||||||||||||||||||||||||||||
| 925 | inline uint QXmlStreamReaderPrivate::getChar() | - | ||||||||||||||||||||||||||||||
| 926 | { | - | ||||||||||||||||||||||||||||||
| 927 | uint c; | - | ||||||||||||||||||||||||||||||
| 928 | if (putStack.size()) {
| 2882731-19625700 | ||||||||||||||||||||||||||||||
| 929 | c = atEnd ? StreamEOF : putStack.pop();
| 4859-2877872 | ||||||||||||||||||||||||||||||
| 930 | } else { executed 2882731 times by 36 tests: end of blockExecuted by:
| 2882731 | ||||||||||||||||||||||||||||||
| 931 | if (readBufferPos < readBuffer.size())
| 117084-19508616 | ||||||||||||||||||||||||||||||
| 932 | c = readBuffer.at(readBufferPos++).unicode(); executed 19508616 times by 36 tests: c = readBuffer.at(readBufferPos++).unicode();Executed by:
| 19508616 | ||||||||||||||||||||||||||||||
| 933 | else | - | ||||||||||||||||||||||||||||||
| 934 | c = getChar_helper(); executed 117084 times by 36 tests: c = getChar_helper();Executed by:
| 117084 | ||||||||||||||||||||||||||||||
| 935 | } | - | ||||||||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||||||||
| 937 | return c; executed 22508431 times by 36 tests: return c;Executed by:
| 22508431 | ||||||||||||||||||||||||||||||
| 938 | } | - | ||||||||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||||||||
| 940 | inline uint QXmlStreamReaderPrivate::peekChar() | - | ||||||||||||||||||||||||||||||
| 941 | { | - | ||||||||||||||||||||||||||||||
| 942 | uint c; | - | ||||||||||||||||||||||||||||||
| 943 | if (putStack.size()) {
| 14016-83809 | ||||||||||||||||||||||||||||||
| 944 | c = putStack.top(); | - | ||||||||||||||||||||||||||||||
| 945 | } else if (readBufferPos < readBuffer.size()) { executed 14016 times by 13 tests: end of blockExecuted by:
| 6682-77127 | ||||||||||||||||||||||||||||||
| 946 | c = readBuffer.at(readBufferPos).unicode(); | - | ||||||||||||||||||||||||||||||
| 947 | } else { executed 77127 times by 35 tests: end of blockExecuted by:
| 77127 | ||||||||||||||||||||||||||||||
| 948 | if ((c = getChar_helper()) != StreamEOF)
| 3331-3351 | ||||||||||||||||||||||||||||||
| 949 | --readBufferPos; executed 3331 times by 1 test: --readBufferPos;Executed by:
| 3331 | ||||||||||||||||||||||||||||||
| 950 | } executed 6682 times by 1 test: end of blockExecuted by:
| 6682 | ||||||||||||||||||||||||||||||
| 951 | - | |||||||||||||||||||||||||||||||
| 952 | return c; executed 97825 times by 35 tests: return c;Executed by:
| 97825 | ||||||||||||||||||||||||||||||
| 953 | } | - | ||||||||||||||||||||||||||||||
| 954 | - | |||||||||||||||||||||||||||||||
| 955 | /*! | - | ||||||||||||||||||||||||||||||
| 956 | \internal | - | ||||||||||||||||||||||||||||||
| 957 | - | |||||||||||||||||||||||||||||||
| 958 | Scans characters until \a str is encountered, and validates the characters | - | ||||||||||||||||||||||||||||||
| 959 | as according to the Char[2] production and do the line-ending normalization. | - | ||||||||||||||||||||||||||||||
| 960 | If any character is invalid, false is returned, otherwise true upon success. | - | ||||||||||||||||||||||||||||||
| 961 | - | |||||||||||||||||||||||||||||||
| 962 | If \a tokenToInject is not less than zero, injectToken() is called with | - | ||||||||||||||||||||||||||||||
| 963 | \a tokenToInject when \a str is found. | - | ||||||||||||||||||||||||||||||
| 964 | - | |||||||||||||||||||||||||||||||
| 965 | If any error occurred, false is returned, otherwise true. | - | ||||||||||||||||||||||||||||||
| 966 | */ | - | ||||||||||||||||||||||||||||||
| 967 | bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject) | - | ||||||||||||||||||||||||||||||
| 968 | { | - | ||||||||||||||||||||||||||||||
| 969 | int pos = textBuffer.size(); | - | ||||||||||||||||||||||||||||||
| 970 | int oldLineNumber = lineNumber; | - | ||||||||||||||||||||||||||||||
| 971 | - | |||||||||||||||||||||||||||||||
| 972 | uint c; | - | ||||||||||||||||||||||||||||||
| 973 | while ((c = getChar()) != StreamEOF) {
| 5870-1254415 | ||||||||||||||||||||||||||||||
| 974 | /* First, we do the validation & normalization. */ | - | ||||||||||||||||||||||||||||||
| 975 | switch (c) { | - | ||||||||||||||||||||||||||||||
| 976 | case '\r': executed 407 times by 1 test: case '\r':Executed by:
| 407 | ||||||||||||||||||||||||||||||
| 977 | if ((c = filterCarriageReturn()) == 0)
| 3-404 | ||||||||||||||||||||||||||||||
| 978 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 979 | // fall through | - | ||||||||||||||||||||||||||||||
| 980 | case '\n': code before this statement executed 404 times by 1 test: case '\n':Executed by:
executed 1800 times by 3 tests: case '\n':Executed by:
| 404-1800 | ||||||||||||||||||||||||||||||
| 981 | ++lineNumber; | - | ||||||||||||||||||||||||||||||
| 982 | lastLineStart = characterOffset + readBufferPos; | - | ||||||||||||||||||||||||||||||
| 983 | // fall through | - | ||||||||||||||||||||||||||||||
| 984 | case '\t': code before this statement executed 2204 times by 3 tests: case '\t':Executed by:
executed 723 times by 1 test: case '\t':Executed by:
| 723-2204 | ||||||||||||||||||||||||||||||
| 985 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 986 | continue; executed 2927 times by 3 tests: continue;Executed by:
| 2927 | ||||||||||||||||||||||||||||||
| 987 | default: executed 1251485 times by 25 tests: default:Executed by:
| 1251485 | ||||||||||||||||||||||||||||||
| 988 | if (c < 0x20 || (c > 0xFFFD && c < 0x10000) || c > QChar::LastValidCodePoint ) {
| 0-1251449 | ||||||||||||||||||||||||||||||
| 989 | raiseWellFormedError(QXmlStream::tr("Invalid XML character.")); | - | ||||||||||||||||||||||||||||||
| 990 | lineNumber = oldLineNumber; | - | ||||||||||||||||||||||||||||||
| 991 | return false; executed 41 times by 1 test: return false;Executed by:
| 41 | ||||||||||||||||||||||||||||||
| 992 | } | - | ||||||||||||||||||||||||||||||
| 993 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 994 | } executed 1251444 times by 25 tests: end of blockExecuted by:
| 1251444 | ||||||||||||||||||||||||||||||
| 995 | - | |||||||||||||||||||||||||||||||
| 996 | - | |||||||||||||||||||||||||||||||
| 997 | /* Second, attempt to lookup str. */ | - | ||||||||||||||||||||||||||||||
| 998 | if (c == uint(*str)) {
| 71833-1179614 | ||||||||||||||||||||||||||||||
| 999 | if (!*(str + 1)) {
| 0-71833 | ||||||||||||||||||||||||||||||
| 1000 | if (tokenToInject >= 0)
| 0 | ||||||||||||||||||||||||||||||
| 1001 | injectToken(tokenToInject); never executed: injectToken(tokenToInject); | 0 | ||||||||||||||||||||||||||||||
| 1002 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 1003 | } else { | - | ||||||||||||||||||||||||||||||
| 1004 | if (scanString(str + 1, tokenToInject, false))
| 5752-66081 | ||||||||||||||||||||||||||||||
| 1005 | return true; executed 66081 times by 25 tests: return true;Executed by:
| 66081 | ||||||||||||||||||||||||||||||
| 1006 | } executed 5752 times by 24 tests: end of blockExecuted by:
| 5752 | ||||||||||||||||||||||||||||||
| 1007 | } | - | ||||||||||||||||||||||||||||||
| 1008 | } executed 1185366 times by 25 tests: end of blockExecuted by:
| 1185366 | ||||||||||||||||||||||||||||||
| 1009 | putString(textBuffer, pos); | - | ||||||||||||||||||||||||||||||
| 1010 | textBuffer.resize(pos); | - | ||||||||||||||||||||||||||||||
| 1011 | lineNumber = oldLineNumber; | - | ||||||||||||||||||||||||||||||
| 1012 | return false; executed 5870 times by 1 test: return false;Executed by:
| 5870 | ||||||||||||||||||||||||||||||
| 1013 | } | - | ||||||||||||||||||||||||||||||
| 1014 | - | |||||||||||||||||||||||||||||||
| 1015 | bool QXmlStreamReaderPrivate::scanString(const char *str, short tokenToInject, bool requireSpace) | - | ||||||||||||||||||||||||||||||
| 1016 | { | - | ||||||||||||||||||||||||||||||
| 1017 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1018 | while (str[n]) {
| 133216-635395 | ||||||||||||||||||||||||||||||
| 1019 | uint c = getChar(); | - | ||||||||||||||||||||||||||||||
| 1020 | if (c != ushort(str[n])) {
| 29730-605665 | ||||||||||||||||||||||||||||||
| 1021 | if (c != StreamEOF)
| 11559-18171 | ||||||||||||||||||||||||||||||
| 1022 | putChar(c); executed 11559 times by 35 tests: putChar(c);Executed by:
| 11559 | ||||||||||||||||||||||||||||||
| 1023 | while (n--) {
| 29730-39487 | ||||||||||||||||||||||||||||||
| 1024 | putChar(ushort(str[n])); | - | ||||||||||||||||||||||||||||||
| 1025 | } executed 39487 times by 13 tests: end of blockExecuted by:
| 39487 | ||||||||||||||||||||||||||||||
| 1026 | return false; executed 29730 times by 35 tests: return false;Executed by:
| 29730 | ||||||||||||||||||||||||||||||
| 1027 | } | - | ||||||||||||||||||||||||||||||
| 1028 | ++n; | - | ||||||||||||||||||||||||||||||
| 1029 | } executed 605665 times by 36 tests: end of blockExecuted by:
| 605665 | ||||||||||||||||||||||||||||||
| 1030 | for (int i = 0; i < n; ++i)
| 133216-566178 | ||||||||||||||||||||||||||||||
| 1031 | textBuffer += QChar(ushort(str[i])); executed 566178 times by 35 tests: textBuffer += QChar(ushort(str[i]));Executed by:
| 566178 | ||||||||||||||||||||||||||||||
| 1032 | if (requireSpace) {
| 13715-119501 | ||||||||||||||||||||||||||||||
| 1033 | int s = fastScanSpace(); | - | ||||||||||||||||||||||||||||||
| 1034 | if (!s || atEnd) {
| 1435-12106 | ||||||||||||||||||||||||||||||
| 1035 | int pos = textBuffer.size() - n - s; | - | ||||||||||||||||||||||||||||||
| 1036 | putString(textBuffer, pos); | - | ||||||||||||||||||||||||||||||
| 1037 | textBuffer.resize(pos); | - | ||||||||||||||||||||||||||||||
| 1038 | return false; executed 3044 times by 1 test: return false;Executed by:
| 3044 | ||||||||||||||||||||||||||||||
| 1039 | } | - | ||||||||||||||||||||||||||||||
| 1040 | } executed 10671 times by 35 tests: end of blockExecuted by:
| 10671 | ||||||||||||||||||||||||||||||
| 1041 | if (tokenToInject >= 0)
| 64091-66081 | ||||||||||||||||||||||||||||||
| 1042 | injectToken(tokenToInject); executed 64091 times by 35 tests: injectToken(tokenToInject);Executed by:
| 64091 | ||||||||||||||||||||||||||||||
| 1043 | return true; executed 130172 times by 35 tests: return true;Executed by:
| 130172 | ||||||||||||||||||||||||||||||
| 1044 | } | - | ||||||||||||||||||||||||||||||
| 1045 | - | |||||||||||||||||||||||||||||||
| 1046 | bool QXmlStreamReaderPrivate::scanAfterLangleBang() | - | ||||||||||||||||||||||||||||||
| 1047 | { | - | ||||||||||||||||||||||||||||||
| 1048 | switch (peekChar()) { | - | ||||||||||||||||||||||||||||||
| 1049 | case '[': executed 46996 times by 2 tests: case '[':Executed by:
| 46996 | ||||||||||||||||||||||||||||||
| 1050 | return scanString(spell[CDATA_START], CDATA_START, false); executed 46996 times by 2 tests: return scanString(spell[CDATA_START], CDATA_START, false);Executed by:
| 46996 | ||||||||||||||||||||||||||||||
| 1051 | case 'D': executed 3815 times by 13 tests: case 'D':Executed by:
| 3815 | ||||||||||||||||||||||||||||||
| 1052 | return scanString(spell[DOCTYPE], DOCTYPE); executed 3815 times by 13 tests: return scanString(spell[DOCTYPE], DOCTYPE);Executed by:
| 3815 | ||||||||||||||||||||||||||||||
| 1053 | case 'A': executed 2355 times by 2 tests: case 'A':Executed by:
| 2355 | ||||||||||||||||||||||||||||||
| 1054 | return scanString(spell[ATTLIST], ATTLIST); executed 2355 times by 2 tests: return scanString(spell[ATTLIST], ATTLIST);Executed by:
| 2355 | ||||||||||||||||||||||||||||||
| 1055 | case 'N': executed 382 times by 1 test: case 'N':Executed by:
| 382 | ||||||||||||||||||||||||||||||
| 1056 | return scanString(spell[NOTATION], NOTATION); executed 382 times by 1 test: return scanString(spell[NOTATION], NOTATION);Executed by:
| 382 | ||||||||||||||||||||||||||||||
| 1057 | case 'E': executed 6772 times by 2 tests: case 'E':Executed by:
| 6772 | ||||||||||||||||||||||||||||||
| 1058 | if (scanString(spell[ELEMENT], ELEMENT))
| 2196-4576 | ||||||||||||||||||||||||||||||
| 1059 | return true; executed 2196 times by 2 tests: return true;Executed by:
| 2196 | ||||||||||||||||||||||||||||||
| 1060 | return scanString(spell[ENTITY], ENTITY); executed 4576 times by 1 test: return scanString(spell[ENTITY], ENTITY);Executed by:
| 4576 | ||||||||||||||||||||||||||||||
| 1061 | - | |||||||||||||||||||||||||||||||
| 1062 | default: executed 19837 times by 25 tests: default:Executed by:
| 19837 | ||||||||||||||||||||||||||||||
| 1063 | ; | - | ||||||||||||||||||||||||||||||
| 1064 | }; executed 19837 times by 25 tests: end of blockExecuted by:
| 19837 | ||||||||||||||||||||||||||||||
| 1065 | return false; executed 19837 times by 25 tests: return false;Executed by:
| 19837 | ||||||||||||||||||||||||||||||
| 1066 | } | - | ||||||||||||||||||||||||||||||
| 1067 | - | |||||||||||||||||||||||||||||||
| 1068 | bool QXmlStreamReaderPrivate::scanPublicOrSystem() | - | ||||||||||||||||||||||||||||||
| 1069 | { | - | ||||||||||||||||||||||||||||||
| 1070 | switch (peekChar()) { | - | ||||||||||||||||||||||||||||||
| 1071 | case 'S': executed 440 times by 1 test: case 'S':Executed by:
| 440 | ||||||||||||||||||||||||||||||
| 1072 | return scanString(spell[SYSTEM], SYSTEM); executed 440 times by 1 test: return scanString(spell[SYSTEM], SYSTEM);Executed by:
| 440 | ||||||||||||||||||||||||||||||
| 1073 | case 'P': executed 386 times by 12 tests: case 'P':Executed by:
| 386 | ||||||||||||||||||||||||||||||
| 1074 | return scanString(spell[PUBLIC], PUBLIC); executed 386 times by 12 tests: return scanString(spell[PUBLIC], PUBLIC);Executed by:
| 386 | ||||||||||||||||||||||||||||||
| 1075 | default: executed 1864 times by 2 tests: default:Executed by:
| 1864 | ||||||||||||||||||||||||||||||
| 1076 | ; | - | ||||||||||||||||||||||||||||||
| 1077 | } executed 1864 times by 2 tests: end of blockExecuted by:
| 1864 | ||||||||||||||||||||||||||||||
| 1078 | return false; executed 1864 times by 2 tests: return false;Executed by:
| 1864 | ||||||||||||||||||||||||||||||
| 1079 | } | - | ||||||||||||||||||||||||||||||
| 1080 | - | |||||||||||||||||||||||||||||||
| 1081 | bool QXmlStreamReaderPrivate::scanNData() | - | ||||||||||||||||||||||||||||||
| 1082 | { | - | ||||||||||||||||||||||||||||||
| 1083 | if (fastScanSpace()) {
| 48-150 | ||||||||||||||||||||||||||||||
| 1084 | if (scanString(spell[NDATA], NDATA))
| 47-103 | ||||||||||||||||||||||||||||||
| 1085 | return true; executed 47 times by 1 test: return true;Executed by:
| 47 | ||||||||||||||||||||||||||||||
| 1086 | putChar(' '); | - | ||||||||||||||||||||||||||||||
| 1087 | } executed 103 times by 1 test: end of blockExecuted by:
| 103 | ||||||||||||||||||||||||||||||
| 1088 | return false; executed 151 times by 1 test: return false;Executed by:
| 151 | ||||||||||||||||||||||||||||||
| 1089 | } | - | ||||||||||||||||||||||||||||||
| 1090 | - | |||||||||||||||||||||||||||||||
| 1091 | bool QXmlStreamReaderPrivate::scanAfterDefaultDecl() | - | ||||||||||||||||||||||||||||||
| 1092 | { | - | ||||||||||||||||||||||||||||||
| 1093 | switch (peekChar()) { | - | ||||||||||||||||||||||||||||||
| 1094 | case 'R': executed 615 times by 2 tests: case 'R':Executed by:
| 615 | ||||||||||||||||||||||||||||||
| 1095 | return scanString(spell[REQUIRED], REQUIRED, false); executed 615 times by 2 tests: return scanString(spell[REQUIRED], REQUIRED, false);Executed by:
| 615 | ||||||||||||||||||||||||||||||
| 1096 | case 'I': executed 1387 times by 2 tests: case 'I':Executed by:
| 1387 | ||||||||||||||||||||||||||||||
| 1097 | return scanString(spell[IMPLIED], IMPLIED, false); executed 1387 times by 2 tests: return scanString(spell[IMPLIED], IMPLIED, false);Executed by:
| 1387 | ||||||||||||||||||||||||||||||
| 1098 | case 'F': executed 77 times by 2 tests: case 'F':Executed by:
| 77 | ||||||||||||||||||||||||||||||
| 1099 | return scanString(spell[FIXED], FIXED, false); executed 77 times by 2 tests: return scanString(spell[FIXED], FIXED, false);Executed by:
| 77 | ||||||||||||||||||||||||||||||
| 1100 | default: executed 200 times by 1 test: default:Executed by:
| 200 | ||||||||||||||||||||||||||||||
| 1101 | ; | - | ||||||||||||||||||||||||||||||
| 1102 | } executed 200 times by 1 test: end of blockExecuted by:
| 200 | ||||||||||||||||||||||||||||||
| 1103 | return false; executed 200 times by 1 test: return false;Executed by:
| 200 | ||||||||||||||||||||||||||||||
| 1104 | } | - | ||||||||||||||||||||||||||||||
| 1105 | - | |||||||||||||||||||||||||||||||
| 1106 | bool QXmlStreamReaderPrivate::scanAttType() | - | ||||||||||||||||||||||||||||||
| 1107 | { | - | ||||||||||||||||||||||||||||||
| 1108 | switch (peekChar()) { | - | ||||||||||||||||||||||||||||||
| 1109 | case 'C': executed 1351 times by 2 tests: case 'C':Executed by:
| 1351 | ||||||||||||||||||||||||||||||
| 1110 | return scanString(spell[CDATA], CDATA); executed 1351 times by 2 tests: return scanString(spell[CDATA], CDATA);Executed by:
| 1351 | ||||||||||||||||||||||||||||||
| 1111 | case 'I': executed 272 times by 1 test: case 'I':Executed by:
| 272 | ||||||||||||||||||||||||||||||
| 1112 | if (scanString(spell[ID], ID))
| 70-202 | ||||||||||||||||||||||||||||||
| 1113 | return true; executed 70 times by 1 test: return true;Executed by:
| 70 | ||||||||||||||||||||||||||||||
| 1114 | if (scanString(spell[IDREF], IDREF))
| 23-179 | ||||||||||||||||||||||||||||||
| 1115 | return true; executed 23 times by 1 test: return true;Executed by:
| 23 | ||||||||||||||||||||||||||||||
| 1116 | return scanString(spell[IDREFS], IDREFS); executed 179 times by 1 test: return scanString(spell[IDREFS], IDREFS);Executed by:
| 179 | ||||||||||||||||||||||||||||||
| 1117 | case 'E': executed 163 times by 1 test: case 'E':Executed by:
| 163 | ||||||||||||||||||||||||||||||
| 1118 | if (scanString(spell[ENTITY], ENTITY))
| 26-137 | ||||||||||||||||||||||||||||||
| 1119 | return true; executed 26 times by 1 test: return true;Executed by:
| 26 | ||||||||||||||||||||||||||||||
| 1120 | return scanString(spell[ENTITIES], ENTITIES); executed 137 times by 1 test: return scanString(spell[ENTITIES], ENTITIES);Executed by:
| 137 | ||||||||||||||||||||||||||||||
| 1121 | case 'N': executed 334 times by 1 test: case 'N':Executed by:
| 334 | ||||||||||||||||||||||||||||||
| 1122 | if (scanString(spell[NOTATION], NOTATION))
| 42-292 | ||||||||||||||||||||||||||||||
| 1123 | return true; executed 42 times by 1 test: return true;Executed by:
| 42 | ||||||||||||||||||||||||||||||
| 1124 | if (scanString(spell[NMTOKEN], NMTOKEN))
| 24-268 | ||||||||||||||||||||||||||||||
| 1125 | return true; executed 24 times by 1 test: return true;Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 1126 | return scanString(spell[NMTOKENS], NMTOKENS); executed 268 times by 1 test: return scanString(spell[NMTOKENS], NMTOKENS);Executed by:
| 268 | ||||||||||||||||||||||||||||||
| 1127 | default: executed 114 times by 2 tests: default:Executed by:
| 114 | ||||||||||||||||||||||||||||||
| 1128 | ; | - | ||||||||||||||||||||||||||||||
| 1129 | } executed 114 times by 2 tests: end of blockExecuted by:
| 114 | ||||||||||||||||||||||||||||||
| 1130 | return false; executed 114 times by 2 tests: return false;Executed by:
| 114 | ||||||||||||||||||||||||||||||
| 1131 | } | - | ||||||||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||||||||
| 1133 | /*! | - | ||||||||||||||||||||||||||||||
| 1134 | \internal | - | ||||||||||||||||||||||||||||||
| 1135 | - | |||||||||||||||||||||||||||||||
| 1136 | Scan strings with quotes or apostrophes surround them. For instance, | - | ||||||||||||||||||||||||||||||
| 1137 | attributes, the version and encoding field in the XML prolog and | - | ||||||||||||||||||||||||||||||
| 1138 | entity declarations. | - | ||||||||||||||||||||||||||||||
| 1139 | - | |||||||||||||||||||||||||||||||
| 1140 | If normalizeLiterals is set to true, the function also normalizes | - | ||||||||||||||||||||||||||||||
| 1141 | whitespace. It is set to true when the first start tag is | - | ||||||||||||||||||||||||||||||
| 1142 | encountered. | - | ||||||||||||||||||||||||||||||
| 1143 | - | |||||||||||||||||||||||||||||||
| 1144 | */ | - | ||||||||||||||||||||||||||||||
| 1145 | inline int QXmlStreamReaderPrivate::fastScanLiteralContent() | - | ||||||||||||||||||||||||||||||
| 1146 | { | - | ||||||||||||||||||||||||||||||
| 1147 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1148 | uint c; | - | ||||||||||||||||||||||||||||||
| 1149 | while ((c = getChar()) != StreamEOF) {
| 2235-1550595 | ||||||||||||||||||||||||||||||
| 1150 | switch (ushort(c)) { | - | ||||||||||||||||||||||||||||||
| 1151 | case 0xfffe: never executed: case 0xfffe: | 0 | ||||||||||||||||||||||||||||||
| 1152 | case 0xffff: never executed: case 0xffff: | 0 | ||||||||||||||||||||||||||||||
| 1153 | case 0: executed 82 times by 1 test: case 0:Executed by:
| 82 | ||||||||||||||||||||||||||||||
| 1154 | /* The putChar() call is necessary so the parser re-gets | - | ||||||||||||||||||||||||||||||
| 1155 | * the character from the input source, when raising an error. */ | - | ||||||||||||||||||||||||||||||
| 1156 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1157 | return n; executed 82 times by 1 test: return n;Executed by:
| 82 | ||||||||||||||||||||||||||||||
| 1158 | case '\r': executed 24 times by 1 test: case '\r':Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 1159 | if (filterCarriageReturn() == 0)
| 1-23 | ||||||||||||||||||||||||||||||
| 1160 | return n; executed 1 time by 1 test: return n;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1161 | // fall through | - | ||||||||||||||||||||||||||||||
| 1162 | case '\n': code before this statement executed 23 times by 1 test: case '\n':Executed by:
executed 534 times by 2 tests: case '\n':Executed by:
| 23-534 | ||||||||||||||||||||||||||||||
| 1163 | ++lineNumber; | - | ||||||||||||||||||||||||||||||
| 1164 | lastLineStart = characterOffset + readBufferPos; | - | ||||||||||||||||||||||||||||||
| 1165 | // fall through | - | ||||||||||||||||||||||||||||||
| 1166 | case ' ': code before this statement executed 557 times by 2 tests: case ' ':Executed by:
executed 15991 times by 14 tests: case ' ':Executed by:
| 557-15991 | ||||||||||||||||||||||||||||||
| 1167 | case '\t': executed 18 times by 1 test: case '\t':Executed by:
| 18 | ||||||||||||||||||||||||||||||
| 1168 | if (normalizeLiterals)
| 1049-15517 | ||||||||||||||||||||||||||||||
| 1169 | textBuffer += QLatin1Char(' '); executed 15517 times by 4 tests: textBuffer += QLatin1Char(' ');Executed by:
| 15517 | ||||||||||||||||||||||||||||||
| 1170 | else | - | ||||||||||||||||||||||||||||||
| 1171 | textBuffer += QChar(c); executed 1049 times by 12 tests: textBuffer += QChar(c);Executed by:
| 1049 | ||||||||||||||||||||||||||||||
| 1172 | ++n; | - | ||||||||||||||||||||||||||||||
| 1173 | break; executed 16566 times by 14 tests: break;Executed by:
| 16566 | ||||||||||||||||||||||||||||||
| 1174 | case '&': executed 1664 times by 4 tests: case '&':Executed by:
| 1664 | ||||||||||||||||||||||||||||||
| 1175 | case '<': executed 19 times by 1 test: case '<':Executed by:
| 19 | ||||||||||||||||||||||||||||||
| 1176 | case '\"': executed 369034 times by 36 tests: case '\"':Executed by:
| 369034 | ||||||||||||||||||||||||||||||
| 1177 | case '\'': executed 245 times by 2 tests: case '\'':Executed by:
| 245 | ||||||||||||||||||||||||||||||
| 1178 | if (!(c & 0xff0000)) {
| 0-370962 | ||||||||||||||||||||||||||||||
| 1179 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1180 | return n; executed 370962 times by 36 tests: return n;Executed by:
| 370962 | ||||||||||||||||||||||||||||||
| 1181 | } | - | ||||||||||||||||||||||||||||||
| 1182 | // fall through | - | ||||||||||||||||||||||||||||||
| 1183 | default: code before this statement never executed: default:executed 1162984 times by 36 tests: default:Executed by:
| 0-1162984 | ||||||||||||||||||||||||||||||
| 1184 | if (c < 0x20) {
| 3-1162981 | ||||||||||||||||||||||||||||||
| 1185 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1186 | return n; executed 3 times by 1 test: return n;Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 1187 | } | - | ||||||||||||||||||||||||||||||
| 1188 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 1189 | ++n; | - | ||||||||||||||||||||||||||||||
| 1190 | } executed 1162981 times by 36 tests: end of blockExecuted by:
| 1162981 | ||||||||||||||||||||||||||||||
| 1191 | } | - | ||||||||||||||||||||||||||||||
| 1192 | return n; executed 2235 times by 1 test: return n;Executed by:
| 2235 | ||||||||||||||||||||||||||||||
| 1193 | } | - | ||||||||||||||||||||||||||||||
| 1194 | - | |||||||||||||||||||||||||||||||
| 1195 | inline int QXmlStreamReaderPrivate::fastScanSpace() | - | ||||||||||||||||||||||||||||||
| 1196 | { | - | ||||||||||||||||||||||||||||||
| 1197 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1198 | uint c; | - | ||||||||||||||||||||||||||||||
| 1199 | while ((c = getChar()) != StreamEOF) {
| 6683-435917 | ||||||||||||||||||||||||||||||
| 1200 | switch (c) { | - | ||||||||||||||||||||||||||||||
| 1201 | case '\r': executed 323 times by 1 test: case '\r':Executed by:
| 323 | ||||||||||||||||||||||||||||||
| 1202 | if ((c = filterCarriageReturn()) == 0)
| 45-278 | ||||||||||||||||||||||||||||||
| 1203 | return n; executed 45 times by 1 test: return n;Executed by:
| 45 | ||||||||||||||||||||||||||||||
| 1204 | // fall through | - | ||||||||||||||||||||||||||||||
| 1205 | case '\n': code before this statement executed 278 times by 1 test: case '\n':Executed by:
executed 135 times by 2 tests: case '\n':Executed by:
| 135-278 | ||||||||||||||||||||||||||||||
| 1206 | ++lineNumber; | - | ||||||||||||||||||||||||||||||
| 1207 | lastLineStart = characterOffset + readBufferPos; | - | ||||||||||||||||||||||||||||||
| 1208 | // fall through | - | ||||||||||||||||||||||||||||||
| 1209 | case ' ': code before this statement executed 413 times by 2 tests: case ' ':Executed by:
executed 16432 times by 35 tests: case ' ':Executed by:
| 413-16432 | ||||||||||||||||||||||||||||||
| 1210 | case '\t': executed 562 times by 1 test: case '\t':Executed by:
| 562 | ||||||||||||||||||||||||||||||
| 1211 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 1212 | ++n; | - | ||||||||||||||||||||||||||||||
| 1213 | break; executed 17407 times by 35 tests: break;Executed by:
| 17407 | ||||||||||||||||||||||||||||||
| 1214 | default: executed 418465 times by 36 tests: default:Executed by:
| 418465 | ||||||||||||||||||||||||||||||
| 1215 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1216 | return n; executed 418465 times by 36 tests: return n;Executed by:
| 418465 | ||||||||||||||||||||||||||||||
| 1217 | } | - | ||||||||||||||||||||||||||||||
| 1218 | } | - | ||||||||||||||||||||||||||||||
| 1219 | return n; executed 6683 times by 1 test: return n;Executed by:
| 6683 | ||||||||||||||||||||||||||||||
| 1220 | } | - | ||||||||||||||||||||||||||||||
| 1221 | - | |||||||||||||||||||||||||||||||
| 1222 | /*! | - | ||||||||||||||||||||||||||||||
| 1223 | \internal | - | ||||||||||||||||||||||||||||||
| 1224 | - | |||||||||||||||||||||||||||||||
| 1225 | Used for text nodes essentially. That is, characters appearing | - | ||||||||||||||||||||||||||||||
| 1226 | inside elements. | - | ||||||||||||||||||||||||||||||
| 1227 | */ | - | ||||||||||||||||||||||||||||||
| 1228 | inline int QXmlStreamReaderPrivate::fastScanContentCharList() | - | ||||||||||||||||||||||||||||||
| 1229 | { | - | ||||||||||||||||||||||||||||||
| 1230 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1231 | uint c; | - | ||||||||||||||||||||||||||||||
| 1232 | while ((c = getChar()) != StreamEOF) {
| 8002-5116550 | ||||||||||||||||||||||||||||||
| 1233 | switch (ushort(c)) { | - | ||||||||||||||||||||||||||||||
| 1234 | case 0xfffe: never executed: case 0xfffe: | 0 | ||||||||||||||||||||||||||||||
| 1235 | case 0xffff: executed 1 time by 1 test: case 0xffff:Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1236 | case 0: executed 60 times by 1 test: case 0:Executed by:
| 60 | ||||||||||||||||||||||||||||||
| 1237 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1238 | return n; executed 61 times by 1 test: return n;Executed by:
| 61 | ||||||||||||||||||||||||||||||
| 1239 | case ']': { executed 17 times by 1 test: case ']':Executed by:
| 17 | ||||||||||||||||||||||||||||||
| 1240 | isWhitespace = false; | - | ||||||||||||||||||||||||||||||
| 1241 | int pos = textBuffer.size(); | - | ||||||||||||||||||||||||||||||
| 1242 | textBuffer += QChar(ushort(c)); | - | ||||||||||||||||||||||||||||||
| 1243 | ++n; | - | ||||||||||||||||||||||||||||||
| 1244 | while ((c = getChar()) == ']') {
| 11-17 | ||||||||||||||||||||||||||||||
| 1245 | textBuffer += QChar(ushort(c)); | - | ||||||||||||||||||||||||||||||
| 1246 | ++n; | - | ||||||||||||||||||||||||||||||
| 1247 | } executed 11 times by 1 test: end of blockExecuted by:
| 11 | ||||||||||||||||||||||||||||||
| 1248 | if (c == 0) {
| 0-17 | ||||||||||||||||||||||||||||||
| 1249 | putString(textBuffer, pos); | - | ||||||||||||||||||||||||||||||
| 1250 | textBuffer.resize(pos); | - | ||||||||||||||||||||||||||||||
| 1251 | } else if (c == '>' && textBuffer.at(textBuffer.size()-2) == QLatin1Char(']')) { never executed: end of block
| 0-9 | ||||||||||||||||||||||||||||||
| 1252 | raiseWellFormedError(QXmlStream::tr("Sequence ']]>' not allowed in content.")); | - | ||||||||||||||||||||||||||||||
| 1253 | } else { executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||||||||
| 1254 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1255 | break; executed 9 times by 1 test: break;Executed by:
| 9 | ||||||||||||||||||||||||||||||
| 1256 | } | - | ||||||||||||||||||||||||||||||
| 1257 | return n; executed 8 times by 1 test: return n;Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 1258 | } break; dead code: break; | - | ||||||||||||||||||||||||||||||
| 1259 | case '\r': executed 389 times by 1 test: case '\r':Executed by:
| 389 | ||||||||||||||||||||||||||||||
| 1260 | if ((c = filterCarriageReturn()) == 0)
| 127-262 | ||||||||||||||||||||||||||||||
| 1261 | return n; executed 127 times by 1 test: return n;Executed by:
| 127 | ||||||||||||||||||||||||||||||
| 1262 | // fall through | - | ||||||||||||||||||||||||||||||
| 1263 | case '\n': code before this statement executed 262 times by 1 test: case '\n':Executed by:
executed 439 times by 3 tests: case '\n':Executed by:
| 262-439 | ||||||||||||||||||||||||||||||
| 1264 | ++lineNumber; | - | ||||||||||||||||||||||||||||||
| 1265 | lastLineStart = characterOffset + readBufferPos; | - | ||||||||||||||||||||||||||||||
| 1266 | // fall through | - | ||||||||||||||||||||||||||||||
| 1267 | case ' ': code before this statement executed 701 times by 3 tests: case ' ':Executed by:
executed 1433440 times by 34 tests: case ' ':Executed by:
| 701-1433440 | ||||||||||||||||||||||||||||||
| 1268 | case '\t': never executed: case '\t': | 0 | ||||||||||||||||||||||||||||||
| 1269 | textBuffer += QChar(ushort(c)); | - | ||||||||||||||||||||||||||||||
| 1270 | ++n; | - | ||||||||||||||||||||||||||||||
| 1271 | break; executed 1434141 times by 34 tests: break;Executed by:
| 1434141 | ||||||||||||||||||||||||||||||
| 1272 | case '&': executed 967 times by 2 tests: case '&':Executed by:
| 967 | ||||||||||||||||||||||||||||||
| 1273 | case '<': executed 676459 times by 34 tests: case '<':Executed by:
| 676459 | ||||||||||||||||||||||||||||||
| 1274 | if (!(c & 0xff0000)) {
| 0-677426 | ||||||||||||||||||||||||||||||
| 1275 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1276 | return n; executed 677426 times by 34 tests: return n;Executed by:
| 677426 | ||||||||||||||||||||||||||||||
| 1277 | } | - | ||||||||||||||||||||||||||||||
| 1278 | // fall through | - | ||||||||||||||||||||||||||||||
| 1279 | default: code before this statement never executed: default:executed 3004778 times by 24 tests: default:Executed by:
| 0-3004778 | ||||||||||||||||||||||||||||||
| 1280 | if (c < 0x20) {
| 5-3004773 | ||||||||||||||||||||||||||||||
| 1281 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1282 | return n; executed 5 times by 1 test: return n;Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 1283 | } | - | ||||||||||||||||||||||||||||||
| 1284 | isWhitespace = false; | - | ||||||||||||||||||||||||||||||
| 1285 | textBuffer += QChar(ushort(c)); | - | ||||||||||||||||||||||||||||||
| 1286 | ++n; | - | ||||||||||||||||||||||||||||||
| 1287 | } executed 3004773 times by 24 tests: end of blockExecuted by:
| 3004773 | ||||||||||||||||||||||||||||||
| 1288 | } | - | ||||||||||||||||||||||||||||||
| 1289 | return n; executed 8002 times by 1 test: return n;Executed by:
| 8002 | ||||||||||||||||||||||||||||||
| 1290 | } | - | ||||||||||||||||||||||||||||||
| 1291 | - | |||||||||||||||||||||||||||||||
| 1292 | inline int QXmlStreamReaderPrivate::fastScanName(int *prefix) | - | ||||||||||||||||||||||||||||||
| 1293 | { | - | ||||||||||||||||||||||||||||||
| 1294 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1295 | uint c; | - | ||||||||||||||||||||||||||||||
| 1296 | while ((c = getChar()) != StreamEOF) {
| 9761-7714886 | ||||||||||||||||||||||||||||||
| 1297 | switch (c) { | - | ||||||||||||||||||||||||||||||
| 1298 | case '\n': executed 46 times by 1 test: case '\n':Executed by:
| 46 | ||||||||||||||||||||||||||||||
| 1299 | case ' ': executed 316372 times by 36 tests: case ' ':Executed by:
| 316372 | ||||||||||||||||||||||||||||||
| 1300 | case '\t': executed 63 times by 1 test: case '\t':Executed by:
| 63 | ||||||||||||||||||||||||||||||
| 1301 | case '\r': executed 300 times by 1 test: case '\r':Executed by:
| 300 | ||||||||||||||||||||||||||||||
| 1302 | case '&': executed 1 time by 1 test: case '&':Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1303 | case '#': executed 1 time by 1 test: case '#':Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1304 | case '\'': executed 1 time by 1 test: case '\'':Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1305 | case '\"': executed 13 times by 1 test: case '\"':Executed by:
| 13 | ||||||||||||||||||||||||||||||
| 1306 | case '<': executed 2 times by 1 test: case '<':Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1307 | case '>': executed 370821 times by 36 tests: case '>':Executed by:
| 370821 | ||||||||||||||||||||||||||||||
| 1308 | case '[': executed 1 time by 1 test: case '[':Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1309 | case ']': executed 2 times by 1 test: case ']':Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1310 | case '=': executed 392288 times by 36 tests: case '=':Executed by:
| 392288 | ||||||||||||||||||||||||||||||
| 1311 | case '%': never executed: case '%': | 0 | ||||||||||||||||||||||||||||||
| 1312 | case '/': executed 374 times by 4 tests: case '/':Executed by:
| 374 | ||||||||||||||||||||||||||||||
| 1313 | case ';': executed 2130 times by 4 tests: case ';':Executed by:
| 2130 | ||||||||||||||||||||||||||||||
| 1314 | case '?': executed 61 times by 2 tests: case '?':Executed by:
| 61 | ||||||||||||||||||||||||||||||
| 1315 | case '!': executed 2 times by 1 test: case '!':Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1316 | case '^': executed 2 times by 1 test: case '^':Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1317 | case '|': executed 102 times by 1 test: case '|':Executed by:
| 102 | ||||||||||||||||||||||||||||||
| 1318 | case ',': executed 97 times by 2 tests: case ',':Executed by:
| 97 | ||||||||||||||||||||||||||||||
| 1319 | case '(': executed 7 times by 1 test: case '(':Executed by:
| 7 | ||||||||||||||||||||||||||||||
| 1320 | case ')': executed 227 times by 2 tests: case ')':Executed by:
| 227 | ||||||||||||||||||||||||||||||
| 1321 | case '+': executed 14 times by 2 tests: case '+':Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 1322 | case '*': executed 31 times by 1 test: case '*':Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 1323 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1324 | if (prefix && *prefix == n+1) {
| 4-1079735 | ||||||||||||||||||||||||||||||
| 1325 | *prefix = 0; | - | ||||||||||||||||||||||||||||||
| 1326 | putChar(':'); | - | ||||||||||||||||||||||||||||||
| 1327 | --n; | - | ||||||||||||||||||||||||||||||
| 1328 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 1329 | return n; executed 1082958 times by 36 tests: return n;Executed by:
| 1082958 | ||||||||||||||||||||||||||||||
| 1330 | case ':': executed 243743 times by 24 tests: case ':':Executed by:
| 243743 | ||||||||||||||||||||||||||||||
| 1331 | if (prefix) {
| 7-243736 | ||||||||||||||||||||||||||||||
| 1332 | if (*prefix == 0) {
| 2-243734 | ||||||||||||||||||||||||||||||
| 1333 | *prefix = n+2; | - | ||||||||||||||||||||||||||||||
| 1334 | } else { // only one colon allowed according to the namespace spec. executed 243734 times by 24 tests: end of blockExecuted by:
| 243734 | ||||||||||||||||||||||||||||||
| 1335 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1336 | return n; executed 2 times by 1 test: return n;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1337 | } | - | ||||||||||||||||||||||||||||||
| 1338 | } else { | - | ||||||||||||||||||||||||||||||
| 1339 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1340 | return n; executed 7 times by 1 test: return n;Executed by:
| 7 | ||||||||||||||||||||||||||||||
| 1341 | } | - | ||||||||||||||||||||||||||||||
| 1342 | // fall through | - | ||||||||||||||||||||||||||||||
| 1343 | default: code before this statement executed 243734 times by 24 tests: default:Executed by:
executed 6388185 times by 36 tests: default:Executed by:
| 243734-6388185 | ||||||||||||||||||||||||||||||
| 1344 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 1345 | ++n; | - | ||||||||||||||||||||||||||||||
| 1346 | } executed 6631919 times by 36 tests: end of blockExecuted by:
| 6631919 | ||||||||||||||||||||||||||||||
| 1347 | } | - | ||||||||||||||||||||||||||||||
| 1348 | - | |||||||||||||||||||||||||||||||
| 1349 | if (prefix)
| 991-8770 | ||||||||||||||||||||||||||||||
| 1350 | *prefix = 0; executed 8770 times by 1 test: *prefix = 0;Executed by:
| 8770 | ||||||||||||||||||||||||||||||
| 1351 | int pos = textBuffer.size() - n; | - | ||||||||||||||||||||||||||||||
| 1352 | putString(textBuffer, pos); | - | ||||||||||||||||||||||||||||||
| 1353 | textBuffer.resize(pos); | - | ||||||||||||||||||||||||||||||
| 1354 | return 0; executed 9761 times by 1 test: return 0;Executed by:
| 9761 | ||||||||||||||||||||||||||||||
| 1355 | } | - | ||||||||||||||||||||||||||||||
| 1356 | - | |||||||||||||||||||||||||||||||
| 1357 | enum NameChar { NameBeginning, NameNotBeginning, NotName }; | - | ||||||||||||||||||||||||||||||
| 1358 | - | |||||||||||||||||||||||||||||||
| 1359 | static const char Begi = static_cast<char>(NameBeginning); | - | ||||||||||||||||||||||||||||||
| 1360 | static const char NtBg = static_cast<char>(NameNotBeginning); | - | ||||||||||||||||||||||||||||||
| 1361 | static const char NotN = static_cast<char>(NotName); | - | ||||||||||||||||||||||||||||||
| 1362 | - | |||||||||||||||||||||||||||||||
| 1363 | static const char nameCharTable[128] = | - | ||||||||||||||||||||||||||||||
| 1364 | { | - | ||||||||||||||||||||||||||||||
| 1365 | // 0x00 | - | ||||||||||||||||||||||||||||||
| 1366 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1367 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1368 | // 0x10 | - | ||||||||||||||||||||||||||||||
| 1369 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1370 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1371 | // 0x20 (0x2D is '-', 0x2E is '.') | - | ||||||||||||||||||||||||||||||
| 1372 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1373 | NotN, NotN, NotN, NotN, NotN, NtBg, NtBg, NotN, | - | ||||||||||||||||||||||||||||||
| 1374 | // 0x30 (0x30..0x39 are '0'..'9', 0x3A is ':') | - | ||||||||||||||||||||||||||||||
| 1375 | NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, | - | ||||||||||||||||||||||||||||||
| 1376 | NtBg, NtBg, Begi, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1377 | // 0x40 (0x41..0x5A are 'A'..'Z') | - | ||||||||||||||||||||||||||||||
| 1378 | NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1379 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1380 | // 0x50 (0x5F is '_') | - | ||||||||||||||||||||||||||||||
| 1381 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1382 | Begi, Begi, Begi, NotN, NotN, NotN, NotN, Begi, | - | ||||||||||||||||||||||||||||||
| 1383 | // 0x60 (0x61..0x7A are 'a'..'z') | - | ||||||||||||||||||||||||||||||
| 1384 | NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1385 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1386 | // 0x70 | - | ||||||||||||||||||||||||||||||
| 1387 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1388 | Begi, Begi, Begi, NotN, NotN, NotN, NotN, NotN | - | ||||||||||||||||||||||||||||||
| 1389 | }; | - | ||||||||||||||||||||||||||||||
| 1390 | - | |||||||||||||||||||||||||||||||
| 1391 | static inline NameChar fastDetermineNameChar(QChar ch) | - | ||||||||||||||||||||||||||||||
| 1392 | { | - | ||||||||||||||||||||||||||||||
| 1393 | ushort uc = ch.unicode(); | - | ||||||||||||||||||||||||||||||
| 1394 | if (!(uc & ~0x7f)) // uc < 128
| 0-2874 | ||||||||||||||||||||||||||||||
| 1395 | return static_cast<NameChar>(nameCharTable[uc]); executed 2874 times by 2 tests: return static_cast<NameChar>(nameCharTable[uc]);Executed by:
| 2874 | ||||||||||||||||||||||||||||||
| 1396 | - | |||||||||||||||||||||||||||||||
| 1397 | QChar::Category cat = ch.category(); | - | ||||||||||||||||||||||||||||||
| 1398 | // ### some these categories might be slightly wrong | - | ||||||||||||||||||||||||||||||
| 1399 | if ((cat >= QChar::Letter_Uppercase && cat <= QChar::Letter_Other)
| 0 | ||||||||||||||||||||||||||||||
| 1400 | || cat == QChar::Number_Letter)
| 0 | ||||||||||||||||||||||||||||||
| 1401 | return NameBeginning; never executed: return NameBeginning; | 0 | ||||||||||||||||||||||||||||||
| 1402 | if ((cat >= QChar::Number_DecimalDigit && cat <= QChar::Number_Other)
| 0 | ||||||||||||||||||||||||||||||
| 1403 | || (cat >= QChar::Mark_NonSpacing && cat <= QChar::Mark_Enclosing))
| 0 | ||||||||||||||||||||||||||||||
| 1404 | return NameNotBeginning; never executed: return NameNotBeginning; | 0 | ||||||||||||||||||||||||||||||
| 1405 | return NotName; never executed: return NotName; | 0 | ||||||||||||||||||||||||||||||
| 1406 | } | - | ||||||||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||||||||
| 1408 | inline int QXmlStreamReaderPrivate::fastScanNMTOKEN() | - | ||||||||||||||||||||||||||||||
| 1409 | { | - | ||||||||||||||||||||||||||||||
| 1410 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1411 | uint c; | - | ||||||||||||||||||||||||||||||
| 1412 | while ((c = getChar()) != StreamEOF) {
| 229-2874 | ||||||||||||||||||||||||||||||
| 1413 | if (fastDetermineNameChar(c) == NotName) {
| 350-2524 | ||||||||||||||||||||||||||||||
| 1414 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1415 | return n; executed 350 times by 2 tests: return n;Executed by:
| 350 | ||||||||||||||||||||||||||||||
| 1416 | } else { | - | ||||||||||||||||||||||||||||||
| 1417 | ++n; | - | ||||||||||||||||||||||||||||||
| 1418 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 1419 | } executed 2524 times by 2 tests: end of blockExecuted by:
| 2524 | ||||||||||||||||||||||||||||||
| 1420 | } | - | ||||||||||||||||||||||||||||||
| 1421 | - | |||||||||||||||||||||||||||||||
| 1422 | int pos = textBuffer.size() - n; | - | ||||||||||||||||||||||||||||||
| 1423 | putString(textBuffer, pos); | - | ||||||||||||||||||||||||||||||
| 1424 | textBuffer.resize(pos); | - | ||||||||||||||||||||||||||||||
| 1425 | - | |||||||||||||||||||||||||||||||
| 1426 | return n; executed 229 times by 1 test: return n;Executed by:
| 229 | ||||||||||||||||||||||||||||||
| 1427 | } | - | ||||||||||||||||||||||||||||||
| 1428 | - | |||||||||||||||||||||||||||||||
| 1429 | void QXmlStreamReaderPrivate::putString(const QString &s, int from) | - | ||||||||||||||||||||||||||||||
| 1430 | { | - | ||||||||||||||||||||||||||||||
| 1431 | putStack.reserve(s.size()); | - | ||||||||||||||||||||||||||||||
| 1432 | for (int i = s.size()-1; i >= from; --i)
| 18909-205554 | ||||||||||||||||||||||||||||||
| 1433 | putStack.rawPush() = s.at(i).unicode(); executed 205554 times by 1 test: putStack.rawPush() = s.at(i).unicode();Executed by:
| 205554 | ||||||||||||||||||||||||||||||
| 1434 | } executed 18909 times by 1 test: end of blockExecuted by:
| 18909 | ||||||||||||||||||||||||||||||
| 1435 | - | |||||||||||||||||||||||||||||||
| 1436 | void QXmlStreamReaderPrivate::putStringLiteral(const QString &s) | - | ||||||||||||||||||||||||||||||
| 1437 | { | - | ||||||||||||||||||||||||||||||
| 1438 | putStack.reserve(s.size()); | - | ||||||||||||||||||||||||||||||
| 1439 | for (int i = s.size()-1; i >= 0; --i)
| 1792-1805 | ||||||||||||||||||||||||||||||
| 1440 | putStack.rawPush() = ((LETTER << 16) | s.at(i).unicode()); executed 1805 times by 4 tests: putStack.rawPush() = ((LETTER << 16) | s.at(i).unicode());Executed by:
| 1805 | ||||||||||||||||||||||||||||||
| 1441 | } executed 1792 times by 4 tests: end of blockExecuted by:
| 1792 | ||||||||||||||||||||||||||||||
| 1442 | - | |||||||||||||||||||||||||||||||
| 1443 | void QXmlStreamReaderPrivate::putReplacement(const QString &s) | - | ||||||||||||||||||||||||||||||
| 1444 | { | - | ||||||||||||||||||||||||||||||
| 1445 | putStack.reserve(s.size()); | - | ||||||||||||||||||||||||||||||
| 1446 | for (int i = s.size()-1; i >= 0; --i) {
| 117-1077 | ||||||||||||||||||||||||||||||
| 1447 | ushort c = s.at(i).unicode(); | - | ||||||||||||||||||||||||||||||
| 1448 | if (c == '\n' || c == '\r')
| 2-1075 | ||||||||||||||||||||||||||||||
| 1449 | putStack.rawPush() = ((LETTER << 16) | c); executed 4 times by 1 test: putStack.rawPush() = ((LETTER << 16) | c);Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 1450 | else | - | ||||||||||||||||||||||||||||||
| 1451 | putStack.rawPush() = c; executed 1073 times by 1 test: putStack.rawPush() = c;Executed by:
| 1073 | ||||||||||||||||||||||||||||||
| 1452 | } | - | ||||||||||||||||||||||||||||||
| 1453 | } executed 117 times by 1 test: end of blockExecuted by:
| 117 | ||||||||||||||||||||||||||||||
| 1454 | void QXmlStreamReaderPrivate::putReplacementInAttributeValue(const QString &s) | - | ||||||||||||||||||||||||||||||
| 1455 | { | - | ||||||||||||||||||||||||||||||
| 1456 | putStack.reserve(s.size()); | - | ||||||||||||||||||||||||||||||
| 1457 | for (int i = s.size()-1; i >= 0; --i) {
| 98-990 | ||||||||||||||||||||||||||||||
| 1458 | ushort c = s.at(i).unicode(); | - | ||||||||||||||||||||||||||||||
| 1459 | if (c == '&' || c == ';')
| 49-941 | ||||||||||||||||||||||||||||||
| 1460 | putStack.rawPush() = c; executed 109 times by 1 test: putStack.rawPush() = c;Executed by:
| 109 | ||||||||||||||||||||||||||||||
| 1461 | else if (c == '\n' || c == '\r')
| 2-877 | ||||||||||||||||||||||||||||||
| 1462 | putStack.rawPush() = ' '; executed 6 times by 1 test: putStack.rawPush() = ' ';Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 1463 | else | - | ||||||||||||||||||||||||||||||
| 1464 | putStack.rawPush() = ((LETTER << 16) | c); executed 875 times by 1 test: putStack.rawPush() = ((LETTER << 16) | c);Executed by:
| 875 | ||||||||||||||||||||||||||||||
| 1465 | } | - | ||||||||||||||||||||||||||||||
| 1466 | } executed 98 times by 1 test: end of blockExecuted by:
| 98 | ||||||||||||||||||||||||||||||
| 1467 | - | |||||||||||||||||||||||||||||||
| 1468 | uint QXmlStreamReaderPrivate::getChar_helper() | - | ||||||||||||||||||||||||||||||
| 1469 | { | - | ||||||||||||||||||||||||||||||
| 1470 | const int BUFFER_SIZE = 8192; | - | ||||||||||||||||||||||||||||||
| 1471 | characterOffset += readBufferPos; | - | ||||||||||||||||||||||||||||||
| 1472 | readBufferPos = 0; | - | ||||||||||||||||||||||||||||||
| 1473 | readBuffer.resize(0); | - | ||||||||||||||||||||||||||||||
| 1474 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 1475 | if (decoder)
| 7746-116020 | ||||||||||||||||||||||||||||||
| 1476 | #endif | - | ||||||||||||||||||||||||||||||
| 1477 | nbytesread = 0; executed 116020 times by 15 tests: nbytesread = 0;Executed by:
| 116020 | ||||||||||||||||||||||||||||||
| 1478 | if (device) {
| 5829-117937 | ||||||||||||||||||||||||||||||
| 1479 | rawReadBuffer.resize(BUFFER_SIZE); | - | ||||||||||||||||||||||||||||||
| 1480 | int nbytesreadOrMinus1 = device->read(rawReadBuffer.data() + nbytesread, BUFFER_SIZE - nbytesread); | - | ||||||||||||||||||||||||||||||
| 1481 | nbytesread += qMax(nbytesreadOrMinus1, 0); | - | ||||||||||||||||||||||||||||||
| 1482 | } else { executed 5829 times by 23 tests: end of blockExecuted by:
| 5829 | ||||||||||||||||||||||||||||||
| 1483 | if (nbytesread)
| 780-117157 | ||||||||||||||||||||||||||||||
| 1484 | rawReadBuffer += dataBuffer; executed 780 times by 1 test: rawReadBuffer += dataBuffer;Executed by:
| 780 | ||||||||||||||||||||||||||||||
| 1485 | else | - | ||||||||||||||||||||||||||||||
| 1486 | rawReadBuffer = dataBuffer; executed 117157 times by 14 tests: rawReadBuffer = dataBuffer;Executed by:
| 117157 | ||||||||||||||||||||||||||||||
| 1487 | nbytesread = rawReadBuffer.size(); | - | ||||||||||||||||||||||||||||||
| 1488 | dataBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 1489 | } executed 117937 times by 14 tests: end of blockExecuted by:
| 117937 | ||||||||||||||||||||||||||||||
| 1490 | if (!nbytesread) {
| 59780-63986 | ||||||||||||||||||||||||||||||
| 1491 | atEnd = true; | - | ||||||||||||||||||||||||||||||
| 1492 | return StreamEOF; executed 59780 times by 15 tests: return StreamEOF;Executed by:
| 59780 | ||||||||||||||||||||||||||||||
| 1493 | } | - | ||||||||||||||||||||||||||||||
| 1494 | - | |||||||||||||||||||||||||||||||
| 1495 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 1496 | if (!decoder) {
| 6108-57878 | ||||||||||||||||||||||||||||||
| 1497 | if (nbytesread < 4) { // the 4 is to cover 0xef 0xbb 0xbf plus
| 782-5326 | ||||||||||||||||||||||||||||||
| 1498 | // one extra for the utf8 codec | - | ||||||||||||||||||||||||||||||
| 1499 | atEnd = true; | - | ||||||||||||||||||||||||||||||
| 1500 | return StreamEOF; executed 782 times by 1 test: return StreamEOF;Executed by:
| 782 | ||||||||||||||||||||||||||||||
| 1501 | } | - | ||||||||||||||||||||||||||||||
| 1502 | int mib = 106; // UTF-8 | - | ||||||||||||||||||||||||||||||
| 1503 | - | |||||||||||||||||||||||||||||||
| 1504 | // look for byte order mark | - | ||||||||||||||||||||||||||||||
| 1505 | uchar ch1 = rawReadBuffer.at(0); | - | ||||||||||||||||||||||||||||||
| 1506 | uchar ch2 = rawReadBuffer.at(1); | - | ||||||||||||||||||||||||||||||
| 1507 | uchar ch3 = rawReadBuffer.at(2); | - | ||||||||||||||||||||||||||||||
| 1508 | uchar ch4 = rawReadBuffer.at(3); | - | ||||||||||||||||||||||||||||||
| 1509 | - | |||||||||||||||||||||||||||||||
| 1510 | if ((ch1 == 0 && ch2 == 0 && ch3 == 0xfe && ch4 == 0xff) ||
| 0-5325 | ||||||||||||||||||||||||||||||
| 1511 | (ch1 == 0xff && ch2 == 0xfe && ch3 == 0 && ch4 == 0))
| 0-5286 | ||||||||||||||||||||||||||||||
| 1512 | mib = 1017; // UTF-32 with byte order mark never executed: mib = 1017; | 0 | ||||||||||||||||||||||||||||||
| 1513 | else if (ch1 == 0x3c && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x00)
| 0-5248 | ||||||||||||||||||||||||||||||
| 1514 | mib = 1019; // UTF-32LE never executed: mib = 1019; | 0 | ||||||||||||||||||||||||||||||
| 1515 | else if (ch1 == 0x00 && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x3c)
| 0-5325 | ||||||||||||||||||||||||||||||
| 1516 | mib = 1018; // UTF-32BE never executed: mib = 1018; | 0 | ||||||||||||||||||||||||||||||
| 1517 | else if ((ch1 == 0xfe && ch2 == 0xff) || (ch1 == 0xff && ch2 == 0xfe))
| 0-5325 | ||||||||||||||||||||||||||||||
| 1518 | mib = 1015; // UTF-16 with byte order mark executed 41 times by 1 test: mib = 1015;Executed by:
| 41 | ||||||||||||||||||||||||||||||
| 1519 | else if (ch1 == 0x3c && ch2 == 0x00)
| 0-5248 | ||||||||||||||||||||||||||||||
| 1520 | mib = 1014; // UTF-16LE never executed: mib = 1014; | 0 | ||||||||||||||||||||||||||||||
| 1521 | else if (ch1 == 0x00 && ch2 == 0x3c)
| 0-5284 | ||||||||||||||||||||||||||||||
| 1522 | mib = 1013; // UTF-16BE executed 1 time by 1 test: mib = 1013;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1523 | codec = QTextCodec::codecForMib(mib); | - | ||||||||||||||||||||||||||||||
| 1524 | Q_ASSERT(codec); | - | ||||||||||||||||||||||||||||||
| 1525 | decoder = codec->makeDecoder(); | - | ||||||||||||||||||||||||||||||
| 1526 | } executed 5326 times by 24 tests: end of blockExecuted by:
| 5326 | ||||||||||||||||||||||||||||||
| 1527 | - | |||||||||||||||||||||||||||||||
| 1528 | decoder->toUnicode(&readBuffer, rawReadBuffer.constData(), nbytesread); | - | ||||||||||||||||||||||||||||||
| 1529 | - | |||||||||||||||||||||||||||||||
| 1530 | if(lockEncoding && decoder->hasFailure()) {
| 0-55226 | ||||||||||||||||||||||||||||||
| 1531 | raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content.")); | - | ||||||||||||||||||||||||||||||
| 1532 | readBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 1533 | return StreamEOF; never executed: return StreamEOF; | 0 | ||||||||||||||||||||||||||||||
| 1534 | } | - | ||||||||||||||||||||||||||||||
| 1535 | #else | - | ||||||||||||||||||||||||||||||
| 1536 | readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread); | - | ||||||||||||||||||||||||||||||
| 1537 | #endif // QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 1538 | - | |||||||||||||||||||||||||||||||
| 1539 | readBuffer.reserve(1); // keep capacity when calling resize() next time | - | ||||||||||||||||||||||||||||||
| 1540 | - | |||||||||||||||||||||||||||||||
| 1541 | if (readBufferPos < readBuffer.size()) {
| 243-62961 | ||||||||||||||||||||||||||||||
| 1542 | ushort c = readBuffer.at(readBufferPos++).unicode(); | - | ||||||||||||||||||||||||||||||
| 1543 | return c; executed 62961 times by 36 tests: return c;Executed by:
| 62961 | ||||||||||||||||||||||||||||||
| 1544 | } | - | ||||||||||||||||||||||||||||||
| 1545 | - | |||||||||||||||||||||||||||||||
| 1546 | atEnd = true; | - | ||||||||||||||||||||||||||||||
| 1547 | return StreamEOF; executed 243 times by 1 test: return StreamEOF;Executed by:
| 243 | ||||||||||||||||||||||||||||||
| 1548 | } | - | ||||||||||||||||||||||||||||||
| 1549 | - | |||||||||||||||||||||||||||||||
| 1550 | QStringRef QXmlStreamReaderPrivate::namespaceForPrefix(const QStringRef &prefix) | - | ||||||||||||||||||||||||||||||
| 1551 | { | - | ||||||||||||||||||||||||||||||
| 1552 | for (int j = namespaceDeclarations.size() - 1; j >= 0; --j) {
| 78711-970435 | ||||||||||||||||||||||||||||||
| 1553 | const NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(j); | - | ||||||||||||||||||||||||||||||
| 1554 | if (namespaceDeclaration.prefix == prefix) {
| 453543-516892 | ||||||||||||||||||||||||||||||
| 1555 | return namespaceDeclaration.namespaceUri; executed 516892 times by 24 tests: return namespaceDeclaration.namespaceUri;Executed by:
| 516892 | ||||||||||||||||||||||||||||||
| 1556 | } | - | ||||||||||||||||||||||||||||||
| 1557 | } executed 453543 times by 36 tests: end of blockExecuted by:
| 453543 | ||||||||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||||||||
| 1559 | #if 1 | - | ||||||||||||||||||||||||||||||
| 1560 | if (namespaceProcessing && !prefix.isEmpty())
| 0-78711 | ||||||||||||||||||||||||||||||
| 1561 | raiseWellFormedError(QXmlStream::tr("Namespace prefix '%1' not declared").arg(prefix.toString())); executed 6 times by 1 test: raiseWellFormedError(QXmlStream::tr("Namespace prefix '%1' not declared").arg(prefix.toString()));Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 1562 | #endif | - | ||||||||||||||||||||||||||||||
| 1563 | - | |||||||||||||||||||||||||||||||
| 1564 | return QStringRef(); executed 78711 times by 14 tests: return QStringRef();Executed by:
| 78711 | ||||||||||||||||||||||||||||||
| 1565 | } | - | ||||||||||||||||||||||||||||||
| 1566 | - | |||||||||||||||||||||||||||||||
| 1567 | /* | - | ||||||||||||||||||||||||||||||
| 1568 | uses namespaceForPrefix and builds the attribute vector | - | ||||||||||||||||||||||||||||||
| 1569 | */ | - | ||||||||||||||||||||||||||||||
| 1570 | void QXmlStreamReaderPrivate::resolveTag() | - | ||||||||||||||||||||||||||||||
| 1571 | { | - | ||||||||||||||||||||||||||||||
| 1572 | int n = attributeStack.size(); | - | ||||||||||||||||||||||||||||||
| 1573 | - | |||||||||||||||||||||||||||||||
| 1574 | if (namespaceProcessing) {
| 0-352257 | ||||||||||||||||||||||||||||||
| 1575 | for (int a = 0; a < dtdAttributes.size(); ++a) {
| 352257-3832797 | ||||||||||||||||||||||||||||||
| 1576 | DtdAttribute &dtdAttribute = dtdAttributes[a]; | - | ||||||||||||||||||||||||||||||
| 1577 | if (!dtdAttribute.isNamespaceAttribute
| 153669-3679128 | ||||||||||||||||||||||||||||||
| 1578 | || dtdAttribute.defaultValue.isNull()
| 91-153578 | ||||||||||||||||||||||||||||||
| 1579 | || dtdAttribute.tagName != qualifiedName
| 9-153569 | ||||||||||||||||||||||||||||||
| 1580 | || dtdAttribute.attributeQualifiedName.isNull())
| 0-9 | ||||||||||||||||||||||||||||||
| 1581 | continue; executed 3832788 times by 2 tests: continue;Executed by:
| 3832788 | ||||||||||||||||||||||||||||||
| 1582 | int i = 0; | - | ||||||||||||||||||||||||||||||
| 1583 | while (i < n && symName(attributeStack[i].key) != dtdAttribute.attributeQualifiedName)
| 0-9 | ||||||||||||||||||||||||||||||
| 1584 | ++i; executed 3 times by 1 test: ++i;Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 1585 | if (i != n)
| 0-9 | ||||||||||||||||||||||||||||||
| 1586 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 1587 | if (dtdAttribute.attributePrefix.isEmpty() && dtdAttribute.attributeName == QLatin1String("xmlns")) {
| 0-7 | ||||||||||||||||||||||||||||||
| 1588 | NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 1589 | namespaceDeclaration.prefix.clear(); | - | ||||||||||||||||||||||||||||||
| 1590 | - | |||||||||||||||||||||||||||||||
| 1591 | const QStringRef ns(dtdAttribute.defaultValue); | - | ||||||||||||||||||||||||||||||
| 1592 | if(ns == QLatin1String("http://www.w3.org/2000/xmlns/") ||
| 0-7 | ||||||||||||||||||||||||||||||
| 1593 | ns == QLatin1String("http://www.w3.org/XML/1998/namespace"))
| 0-7 | ||||||||||||||||||||||||||||||
| 1594 | raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration.")); never executed: raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration.")); | 0 | ||||||||||||||||||||||||||||||
| 1595 | else | - | ||||||||||||||||||||||||||||||
| 1596 | namespaceDeclaration.namespaceUri = ns; executed 7 times by 2 tests: namespaceDeclaration.namespaceUri = ns;Executed by:
| 7 | ||||||||||||||||||||||||||||||
| 1597 | } else if (dtdAttribute.attributePrefix == QLatin1String("xmlns")) {
| 0-2 | ||||||||||||||||||||||||||||||
| 1598 | NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 1599 | QStringRef namespacePrefix = dtdAttribute.attributeName; | - | ||||||||||||||||||||||||||||||
| 1600 | QStringRef namespaceUri = dtdAttribute.defaultValue; | - | ||||||||||||||||||||||||||||||
| 1601 | if (((namespacePrefix == QLatin1String("xml"))
| 0-2 | ||||||||||||||||||||||||||||||
| 1602 | ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))
| 0-2 | ||||||||||||||||||||||||||||||
| 1603 | || namespaceUri == QLatin1String("http://www.w3.org/2000/xmlns/")
| 0-2 | ||||||||||||||||||||||||||||||
| 1604 | || namespaceUri.isEmpty()
| 0-2 | ||||||||||||||||||||||||||||||
| 1605 | || namespacePrefix == QLatin1String("xmlns"))
| 0-2 | ||||||||||||||||||||||||||||||
| 1606 | raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration.")); never executed: raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration.")); | 0 | ||||||||||||||||||||||||||||||
| 1607 | - | |||||||||||||||||||||||||||||||
| 1608 | namespaceDeclaration.prefix = namespacePrefix; | - | ||||||||||||||||||||||||||||||
| 1609 | namespaceDeclaration.namespaceUri = namespaceUri; | - | ||||||||||||||||||||||||||||||
| 1610 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 1611 | } executed 9 times by 2 tests: end of blockExecuted by:
| 9 | ||||||||||||||||||||||||||||||
| 1612 | } executed 352257 times by 36 tests: end of blockExecuted by:
| 352257 | ||||||||||||||||||||||||||||||
| 1613 | - | |||||||||||||||||||||||||||||||
| 1614 | tagStack.top().namespaceDeclaration.namespaceUri = namespaceUri = namespaceForPrefix(prefix); | - | ||||||||||||||||||||||||||||||
| 1615 | - | |||||||||||||||||||||||||||||||
| 1616 | attributes.resize(n); | - | ||||||||||||||||||||||||||||||
| 1617 | - | |||||||||||||||||||||||||||||||
| 1618 | for (int i = 0; i < n; ++i) {
| 352257-386636 | ||||||||||||||||||||||||||||||
| 1619 | QXmlStreamAttribute &attribute = attributes[i]; | - | ||||||||||||||||||||||||||||||
| 1620 | Attribute &attrib = attributeStack[i]; | - | ||||||||||||||||||||||||||||||
| 1621 | QStringRef prefix(symPrefix(attrib.key)); | - | ||||||||||||||||||||||||||||||
| 1622 | QStringRef name(symString(attrib.key)); | - | ||||||||||||||||||||||||||||||
| 1623 | QStringRef qualifiedName(symName(attrib.key)); | - | ||||||||||||||||||||||||||||||
| 1624 | QStringRef value(symString(attrib.value)); | - | ||||||||||||||||||||||||||||||
| 1625 | - | |||||||||||||||||||||||||||||||
| 1626 | attribute.m_name = QXmlStreamStringRef(name); | - | ||||||||||||||||||||||||||||||
| 1627 | attribute.m_qualifiedName = QXmlStreamStringRef(qualifiedName); | - | ||||||||||||||||||||||||||||||
| 1628 | attribute.m_value = QXmlStreamStringRef(value); | - | ||||||||||||||||||||||||||||||
| 1629 | - | |||||||||||||||||||||||||||||||
| 1630 | if (!prefix.isEmpty()) {
| 143290-243346 | ||||||||||||||||||||||||||||||
| 1631 | QStringRef attributeNamespaceUri = namespaceForPrefix(prefix); | - | ||||||||||||||||||||||||||||||
| 1632 | attribute.m_namespaceUri = QXmlStreamStringRef(attributeNamespaceUri); | - | ||||||||||||||||||||||||||||||
| 1633 | } executed 243346 times by 23 tests: end of blockExecuted by:
| 243346 | ||||||||||||||||||||||||||||||
| 1634 | - | |||||||||||||||||||||||||||||||
| 1635 | for (int j = 0; j < i; ++j) {
| 114648-386636 | ||||||||||||||||||||||||||||||
| 1636 | if (attributes[j].name() == attribute.name()
| 38-114610 | ||||||||||||||||||||||||||||||
| 1637 | && attributes[j].namespaceUri() == attribute.namespaceUri()
| 16-22 | ||||||||||||||||||||||||||||||
| 1638 | && (namespaceProcessing || attributes[j].qualifiedName() == attribute.qualifiedName()))
| 0-16 | ||||||||||||||||||||||||||||||
| 1639 | raiseWellFormedError(QXmlStream::tr("Attribute '%1' redefined.").arg(attribute.qualifiedName().toString())); executed 16 times by 1 test: raiseWellFormedError(QXmlStream::tr("Attribute '%1' redefined.").arg(attribute.qualifiedName().toString()));Executed by:
| 16 | ||||||||||||||||||||||||||||||
| 1640 | } executed 114648 times by 16 tests: end of blockExecuted by:
| 114648 | ||||||||||||||||||||||||||||||
| 1641 | } executed 386636 times by 36 tests: end of blockExecuted by:
| 386636 | ||||||||||||||||||||||||||||||
| 1642 | - | |||||||||||||||||||||||||||||||
| 1643 | for (int a = 0; a < dtdAttributes.size(); ++a) {
| 352257-3832797 | ||||||||||||||||||||||||||||||
| 1644 | DtdAttribute &dtdAttribute = dtdAttributes[a]; | - | ||||||||||||||||||||||||||||||
| 1645 | if (dtdAttribute.isNamespaceAttribute
| 153669-3679128 | ||||||||||||||||||||||||||||||
| 1646 | || dtdAttribute.defaultValue.isNull()
| 168-3678960 | ||||||||||||||||||||||||||||||
| 1647 | || dtdAttribute.tagName != qualifiedName
| 75-93 | ||||||||||||||||||||||||||||||
| 1648 | || dtdAttribute.attributeQualifiedName.isNull())
| 2-91 | ||||||||||||||||||||||||||||||
| 1649 | continue; executed 3832706 times by 2 tests: continue;Executed by:
| 3832706 | ||||||||||||||||||||||||||||||
| 1650 | int i = 0; | - | ||||||||||||||||||||||||||||||
| 1651 | while (i < n && symName(attributeStack[i].key) != dtdAttribute.attributeQualifiedName)
| 36-117 | ||||||||||||||||||||||||||||||
| 1652 | ++i; executed 62 times by 1 test: ++i;Executed by:
| 62 | ||||||||||||||||||||||||||||||
| 1653 | if (i != n)
| 36-55 | ||||||||||||||||||||||||||||||
| 1654 | continue; executed 55 times by 1 test: continue;Executed by:
| 55 | ||||||||||||||||||||||||||||||
| 1655 | - | |||||||||||||||||||||||||||||||
| 1656 | - | |||||||||||||||||||||||||||||||
| 1657 | - | |||||||||||||||||||||||||||||||
| 1658 | QXmlStreamAttribute attribute; | - | ||||||||||||||||||||||||||||||
| 1659 | attribute.m_name = QXmlStreamStringRef(dtdAttribute.attributeName); | - | ||||||||||||||||||||||||||||||
| 1660 | attribute.m_qualifiedName = QXmlStreamStringRef(dtdAttribute.attributeQualifiedName); | - | ||||||||||||||||||||||||||||||
| 1661 | attribute.m_value = QXmlStreamStringRef(dtdAttribute.defaultValue); | - | ||||||||||||||||||||||||||||||
| 1662 | - | |||||||||||||||||||||||||||||||
| 1663 | if (!dtdAttribute.attributePrefix.isEmpty()) {
| 0-36 | ||||||||||||||||||||||||||||||
| 1664 | QStringRef attributeNamespaceUri = namespaceForPrefix(dtdAttribute.attributePrefix); | - | ||||||||||||||||||||||||||||||
| 1665 | attribute.m_namespaceUri = QXmlStreamStringRef(attributeNamespaceUri); | - | ||||||||||||||||||||||||||||||
| 1666 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1667 | attribute.m_isDefault = true; | - | ||||||||||||||||||||||||||||||
| 1668 | attributes.append(attribute); | - | ||||||||||||||||||||||||||||||
| 1669 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||||||||||||||
| 1670 | - | |||||||||||||||||||||||||||||||
| 1671 | attributeStack.clear(); | - | ||||||||||||||||||||||||||||||
| 1672 | } executed 352257 times by 36 tests: end of blockExecuted by:
| 352257 | ||||||||||||||||||||||||||||||
| 1673 | - | |||||||||||||||||||||||||||||||
| 1674 | void QXmlStreamReaderPrivate::resolvePublicNamespaces() | - | ||||||||||||||||||||||||||||||
| 1675 | { | - | ||||||||||||||||||||||||||||||
| 1676 | const Tag &tag = tagStack.top(); | - | ||||||||||||||||||||||||||||||
| 1677 | int n = namespaceDeclarations.size() - tag.namespaceDeclarationsSize; | - | ||||||||||||||||||||||||||||||
| 1678 | publicNamespaceDeclarations.resize(n); | - | ||||||||||||||||||||||||||||||
| 1679 | for (int i = 0; i < n; ++i) {
| 54-446 | ||||||||||||||||||||||||||||||
| 1680 | const NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(tag.namespaceDeclarationsSize + i); | - | ||||||||||||||||||||||||||||||
| 1681 | QXmlStreamNamespaceDeclaration &publicNamespaceDeclaration = publicNamespaceDeclarations[i]; | - | ||||||||||||||||||||||||||||||
| 1682 | publicNamespaceDeclaration.m_prefix = QXmlStreamStringRef(namespaceDeclaration.prefix); | - | ||||||||||||||||||||||||||||||
| 1683 | publicNamespaceDeclaration.m_namespaceUri = QXmlStreamStringRef(namespaceDeclaration.namespaceUri); | - | ||||||||||||||||||||||||||||||
| 1684 | } executed 54 times by 1 test: end of blockExecuted by:
| 54 | ||||||||||||||||||||||||||||||
| 1685 | } executed 446 times by 1 test: end of blockExecuted by:
| 446 | ||||||||||||||||||||||||||||||
| 1686 | - | |||||||||||||||||||||||||||||||
| 1687 | void QXmlStreamReaderPrivate::resolveDtd() | - | ||||||||||||||||||||||||||||||
| 1688 | { | - | ||||||||||||||||||||||||||||||
| 1689 | publicNotationDeclarations.resize(notationDeclarations.size()); | - | ||||||||||||||||||||||||||||||
| 1690 | for (int i = 0; i < notationDeclarations.size(); ++i) {
| 52-79 | ||||||||||||||||||||||||||||||
| 1691 | const QXmlStreamReaderPrivate::NotationDeclaration ¬ationDeclaration = notationDeclarations.at(i); | - | ||||||||||||||||||||||||||||||
| 1692 | QXmlStreamNotationDeclaration &publicNotationDeclaration = publicNotationDeclarations[i]; | - | ||||||||||||||||||||||||||||||
| 1693 | publicNotationDeclaration.m_name = QXmlStreamStringRef(notationDeclaration.name); | - | ||||||||||||||||||||||||||||||
| 1694 | publicNotationDeclaration.m_systemId = QXmlStreamStringRef(notationDeclaration.systemId); | - | ||||||||||||||||||||||||||||||
| 1695 | publicNotationDeclaration.m_publicId = QXmlStreamStringRef(notationDeclaration.publicId); | - | ||||||||||||||||||||||||||||||
| 1696 | - | |||||||||||||||||||||||||||||||
| 1697 | } executed 79 times by 1 test: end of blockExecuted by:
| 79 | ||||||||||||||||||||||||||||||
| 1698 | notationDeclarations.clear(); | - | ||||||||||||||||||||||||||||||
| 1699 | publicEntityDeclarations.resize(entityDeclarations.size()); | - | ||||||||||||||||||||||||||||||
| 1700 | for (int i = 0; i < entityDeclarations.size(); ++i) {
| 44-52 | ||||||||||||||||||||||||||||||
| 1701 | const QXmlStreamReaderPrivate::EntityDeclaration &entityDeclaration = entityDeclarations.at(i); | - | ||||||||||||||||||||||||||||||
| 1702 | QXmlStreamEntityDeclaration &publicEntityDeclaration = publicEntityDeclarations[i]; | - | ||||||||||||||||||||||||||||||
| 1703 | publicEntityDeclaration.m_name = QXmlStreamStringRef(entityDeclaration.name); | - | ||||||||||||||||||||||||||||||
| 1704 | publicEntityDeclaration.m_notationName = QXmlStreamStringRef(entityDeclaration.notationName); | - | ||||||||||||||||||||||||||||||
| 1705 | publicEntityDeclaration.m_systemId = QXmlStreamStringRef(entityDeclaration.systemId); | - | ||||||||||||||||||||||||||||||
| 1706 | publicEntityDeclaration.m_publicId = QXmlStreamStringRef(entityDeclaration.publicId); | - | ||||||||||||||||||||||||||||||
| 1707 | publicEntityDeclaration.m_value = QXmlStreamStringRef(entityDeclaration.value); | - | ||||||||||||||||||||||||||||||
| 1708 | } executed 44 times by 1 test: end of blockExecuted by:
| 44 | ||||||||||||||||||||||||||||||
| 1709 | entityDeclarations.clear(); | - | ||||||||||||||||||||||||||||||
| 1710 | parameterEntityHash.clear(); | - | ||||||||||||||||||||||||||||||
| 1711 | } executed 52 times by 1 test: end of blockExecuted by:
| 52 | ||||||||||||||||||||||||||||||
| 1712 | - | |||||||||||||||||||||||||||||||
| 1713 | uint QXmlStreamReaderPrivate::resolveCharRef(int symbolIndex) | - | ||||||||||||||||||||||||||||||
| 1714 | { | - | ||||||||||||||||||||||||||||||
| 1715 | bool ok = true; | - | ||||||||||||||||||||||||||||||
| 1716 | uint s; | - | ||||||||||||||||||||||||||||||
| 1717 | // ### add toXShort to QStringRef? | - | ||||||||||||||||||||||||||||||
| 1718 | if (sym(symbolIndex).c == 'x')
| 143-1291 | ||||||||||||||||||||||||||||||
| 1719 | s = symString(symbolIndex, 1).toUInt(&ok, 16); executed 1291 times by 2 tests: s = symString(symbolIndex, 1).toUInt(&ok, 16);Executed by:
| 1291 | ||||||||||||||||||||||||||||||
| 1720 | else | - | ||||||||||||||||||||||||||||||
| 1721 | s = symString(symbolIndex).toUInt(&ok, 10); executed 143 times by 1 test: s = symString(symbolIndex).toUInt(&ok, 10);Executed by:
| 143 | ||||||||||||||||||||||||||||||
| 1722 | - | |||||||||||||||||||||||||||||||
| 1723 | ok &= (s == 0x9 || s == 0xa || s == 0xd || (s >= 0x20 && s <= 0xd7ff)
| 13-1420 | ||||||||||||||||||||||||||||||
| 1724 | || (s >= 0xe000 && s <= 0xfffd) || (s >= 0x10000 && s <= QChar::LastValidCodePoint));
| 1-25 | ||||||||||||||||||||||||||||||
| 1725 | - | |||||||||||||||||||||||||||||||
| 1726 | return ok ? s : 0; executed 1434 times by 2 tests: return ok ? s : 0;Executed by:
| 1434 | ||||||||||||||||||||||||||||||
| 1727 | } | - | ||||||||||||||||||||||||||||||
| 1728 | - | |||||||||||||||||||||||||||||||
| 1729 | - | |||||||||||||||||||||||||||||||
| 1730 | void QXmlStreamReaderPrivate::checkPublicLiteral(const QStringRef &publicId) | - | ||||||||||||||||||||||||||||||
| 1731 | { | - | ||||||||||||||||||||||||||||||
| 1732 | //#x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] | - | ||||||||||||||||||||||||||||||
| 1733 | - | |||||||||||||||||||||||||||||||
| 1734 | const ushort *data = reinterpret_cast<const ushort *>(publicId.constData()); | - | ||||||||||||||||||||||||||||||
| 1735 | uchar c = 0; | - | ||||||||||||||||||||||||||||||
| 1736 | int i; | - | ||||||||||||||||||||||||||||||
| 1737 | for (i = publicId.size() - 1; i >= 0; --i) {
| 295-13888 | ||||||||||||||||||||||||||||||
| 1738 | if (data[i] < 256)
| 0-13888 | ||||||||||||||||||||||||||||||
| 1739 | switch ((c = data[i])) { | - | ||||||||||||||||||||||||||||||
| 1740 | case ' ': case '\n': case '\r': case '-': case '(': case ')': executed 987 times by 12 tests: case ' ':Executed by:
never executed: case '\n':executed 1 time by 1 test: case '\r':Executed by:
executed 501 times by 12 tests: case '-':Executed by:
executed 3 times by 1 test: case '(':Executed by:
executed 3 times by 1 test: case ')':Executed by:
| 0-987 | ||||||||||||||||||||||||||||||
| 1741 | case '+': case ',': case '.': case '/': case ':': case '=': executed 3 times by 1 test: case '+':Executed by:
executed 3 times by 1 test: case ',':Executed by:
executed 246 times by 12 tests: case '.':Executed by:
executed 1546 times by 12 tests: case '/':Executed by:
executed 3 times by 1 test: case ':':Executed by:
executed 3 times by 1 test: case '=':Executed by:
| 3-1546 | ||||||||||||||||||||||||||||||
| 1742 | case '?': case ';': case '!': case '*': case '#': case '@': executed 3 times by 1 test: case '?':Executed by:
executed 5 times by 1 test: case ';':Executed by:
executed 5 times by 1 test: case '!':Executed by:
executed 5 times by 1 test: case '*':Executed by:
executed 5 times by 1 test: case '#':Executed by:
executed 5 times by 1 test: case '@':Executed by:
| 3-5 | ||||||||||||||||||||||||||||||
| 1743 | case '$': case '_': case '%': case '\'': case '\"': executed 5 times by 1 test: case '$':Executed by:
executed 5 times by 1 test: case '_':Executed by:
executed 5 times by 1 test: case '%':Executed by:
executed 3 times by 1 test: case '\'':Executed by:
never executed: case '\"': | 0-5 | ||||||||||||||||||||||||||||||
| 1744 | continue; executed 3345 times by 12 tests: continue;Executed by:
| 3345 | ||||||||||||||||||||||||||||||
| 1745 | default: executed 10543 times by 12 tests: default:Executed by:
| 10543 | ||||||||||||||||||||||||||||||
| 1746 | if ((c >= 'a' && c <= 'z')
| 0-7242 | ||||||||||||||||||||||||||||||
| 1747 | || (c >= 'A' && c <= 'Z')
| 0-2782 | ||||||||||||||||||||||||||||||
| 1748 | || (c >= '0' && c <= '9'))
| 0-519 | ||||||||||||||||||||||||||||||
| 1749 | continue; executed 10543 times by 12 tests: continue;Executed by:
| 10543 | ||||||||||||||||||||||||||||||
| 1750 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1751 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1752 | } | - | ||||||||||||||||||||||||||||||
| 1753 | if (i >= 0)
| 0-295 | ||||||||||||||||||||||||||||||
| 1754 | raiseWellFormedError(QXmlStream::tr("Unexpected character '%1' in public id literal.").arg(QChar(QLatin1Char(c)))); never executed: raiseWellFormedError(QXmlStream::tr("Unexpected character '%1' in public id literal.").arg(QChar(QLatin1Char(c)))); | 0 | ||||||||||||||||||||||||||||||
| 1755 | } executed 295 times by 12 tests: end of blockExecuted by:
| 295 | ||||||||||||||||||||||||||||||
| 1756 | - | |||||||||||||||||||||||||||||||
| 1757 | /* | - | ||||||||||||||||||||||||||||||
| 1758 | Checks whether the document starts with an xml declaration. If it | - | ||||||||||||||||||||||||||||||
| 1759 | does, this function returns \c true; otherwise it sets up everything | - | ||||||||||||||||||||||||||||||
| 1760 | for a synthetic start document event and returns \c false. | - | ||||||||||||||||||||||||||||||
| 1761 | */ | - | ||||||||||||||||||||||||||||||
| 1762 | bool QXmlStreamReaderPrivate::checkStartDocument() | - | ||||||||||||||||||||||||||||||
| 1763 | { | - | ||||||||||||||||||||||||||||||
| 1764 | hasCheckedStartDocument = true; | - | ||||||||||||||||||||||||||||||
| 1765 | - | |||||||||||||||||||||||||||||||
| 1766 | if (scanString(spell[XML], XML))
| 3714-4669 | ||||||||||||||||||||||||||||||
| 1767 | return true; executed 3714 times by 26 tests: return true;Executed by:
| 3714 | ||||||||||||||||||||||||||||||
| 1768 | - | |||||||||||||||||||||||||||||||
| 1769 | type = QXmlStreamReader::StartDocument; | - | ||||||||||||||||||||||||||||||
| 1770 | if (atEnd) {
| 1984-2685 | ||||||||||||||||||||||||||||||
| 1771 | hasCheckedStartDocument = false; | - | ||||||||||||||||||||||||||||||
| 1772 | raiseError(QXmlStreamReader::PrematureEndOfDocumentError); | - | ||||||||||||||||||||||||||||||
| 1773 | } executed 2685 times by 2 tests: end of blockExecuted by:
| 2685 | ||||||||||||||||||||||||||||||
| 1774 | return false; executed 4669 times by 13 tests: return false;Executed by:
| 4669 | ||||||||||||||||||||||||||||||
| 1775 | } | - | ||||||||||||||||||||||||||||||
| 1776 | - | |||||||||||||||||||||||||||||||
| 1777 | void QXmlStreamReaderPrivate::startDocument() | - | ||||||||||||||||||||||||||||||
| 1778 | { | - | ||||||||||||||||||||||||||||||
| 1779 | QString err; | - | ||||||||||||||||||||||||||||||
| 1780 | if (documentVersion != QLatin1String("1.0")) {
| 4-3666 | ||||||||||||||||||||||||||||||
| 1781 | if (documentVersion.contains(QLatin1Char(' ')))
| 1-3 | ||||||||||||||||||||||||||||||
| 1782 | err = QXmlStream::tr("Invalid XML version string."); executed 1 time by 1 test: err = QXmlStream::tr("Invalid XML version string.");Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1783 | else | - | ||||||||||||||||||||||||||||||
| 1784 | err = QXmlStream::tr("Unsupported XML version."); executed 3 times by 1 test: err = QXmlStream::tr("Unsupported XML version.");Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 1785 | } | - | ||||||||||||||||||||||||||||||
| 1786 | int n = attributeStack.size(); | - | ||||||||||||||||||||||||||||||
| 1787 | - | |||||||||||||||||||||||||||||||
| 1788 | /* We use this bool to ensure that the pesudo attributes are in the | - | ||||||||||||||||||||||||||||||
| 1789 | * proper order: | - | ||||||||||||||||||||||||||||||
| 1790 | * | - | ||||||||||||||||||||||||||||||
| 1791 | * [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>' */ | - | ||||||||||||||||||||||||||||||
| 1792 | bool hasStandalone = false; | - | ||||||||||||||||||||||||||||||
| 1793 | - | |||||||||||||||||||||||||||||||
| 1794 | for (int i = 0; err.isNull() && i < n; ++i) {
| 31-6760 | ||||||||||||||||||||||||||||||
| 1795 | Attribute &attrib = attributeStack[i]; | - | ||||||||||||||||||||||||||||||
| 1796 | QStringRef prefix(symPrefix(attrib.key)); | - | ||||||||||||||||||||||||||||||
| 1797 | QStringRef key(symString(attrib.key)); | - | ||||||||||||||||||||||||||||||
| 1798 | QStringRef value(symString(attrib.value)); | - | ||||||||||||||||||||||||||||||
| 1799 | - | |||||||||||||||||||||||||||||||
| 1800 | if (prefix.isEmpty() && key == QLatin1String("encoding")) {
| 0-3121 | ||||||||||||||||||||||||||||||
| 1801 | const QString name(value.toString()); | - | ||||||||||||||||||||||||||||||
| 1802 | documentEncoding = value; | - | ||||||||||||||||||||||||||||||
| 1803 | - | |||||||||||||||||||||||||||||||
| 1804 | if(hasStandalone)
| 1-3087 | ||||||||||||||||||||||||||||||
| 1805 | err = QXmlStream::tr("The standalone pseudo attribute must appear after the encoding."); executed 1 time by 1 test: err = QXmlStream::tr("The standalone pseudo attribute must appear after the encoding.");Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1806 | if(!QXmlUtils::isEncName(name))
| 16-3072 | ||||||||||||||||||||||||||||||
| 1807 | err = QXmlStream::tr("%1 is an invalid encoding name.").arg(name); executed 16 times by 1 test: err = QXmlStream::tr("%1 is an invalid encoding name.").arg(name);Executed by:
| 16 | ||||||||||||||||||||||||||||||
| 1808 | else { | - | ||||||||||||||||||||||||||||||
| 1809 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 1810 | readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread); | - | ||||||||||||||||||||||||||||||
| 1811 | #else | - | ||||||||||||||||||||||||||||||
| 1812 | QTextCodec *const newCodec = QTextCodec::codecForName(name.toLatin1()); | - | ||||||||||||||||||||||||||||||
| 1813 | if (!newCodec)
| 0-3072 | ||||||||||||||||||||||||||||||
| 1814 | err = QXmlStream::tr("Encoding %1 is unsupported").arg(name); never executed: err = QXmlStream::tr("Encoding %1 is unsupported").arg(name); | 0 | ||||||||||||||||||||||||||||||
| 1815 | else if (newCodec != codec && !lockEncoding) {
| 0-3068 | ||||||||||||||||||||||||||||||
| 1816 | codec = newCodec; | - | ||||||||||||||||||||||||||||||
| 1817 | delete decoder; | - | ||||||||||||||||||||||||||||||
| 1818 | decoder = codec->makeDecoder(); | - | ||||||||||||||||||||||||||||||
| 1819 | decoder->toUnicode(&readBuffer, rawReadBuffer.data(), nbytesread); | - | ||||||||||||||||||||||||||||||
| 1820 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 1821 | #endif // QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 1822 | } executed 3072 times by 25 tests: end of blockExecuted by:
| 3072 | ||||||||||||||||||||||||||||||
| 1823 | } else if (prefix.isEmpty() && key == QLatin1String("standalone")) {
| 0-33 | ||||||||||||||||||||||||||||||
| 1824 | hasStandalone = true; | - | ||||||||||||||||||||||||||||||
| 1825 | if (value == QLatin1String("yes"))
| 8-21 | ||||||||||||||||||||||||||||||
| 1826 | standalone = true; executed 21 times by 1 test: standalone = true;Executed by:
| 21 | ||||||||||||||||||||||||||||||
| 1827 | else if (value == QLatin1String("no"))
| 2-6 | ||||||||||||||||||||||||||||||
| 1828 | standalone = false; executed 2 times by 1 test: standalone = false;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1829 | else | - | ||||||||||||||||||||||||||||||
| 1830 | err = QXmlStream::tr("Standalone accepts only yes or no."); executed 6 times by 1 test: err = QXmlStream::tr("Standalone accepts only yes or no.");Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 1831 | } else { | - | ||||||||||||||||||||||||||||||
| 1832 | err = QXmlStream::tr("Invalid attribute in XML declaration."); | - | ||||||||||||||||||||||||||||||
| 1833 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 1834 | } | - | ||||||||||||||||||||||||||||||
| 1835 | - | |||||||||||||||||||||||||||||||
| 1836 | if (!err.isNull())
| 31-3639 | ||||||||||||||||||||||||||||||
| 1837 | raiseWellFormedError(err); executed 31 times by 1 test: raiseWellFormedError(err);Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 1838 | attributeStack.clear(); | - | ||||||||||||||||||||||||||||||
| 1839 | } executed 3670 times by 26 tests: end of blockExecuted by:
| 3670 | ||||||||||||||||||||||||||||||
| 1840 | - | |||||||||||||||||||||||||||||||
| 1841 | - | |||||||||||||||||||||||||||||||
| 1842 | void QXmlStreamReaderPrivate::raiseError(QXmlStreamReader::Error error, const QString& message) | - | ||||||||||||||||||||||||||||||
| 1843 | { | - | ||||||||||||||||||||||||||||||
| 1844 | this->error = error; | - | ||||||||||||||||||||||||||||||
| 1845 | errorString = message; | - | ||||||||||||||||||||||||||||||
| 1846 | if (errorString.isNull()) {
| 1235-58733 | ||||||||||||||||||||||||||||||
| 1847 | if (error == QXmlStreamReader::PrematureEndOfDocumentError)
| 0-58733 | ||||||||||||||||||||||||||||||
| 1848 | errorString = QXmlStream::tr("Premature end of document."); executed 58733 times by 2 tests: errorString = QXmlStream::tr("Premature end of document.");Executed by:
| 58733 | ||||||||||||||||||||||||||||||
| 1849 | else if (error == QXmlStreamReader::CustomError)
| 0 | ||||||||||||||||||||||||||||||
| 1850 | errorString = QXmlStream::tr("Invalid document."); never executed: errorString = QXmlStream::tr("Invalid document."); | 0 | ||||||||||||||||||||||||||||||
| 1851 | } executed 58733 times by 2 tests: end of blockExecuted by:
| 58733 | ||||||||||||||||||||||||||||||
| 1852 | - | |||||||||||||||||||||||||||||||
| 1853 | type = QXmlStreamReader::Invalid; | - | ||||||||||||||||||||||||||||||
| 1854 | } executed 59968 times by 3 tests: end of blockExecuted by:
| 59968 | ||||||||||||||||||||||||||||||
| 1855 | - | |||||||||||||||||||||||||||||||
| 1856 | void QXmlStreamReaderPrivate::raiseWellFormedError(const QString &message) | - | ||||||||||||||||||||||||||||||
| 1857 | { | - | ||||||||||||||||||||||||||||||
| 1858 | raiseError(QXmlStreamReader::NotWellFormedError, message); | - | ||||||||||||||||||||||||||||||
| 1859 | } executed 1196 times by 2 tests: end of blockExecuted by:
| 1196 | ||||||||||||||||||||||||||||||
| 1860 | - | |||||||||||||||||||||||||||||||
| 1861 | void QXmlStreamReaderPrivate::parseError() | - | ||||||||||||||||||||||||||||||
| 1862 | { | - | ||||||||||||||||||||||||||||||
| 1863 | - | |||||||||||||||||||||||||||||||
| 1864 | if (token == EOF_SYMBOL) {
| 613-6305 | ||||||||||||||||||||||||||||||
| 1865 | raiseError(QXmlStreamReader::PrematureEndOfDocumentError); | - | ||||||||||||||||||||||||||||||
| 1866 | return; executed 6305 times by 1 test: return;Executed by:
| 6305 | ||||||||||||||||||||||||||||||
| 1867 | } | - | ||||||||||||||||||||||||||||||
| 1868 | const int nmax = 4; | - | ||||||||||||||||||||||||||||||
| 1869 | QString error_message; | - | ||||||||||||||||||||||||||||||
| 1870 | int ers = state_stack[tos]; | - | ||||||||||||||||||||||||||||||
| 1871 | int nexpected = 0; | - | ||||||||||||||||||||||||||||||
| 1872 | int expected[nmax]; | - | ||||||||||||||||||||||||||||||
| 1873 | if (token != ERROR)
| 7-606 | ||||||||||||||||||||||||||||||
| 1874 | for (int tk = 0; tk < TERMINAL_COUNT; ++tk) {
| 606-34542 | ||||||||||||||||||||||||||||||
| 1875 | int k = t_action(ers, tk); | - | ||||||||||||||||||||||||||||||
| 1876 | if (k <= 0)
| 3323-31219 | ||||||||||||||||||||||||||||||
| 1877 | continue; executed 31219 times by 1 test: continue;Executed by:
| 31219 | ||||||||||||||||||||||||||||||
| 1878 | if (spell[tk]) {
| 96-3227 | ||||||||||||||||||||||||||||||
| 1879 | if (nexpected < nmax)
| 1391-1836 | ||||||||||||||||||||||||||||||
| 1880 | expected[nexpected++] = tk; executed 1391 times by 1 test: expected[nexpected++] = tk;Executed by:
| 1391 | ||||||||||||||||||||||||||||||
| 1881 | } executed 3227 times by 1 test: end of blockExecuted by:
| 3227 | ||||||||||||||||||||||||||||||
| 1882 | } executed 3323 times by 1 test: end of blockExecuted by:
| 3323 | ||||||||||||||||||||||||||||||
| 1883 | - | |||||||||||||||||||||||||||||||
| 1884 | error_message.clear (); | - | ||||||||||||||||||||||||||||||
| 1885 | if (nexpected && nexpected < nmax) {
| 7-606 | ||||||||||||||||||||||||||||||
| 1886 | bool first = true; | - | ||||||||||||||||||||||||||||||
| 1887 | - | |||||||||||||||||||||||||||||||
| 1888 | for (int s = 0; s < nexpected; ++s) {
| 448-759 | ||||||||||||||||||||||||||||||
| 1889 | if (first)
| 311-448 | ||||||||||||||||||||||||||||||
| 1890 | error_message += QXmlStream::tr ("Expected "); executed 448 times by 1 test: error_message += QXmlStream::tr ("Expected ");Executed by:
| 448 | ||||||||||||||||||||||||||||||
| 1891 | else if (s == nexpected - 1)
| 89-222 | ||||||||||||||||||||||||||||||
| 1892 | error_message += QLatin1String (nexpected > 2 ? ", or " : " or "); executed 222 times by 1 test: error_message += QLatin1String (nexpected > 2 ? ", or " : " or ");Executed by:
| 222 | ||||||||||||||||||||||||||||||
| 1893 | else | - | ||||||||||||||||||||||||||||||
| 1894 | error_message += QLatin1String (", "); executed 89 times by 1 test: error_message += QLatin1String (", ");Executed by:
| 89 | ||||||||||||||||||||||||||||||
| 1895 | - | |||||||||||||||||||||||||||||||
| 1896 | first = false; | - | ||||||||||||||||||||||||||||||
| 1897 | error_message += QLatin1String("\'"); | - | ||||||||||||||||||||||||||||||
| 1898 | error_message += QLatin1String (spell [expected[s]]); | - | ||||||||||||||||||||||||||||||
| 1899 | error_message += QLatin1String("\'"); | - | ||||||||||||||||||||||||||||||
| 1900 | } executed 759 times by 1 test: end of blockExecuted by:
| 759 | ||||||||||||||||||||||||||||||
| 1901 | error_message += QXmlStream::tr(", but got \'"); | - | ||||||||||||||||||||||||||||||
| 1902 | error_message += QLatin1String(spell [token]); | - | ||||||||||||||||||||||||||||||
| 1903 | error_message += QLatin1String("\'"); | - | ||||||||||||||||||||||||||||||
| 1904 | } else { executed 448 times by 1 test: end of blockExecuted by:
| 448 | ||||||||||||||||||||||||||||||
| 1905 | error_message += QXmlStream::tr("Unexpected \'"); | - | ||||||||||||||||||||||||||||||
| 1906 | error_message += QLatin1String(spell [token]); | - | ||||||||||||||||||||||||||||||
| 1907 | error_message += QLatin1String("\'"); | - | ||||||||||||||||||||||||||||||
| 1908 | } executed 165 times by 1 test: end of blockExecuted by:
| 165 | ||||||||||||||||||||||||||||||
| 1909 | error_message += QLatin1Char('.'); | - | ||||||||||||||||||||||||||||||
| 1910 | - | |||||||||||||||||||||||||||||||
| 1911 | raiseWellFormedError(error_message); | - | ||||||||||||||||||||||||||||||
| 1912 | } executed 613 times by 1 test: end of blockExecuted by:
| 613 | ||||||||||||||||||||||||||||||
| 1913 | - | |||||||||||||||||||||||||||||||
| 1914 | void QXmlStreamReaderPrivate::resume(int rule) { | - | ||||||||||||||||||||||||||||||
| 1915 | resumeReduction = rule; | - | ||||||||||||||||||||||||||||||
| 1916 | if (error == QXmlStreamReader::NoError)
| 26-44571 | ||||||||||||||||||||||||||||||
| 1917 | raiseError(QXmlStreamReader::PrematureEndOfDocumentError); executed 26 times by 1 test: raiseError(QXmlStreamReader::PrematureEndOfDocumentError);Executed by:
| 26 | ||||||||||||||||||||||||||||||
| 1918 | } executed 44597 times by 1 test: end of blockExecuted by:
| 44597 | ||||||||||||||||||||||||||||||
| 1919 | - | |||||||||||||||||||||||||||||||
| 1920 | /*! Returns the current line number, starting with 1. | - | ||||||||||||||||||||||||||||||
| 1921 | - | |||||||||||||||||||||||||||||||
| 1922 | \sa columnNumber(), characterOffset() | - | ||||||||||||||||||||||||||||||
| 1923 | */ | - | ||||||||||||||||||||||||||||||
| 1924 | qint64 QXmlStreamReader::lineNumber() const | - | ||||||||||||||||||||||||||||||
| 1925 | { | - | ||||||||||||||||||||||||||||||
| 1926 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1927 | return d->lineNumber + 1; // in public we start with 1 executed 584 times by 1 test: return d->lineNumber + 1;Executed by:
| 584 | ||||||||||||||||||||||||||||||
| 1928 | } | - | ||||||||||||||||||||||||||||||
| 1929 | - | |||||||||||||||||||||||||||||||
| 1930 | /*! Returns the current column number, starting with 0. | - | ||||||||||||||||||||||||||||||
| 1931 | - | |||||||||||||||||||||||||||||||
| 1932 | \sa lineNumber(), characterOffset() | - | ||||||||||||||||||||||||||||||
| 1933 | */ | - | ||||||||||||||||||||||||||||||
| 1934 | qint64 QXmlStreamReader::columnNumber() const | - | ||||||||||||||||||||||||||||||
| 1935 | { | - | ||||||||||||||||||||||||||||||
| 1936 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1937 | return d->characterOffset - d->lastLineStart + d->readBufferPos; executed 584 times by 1 test: return d->characterOffset - d->lastLineStart + d->readBufferPos;Executed by:
| 584 | ||||||||||||||||||||||||||||||
| 1938 | } | - | ||||||||||||||||||||||||||||||
| 1939 | - | |||||||||||||||||||||||||||||||
| 1940 | /*! Returns the current character offset, starting with 0. | - | ||||||||||||||||||||||||||||||
| 1941 | - | |||||||||||||||||||||||||||||||
| 1942 | \sa lineNumber(), columnNumber() | - | ||||||||||||||||||||||||||||||
| 1943 | */ | - | ||||||||||||||||||||||||||||||
| 1944 | qint64 QXmlStreamReader::characterOffset() const | - | ||||||||||||||||||||||||||||||
| 1945 | { | - | ||||||||||||||||||||||||||||||
| 1946 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1947 | return d->characterOffset + d->readBufferPos; never executed: return d->characterOffset + d->readBufferPos; | 0 | ||||||||||||||||||||||||||||||
| 1948 | } | - | ||||||||||||||||||||||||||||||
| 1949 | - | |||||||||||||||||||||||||||||||
| 1950 | - | |||||||||||||||||||||||||||||||
| 1951 | /*! Returns the text of \l Characters, \l Comment, \l DTD, or | - | ||||||||||||||||||||||||||||||
| 1952 | EntityReference. | - | ||||||||||||||||||||||||||||||
| 1953 | */ | - | ||||||||||||||||||||||||||||||
| 1954 | QStringRef QXmlStreamReader::text() const | - | ||||||||||||||||||||||||||||||
| 1955 | { | - | ||||||||||||||||||||||||||||||
| 1956 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1957 | return d->text; executed 3556 times by 1 test: return d->text;Executed by:
| 3556 | ||||||||||||||||||||||||||||||
| 1958 | } | - | ||||||||||||||||||||||||||||||
| 1959 | - | |||||||||||||||||||||||||||||||
| 1960 | - | |||||||||||||||||||||||||||||||
| 1961 | /*! If the tokenType() is \l DTD, this function returns the DTD's | - | ||||||||||||||||||||||||||||||
| 1962 | notation declarations. Otherwise an empty vector is returned. | - | ||||||||||||||||||||||||||||||
| 1963 | - | |||||||||||||||||||||||||||||||
| 1964 | The QXmlStreamNotationDeclarations class is defined to be a QVector | - | ||||||||||||||||||||||||||||||
| 1965 | of QXmlStreamNotationDeclaration. | - | ||||||||||||||||||||||||||||||
| 1966 | */ | - | ||||||||||||||||||||||||||||||
| 1967 | QXmlStreamNotationDeclarations QXmlStreamReader::notationDeclarations() const | - | ||||||||||||||||||||||||||||||
| 1968 | { | - | ||||||||||||||||||||||||||||||
| 1969 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1970 | if (d->notationDeclarations.size())
| 47-2545 | ||||||||||||||||||||||||||||||
| 1971 | const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd(); executed 47 times by 1 test: const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd();Executed by:
| 47 | ||||||||||||||||||||||||||||||
| 1972 | return d->publicNotationDeclarations; executed 2592 times by 1 test: return d->publicNotationDeclarations;Executed by:
| 2592 | ||||||||||||||||||||||||||||||
| 1973 | } | - | ||||||||||||||||||||||||||||||
| 1974 | - | |||||||||||||||||||||||||||||||
| 1975 | - | |||||||||||||||||||||||||||||||
| 1976 | /*! If the tokenType() is \l DTD, this function returns the DTD's | - | ||||||||||||||||||||||||||||||
| 1977 | unparsed (external) entity declarations. Otherwise an empty vector is returned. | - | ||||||||||||||||||||||||||||||
| 1978 | - | |||||||||||||||||||||||||||||||
| 1979 | The QXmlStreamEntityDeclarations class is defined to be a QVector | - | ||||||||||||||||||||||||||||||
| 1980 | of QXmlStreamEntityDeclaration. | - | ||||||||||||||||||||||||||||||
| 1981 | */ | - | ||||||||||||||||||||||||||||||
| 1982 | QXmlStreamEntityDeclarations QXmlStreamReader::entityDeclarations() const | - | ||||||||||||||||||||||||||||||
| 1983 | { | - | ||||||||||||||||||||||||||||||
| 1984 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1985 | if (d->entityDeclarations.size())
| 5-1903 | ||||||||||||||||||||||||||||||
| 1986 | const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd(); executed 5 times by 1 test: const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd();Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 1987 | return d->publicEntityDeclarations; executed 1908 times by 1 test: return d->publicEntityDeclarations;Executed by:
| 1908 | ||||||||||||||||||||||||||||||
| 1988 | } | - | ||||||||||||||||||||||||||||||
| 1989 | - | |||||||||||||||||||||||||||||||
| 1990 | /*! | - | ||||||||||||||||||||||||||||||
| 1991 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 1992 | - | |||||||||||||||||||||||||||||||
| 1993 | If the tokenType() is \l DTD, this function returns the DTD's | - | ||||||||||||||||||||||||||||||
| 1994 | name. Otherwise an empty string is returned. | - | ||||||||||||||||||||||||||||||
| 1995 | - | |||||||||||||||||||||||||||||||
| 1996 | */ | - | ||||||||||||||||||||||||||||||
| 1997 | QStringRef QXmlStreamReader::dtdName() const | - | ||||||||||||||||||||||||||||||
| 1998 | { | - | ||||||||||||||||||||||||||||||
| 1999 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2000 | if (d->type == QXmlStreamReader::DTD)
| 50-1878 | ||||||||||||||||||||||||||||||
| 2001 | return d->dtdName; executed 50 times by 1 test: return d->dtdName;Executed by:
| 50 | ||||||||||||||||||||||||||||||
| 2002 | return QStringRef(); executed 1878 times by 1 test: return QStringRef();Executed by:
| 1878 | ||||||||||||||||||||||||||||||
| 2003 | } | - | ||||||||||||||||||||||||||||||
| 2004 | - | |||||||||||||||||||||||||||||||
| 2005 | /*! | - | ||||||||||||||||||||||||||||||
| 2006 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2007 | - | |||||||||||||||||||||||||||||||
| 2008 | If the tokenType() is \l DTD, this function returns the DTD's | - | ||||||||||||||||||||||||||||||
| 2009 | public identifier. Otherwise an empty string is returned. | - | ||||||||||||||||||||||||||||||
| 2010 | - | |||||||||||||||||||||||||||||||
| 2011 | */ | - | ||||||||||||||||||||||||||||||
| 2012 | QStringRef QXmlStreamReader::dtdPublicId() const | - | ||||||||||||||||||||||||||||||
| 2013 | { | - | ||||||||||||||||||||||||||||||
| 2014 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2015 | if (d->type == QXmlStreamReader::DTD)
| 27-1878 | ||||||||||||||||||||||||||||||
| 2016 | return d->dtdPublicId; executed 27 times by 1 test: return d->dtdPublicId;Executed by:
| 27 | ||||||||||||||||||||||||||||||
| 2017 | return QStringRef(); executed 1878 times by 1 test: return QStringRef();Executed by:
| 1878 | ||||||||||||||||||||||||||||||
| 2018 | } | - | ||||||||||||||||||||||||||||||
| 2019 | - | |||||||||||||||||||||||||||||||
| 2020 | /*! | - | ||||||||||||||||||||||||||||||
| 2021 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2022 | - | |||||||||||||||||||||||||||||||
| 2023 | If the tokenType() is \l DTD, this function returns the DTD's | - | ||||||||||||||||||||||||||||||
| 2024 | system identifier. Otherwise an empty string is returned. | - | ||||||||||||||||||||||||||||||
| 2025 | - | |||||||||||||||||||||||||||||||
| 2026 | */ | - | ||||||||||||||||||||||||||||||
| 2027 | QStringRef QXmlStreamReader::dtdSystemId() const | - | ||||||||||||||||||||||||||||||
| 2028 | { | - | ||||||||||||||||||||||||||||||
| 2029 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2030 | if (d->type == QXmlStreamReader::DTD)
| 27-1878 | ||||||||||||||||||||||||||||||
| 2031 | return d->dtdSystemId; executed 27 times by 1 test: return d->dtdSystemId;Executed by:
| 27 | ||||||||||||||||||||||||||||||
| 2032 | return QStringRef(); executed 1878 times by 1 test: return QStringRef();Executed by:
| 1878 | ||||||||||||||||||||||||||||||
| 2033 | } | - | ||||||||||||||||||||||||||||||
| 2034 | - | |||||||||||||||||||||||||||||||
| 2035 | /*! If the tokenType() is \l StartElement, this function returns the | - | ||||||||||||||||||||||||||||||
| 2036 | element's namespace declarations. Otherwise an empty vector is | - | ||||||||||||||||||||||||||||||
| 2037 | returned. | - | ||||||||||||||||||||||||||||||
| 2038 | - | |||||||||||||||||||||||||||||||
| 2039 | The QXmlStreamNamespaceDeclarations class is defined to be a QVector | - | ||||||||||||||||||||||||||||||
| 2040 | of QXmlStreamNamespaceDeclaration. | - | ||||||||||||||||||||||||||||||
| 2041 | - | |||||||||||||||||||||||||||||||
| 2042 | \sa addExtraNamespaceDeclaration(), addExtraNamespaceDeclarations() | - | ||||||||||||||||||||||||||||||
| 2043 | */ | - | ||||||||||||||||||||||||||||||
| 2044 | QXmlStreamNamespaceDeclarations QXmlStreamReader::namespaceDeclarations() const | - | ||||||||||||||||||||||||||||||
| 2045 | { | - | ||||||||||||||||||||||||||||||
| 2046 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2047 | if (d->publicNamespaceDeclarations.isEmpty() && d->type == StartElement)
| 38-1907 | ||||||||||||||||||||||||||||||
| 2048 | const_cast<QXmlStreamReaderPrivate *>(d)->resolvePublicNamespaces(); executed 446 times by 1 test: const_cast<QXmlStreamReaderPrivate *>(d)->resolvePublicNamespaces();Executed by:
| 446 | ||||||||||||||||||||||||||||||
| 2049 | return d->publicNamespaceDeclarations; executed 1945 times by 1 test: return d->publicNamespaceDeclarations;Executed by:
| 1945 | ||||||||||||||||||||||||||||||
| 2050 | } | - | ||||||||||||||||||||||||||||||
| 2051 | - | |||||||||||||||||||||||||||||||
| 2052 | - | |||||||||||||||||||||||||||||||
| 2053 | /*! | - | ||||||||||||||||||||||||||||||
| 2054 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2055 | - | |||||||||||||||||||||||||||||||
| 2056 | Adds an \a extraNamespaceDeclaration. The declaration will be | - | ||||||||||||||||||||||||||||||
| 2057 | valid for children of the current element, or - should the function | - | ||||||||||||||||||||||||||||||
| 2058 | be called before any elements are read - for the entire XML | - | ||||||||||||||||||||||||||||||
| 2059 | document. | - | ||||||||||||||||||||||||||||||
| 2060 | - | |||||||||||||||||||||||||||||||
| 2061 | \sa namespaceDeclarations(), addExtraNamespaceDeclarations(), setNamespaceProcessing() | - | ||||||||||||||||||||||||||||||
| 2062 | */ | - | ||||||||||||||||||||||||||||||
| 2063 | void QXmlStreamReader::addExtraNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &extraNamespaceDeclaration) | - | ||||||||||||||||||||||||||||||
| 2064 | { | - | ||||||||||||||||||||||||||||||
| 2065 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2066 | QXmlStreamReaderPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 2067 | namespaceDeclaration.prefix = d->addToStringStorage(extraNamespaceDeclaration.prefix()); | - | ||||||||||||||||||||||||||||||
| 2068 | namespaceDeclaration.namespaceUri = d->addToStringStorage(extraNamespaceDeclaration.namespaceUri()); | - | ||||||||||||||||||||||||||||||
| 2069 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 2070 | - | |||||||||||||||||||||||||||||||
| 2071 | /*! | - | ||||||||||||||||||||||||||||||
| 2072 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2073 | - | |||||||||||||||||||||||||||||||
| 2074 | Adds a vector of declarations specified by \a extraNamespaceDeclarations. | - | ||||||||||||||||||||||||||||||
| 2075 | - | |||||||||||||||||||||||||||||||
| 2076 | \sa namespaceDeclarations(), addExtraNamespaceDeclaration() | - | ||||||||||||||||||||||||||||||
| 2077 | */ | - | ||||||||||||||||||||||||||||||
| 2078 | void QXmlStreamReader::addExtraNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &extraNamespaceDeclarations) | - | ||||||||||||||||||||||||||||||
| 2079 | { | - | ||||||||||||||||||||||||||||||
| 2080 | for (int i = 0; i < extraNamespaceDeclarations.size(); ++i)
| 0 | ||||||||||||||||||||||||||||||
| 2081 | addExtraNamespaceDeclaration(extraNamespaceDeclarations.at(i)); never executed: addExtraNamespaceDeclaration(extraNamespaceDeclarations.at(i)); | 0 | ||||||||||||||||||||||||||||||
| 2082 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2083 | - | |||||||||||||||||||||||||||||||
| 2084 | - | |||||||||||||||||||||||||||||||
| 2085 | /*! Convenience function to be called in case a StartElement was | - | ||||||||||||||||||||||||||||||
| 2086 | read. Reads until the corresponding EndElement and returns all text | - | ||||||||||||||||||||||||||||||
| 2087 | in-between. In case of no error, the current token (see tokenType()) | - | ||||||||||||||||||||||||||||||
| 2088 | after having called this function is EndElement. | - | ||||||||||||||||||||||||||||||
| 2089 | - | |||||||||||||||||||||||||||||||
| 2090 | The function concatenates text() when it reads either \l Characters | - | ||||||||||||||||||||||||||||||
| 2091 | or EntityReference tokens, but skips ProcessingInstruction and \l | - | ||||||||||||||||||||||||||||||
| 2092 | Comment. If the current token is not StartElement, an empty string is | - | ||||||||||||||||||||||||||||||
| 2093 | returned. | - | ||||||||||||||||||||||||||||||
| 2094 | - | |||||||||||||||||||||||||||||||
| 2095 | The \a behaviour defines what happens in case anything else is | - | ||||||||||||||||||||||||||||||
| 2096 | read before reaching EndElement. The function can include the text from | - | ||||||||||||||||||||||||||||||
| 2097 | child elements (useful for example for HTML), ignore child elements, or | - | ||||||||||||||||||||||||||||||
| 2098 | raise an UnexpectedElementError and return what was read so far (default). | - | ||||||||||||||||||||||||||||||
| 2099 | - | |||||||||||||||||||||||||||||||
| 2100 | \since 4.6 | - | ||||||||||||||||||||||||||||||
| 2101 | */ | - | ||||||||||||||||||||||||||||||
| 2102 | QString QXmlStreamReader::readElementText(ReadElementTextBehaviour behaviour) | - | ||||||||||||||||||||||||||||||
| 2103 | { | - | ||||||||||||||||||||||||||||||
| 2104 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2105 | if (isStartElement()) {
| 0-249021 | ||||||||||||||||||||||||||||||
| 2106 | QString result; | - | ||||||||||||||||||||||||||||||
| 2107 | forever { | - | ||||||||||||||||||||||||||||||
| 2108 | switch (readNext()) { | - | ||||||||||||||||||||||||||||||
| 2109 | case Characters: executed 249024 times by 23 tests: case Characters:Executed by:
| 249024 | ||||||||||||||||||||||||||||||
| 2110 | case EntityReference: never executed: case EntityReference: | 0 | ||||||||||||||||||||||||||||||
| 2111 | result.insert(result.size(), d->text.unicode(), d->text.size()); | - | ||||||||||||||||||||||||||||||
| 2112 | break; executed 249024 times by 23 tests: break;Executed by:
| 249024 | ||||||||||||||||||||||||||||||
| 2113 | case EndElement: executed 249016 times by 23 tests: case EndElement:Executed by:
| 249016 | ||||||||||||||||||||||||||||||
| 2114 | return result; executed 249016 times by 23 tests: return result;Executed by:
| 249016 | ||||||||||||||||||||||||||||||
| 2115 | case ProcessingInstruction: never executed: case ProcessingInstruction: | 0 | ||||||||||||||||||||||||||||||
| 2116 | case Comment: executed 2 times by 1 test: case Comment:Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2117 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2118 | case StartElement: executed 6 times by 1 test: case StartElement:Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 2119 | if (behaviour == SkipChildElements) {
| 2-4 | ||||||||||||||||||||||||||||||
| 2120 | skipCurrentElement(); | - | ||||||||||||||||||||||||||||||
| 2121 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2122 | } else if (behaviour == IncludeChildElements) {
| 2 | ||||||||||||||||||||||||||||||
| 2123 | result += readElementText(behaviour); | - | ||||||||||||||||||||||||||||||
| 2124 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2125 | } | - | ||||||||||||||||||||||||||||||
| 2126 | // Fall through (for ErrorOnUnexpectedElement) | - | ||||||||||||||||||||||||||||||
| 2127 | default: code before this statement executed 2 times by 1 test: default:Executed by:
executed 5 times by 1 test: default:Executed by:
| 2-5 | ||||||||||||||||||||||||||||||
| 2128 | if (d->error || behaviour == ErrorOnUnexpectedElement) {
| 0-2 | ||||||||||||||||||||||||||||||
| 2129 | if (!d->error)
| 2-3 | ||||||||||||||||||||||||||||||
| 2130 | d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data.")); executed 2 times by 1 test: d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data."));Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2131 | return result; executed 5 times by 1 test: return result;Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 2132 | } | - | ||||||||||||||||||||||||||||||
| 2133 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2134 | } | - | ||||||||||||||||||||||||||||||
| 2135 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2136 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||
| 2137 | } | - | ||||||||||||||||||||||||||||||
| 2138 | - | |||||||||||||||||||||||||||||||
| 2139 | /*! Raises a custom error with an optional error \a message. | - | ||||||||||||||||||||||||||||||
| 2140 | - | |||||||||||||||||||||||||||||||
| 2141 | \sa error(), errorString() | - | ||||||||||||||||||||||||||||||
| 2142 | */ | - | ||||||||||||||||||||||||||||||
| 2143 | void QXmlStreamReader::raiseError(const QString& message) | - | ||||||||||||||||||||||||||||||
| 2144 | { | - | ||||||||||||||||||||||||||||||
| 2145 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2146 | d->raiseError(CustomError, message); | - | ||||||||||||||||||||||||||||||
| 2147 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2148 | - | |||||||||||||||||||||||||||||||
| 2149 | /*! | - | ||||||||||||||||||||||||||||||
| 2150 | Returns the error message that was set with raiseError(). | - | ||||||||||||||||||||||||||||||
| 2151 | - | |||||||||||||||||||||||||||||||
| 2152 | \sa error(), lineNumber(), columnNumber(), characterOffset() | - | ||||||||||||||||||||||||||||||
| 2153 | */ | - | ||||||||||||||||||||||||||||||
| 2154 | QString QXmlStreamReader::errorString() const | - | ||||||||||||||||||||||||||||||
| 2155 | { | - | ||||||||||||||||||||||||||||||
| 2156 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2157 | if (d->type == QXmlStreamReader::Invalid)
| 39-586 | ||||||||||||||||||||||||||||||
| 2158 | return d->errorString; executed 39 times by 1 test: return d->errorString;Executed by:
| 39 | ||||||||||||||||||||||||||||||
| 2159 | return QString(); executed 586 times by 2 tests: return QString();Executed by:
| 586 | ||||||||||||||||||||||||||||||
| 2160 | } | - | ||||||||||||||||||||||||||||||
| 2161 | - | |||||||||||||||||||||||||||||||
| 2162 | /*! Returns the type of the current error, or NoError if no error occurred. | - | ||||||||||||||||||||||||||||||
| 2163 | - | |||||||||||||||||||||||||||||||
| 2164 | \sa errorString(), raiseError() | - | ||||||||||||||||||||||||||||||
| 2165 | */ | - | ||||||||||||||||||||||||||||||
| 2166 | QXmlStreamReader::Error QXmlStreamReader::error() const | - | ||||||||||||||||||||||||||||||
| 2167 | { | - | ||||||||||||||||||||||||||||||
| 2168 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2169 | if (d->type == QXmlStreamReader::Invalid)
| 2921-59946 | ||||||||||||||||||||||||||||||
| 2170 | return d->error; executed 59946 times by 3 tests: return d->error;Executed by:
| 59946 | ||||||||||||||||||||||||||||||
| 2171 | return NoError; executed 2921 times by 15 tests: return NoError;Executed by:
| 2921 | ||||||||||||||||||||||||||||||
| 2172 | } | - | ||||||||||||||||||||||||||||||
| 2173 | - | |||||||||||||||||||||||||||||||
| 2174 | /*! | - | ||||||||||||||||||||||||||||||
| 2175 | Returns the target of a ProcessingInstruction. | - | ||||||||||||||||||||||||||||||
| 2176 | */ | - | ||||||||||||||||||||||||||||||
| 2177 | QStringRef QXmlStreamReader::processingInstructionTarget() const | - | ||||||||||||||||||||||||||||||
| 2178 | { | - | ||||||||||||||||||||||||||||||
| 2179 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2180 | return d->processingInstructionTarget; executed 1988 times by 1 test: return d->processingInstructionTarget;Executed by:
| 1988 | ||||||||||||||||||||||||||||||
| 2181 | } | - | ||||||||||||||||||||||||||||||
| 2182 | - | |||||||||||||||||||||||||||||||
| 2183 | /*! | - | ||||||||||||||||||||||||||||||
| 2184 | Returns the data of a ProcessingInstruction. | - | ||||||||||||||||||||||||||||||
| 2185 | */ | - | ||||||||||||||||||||||||||||||
| 2186 | QStringRef QXmlStreamReader::processingInstructionData() const | - | ||||||||||||||||||||||||||||||
| 2187 | { | - | ||||||||||||||||||||||||||||||
| 2188 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2189 | return d->processingInstructionData; executed 2024 times by 1 test: return d->processingInstructionData;Executed by:
| 2024 | ||||||||||||||||||||||||||||||
| 2190 | } | - | ||||||||||||||||||||||||||||||
| 2191 | - | |||||||||||||||||||||||||||||||
| 2192 | - | |||||||||||||||||||||||||||||||
| 2193 | - | |||||||||||||||||||||||||||||||
| 2194 | /*! | - | ||||||||||||||||||||||||||||||
| 2195 | Returns the local name of a StartElement, EndElement, or an EntityReference. | - | ||||||||||||||||||||||||||||||
| 2196 | - | |||||||||||||||||||||||||||||||
| 2197 | \sa namespaceUri(), qualifiedName() | - | ||||||||||||||||||||||||||||||
| 2198 | */ | - | ||||||||||||||||||||||||||||||
| 2199 | QStringRef QXmlStreamReader::name() const | - | ||||||||||||||||||||||||||||||
| 2200 | { | - | ||||||||||||||||||||||||||||||
| 2201 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2202 | return d->name; executed 311578 times by 35 tests: return d->name;Executed by:
| 311578 | ||||||||||||||||||||||||||||||
| 2203 | } | - | ||||||||||||||||||||||||||||||
| 2204 | - | |||||||||||||||||||||||||||||||
| 2205 | /*! | - | ||||||||||||||||||||||||||||||
| 2206 | Returns the namespaceUri of a StartElement or EndElement. | - | ||||||||||||||||||||||||||||||
| 2207 | - | |||||||||||||||||||||||||||||||
| 2208 | \sa name(), qualifiedName() | - | ||||||||||||||||||||||||||||||
| 2209 | */ | - | ||||||||||||||||||||||||||||||
| 2210 | QStringRef QXmlStreamReader::namespaceUri() const | - | ||||||||||||||||||||||||||||||
| 2211 | { | - | ||||||||||||||||||||||||||||||
| 2212 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2213 | return d->namespaceUri; executed 3754 times by 1 test: return d->namespaceUri;Executed by:
| 3754 | ||||||||||||||||||||||||||||||
| 2214 | } | - | ||||||||||||||||||||||||||||||
| 2215 | - | |||||||||||||||||||||||||||||||
| 2216 | /*! | - | ||||||||||||||||||||||||||||||
| 2217 | Returns the qualified name of a StartElement or EndElement; | - | ||||||||||||||||||||||||||||||
| 2218 | - | |||||||||||||||||||||||||||||||
| 2219 | A qualified name is the raw name of an element in the XML data. It | - | ||||||||||||||||||||||||||||||
| 2220 | consists of the namespace prefix, followed by colon, followed by the | - | ||||||||||||||||||||||||||||||
| 2221 | element's local name. Since the namespace prefix is not unique (the | - | ||||||||||||||||||||||||||||||
| 2222 | same prefix can point to different namespaces and different prefixes | - | ||||||||||||||||||||||||||||||
| 2223 | can point to the same namespace), you shouldn't use qualifiedName(), | - | ||||||||||||||||||||||||||||||
| 2224 | but the resolved namespaceUri() and the attribute's local name(). | - | ||||||||||||||||||||||||||||||
| 2225 | - | |||||||||||||||||||||||||||||||
| 2226 | \sa name(), prefix(), namespaceUri() | - | ||||||||||||||||||||||||||||||
| 2227 | */ | - | ||||||||||||||||||||||||||||||
| 2228 | QStringRef QXmlStreamReader::qualifiedName() const | - | ||||||||||||||||||||||||||||||
| 2229 | { | - | ||||||||||||||||||||||||||||||
| 2230 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2231 | return d->qualifiedName; executed 3055 times by 1 test: return d->qualifiedName;Executed by:
| 3055 | ||||||||||||||||||||||||||||||
| 2232 | } | - | ||||||||||||||||||||||||||||||
| 2233 | - | |||||||||||||||||||||||||||||||
| 2234 | - | |||||||||||||||||||||||||||||||
| 2235 | - | |||||||||||||||||||||||||||||||
| 2236 | /*! | - | ||||||||||||||||||||||||||||||
| 2237 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2238 | - | |||||||||||||||||||||||||||||||
| 2239 | Returns the prefix of a StartElement or EndElement. | - | ||||||||||||||||||||||||||||||
| 2240 | - | |||||||||||||||||||||||||||||||
| 2241 | \sa name(), qualifiedName() | - | ||||||||||||||||||||||||||||||
| 2242 | */ | - | ||||||||||||||||||||||||||||||
| 2243 | QStringRef QXmlStreamReader::prefix() const | - | ||||||||||||||||||||||||||||||
| 2244 | { | - | ||||||||||||||||||||||||||||||
| 2245 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2246 | return d->prefix; executed 1943 times by 2 tests: return d->prefix;Executed by:
| 1943 | ||||||||||||||||||||||||||||||
| 2247 | } | - | ||||||||||||||||||||||||||||||
| 2248 | - | |||||||||||||||||||||||||||||||
| 2249 | /*! | - | ||||||||||||||||||||||||||||||
| 2250 | Returns the attributes of a StartElement. | - | ||||||||||||||||||||||||||||||
| 2251 | */ | - | ||||||||||||||||||||||||||||||
| 2252 | QXmlStreamAttributes QXmlStreamReader::attributes() const | - | ||||||||||||||||||||||||||||||
| 2253 | { | - | ||||||||||||||||||||||||||||||
| 2254 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2255 | return d->attributes; executed 282020 times by 35 tests: return d->attributes;Executed by:
| 282020 | ||||||||||||||||||||||||||||||
| 2256 | } | - | ||||||||||||||||||||||||||||||
| 2257 | - | |||||||||||||||||||||||||||||||
| 2258 | #endif // QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 2259 | - | |||||||||||||||||||||||||||||||
| 2260 | /*! | - | ||||||||||||||||||||||||||||||
| 2261 | \class QXmlStreamAttribute | - | ||||||||||||||||||||||||||||||
| 2262 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2263 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2264 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2265 | \brief The QXmlStreamAttribute class represents a single XML attribute | - | ||||||||||||||||||||||||||||||
| 2266 | - | |||||||||||||||||||||||||||||||
| 2267 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2268 | - | |||||||||||||||||||||||||||||||
| 2269 | An attribute consists of an optionally empty namespaceUri(), a | - | ||||||||||||||||||||||||||||||
| 2270 | name(), a value(), and an isDefault() attribute. | - | ||||||||||||||||||||||||||||||
| 2271 | - | |||||||||||||||||||||||||||||||
| 2272 | The raw XML attribute name is returned as qualifiedName(). | - | ||||||||||||||||||||||||||||||
| 2273 | */ | - | ||||||||||||||||||||||||||||||
| 2274 | - | |||||||||||||||||||||||||||||||
| 2275 | /*! | - | ||||||||||||||||||||||||||||||
| 2276 | Creates an empty attribute. | - | ||||||||||||||||||||||||||||||
| 2277 | */ | - | ||||||||||||||||||||||||||||||
| 2278 | QXmlStreamAttribute::QXmlStreamAttribute() | - | ||||||||||||||||||||||||||||||
| 2279 | { | - | ||||||||||||||||||||||||||||||
| 2280 | m_isDefault = false; | - | ||||||||||||||||||||||||||||||
| 2281 | } executed 386672 times by 36 tests: end of blockExecuted by:
| 386672 | ||||||||||||||||||||||||||||||
| 2282 | - | |||||||||||||||||||||||||||||||
| 2283 | /*! | - | ||||||||||||||||||||||||||||||
| 2284 | Destructs an attribute. | - | ||||||||||||||||||||||||||||||
| 2285 | */ | - | ||||||||||||||||||||||||||||||
| 2286 | QXmlStreamAttribute::~QXmlStreamAttribute() | - | ||||||||||||||||||||||||||||||
| 2287 | { | - | ||||||||||||||||||||||||||||||
| 2288 | } | - | ||||||||||||||||||||||||||||||
| 2289 | - | |||||||||||||||||||||||||||||||
| 2290 | /*! Constructs an attribute in the namespace described with \a | - | ||||||||||||||||||||||||||||||
| 2291 | namespaceUri with \a name and value \a value. | - | ||||||||||||||||||||||||||||||
| 2292 | */ | - | ||||||||||||||||||||||||||||||
| 2293 | QXmlStreamAttribute::QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value) | - | ||||||||||||||||||||||||||||||
| 2294 | { | - | ||||||||||||||||||||||||||||||
| 2295 | m_namespaceUri = QXmlStreamStringRef(QStringRef(&namespaceUri)); | - | ||||||||||||||||||||||||||||||
| 2296 | m_name = m_qualifiedName = QXmlStreamStringRef(QStringRef(&name)); | - | ||||||||||||||||||||||||||||||
| 2297 | m_value = QXmlStreamStringRef(QStringRef(&value)); | - | ||||||||||||||||||||||||||||||
| 2298 | m_namespaceUri = QXmlStreamStringRef(QStringRef(&namespaceUri)); | - | ||||||||||||||||||||||||||||||
| 2299 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2300 | - | |||||||||||||||||||||||||||||||
| 2301 | /*! | - | ||||||||||||||||||||||||||||||
| 2302 | Constructs an attribute with qualified name \a qualifiedName and value \a value. | - | ||||||||||||||||||||||||||||||
| 2303 | */ | - | ||||||||||||||||||||||||||||||
| 2304 | QXmlStreamAttribute::QXmlStreamAttribute(const QString &qualifiedName, const QString &value) | - | ||||||||||||||||||||||||||||||
| 2305 | { | - | ||||||||||||||||||||||||||||||
| 2306 | int colon = qualifiedName.indexOf(QLatin1Char(':')); | - | ||||||||||||||||||||||||||||||
| 2307 | m_name = QXmlStreamStringRef(QStringRef(&qualifiedName, | - | ||||||||||||||||||||||||||||||
| 2308 | colon + 1, | - | ||||||||||||||||||||||||||||||
| 2309 | qualifiedName.size() - (colon + 1))); | - | ||||||||||||||||||||||||||||||
| 2310 | m_qualifiedName = QXmlStreamStringRef(QStringRef(&qualifiedName)); | - | ||||||||||||||||||||||||||||||
| 2311 | m_value = QXmlStreamStringRef(QStringRef(&value)); | - | ||||||||||||||||||||||||||||||
| 2312 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2313 | - | |||||||||||||||||||||||||||||||
| 2314 | /*! \fn QStringRef QXmlStreamAttribute::namespaceUri() const | - | ||||||||||||||||||||||||||||||
| 2315 | - | |||||||||||||||||||||||||||||||
| 2316 | Returns the attribute's resolved namespaceUri, or an empty string | - | ||||||||||||||||||||||||||||||
| 2317 | reference if the attribute does not have a defined namespace. | - | ||||||||||||||||||||||||||||||
| 2318 | */ | - | ||||||||||||||||||||||||||||||
| 2319 | /*! \fn QStringRef QXmlStreamAttribute::name() const | - | ||||||||||||||||||||||||||||||
| 2320 | Returns the attribute's local name. | - | ||||||||||||||||||||||||||||||
| 2321 | */ | - | ||||||||||||||||||||||||||||||
| 2322 | /*! \fn QStringRef QXmlStreamAttribute::qualifiedName() const | - | ||||||||||||||||||||||||||||||
| 2323 | Returns the attribute's qualified name. | - | ||||||||||||||||||||||||||||||
| 2324 | - | |||||||||||||||||||||||||||||||
| 2325 | A qualified name is the raw name of an attribute in the XML | - | ||||||||||||||||||||||||||||||
| 2326 | data. It consists of the namespace prefix(), followed by colon, | - | ||||||||||||||||||||||||||||||
| 2327 | followed by the attribute's local name(). Since the namespace prefix | - | ||||||||||||||||||||||||||||||
| 2328 | is not unique (the same prefix can point to different namespaces | - | ||||||||||||||||||||||||||||||
| 2329 | and different prefixes can point to the same namespace), you | - | ||||||||||||||||||||||||||||||
| 2330 | shouldn't use qualifiedName(), but the resolved namespaceUri() and | - | ||||||||||||||||||||||||||||||
| 2331 | the attribute's local name(). | - | ||||||||||||||||||||||||||||||
| 2332 | */ | - | ||||||||||||||||||||||||||||||
| 2333 | /*! | - | ||||||||||||||||||||||||||||||
| 2334 | \fn QStringRef QXmlStreamAttribute::prefix() const | - | ||||||||||||||||||||||||||||||
| 2335 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2336 | Returns the attribute's namespace prefix. | - | ||||||||||||||||||||||||||||||
| 2337 | - | |||||||||||||||||||||||||||||||
| 2338 | \sa name(), qualifiedName() | - | ||||||||||||||||||||||||||||||
| 2339 | - | |||||||||||||||||||||||||||||||
| 2340 | */ | - | ||||||||||||||||||||||||||||||
| 2341 | - | |||||||||||||||||||||||||||||||
| 2342 | /*! \fn QStringRef QXmlStreamAttribute::value() const | - | ||||||||||||||||||||||||||||||
| 2343 | Returns the attribute's value. | - | ||||||||||||||||||||||||||||||
| 2344 | */ | - | ||||||||||||||||||||||||||||||
| 2345 | - | |||||||||||||||||||||||||||||||
| 2346 | /*! \fn bool QXmlStreamAttribute::isDefault() const | - | ||||||||||||||||||||||||||||||
| 2347 | - | |||||||||||||||||||||||||||||||
| 2348 | Returns \c true if the parser added this attribute with a default | - | ||||||||||||||||||||||||||||||
| 2349 | value following an ATTLIST declaration in the DTD; otherwise | - | ||||||||||||||||||||||||||||||
| 2350 | returns \c false. | - | ||||||||||||||||||||||||||||||
| 2351 | */ | - | ||||||||||||||||||||||||||||||
| 2352 | /*! \fn bool QXmlStreamAttribute::operator==(const QXmlStreamAttribute &other) const | - | ||||||||||||||||||||||||||||||
| 2353 | - | |||||||||||||||||||||||||||||||
| 2354 | Compares this attribute with \a other and returns \c true if they are | - | ||||||||||||||||||||||||||||||
| 2355 | equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2356 | */ | - | ||||||||||||||||||||||||||||||
| 2357 | /*! \fn bool QXmlStreamAttribute::operator!=(const QXmlStreamAttribute &other) const | - | ||||||||||||||||||||||||||||||
| 2358 | - | |||||||||||||||||||||||||||||||
| 2359 | Compares this attribute with \a other and returns \c true if they are | - | ||||||||||||||||||||||||||||||
| 2360 | not equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2361 | */ | - | ||||||||||||||||||||||||||||||
| 2362 | - | |||||||||||||||||||||||||||||||
| 2363 | - | |||||||||||||||||||||||||||||||
| 2364 | /*! | - | ||||||||||||||||||||||||||||||
| 2365 | Creates a copy of \a other. | - | ||||||||||||||||||||||||||||||
| 2366 | */ | - | ||||||||||||||||||||||||||||||
| 2367 | QXmlStreamAttribute::QXmlStreamAttribute(const QXmlStreamAttribute &other) | - | ||||||||||||||||||||||||||||||
| 2368 | { | - | ||||||||||||||||||||||||||||||
| 2369 | *this = other; | - | ||||||||||||||||||||||||||||||
| 2370 | } executed 2543 times by 1 test: end of blockExecuted by:
| 2543 | ||||||||||||||||||||||||||||||
| 2371 | - | |||||||||||||||||||||||||||||||
| 2372 | /*! | - | ||||||||||||||||||||||||||||||
| 2373 | Assigns \a other to this attribute. | - | ||||||||||||||||||||||||||||||
| 2374 | */ | - | ||||||||||||||||||||||||||||||
| 2375 | QXmlStreamAttribute& QXmlStreamAttribute::operator=(const QXmlStreamAttribute &other) | - | ||||||||||||||||||||||||||||||
| 2376 | { | - | ||||||||||||||||||||||||||||||
| 2377 | m_name = other.m_name; | - | ||||||||||||||||||||||||||||||
| 2378 | m_namespaceUri = other.m_namespaceUri; | - | ||||||||||||||||||||||||||||||
| 2379 | m_qualifiedName = other.m_qualifiedName; | - | ||||||||||||||||||||||||||||||
| 2380 | m_value = other.m_value; | - | ||||||||||||||||||||||||||||||
| 2381 | m_isDefault = other.m_isDefault; | - | ||||||||||||||||||||||||||||||
| 2382 | return *this; executed 2552 times by 1 test: return *this;Executed by:
| 2552 | ||||||||||||||||||||||||||||||
| 2383 | } | - | ||||||||||||||||||||||||||||||
| 2384 | - | |||||||||||||||||||||||||||||||
| 2385 | - | |||||||||||||||||||||||||||||||
| 2386 | /*! | - | ||||||||||||||||||||||||||||||
| 2387 | \class QXmlStreamAttributes | - | ||||||||||||||||||||||||||||||
| 2388 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2389 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2390 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2391 | \brief The QXmlStreamAttributes class represents a vector of QXmlStreamAttribute. | - | ||||||||||||||||||||||||||||||
| 2392 | - | |||||||||||||||||||||||||||||||
| 2393 | Attributes are returned by a QXmlStreamReader in | - | ||||||||||||||||||||||||||||||
| 2394 | \l{QXmlStreamReader::attributes()} {attributes()} when the reader | - | ||||||||||||||||||||||||||||||
| 2395 | reports a \l {QXmlStreamReader::StartElement}{start element}. The | - | ||||||||||||||||||||||||||||||
| 2396 | class can also be used with a QXmlStreamWriter as an argument to | - | ||||||||||||||||||||||||||||||
| 2397 | \l {QXmlStreamWriter::writeAttributes()}{writeAttributes()}. | - | ||||||||||||||||||||||||||||||
| 2398 | - | |||||||||||||||||||||||||||||||
| 2399 | The convenience function value() loops over the vector and returns | - | ||||||||||||||||||||||||||||||
| 2400 | an attribute value for a given namespaceUri and an attribute's | - | ||||||||||||||||||||||||||||||
| 2401 | name. | - | ||||||||||||||||||||||||||||||
| 2402 | - | |||||||||||||||||||||||||||||||
| 2403 | New attributes can be added with append(). | - | ||||||||||||||||||||||||||||||
| 2404 | - | |||||||||||||||||||||||||||||||
| 2405 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2406 | */ | - | ||||||||||||||||||||||||||||||
| 2407 | - | |||||||||||||||||||||||||||||||
| 2408 | /*! | - | ||||||||||||||||||||||||||||||
| 2409 | \fn QXmlStreamAttributes::QXmlStreamAttributes() | - | ||||||||||||||||||||||||||||||
| 2410 | - | |||||||||||||||||||||||||||||||
| 2411 | A constructor for QXmlStreamAttributes. | - | ||||||||||||||||||||||||||||||
| 2412 | */ | - | ||||||||||||||||||||||||||||||
| 2413 | - | |||||||||||||||||||||||||||||||
| 2414 | /*! | - | ||||||||||||||||||||||||||||||
| 2415 | \typedef QXmlStreamNotationDeclarations | - | ||||||||||||||||||||||||||||||
| 2416 | \relates QXmlStreamNotationDeclaration | - | ||||||||||||||||||||||||||||||
| 2417 | - | |||||||||||||||||||||||||||||||
| 2418 | Synonym for QVector<QXmlStreamNotationDeclaration>. | - | ||||||||||||||||||||||||||||||
| 2419 | */ | - | ||||||||||||||||||||||||||||||
| 2420 | - | |||||||||||||||||||||||||||||||
| 2421 | - | |||||||||||||||||||||||||||||||
| 2422 | /*! | - | ||||||||||||||||||||||||||||||
| 2423 | \class QXmlStreamNotationDeclaration | - | ||||||||||||||||||||||||||||||
| 2424 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2425 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2426 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2427 | \brief The QXmlStreamNotationDeclaration class represents a DTD notation declaration. | - | ||||||||||||||||||||||||||||||
| 2428 | - | |||||||||||||||||||||||||||||||
| 2429 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2430 | - | |||||||||||||||||||||||||||||||
| 2431 | An notation declaration consists of a name(), a systemId(), and a publicId(). | - | ||||||||||||||||||||||||||||||
| 2432 | */ | - | ||||||||||||||||||||||||||||||
| 2433 | - | |||||||||||||||||||||||||||||||
| 2434 | /*! | - | ||||||||||||||||||||||||||||||
| 2435 | Creates an empty notation declaration. | - | ||||||||||||||||||||||||||||||
| 2436 | */ | - | ||||||||||||||||||||||||||||||
| 2437 | QXmlStreamNotationDeclaration::QXmlStreamNotationDeclaration() | - | ||||||||||||||||||||||||||||||
| 2438 | { | - | ||||||||||||||||||||||||||||||
| 2439 | } | - | ||||||||||||||||||||||||||||||
| 2440 | /*! | - | ||||||||||||||||||||||||||||||
| 2441 | Creates a copy of \a other. | - | ||||||||||||||||||||||||||||||
| 2442 | */ | - | ||||||||||||||||||||||||||||||
| 2443 | QXmlStreamNotationDeclaration::QXmlStreamNotationDeclaration(const QXmlStreamNotationDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2444 | { | - | ||||||||||||||||||||||||||||||
| 2445 | *this = other; | - | ||||||||||||||||||||||||||||||
| 2446 | } executed 304 times by 1 test: end of blockExecuted by:
| 304 | ||||||||||||||||||||||||||||||
| 2447 | - | |||||||||||||||||||||||||||||||
| 2448 | /*! | - | ||||||||||||||||||||||||||||||
| 2449 | Assigns \a other to this notation declaration. | - | ||||||||||||||||||||||||||||||
| 2450 | */ | - | ||||||||||||||||||||||||||||||
| 2451 | QXmlStreamNotationDeclaration& QXmlStreamNotationDeclaration::operator=(const QXmlStreamNotationDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2452 | { | - | ||||||||||||||||||||||||||||||
| 2453 | m_name = other.m_name; | - | ||||||||||||||||||||||||||||||
| 2454 | m_systemId = other.m_systemId; | - | ||||||||||||||||||||||||||||||
| 2455 | m_publicId = other.m_publicId; | - | ||||||||||||||||||||||||||||||
| 2456 | return *this; executed 304 times by 1 test: return *this;Executed by:
| 304 | ||||||||||||||||||||||||||||||
| 2457 | } | - | ||||||||||||||||||||||||||||||
| 2458 | - | |||||||||||||||||||||||||||||||
| 2459 | /*! | - | ||||||||||||||||||||||||||||||
| 2460 | Destructs this notation declaration. | - | ||||||||||||||||||||||||||||||
| 2461 | */ | - | ||||||||||||||||||||||||||||||
| 2462 | QXmlStreamNotationDeclaration::~QXmlStreamNotationDeclaration() | - | ||||||||||||||||||||||||||||||
| 2463 | { | - | ||||||||||||||||||||||||||||||
| 2464 | } | - | ||||||||||||||||||||||||||||||
| 2465 | - | |||||||||||||||||||||||||||||||
| 2466 | /*! \fn QStringRef QXmlStreamNotationDeclaration::name() const | - | ||||||||||||||||||||||||||||||
| 2467 | - | |||||||||||||||||||||||||||||||
| 2468 | Returns the notation name. | - | ||||||||||||||||||||||||||||||
| 2469 | */ | - | ||||||||||||||||||||||||||||||
| 2470 | /*! \fn QStringRef QXmlStreamNotationDeclaration::systemId() const | - | ||||||||||||||||||||||||||||||
| 2471 | - | |||||||||||||||||||||||||||||||
| 2472 | Returns the system identifier. | - | ||||||||||||||||||||||||||||||
| 2473 | */ | - | ||||||||||||||||||||||||||||||
| 2474 | /*! \fn QStringRef QXmlStreamNotationDeclaration::publicId() const | - | ||||||||||||||||||||||||||||||
| 2475 | - | |||||||||||||||||||||||||||||||
| 2476 | Returns the public identifier. | - | ||||||||||||||||||||||||||||||
| 2477 | */ | - | ||||||||||||||||||||||||||||||
| 2478 | - | |||||||||||||||||||||||||||||||
| 2479 | /*! \fn inline bool QXmlStreamNotationDeclaration::operator==(const QXmlStreamNotationDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2480 | - | |||||||||||||||||||||||||||||||
| 2481 | Compares this notation declaration with \a other and returns \c true | - | ||||||||||||||||||||||||||||||
| 2482 | if they are equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2483 | */ | - | ||||||||||||||||||||||||||||||
| 2484 | /*! \fn inline bool QXmlStreamNotationDeclaration::operator!=(const QXmlStreamNotationDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2485 | - | |||||||||||||||||||||||||||||||
| 2486 | Compares this notation declaration with \a other and returns \c true | - | ||||||||||||||||||||||||||||||
| 2487 | if they are not equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2488 | */ | - | ||||||||||||||||||||||||||||||
| 2489 | - | |||||||||||||||||||||||||||||||
| 2490 | /*! | - | ||||||||||||||||||||||||||||||
| 2491 | \typedef QXmlStreamNamespaceDeclarations | - | ||||||||||||||||||||||||||||||
| 2492 | \relates QXmlStreamNamespaceDeclaration | - | ||||||||||||||||||||||||||||||
| 2493 | - | |||||||||||||||||||||||||||||||
| 2494 | Synonym for QVector<QXmlStreamNamespaceDeclaration>. | - | ||||||||||||||||||||||||||||||
| 2495 | */ | - | ||||||||||||||||||||||||||||||
| 2496 | - | |||||||||||||||||||||||||||||||
| 2497 | /*! | - | ||||||||||||||||||||||||||||||
| 2498 | \class QXmlStreamNamespaceDeclaration | - | ||||||||||||||||||||||||||||||
| 2499 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2500 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2501 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2502 | \brief The QXmlStreamNamespaceDeclaration class represents a namespace declaration. | - | ||||||||||||||||||||||||||||||
| 2503 | - | |||||||||||||||||||||||||||||||
| 2504 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2505 | - | |||||||||||||||||||||||||||||||
| 2506 | An namespace declaration consists of a prefix() and a namespaceUri(). | - | ||||||||||||||||||||||||||||||
| 2507 | */ | - | ||||||||||||||||||||||||||||||
| 2508 | /*! \fn inline bool QXmlStreamNamespaceDeclaration::operator==(const QXmlStreamNamespaceDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2509 | - | |||||||||||||||||||||||||||||||
| 2510 | Compares this namespace declaration with \a other and returns \c true | - | ||||||||||||||||||||||||||||||
| 2511 | if they are equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2512 | */ | - | ||||||||||||||||||||||||||||||
| 2513 | /*! \fn inline bool QXmlStreamNamespaceDeclaration::operator!=(const QXmlStreamNamespaceDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2514 | - | |||||||||||||||||||||||||||||||
| 2515 | Compares this namespace declaration with \a other and returns \c true | - | ||||||||||||||||||||||||||||||
| 2516 | if they are not equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2517 | */ | - | ||||||||||||||||||||||||||||||
| 2518 | - | |||||||||||||||||||||||||||||||
| 2519 | /*! | - | ||||||||||||||||||||||||||||||
| 2520 | Creates an empty namespace declaration. | - | ||||||||||||||||||||||||||||||
| 2521 | */ | - | ||||||||||||||||||||||||||||||
| 2522 | QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration() | - | ||||||||||||||||||||||||||||||
| 2523 | { | - | ||||||||||||||||||||||||||||||
| 2524 | } | - | ||||||||||||||||||||||||||||||
| 2525 | - | |||||||||||||||||||||||||||||||
| 2526 | /*! | - | ||||||||||||||||||||||||||||||
| 2527 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2528 | - | |||||||||||||||||||||||||||||||
| 2529 | Creates a namespace declaration with \a prefix and \a namespaceUri. | - | ||||||||||||||||||||||||||||||
| 2530 | */ | - | ||||||||||||||||||||||||||||||
| 2531 | QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration(const QString &prefix, const QString &namespaceUri) | - | ||||||||||||||||||||||||||||||
| 2532 | { | - | ||||||||||||||||||||||||||||||
| 2533 | m_prefix = prefix; | - | ||||||||||||||||||||||||||||||
| 2534 | m_namespaceUri = namespaceUri; | - | ||||||||||||||||||||||||||||||
| 2535 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 2536 | - | |||||||||||||||||||||||||||||||
| 2537 | /*! | - | ||||||||||||||||||||||||||||||
| 2538 | Creates a copy of \a other. | - | ||||||||||||||||||||||||||||||
| 2539 | */ | - | ||||||||||||||||||||||||||||||
| 2540 | QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2541 | { | - | ||||||||||||||||||||||||||||||
| 2542 | *this = other; | - | ||||||||||||||||||||||||||||||
| 2543 | } executed 54 times by 1 test: end of blockExecuted by:
| 54 | ||||||||||||||||||||||||||||||
| 2544 | - | |||||||||||||||||||||||||||||||
| 2545 | /*! | - | ||||||||||||||||||||||||||||||
| 2546 | Assigns \a other to this namespace declaration. | - | ||||||||||||||||||||||||||||||
| 2547 | */ | - | ||||||||||||||||||||||||||||||
| 2548 | QXmlStreamNamespaceDeclaration& QXmlStreamNamespaceDeclaration::operator=(const QXmlStreamNamespaceDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2549 | { | - | ||||||||||||||||||||||||||||||
| 2550 | m_prefix = other.m_prefix; | - | ||||||||||||||||||||||||||||||
| 2551 | m_namespaceUri = other.m_namespaceUri; | - | ||||||||||||||||||||||||||||||
| 2552 | return *this; executed 54 times by 1 test: return *this;Executed by:
| 54 | ||||||||||||||||||||||||||||||
| 2553 | } | - | ||||||||||||||||||||||||||||||
| 2554 | /*! | - | ||||||||||||||||||||||||||||||
| 2555 | Destructs this namespace declaration. | - | ||||||||||||||||||||||||||||||
| 2556 | */ | - | ||||||||||||||||||||||||||||||
| 2557 | QXmlStreamNamespaceDeclaration::~QXmlStreamNamespaceDeclaration() | - | ||||||||||||||||||||||||||||||
| 2558 | { | - | ||||||||||||||||||||||||||||||
| 2559 | } | - | ||||||||||||||||||||||||||||||
| 2560 | - | |||||||||||||||||||||||||||||||
| 2561 | /*! \fn QStringRef QXmlStreamNamespaceDeclaration::prefix() const | - | ||||||||||||||||||||||||||||||
| 2562 | - | |||||||||||||||||||||||||||||||
| 2563 | Returns the prefix. | - | ||||||||||||||||||||||||||||||
| 2564 | */ | - | ||||||||||||||||||||||||||||||
| 2565 | /*! \fn QStringRef QXmlStreamNamespaceDeclaration::namespaceUri() const | - | ||||||||||||||||||||||||||||||
| 2566 | - | |||||||||||||||||||||||||||||||
| 2567 | Returns the namespaceUri. | - | ||||||||||||||||||||||||||||||
| 2568 | */ | - | ||||||||||||||||||||||||||||||
| 2569 | - | |||||||||||||||||||||||||||||||
| 2570 | - | |||||||||||||||||||||||||||||||
| 2571 | - | |||||||||||||||||||||||||||||||
| 2572 | - | |||||||||||||||||||||||||||||||
| 2573 | /*! | - | ||||||||||||||||||||||||||||||
| 2574 | \typedef QXmlStreamEntityDeclarations | - | ||||||||||||||||||||||||||||||
| 2575 | \relates QXmlStreamEntityDeclaration | - | ||||||||||||||||||||||||||||||
| 2576 | - | |||||||||||||||||||||||||||||||
| 2577 | Synonym for QVector<QXmlStreamEntityDeclaration>. | - | ||||||||||||||||||||||||||||||
| 2578 | */ | - | ||||||||||||||||||||||||||||||
| 2579 | - | |||||||||||||||||||||||||||||||
| 2580 | /*! | - | ||||||||||||||||||||||||||||||
| 2581 | \class QXmlStreamStringRef | - | ||||||||||||||||||||||||||||||
| 2582 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2583 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2584 | \internal | - | ||||||||||||||||||||||||||||||
| 2585 | */ | - | ||||||||||||||||||||||||||||||
| 2586 | - | |||||||||||||||||||||||||||||||
| 2587 | /*! | - | ||||||||||||||||||||||||||||||
| 2588 | \class QXmlStreamEntityDeclaration | - | ||||||||||||||||||||||||||||||
| 2589 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2590 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2591 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2592 | \brief The QXmlStreamEntityDeclaration class represents a DTD entity declaration. | - | ||||||||||||||||||||||||||||||
| 2593 | - | |||||||||||||||||||||||||||||||
| 2594 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2595 | - | |||||||||||||||||||||||||||||||
| 2596 | An entity declaration consists of a name(), a notationName(), a | - | ||||||||||||||||||||||||||||||
| 2597 | systemId(), a publicId(), and a value(). | - | ||||||||||||||||||||||||||||||
| 2598 | */ | - | ||||||||||||||||||||||||||||||
| 2599 | - | |||||||||||||||||||||||||||||||
| 2600 | /*! | - | ||||||||||||||||||||||||||||||
| 2601 | Creates an empty entity declaration. | - | ||||||||||||||||||||||||||||||
| 2602 | */ | - | ||||||||||||||||||||||||||||||
| 2603 | QXmlStreamEntityDeclaration::QXmlStreamEntityDeclaration() | - | ||||||||||||||||||||||||||||||
| 2604 | { | - | ||||||||||||||||||||||||||||||
| 2605 | } | - | ||||||||||||||||||||||||||||||
| 2606 | - | |||||||||||||||||||||||||||||||
| 2607 | /*! | - | ||||||||||||||||||||||||||||||
| 2608 | Creates a copy of \a other. | - | ||||||||||||||||||||||||||||||
| 2609 | */ | - | ||||||||||||||||||||||||||||||
| 2610 | QXmlStreamEntityDeclaration::QXmlStreamEntityDeclaration(const QXmlStreamEntityDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2611 | { | - | ||||||||||||||||||||||||||||||
| 2612 | *this = other; | - | ||||||||||||||||||||||||||||||
| 2613 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 2614 | - | |||||||||||||||||||||||||||||||
| 2615 | /*! | - | ||||||||||||||||||||||||||||||
| 2616 | Assigns \a other to this entity declaration. | - | ||||||||||||||||||||||||||||||
| 2617 | */ | - | ||||||||||||||||||||||||||||||
| 2618 | QXmlStreamEntityDeclaration& QXmlStreamEntityDeclaration::operator=(const QXmlStreamEntityDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2619 | { | - | ||||||||||||||||||||||||||||||
| 2620 | m_name = other.m_name; | - | ||||||||||||||||||||||||||||||
| 2621 | m_notationName = other.m_notationName; | - | ||||||||||||||||||||||||||||||
| 2622 | m_systemId = other.m_systemId; | - | ||||||||||||||||||||||||||||||
| 2623 | m_publicId = other.m_publicId; | - | ||||||||||||||||||||||||||||||
| 2624 | m_value = other.m_value; | - | ||||||||||||||||||||||||||||||
| 2625 | return *this; executed 10 times by 1 test: return *this;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 2626 | } | - | ||||||||||||||||||||||||||||||
| 2627 | - | |||||||||||||||||||||||||||||||
| 2628 | /*! | - | ||||||||||||||||||||||||||||||
| 2629 | Destructs this entity declaration. | - | ||||||||||||||||||||||||||||||
| 2630 | */ | - | ||||||||||||||||||||||||||||||
| 2631 | QXmlStreamEntityDeclaration::~QXmlStreamEntityDeclaration() | - | ||||||||||||||||||||||||||||||
| 2632 | { | - | ||||||||||||||||||||||||||||||
| 2633 | } | - | ||||||||||||||||||||||||||||||
| 2634 | - | |||||||||||||||||||||||||||||||
| 2635 | /*! \fn QXmlStreamStringRef::swap(QXmlStreamStringRef &other) | - | ||||||||||||||||||||||||||||||
| 2636 | \since 5.6 | - | ||||||||||||||||||||||||||||||
| 2637 | - | |||||||||||||||||||||||||||||||
| 2638 | Swaps this string reference's contents with \a other. | - | ||||||||||||||||||||||||||||||
| 2639 | This function is very fast and never fails. | - | ||||||||||||||||||||||||||||||
| 2640 | */ | - | ||||||||||||||||||||||||||||||
| 2641 | - | |||||||||||||||||||||||||||||||
| 2642 | /*! \fn QStringRef QXmlStreamEntityDeclaration::name() const | - | ||||||||||||||||||||||||||||||
| 2643 | - | |||||||||||||||||||||||||||||||
| 2644 | Returns the entity name. | - | ||||||||||||||||||||||||||||||
| 2645 | */ | - | ||||||||||||||||||||||||||||||
| 2646 | /*! \fn QStringRef QXmlStreamEntityDeclaration::notationName() const | - | ||||||||||||||||||||||||||||||
| 2647 | - | |||||||||||||||||||||||||||||||
| 2648 | Returns the notation name. | - | ||||||||||||||||||||||||||||||
| 2649 | */ | - | ||||||||||||||||||||||||||||||
| 2650 | /*! \fn QStringRef QXmlStreamEntityDeclaration::systemId() const | - | ||||||||||||||||||||||||||||||
| 2651 | - | |||||||||||||||||||||||||||||||
| 2652 | Returns the system identifier. | - | ||||||||||||||||||||||||||||||
| 2653 | */ | - | ||||||||||||||||||||||||||||||
| 2654 | /*! \fn QStringRef QXmlStreamEntityDeclaration::publicId() const | - | ||||||||||||||||||||||||||||||
| 2655 | - | |||||||||||||||||||||||||||||||
| 2656 | Returns the public identifier. | - | ||||||||||||||||||||||||||||||
| 2657 | */ | - | ||||||||||||||||||||||||||||||
| 2658 | /*! \fn QStringRef QXmlStreamEntityDeclaration::value() const | - | ||||||||||||||||||||||||||||||
| 2659 | - | |||||||||||||||||||||||||||||||
| 2660 | Returns the entity's value. | - | ||||||||||||||||||||||||||||||
| 2661 | */ | - | ||||||||||||||||||||||||||||||
| 2662 | - | |||||||||||||||||||||||||||||||
| 2663 | /*! \fn bool QXmlStreamEntityDeclaration::operator==(const QXmlStreamEntityDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2664 | - | |||||||||||||||||||||||||||||||
| 2665 | Compares this entity declaration with \a other and returns \c true if | - | ||||||||||||||||||||||||||||||
| 2666 | they are equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2667 | */ | - | ||||||||||||||||||||||||||||||
| 2668 | /*! \fn bool QXmlStreamEntityDeclaration::operator!=(const QXmlStreamEntityDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2669 | - | |||||||||||||||||||||||||||||||
| 2670 | Compares this entity declaration with \a other and returns \c true if | - | ||||||||||||||||||||||||||||||
| 2671 | they are not equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2672 | */ | - | ||||||||||||||||||||||||||||||
| 2673 | - | |||||||||||||||||||||||||||||||
| 2674 | /*! Returns the value of the attribute \a name in the namespace | - | ||||||||||||||||||||||||||||||
| 2675 | described with \a namespaceUri, or an empty string reference if the | - | ||||||||||||||||||||||||||||||
| 2676 | attribute is not defined. The \a namespaceUri can be empty. | - | ||||||||||||||||||||||||||||||
| 2677 | */ | - | ||||||||||||||||||||||||||||||
| 2678 | QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, const QString &name) const | - | ||||||||||||||||||||||||||||||
| 2679 | { | - | ||||||||||||||||||||||||||||||
| 2680 | for (int i = 0; i < size(); ++i) {
| 6-28 | ||||||||||||||||||||||||||||||
| 2681 | const QXmlStreamAttribute &attribute = at(i); | - | ||||||||||||||||||||||||||||||
| 2682 | if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
| 2-21 | ||||||||||||||||||||||||||||||
| 2683 | return attribute.value(); executed 5 times by 1 test: return attribute.value();Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 2684 | } executed 23 times by 1 test: end of blockExecuted by:
| 23 | ||||||||||||||||||||||||||||||
| 2685 | return QStringRef(); executed 6 times by 1 test: return QStringRef();Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 2686 | } | - | ||||||||||||||||||||||||||||||
| 2687 | - | |||||||||||||||||||||||||||||||
| 2688 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 2689 | Returns the value of the attribute \a name in the namespace | - | ||||||||||||||||||||||||||||||
| 2690 | described with \a namespaceUri, or an empty string reference if the | - | ||||||||||||||||||||||||||||||
| 2691 | attribute is not defined. The \a namespaceUri can be empty. | - | ||||||||||||||||||||||||||||||
| 2692 | */ | - | ||||||||||||||||||||||||||||||
| 2693 | QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1String name) const | - | ||||||||||||||||||||||||||||||
| 2694 | { | - | ||||||||||||||||||||||||||||||
| 2695 | for (int i = 0; i < size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 2696 | const QXmlStreamAttribute &attribute = at(i); | - | ||||||||||||||||||||||||||||||
| 2697 | if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
| 0 | ||||||||||||||||||||||||||||||
| 2698 | return attribute.value(); never executed: return attribute.value(); | 0 | ||||||||||||||||||||||||||||||
| 2699 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2700 | return QStringRef(); never executed: return QStringRef(); | 0 | ||||||||||||||||||||||||||||||
| 2701 | } | - | ||||||||||||||||||||||||||||||
| 2702 | - | |||||||||||||||||||||||||||||||
| 2703 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 2704 | Returns the value of the attribute \a name in the namespace | - | ||||||||||||||||||||||||||||||
| 2705 | described with \a namespaceUri, or an empty string reference if the | - | ||||||||||||||||||||||||||||||
| 2706 | attribute is not defined. The \a namespaceUri can be empty. | - | ||||||||||||||||||||||||||||||
| 2707 | */ | - | ||||||||||||||||||||||||||||||
| 2708 | QStringRef QXmlStreamAttributes::value(QLatin1String namespaceUri, QLatin1String name) const | - | ||||||||||||||||||||||||||||||
| 2709 | { | - | ||||||||||||||||||||||||||||||
| 2710 | for (int i = 0; i < size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 2711 | const QXmlStreamAttribute &attribute = at(i); | - | ||||||||||||||||||||||||||||||
| 2712 | if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
| 0 | ||||||||||||||||||||||||||||||
| 2713 | return attribute.value(); never executed: return attribute.value(); | 0 | ||||||||||||||||||||||||||||||
| 2714 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2715 | return QStringRef(); never executed: return QStringRef(); | 0 | ||||||||||||||||||||||||||||||
| 2716 | } | - | ||||||||||||||||||||||||||||||
| 2717 | - | |||||||||||||||||||||||||||||||
| 2718 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 2719 | - | |||||||||||||||||||||||||||||||
| 2720 | Returns the value of the attribute with qualified name \a | - | ||||||||||||||||||||||||||||||
| 2721 | qualifiedName , or an empty string reference if the attribute is not | - | ||||||||||||||||||||||||||||||
| 2722 | defined. A qualified name is the raw name of an attribute in the XML | - | ||||||||||||||||||||||||||||||
| 2723 | data. It consists of the namespace prefix, followed by colon, | - | ||||||||||||||||||||||||||||||
| 2724 | followed by the attribute's local name. Since the namespace prefix | - | ||||||||||||||||||||||||||||||
| 2725 | is not unique (the same prefix can point to different namespaces and | - | ||||||||||||||||||||||||||||||
| 2726 | different prefixes can point to the same namespace), you shouldn't | - | ||||||||||||||||||||||||||||||
| 2727 | use qualified names, but a resolved namespaceUri and the attribute's | - | ||||||||||||||||||||||||||||||
| 2728 | local name. | - | ||||||||||||||||||||||||||||||
| 2729 | */ | - | ||||||||||||||||||||||||||||||
| 2730 | QStringRef QXmlStreamAttributes::value(const QString &qualifiedName) const | - | ||||||||||||||||||||||||||||||
| 2731 | { | - | ||||||||||||||||||||||||||||||
| 2732 | for (int i = 0; i < size(); ++i) {
| 3-19 | ||||||||||||||||||||||||||||||
| 2733 | const QXmlStreamAttribute &attribute = at(i); | - | ||||||||||||||||||||||||||||||
| 2734 | if (attribute.qualifiedName() == qualifiedName)
| 5-14 | ||||||||||||||||||||||||||||||
| 2735 | return attribute.value(); executed 5 times by 1 test: return attribute.value();Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 2736 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 2737 | return QStringRef(); executed 3 times by 1 test: return QStringRef();Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 2738 | } | - | ||||||||||||||||||||||||||||||
| 2739 | - | |||||||||||||||||||||||||||||||
| 2740 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 2741 | - | |||||||||||||||||||||||||||||||
| 2742 | Returns the value of the attribute with qualified name \a | - | ||||||||||||||||||||||||||||||
| 2743 | qualifiedName , or an empty string reference if the attribute is not | - | ||||||||||||||||||||||||||||||
| 2744 | defined. A qualified name is the raw name of an attribute in the XML | - | ||||||||||||||||||||||||||||||
| 2745 | data. It consists of the namespace prefix, followed by colon, | - | ||||||||||||||||||||||||||||||
| 2746 | followed by the attribute's local name. Since the namespace prefix | - | ||||||||||||||||||||||||||||||
| 2747 | is not unique (the same prefix can point to different namespaces and | - | ||||||||||||||||||||||||||||||
| 2748 | different prefixes can point to the same namespace), you shouldn't | - | ||||||||||||||||||||||||||||||
| 2749 | use qualified names, but a resolved namespaceUri and the attribute's | - | ||||||||||||||||||||||||||||||
| 2750 | local name. | - | ||||||||||||||||||||||||||||||
| 2751 | */ | - | ||||||||||||||||||||||||||||||
| 2752 | QStringRef QXmlStreamAttributes::value(QLatin1String qualifiedName) const | - | ||||||||||||||||||||||||||||||
| 2753 | { | - | ||||||||||||||||||||||||||||||
| 2754 | for (int i = 0; i < size(); ++i) {
| 19261-340807 | ||||||||||||||||||||||||||||||
| 2755 | const QXmlStreamAttribute &attribute = at(i); | - | ||||||||||||||||||||||||||||||
| 2756 | if (attribute.qualifiedName() == qualifiedName)
| 51027-289780 | ||||||||||||||||||||||||||||||
| 2757 | return attribute.value(); executed 289780 times by 35 tests: return attribute.value();Executed by:
| 289780 | ||||||||||||||||||||||||||||||
| 2758 | } executed 51027 times by 14 tests: end of blockExecuted by:
| 51027 | ||||||||||||||||||||||||||||||
| 2759 | return QStringRef(); executed 19261 times by 35 tests: return QStringRef();Executed by:
| 19261 | ||||||||||||||||||||||||||||||
| 2760 | } | - | ||||||||||||||||||||||||||||||
| 2761 | - | |||||||||||||||||||||||||||||||
| 2762 | /*!Appends a new attribute with \a name in the namespace | - | ||||||||||||||||||||||||||||||
| 2763 | described with \a namespaceUri, and value \a value. The \a | - | ||||||||||||||||||||||||||||||
| 2764 | namespaceUri can be empty. | - | ||||||||||||||||||||||||||||||
| 2765 | */ | - | ||||||||||||||||||||||||||||||
| 2766 | void QXmlStreamAttributes::append(const QString &namespaceUri, const QString &name, const QString &value) | - | ||||||||||||||||||||||||||||||
| 2767 | { | - | ||||||||||||||||||||||||||||||
| 2768 | append(QXmlStreamAttribute(namespaceUri, name, value)); | - | ||||||||||||||||||||||||||||||
| 2769 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2770 | - | |||||||||||||||||||||||||||||||
| 2771 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 2772 | Appends a new attribute with qualified name \a qualifiedName and | - | ||||||||||||||||||||||||||||||
| 2773 | value \a value. | - | ||||||||||||||||||||||||||||||
| 2774 | */ | - | ||||||||||||||||||||||||||||||
| 2775 | void QXmlStreamAttributes::append(const QString &qualifiedName, const QString &value) | - | ||||||||||||||||||||||||||||||
| 2776 | { | - | ||||||||||||||||||||||||||||||
| 2777 | append(QXmlStreamAttribute(qualifiedName, value)); | - | ||||||||||||||||||||||||||||||
| 2778 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2779 | - | |||||||||||||||||||||||||||||||
| 2780 | #ifndef QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 2781 | - | |||||||||||||||||||||||||||||||
| 2782 | /*! \fn bool QXmlStreamReader::isStartDocument() const | - | ||||||||||||||||||||||||||||||
| 2783 | Returns \c true if tokenType() equals \l StartDocument; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2784 | */ | - | ||||||||||||||||||||||||||||||
| 2785 | /*! \fn bool QXmlStreamReader::isEndDocument() const | - | ||||||||||||||||||||||||||||||
| 2786 | Returns \c true if tokenType() equals \l EndDocument; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2787 | */ | - | ||||||||||||||||||||||||||||||
| 2788 | /*! \fn bool QXmlStreamReader::isStartElement() const | - | ||||||||||||||||||||||||||||||
| 2789 | Returns \c true if tokenType() equals \l StartElement; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2790 | */ | - | ||||||||||||||||||||||||||||||
| 2791 | /*! \fn bool QXmlStreamReader::isEndElement() const | - | ||||||||||||||||||||||||||||||
| 2792 | Returns \c true if tokenType() equals \l EndElement; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2793 | */ | - | ||||||||||||||||||||||||||||||
| 2794 | /*! \fn bool QXmlStreamReader::isCharacters() const | - | ||||||||||||||||||||||||||||||
| 2795 | Returns \c true if tokenType() equals \l Characters; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2796 | - | |||||||||||||||||||||||||||||||
| 2797 | \sa isWhitespace(), isCDATA() | - | ||||||||||||||||||||||||||||||
| 2798 | */ | - | ||||||||||||||||||||||||||||||
| 2799 | /*! \fn bool QXmlStreamReader::isComment() const | - | ||||||||||||||||||||||||||||||
| 2800 | Returns \c true if tokenType() equals \l Comment; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2801 | */ | - | ||||||||||||||||||||||||||||||
| 2802 | /*! \fn bool QXmlStreamReader::isDTD() const | - | ||||||||||||||||||||||||||||||
| 2803 | Returns \c true if tokenType() equals \l DTD; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2804 | */ | - | ||||||||||||||||||||||||||||||
| 2805 | /*! \fn bool QXmlStreamReader::isEntityReference() const | - | ||||||||||||||||||||||||||||||
| 2806 | Returns \c true if tokenType() equals \l EntityReference; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2807 | */ | - | ||||||||||||||||||||||||||||||
| 2808 | /*! \fn bool QXmlStreamReader::isProcessingInstruction() const | - | ||||||||||||||||||||||||||||||
| 2809 | Returns \c true if tokenType() equals \l ProcessingInstruction; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2810 | */ | - | ||||||||||||||||||||||||||||||
| 2811 | - | |||||||||||||||||||||||||||||||
| 2812 | /*! Returns \c true if the reader reports characters that only consist | - | ||||||||||||||||||||||||||||||
| 2813 | of white-space; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2814 | - | |||||||||||||||||||||||||||||||
| 2815 | \sa isCharacters(), text() | - | ||||||||||||||||||||||||||||||
| 2816 | */ | - | ||||||||||||||||||||||||||||||
| 2817 | bool QXmlStreamReader::isWhitespace() const | - | ||||||||||||||||||||||||||||||
| 2818 | { | - | ||||||||||||||||||||||||||||||
| 2819 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2820 | return d->type == QXmlStreamReader::Characters && d->isWhitespace; executed 1903 times by 1 test: return d->type == QXmlStreamReader::Characters && d->isWhitespace;Executed by:
| 1903 | ||||||||||||||||||||||||||||||
| 2821 | } | - | ||||||||||||||||||||||||||||||
| 2822 | - | |||||||||||||||||||||||||||||||
| 2823 | /*! Returns \c true if the reader reports characters that stem from a | - | ||||||||||||||||||||||||||||||
| 2824 | CDATA section; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2825 | - | |||||||||||||||||||||||||||||||
| 2826 | \sa isCharacters(), text() | - | ||||||||||||||||||||||||||||||
| 2827 | */ | - | ||||||||||||||||||||||||||||||
| 2828 | bool QXmlStreamReader::isCDATA() const | - | ||||||||||||||||||||||||||||||
| 2829 | { | - | ||||||||||||||||||||||||||||||
| 2830 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2831 | return d->type == QXmlStreamReader::Characters && d->isCDATA; executed 1903 times by 1 test: return d->type == QXmlStreamReader::Characters && d->isCDATA;Executed by:
| 1903 | ||||||||||||||||||||||||||||||
| 2832 | } | - | ||||||||||||||||||||||||||||||
| 2833 | - | |||||||||||||||||||||||||||||||
| 2834 | - | |||||||||||||||||||||||||||||||
| 2835 | - | |||||||||||||||||||||||||||||||
| 2836 | /*! | - | ||||||||||||||||||||||||||||||
| 2837 | Returns \c true if this document has been declared standalone in the | - | ||||||||||||||||||||||||||||||
| 2838 | XML declaration; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2839 | - | |||||||||||||||||||||||||||||||
| 2840 | If no XML declaration has been parsed, this function returns \c false. | - | ||||||||||||||||||||||||||||||
| 2841 | */ | - | ||||||||||||||||||||||||||||||
| 2842 | bool QXmlStreamReader::isStandaloneDocument() const | - | ||||||||||||||||||||||||||||||
| 2843 | { | - | ||||||||||||||||||||||||||||||
| 2844 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2845 | return d->standalone; executed 77 times by 1 test: return d->standalone;Executed by:
| 77 | ||||||||||||||||||||||||||||||
| 2846 | } | - | ||||||||||||||||||||||||||||||
| 2847 | - | |||||||||||||||||||||||||||||||
| 2848 | - | |||||||||||||||||||||||||||||||
| 2849 | /*! | - | ||||||||||||||||||||||||||||||
| 2850 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2851 | - | |||||||||||||||||||||||||||||||
| 2852 | If the tokenType() is \l StartDocument, this function returns the | - | ||||||||||||||||||||||||||||||
| 2853 | version string as specified in the XML declaration. | - | ||||||||||||||||||||||||||||||
| 2854 | Otherwise an empty string is returned. | - | ||||||||||||||||||||||||||||||
| 2855 | */ | - | ||||||||||||||||||||||||||||||
| 2856 | QStringRef QXmlStreamReader::documentVersion() const | - | ||||||||||||||||||||||||||||||
| 2857 | { | - | ||||||||||||||||||||||||||||||
| 2858 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2859 | if (d->type == QXmlStreamReader::StartDocument)
| 133-1826 | ||||||||||||||||||||||||||||||
| 2860 | return d->documentVersion; executed 133 times by 1 test: return d->documentVersion;Executed by:
| 133 | ||||||||||||||||||||||||||||||
| 2861 | return QStringRef(); executed 1826 times by 1 test: return QStringRef();Executed by:
| 1826 | ||||||||||||||||||||||||||||||
| 2862 | } | - | ||||||||||||||||||||||||||||||
| 2863 | - | |||||||||||||||||||||||||||||||
| 2864 | /*! | - | ||||||||||||||||||||||||||||||
| 2865 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2866 | - | |||||||||||||||||||||||||||||||
| 2867 | If the tokenType() is \l StartDocument, this function returns the | - | ||||||||||||||||||||||||||||||
| 2868 | encoding string as specified in the XML declaration. | - | ||||||||||||||||||||||||||||||
| 2869 | Otherwise an empty string is returned. | - | ||||||||||||||||||||||||||||||
| 2870 | */ | - | ||||||||||||||||||||||||||||||
| 2871 | QStringRef QXmlStreamReader::documentEncoding() const | - | ||||||||||||||||||||||||||||||
| 2872 | { | - | ||||||||||||||||||||||||||||||
| 2873 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2874 | if (d->type == QXmlStreamReader::StartDocument)
| 83-1826 | ||||||||||||||||||||||||||||||
| 2875 | return d->documentEncoding; executed 83 times by 1 test: return d->documentEncoding;Executed by:
| 83 | ||||||||||||||||||||||||||||||
| 2876 | return QStringRef(); executed 1826 times by 1 test: return QStringRef();Executed by:
| 1826 | ||||||||||||||||||||||||||||||
| 2877 | } | - | ||||||||||||||||||||||||||||||
| 2878 | - | |||||||||||||||||||||||||||||||
| 2879 | #endif // QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 2880 | - | |||||||||||||||||||||||||||||||
| 2881 | /*! | - | ||||||||||||||||||||||||||||||
| 2882 | \class QXmlStreamWriter | - | ||||||||||||||||||||||||||||||
| 2883 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2884 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2885 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2886 | - | |||||||||||||||||||||||||||||||
| 2887 | \brief The QXmlStreamWriter class provides an XML writer with a | - | ||||||||||||||||||||||||||||||
| 2888 | simple streaming API. | - | ||||||||||||||||||||||||||||||
| 2889 | - | |||||||||||||||||||||||||||||||
| 2890 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2891 | - | |||||||||||||||||||||||||||||||
| 2892 | QXmlStreamWriter is the counterpart to QXmlStreamReader for writing | - | ||||||||||||||||||||||||||||||
| 2893 | XML. Like its related class, it operates on a QIODevice specified | - | ||||||||||||||||||||||||||||||
| 2894 | with setDevice(). The API is simple and straightforward: for every | - | ||||||||||||||||||||||||||||||
| 2895 | XML token or event you want to write, the writer provides a | - | ||||||||||||||||||||||||||||||
| 2896 | specialized function. | - | ||||||||||||||||||||||||||||||
| 2897 | - | |||||||||||||||||||||||||||||||
| 2898 | You start a document with writeStartDocument() and end it with | - | ||||||||||||||||||||||||||||||
| 2899 | writeEndDocument(). This will implicitly close all remaining open | - | ||||||||||||||||||||||||||||||
| 2900 | tags. | - | ||||||||||||||||||||||||||||||
| 2901 | - | |||||||||||||||||||||||||||||||
| 2902 | Element tags are opened with writeStartElement() followed by | - | ||||||||||||||||||||||||||||||
| 2903 | writeAttribute() or writeAttributes(), element content, and then | - | ||||||||||||||||||||||||||||||
| 2904 | writeEndElement(). A shorter form writeEmptyElement() can be used | - | ||||||||||||||||||||||||||||||
| 2905 | to write empty elements, followed by writeAttributes(). | - | ||||||||||||||||||||||||||||||
| 2906 | - | |||||||||||||||||||||||||||||||
| 2907 | Element content consists of either characters, entity references or | - | ||||||||||||||||||||||||||||||
| 2908 | nested elements. It is written with writeCharacters(), which also | - | ||||||||||||||||||||||||||||||
| 2909 | takes care of escaping all forbidden characters and character | - | ||||||||||||||||||||||||||||||
| 2910 | sequences, writeEntityReference(), or subsequent calls to | - | ||||||||||||||||||||||||||||||
| 2911 | writeStartElement(). A convenience method writeTextElement() can be | - | ||||||||||||||||||||||||||||||
| 2912 | used for writing terminal elements that contain nothing but text. | - | ||||||||||||||||||||||||||||||
| 2913 | - | |||||||||||||||||||||||||||||||
| 2914 | The following abridged code snippet shows the basic use of the class | - | ||||||||||||||||||||||||||||||
| 2915 | to write formatted XML with indentation: | - | ||||||||||||||||||||||||||||||
| 2916 | - | |||||||||||||||||||||||||||||||
| 2917 | \snippet qxmlstreamwriter/main.cpp start stream | - | ||||||||||||||||||||||||||||||
| 2918 | \dots | - | ||||||||||||||||||||||||||||||
| 2919 | \snippet qxmlstreamwriter/main.cpp write element | - | ||||||||||||||||||||||||||||||
| 2920 | \dots | - | ||||||||||||||||||||||||||||||
| 2921 | \snippet qxmlstreamwriter/main.cpp finish stream | - | ||||||||||||||||||||||||||||||
| 2922 | - | |||||||||||||||||||||||||||||||
| 2923 | QXmlStreamWriter takes care of prefixing namespaces, all you have to | - | ||||||||||||||||||||||||||||||
| 2924 | do is specify the \c namespaceUri when writing elements or | - | ||||||||||||||||||||||||||||||
| 2925 | attributes. If you must conform to certain prefixes, you can force | - | ||||||||||||||||||||||||||||||
| 2926 | the writer to use them by declaring the namespaces manually with | - | ||||||||||||||||||||||||||||||
| 2927 | either writeNamespace() or writeDefaultNamespace(). Alternatively, | - | ||||||||||||||||||||||||||||||
| 2928 | you can bypass the stream writer's namespace support and use | - | ||||||||||||||||||||||||||||||
| 2929 | overloaded methods that take a qualified name instead. The namespace | - | ||||||||||||||||||||||||||||||
| 2930 | \e http://www.w3.org/XML/1998/namespace is implicit and mapped to the | - | ||||||||||||||||||||||||||||||
| 2931 | prefix \e xml. | - | ||||||||||||||||||||||||||||||
| 2932 | - | |||||||||||||||||||||||||||||||
| 2933 | The stream writer can automatically format the generated XML data by | - | ||||||||||||||||||||||||||||||
| 2934 | adding line-breaks and indentation to empty sections between | - | ||||||||||||||||||||||||||||||
| 2935 | elements, making the XML data more readable for humans and easier to | - | ||||||||||||||||||||||||||||||
| 2936 | work with for most source code management systems. The feature can | - | ||||||||||||||||||||||||||||||
| 2937 | be turned on with the \l autoFormatting property, and customized | - | ||||||||||||||||||||||||||||||
| 2938 | with the \l autoFormattingIndent property. | - | ||||||||||||||||||||||||||||||
| 2939 | - | |||||||||||||||||||||||||||||||
| 2940 | Other functions are writeCDATA(), writeComment(), | - | ||||||||||||||||||||||||||||||
| 2941 | writeProcessingInstruction(), and writeDTD(). Chaining of XML | - | ||||||||||||||||||||||||||||||
| 2942 | streams is supported with writeCurrentToken(). | - | ||||||||||||||||||||||||||||||
| 2943 | - | |||||||||||||||||||||||||||||||
| 2944 | By default, QXmlStreamWriter encodes XML in UTF-8. Different | - | ||||||||||||||||||||||||||||||
| 2945 | encodings can be enforced using setCodec(). | - | ||||||||||||||||||||||||||||||
| 2946 | - | |||||||||||||||||||||||||||||||
| 2947 | If an error occurs while writing to the underlying device, hasError() | - | ||||||||||||||||||||||||||||||
| 2948 | starts returning true and subsequent writes are ignored. | - | ||||||||||||||||||||||||||||||
| 2949 | - | |||||||||||||||||||||||||||||||
| 2950 | The \l{QXmlStream Bookmarks Example} illustrates how to use a | - | ||||||||||||||||||||||||||||||
| 2951 | stream writer to write an XML bookmark file (XBEL) that | - | ||||||||||||||||||||||||||||||
| 2952 | was previously read in by a QXmlStreamReader. | - | ||||||||||||||||||||||||||||||
| 2953 | - | |||||||||||||||||||||||||||||||
| 2954 | */ | - | ||||||||||||||||||||||||||||||
| 2955 | - | |||||||||||||||||||||||||||||||
| 2956 | #ifndef QT_NO_XMLSTREAMWRITER | - | ||||||||||||||||||||||||||||||
| 2957 | - | |||||||||||||||||||||||||||||||
| 2958 | class QXmlStreamWriterPrivate : public QXmlStreamPrivateTagStack { | - | ||||||||||||||||||||||||||||||
| 2959 | QXmlStreamWriter *q_ptr; | - | ||||||||||||||||||||||||||||||
| 2960 | Q_DECLARE_PUBLIC(QXmlStreamWriter) | - | ||||||||||||||||||||||||||||||
| 2961 | public: | - | ||||||||||||||||||||||||||||||
| 2962 | QXmlStreamWriterPrivate(QXmlStreamWriter *q); | - | ||||||||||||||||||||||||||||||
| 2963 | ~QXmlStreamWriterPrivate() { | - | ||||||||||||||||||||||||||||||
| 2964 | if (deleteDevice)
| 34-710 | ||||||||||||||||||||||||||||||
| 2965 | delete device; executed 710 times by 1 test: delete device;Executed by:
| 710 | ||||||||||||||||||||||||||||||
| 2966 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 2967 | delete encoder; | - | ||||||||||||||||||||||||||||||
| 2968 | #endif | - | ||||||||||||||||||||||||||||||
| 2969 | } executed 744 times by 3 tests: end of blockExecuted by:
| 744 | ||||||||||||||||||||||||||||||
| 2970 | - | |||||||||||||||||||||||||||||||
| 2971 | void write(const QStringRef &); | - | ||||||||||||||||||||||||||||||
| 2972 | void write(const QString &); | - | ||||||||||||||||||||||||||||||
| 2973 | void writeEscaped(const QString &, bool escapeWhitespace = false); | - | ||||||||||||||||||||||||||||||
| 2974 | void write(const char *s, int len); | - | ||||||||||||||||||||||||||||||
| 2975 | template <int N> void write(const char (&s)[N]) { write(s, N - 1); } executed 9934 times by 3 tests: end of blockExecuted by:
| 9934 | ||||||||||||||||||||||||||||||
| 2976 | bool finishStartElement(bool contents = true); | - | ||||||||||||||||||||||||||||||
| 2977 | void writeStartElement(const QString &namespaceUri, const QString &name); | - | ||||||||||||||||||||||||||||||
| 2978 | QIODevice *device; | - | ||||||||||||||||||||||||||||||
| 2979 | QString *stringDevice; | - | ||||||||||||||||||||||||||||||
| 2980 | uint deleteDevice :1; | - | ||||||||||||||||||||||||||||||
| 2981 | uint inStartElement :1; | - | ||||||||||||||||||||||||||||||
| 2982 | uint inEmptyElement :1; | - | ||||||||||||||||||||||||||||||
| 2983 | uint lastWasStartElement :1; | - | ||||||||||||||||||||||||||||||
| 2984 | uint wroteSomething :1; | - | ||||||||||||||||||||||||||||||
| 2985 | uint hasError :1; | - | ||||||||||||||||||||||||||||||
| 2986 | uint autoFormatting :1; | - | ||||||||||||||||||||||||||||||
| 2987 | uint isCodecASCIICompatible :1; | - | ||||||||||||||||||||||||||||||
| 2988 | QByteArray autoFormattingIndent; | - | ||||||||||||||||||||||||||||||
| 2989 | NamespaceDeclaration emptyNamespace; | - | ||||||||||||||||||||||||||||||
| 2990 | int lastNamespaceDeclaration; | - | ||||||||||||||||||||||||||||||
| 2991 | - | |||||||||||||||||||||||||||||||
| 2992 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 2993 | QTextCodec *codec; | - | ||||||||||||||||||||||||||||||
| 2994 | QTextEncoder *encoder; | - | ||||||||||||||||||||||||||||||
| 2995 | #endif | - | ||||||||||||||||||||||||||||||
| 2996 | void checkIfASCIICompatibleCodec(); | - | ||||||||||||||||||||||||||||||
| 2997 | - | |||||||||||||||||||||||||||||||
| 2998 | NamespaceDeclaration &findNamespace(const QString &namespaceUri, bool writeDeclaration = false, bool noDefault = false); | - | ||||||||||||||||||||||||||||||
| 2999 | void writeNamespaceDeclaration(const NamespaceDeclaration &namespaceDeclaration); | - | ||||||||||||||||||||||||||||||
| 3000 | - | |||||||||||||||||||||||||||||||
| 3001 | int namespacePrefixCount; | - | ||||||||||||||||||||||||||||||
| 3002 | - | |||||||||||||||||||||||||||||||
| 3003 | void indent(int level); | - | ||||||||||||||||||||||||||||||
| 3004 | }; | - | ||||||||||||||||||||||||||||||
| 3005 | - | |||||||||||||||||||||||||||||||
| 3006 | - | |||||||||||||||||||||||||||||||
| 3007 | QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) | - | ||||||||||||||||||||||||||||||
| 3008 | :autoFormattingIndent(4, ' ') | - | ||||||||||||||||||||||||||||||
| 3009 | { | - | ||||||||||||||||||||||||||||||
| 3010 | q_ptr = q; | - | ||||||||||||||||||||||||||||||
| 3011 | device = 0; | - | ||||||||||||||||||||||||||||||
| 3012 | stringDevice = 0; | - | ||||||||||||||||||||||||||||||
| 3013 | deleteDevice = false; | - | ||||||||||||||||||||||||||||||
| 3014 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3015 | codec = QTextCodec::codecForMib(106); // utf8 | - | ||||||||||||||||||||||||||||||
| 3016 | encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8 | - | ||||||||||||||||||||||||||||||
| 3017 | #endif | - | ||||||||||||||||||||||||||||||
| 3018 | checkIfASCIICompatibleCodec(); | - | ||||||||||||||||||||||||||||||
| 3019 | inStartElement = inEmptyElement = false; | - | ||||||||||||||||||||||||||||||
| 3020 | wroteSomething = false; | - | ||||||||||||||||||||||||||||||
| 3021 | hasError = false; | - | ||||||||||||||||||||||||||||||
| 3022 | lastWasStartElement = false; | - | ||||||||||||||||||||||||||||||
| 3023 | lastNamespaceDeclaration = 1; | - | ||||||||||||||||||||||||||||||
| 3024 | autoFormatting = false; | - | ||||||||||||||||||||||||||||||
| 3025 | namespacePrefixCount = 0; | - | ||||||||||||||||||||||||||||||
| 3026 | } executed 744 times by 3 tests: end of blockExecuted by:
| 744 | ||||||||||||||||||||||||||||||
| 3027 | - | |||||||||||||||||||||||||||||||
| 3028 | void QXmlStreamWriterPrivate::checkIfASCIICompatibleCodec() | - | ||||||||||||||||||||||||||||||
| 3029 | { | - | ||||||||||||||||||||||||||||||
| 3030 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3031 | Q_ASSERT(encoder); | - | ||||||||||||||||||||||||||||||
| 3032 | // test ASCII-compatibility using the letter 'a' | - | ||||||||||||||||||||||||||||||
| 3033 | QChar letterA = QLatin1Char('a'); | - | ||||||||||||||||||||||||||||||
| 3034 | const QByteArray bytesA = encoder->fromUnicode(&letterA, 1); | - | ||||||||||||||||||||||||||||||
| 3035 | const bool isCodecASCIICompatibleA = (bytesA.count() == 1) && (bytesA[0] == 0x61) ;
| 1-757 | ||||||||||||||||||||||||||||||
| 3036 | QChar letterLess = QLatin1Char('<'); | - | ||||||||||||||||||||||||||||||
| 3037 | const QByteArray bytesLess = encoder->fromUnicode(&letterLess, 1); | - | ||||||||||||||||||||||||||||||
| 3038 | const bool isCodecASCIICompatibleLess = (bytesLess.count() == 1) && (bytesLess[0] == 0x3C) ;
| 1-757 | ||||||||||||||||||||||||||||||
| 3039 | isCodecASCIICompatible = isCodecASCIICompatibleA && isCodecASCIICompatibleLess ;
| 0-756 | ||||||||||||||||||||||||||||||
| 3040 | #else | - | ||||||||||||||||||||||||||||||
| 3041 | isCodecASCIICompatible = true; | - | ||||||||||||||||||||||||||||||
| 3042 | #endif | - | ||||||||||||||||||||||||||||||
| 3043 | } executed 758 times by 3 tests: end of blockExecuted by:
| 758 | ||||||||||||||||||||||||||||||
| 3044 | - | |||||||||||||||||||||||||||||||
| 3045 | void QXmlStreamWriterPrivate::write(const QStringRef &s) | - | ||||||||||||||||||||||||||||||
| 3046 | { | - | ||||||||||||||||||||||||||||||
| 3047 | if (device) {
| 8-3151 | ||||||||||||||||||||||||||||||
| 3048 | if (hasError)
| 4-3147 | ||||||||||||||||||||||||||||||
| 3049 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 3050 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3051 | QByteArray bytes = s.toLatin1(); | - | ||||||||||||||||||||||||||||||
| 3052 | #else | - | ||||||||||||||||||||||||||||||
| 3053 | QByteArray bytes = encoder->fromUnicode(s.constData(), s.size()); | - | ||||||||||||||||||||||||||||||
| 3054 | #endif | - | ||||||||||||||||||||||||||||||
| 3055 | if (device->write(bytes) != bytes.size())
| 1-3146 | ||||||||||||||||||||||||||||||
| 3056 | hasError = true; executed 1 time by 1 test: hasError = true;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3057 | } executed 3147 times by 3 tests: end of blockExecuted by:
| 3147 | ||||||||||||||||||||||||||||||
| 3058 | else if (stringDevice)
| 0-8 | ||||||||||||||||||||||||||||||
| 3059 | s.appendTo(stringDevice); executed 8 times by 1 test: s.appendTo(stringDevice);Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 3060 | else | - | ||||||||||||||||||||||||||||||
| 3061 | qWarning("QXmlStreamWriter: No device"); never executed: QMessageLogger(__FILE__, 3061, __PRETTY_FUNCTION__).warning("QXmlStreamWriter: No device"); | 0 | ||||||||||||||||||||||||||||||
| 3062 | } | - | ||||||||||||||||||||||||||||||
| 3063 | - | |||||||||||||||||||||||||||||||
| 3064 | void QXmlStreamWriterPrivate::write(const QString &s) | - | ||||||||||||||||||||||||||||||
| 3065 | { | - | ||||||||||||||||||||||||||||||
| 3066 | if (device) {
| 72-5148 | ||||||||||||||||||||||||||||||
| 3067 | if (hasError)
| 1-5147 | ||||||||||||||||||||||||||||||
| 3068 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3069 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3070 | QByteArray bytes = s.toLatin1(); | - | ||||||||||||||||||||||||||||||
| 3071 | #else | - | ||||||||||||||||||||||||||||||
| 3072 | QByteArray bytes = encoder->fromUnicode(s); | - | ||||||||||||||||||||||||||||||
| 3073 | #endif | - | ||||||||||||||||||||||||||||||
| 3074 | if (device->write(bytes) != bytes.size())
| 1-5146 | ||||||||||||||||||||||||||||||
| 3075 | hasError = true; executed 1 time by 1 test: hasError = true;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3076 | } executed 5147 times by 3 tests: end of blockExecuted by:
| 5147 | ||||||||||||||||||||||||||||||
| 3077 | else if (stringDevice)
| 0-72 | ||||||||||||||||||||||||||||||
| 3078 | stringDevice->append(s); executed 72 times by 1 test: stringDevice->append(s);Executed by:
| 72 | ||||||||||||||||||||||||||||||
| 3079 | else | - | ||||||||||||||||||||||||||||||
| 3080 | qWarning("QXmlStreamWriter: No device"); never executed: QMessageLogger(__FILE__, 3080, __PRETTY_FUNCTION__).warning("QXmlStreamWriter: No device"); | 0 | ||||||||||||||||||||||||||||||
| 3081 | } | - | ||||||||||||||||||||||||||||||
| 3082 | - | |||||||||||||||||||||||||||||||
| 3083 | void QXmlStreamWriterPrivate::writeEscaped(const QString &s, bool escapeWhitespace) | - | ||||||||||||||||||||||||||||||
| 3084 | { | - | ||||||||||||||||||||||||||||||
| 3085 | QString escaped; | - | ||||||||||||||||||||||||||||||
| 3086 | escaped.reserve(s.size()); | - | ||||||||||||||||||||||||||||||
| 3087 | for ( int i = 0; i < s.size(); ++i ) {
| 3437-20852 | ||||||||||||||||||||||||||||||
| 3088 | QChar c = s.at(i); | - | ||||||||||||||||||||||||||||||
| 3089 | if (c.unicode() == '<' )
| 50-20802 | ||||||||||||||||||||||||||||||
| 3090 | escaped.append(QLatin1String("<")); executed 50 times by 1 test: escaped.append(QLatin1String("<"));Executed by:
| 50 | ||||||||||||||||||||||||||||||
| 3091 | else if (c.unicode() == '>' )
| 52-20750 | ||||||||||||||||||||||||||||||
| 3092 | escaped.append(QLatin1String(">")); executed 52 times by 1 test: escaped.append(QLatin1String(">"));Executed by:
| 52 | ||||||||||||||||||||||||||||||
| 3093 | else if (c.unicode() == '&' )
| 29-20721 | ||||||||||||||||||||||||||||||
| 3094 | escaped.append(QLatin1String("&")); executed 29 times by 1 test: escaped.append(QLatin1String("&"));Executed by:
| 29 | ||||||||||||||||||||||||||||||
| 3095 | else if (c.unicode() == '\"' )
| 21-20700 | ||||||||||||||||||||||||||||||
| 3096 | escaped.append(QLatin1String(""")); executed 21 times by 1 test: escaped.append(QLatin1String("""));Executed by:
| 21 | ||||||||||||||||||||||||||||||
| 3097 | else if (escapeWhitespace && c.isSpace()) {
| 173-16644 | ||||||||||||||||||||||||||||||
| 3098 | if (c.unicode() == '\n')
| 2-171 | ||||||||||||||||||||||||||||||
| 3099 | escaped.append(QLatin1String(" ")); executed 2 times by 1 test: escaped.append(QLatin1String(" "));Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3100 | else if (c.unicode() == '\r')
| 2-169 | ||||||||||||||||||||||||||||||
| 3101 | escaped.append(QLatin1String(" ")); executed 2 times by 1 test: escaped.append(QLatin1String(" "));Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3102 | else if (c.unicode() == '\t')
| 3-166 | ||||||||||||||||||||||||||||||
| 3103 | escaped.append(QLatin1String("	")); executed 3 times by 1 test: escaped.append(QLatin1String("	"));Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 3104 | else | - | ||||||||||||||||||||||||||||||
| 3105 | escaped += c; executed 166 times by 1 test: escaped += c;Executed by:
| 166 | ||||||||||||||||||||||||||||||
| 3106 | } else { | - | ||||||||||||||||||||||||||||||
| 3107 | escaped += QChar(c); | - | ||||||||||||||||||||||||||||||
| 3108 | } executed 20527 times by 3 tests: end of blockExecuted by:
| 20527 | ||||||||||||||||||||||||||||||
| 3109 | } | - | ||||||||||||||||||||||||||||||
| 3110 | write(escaped); | - | ||||||||||||||||||||||||||||||
| 3111 | } executed 3437 times by 3 tests: end of blockExecuted by:
| 3437 | ||||||||||||||||||||||||||||||
| 3112 | - | |||||||||||||||||||||||||||||||
| 3113 | // Converts from ASCII to output encoding | - | ||||||||||||||||||||||||||||||
| 3114 | void QXmlStreamWriterPrivate::write(const char *s, int len) | - | ||||||||||||||||||||||||||||||
| 3115 | { | - | ||||||||||||||||||||||||||||||
| 3116 | if (device) {
| 64-10239 | ||||||||||||||||||||||||||||||
| 3117 | if (hasError)
| 14-10225 | ||||||||||||||||||||||||||||||
| 3118 | return; executed 14 times by 1 test: return;Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 3119 | if (isCodecASCIICompatible) {
| 14-10211 | ||||||||||||||||||||||||||||||
| 3120 | if (device->write(s, len) != len)
| 2-10209 | ||||||||||||||||||||||||||||||
| 3121 | hasError = true; executed 2 times by 1 test: hasError = true;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3122 | return; executed 10211 times by 3 tests: return;Executed by:
| 10211 | ||||||||||||||||||||||||||||||
| 3123 | } | - | ||||||||||||||||||||||||||||||
| 3124 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 3125 | - | |||||||||||||||||||||||||||||||
| 3126 | write(QString::fromLatin1(s, len)); | - | ||||||||||||||||||||||||||||||
| 3127 | } executed 78 times by 1 test: end of blockExecuted by:
| 78 | ||||||||||||||||||||||||||||||
| 3128 | - | |||||||||||||||||||||||||||||||
| 3129 | void QXmlStreamWriterPrivate::writeNamespaceDeclaration(const NamespaceDeclaration &namespaceDeclaration) { | - | ||||||||||||||||||||||||||||||
| 3130 | if (namespaceDeclaration.prefix.isEmpty()) {
| 0-102 | ||||||||||||||||||||||||||||||
| 3131 | write(" xmlns=\""); | - | ||||||||||||||||||||||||||||||
| 3132 | write(namespaceDeclaration.namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3133 | write("\""); | - | ||||||||||||||||||||||||||||||
| 3134 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3135 | write(" xmlns:"); | - | ||||||||||||||||||||||||||||||
| 3136 | write(namespaceDeclaration.prefix); | - | ||||||||||||||||||||||||||||||
| 3137 | write("=\""); | - | ||||||||||||||||||||||||||||||
| 3138 | write(namespaceDeclaration.namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3139 | write("\""); | - | ||||||||||||||||||||||||||||||
| 3140 | } executed 102 times by 3 tests: end of blockExecuted by:
| 102 | ||||||||||||||||||||||||||||||
| 3141 | } | - | ||||||||||||||||||||||||||||||
| 3142 | - | |||||||||||||||||||||||||||||||
| 3143 | bool QXmlStreamWriterPrivate::finishStartElement(bool contents) | - | ||||||||||||||||||||||||||||||
| 3144 | { | - | ||||||||||||||||||||||||||||||
| 3145 | bool hadSomethingWritten = wroteSomething; | - | ||||||||||||||||||||||||||||||
| 3146 | wroteSomething = contents; | - | ||||||||||||||||||||||||||||||
| 3147 | if (!inStartElement)
| 1276-5103 | ||||||||||||||||||||||||||||||
| 3148 | return hadSomethingWritten; executed 5103 times by 3 tests: return hadSomethingWritten;Executed by:
| 5103 | ||||||||||||||||||||||||||||||
| 3149 | - | |||||||||||||||||||||||||||||||
| 3150 | if (inEmptyElement) {
| 39-1237 | ||||||||||||||||||||||||||||||
| 3151 | write("/>"); | - | ||||||||||||||||||||||||||||||
| 3152 | QXmlStreamWriterPrivate::Tag &tag = tagStack_pop(); | - | ||||||||||||||||||||||||||||||
| 3153 | lastNamespaceDeclaration = tag.namespaceDeclarationsSize; | - | ||||||||||||||||||||||||||||||
| 3154 | lastWasStartElement = false; | - | ||||||||||||||||||||||||||||||
| 3155 | } else { executed 39 times by 3 tests: end of blockExecuted by:
| 39 | ||||||||||||||||||||||||||||||
| 3156 | write(">"); | - | ||||||||||||||||||||||||||||||
| 3157 | } executed 1237 times by 3 tests: end of blockExecuted by:
| 1237 | ||||||||||||||||||||||||||||||
| 3158 | inStartElement = inEmptyElement = false; | - | ||||||||||||||||||||||||||||||
| 3159 | lastNamespaceDeclaration = namespaceDeclarations.size(); | - | ||||||||||||||||||||||||||||||
| 3160 | return hadSomethingWritten; executed 1276 times by 3 tests: return hadSomethingWritten;Executed by:
| 1276 | ||||||||||||||||||||||||||||||
| 3161 | } | - | ||||||||||||||||||||||||||||||
| 3162 | - | |||||||||||||||||||||||||||||||
| 3163 | QXmlStreamPrivateTagStack::NamespaceDeclaration &QXmlStreamWriterPrivate::findNamespace(const QString &namespaceUri, bool writeDeclaration, bool noDefault) | - | ||||||||||||||||||||||||||||||
| 3164 | { | - | ||||||||||||||||||||||||||||||
| 3165 | for (int j = namespaceDeclarations.size() - 1; j >= 0; --j) {
| 1162-2565 | ||||||||||||||||||||||||||||||
| 3166 | NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations[j]; | - | ||||||||||||||||||||||||||||||
| 3167 | if (namespaceDeclaration.namespaceUri == namespaceUri) {
| 302-2263 | ||||||||||||||||||||||||||||||
| 3168 | if (!noDefault || !namespaceDeclaration.prefix.isEmpty())
| 0-168 | ||||||||||||||||||||||||||||||
| 3169 | return namespaceDeclaration; executed 302 times by 3 tests: return namespaceDeclaration;Executed by:
| 302 | ||||||||||||||||||||||||||||||
| 3170 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3171 | } executed 2263 times by 3 tests: end of blockExecuted by:
| 2263 | ||||||||||||||||||||||||||||||
| 3172 | if (namespaceUri.isEmpty())
| 19-1143 | ||||||||||||||||||||||||||||||
| 3173 | return emptyNamespace; executed 1143 times by 1 test: return emptyNamespace;Executed by:
| 1143 | ||||||||||||||||||||||||||||||
| 3174 | NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 3175 | if (namespaceUri.isEmpty()) {
| 0-19 | ||||||||||||||||||||||||||||||
| 3176 | namespaceDeclaration.prefix.clear(); | - | ||||||||||||||||||||||||||||||
| 3177 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3178 | QString s; | - | ||||||||||||||||||||||||||||||
| 3179 | int n = ++namespacePrefixCount; | - | ||||||||||||||||||||||||||||||
| 3180 | forever { | - | ||||||||||||||||||||||||||||||
| 3181 | s = QLatin1Char('n') + QString::number(n++); | - | ||||||||||||||||||||||||||||||
| 3182 | int j = namespaceDeclarations.size() - 2; | - | ||||||||||||||||||||||||||||||
| 3183 | while (j >= 0 && namespaceDeclarations.at(j).prefix != s)
| 0-22 | ||||||||||||||||||||||||||||||
| 3184 | --j; executed 22 times by 1 test: --j;Executed by:
| 22 | ||||||||||||||||||||||||||||||
| 3185 | if (j < 0)
| 0-19 | ||||||||||||||||||||||||||||||
| 3186 | break; executed 19 times by 1 test: break;Executed by:
| 19 | ||||||||||||||||||||||||||||||
| 3187 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3188 | namespaceDeclaration.prefix = addToStringStorage(s); | - | ||||||||||||||||||||||||||||||
| 3189 | } executed 19 times by 1 test: end of blockExecuted by:
| 19 | ||||||||||||||||||||||||||||||
| 3190 | namespaceDeclaration.namespaceUri = addToStringStorage(namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3191 | if (writeDeclaration)
| 4-15 | ||||||||||||||||||||||||||||||
| 3192 | writeNamespaceDeclaration(namespaceDeclaration); executed 4 times by 1 test: writeNamespaceDeclaration(namespaceDeclaration);Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 3193 | return namespaceDeclaration; executed 19 times by 1 test: return namespaceDeclaration;Executed by:
| 19 | ||||||||||||||||||||||||||||||
| 3194 | } | - | ||||||||||||||||||||||||||||||
| 3195 | - | |||||||||||||||||||||||||||||||
| 3196 | - | |||||||||||||||||||||||||||||||
| 3197 | - | |||||||||||||||||||||||||||||||
| 3198 | void QXmlStreamWriterPrivate::indent(int level) | - | ||||||||||||||||||||||||||||||
| 3199 | { | - | ||||||||||||||||||||||||||||||
| 3200 | write("\n"); | - | ||||||||||||||||||||||||||||||
| 3201 | for (int i = level; i > 0; --i)
| 218-332 | ||||||||||||||||||||||||||||||
| 3202 | write(autoFormattingIndent.constData(), autoFormattingIndent.length()); executed 332 times by 3 tests: write(autoFormattingIndent.constData(), autoFormattingIndent.length());Executed by:
| 332 | ||||||||||||||||||||||||||||||
| 3203 | } executed 218 times by 3 tests: end of blockExecuted by:
| 218 | ||||||||||||||||||||||||||||||
| 3204 | - | |||||||||||||||||||||||||||||||
| 3205 | - | |||||||||||||||||||||||||||||||
| 3206 | /*! | - | ||||||||||||||||||||||||||||||
| 3207 | Constructs a stream writer. | - | ||||||||||||||||||||||||||||||
| 3208 | - | |||||||||||||||||||||||||||||||
| 3209 | \sa setDevice() | - | ||||||||||||||||||||||||||||||
| 3210 | */ | - | ||||||||||||||||||||||||||||||
| 3211 | QXmlStreamWriter::QXmlStreamWriter() | - | ||||||||||||||||||||||||||||||
| 3212 | : d_ptr(new QXmlStreamWriterPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 3213 | { | - | ||||||||||||||||||||||||||||||
| 3214 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3215 | - | |||||||||||||||||||||||||||||||
| 3216 | /*! | - | ||||||||||||||||||||||||||||||
| 3217 | Constructs a stream writer that writes into \a device; | - | ||||||||||||||||||||||||||||||
| 3218 | */ | - | ||||||||||||||||||||||||||||||
| 3219 | QXmlStreamWriter::QXmlStreamWriter(QIODevice *device) | - | ||||||||||||||||||||||||||||||
| 3220 | : d_ptr(new QXmlStreamWriterPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 3221 | { | - | ||||||||||||||||||||||||||||||
| 3222 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3223 | d->device = device; | - | ||||||||||||||||||||||||||||||
| 3224 | } executed 32 times by 3 tests: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||||||||
| 3225 | - | |||||||||||||||||||||||||||||||
| 3226 | /*! Constructs a stream writer that writes into \a array. This is the | - | ||||||||||||||||||||||||||||||
| 3227 | same as creating an xml writer that operates on a QBuffer device | - | ||||||||||||||||||||||||||||||
| 3228 | which in turn operates on \a array. | - | ||||||||||||||||||||||||||||||
| 3229 | */ | - | ||||||||||||||||||||||||||||||
| 3230 | QXmlStreamWriter::QXmlStreamWriter(QByteArray *array) | - | ||||||||||||||||||||||||||||||
| 3231 | : d_ptr(new QXmlStreamWriterPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 3232 | { | - | ||||||||||||||||||||||||||||||
| 3233 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3234 | d->device = new QBuffer(array); | - | ||||||||||||||||||||||||||||||
| 3235 | d->device->open(QIODevice::WriteOnly); | - | ||||||||||||||||||||||||||||||
| 3236 | d->deleteDevice = true; | - | ||||||||||||||||||||||||||||||
| 3237 | } executed 710 times by 1 test: end of blockExecuted by:
| 710 | ||||||||||||||||||||||||||||||
| 3238 | - | |||||||||||||||||||||||||||||||
| 3239 | - | |||||||||||||||||||||||||||||||
| 3240 | /*! Constructs a stream writer that writes into \a string. | - | ||||||||||||||||||||||||||||||
| 3241 | */ | - | ||||||||||||||||||||||||||||||
| 3242 | QXmlStreamWriter::QXmlStreamWriter(QString *string) | - | ||||||||||||||||||||||||||||||
| 3243 | : d_ptr(new QXmlStreamWriterPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 3244 | { | - | ||||||||||||||||||||||||||||||
| 3245 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3246 | d->stringDevice = string; | - | ||||||||||||||||||||||||||||||
| 3247 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 3248 | - | |||||||||||||||||||||||||||||||
| 3249 | /*! | - | ||||||||||||||||||||||||||||||
| 3250 | Destructor. | - | ||||||||||||||||||||||||||||||
| 3251 | */ | - | ||||||||||||||||||||||||||||||
| 3252 | QXmlStreamWriter::~QXmlStreamWriter() | - | ||||||||||||||||||||||||||||||
| 3253 | { | - | ||||||||||||||||||||||||||||||
| 3254 | } | - | ||||||||||||||||||||||||||||||
| 3255 | - | |||||||||||||||||||||||||||||||
| 3256 | - | |||||||||||||||||||||||||||||||
| 3257 | /*! | - | ||||||||||||||||||||||||||||||
| 3258 | Sets the current device to \a device. If you want the stream to | - | ||||||||||||||||||||||||||||||
| 3259 | write into a QByteArray, you can create a QBuffer device. | - | ||||||||||||||||||||||||||||||
| 3260 | - | |||||||||||||||||||||||||||||||
| 3261 | \sa device() | - | ||||||||||||||||||||||||||||||
| 3262 | */ | - | ||||||||||||||||||||||||||||||
| 3263 | void QXmlStreamWriter::setDevice(QIODevice *device) | - | ||||||||||||||||||||||||||||||
| 3264 | { | - | ||||||||||||||||||||||||||||||
| 3265 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3266 | if (device == d->device)
| 0 | ||||||||||||||||||||||||||||||
| 3267 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3268 | d->stringDevice = 0; | - | ||||||||||||||||||||||||||||||
| 3269 | if (d->deleteDevice) {
| 0 | ||||||||||||||||||||||||||||||
| 3270 | delete d->device; | - | ||||||||||||||||||||||||||||||
| 3271 | d->deleteDevice = false; | - | ||||||||||||||||||||||||||||||
| 3272 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3273 | d->device = device; | - | ||||||||||||||||||||||||||||||
| 3274 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3275 | - | |||||||||||||||||||||||||||||||
| 3276 | /*! | - | ||||||||||||||||||||||||||||||
| 3277 | Returns the current device associated with the QXmlStreamWriter, | - | ||||||||||||||||||||||||||||||
| 3278 | or 0 if no device has been assigned. | - | ||||||||||||||||||||||||||||||
| 3279 | - | |||||||||||||||||||||||||||||||
| 3280 | \sa setDevice() | - | ||||||||||||||||||||||||||||||
| 3281 | */ | - | ||||||||||||||||||||||||||||||
| 3282 | QIODevice *QXmlStreamWriter::device() const | - | ||||||||||||||||||||||||||||||
| 3283 | { | - | ||||||||||||||||||||||||||||||
| 3284 | Q_D(const QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3285 | return d->device; never executed: return d->device; | 0 | ||||||||||||||||||||||||||||||
| 3286 | } | - | ||||||||||||||||||||||||||||||
| 3287 | - | |||||||||||||||||||||||||||||||
| 3288 | - | |||||||||||||||||||||||||||||||
| 3289 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3290 | /*! | - | ||||||||||||||||||||||||||||||
| 3291 | Sets the codec for this stream to \a codec. The codec is used for | - | ||||||||||||||||||||||||||||||
| 3292 | encoding any data that is written. By default, QXmlStreamWriter | - | ||||||||||||||||||||||||||||||
| 3293 | uses UTF-8. | - | ||||||||||||||||||||||||||||||
| 3294 | - | |||||||||||||||||||||||||||||||
| 3295 | The encoding information is stored in the initial xml tag which | - | ||||||||||||||||||||||||||||||
| 3296 | gets written when you call writeStartDocument(). Call this | - | ||||||||||||||||||||||||||||||
| 3297 | function before calling writeStartDocument(). | - | ||||||||||||||||||||||||||||||
| 3298 | - | |||||||||||||||||||||||||||||||
| 3299 | \sa codec() | - | ||||||||||||||||||||||||||||||
| 3300 | */ | - | ||||||||||||||||||||||||||||||
| 3301 | void QXmlStreamWriter::setCodec(QTextCodec *codec) | - | ||||||||||||||||||||||||||||||
| 3302 | { | - | ||||||||||||||||||||||||||||||
| 3303 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3304 | if (codec) {
| 0-14 | ||||||||||||||||||||||||||||||
| 3305 | d->codec = codec; | - | ||||||||||||||||||||||||||||||
| 3306 | delete d->encoder; | - | ||||||||||||||||||||||||||||||
| 3307 | d->encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8 | - | ||||||||||||||||||||||||||||||
| 3308 | d->checkIfASCIICompatibleCodec(); | - | ||||||||||||||||||||||||||||||
| 3309 | } executed 14 times by 3 tests: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 3310 | } executed 14 times by 3 tests: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 3311 | - | |||||||||||||||||||||||||||||||
| 3312 | /*! | - | ||||||||||||||||||||||||||||||
| 3313 | Sets the codec for this stream to the QTextCodec for the encoding | - | ||||||||||||||||||||||||||||||
| 3314 | specified by \a codecName. Common values for \c codecName include | - | ||||||||||||||||||||||||||||||
| 3315 | "ISO 8859-1", "UTF-8", and "UTF-16". If the encoding isn't | - | ||||||||||||||||||||||||||||||
| 3316 | recognized, nothing happens. | - | ||||||||||||||||||||||||||||||
| 3317 | - | |||||||||||||||||||||||||||||||
| 3318 | \sa QTextCodec::codecForName() | - | ||||||||||||||||||||||||||||||
| 3319 | */ | - | ||||||||||||||||||||||||||||||
| 3320 | void QXmlStreamWriter::setCodec(const char *codecName) | - | ||||||||||||||||||||||||||||||
| 3321 | { | - | ||||||||||||||||||||||||||||||
| 3322 | setCodec(QTextCodec::codecForName(codecName)); | - | ||||||||||||||||||||||||||||||
| 3323 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 3324 | - | |||||||||||||||||||||||||||||||
| 3325 | /*! | - | ||||||||||||||||||||||||||||||
| 3326 | Returns the codec that is currently assigned to the stream. | - | ||||||||||||||||||||||||||||||
| 3327 | - | |||||||||||||||||||||||||||||||
| 3328 | \sa setCodec() | - | ||||||||||||||||||||||||||||||
| 3329 | */ | - | ||||||||||||||||||||||||||||||
| 3330 | QTextCodec *QXmlStreamWriter::codec() const | - | ||||||||||||||||||||||||||||||
| 3331 | { | - | ||||||||||||||||||||||||||||||
| 3332 | Q_D(const QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3333 | return d->codec; never executed: return d->codec; | 0 | ||||||||||||||||||||||||||||||
| 3334 | } | - | ||||||||||||||||||||||||||||||
| 3335 | #endif // QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3336 | - | |||||||||||||||||||||||||||||||
| 3337 | /*! | - | ||||||||||||||||||||||||||||||
| 3338 | \property QXmlStreamWriter::autoFormatting | - | ||||||||||||||||||||||||||||||
| 3339 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 3340 | The auto-formatting flag of the stream writer | - | ||||||||||||||||||||||||||||||
| 3341 | - | |||||||||||||||||||||||||||||||
| 3342 | This property controls whether or not the stream writer | - | ||||||||||||||||||||||||||||||
| 3343 | automatically formats the generated XML data. If enabled, the | - | ||||||||||||||||||||||||||||||
| 3344 | writer automatically adds line-breaks and indentation to empty | - | ||||||||||||||||||||||||||||||
| 3345 | sections between elements (ignorable whitespace). The main purpose | - | ||||||||||||||||||||||||||||||
| 3346 | of auto-formatting is to split the data into several lines, and to | - | ||||||||||||||||||||||||||||||
| 3347 | increase readability for a human reader. The indentation depth can | - | ||||||||||||||||||||||||||||||
| 3348 | be controlled through the \l autoFormattingIndent property. | - | ||||||||||||||||||||||||||||||
| 3349 | - | |||||||||||||||||||||||||||||||
| 3350 | By default, auto-formatting is disabled. | - | ||||||||||||||||||||||||||||||
| 3351 | */ | - | ||||||||||||||||||||||||||||||
| 3352 | - | |||||||||||||||||||||||||||||||
| 3353 | /*! | - | ||||||||||||||||||||||||||||||
| 3354 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 3355 | - | |||||||||||||||||||||||||||||||
| 3356 | Enables auto formatting if \a enable is \c true, otherwise | - | ||||||||||||||||||||||||||||||
| 3357 | disables it. | - | ||||||||||||||||||||||||||||||
| 3358 | - | |||||||||||||||||||||||||||||||
| 3359 | The default value is \c false. | - | ||||||||||||||||||||||||||||||
| 3360 | */ | - | ||||||||||||||||||||||||||||||
| 3361 | void QXmlStreamWriter::setAutoFormatting(bool enable) | - | ||||||||||||||||||||||||||||||
| 3362 | { | - | ||||||||||||||||||||||||||||||
| 3363 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3364 | d->autoFormatting = enable; | - | ||||||||||||||||||||||||||||||
| 3365 | } executed 28 times by 3 tests: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||||||||
| 3366 | - | |||||||||||||||||||||||||||||||
| 3367 | /*! | - | ||||||||||||||||||||||||||||||
| 3368 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 3369 | - | |||||||||||||||||||||||||||||||
| 3370 | Returns \c true if auto formattting is enabled, otherwise \c false. | - | ||||||||||||||||||||||||||||||
| 3371 | */ | - | ||||||||||||||||||||||||||||||
| 3372 | bool QXmlStreamWriter::autoFormatting() const | - | ||||||||||||||||||||||||||||||
| 3373 | { | - | ||||||||||||||||||||||||||||||
| 3374 | Q_D(const QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3375 | return d->autoFormatting; never executed: return d->autoFormatting; | 0 | ||||||||||||||||||||||||||||||
| 3376 | } | - | ||||||||||||||||||||||||||||||
| 3377 | - | |||||||||||||||||||||||||||||||
| 3378 | /*! | - | ||||||||||||||||||||||||||||||
| 3379 | \property QXmlStreamWriter::autoFormattingIndent | - | ||||||||||||||||||||||||||||||
| 3380 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 3381 | - | |||||||||||||||||||||||||||||||
| 3382 | \brief the number of spaces or tabs used for indentation when | - | ||||||||||||||||||||||||||||||
| 3383 | auto-formatting is enabled. Positive numbers indicate spaces, | - | ||||||||||||||||||||||||||||||
| 3384 | negative numbers tabs. | - | ||||||||||||||||||||||||||||||
| 3385 | - | |||||||||||||||||||||||||||||||
| 3386 | The default indentation is 4. | - | ||||||||||||||||||||||||||||||
| 3387 | - | |||||||||||||||||||||||||||||||
| 3388 | \sa autoFormatting | - | ||||||||||||||||||||||||||||||
| 3389 | */ | - | ||||||||||||||||||||||||||||||
| 3390 | - | |||||||||||||||||||||||||||||||
| 3391 | - | |||||||||||||||||||||||||||||||
| 3392 | void QXmlStreamWriter::setAutoFormattingIndent(int spacesOrTabs) | - | ||||||||||||||||||||||||||||||
| 3393 | { | - | ||||||||||||||||||||||||||||||
| 3394 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3395 | d->autoFormattingIndent = QByteArray(qAbs(spacesOrTabs), spacesOrTabs >= 0 ? ' ' : '\t'); | - | ||||||||||||||||||||||||||||||
| 3396 | } executed 21 times by 3 tests: end of blockExecuted by:
| 21 | ||||||||||||||||||||||||||||||
| 3397 | - | |||||||||||||||||||||||||||||||
| 3398 | int QXmlStreamWriter::autoFormattingIndent() const | - | ||||||||||||||||||||||||||||||
| 3399 | { | - | ||||||||||||||||||||||||||||||
| 3400 | Q_D(const QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3401 | return d->autoFormattingIndent.count(' ') - d->autoFormattingIndent.count('\t'); executed 1 time by 1 test: return d->autoFormattingIndent.count(' ') - d->autoFormattingIndent.count('\t');Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3402 | } | - | ||||||||||||||||||||||||||||||
| 3403 | - | |||||||||||||||||||||||||||||||
| 3404 | /*! | - | ||||||||||||||||||||||||||||||
| 3405 | Returns \c true if the stream failed to write to the underlying device. | - | ||||||||||||||||||||||||||||||
| 3406 | - | |||||||||||||||||||||||||||||||
| 3407 | The error status is never reset. Writes happening after the error | - | ||||||||||||||||||||||||||||||
| 3408 | occurred are ignored, even if the error condition is cleared. | - | ||||||||||||||||||||||||||||||
| 3409 | */ | - | ||||||||||||||||||||||||||||||
| 3410 | bool QXmlStreamWriter::hasError() const | - | ||||||||||||||||||||||||||||||
| 3411 | { | - | ||||||||||||||||||||||||||||||
| 3412 | Q_D(const QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3413 | return d->hasError; executed 6 times by 1 test: return d->hasError;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 3414 | } | - | ||||||||||||||||||||||||||||||
| 3415 | - | |||||||||||||||||||||||||||||||
| 3416 | /*! | - | ||||||||||||||||||||||||||||||
| 3417 | \overload | - | ||||||||||||||||||||||||||||||
| 3418 | Writes an attribute with \a qualifiedName and \a value. | - | ||||||||||||||||||||||||||||||
| 3419 | - | |||||||||||||||||||||||||||||||
| 3420 | - | |||||||||||||||||||||||||||||||
| 3421 | This function can only be called after writeStartElement() before | - | ||||||||||||||||||||||||||||||
| 3422 | any content is written, or after writeEmptyElement(). | - | ||||||||||||||||||||||||||||||
| 3423 | */ | - | ||||||||||||||||||||||||||||||
| 3424 | void QXmlStreamWriter::writeAttribute(const QString &qualifiedName, const QString &value) | - | ||||||||||||||||||||||||||||||
| 3425 | { | - | ||||||||||||||||||||||||||||||
| 3426 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3427 | Q_ASSERT(d->inStartElement); | - | ||||||||||||||||||||||||||||||
| 3428 | Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1); | - | ||||||||||||||||||||||||||||||
| 3429 | d->write(" "); | - | ||||||||||||||||||||||||||||||
| 3430 | d->write(qualifiedName); | - | ||||||||||||||||||||||||||||||
| 3431 | d->write("=\""); | - | ||||||||||||||||||||||||||||||
| 3432 | d->writeEscaped(value, true); | - | ||||||||||||||||||||||||||||||
| 3433 | d->write("\""); | - | ||||||||||||||||||||||||||||||
| 3434 | } executed 440 times by 1 test: end of blockExecuted by:
| 440 | ||||||||||||||||||||||||||||||
| 3435 | - | |||||||||||||||||||||||||||||||
| 3436 | /*! Writes an attribute with \a name and \a value, prefixed for | - | ||||||||||||||||||||||||||||||
| 3437 | the specified \a namespaceUri. If the namespace has not been | - | ||||||||||||||||||||||||||||||
| 3438 | declared yet, QXmlStreamWriter will generate a namespace declaration | - | ||||||||||||||||||||||||||||||
| 3439 | for it. | - | ||||||||||||||||||||||||||||||
| 3440 | - | |||||||||||||||||||||||||||||||
| 3441 | This function can only be called after writeStartElement() before | - | ||||||||||||||||||||||||||||||
| 3442 | any content is written, or after writeEmptyElement(). | - | ||||||||||||||||||||||||||||||
| 3443 | */ | - | ||||||||||||||||||||||||||||||
| 3444 | void QXmlStreamWriter::writeAttribute(const QString &namespaceUri, const QString &name, const QString &value) | - | ||||||||||||||||||||||||||||||
| 3445 | { | - | ||||||||||||||||||||||||||||||
| 3446 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3447 | Q_ASSERT(d->inStartElement); | - | ||||||||||||||||||||||||||||||
| 3448 | Q_ASSERT(!name.contains(QLatin1Char(':'))); | - | ||||||||||||||||||||||||||||||
| 3449 | QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->findNamespace(namespaceUri, true, true); | - | ||||||||||||||||||||||||||||||
| 3450 | d->write(" "); | - | ||||||||||||||||||||||||||||||
| 3451 | if (!namespaceDeclaration.prefix.isEmpty()) {
| 0-172 | ||||||||||||||||||||||||||||||
| 3452 | d->write(namespaceDeclaration.prefix); | - | ||||||||||||||||||||||||||||||
| 3453 | d->write(":"); | - | ||||||||||||||||||||||||||||||
| 3454 | } executed 172 times by 3 tests: end of blockExecuted by:
| 172 | ||||||||||||||||||||||||||||||
| 3455 | d->write(name); | - | ||||||||||||||||||||||||||||||
| 3456 | d->write("=\""); | - | ||||||||||||||||||||||||||||||
| 3457 | d->writeEscaped(value, true); | - | ||||||||||||||||||||||||||||||
| 3458 | d->write("\""); | - | ||||||||||||||||||||||||||||||
| 3459 | } executed 172 times by 3 tests: end of blockExecuted by:
| 172 | ||||||||||||||||||||||||||||||
| 3460 | - | |||||||||||||||||||||||||||||||
| 3461 | /*! | - | ||||||||||||||||||||||||||||||
| 3462 | \overload | - | ||||||||||||||||||||||||||||||
| 3463 | - | |||||||||||||||||||||||||||||||
| 3464 | Writes the \a attribute. | - | ||||||||||||||||||||||||||||||
| 3465 | - | |||||||||||||||||||||||||||||||
| 3466 | This function can only be called after writeStartElement() before | - | ||||||||||||||||||||||||||||||
| 3467 | any content is written, or after writeEmptyElement(). | - | ||||||||||||||||||||||||||||||
| 3468 | */ | - | ||||||||||||||||||||||||||||||
| 3469 | void QXmlStreamWriter::writeAttribute(const QXmlStreamAttribute& attribute) | - | ||||||||||||||||||||||||||||||
| 3470 | { | - | ||||||||||||||||||||||||||||||
| 3471 | if (attribute.namespaceUri().isEmpty())
| 34-433 | ||||||||||||||||||||||||||||||
| 3472 | writeAttribute(attribute.qualifiedName().toString(), executed 433 times by 1 test: writeAttribute(attribute.qualifiedName().toString(), attribute.value().toString());Executed by:
| 433 | ||||||||||||||||||||||||||||||
| 3473 | attribute.value().toString()); executed 433 times by 1 test: writeAttribute(attribute.qualifiedName().toString(), attribute.value().toString());Executed by:
| 433 | ||||||||||||||||||||||||||||||
| 3474 | else | - | ||||||||||||||||||||||||||||||
| 3475 | writeAttribute(attribute.namespaceUri().toString(), executed 34 times by 1 test: writeAttribute(attribute.namespaceUri().toString(), attribute.name().toString(), attribute.value().toString());Executed by:
| 34 | ||||||||||||||||||||||||||||||
| 3476 | attribute.name().toString(), executed 34 times by 1 test: writeAttribute(attribute.namespaceUri().toString(), attribute.name().toString(), attribute.value().toString());Executed by:
| 34 | ||||||||||||||||||||||||||||||
| 3477 | attribute.value().toString()); executed 34 times by 1 test: writeAttribute(attribute.namespaceUri().toString(), attribute.name().toString(), attribute.value().toString());Executed by:
| 34 | ||||||||||||||||||||||||||||||
| 3478 | } | - | ||||||||||||||||||||||||||||||
| 3479 | - | |||||||||||||||||||||||||||||||
| 3480 | - | |||||||||||||||||||||||||||||||
| 3481 | /*! Writes the attribute vector \a attributes. If a namespace | - | ||||||||||||||||||||||||||||||
| 3482 | referenced in an attribute not been declared yet, QXmlStreamWriter | - | ||||||||||||||||||||||||||||||
| 3483 | will generate a namespace declaration for it. | - | ||||||||||||||||||||||||||||||
| 3484 | - | |||||||||||||||||||||||||||||||
| 3485 | This function can only be called after writeStartElement() before | - | ||||||||||||||||||||||||||||||
| 3486 | any content is written, or after writeEmptyElement(). | - | ||||||||||||||||||||||||||||||
| 3487 | - | |||||||||||||||||||||||||||||||
| 3488 | \sa writeAttribute(), writeNamespace() | - | ||||||||||||||||||||||||||||||
| 3489 | */ | - | ||||||||||||||||||||||||||||||
| 3490 | void QXmlStreamWriter::writeAttributes(const QXmlStreamAttributes& attributes) | - | ||||||||||||||||||||||||||||||
| 3491 | { | - | ||||||||||||||||||||||||||||||
| 3492 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3493 | Q_ASSERT(d->inStartElement); | - | ||||||||||||||||||||||||||||||
| 3494 | Q_UNUSED(d); | - | ||||||||||||||||||||||||||||||
| 3495 | for (int i = 0; i < attributes.size(); ++i)
| 0-4 | ||||||||||||||||||||||||||||||
| 3496 | writeAttribute(attributes.at(i)); never executed: writeAttribute(attributes.at(i)); | 0 | ||||||||||||||||||||||||||||||
| 3497 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 3498 | - | |||||||||||||||||||||||||||||||
| 3499 | - | |||||||||||||||||||||||||||||||
| 3500 | /*! Writes \a text as CDATA section. If \a text contains the | - | ||||||||||||||||||||||||||||||
| 3501 | forbidden character sequence "]]>", it is split into different CDATA | - | ||||||||||||||||||||||||||||||
| 3502 | sections. | - | ||||||||||||||||||||||||||||||
| 3503 | - | |||||||||||||||||||||||||||||||
| 3504 | This function mainly exists for completeness. Normally you should | - | ||||||||||||||||||||||||||||||
| 3505 | not need use it, because writeCharacters() automatically escapes all | - | ||||||||||||||||||||||||||||||
| 3506 | non-content characters. | - | ||||||||||||||||||||||||||||||
| 3507 | */ | - | ||||||||||||||||||||||||||||||
| 3508 | void QXmlStreamWriter::writeCDATA(const QString &text) | - | ||||||||||||||||||||||||||||||
| 3509 | { | - | ||||||||||||||||||||||||||||||
| 3510 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3511 | d->finishStartElement(); | - | ||||||||||||||||||||||||||||||
| 3512 | QString copy(text); | - | ||||||||||||||||||||||||||||||
| 3513 | copy.replace(QLatin1String("]]>"), QLatin1String("]]]]><![CDATA[>")); | - | ||||||||||||||||||||||||||||||
| 3514 | d->write("<![CDATA["); | - | ||||||||||||||||||||||||||||||
| 3515 | d->write(copy); | - | ||||||||||||||||||||||||||||||
| 3516 | d->write("]]>"); | - | ||||||||||||||||||||||||||||||
| 3517 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3518 | - | |||||||||||||||||||||||||||||||
| 3519 | - | |||||||||||||||||||||||||||||||
| 3520 | /*! Writes \a text. The characters "<", "&", and "\"" are escaped as entity | - | ||||||||||||||||||||||||||||||
| 3521 | references "<", "&, and """. To avoid the forbidden sequence | - | ||||||||||||||||||||||||||||||
| 3522 | "]]>", ">" is also escaped as ">". | - | ||||||||||||||||||||||||||||||
| 3523 | - | |||||||||||||||||||||||||||||||
| 3524 | \sa writeEntityReference() | - | ||||||||||||||||||||||||||||||
| 3525 | */ | - | ||||||||||||||||||||||||||||||
| 3526 | void QXmlStreamWriter::writeCharacters(const QString &text) | - | ||||||||||||||||||||||||||||||
| 3527 | { | - | ||||||||||||||||||||||||||||||
| 3528 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3529 | d->finishStartElement(); | - | ||||||||||||||||||||||||||||||
| 3530 | d->writeEscaped(text); | - | ||||||||||||||||||||||||||||||
| 3531 | } executed 2825 times by 3 tests: end of blockExecuted by:
| 2825 | ||||||||||||||||||||||||||||||
| 3532 | - | |||||||||||||||||||||||||||||||
| 3533 | - | |||||||||||||||||||||||||||||||
| 3534 | /*! Writes \a text as XML comment, where \a text must not contain the | - | ||||||||||||||||||||||||||||||
| 3535 | forbidden sequence "--" or end with "-". Note that XML does not | - | ||||||||||||||||||||||||||||||
| 3536 | provide any way to escape "-" in a comment. | - | ||||||||||||||||||||||||||||||
| 3537 | */ | - | ||||||||||||||||||||||||||||||
| 3538 | void QXmlStreamWriter::writeComment(const QString &text) | - | ||||||||||||||||||||||||||||||
| 3539 | { | - | ||||||||||||||||||||||||||||||
| 3540 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3541 | Q_ASSERT(!text.contains(QLatin1String("--")) && !text.endsWith(QLatin1Char('-'))); | - | ||||||||||||||||||||||||||||||
| 3542 | if (!d->finishStartElement(false) && d->autoFormatting)
| 0-7 | ||||||||||||||||||||||||||||||
| 3543 | d->indent(d->tagStack.size()); executed 7 times by 1 test: d->indent(d->tagStack.size());Executed by:
| 7 | ||||||||||||||||||||||||||||||
| 3544 | d->write("<!--"); | - | ||||||||||||||||||||||||||||||
| 3545 | d->write(text); | - | ||||||||||||||||||||||||||||||
| 3546 | d->write("-->"); | - | ||||||||||||||||||||||||||||||
| 3547 | d->inStartElement = d->lastWasStartElement = false; | - | ||||||||||||||||||||||||||||||
| 3548 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||||||||
| 3549 | - | |||||||||||||||||||||||||||||||
| 3550 | - | |||||||||||||||||||||||||||||||
| 3551 | /*! Writes a DTD section. The \a dtd represents the entire | - | ||||||||||||||||||||||||||||||
| 3552 | doctypedecl production from the XML 1.0 specification. | - | ||||||||||||||||||||||||||||||
| 3553 | */ | - | ||||||||||||||||||||||||||||||
| 3554 | void QXmlStreamWriter::writeDTD(const QString &dtd) | - | ||||||||||||||||||||||||||||||
| 3555 | { | - | ||||||||||||||||||||||||||||||
| 3556 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3557 | d->finishStartElement(); | - | ||||||||||||||||||||||||||||||
| 3558 | if (d->autoFormatting)
| 0-46 | ||||||||||||||||||||||||||||||
| 3559 | d->write("\n"); never executed: d->write("\n"); | 0 | ||||||||||||||||||||||||||||||
| 3560 | d->write(dtd); | - | ||||||||||||||||||||||||||||||
| 3561 | if (d->autoFormatting)
| 0-46 | ||||||||||||||||||||||||||||||
| 3562 | d->write("\n"); never executed: d->write("\n"); | 0 | ||||||||||||||||||||||||||||||
| 3563 | } executed 46 times by 1 test: end of blockExecuted by:
| 46 | ||||||||||||||||||||||||||||||
| 3564 | - | |||||||||||||||||||||||||||||||
| 3565 | - | |||||||||||||||||||||||||||||||
| 3566 | - | |||||||||||||||||||||||||||||||
| 3567 | /*! \overload | - | ||||||||||||||||||||||||||||||
| 3568 | Writes an empty element with qualified name \a qualifiedName. | - | ||||||||||||||||||||||||||||||
| 3569 | Subsequent calls to writeAttribute() will add attributes to this element. | - | ||||||||||||||||||||||||||||||
| 3570 | */ | - | ||||||||||||||||||||||||||||||
| 3571 | void QXmlStreamWriter::writeEmptyElement(const QString &qualifiedName) | - | ||||||||||||||||||||||||||||||
| 3572 | { | - | ||||||||||||||||||||||||||||||
| 3573 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3574 | Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1); | - | ||||||||||||||||||||||||||||||
| 3575 | d->writeStartElement(QString(), qualifiedName); | - | ||||||||||||||||||||||||||||||
| 3576 | d->inEmptyElement = true; | - | ||||||||||||||||||||||||||||||
| 3577 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||||||||
| 3578 | - | |||||||||||||||||||||||||||||||
| 3579 | - | |||||||||||||||||||||||||||||||
| 3580 | /*! Writes an empty element with \a name, prefixed for the specified | - | ||||||||||||||||||||||||||||||
| 3581 | \a namespaceUri. If the namespace has not been declared, | - | ||||||||||||||||||||||||||||||
| 3582 | QXmlStreamWriter will generate a namespace declaration for it. | - | ||||||||||||||||||||||||||||||
| 3583 | Subsequent calls to writeAttribute() will add attributes to this element. | - | ||||||||||||||||||||||||||||||
| 3584 | - | |||||||||||||||||||||||||||||||
| 3585 | \sa writeNamespace() | - | ||||||||||||||||||||||||||||||
| 3586 | */ | - | ||||||||||||||||||||||||||||||
| 3587 | void QXmlStreamWriter::writeEmptyElement(const QString &namespaceUri, const QString &name) | - | ||||||||||||||||||||||||||||||
| 3588 | { | - | ||||||||||||||||||||||||||||||
| 3589 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3590 | Q_ASSERT(!name.contains(QLatin1Char(':'))); | - | ||||||||||||||||||||||||||||||
| 3591 | d->writeStartElement(namespaceUri, name); | - | ||||||||||||||||||||||||||||||
| 3592 | d->inEmptyElement = true; | - | ||||||||||||||||||||||||||||||
| 3593 | } executed 34 times by 2 tests: end of blockExecuted by:
| 34 | ||||||||||||||||||||||||||||||
| 3594 | - | |||||||||||||||||||||||||||||||
| 3595 | - | |||||||||||||||||||||||||||||||
| 3596 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 3597 | Writes a text element with \a qualifiedName and \a text. | - | ||||||||||||||||||||||||||||||
| 3598 | - | |||||||||||||||||||||||||||||||
| 3599 | - | |||||||||||||||||||||||||||||||
| 3600 | This is a convenience function equivalent to: | - | ||||||||||||||||||||||||||||||
| 3601 | \snippet code/src_corelib_xml_qxmlstream.cpp 1 | - | ||||||||||||||||||||||||||||||
| 3602 | - | |||||||||||||||||||||||||||||||
| 3603 | */ | - | ||||||||||||||||||||||||||||||
| 3604 | void QXmlStreamWriter::writeTextElement(const QString &qualifiedName, const QString &text) | - | ||||||||||||||||||||||||||||||
| 3605 | { | - | ||||||||||||||||||||||||||||||
| 3606 | writeStartElement(qualifiedName); | - | ||||||||||||||||||||||||||||||
| 3607 | writeCharacters(text); | - | ||||||||||||||||||||||||||||||
| 3608 | writeEndElement(); | - | ||||||||||||||||||||||||||||||
| 3609 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 3610 | - | |||||||||||||||||||||||||||||||
| 3611 | /*! Writes a text element with \a name, prefixed for the specified \a | - | ||||||||||||||||||||||||||||||
| 3612 | namespaceUri, and \a text. If the namespace has not been | - | ||||||||||||||||||||||||||||||
| 3613 | declared, QXmlStreamWriter will generate a namespace declaration | - | ||||||||||||||||||||||||||||||
| 3614 | for it. | - | ||||||||||||||||||||||||||||||
| 3615 | - | |||||||||||||||||||||||||||||||
| 3616 | - | |||||||||||||||||||||||||||||||
| 3617 | This is a convenience function equivalent to: | - | ||||||||||||||||||||||||||||||
| 3618 | \snippet code/src_corelib_xml_qxmlstream.cpp 2 | - | ||||||||||||||||||||||||||||||
| 3619 | - | |||||||||||||||||||||||||||||||
| 3620 | */ | - | ||||||||||||||||||||||||||||||
| 3621 | void QXmlStreamWriter::writeTextElement(const QString &namespaceUri, const QString &name, const QString &text) | - | ||||||||||||||||||||||||||||||
| 3622 | { | - | ||||||||||||||||||||||||||||||
| 3623 | writeStartElement(namespaceUri, name); | - | ||||||||||||||||||||||||||||||
| 3624 | writeCharacters(text); | - | ||||||||||||||||||||||||||||||
| 3625 | writeEndElement(); | - | ||||||||||||||||||||||||||||||
| 3626 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3627 | - | |||||||||||||||||||||||||||||||
| 3628 | - | |||||||||||||||||||||||||||||||
| 3629 | /*! | - | ||||||||||||||||||||||||||||||
| 3630 | Closes all remaining open start elements and writes a newline. | - | ||||||||||||||||||||||||||||||
| 3631 | - | |||||||||||||||||||||||||||||||
| 3632 | \sa writeStartDocument() | - | ||||||||||||||||||||||||||||||
| 3633 | */ | - | ||||||||||||||||||||||||||||||
| 3634 | void QXmlStreamWriter::writeEndDocument() | - | ||||||||||||||||||||||||||||||
| 3635 | { | - | ||||||||||||||||||||||||||||||
| 3636 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3637 | while (d->tagStack.size())
| 14-33 | ||||||||||||||||||||||||||||||
| 3638 | writeEndElement(); executed 14 times by 3 tests: writeEndElement();Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 3639 | d->write("\n"); | - | ||||||||||||||||||||||||||||||
| 3640 | } executed 33 times by 3 tests: end of blockExecuted by:
| 33 | ||||||||||||||||||||||||||||||
| 3641 | - | |||||||||||||||||||||||||||||||
| 3642 | /*! | - | ||||||||||||||||||||||||||||||
| 3643 | Closes the previous start element. | - | ||||||||||||||||||||||||||||||
| 3644 | - | |||||||||||||||||||||||||||||||
| 3645 | \sa writeStartElement() | - | ||||||||||||||||||||||||||||||
| 3646 | */ | - | ||||||||||||||||||||||||||||||
| 3647 | void QXmlStreamWriter::writeEndElement() | - | ||||||||||||||||||||||||||||||
| 3648 | { | - | ||||||||||||||||||||||||||||||
| 3649 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3650 | if (d->tagStack.isEmpty())
| 1-1255 | ||||||||||||||||||||||||||||||
| 3651 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3652 | - | |||||||||||||||||||||||||||||||
| 3653 | // shortcut: if nothing was written, close as empty tag | - | ||||||||||||||||||||||||||||||
| 3654 | if (d->inStartElement && !d->inEmptyElement) {
| 14-1213 | ||||||||||||||||||||||||||||||
| 3655 | d->write("/>"); | - | ||||||||||||||||||||||||||||||
| 3656 | d->lastWasStartElement = d->inStartElement = false; | - | ||||||||||||||||||||||||||||||
| 3657 | QXmlStreamWriterPrivate::Tag &tag = d->tagStack_pop(); | - | ||||||||||||||||||||||||||||||
| 3658 | d->lastNamespaceDeclaration = tag.namespaceDeclarationsSize; | - | ||||||||||||||||||||||||||||||
| 3659 | return; executed 14 times by 3 tests: return;Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 3660 | } | - | ||||||||||||||||||||||||||||||
| 3661 | - | |||||||||||||||||||||||||||||||
| 3662 | if (!d->finishStartElement(false) && !d->lastWasStartElement && d->autoFormatting)
| 7-1096 | ||||||||||||||||||||||||||||||
| 3663 | d->indent(d->tagStack.size()-1); executed 77 times by 3 tests: d->indent(d->tagStack.size()-1);Executed by:
| 77 | ||||||||||||||||||||||||||||||
| 3664 | if (d->tagStack.isEmpty())
| 4-1237 | ||||||||||||||||||||||||||||||
| 3665 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 3666 | d->lastWasStartElement = false; | - | ||||||||||||||||||||||||||||||
| 3667 | QXmlStreamWriterPrivate::Tag &tag = d->tagStack_pop(); | - | ||||||||||||||||||||||||||||||
| 3668 | d->lastNamespaceDeclaration = tag.namespaceDeclarationsSize; | - | ||||||||||||||||||||||||||||||
| 3669 | d->write("</"); | - | ||||||||||||||||||||||||||||||
| 3670 | if (!tag.namespaceDeclaration.prefix.isEmpty()) {
| 105-1132 | ||||||||||||||||||||||||||||||
| 3671 | d->write(tag.namespaceDeclaration.prefix); | - | ||||||||||||||||||||||||||||||
| 3672 | d->write(":"); | - | ||||||||||||||||||||||||||||||
| 3673 | } executed 105 times by 3 tests: end of blockExecuted by:
| 105 | ||||||||||||||||||||||||||||||
| 3674 | d->write(tag.name); | - | ||||||||||||||||||||||||||||||
| 3675 | d->write(">"); | - | ||||||||||||||||||||||||||||||
| 3676 | } executed 1237 times by 3 tests: end of blockExecuted by:
| 1237 | ||||||||||||||||||||||||||||||
| 3677 | - | |||||||||||||||||||||||||||||||
| 3678 | - | |||||||||||||||||||||||||||||||
| 3679 | - | |||||||||||||||||||||||||||||||
| 3680 | /*! | - | ||||||||||||||||||||||||||||||
| 3681 | Writes the entity reference \a name to the stream, as "&\a{name};". | - | ||||||||||||||||||||||||||||||
| 3682 | */ | - | ||||||||||||||||||||||||||||||
| 3683 | void QXmlStreamWriter::writeEntityReference(const QString &name) | - | ||||||||||||||||||||||||||||||
| 3684 | { | - | ||||||||||||||||||||||||||||||
| 3685 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3686 | d->finishStartElement(); | - | ||||||||||||||||||||||||||||||
| 3687 | d->write("&"); | - | ||||||||||||||||||||||||||||||
| 3688 | d->write(name); | - | ||||||||||||||||||||||||||||||
| 3689 | d->write(";"); | - | ||||||||||||||||||||||||||||||
| 3690 | } executed 857 times by 1 test: end of blockExecuted by:
| 857 | ||||||||||||||||||||||||||||||
| 3691 | - | |||||||||||||||||||||||||||||||
| 3692 | - | |||||||||||||||||||||||||||||||
| 3693 | /*! Writes a namespace declaration for \a namespaceUri with \a | - | ||||||||||||||||||||||||||||||
| 3694 | prefix. If \a prefix is empty, QXmlStreamWriter assigns a unique | - | ||||||||||||||||||||||||||||||
| 3695 | prefix consisting of the letter 'n' followed by a number. | - | ||||||||||||||||||||||||||||||
| 3696 | - | |||||||||||||||||||||||||||||||
| 3697 | If writeStartElement() or writeEmptyElement() was called, the | - | ||||||||||||||||||||||||||||||
| 3698 | declaration applies to the current element; otherwise it applies to | - | ||||||||||||||||||||||||||||||
| 3699 | the next child element. | - | ||||||||||||||||||||||||||||||
| 3700 | - | |||||||||||||||||||||||||||||||
| 3701 | Note that the prefix \e xml is both predefined and reserved for | - | ||||||||||||||||||||||||||||||
| 3702 | \e http://www.w3.org/XML/1998/namespace, which in turn cannot be | - | ||||||||||||||||||||||||||||||
| 3703 | bound to any other prefix. The prefix \e xmlns and its URI | - | ||||||||||||||||||||||||||||||
| 3704 | \e http://www.w3.org/2000/xmlns/ are used for the namespace mechanism | - | ||||||||||||||||||||||||||||||
| 3705 | itself and thus completely forbidden in declarations. | - | ||||||||||||||||||||||||||||||
| 3706 | - | |||||||||||||||||||||||||||||||
| 3707 | */ | - | ||||||||||||||||||||||||||||||
| 3708 | void QXmlStreamWriter::writeNamespace(const QString &namespaceUri, const QString &prefix) | - | ||||||||||||||||||||||||||||||
| 3709 | { | - | ||||||||||||||||||||||||||||||
| 3710 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3711 | Q_ASSERT(!namespaceUri.isEmpty()); | - | ||||||||||||||||||||||||||||||
| 3712 | Q_ASSERT(prefix != QLatin1String("xmlns")); | - | ||||||||||||||||||||||||||||||
| 3713 | if (prefix.isEmpty()) {
| 0-83 | ||||||||||||||||||||||||||||||
| 3714 | d->findNamespace(namespaceUri, d->inStartElement); | - | ||||||||||||||||||||||||||||||
| 3715 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3716 | Q_ASSERT(!((prefix == QLatin1String("xml")) ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))); | - | ||||||||||||||||||||||||||||||
| 3717 | Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/2000/xmlns/")); | - | ||||||||||||||||||||||||||||||
| 3718 | QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 3719 | namespaceDeclaration.prefix = d->addToStringStorage(prefix); | - | ||||||||||||||||||||||||||||||
| 3720 | namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3721 | if (d->inStartElement)
| 2-81 | ||||||||||||||||||||||||||||||
| 3722 | d->writeNamespaceDeclaration(namespaceDeclaration); executed 2 times by 1 test: d->writeNamespaceDeclaration(namespaceDeclaration);Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3723 | } executed 83 times by 3 tests: end of blockExecuted by:
| 83 | ||||||||||||||||||||||||||||||
| 3724 | } | - | ||||||||||||||||||||||||||||||
| 3725 | - | |||||||||||||||||||||||||||||||
| 3726 | - | |||||||||||||||||||||||||||||||
| 3727 | /*! Writes a default namespace declaration for \a namespaceUri. | - | ||||||||||||||||||||||||||||||
| 3728 | - | |||||||||||||||||||||||||||||||
| 3729 | If writeStartElement() or writeEmptyElement() was called, the | - | ||||||||||||||||||||||||||||||
| 3730 | declaration applies to the current element; otherwise it applies to | - | ||||||||||||||||||||||||||||||
| 3731 | the next child element. | - | ||||||||||||||||||||||||||||||
| 3732 | - | |||||||||||||||||||||||||||||||
| 3733 | Note that the namespaces \e http://www.w3.org/XML/1998/namespace | - | ||||||||||||||||||||||||||||||
| 3734 | (bound to \e xmlns) and \e http://www.w3.org/2000/xmlns/ (bound to | - | ||||||||||||||||||||||||||||||
| 3735 | \e xml) by definition cannot be declared as default. | - | ||||||||||||||||||||||||||||||
| 3736 | */ | - | ||||||||||||||||||||||||||||||
| 3737 | void QXmlStreamWriter::writeDefaultNamespace(const QString &namespaceUri) | - | ||||||||||||||||||||||||||||||
| 3738 | { | - | ||||||||||||||||||||||||||||||
| 3739 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3740 | Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/XML/1998/namespace")); | - | ||||||||||||||||||||||||||||||
| 3741 | Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/2000/xmlns/")); | - | ||||||||||||||||||||||||||||||
| 3742 | QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 3743 | namespaceDeclaration.prefix.clear(); | - | ||||||||||||||||||||||||||||||
| 3744 | namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3745 | if (d->inStartElement)
| 0 | ||||||||||||||||||||||||||||||
| 3746 | d->writeNamespaceDeclaration(namespaceDeclaration); never executed: d->writeNamespaceDeclaration(namespaceDeclaration); | 0 | ||||||||||||||||||||||||||||||
| 3747 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3748 | - | |||||||||||||||||||||||||||||||
| 3749 | - | |||||||||||||||||||||||||||||||
| 3750 | /*! | - | ||||||||||||||||||||||||||||||
| 3751 | Writes an XML processing instruction with \a target and \a data, | - | ||||||||||||||||||||||||||||||
| 3752 | where \a data must not contain the sequence "?>". | - | ||||||||||||||||||||||||||||||
| 3753 | */ | - | ||||||||||||||||||||||||||||||
| 3754 | void QXmlStreamWriter::writeProcessingInstruction(const QString &target, const QString &data) | - | ||||||||||||||||||||||||||||||
| 3755 | { | - | ||||||||||||||||||||||||||||||
| 3756 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3757 | Q_ASSERT(!data.contains(QLatin1String("?>"))); | - | ||||||||||||||||||||||||||||||
| 3758 | if (!d->finishStartElement(false) && d->autoFormatting)
| 1-61 | ||||||||||||||||||||||||||||||
| 3759 | d->indent(d->tagStack.size()); executed 1 time by 1 test: d->indent(d->tagStack.size());Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3760 | d->write("<?"); | - | ||||||||||||||||||||||||||||||
| 3761 | d->write(target); | - | ||||||||||||||||||||||||||||||
| 3762 | if (!data.isNull()) {
| 0-72 | ||||||||||||||||||||||||||||||
| 3763 | d->write(" "); | - | ||||||||||||||||||||||||||||||
| 3764 | d->write(data); | - | ||||||||||||||||||||||||||||||
| 3765 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||||||||||||||
| 3766 | d->write("?>"); | - | ||||||||||||||||||||||||||||||
| 3767 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||||||||||||||
| 3768 | - | |||||||||||||||||||||||||||||||
| 3769 | - | |||||||||||||||||||||||||||||||
| 3770 | - | |||||||||||||||||||||||||||||||
| 3771 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 3772 | - | |||||||||||||||||||||||||||||||
| 3773 | Writes a document start with XML version number "1.0". This also | - | ||||||||||||||||||||||||||||||
| 3774 | writes the encoding information. | - | ||||||||||||||||||||||||||||||
| 3775 | - | |||||||||||||||||||||||||||||||
| 3776 | \sa writeEndDocument(), setCodec() | - | ||||||||||||||||||||||||||||||
| 3777 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 3778 | */ | - | ||||||||||||||||||||||||||||||
| 3779 | void QXmlStreamWriter::writeStartDocument() | - | ||||||||||||||||||||||||||||||
| 3780 | { | - | ||||||||||||||||||||||||||||||
| 3781 | writeStartDocument(QLatin1String("1.0")); | - | ||||||||||||||||||||||||||||||
| 3782 | } executed 34 times by 3 tests: end of blockExecuted by:
| 34 | ||||||||||||||||||||||||||||||
| 3783 | - | |||||||||||||||||||||||||||||||
| 3784 | - | |||||||||||||||||||||||||||||||
| 3785 | /*! | - | ||||||||||||||||||||||||||||||
| 3786 | Writes a document start with the XML version number \a version. | - | ||||||||||||||||||||||||||||||
| 3787 | - | |||||||||||||||||||||||||||||||
| 3788 | \sa writeEndDocument() | - | ||||||||||||||||||||||||||||||
| 3789 | */ | - | ||||||||||||||||||||||||||||||
| 3790 | void QXmlStreamWriter::writeStartDocument(const QString &version) | - | ||||||||||||||||||||||||||||||
| 3791 | { | - | ||||||||||||||||||||||||||||||
| 3792 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3793 | d->finishStartElement(false); | - | ||||||||||||||||||||||||||||||
| 3794 | d->write("<?xml version=\""); | - | ||||||||||||||||||||||||||||||
| 3795 | d->write(version); | - | ||||||||||||||||||||||||||||||
| 3796 | if (d->device) { // stringDevice does not get any encoding
| 2-35 | ||||||||||||||||||||||||||||||
| 3797 | d->write("\" encoding=\""); | - | ||||||||||||||||||||||||||||||
| 3798 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3799 | d->write("iso-8859-1"); | - | ||||||||||||||||||||||||||||||
| 3800 | #else | - | ||||||||||||||||||||||||||||||
| 3801 | const QByteArray name = d->codec->name(); | - | ||||||||||||||||||||||||||||||
| 3802 | d->write(name.constData(), name.length()); | - | ||||||||||||||||||||||||||||||
| 3803 | #endif | - | ||||||||||||||||||||||||||||||
| 3804 | } executed 35 times by 3 tests: end of blockExecuted by:
| 35 | ||||||||||||||||||||||||||||||
| 3805 | d->write("\"?>"); | - | ||||||||||||||||||||||||||||||
| 3806 | } executed 37 times by 3 tests: end of blockExecuted by:
| 37 | ||||||||||||||||||||||||||||||
| 3807 | - | |||||||||||||||||||||||||||||||
| 3808 | /*! Writes a document start with the XML version number \a version | - | ||||||||||||||||||||||||||||||
| 3809 | and a standalone attribute \a standalone. | - | ||||||||||||||||||||||||||||||
| 3810 | - | |||||||||||||||||||||||||||||||
| 3811 | \sa writeEndDocument() | - | ||||||||||||||||||||||||||||||
| 3812 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 3813 | */ | - | ||||||||||||||||||||||||||||||
| 3814 | void QXmlStreamWriter::writeStartDocument(const QString &version, bool standalone) | - | ||||||||||||||||||||||||||||||
| 3815 | { | - | ||||||||||||||||||||||||||||||
| 3816 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3817 | d->finishStartElement(false); | - | ||||||||||||||||||||||||||||||
| 3818 | d->write("<?xml version=\""); | - | ||||||||||||||||||||||||||||||
| 3819 | d->write(version); | - | ||||||||||||||||||||||||||||||
| 3820 | if (d->device) { // stringDevice does not get any encoding
| 0-2 | ||||||||||||||||||||||||||||||
| 3821 | d->write("\" encoding=\""); | - | ||||||||||||||||||||||||||||||
| 3822 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3823 | d->write("iso-8859-1"); | - | ||||||||||||||||||||||||||||||
| 3824 | #else | - | ||||||||||||||||||||||||||||||
| 3825 | const QByteArray name = d->codec->name(); | - | ||||||||||||||||||||||||||||||
| 3826 | d->write(name.constData(), name.length()); | - | ||||||||||||||||||||||||||||||
| 3827 | #endif | - | ||||||||||||||||||||||||||||||
| 3828 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 3829 | if (standalone)
| 1 | ||||||||||||||||||||||||||||||
| 3830 | d->write("\" standalone=\"yes\"?>"); executed 1 time by 1 test: d->write("\" standalone=\"yes\"?>");Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3831 | else | - | ||||||||||||||||||||||||||||||
| 3832 | d->write("\" standalone=\"no\"?>"); executed 1 time by 1 test: d->write("\" standalone=\"no\"?>");Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3833 | } | - | ||||||||||||||||||||||||||||||
| 3834 | - | |||||||||||||||||||||||||||||||
| 3835 | - | |||||||||||||||||||||||||||||||
| 3836 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 3837 | - | |||||||||||||||||||||||||||||||
| 3838 | Writes a start element with \a qualifiedName. Subsequent calls to | - | ||||||||||||||||||||||||||||||
| 3839 | writeAttribute() will add attributes to this element. | - | ||||||||||||||||||||||||||||||
| 3840 | - | |||||||||||||||||||||||||||||||
| 3841 | \sa writeEndElement(), writeEmptyElement() | - | ||||||||||||||||||||||||||||||
| 3842 | */ | - | ||||||||||||||||||||||||||||||
| 3843 | void QXmlStreamWriter::writeStartElement(const QString &qualifiedName) | - | ||||||||||||||||||||||||||||||
| 3844 | { | - | ||||||||||||||||||||||||||||||
| 3845 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3846 | Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1); | - | ||||||||||||||||||||||||||||||
| 3847 | d->writeStartElement(QString(), qualifiedName); | - | ||||||||||||||||||||||||||||||
| 3848 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 3849 | - | |||||||||||||||||||||||||||||||
| 3850 | - | |||||||||||||||||||||||||||||||
| 3851 | /*! Writes a start element with \a name, prefixed for the specified | - | ||||||||||||||||||||||||||||||
| 3852 | \a namespaceUri. If the namespace has not been declared yet, | - | ||||||||||||||||||||||||||||||
| 3853 | QXmlStreamWriter will generate a namespace declaration for | - | ||||||||||||||||||||||||||||||
| 3854 | it. Subsequent calls to writeAttribute() will add attributes to this | - | ||||||||||||||||||||||||||||||
| 3855 | element. | - | ||||||||||||||||||||||||||||||
| 3856 | - | |||||||||||||||||||||||||||||||
| 3857 | \sa writeNamespace(), writeEndElement(), writeEmptyElement() | - | ||||||||||||||||||||||||||||||
| 3858 | */ | - | ||||||||||||||||||||||||||||||
| 3859 | void QXmlStreamWriter::writeStartElement(const QString &namespaceUri, const QString &name) | - | ||||||||||||||||||||||||||||||
| 3860 | { | - | ||||||||||||||||||||||||||||||
| 3861 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3862 | Q_ASSERT(!name.contains(QLatin1Char(':'))); | - | ||||||||||||||||||||||||||||||
| 3863 | d->writeStartElement(namespaceUri, name); | - | ||||||||||||||||||||||||||||||
| 3864 | } executed 1243 times by 3 tests: end of blockExecuted by:
| 1243 | ||||||||||||||||||||||||||||||
| 3865 | - | |||||||||||||||||||||||||||||||
| 3866 | void QXmlStreamWriterPrivate::writeStartElement(const QString &namespaceUri, const QString &name) | - | ||||||||||||||||||||||||||||||
| 3867 | { | - | ||||||||||||||||||||||||||||||
| 3868 | if (!finishStartElement(false) && autoFormatting)
| 133-845 | ||||||||||||||||||||||||||||||
| 3869 | indent(tagStack.size()); executed 133 times by 3 tests: indent(tagStack.size());Executed by:
| 133 | ||||||||||||||||||||||||||||||
| 3870 | - | |||||||||||||||||||||||||||||||
| 3871 | Tag &tag = tagStack_push(); | - | ||||||||||||||||||||||||||||||
| 3872 | tag.name = addToStringStorage(name); | - | ||||||||||||||||||||||||||||||
| 3873 | tag.namespaceDeclaration = findNamespace(namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3874 | write("<"); | - | ||||||||||||||||||||||||||||||
| 3875 | if (!tag.namespaceDeclaration.prefix.isEmpty()) {
| 149-1143 | ||||||||||||||||||||||||||||||
| 3876 | write(tag.namespaceDeclaration.prefix); | - | ||||||||||||||||||||||||||||||
| 3877 | write(":"); | - | ||||||||||||||||||||||||||||||
| 3878 | } executed 149 times by 3 tests: end of blockExecuted by:
| 149 | ||||||||||||||||||||||||||||||
| 3879 | write(tag.name); | - | ||||||||||||||||||||||||||||||
| 3880 | inStartElement = lastWasStartElement = true; | - | ||||||||||||||||||||||||||||||
| 3881 | - | |||||||||||||||||||||||||||||||
| 3882 | for (int i = lastNamespaceDeclaration; i < namespaceDeclarations.size(); ++i)
| 96-1292 | ||||||||||||||||||||||||||||||
| 3883 | writeNamespaceDeclaration(namespaceDeclarations[i]); executed 96 times by 3 tests: writeNamespaceDeclaration(namespaceDeclarations[i]);Executed by:
| 96 | ||||||||||||||||||||||||||||||
| 3884 | tag.namespaceDeclarationsSize = lastNamespaceDeclaration; | - | ||||||||||||||||||||||||||||||
| 3885 | } executed 1292 times by 3 tests: end of blockExecuted by:
| 1292 | ||||||||||||||||||||||||||||||
| 3886 | - | |||||||||||||||||||||||||||||||
| 3887 | #ifndef QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 3888 | /*! Writes the current state of the \a reader. All possible valid | - | ||||||||||||||||||||||||||||||
| 3889 | states are supported. | - | ||||||||||||||||||||||||||||||
| 3890 | - | |||||||||||||||||||||||||||||||
| 3891 | The purpose of this function is to support chained processing of XML data. | - | ||||||||||||||||||||||||||||||
| 3892 | - | |||||||||||||||||||||||||||||||
| 3893 | \sa QXmlStreamReader::tokenType() | - | ||||||||||||||||||||||||||||||
| 3894 | */ | - | ||||||||||||||||||||||||||||||
| 3895 | void QXmlStreamWriter::writeCurrentToken(const QXmlStreamReader &reader) | - | ||||||||||||||||||||||||||||||
| 3896 | { | - | ||||||||||||||||||||||||||||||
| 3897 | switch (reader.tokenType()) { | - | ||||||||||||||||||||||||||||||
| 3898 | case QXmlStreamReader::NoToken: never executed: case QXmlStreamReader::NoToken: | 0 | ||||||||||||||||||||||||||||||
| 3899 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 3900 | case QXmlStreamReader::StartDocument: executed 2 times by 1 test: case QXmlStreamReader::StartDocument:Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3901 | writeStartDocument(); | - | ||||||||||||||||||||||||||||||
| 3902 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3903 | case QXmlStreamReader::EndDocument: executed 2 times by 1 test: case QXmlStreamReader::EndDocument:Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3904 | writeEndDocument(); | - | ||||||||||||||||||||||||||||||
| 3905 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3906 | case QXmlStreamReader::StartElement: { executed 4 times by 1 test: case QXmlStreamReader::StartElement:Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 3907 | QXmlStreamNamespaceDeclarations namespaceDeclarations = reader.namespaceDeclarations(); | - | ||||||||||||||||||||||||||||||
| 3908 | for (int i = 0; i < namespaceDeclarations.size(); ++i) {
| 0-4 | ||||||||||||||||||||||||||||||
| 3909 | const QXmlStreamNamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(i); | - | ||||||||||||||||||||||||||||||
| 3910 | writeNamespace(namespaceDeclaration.namespaceUri().toString(), | - | ||||||||||||||||||||||||||||||
| 3911 | namespaceDeclaration.prefix().toString()); | - | ||||||||||||||||||||||||||||||
| 3912 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3913 | writeStartElement(reader.namespaceUri().toString(), reader.name().toString()); | - | ||||||||||||||||||||||||||||||
| 3914 | writeAttributes(reader.attributes()); | - | ||||||||||||||||||||||||||||||
| 3915 | } break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 3916 | case QXmlStreamReader::EndElement: executed 1144 times by 1 test: case QXmlStreamReader::EndElement:Executed by:
| 1144 | ||||||||||||||||||||||||||||||
| 3917 | writeEndElement(); | - | ||||||||||||||||||||||||||||||
| 3918 | break; executed 1144 times by 1 test: break;Executed by:
| 1144 | ||||||||||||||||||||||||||||||
| 3919 | case QXmlStreamReader::Characters: never executed: case QXmlStreamReader::Characters: | 0 | ||||||||||||||||||||||||||||||
| 3920 | if (reader.isCDATA())
| 0 | ||||||||||||||||||||||||||||||
| 3921 | writeCDATA(reader.text().toString()); never executed: writeCDATA(reader.text().toString()); | 0 | ||||||||||||||||||||||||||||||
| 3922 | else | - | ||||||||||||||||||||||||||||||
| 3923 | writeCharacters(reader.text().toString()); never executed: writeCharacters(reader.text().toString()); | 0 | ||||||||||||||||||||||||||||||
| 3924 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 3925 | case QXmlStreamReader::Comment: executed 6 times by 1 test: case QXmlStreamReader::Comment:Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 3926 | writeComment(reader.text().toString()); | - | ||||||||||||||||||||||||||||||
| 3927 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 3928 | case QXmlStreamReader::DTD: never executed: case QXmlStreamReader::DTD: | 0 | ||||||||||||||||||||||||||||||
| 3929 | writeDTD(reader.text().toString()); | - | ||||||||||||||||||||||||||||||
| 3930 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 3931 | case QXmlStreamReader::EntityReference: executed 1 time by 1 test: case QXmlStreamReader::EntityReference:Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3932 | writeEntityReference(reader.name().toString()); | - | ||||||||||||||||||||||||||||||
| 3933 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3934 | case QXmlStreamReader::ProcessingInstruction: executed 48 times by 1 test: case QXmlStreamReader::ProcessingInstruction:Executed by:
| 48 | ||||||||||||||||||||||||||||||
| 3935 | writeProcessingInstruction(reader.processingInstructionTarget().toString(), | - | ||||||||||||||||||||||||||||||
| 3936 | reader.processingInstructionData().toString()); | - | ||||||||||||||||||||||||||||||
| 3937 | break; executed 48 times by 1 test: break;Executed by:
| 48 | ||||||||||||||||||||||||||||||
| 3938 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 3939 | Q_ASSERT(reader.tokenType() != QXmlStreamReader::Invalid); | - | ||||||||||||||||||||||||||||||
| 3940 | qWarning("QXmlStreamWriter: writeCurrentToken() with invalid state."); | - | ||||||||||||||||||||||||||||||
| 3941 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 3942 | } | - | ||||||||||||||||||||||||||||||
| 3943 | } | - | ||||||||||||||||||||||||||||||
| 3944 | - | |||||||||||||||||||||||||||||||
| 3945 | /*! | - | ||||||||||||||||||||||||||||||
| 3946 | \fn bool QXmlStreamAttributes::hasAttribute(const QString &qualifiedName) const | - | ||||||||||||||||||||||||||||||
| 3947 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 3948 | - | |||||||||||||||||||||||||||||||
| 3949 | Returns \c true if this QXmlStreamAttributes has an attribute whose | - | ||||||||||||||||||||||||||||||
| 3950 | qualified name is \a qualifiedName; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 3951 | - | |||||||||||||||||||||||||||||||
| 3952 | Note that this is not namespace aware. For instance, if this | - | ||||||||||||||||||||||||||||||
| 3953 | QXmlStreamAttributes contains an attribute whose lexical name is "xlink:href" | - | ||||||||||||||||||||||||||||||
| 3954 | this doesn't tell that an attribute named \c href in the XLink namespace is | - | ||||||||||||||||||||||||||||||
| 3955 | present, since the \c xlink prefix can be bound to any namespace. Use the | - | ||||||||||||||||||||||||||||||
| 3956 | overload that takes a namespace URI and a local name as parameter, for | - | ||||||||||||||||||||||||||||||
| 3957 | namespace aware code. | - | ||||||||||||||||||||||||||||||
| 3958 | */ | - | ||||||||||||||||||||||||||||||
| 3959 | - | |||||||||||||||||||||||||||||||
| 3960 | /*! | - | ||||||||||||||||||||||||||||||
| 3961 | \fn bool QXmlStreamAttributes::hasAttribute(QLatin1String qualifiedName) const | - | ||||||||||||||||||||||||||||||
| 3962 | \overload | - | ||||||||||||||||||||||||||||||
| 3963 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 3964 | */ | - | ||||||||||||||||||||||||||||||
| 3965 | - | |||||||||||||||||||||||||||||||
| 3966 | /*! | - | ||||||||||||||||||||||||||||||
| 3967 | \fn bool QXmlStreamAttributes::hasAttribute(const QString &namespaceUri, | - | ||||||||||||||||||||||||||||||
| 3968 | const QString &name) const | - | ||||||||||||||||||||||||||||||
| 3969 | \overload | - | ||||||||||||||||||||||||||||||
| 3970 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 3971 | - | |||||||||||||||||||||||||||||||
| 3972 | Returns \c true if this QXmlStreamAttributes has an attribute whose | - | ||||||||||||||||||||||||||||||
| 3973 | namespace URI and name correspond to \a namespaceUri and \a name; | - | ||||||||||||||||||||||||||||||
| 3974 | otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 3975 | */ | - | ||||||||||||||||||||||||||||||
| 3976 | - | |||||||||||||||||||||||||||||||
| 3977 | #endif // QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 3978 | #endif // QT_NO_XMLSTREAMWRITER | - | ||||||||||||||||||||||||||||||
| 3979 | - | |||||||||||||||||||||||||||||||
| 3980 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 3981 | - | |||||||||||||||||||||||||||||||
| 3982 | #endif // QT_NO_XMLSTREAM | - | ||||||||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |