| 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) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||||||||||||||
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||||||||
| 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 http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||||||||
| 15 | ** information use the contact form at http://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 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||||||||
| 25 | ** | - | ||||||||||||||||||||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||||||||
| 29 | ** | - | ||||||||||||||||||||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||||||||
| 31 | ** | - | ||||||||||||||||||||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||||||||
| 34 | #include "QtCore/qxmlstream.h" | - | ||||||||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||||||||
| 36 | #ifndef QT_NO_XMLSTREAM | - | ||||||||||||||||||||||||||||||
| 37 | - | |||||||||||||||||||||||||||||||
| 38 | #include "qxmlutils_p.h" | - | ||||||||||||||||||||||||||||||
| 39 | #include <qdebug.h> | - | ||||||||||||||||||||||||||||||
| 40 | #include <qfile.h> | - | ||||||||||||||||||||||||||||||
| 41 | #include <stdio.h> | - | ||||||||||||||||||||||||||||||
| 42 | #include <qtextcodec.h> | - | ||||||||||||||||||||||||||||||
| 43 | #include <qstack.h> | - | ||||||||||||||||||||||||||||||
| 44 | #include <qbuffer.h> | - | ||||||||||||||||||||||||||||||
| 45 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||||||||
| 46 | #include <qcoreapplication.h> | - | ||||||||||||||||||||||||||||||
| 47 | #else | - | ||||||||||||||||||||||||||||||
| 48 | // This specialization of Q_DECLARE_TR_FUNCTIONS is not in qcoreapplication.h, | - | ||||||||||||||||||||||||||||||
| 49 | // because that header depends on QObject being available, which is not the | - | ||||||||||||||||||||||||||||||
| 50 | // case for most bootstrapped applications. | - | ||||||||||||||||||||||||||||||
| 51 | #define Q_DECLARE_TR_FUNCTIONS(context) \ | - | ||||||||||||||||||||||||||||||
| 52 | public: \ | - | ||||||||||||||||||||||||||||||
| 53 | static inline QString tr(const char *sourceText, const char *comment = 0) \ | - | ||||||||||||||||||||||||||||||
| 54 | { Q_UNUSED(comment); return QString::fromLatin1(sourceText); } \ | - | ||||||||||||||||||||||||||||||
| 55 | static inline QString trUtf8(const char *sourceText, const char *comment = 0) \ | - | ||||||||||||||||||||||||||||||
| 56 | { Q_UNUSED(comment); return QString::fromLatin1(sourceText); } \ | - | ||||||||||||||||||||||||||||||
| 57 | static inline QString tr(const char *sourceText, const char*, int) \ | - | ||||||||||||||||||||||||||||||
| 58 | { return QString::fromLatin1(sourceText); } \ | - | ||||||||||||||||||||||||||||||
| 59 | static inline QString trUtf8(const char *sourceText, const char*, int) \ | - | ||||||||||||||||||||||||||||||
| 60 | { return QString::fromLatin1(sourceText); } \ | - | ||||||||||||||||||||||||||||||
| 61 | private: | - | ||||||||||||||||||||||||||||||
| 62 | #endif | - | ||||||||||||||||||||||||||||||
| 63 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||||||||
| 65 | #include "qxmlstream_p.h" | - | ||||||||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||||||||
| 67 | enum { StreamEOF = ~0U }; | - | ||||||||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||||||||
| 69 | /*! | - | ||||||||||||||||||||||||||||||
| 70 | \enum QXmlStreamReader::TokenType | - | ||||||||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||||||||
| 72 | This enum specifies the type of token the reader just read. | - | ||||||||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||||||||
| 74 | \value NoToken The reader has not yet read anything. | - | ||||||||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||||||||
| 76 | \value Invalid An error has occurred, reported in error() and | - | ||||||||||||||||||||||||||||||
| 77 | errorString(). | - | ||||||||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||||||||
| 79 | \value StartDocument The reader reports the XML version number in | - | ||||||||||||||||||||||||||||||
| 80 | documentVersion(), and the encoding as specified in the XML | - | ||||||||||||||||||||||||||||||
| 81 | document in documentEncoding(). If the document is declared | - | ||||||||||||||||||||||||||||||
| 82 | standalone, isStandaloneDocument() returns \c true; otherwise it | - | ||||||||||||||||||||||||||||||
| 83 | returns \c false. | - | ||||||||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||||||||
| 85 | \value EndDocument The reader reports the end of the document. | - | ||||||||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||||||||
| 87 | \value StartElement The reader reports the start of an element | - | ||||||||||||||||||||||||||||||
| 88 | with namespaceUri() and name(). Empty elements are also reported | - | ||||||||||||||||||||||||||||||
| 89 | as StartElement, followed directly by EndElement. The convenience | - | ||||||||||||||||||||||||||||||
| 90 | function readElementText() can be called to concatenate all | - | ||||||||||||||||||||||||||||||
| 91 | content until the corresponding EndElement. Attributes are | - | ||||||||||||||||||||||||||||||
| 92 | reported in attributes(), namespace declarations in | - | ||||||||||||||||||||||||||||||
| 93 | namespaceDeclarations(). | - | ||||||||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||||||||
| 95 | \value EndElement The reader reports the end of an element with | - | ||||||||||||||||||||||||||||||
| 96 | namespaceUri() and name(). | - | ||||||||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||||||||
| 98 | \value Characters The reader reports characters in text(). If the | - | ||||||||||||||||||||||||||||||
| 99 | characters are all white-space, isWhitespace() returns \c true. If | - | ||||||||||||||||||||||||||||||
| 100 | the characters stem from a CDATA section, isCDATA() returns \c true. | - | ||||||||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||||||||
| 102 | \value Comment The reader reports a comment in text(). | - | ||||||||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||||||||
| 104 | \value DTD The reader reports a DTD in text(), notation | - | ||||||||||||||||||||||||||||||
| 105 | declarations in notationDeclarations(), and entity declarations in | - | ||||||||||||||||||||||||||||||
| 106 | entityDeclarations(). Details of the DTD declaration are reported | - | ||||||||||||||||||||||||||||||
| 107 | in in dtdName(), dtdPublicId(), and dtdSystemId(). | - | ||||||||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||||||||
| 109 | \value EntityReference The reader reports an entity reference that | - | ||||||||||||||||||||||||||||||
| 110 | could not be resolved. The name of the reference is reported in | - | ||||||||||||||||||||||||||||||
| 111 | name(), the replacement text in text(). | - | ||||||||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||||||||
| 113 | \value ProcessingInstruction The reader reports a processing | - | ||||||||||||||||||||||||||||||
| 114 | instruction in processingInstructionTarget() and | - | ||||||||||||||||||||||||||||||
| 115 | processingInstructionData(). | - | ||||||||||||||||||||||||||||||
| 116 | */ | - | ||||||||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||||||||
| 118 | /*! | - | ||||||||||||||||||||||||||||||
| 119 | \enum QXmlStreamReader::ReadElementTextBehaviour | - | ||||||||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||||||||
| 121 | This enum specifies the different behaviours of readElementText(). | - | ||||||||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||||||||
| 123 | \value ErrorOnUnexpectedElement Raise an UnexpectedElementError and return | - | ||||||||||||||||||||||||||||||
| 124 | what was read so far when a child element is encountered. | - | ||||||||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||||||||
| 126 | \value IncludeChildElements Recursively include the text from child elements. | - | ||||||||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||||||||
| 128 | \value SkipChildElements Skip child elements. | - | ||||||||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||||||||
| 130 | \since 4.6 | - | ||||||||||||||||||||||||||||||
| 131 | */ | - | ||||||||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||||||||
| 133 | /*! | - | ||||||||||||||||||||||||||||||
| 134 | \enum QXmlStreamReader::Error | - | ||||||||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||||||||
| 136 | This enum specifies different error cases | - | ||||||||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||||||||
| 138 | \value NoError No error has occurred. | - | ||||||||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||||||||
| 140 | \value CustomError A custom error has been raised with | - | ||||||||||||||||||||||||||||||
| 141 | raiseError() | - | ||||||||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||||||||
| 143 | \value NotWellFormedError The parser internally raised an error | - | ||||||||||||||||||||||||||||||
| 144 | due to the read XML not being well-formed. | - | ||||||||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||||||||
| 146 | \value PrematureEndOfDocumentError The input stream ended before a | - | ||||||||||||||||||||||||||||||
| 147 | well-formed XML document was parsed. Recovery from this error is | - | ||||||||||||||||||||||||||||||
| 148 | possible if more XML arrives in the stream, either by calling | - | ||||||||||||||||||||||||||||||
| 149 | addData() or by waiting for it to arrive on the device(). | - | ||||||||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||||||||
| 151 | \value UnexpectedElementError The parser encountered an element | - | ||||||||||||||||||||||||||||||
| 152 | that was different to those it expected. | - | ||||||||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||||||||
| 154 | */ | - | ||||||||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||||||||
| 156 | /*! | - | ||||||||||||||||||||||||||||||
| 157 | \class QXmlStreamEntityResolver | - | ||||||||||||||||||||||||||||||
| 158 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 159 | \reentrant | - | ||||||||||||||||||||||||||||||
| 160 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||||||||
| 162 | \brief The QXmlStreamEntityResolver class provides an entity | - | ||||||||||||||||||||||||||||||
| 163 | resolver for a QXmlStreamReader. | - | ||||||||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||||||||
| 165 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 166 | */ | - | ||||||||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||||||||
| 168 | /*! | - | ||||||||||||||||||||||||||||||
| 169 | Destroys the entity resolver. | - | ||||||||||||||||||||||||||||||
| 170 | */ | - | ||||||||||||||||||||||||||||||
| 171 | QXmlStreamEntityResolver::~QXmlStreamEntityResolver() | - | ||||||||||||||||||||||||||||||
| 172 | { | - | ||||||||||||||||||||||||||||||
| 173 | } | - | ||||||||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||||||||
| 175 | /*! | - | ||||||||||||||||||||||||||||||
| 176 | \internal | - | ||||||||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||||||||
| 178 | This function is a stub for later functionality. | - | ||||||||||||||||||||||||||||||
| 179 | */ | - | ||||||||||||||||||||||||||||||
| 180 | QString QXmlStreamEntityResolver::resolveEntity(const QString& /*publicId*/, const QString& /*systemId*/) | - | ||||||||||||||||||||||||||||||
| 181 | { | - | ||||||||||||||||||||||||||||||
| 182 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||
| 183 | } | - | ||||||||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||||||||
| 185 | - | |||||||||||||||||||||||||||||||
| 186 | /*! | - | ||||||||||||||||||||||||||||||
| 187 | Resolves the undeclared entity \a name and returns its replacement | - | ||||||||||||||||||||||||||||||
| 188 | text. If the entity is also unknown to the entity resolver, it | - | ||||||||||||||||||||||||||||||
| 189 | returns an empty string. | - | ||||||||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||||||||
| 191 | The default implementation always returns an empty string. | - | ||||||||||||||||||||||||||||||
| 192 | */ | - | ||||||||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||||||||
| 194 | QString QXmlStreamEntityResolver::resolveUndeclaredEntity(const QString &/*name*/) | - | ||||||||||||||||||||||||||||||
| 195 | { | - | ||||||||||||||||||||||||||||||
| 196 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||
| 197 | } | - | ||||||||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||||||||
| 199 | #ifndef QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||||||||
| 201 | QString QXmlStreamReaderPrivate::resolveUndeclaredEntity(const QString &name) | - | ||||||||||||||||||||||||||||||
| 202 | { | - | ||||||||||||||||||||||||||||||
| 203 | if (entityResolver)
| 0-2 | ||||||||||||||||||||||||||||||
| 204 | return entityResolver->resolveUndeclaredEntity(name); executed 2 times by 1 test: return entityResolver->resolveUndeclaredEntity(name);Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 205 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||
| 206 | } | - | ||||||||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||||||||
| 210 | /*! | - | ||||||||||||||||||||||||||||||
| 211 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||||||||
| 213 | Makes \a resolver the new entityResolver(). | - | ||||||||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||||||||
| 215 | The stream reader does \e not take ownership of the resolver. It's | - | ||||||||||||||||||||||||||||||
| 216 | the callers responsibility to ensure that the resolver is valid | - | ||||||||||||||||||||||||||||||
| 217 | during the entire life-time of the stream reader object, or until | - | ||||||||||||||||||||||||||||||
| 218 | another resolver or 0 is set. | - | ||||||||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||||||||
| 220 | \sa entityResolver() | - | ||||||||||||||||||||||||||||||
| 221 | */ | - | ||||||||||||||||||||||||||||||
| 222 | void QXmlStreamReader::setEntityResolver(QXmlStreamEntityResolver *resolver) | - | ||||||||||||||||||||||||||||||
| 223 | { | - | ||||||||||||||||||||||||||||||
| 224 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 225 | d->entityResolver = resolver; | - | ||||||||||||||||||||||||||||||
| 226 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||||||||
| 228 | /*! | - | ||||||||||||||||||||||||||||||
| 229 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 230 | - | |||||||||||||||||||||||||||||||
| 231 | Returns the entity resolver, or 0 if there is no entity resolver. | - | ||||||||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||||||||
| 233 | \sa setEntityResolver() | - | ||||||||||||||||||||||||||||||
| 234 | */ | - | ||||||||||||||||||||||||||||||
| 235 | QXmlStreamEntityResolver *QXmlStreamReader::entityResolver() const | - | ||||||||||||||||||||||||||||||
| 236 | { | - | ||||||||||||||||||||||||||||||
| 237 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 238 | return d->entityResolver; never executed: return d->entityResolver; | 0 | ||||||||||||||||||||||||||||||
| 239 | } | - | ||||||||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||||||||
| 242 | - | |||||||||||||||||||||||||||||||
| 243 | /*! | - | ||||||||||||||||||||||||||||||
| 244 | \class QXmlStreamReader | - | ||||||||||||||||||||||||||||||
| 245 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 246 | \reentrant | - | ||||||||||||||||||||||||||||||
| 247 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||||||||
| 249 | \brief The QXmlStreamReader class provides a fast parser for reading | - | ||||||||||||||||||||||||||||||
| 250 | well-formed XML via a simple streaming API. | - | ||||||||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||||||||
| 253 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||||||||
| 255 | QXmlStreamReader is a faster and more convenient replacement for | - | ||||||||||||||||||||||||||||||
| 256 | Qt's own SAX parser (see QXmlSimpleReader). In some cases it might | - | ||||||||||||||||||||||||||||||
| 257 | also be a faster and more convenient alternative for use in | - | ||||||||||||||||||||||||||||||
| 258 | applications that would otherwise use a DOM tree (see QDomDocument). | - | ||||||||||||||||||||||||||||||
| 259 | QXmlStreamReader reads data either from a QIODevice (see | - | ||||||||||||||||||||||||||||||
| 260 | setDevice()), or from a raw QByteArray (see addData()). | - | ||||||||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||||||||
| 262 | Qt provides QXmlStreamWriter for writing XML. | - | ||||||||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||||||||
| 264 | The basic concept of a stream reader is to report an XML document as | - | ||||||||||||||||||||||||||||||
| 265 | a stream of tokens, similar to SAX. The main difference between | - | ||||||||||||||||||||||||||||||
| 266 | QXmlStreamReader and SAX is \e how these XML tokens are reported. | - | ||||||||||||||||||||||||||||||
| 267 | With SAX, the application must provide handlers (callback functions) | - | ||||||||||||||||||||||||||||||
| 268 | that receive so-called XML \e events from the parser at the parser's | - | ||||||||||||||||||||||||||||||
| 269 | convenience. With QXmlStreamReader, the application code itself | - | ||||||||||||||||||||||||||||||
| 270 | drives the loop and pulls \e tokens from the reader, one after | - | ||||||||||||||||||||||||||||||
| 271 | another, as it needs them. This is done by calling readNext(), where | - | ||||||||||||||||||||||||||||||
| 272 | the reader reads from the input stream until it completes the next | - | ||||||||||||||||||||||||||||||
| 273 | token, at which point it returns the tokenType(). A set of | - | ||||||||||||||||||||||||||||||
| 274 | convenient functions including isStartElement() and text() can then | - | ||||||||||||||||||||||||||||||
| 275 | be used to examine the token to obtain information about what has | - | ||||||||||||||||||||||||||||||
| 276 | been read. The big advantage of this \e pulling approach is the | - | ||||||||||||||||||||||||||||||
| 277 | possibility to build recursive descent parsers with it, meaning you | - | ||||||||||||||||||||||||||||||
| 278 | can split your XML parsing code easily into different methods or | - | ||||||||||||||||||||||||||||||
| 279 | classes. This makes it easy to keep track of the application's own | - | ||||||||||||||||||||||||||||||
| 280 | state when parsing XML. | - | ||||||||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||||||||
| 282 | A typical loop with QXmlStreamReader looks like this: | - | ||||||||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||||||||
| 284 | \snippet code/src_corelib_xml_qxmlstream.cpp 0 | - | ||||||||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||||||||
| 287 | QXmlStreamReader is a well-formed XML 1.0 parser that does \e not | - | ||||||||||||||||||||||||||||||
| 288 | include external parsed entities. As long as no error occurs, the | - | ||||||||||||||||||||||||||||||
| 289 | application code can thus be assured that the data provided by the | - | ||||||||||||||||||||||||||||||
| 290 | stream reader satisfies the W3C's criteria for well-formed XML. For | - | ||||||||||||||||||||||||||||||
| 291 | example, you can be certain that all tags are indeed nested and | - | ||||||||||||||||||||||||||||||
| 292 | closed properly, that references to internal entities have been | - | ||||||||||||||||||||||||||||||
| 293 | replaced with the correct replacement text, and that attributes have | - | ||||||||||||||||||||||||||||||
| 294 | been normalized or added according to the internal subset of the | - | ||||||||||||||||||||||||||||||
| 295 | DTD. | - | ||||||||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||||||||
| 297 | If an error occurs while parsing, atEnd() and hasError() return | - | ||||||||||||||||||||||||||||||
| 298 | true, and error() returns the error that occurred. The functions | - | ||||||||||||||||||||||||||||||
| 299 | errorString(), lineNumber(), columnNumber(), and characterOffset() | - | ||||||||||||||||||||||||||||||
| 300 | are for constructing an appropriate error or warning message. To | - | ||||||||||||||||||||||||||||||
| 301 | simplify application code, QXmlStreamReader contains a raiseError() | - | ||||||||||||||||||||||||||||||
| 302 | mechanism that lets you raise custom errors that trigger the same | - | ||||||||||||||||||||||||||||||
| 303 | error handling described. | - | ||||||||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||||||||
| 305 | The \l{QXmlStream Bookmarks Example} illustrates how to use the | - | ||||||||||||||||||||||||||||||
| 306 | recursive descent technique to read an XML bookmark file (XBEL) with | - | ||||||||||||||||||||||||||||||
| 307 | a stream reader. | - | ||||||||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||||||||
| 309 | \section1 Namespaces | - | ||||||||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||||||||
| 311 | QXmlStream understands and resolves XML namespaces. E.g. in case of | - | ||||||||||||||||||||||||||||||
| 312 | a StartElement, namespaceUri() returns the namespace the element is | - | ||||||||||||||||||||||||||||||
| 313 | in, and name() returns the element's \e local name. The combination | - | ||||||||||||||||||||||||||||||
| 314 | of namespaceUri and name uniquely identifies an element. If a | - | ||||||||||||||||||||||||||||||
| 315 | namespace prefix was not declared in the XML entities parsed by the | - | ||||||||||||||||||||||||||||||
| 316 | reader, the namespaceUri is empty. | - | ||||||||||||||||||||||||||||||
| 317 | - | |||||||||||||||||||||||||||||||
| 318 | If you parse XML data that does not utilize namespaces according to | - | ||||||||||||||||||||||||||||||
| 319 | the XML specification or doesn't use namespaces at all, you can use | - | ||||||||||||||||||||||||||||||
| 320 | the element's qualifiedName() instead. A qualified name is the | - | ||||||||||||||||||||||||||||||
| 321 | element's prefix() followed by colon followed by the element's local | - | ||||||||||||||||||||||||||||||
| 322 | name() - exactly like the element appears in the raw XML data. Since | - | ||||||||||||||||||||||||||||||
| 323 | the mapping namespaceUri to prefix is neither unique nor universal, | - | ||||||||||||||||||||||||||||||
| 324 | qualifiedName() should be avoided for namespace-compliant XML data. | - | ||||||||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||||||||
| 326 | In order to parse standalone documents that do use undeclared | - | ||||||||||||||||||||||||||||||
| 327 | namespace prefixes, you can turn off namespace processing completely | - | ||||||||||||||||||||||||||||||
| 328 | with the \l namespaceProcessing property. | - | ||||||||||||||||||||||||||||||
| 329 | - | |||||||||||||||||||||||||||||||
| 330 | \section1 Incremental Parsing | - | ||||||||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||||||||
| 332 | QXmlStreamReader is an incremental parser. It can handle the case | - | ||||||||||||||||||||||||||||||
| 333 | where the document can't be parsed all at once because it arrives in | - | ||||||||||||||||||||||||||||||
| 334 | chunks (e.g. from multiple files, or over a network connection). | - | ||||||||||||||||||||||||||||||
| 335 | When the reader runs out of data before the complete document has | - | ||||||||||||||||||||||||||||||
| 336 | been parsed, it reports a PrematureEndOfDocumentError. When more | - | ||||||||||||||||||||||||||||||
| 337 | data arrives, either because of a call to addData() or because more | - | ||||||||||||||||||||||||||||||
| 338 | data is available through the network device(), the reader recovers | - | ||||||||||||||||||||||||||||||
| 339 | from the PrematureEndOfDocumentError error and continues parsing the | - | ||||||||||||||||||||||||||||||
| 340 | new data with the next call to readNext(). | - | ||||||||||||||||||||||||||||||
| 341 | - | |||||||||||||||||||||||||||||||
| 342 | For example, if your application reads data from the network using a | - | ||||||||||||||||||||||||||||||
| 343 | \l{QNetworkAccessManager} {network access manager}, you would issue | - | ||||||||||||||||||||||||||||||
| 344 | a \l{QNetworkRequest} {network request} to the manager and receive a | - | ||||||||||||||||||||||||||||||
| 345 | \l{QNetworkReply} {network reply} in return. Since a QNetworkReply | - | ||||||||||||||||||||||||||||||
| 346 | is a QIODevice, you connect its \l{QIODevice::readyRead()} | - | ||||||||||||||||||||||||||||||
| 347 | {readyRead()} signal to a custom slot, e.g. \c{slotReadyRead()} in | - | ||||||||||||||||||||||||||||||
| 348 | the code snippet shown in the discussion for QNetworkAccessManager. | - | ||||||||||||||||||||||||||||||
| 349 | In this slot, you read all available data with | - | ||||||||||||||||||||||||||||||
| 350 | \l{QIODevice::readAll()} {readAll()} and pass it to the XML | - | ||||||||||||||||||||||||||||||
| 351 | stream reader using addData(). Then you call your custom parsing | - | ||||||||||||||||||||||||||||||
| 352 | function that reads the XML events from the reader. | - | ||||||||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||||||||
| 354 | \section1 Performance and Memory Consumption | - | ||||||||||||||||||||||||||||||
| 355 | - | |||||||||||||||||||||||||||||||
| 356 | QXmlStreamReader is memory-conservative by design, since it doesn't | - | ||||||||||||||||||||||||||||||
| 357 | store the entire XML document tree in memory, but only the current | - | ||||||||||||||||||||||||||||||
| 358 | token at the time it is reported. In addition, QXmlStreamReader | - | ||||||||||||||||||||||||||||||
| 359 | avoids the many small string allocations that it normally takes to | - | ||||||||||||||||||||||||||||||
| 360 | map an XML document to a convenient and Qt-ish API. It does this by | - | ||||||||||||||||||||||||||||||
| 361 | reporting all string data as QStringRef rather than real QString | - | ||||||||||||||||||||||||||||||
| 362 | objects. QStringRef is a thin wrapper around QString substrings that | - | ||||||||||||||||||||||||||||||
| 363 | provides a subset of the QString API without the memory allocation | - | ||||||||||||||||||||||||||||||
| 364 | and reference-counting overhead. Calling | - | ||||||||||||||||||||||||||||||
| 365 | \l{QStringRef::toString()}{toString()} on any of those objects | - | ||||||||||||||||||||||||||||||
| 366 | returns an equivalent real QString object. | - | ||||||||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||||||||
| 368 | */ | - | ||||||||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||||||||
| 371 | /*! | - | ||||||||||||||||||||||||||||||
| 372 | Constructs a stream reader. | - | ||||||||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||||||||
| 374 | \sa setDevice(), addData() | - | ||||||||||||||||||||||||||||||
| 375 | */ | - | ||||||||||||||||||||||||||||||
| 376 | QXmlStreamReader::QXmlStreamReader() | - | ||||||||||||||||||||||||||||||
| 377 | : d_ptr(new QXmlStreamReaderPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 378 | { | - | ||||||||||||||||||||||||||||||
| 379 | } executed 3174 times by 1 test: end of blockExecuted by:
| 3174 | ||||||||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||||||||
| 381 | /*! Creates a new stream reader that reads from \a device. | - | ||||||||||||||||||||||||||||||
| 382 | - | |||||||||||||||||||||||||||||||
| 383 | \sa setDevice(), clear() | - | ||||||||||||||||||||||||||||||
| 384 | */ | - | ||||||||||||||||||||||||||||||
| 385 | QXmlStreamReader::QXmlStreamReader(QIODevice *device) | - | ||||||||||||||||||||||||||||||
| 386 | : d_ptr(new QXmlStreamReaderPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 387 | { | - | ||||||||||||||||||||||||||||||
| 388 | setDevice(device); | - | ||||||||||||||||||||||||||||||
| 389 | } executed 519 times by 2 tests: end of blockExecuted by:
| 519 | ||||||||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||||||||
| 391 | /*! | - | ||||||||||||||||||||||||||||||
| 392 | Creates a new stream reader that reads from \a data. | - | ||||||||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||||||||
| 394 | \sa addData(), clear(), setDevice() | - | ||||||||||||||||||||||||||||||
| 395 | */ | - | ||||||||||||||||||||||||||||||
| 396 | QXmlStreamReader::QXmlStreamReader(const QByteArray &data) | - | ||||||||||||||||||||||||||||||
| 397 | : d_ptr(new QXmlStreamReaderPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 398 | { | - | ||||||||||||||||||||||||||||||
| 399 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 400 | d->dataBuffer = data; | - | ||||||||||||||||||||||||||||||
| 401 | } executed 845 times by 2 tests: end of blockExecuted by:
| 845 | ||||||||||||||||||||||||||||||
| 402 | - | |||||||||||||||||||||||||||||||
| 403 | /*! | - | ||||||||||||||||||||||||||||||
| 404 | Creates a new stream reader that reads from \a data. | - | ||||||||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||||||||
| 406 | \sa addData(), clear(), setDevice() | - | ||||||||||||||||||||||||||||||
| 407 | */ | - | ||||||||||||||||||||||||||||||
| 408 | QXmlStreamReader::QXmlStreamReader(const QString &data) | - | ||||||||||||||||||||||||||||||
| 409 | : d_ptr(new QXmlStreamReaderPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 410 | { | - | ||||||||||||||||||||||||||||||
| 411 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 412 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 413 | d->dataBuffer = data.toLatin1(); | - | ||||||||||||||||||||||||||||||
| 414 | #else | - | ||||||||||||||||||||||||||||||
| 415 | d->dataBuffer = d->codec->fromUnicode(data); | - | ||||||||||||||||||||||||||||||
| 416 | d->decoder = d->codec->makeDecoder(); | - | ||||||||||||||||||||||||||||||
| 417 | #endif | - | ||||||||||||||||||||||||||||||
| 418 | d->lockEncoding = true; | - | ||||||||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||||||||
| 420 | } executed 378 times by 13 tests: end of blockExecuted by:
| 378 | ||||||||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||||||||
| 422 | /*! | - | ||||||||||||||||||||||||||||||
| 423 | Creates a new stream reader that reads from \a data. | - | ||||||||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||||||||
| 425 | \sa addData(), clear(), setDevice() | - | ||||||||||||||||||||||||||||||
| 426 | */ | - | ||||||||||||||||||||||||||||||
| 427 | QXmlStreamReader::QXmlStreamReader(const char *data) | - | ||||||||||||||||||||||||||||||
| 428 | : d_ptr(new QXmlStreamReaderPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 429 | { | - | ||||||||||||||||||||||||||||||
| 430 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 431 | d->dataBuffer = QByteArray(data); | - | ||||||||||||||||||||||||||||||
| 432 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||||||||
| 434 | /*! | - | ||||||||||||||||||||||||||||||
| 435 | Destructs the reader. | - | ||||||||||||||||||||||||||||||
| 436 | */ | - | ||||||||||||||||||||||||||||||
| 437 | QXmlStreamReader::~QXmlStreamReader() | - | ||||||||||||||||||||||||||||||
| 438 | { | - | ||||||||||||||||||||||||||||||
| 439 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 440 | if (d->deleteDevice)
| 0-4922 | ||||||||||||||||||||||||||||||
| 441 | delete d->device; never executed: delete d->device; | 0 | ||||||||||||||||||||||||||||||
| 442 | } executed 4922 times by 15 tests: end of blockExecuted by:
| 4922 | ||||||||||||||||||||||||||||||
| 443 | - | |||||||||||||||||||||||||||||||
| 444 | /*! \fn bool QXmlStreamReader::hasError() const | - | ||||||||||||||||||||||||||||||
| 445 | Returns \c true if an error has occurred, otherwise \c false. | - | ||||||||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||||||||
| 447 | \sa errorString(), error() | - | ||||||||||||||||||||||||||||||
| 448 | */ | - | ||||||||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||||||||
| 450 | /*! | - | ||||||||||||||||||||||||||||||
| 451 | Sets the current device to \a device. Setting the device resets | - | ||||||||||||||||||||||||||||||
| 452 | the stream to its initial state. | - | ||||||||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||||||||
| 454 | \sa device(), clear() | - | ||||||||||||||||||||||||||||||
| 455 | */ | - | ||||||||||||||||||||||||||||||
| 456 | void QXmlStreamReader::setDevice(QIODevice *device) | - | ||||||||||||||||||||||||||||||
| 457 | { | - | ||||||||||||||||||||||||||||||
| 458 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 459 | if (d->deleteDevice) {
| 0-2240 | ||||||||||||||||||||||||||||||
| 460 | delete d->device; | - | ||||||||||||||||||||||||||||||
| 461 | d->deleteDevice = false; | - | ||||||||||||||||||||||||||||||
| 462 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 463 | d->device = device; | - | ||||||||||||||||||||||||||||||
| 464 | d->init(); | - | ||||||||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||||||||
| 466 | } executed 2240 times by 2 tests: end of blockExecuted by:
| 2240 | ||||||||||||||||||||||||||||||
| 467 | - | |||||||||||||||||||||||||||||||
| 468 | /*! | - | ||||||||||||||||||||||||||||||
| 469 | Returns the current device associated with the QXmlStreamReader, | - | ||||||||||||||||||||||||||||||
| 470 | or 0 if no device has been assigned. | - | ||||||||||||||||||||||||||||||
| 471 | - | |||||||||||||||||||||||||||||||
| 472 | \sa setDevice() | - | ||||||||||||||||||||||||||||||
| 473 | */ | - | ||||||||||||||||||||||||||||||
| 474 | QIODevice *QXmlStreamReader::device() const | - | ||||||||||||||||||||||||||||||
| 475 | { | - | ||||||||||||||||||||||||||||||
| 476 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 477 | return d->device; never executed: return d->device; | 0 | ||||||||||||||||||||||||||||||
| 478 | } | - | ||||||||||||||||||||||||||||||
| 479 | - | |||||||||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||||||||
| 481 | /*! | - | ||||||||||||||||||||||||||||||
| 482 | Adds more \a data for the reader to read. This function does | - | ||||||||||||||||||||||||||||||
| 483 | nothing if the reader has a device(). | - | ||||||||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||||||||
| 485 | \sa readNext(), clear() | - | ||||||||||||||||||||||||||||||
| 486 | */ | - | ||||||||||||||||||||||||||||||
| 487 | void QXmlStreamReader::addData(const QByteArray &data) | - | ||||||||||||||||||||||||||||||
| 488 | { | - | ||||||||||||||||||||||||||||||
| 489 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 490 | if (d->device) {
| 0-57484 | ||||||||||||||||||||||||||||||
| 491 | qWarning("QXmlStreamReader: addData() with device()"); | - | ||||||||||||||||||||||||||||||
| 492 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 493 | } | - | ||||||||||||||||||||||||||||||
| 494 | d->dataBuffer += data; | - | ||||||||||||||||||||||||||||||
| 495 | } executed 57484 times by 1 test: end of blockExecuted by:
| 57484 | ||||||||||||||||||||||||||||||
| 496 | - | |||||||||||||||||||||||||||||||
| 497 | /*! | - | ||||||||||||||||||||||||||||||
| 498 | Adds more \a data for the reader to read. This function does | - | ||||||||||||||||||||||||||||||
| 499 | nothing if the reader has a device(). | - | ||||||||||||||||||||||||||||||
| 500 | - | |||||||||||||||||||||||||||||||
| 501 | \sa readNext(), clear() | - | ||||||||||||||||||||||||||||||
| 502 | */ | - | ||||||||||||||||||||||||||||||
| 503 | void QXmlStreamReader::addData(const QString &data) | - | ||||||||||||||||||||||||||||||
| 504 | { | - | ||||||||||||||||||||||||||||||
| 505 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 506 | d->lockEncoding = true; | - | ||||||||||||||||||||||||||||||
| 507 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 508 | addData(data.toLatin1()); | - | ||||||||||||||||||||||||||||||
| 509 | #else | - | ||||||||||||||||||||||||||||||
| 510 | addData(d->codec->fromUnicode(data)); | - | ||||||||||||||||||||||||||||||
| 511 | #endif | - | ||||||||||||||||||||||||||||||
| 512 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||||||||
| 514 | /*! | - | ||||||||||||||||||||||||||||||
| 515 | Adds more \a data for the reader to read. This function does | - | ||||||||||||||||||||||||||||||
| 516 | nothing if the reader has a device(). | - | ||||||||||||||||||||||||||||||
| 517 | - | |||||||||||||||||||||||||||||||
| 518 | \sa readNext(), clear() | - | ||||||||||||||||||||||||||||||
| 519 | */ | - | ||||||||||||||||||||||||||||||
| 520 | void QXmlStreamReader::addData(const char *data) | - | ||||||||||||||||||||||||||||||
| 521 | { | - | ||||||||||||||||||||||||||||||
| 522 | addData(QByteArray(data)); | - | ||||||||||||||||||||||||||||||
| 523 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||||||||
| 525 | /*! | - | ||||||||||||||||||||||||||||||
| 526 | Removes any device() or data from the reader and resets its | - | ||||||||||||||||||||||||||||||
| 527 | internal state to the initial state. | - | ||||||||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||||||||
| 529 | \sa addData() | - | ||||||||||||||||||||||||||||||
| 530 | */ | - | ||||||||||||||||||||||||||||||
| 531 | void QXmlStreamReader::clear() | - | ||||||||||||||||||||||||||||||
| 532 | { | - | ||||||||||||||||||||||||||||||
| 533 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 534 | d->init(); | - | ||||||||||||||||||||||||||||||
| 535 | if (d->device) {
| 0-3 | ||||||||||||||||||||||||||||||
| 536 | if (d->deleteDevice)
| 0 | ||||||||||||||||||||||||||||||
| 537 | delete d->device; never executed: delete d->device; | 0 | ||||||||||||||||||||||||||||||
| 538 | d->device = 0; | - | ||||||||||||||||||||||||||||||
| 539 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 540 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||||||||
| 541 | - | |||||||||||||||||||||||||||||||
| 542 | /*! | - | ||||||||||||||||||||||||||||||
| 543 | Returns \c true if the reader has read until the end of the XML | - | ||||||||||||||||||||||||||||||
| 544 | document, or if an error() has occurred and reading has been | - | ||||||||||||||||||||||||||||||
| 545 | aborted. Otherwise, it returns \c false. | - | ||||||||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||||||||
| 547 | When atEnd() and hasError() return true and error() returns | - | ||||||||||||||||||||||||||||||
| 548 | PrematureEndOfDocumentError, it means the XML has been well-formed | - | ||||||||||||||||||||||||||||||
| 549 | so far, but a complete XML document has not been parsed. The next | - | ||||||||||||||||||||||||||||||
| 550 | chunk of XML can be added with addData(), if the XML is being read | - | ||||||||||||||||||||||||||||||
| 551 | from a QByteArray, or by waiting for more data to arrive if the | - | ||||||||||||||||||||||||||||||
| 552 | XML is being read from a QIODevice. Either way, atEnd() will | - | ||||||||||||||||||||||||||||||
| 553 | return false once more data is available. | - | ||||||||||||||||||||||||||||||
| 554 | - | |||||||||||||||||||||||||||||||
| 555 | \sa hasError(), error(), device(), QIODevice::atEnd() | - | ||||||||||||||||||||||||||||||
| 556 | */ | - | ||||||||||||||||||||||||||||||
| 557 | bool QXmlStreamReader::atEnd() const | - | ||||||||||||||||||||||||||||||
| 558 | { | - | ||||||||||||||||||||||||||||||
| 559 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 560 | if (d->atEnd
| 118570-690755 | ||||||||||||||||||||||||||||||
| 561 | && ((d->type == QXmlStreamReader::Invalid && d->error == PrematureEndOfDocumentError)
| 0-115547 | ||||||||||||||||||||||||||||||
| 562 | || (d->type == QXmlStreamReader::EndDocument))) {
| 0-3023 | ||||||||||||||||||||||||||||||
| 563 | if (d->device)
| 551-118019 | ||||||||||||||||||||||||||||||
| 564 | return d->device->atEnd(); executed 551 times by 2 tests: return d->device->atEnd();Executed by:
| 551 | ||||||||||||||||||||||||||||||
| 565 | else | - | ||||||||||||||||||||||||||||||
| 566 | return !d->dataBuffer.size(); executed 118019 times by 14 tests: return !d->dataBuffer.size();Executed by:
| 118019 | ||||||||||||||||||||||||||||||
| 567 | } | - | ||||||||||||||||||||||||||||||
| 568 | return (d->atEnd || d->type == QXmlStreamReader::Invalid); executed 690755 times by 15 tests: return (d->atEnd || d->type == QXmlStreamReader::Invalid);Executed by:
| 0-690755 | ||||||||||||||||||||||||||||||
| 569 | } | - | ||||||||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||||||||
| 571 | - | |||||||||||||||||||||||||||||||
| 572 | /*! | - | ||||||||||||||||||||||||||||||
| 573 | Reads the next token and returns its type. | - | ||||||||||||||||||||||||||||||
| 574 | - | |||||||||||||||||||||||||||||||
| 575 | With one exception, once an error() is reported by readNext(), | - | ||||||||||||||||||||||||||||||
| 576 | further reading of the XML stream is not possible. Then atEnd() | - | ||||||||||||||||||||||||||||||
| 577 | returns \c true, hasError() returns \c true, and this function returns | - | ||||||||||||||||||||||||||||||
| 578 | QXmlStreamReader::Invalid. | - | ||||||||||||||||||||||||||||||
| 579 | - | |||||||||||||||||||||||||||||||
| 580 | The exception is when error() returns PrematureEndOfDocumentError. | - | ||||||||||||||||||||||||||||||
| 581 | This error is reported when the end of an otherwise well-formed | - | ||||||||||||||||||||||||||||||
| 582 | chunk of XML is reached, but the chunk doesn't represent a complete | - | ||||||||||||||||||||||||||||||
| 583 | XML document. In that case, parsing \e can be resumed by calling | - | ||||||||||||||||||||||||||||||
| 584 | addData() to add the next chunk of XML, when the stream is being | - | ||||||||||||||||||||||||||||||
| 585 | read from a QByteArray, or by waiting for more data to arrive when | - | ||||||||||||||||||||||||||||||
| 586 | the stream is being read from a device(). | - | ||||||||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||||||||
| 588 | \sa tokenType(), tokenString() | - | ||||||||||||||||||||||||||||||
| 589 | */ | - | ||||||||||||||||||||||||||||||
| 590 | QXmlStreamReader::TokenType QXmlStreamReader::readNext() | - | ||||||||||||||||||||||||||||||
| 591 | { | - | ||||||||||||||||||||||||||||||
| 592 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 593 | if (d->type != Invalid) {
| 57494-1035578 | ||||||||||||||||||||||||||||||
| 594 | if (!d->hasCheckedStartDocument)
| 5954-1029624 | ||||||||||||||||||||||||||||||
| 595 | if (!d->checkStartDocument())
| 1285-4669 | ||||||||||||||||||||||||||||||
| 596 | return d->type; // synthetic StartDocument or error executed 4669 times by 13 tests: return d->type;Executed by:
| 4669 | ||||||||||||||||||||||||||||||
| 597 | d->parse(); | - | ||||||||||||||||||||||||||||||
| 598 | if (d->atEnd && d->type != EndDocument && d->type != Invalid)
| 2371-972500 | ||||||||||||||||||||||||||||||
| 599 | d->raiseError(PrematureEndOfDocumentError); executed 45171 times by 1 test: d->raiseError(PrematureEndOfDocumentError);Executed by:
| 45171 | ||||||||||||||||||||||||||||||
| 600 | else if (!d->atEnd && d->type == EndDocument)
| 5-972500 | ||||||||||||||||||||||||||||||
| 601 | 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 | ||||||||||||||||||||||||||||||
| 602 | } else if (d->error == PrematureEndOfDocumentError) { executed 1030909 times by 15 tests: end of blockExecuted by:
| 12-1030909 | ||||||||||||||||||||||||||||||
| 603 | // resume error | - | ||||||||||||||||||||||||||||||
| 604 | d->type = NoToken; | - | ||||||||||||||||||||||||||||||
| 605 | d->atEnd = false; | - | ||||||||||||||||||||||||||||||
| 606 | d->token = -1; | - | ||||||||||||||||||||||||||||||
| 607 | return readNext(); executed 57482 times by 1 test: return readNext();Executed by:
| 57482 | ||||||||||||||||||||||||||||||
| 608 | } | - | ||||||||||||||||||||||||||||||
| 609 | return d->type; executed 1030921 times by 15 tests: return d->type;Executed by:
| 1030921 | ||||||||||||||||||||||||||||||
| 610 | } | - | ||||||||||||||||||||||||||||||
| 611 | - | |||||||||||||||||||||||||||||||
| 612 | - | |||||||||||||||||||||||||||||||
| 613 | /*! | - | ||||||||||||||||||||||||||||||
| 614 | Returns the type of the current token. | - | ||||||||||||||||||||||||||||||
| 615 | - | |||||||||||||||||||||||||||||||
| 616 | The current token can also be queried with the convenience functions | - | ||||||||||||||||||||||||||||||
| 617 | isStartDocument(), isEndDocument(), isStartElement(), | - | ||||||||||||||||||||||||||||||
| 618 | isEndElement(), isCharacters(), isComment(), isDTD(), | - | ||||||||||||||||||||||||||||||
| 619 | isEntityReference(), and isProcessingInstruction(). | - | ||||||||||||||||||||||||||||||
| 620 | - | |||||||||||||||||||||||||||||||
| 621 | \sa tokenString() | - | ||||||||||||||||||||||||||||||
| 622 | */ | - | ||||||||||||||||||||||||||||||
| 623 | QXmlStreamReader::TokenType QXmlStreamReader::tokenType() const | - | ||||||||||||||||||||||||||||||
| 624 | { | - | ||||||||||||||||||||||||||||||
| 625 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 626 | return d->type; executed 604486 times by 14 tests: return d->type;Executed by:
| 604486 | ||||||||||||||||||||||||||||||
| 627 | } | - | ||||||||||||||||||||||||||||||
| 628 | - | |||||||||||||||||||||||||||||||
| 629 | /*! | - | ||||||||||||||||||||||||||||||
| 630 | Reads until the next start element within the current element. Returns \c true | - | ||||||||||||||||||||||||||||||
| 631 | when a start element was reached. When the end element was reached, or when | - | ||||||||||||||||||||||||||||||
| 632 | an error occurred, false is returned. | - | ||||||||||||||||||||||||||||||
| 633 | - | |||||||||||||||||||||||||||||||
| 634 | The current element is the element matching the most recently parsed start | - | ||||||||||||||||||||||||||||||
| 635 | element of which a matching end element has not yet been reached. When the | - | ||||||||||||||||||||||||||||||
| 636 | parser has reached the end element, the current element becomes the parent | - | ||||||||||||||||||||||||||||||
| 637 | element. | - | ||||||||||||||||||||||||||||||
| 638 | - | |||||||||||||||||||||||||||||||
| 639 | This is a convenience function for when you're only concerned with parsing | - | ||||||||||||||||||||||||||||||
| 640 | XML elements. The \l{QXmlStream Bookmarks Example} makes extensive use of | - | ||||||||||||||||||||||||||||||
| 641 | this function. | - | ||||||||||||||||||||||||||||||
| 642 | - | |||||||||||||||||||||||||||||||
| 643 | \since 4.6 | - | ||||||||||||||||||||||||||||||
| 644 | \sa readNext() | - | ||||||||||||||||||||||||||||||
| 645 | */ | - | ||||||||||||||||||||||||||||||
| 646 | bool QXmlStreamReader::readNextStartElement() | - | ||||||||||||||||||||||||||||||
| 647 | { | - | ||||||||||||||||||||||||||||||
| 648 | while (readNext() != Invalid) {
| 12-15735 | ||||||||||||||||||||||||||||||
| 649 | if (isEndElement())
| 2626-13109 | ||||||||||||||||||||||||||||||
| 650 | return false; executed 2626 times by 14 tests: return false;Executed by:
| 2626 | ||||||||||||||||||||||||||||||
| 651 | else if (isStartElement())
| 5437-7672 | ||||||||||||||||||||||||||||||
| 652 | return true; executed 5437 times by 14 tests: return true;Executed by:
| 5437 | ||||||||||||||||||||||||||||||
| 653 | } executed 7672 times by 12 tests: end of blockExecuted by:
| 7672 | ||||||||||||||||||||||||||||||
| 654 | return false; executed 12 times by 1 test: return false;Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 655 | } | - | ||||||||||||||||||||||||||||||
| 656 | - | |||||||||||||||||||||||||||||||
| 657 | /*! | - | ||||||||||||||||||||||||||||||
| 658 | Reads until the end of the current element, skipping any child nodes. | - | ||||||||||||||||||||||||||||||
| 659 | This function is useful for skipping unknown elements. | - | ||||||||||||||||||||||||||||||
| 660 | - | |||||||||||||||||||||||||||||||
| 661 | The current element is the element matching the most recently parsed start | - | ||||||||||||||||||||||||||||||
| 662 | element of which a matching end element has not yet been reached. When the | - | ||||||||||||||||||||||||||||||
| 663 | parser has reached the end element, the current element becomes the parent | - | ||||||||||||||||||||||||||||||
| 664 | element. | - | ||||||||||||||||||||||||||||||
| 665 | - | |||||||||||||||||||||||||||||||
| 666 | \since 4.6 | - | ||||||||||||||||||||||||||||||
| 667 | */ | - | ||||||||||||||||||||||||||||||
| 668 | void QXmlStreamReader::skipCurrentElement() | - | ||||||||||||||||||||||||||||||
| 669 | { | - | ||||||||||||||||||||||||||||||
| 670 | int depth = 1; | - | ||||||||||||||||||||||||||||||
| 671 | while (depth && readNext() != Invalid) {
| 7-2686 | ||||||||||||||||||||||||||||||
| 672 | if (isEndElement())
| 24-2655 | ||||||||||||||||||||||||||||||
| 673 | --depth; executed 2655 times by 14 tests: --depth;Executed by:
| 2655 | ||||||||||||||||||||||||||||||
| 674 | else if (isStartElement())
| 11-13 | ||||||||||||||||||||||||||||||
| 675 | ++depth; executed 13 times by 2 tests: ++depth;Executed by:
| 13 | ||||||||||||||||||||||||||||||
| 676 | } executed 2679 times by 14 tests: end of blockExecuted by:
| 2679 | ||||||||||||||||||||||||||||||
| 677 | } executed 2649 times by 14 tests: end of blockExecuted by:
| 2649 | ||||||||||||||||||||||||||||||
| 678 | - | |||||||||||||||||||||||||||||||
| 679 | /* | - | ||||||||||||||||||||||||||||||
| 680 | * Use the following Perl script to generate the error string index list: | - | ||||||||||||||||||||||||||||||
| 681 | ===== PERL SCRIPT ==== | - | ||||||||||||||||||||||||||||||
| 682 | print "static const char QXmlStreamReader_tokenTypeString_string[] =\n"; | - | ||||||||||||||||||||||||||||||
| 683 | $counter = 0; | - | ||||||||||||||||||||||||||||||
| 684 | $i = 0; | - | ||||||||||||||||||||||||||||||
| 685 | while (<STDIN>) { | - | ||||||||||||||||||||||||||||||
| 686 | chomp; | - | ||||||||||||||||||||||||||||||
| 687 | print " \"$_\\0\"\n"; | - | ||||||||||||||||||||||||||||||
| 688 | $sizes[$i++] = $counter; | - | ||||||||||||||||||||||||||||||
| 689 | $counter += length 1 + $_; | - | ||||||||||||||||||||||||||||||
| 690 | } | - | ||||||||||||||||||||||||||||||
| 691 | print " \"\\0\";\n\nstatic const short QXmlStreamReader_tokenTypeString_indices[] = {\n "; | - | ||||||||||||||||||||||||||||||
| 692 | for ($j = 0; $j < $i; ++$j) { | - | ||||||||||||||||||||||||||||||
| 693 | printf "$sizes[$j], "; | - | ||||||||||||||||||||||||||||||
| 694 | } | - | ||||||||||||||||||||||||||||||
| 695 | print "0\n};\n"; | - | ||||||||||||||||||||||||||||||
| 696 | ===== PERL SCRIPT ==== | - | ||||||||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||||||||
| 698 | * The input data is as follows (copied from qxmlstream.h): | - | ||||||||||||||||||||||||||||||
| 699 | NoToken | - | ||||||||||||||||||||||||||||||
| 700 | Invalid | - | ||||||||||||||||||||||||||||||
| 701 | StartDocument | - | ||||||||||||||||||||||||||||||
| 702 | EndDocument | - | ||||||||||||||||||||||||||||||
| 703 | StartElement | - | ||||||||||||||||||||||||||||||
| 704 | EndElement | - | ||||||||||||||||||||||||||||||
| 705 | Characters | - | ||||||||||||||||||||||||||||||
| 706 | Comment | - | ||||||||||||||||||||||||||||||
| 707 | DTD | - | ||||||||||||||||||||||||||||||
| 708 | EntityReference | - | ||||||||||||||||||||||||||||||
| 709 | ProcessingInstruction | - | ||||||||||||||||||||||||||||||
| 710 | */ | - | ||||||||||||||||||||||||||||||
| 711 | static const char QXmlStreamReader_tokenTypeString_string[] = | - | ||||||||||||||||||||||||||||||
| 712 | "NoToken\0" | - | ||||||||||||||||||||||||||||||
| 713 | "Invalid\0" | - | ||||||||||||||||||||||||||||||
| 714 | "StartDocument\0" | - | ||||||||||||||||||||||||||||||
| 715 | "EndDocument\0" | - | ||||||||||||||||||||||||||||||
| 716 | "StartElement\0" | - | ||||||||||||||||||||||||||||||
| 717 | "EndElement\0" | - | ||||||||||||||||||||||||||||||
| 718 | "Characters\0" | - | ||||||||||||||||||||||||||||||
| 719 | "Comment\0" | - | ||||||||||||||||||||||||||||||
| 720 | "DTD\0" | - | ||||||||||||||||||||||||||||||
| 721 | "EntityReference\0" | - | ||||||||||||||||||||||||||||||
| 722 | "ProcessingInstruction\0"; | - | ||||||||||||||||||||||||||||||
| 723 | - | |||||||||||||||||||||||||||||||
| 724 | static const short QXmlStreamReader_tokenTypeString_indices[] = { | - | ||||||||||||||||||||||||||||||
| 725 | 0, 8, 16, 30, 42, 55, 66, 77, 85, 89, 105, 0 | - | ||||||||||||||||||||||||||||||
| 726 | }; | - | ||||||||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||||||||
| 729 | /*! | - | ||||||||||||||||||||||||||||||
| 730 | \property QXmlStreamReader::namespaceProcessing | - | ||||||||||||||||||||||||||||||
| 731 | The namespace-processing flag of the stream reader | - | ||||||||||||||||||||||||||||||
| 732 | - | |||||||||||||||||||||||||||||||
| 733 | This property controls whether or not the stream reader processes | - | ||||||||||||||||||||||||||||||
| 734 | namespaces. If enabled, the reader processes namespaces, otherwise | - | ||||||||||||||||||||||||||||||
| 735 | it does not. | - | ||||||||||||||||||||||||||||||
| 736 | - | |||||||||||||||||||||||||||||||
| 737 | By default, namespace-processing is enabled. | - | ||||||||||||||||||||||||||||||
| 738 | */ | - | ||||||||||||||||||||||||||||||
| 739 | - | |||||||||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||||||||
| 741 | void QXmlStreamReader::setNamespaceProcessing(bool enable) | - | ||||||||||||||||||||||||||||||
| 742 | { | - | ||||||||||||||||||||||||||||||
| 743 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 744 | d->namespaceProcessing = enable; | - | ||||||||||||||||||||||||||||||
| 745 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||||||||
| 747 | bool QXmlStreamReader::namespaceProcessing() const | - | ||||||||||||||||||||||||||||||
| 748 | { | - | ||||||||||||||||||||||||||||||
| 749 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 750 | return d->namespaceProcessing; never executed: return d->namespaceProcessing; | 0 | ||||||||||||||||||||||||||||||
| 751 | } | - | ||||||||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||||||||
| 753 | /*! Returns the reader's current token as string. | - | ||||||||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||||||||
| 755 | \sa tokenType() | - | ||||||||||||||||||||||||||||||
| 756 | */ | - | ||||||||||||||||||||||||||||||
| 757 | QString QXmlStreamReader::tokenString() const | - | ||||||||||||||||||||||||||||||
| 758 | { | - | ||||||||||||||||||||||||||||||
| 759 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 760 | return QLatin1String(QXmlStreamReader_tokenTypeString_string + executed 1903 times by 1 test: return QLatin1String(QXmlStreamReader_tokenTypeString_string + QXmlStreamReader_tokenTypeString_indices[d->type]);Executed by:
| 1903 | ||||||||||||||||||||||||||||||
| 761 | QXmlStreamReader_tokenTypeString_indices[d->type]); executed 1903 times by 1 test: return QLatin1String(QXmlStreamReader_tokenTypeString_string + QXmlStreamReader_tokenTypeString_indices[d->type]);Executed by:
| 1903 | ||||||||||||||||||||||||||||||
| 762 | } | - | ||||||||||||||||||||||||||||||
| 763 | - | |||||||||||||||||||||||||||||||
| 764 | #endif // QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 765 | - | |||||||||||||||||||||||||||||||
| 766 | QXmlStreamPrivateTagStack::QXmlStreamPrivateTagStack() | - | ||||||||||||||||||||||||||||||
| 767 | { | - | ||||||||||||||||||||||||||||||
| 768 | tagStack.reserve(16); | - | ||||||||||||||||||||||||||||||
| 769 | tagStackStringStorage.reserve(32); | - | ||||||||||||||||||||||||||||||
| 770 | tagStackStringStorageSize = 0; | - | ||||||||||||||||||||||||||||||
| 771 | NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 772 | namespaceDeclaration.prefix = addToStringStorage(QLatin1String("xml")); | - | ||||||||||||||||||||||||||||||
| 773 | namespaceDeclaration.namespaceUri = addToStringStorage(QLatin1String("http://www.w3.org/XML/1998/namespace")); | - | ||||||||||||||||||||||||||||||
| 774 | initialTagStackStringStorageSize = tagStackStringStorageSize; | - | ||||||||||||||||||||||||||||||
| 775 | } executed 5757 times by 17 tests: end of blockExecuted by:
| 5757 | ||||||||||||||||||||||||||||||
| 776 | - | |||||||||||||||||||||||||||||||
| 777 | #ifndef QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 778 | - | |||||||||||||||||||||||||||||||
| 779 | QXmlStreamReaderPrivate::QXmlStreamReaderPrivate(QXmlStreamReader *q) | - | ||||||||||||||||||||||||||||||
| 780 | :q_ptr(q) | - | ||||||||||||||||||||||||||||||
| 781 | { | - | ||||||||||||||||||||||||||||||
| 782 | device = 0; | - | ||||||||||||||||||||||||||||||
| 783 | deleteDevice = false; | - | ||||||||||||||||||||||||||||||
| 784 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 785 | decoder = 0; | - | ||||||||||||||||||||||||||||||
| 786 | #endif | - | ||||||||||||||||||||||||||||||
| 787 | stack_size = 64; | - | ||||||||||||||||||||||||||||||
| 788 | sym_stack = 0; | - | ||||||||||||||||||||||||||||||
| 789 | state_stack = 0; | - | ||||||||||||||||||||||||||||||
| 790 | reallocateStack(); | - | ||||||||||||||||||||||||||||||
| 791 | entityResolver = 0; | - | ||||||||||||||||||||||||||||||
| 792 | init(); | - | ||||||||||||||||||||||||||||||
| 793 | entityHash.insert(QLatin1String("lt"), Entity::createLiteral(QLatin1String("<"))); | - | ||||||||||||||||||||||||||||||
| 794 | entityHash.insert(QLatin1String("gt"), Entity::createLiteral(QLatin1String(">"))); | - | ||||||||||||||||||||||||||||||
| 795 | entityHash.insert(QLatin1String("amp"), Entity::createLiteral(QLatin1String("&"))); | - | ||||||||||||||||||||||||||||||
| 796 | entityHash.insert(QLatin1String("apos"), Entity::createLiteral(QLatin1String("'"))); | - | ||||||||||||||||||||||||||||||
| 797 | entityHash.insert(QLatin1String("quot"), Entity::createLiteral(QLatin1String("\""))); | - | ||||||||||||||||||||||||||||||
| 798 | } executed 5013 times by 15 tests: end of blockExecuted by:
| 5013 | ||||||||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||||||||
| 800 | void QXmlStreamReaderPrivate::init() | - | ||||||||||||||||||||||||||||||
| 801 | { | - | ||||||||||||||||||||||||||||||
| 802 | scanDtd = false; | - | ||||||||||||||||||||||||||||||
| 803 | token = -1; | - | ||||||||||||||||||||||||||||||
| 804 | token_char = 0; | - | ||||||||||||||||||||||||||||||
| 805 | isEmptyElement = false; | - | ||||||||||||||||||||||||||||||
| 806 | isWhitespace = true; | - | ||||||||||||||||||||||||||||||
| 807 | isCDATA = false; | - | ||||||||||||||||||||||||||||||
| 808 | standalone = false; | - | ||||||||||||||||||||||||||||||
| 809 | tos = 0; | - | ||||||||||||||||||||||||||||||
| 810 | resumeReduction = 0; | - | ||||||||||||||||||||||||||||||
| 811 | state_stack[tos++] = 0; | - | ||||||||||||||||||||||||||||||
| 812 | state_stack[tos] = 0; | - | ||||||||||||||||||||||||||||||
| 813 | putStack.clear(); | - | ||||||||||||||||||||||||||||||
| 814 | putStack.reserve(32); | - | ||||||||||||||||||||||||||||||
| 815 | textBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 816 | textBuffer.reserve(256); | - | ||||||||||||||||||||||||||||||
| 817 | tagStack.clear(); | - | ||||||||||||||||||||||||||||||
| 818 | tagsDone = false; | - | ||||||||||||||||||||||||||||||
| 819 | attributes.clear(); | - | ||||||||||||||||||||||||||||||
| 820 | attributes.reserve(16); | - | ||||||||||||||||||||||||||||||
| 821 | lineNumber = lastLineStart = characterOffset = 0; | - | ||||||||||||||||||||||||||||||
| 822 | readBufferPos = 0; | - | ||||||||||||||||||||||||||||||
| 823 | nbytesread = 0; | - | ||||||||||||||||||||||||||||||
| 824 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 825 | codec = QTextCodec::codecForMib(106); // utf8 | - | ||||||||||||||||||||||||||||||
| 826 | delete decoder; | - | ||||||||||||||||||||||||||||||
| 827 | decoder = 0; | - | ||||||||||||||||||||||||||||||
| 828 | #endif | - | ||||||||||||||||||||||||||||||
| 829 | attributeStack.clear(); | - | ||||||||||||||||||||||||||||||
| 830 | attributeStack.reserve(16); | - | ||||||||||||||||||||||||||||||
| 831 | entityParser = 0; | - | ||||||||||||||||||||||||||||||
| 832 | hasCheckedStartDocument = false; | - | ||||||||||||||||||||||||||||||
| 833 | normalizeLiterals = false; | - | ||||||||||||||||||||||||||||||
| 834 | hasSeenTag = false; | - | ||||||||||||||||||||||||||||||
| 835 | atEnd = false; | - | ||||||||||||||||||||||||||||||
| 836 | inParseEntity = false; | - | ||||||||||||||||||||||||||||||
| 837 | referenceToUnparsedEntityDetected = false; | - | ||||||||||||||||||||||||||||||
| 838 | referenceToParameterEntityDetected = false; | - | ||||||||||||||||||||||||||||||
| 839 | hasExternalDtdSubset = false; | - | ||||||||||||||||||||||||||||||
| 840 | lockEncoding = false; | - | ||||||||||||||||||||||||||||||
| 841 | namespaceProcessing = true; | - | ||||||||||||||||||||||||||||||
| 842 | rawReadBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 843 | dataBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 844 | readBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 845 | tagStackStringStorageSize = initialTagStackStringStorageSize; | - | ||||||||||||||||||||||||||||||
| 846 | - | |||||||||||||||||||||||||||||||
| 847 | type = QXmlStreamReader::NoToken; | - | ||||||||||||||||||||||||||||||
| 848 | error = QXmlStreamReader::NoError; | - | ||||||||||||||||||||||||||||||
| 849 | } executed 7289 times by 15 tests: end of blockExecuted by:
| 7289 | ||||||||||||||||||||||||||||||
| 850 | - | |||||||||||||||||||||||||||||||
| 851 | /* | - | ||||||||||||||||||||||||||||||
| 852 | Well-formed requires that we verify entity values. We do this with a | - | ||||||||||||||||||||||||||||||
| 853 | standard parser. | - | ||||||||||||||||||||||||||||||
| 854 | */ | - | ||||||||||||||||||||||||||||||
| 855 | void QXmlStreamReaderPrivate::parseEntity(const QString &value) | - | ||||||||||||||||||||||||||||||
| 856 | { | - | ||||||||||||||||||||||||||||||
| 857 | Q_Q(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||||||||
| 859 | if (value.isEmpty())
| 14-124 | ||||||||||||||||||||||||||||||
| 860 | return; executed 14 times by 1 test: return;Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 861 | - | |||||||||||||||||||||||||||||||
| 862 | - | |||||||||||||||||||||||||||||||
| 863 | if (!entityParser)
| 33-91 | ||||||||||||||||||||||||||||||
| 864 | entityParser = new QXmlStreamReaderPrivate(q); executed 91 times by 1 test: entityParser = new QXmlStreamReaderPrivate(q);Executed by:
| 91 | ||||||||||||||||||||||||||||||
| 865 | else | - | ||||||||||||||||||||||||||||||
| 866 | entityParser->init(); executed 33 times by 1 test: entityParser->init();Executed by:
| 33 | ||||||||||||||||||||||||||||||
| 867 | entityParser->inParseEntity = true; | - | ||||||||||||||||||||||||||||||
| 868 | entityParser->readBuffer = value; | - | ||||||||||||||||||||||||||||||
| 869 | entityParser->injectToken(PARSE_ENTITY); | - | ||||||||||||||||||||||||||||||
| 870 | while (!entityParser->atEnd && entityParser->type != QXmlStreamReader::Invalid)
| 6-215 | ||||||||||||||||||||||||||||||
| 871 | entityParser->parse(); executed 209 times by 1 test: entityParser->parse();Executed by:
| 209 | ||||||||||||||||||||||||||||||
| 872 | if (entityParser->type == QXmlStreamReader::Invalid || entityParser->tagStack.size())
| 2-108 | ||||||||||||||||||||||||||||||
| 873 | raiseWellFormedError(QXmlStream::tr("Invalid entity value.")); executed 18 times by 1 test: raiseWellFormedError(QXmlStream::tr("Invalid entity value."));Executed by:
| 18 | ||||||||||||||||||||||||||||||
| 874 | - | |||||||||||||||||||||||||||||||
| 875 | } executed 124 times by 1 test: end of blockExecuted by:
| 124 | ||||||||||||||||||||||||||||||
| 876 | - | |||||||||||||||||||||||||||||||
| 877 | inline void QXmlStreamReaderPrivate::reallocateStack() | - | ||||||||||||||||||||||||||||||
| 878 | { | - | ||||||||||||||||||||||||||||||
| 879 | stack_size <<= 1; | - | ||||||||||||||||||||||||||||||
| 880 | sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value))); | - | ||||||||||||||||||||||||||||||
| 881 | Q_CHECK_PTR(sym_stack); never executed: qBadAlloc();
| 0-5014 | ||||||||||||||||||||||||||||||
| 882 | state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int))); | - | ||||||||||||||||||||||||||||||
| 883 | Q_CHECK_PTR(state_stack); never executed: qBadAlloc();
| 0-5014 | ||||||||||||||||||||||||||||||
| 884 | } executed 5014 times by 15 tests: end of blockExecuted by:
| 5014 | ||||||||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||||||||
| 886 | - | |||||||||||||||||||||||||||||||
| 887 | QXmlStreamReaderPrivate::~QXmlStreamReaderPrivate() | - | ||||||||||||||||||||||||||||||
| 888 | { | - | ||||||||||||||||||||||||||||||
| 889 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 890 | delete decoder; | - | ||||||||||||||||||||||||||||||
| 891 | #endif | - | ||||||||||||||||||||||||||||||
| 892 | free(sym_stack); | - | ||||||||||||||||||||||||||||||
| 893 | free(state_stack); | - | ||||||||||||||||||||||||||||||
| 894 | delete entityParser; | - | ||||||||||||||||||||||||||||||
| 895 | } executed 5013 times by 15 tests: end of blockExecuted by:
| 5013 | ||||||||||||||||||||||||||||||
| 896 | - | |||||||||||||||||||||||||||||||
| 897 | - | |||||||||||||||||||||||||||||||
| 898 | inline uint QXmlStreamReaderPrivate::filterCarriageReturn() | - | ||||||||||||||||||||||||||||||
| 899 | { | - | ||||||||||||||||||||||||||||||
| 900 | uint peekc = peekChar(); | - | ||||||||||||||||||||||||||||||
| 901 | if (peekc == '\n') {
| 2158-8307 | ||||||||||||||||||||||||||||||
| 902 | if (putStack.size())
| 0-8307 | ||||||||||||||||||||||||||||||
| 903 | putStack.pop(); never executed: putStack.pop(); | 0 | ||||||||||||||||||||||||||||||
| 904 | else | - | ||||||||||||||||||||||||||||||
| 905 | ++readBufferPos; executed 8307 times by 1 test: ++readBufferPos;Executed by:
| 8307 | ||||||||||||||||||||||||||||||
| 906 | return peekc; executed 8307 times by 1 test: return peekc;Executed by:
| 8307 | ||||||||||||||||||||||||||||||
| 907 | } | - | ||||||||||||||||||||||||||||||
| 908 | if (peekc == StreamEOF) {
| 12-2146 | ||||||||||||||||||||||||||||||
| 909 | putChar('\r'); | - | ||||||||||||||||||||||||||||||
| 910 | return 0; executed 2146 times by 1 test: return 0;Executed by:
| 2146 | ||||||||||||||||||||||||||||||
| 911 | } | - | ||||||||||||||||||||||||||||||
| 912 | return '\n'; executed 12 times by 1 test: return '\n';Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 913 | } | - | ||||||||||||||||||||||||||||||
| 914 | - | |||||||||||||||||||||||||||||||
| 915 | /*! | - | ||||||||||||||||||||||||||||||
| 916 | \internal | - | ||||||||||||||||||||||||||||||
| 917 | If the end of the file is encountered, ~0 is returned. | - | ||||||||||||||||||||||||||||||
| 918 | */ | - | ||||||||||||||||||||||||||||||
| 919 | inline uint QXmlStreamReaderPrivate::getChar() | - | ||||||||||||||||||||||||||||||
| 920 | { | - | ||||||||||||||||||||||||||||||
| 921 | uint c; | - | ||||||||||||||||||||||||||||||
| 922 | if (putStack.size()) {
| 2030335-13769355 | ||||||||||||||||||||||||||||||
| 923 | c = atEnd ? StreamEOF : putStack.pop();
| 4859-2025476 | ||||||||||||||||||||||||||||||
| 924 | } else { executed 2030335 times by 15 tests: end of blockExecuted by:
| 2030335 | ||||||||||||||||||||||||||||||
| 925 | if (readBufferPos < readBuffer.size())
| 114655-13654700 | ||||||||||||||||||||||||||||||
| 926 | c = readBuffer.at(readBufferPos++).unicode(); executed 13654700 times by 15 tests: c = readBuffer.at(readBufferPos++).unicode();Executed by:
| 13654700 | ||||||||||||||||||||||||||||||
| 927 | else | - | ||||||||||||||||||||||||||||||
| 928 | c = getChar_helper(); executed 114655 times by 15 tests: c = getChar_helper();Executed by:
| 114655 | ||||||||||||||||||||||||||||||
| 929 | } | - | ||||||||||||||||||||||||||||||
| 930 | - | |||||||||||||||||||||||||||||||
| 931 | return c; executed 15799690 times by 15 tests: return c;Executed by:
| 15799690 | ||||||||||||||||||||||||||||||
| 932 | } | - | ||||||||||||||||||||||||||||||
| 933 | - | |||||||||||||||||||||||||||||||
| 934 | inline uint QXmlStreamReaderPrivate::peekChar() | - | ||||||||||||||||||||||||||||||
| 935 | { | - | ||||||||||||||||||||||||||||||
| 936 | uint c; | - | ||||||||||||||||||||||||||||||
| 937 | if (putStack.size()) {
| 14016-81284 | ||||||||||||||||||||||||||||||
| 938 | c = putStack.top(); | - | ||||||||||||||||||||||||||||||
| 939 | } else if (readBufferPos < readBuffer.size()) { executed 14016 times by 13 tests: end of blockExecuted by:
| 6682-74602 | ||||||||||||||||||||||||||||||
| 940 | c = readBuffer.at(readBufferPos).unicode(); | - | ||||||||||||||||||||||||||||||
| 941 | } else { executed 74602 times by 14 tests: end of blockExecuted by:
| 74602 | ||||||||||||||||||||||||||||||
| 942 | if ((c = getChar_helper()) != StreamEOF)
| 3331-3351 | ||||||||||||||||||||||||||||||
| 943 | --readBufferPos; executed 3331 times by 1 test: --readBufferPos;Executed by:
| 3331 | ||||||||||||||||||||||||||||||
| 944 | } executed 6682 times by 1 test: end of blockExecuted by:
| 6682 | ||||||||||||||||||||||||||||||
| 945 | - | |||||||||||||||||||||||||||||||
| 946 | return c; executed 95300 times by 14 tests: return c;Executed by:
| 95300 | ||||||||||||||||||||||||||||||
| 947 | } | - | ||||||||||||||||||||||||||||||
| 948 | - | |||||||||||||||||||||||||||||||
| 949 | /*! | - | ||||||||||||||||||||||||||||||
| 950 | \internal | - | ||||||||||||||||||||||||||||||
| 951 | - | |||||||||||||||||||||||||||||||
| 952 | Scans characters until \a str is encountered, and validates the characters | - | ||||||||||||||||||||||||||||||
| 953 | as according to the Char[2] production and do the line-ending normalization. | - | ||||||||||||||||||||||||||||||
| 954 | If any character is invalid, false is returned, otherwise true upon success. | - | ||||||||||||||||||||||||||||||
| 955 | - | |||||||||||||||||||||||||||||||
| 956 | If \a tokenToInject is not less than zero, injectToken() is called with | - | ||||||||||||||||||||||||||||||
| 957 | \a tokenToInject when \a str is found. | - | ||||||||||||||||||||||||||||||
| 958 | - | |||||||||||||||||||||||||||||||
| 959 | If any error occurred, false is returned, otherwise true. | - | ||||||||||||||||||||||||||||||
| 960 | */ | - | ||||||||||||||||||||||||||||||
| 961 | bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject) | - | ||||||||||||||||||||||||||||||
| 962 | { | - | ||||||||||||||||||||||||||||||
| 963 | int pos = textBuffer.size(); | - | ||||||||||||||||||||||||||||||
| 964 | int oldLineNumber = lineNumber; | - | ||||||||||||||||||||||||||||||
| 965 | - | |||||||||||||||||||||||||||||||
| 966 | uint c; | - | ||||||||||||||||||||||||||||||
| 967 | while ((c = getChar()) != StreamEOF) {
| 5870-1102147 | ||||||||||||||||||||||||||||||
| 968 | /* First, we do the validation & normalization. */ | - | ||||||||||||||||||||||||||||||
| 969 | switch (c) { | - | ||||||||||||||||||||||||||||||
| 970 | case '\r': executed 407 times by 1 test: case '\r':Executed by:
| 407 | ||||||||||||||||||||||||||||||
| 971 | if ((c = filterCarriageReturn()) == 0)
| 3-404 | ||||||||||||||||||||||||||||||
| 972 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 973 | // fall through | - | ||||||||||||||||||||||||||||||
| 974 | case '\n': code before this statement executed 404 times by 1 test: case '\n':Executed by:
executed 1704 times by 3 tests: case '\n':Executed by:
| 404-1704 | ||||||||||||||||||||||||||||||
| 975 | ++lineNumber; | - | ||||||||||||||||||||||||||||||
| 976 | lastLineStart = characterOffset + readBufferPos; | - | ||||||||||||||||||||||||||||||
| 977 | // fall through | - | ||||||||||||||||||||||||||||||
| 978 | case '\t': code before this statement executed 2108 times by 3 tests: case '\t':Executed by:
executed 723 times by 1 test: case '\t':Executed by:
| 723-2108 | ||||||||||||||||||||||||||||||
| 979 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 980 | continue; executed 2831 times by 3 tests: continue;Executed by:
| 2831 | ||||||||||||||||||||||||||||||
| 981 | default: executed 1099313 times by 4 tests: default:Executed by:
| 1099313 | ||||||||||||||||||||||||||||||
| 982 | if (c < 0x20 || (c > 0xFFFD && c < 0x10000) || c > QChar::LastValidCodePoint ) {
| 0-1099277 | ||||||||||||||||||||||||||||||
| 983 | raiseWellFormedError(QXmlStream::tr("Invalid XML character.")); | - | ||||||||||||||||||||||||||||||
| 984 | lineNumber = oldLineNumber; | - | ||||||||||||||||||||||||||||||
| 985 | return false; executed 41 times by 1 test: return false;Executed by:
| 41 | ||||||||||||||||||||||||||||||
| 986 | } | - | ||||||||||||||||||||||||||||||
| 987 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 988 | } executed 1099272 times by 4 tests: end of blockExecuted by:
| 1099272 | ||||||||||||||||||||||||||||||
| 989 | - | |||||||||||||||||||||||||||||||
| 990 | - | |||||||||||||||||||||||||||||||
| 991 | /* Second, attempt to lookup str. */ | - | ||||||||||||||||||||||||||||||
| 992 | if (c == uint(*str)) {
| 64450-1034825 | ||||||||||||||||||||||||||||||
| 993 | if (!*(str + 1)) {
| 0-64450 | ||||||||||||||||||||||||||||||
| 994 | if (tokenToInject >= 0)
| 0 | ||||||||||||||||||||||||||||||
| 995 | injectToken(tokenToInject); never executed: injectToken(tokenToInject); | 0 | ||||||||||||||||||||||||||||||
| 996 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 997 | } else { | - | ||||||||||||||||||||||||||||||
| 998 | if (scanString(str + 1, tokenToInject, false))
| 894-63556 | ||||||||||||||||||||||||||||||
| 999 | return true; executed 63556 times by 4 tests: return true;Executed by:
| 63556 | ||||||||||||||||||||||||||||||
| 1000 | } executed 894 times by 3 tests: end of blockExecuted by:
| 894 | ||||||||||||||||||||||||||||||
| 1001 | } | - | ||||||||||||||||||||||||||||||
| 1002 | } executed 1035719 times by 4 tests: end of blockExecuted by:
| 1035719 | ||||||||||||||||||||||||||||||
| 1003 | putString(textBuffer, pos); | - | ||||||||||||||||||||||||||||||
| 1004 | textBuffer.resize(pos); | - | ||||||||||||||||||||||||||||||
| 1005 | lineNumber = oldLineNumber; | - | ||||||||||||||||||||||||||||||
| 1006 | return false; executed 5870 times by 1 test: return false;Executed by:
| 5870 | ||||||||||||||||||||||||||||||
| 1007 | } | - | ||||||||||||||||||||||||||||||
| 1008 | - | |||||||||||||||||||||||||||||||
| 1009 | bool QXmlStreamReaderPrivate::scanString(const char *str, short tokenToInject, bool requireSpace) | - | ||||||||||||||||||||||||||||||
| 1010 | { | - | ||||||||||||||||||||||||||||||
| 1011 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1012 | while (str[n]) {
| 125737-598096 | ||||||||||||||||||||||||||||||
| 1013 | uint c = getChar(); | - | ||||||||||||||||||||||||||||||
| 1014 | if (c != ushort(str[n])) {
| 24872-573224 | ||||||||||||||||||||||||||||||
| 1015 | if (c != StreamEOF)
| 6701-18171 | ||||||||||||||||||||||||||||||
| 1016 | putChar(c); executed 6701 times by 14 tests: putChar(c);Executed by:
| 6701 | ||||||||||||||||||||||||||||||
| 1017 | while (n--) {
| 24872-39487 | ||||||||||||||||||||||||||||||
| 1018 | putChar(ushort(str[n])); | - | ||||||||||||||||||||||||||||||
| 1019 | } executed 39487 times by 13 tests: end of blockExecuted by:
| 39487 | ||||||||||||||||||||||||||||||
| 1020 | return false; executed 24872 times by 14 tests: return false;Executed by:
| 24872 | ||||||||||||||||||||||||||||||
| 1021 | } | - | ||||||||||||||||||||||||||||||
| 1022 | ++n; | - | ||||||||||||||||||||||||||||||
| 1023 | } executed 573224 times by 15 tests: end of blockExecuted by:
| 573224 | ||||||||||||||||||||||||||||||
| 1024 | for (int i = 0; i < n; ++i)
| 125737-533737 | ||||||||||||||||||||||||||||||
| 1025 | textBuffer += QChar(ushort(str[i])); executed 533737 times by 14 tests: textBuffer += QChar(ushort(str[i]));Executed by:
| 533737 | ||||||||||||||||||||||||||||||
| 1026 | if (requireSpace) {
| 11286-114451 | ||||||||||||||||||||||||||||||
| 1027 | int s = fastScanSpace(); | - | ||||||||||||||||||||||||||||||
| 1028 | if (!s || atEnd) {
| 1435-9677 | ||||||||||||||||||||||||||||||
| 1029 | int pos = textBuffer.size() - n - s; | - | ||||||||||||||||||||||||||||||
| 1030 | putString(textBuffer, pos); | - | ||||||||||||||||||||||||||||||
| 1031 | textBuffer.resize(pos); | - | ||||||||||||||||||||||||||||||
| 1032 | return false; executed 3044 times by 1 test: return false;Executed by:
| 3044 | ||||||||||||||||||||||||||||||
| 1033 | } | - | ||||||||||||||||||||||||||||||
| 1034 | } executed 8242 times by 14 tests: end of blockExecuted by:
| 8242 | ||||||||||||||||||||||||||||||
| 1035 | if (tokenToInject >= 0)
| 59137-63556 | ||||||||||||||||||||||||||||||
| 1036 | injectToken(tokenToInject); executed 59137 times by 14 tests: injectToken(tokenToInject);Executed by:
| 59137 | ||||||||||||||||||||||||||||||
| 1037 | return true; executed 122693 times by 14 tests: return true;Executed by:
| 122693 | ||||||||||||||||||||||||||||||
| 1038 | } | - | ||||||||||||||||||||||||||||||
| 1039 | - | |||||||||||||||||||||||||||||||
| 1040 | bool QXmlStreamReaderPrivate::scanAfterLangleBang() | - | ||||||||||||||||||||||||||||||
| 1041 | { | - | ||||||||||||||||||||||||||||||
| 1042 | switch (peekChar()) { | - | ||||||||||||||||||||||||||||||
| 1043 | case '[': executed 46900 times by 2 tests: case '[':Executed by:
| 46900 | ||||||||||||||||||||||||||||||
| 1044 | return scanString(spell[CDATA_START], CDATA_START, false); executed 46900 times by 2 tests: return scanString(spell[CDATA_START], CDATA_START, false);Executed by:
| 46900 | ||||||||||||||||||||||||||||||
| 1045 | case 'D': executed 3815 times by 13 tests: case 'D':Executed by:
| 3815 | ||||||||||||||||||||||||||||||
| 1046 | return scanString(spell[DOCTYPE], DOCTYPE); executed 3815 times by 13 tests: return scanString(spell[DOCTYPE], DOCTYPE);Executed by:
| 3815 | ||||||||||||||||||||||||||||||
| 1047 | case 'A': executed 2355 times by 2 tests: case 'A':Executed by:
| 2355 | ||||||||||||||||||||||||||||||
| 1048 | return scanString(spell[ATTLIST], ATTLIST); executed 2355 times by 2 tests: return scanString(spell[ATTLIST], ATTLIST);Executed by:
| 2355 | ||||||||||||||||||||||||||||||
| 1049 | case 'N': executed 382 times by 1 test: case 'N':Executed by:
| 382 | ||||||||||||||||||||||||||||||
| 1050 | return scanString(spell[NOTATION], NOTATION); executed 382 times by 1 test: return scanString(spell[NOTATION], NOTATION);Executed by:
| 382 | ||||||||||||||||||||||||||||||
| 1051 | case 'E': executed 6772 times by 2 tests: case 'E':Executed by:
| 6772 | ||||||||||||||||||||||||||||||
| 1052 | if (scanString(spell[ELEMENT], ELEMENT))
| 2196-4576 | ||||||||||||||||||||||||||||||
| 1053 | return true; executed 2196 times by 2 tests: return true;Executed by:
| 2196 | ||||||||||||||||||||||||||||||
| 1054 | return scanString(spell[ENTITY], ENTITY); executed 4576 times by 1 test: return scanString(spell[ENTITY], ENTITY);Executed by:
| 4576 | ||||||||||||||||||||||||||||||
| 1055 | - | |||||||||||||||||||||||||||||||
| 1056 | default: executed 17408 times by 4 tests: default:Executed by:
| 17408 | ||||||||||||||||||||||||||||||
| 1057 | ; | - | ||||||||||||||||||||||||||||||
| 1058 | }; executed 17408 times by 4 tests: end of blockExecuted by:
| 17408 | ||||||||||||||||||||||||||||||
| 1059 | return false; executed 17408 times by 4 tests: return false;Executed by:
| 17408 | ||||||||||||||||||||||||||||||
| 1060 | } | - | ||||||||||||||||||||||||||||||
| 1061 | - | |||||||||||||||||||||||||||||||
| 1062 | bool QXmlStreamReaderPrivate::scanPublicOrSystem() | - | ||||||||||||||||||||||||||||||
| 1063 | { | - | ||||||||||||||||||||||||||||||
| 1064 | switch (peekChar()) { | - | ||||||||||||||||||||||||||||||
| 1065 | case 'S': executed 440 times by 1 test: case 'S':Executed by:
| 440 | ||||||||||||||||||||||||||||||
| 1066 | return scanString(spell[SYSTEM], SYSTEM); executed 440 times by 1 test: return scanString(spell[SYSTEM], SYSTEM);Executed by:
| 440 | ||||||||||||||||||||||||||||||
| 1067 | case 'P': executed 386 times by 12 tests: case 'P':Executed by:
| 386 | ||||||||||||||||||||||||||||||
| 1068 | return scanString(spell[PUBLIC], PUBLIC); executed 386 times by 12 tests: return scanString(spell[PUBLIC], PUBLIC);Executed by:
| 386 | ||||||||||||||||||||||||||||||
| 1069 | default: executed 1864 times by 2 tests: default:Executed by:
| 1864 | ||||||||||||||||||||||||||||||
| 1070 | ; | - | ||||||||||||||||||||||||||||||
| 1071 | } executed 1864 times by 2 tests: end of blockExecuted by:
| 1864 | ||||||||||||||||||||||||||||||
| 1072 | return false; executed 1864 times by 2 tests: return false;Executed by:
| 1864 | ||||||||||||||||||||||||||||||
| 1073 | } | - | ||||||||||||||||||||||||||||||
| 1074 | - | |||||||||||||||||||||||||||||||
| 1075 | bool QXmlStreamReaderPrivate::scanNData() | - | ||||||||||||||||||||||||||||||
| 1076 | { | - | ||||||||||||||||||||||||||||||
| 1077 | if (fastScanSpace()) {
| 48-150 | ||||||||||||||||||||||||||||||
| 1078 | if (scanString(spell[NDATA], NDATA))
| 47-103 | ||||||||||||||||||||||||||||||
| 1079 | return true; executed 47 times by 1 test: return true;Executed by:
| 47 | ||||||||||||||||||||||||||||||
| 1080 | putChar(' '); | - | ||||||||||||||||||||||||||||||
| 1081 | } executed 103 times by 1 test: end of blockExecuted by:
| 103 | ||||||||||||||||||||||||||||||
| 1082 | return false; executed 151 times by 1 test: return false;Executed by:
| 151 | ||||||||||||||||||||||||||||||
| 1083 | } | - | ||||||||||||||||||||||||||||||
| 1084 | - | |||||||||||||||||||||||||||||||
| 1085 | bool QXmlStreamReaderPrivate::scanAfterDefaultDecl() | - | ||||||||||||||||||||||||||||||
| 1086 | { | - | ||||||||||||||||||||||||||||||
| 1087 | switch (peekChar()) { | - | ||||||||||||||||||||||||||||||
| 1088 | case 'R': executed 615 times by 2 tests: case 'R':Executed by:
| 615 | ||||||||||||||||||||||||||||||
| 1089 | return scanString(spell[REQUIRED], REQUIRED, false); executed 615 times by 2 tests: return scanString(spell[REQUIRED], REQUIRED, false);Executed by:
| 615 | ||||||||||||||||||||||||||||||
| 1090 | case 'I': executed 1387 times by 2 tests: case 'I':Executed by:
| 1387 | ||||||||||||||||||||||||||||||
| 1091 | return scanString(spell[IMPLIED], IMPLIED, false); executed 1387 times by 2 tests: return scanString(spell[IMPLIED], IMPLIED, false);Executed by:
| 1387 | ||||||||||||||||||||||||||||||
| 1092 | case 'F': executed 77 times by 2 tests: case 'F':Executed by:
| 77 | ||||||||||||||||||||||||||||||
| 1093 | return scanString(spell[FIXED], FIXED, false); executed 77 times by 2 tests: return scanString(spell[FIXED], FIXED, false);Executed by:
| 77 | ||||||||||||||||||||||||||||||
| 1094 | default: executed 200 times by 1 test: default:Executed by:
| 200 | ||||||||||||||||||||||||||||||
| 1095 | ; | - | ||||||||||||||||||||||||||||||
| 1096 | } executed 200 times by 1 test: end of blockExecuted by:
| 200 | ||||||||||||||||||||||||||||||
| 1097 | return false; executed 200 times by 1 test: return false;Executed by:
| 200 | ||||||||||||||||||||||||||||||
| 1098 | } | - | ||||||||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||||||||
| 1100 | bool QXmlStreamReaderPrivate::scanAttType() | - | ||||||||||||||||||||||||||||||
| 1101 | { | - | ||||||||||||||||||||||||||||||
| 1102 | switch (peekChar()) { | - | ||||||||||||||||||||||||||||||
| 1103 | case 'C': executed 1351 times by 2 tests: case 'C':Executed by:
| 1351 | ||||||||||||||||||||||||||||||
| 1104 | return scanString(spell[CDATA], CDATA); executed 1351 times by 2 tests: return scanString(spell[CDATA], CDATA);Executed by:
| 1351 | ||||||||||||||||||||||||||||||
| 1105 | case 'I': executed 272 times by 1 test: case 'I':Executed by:
| 272 | ||||||||||||||||||||||||||||||
| 1106 | if (scanString(spell[ID], ID))
| 70-202 | ||||||||||||||||||||||||||||||
| 1107 | return true; executed 70 times by 1 test: return true;Executed by:
| 70 | ||||||||||||||||||||||||||||||
| 1108 | if (scanString(spell[IDREF], IDREF))
| 23-179 | ||||||||||||||||||||||||||||||
| 1109 | return true; executed 23 times by 1 test: return true;Executed by:
| 23 | ||||||||||||||||||||||||||||||
| 1110 | return scanString(spell[IDREFS], IDREFS); executed 179 times by 1 test: return scanString(spell[IDREFS], IDREFS);Executed by:
| 179 | ||||||||||||||||||||||||||||||
| 1111 | case 'E': executed 163 times by 1 test: case 'E':Executed by:
| 163 | ||||||||||||||||||||||||||||||
| 1112 | if (scanString(spell[ENTITY], ENTITY))
| 26-137 | ||||||||||||||||||||||||||||||
| 1113 | return true; executed 26 times by 1 test: return true;Executed by:
| 26 | ||||||||||||||||||||||||||||||
| 1114 | return scanString(spell[ENTITIES], ENTITIES); executed 137 times by 1 test: return scanString(spell[ENTITIES], ENTITIES);Executed by:
| 137 | ||||||||||||||||||||||||||||||
| 1115 | case 'N': executed 334 times by 1 test: case 'N':Executed by:
| 334 | ||||||||||||||||||||||||||||||
| 1116 | if (scanString(spell[NOTATION], NOTATION))
| 42-292 | ||||||||||||||||||||||||||||||
| 1117 | return true; executed 42 times by 1 test: return true;Executed by:
| 42 | ||||||||||||||||||||||||||||||
| 1118 | if (scanString(spell[NMTOKEN], NMTOKEN))
| 24-268 | ||||||||||||||||||||||||||||||
| 1119 | return true; executed 24 times by 1 test: return true;Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 1120 | return scanString(spell[NMTOKENS], NMTOKENS); executed 268 times by 1 test: return scanString(spell[NMTOKENS], NMTOKENS);Executed by:
| 268 | ||||||||||||||||||||||||||||||
| 1121 | default: executed 114 times by 2 tests: default:Executed by:
| 114 | ||||||||||||||||||||||||||||||
| 1122 | ; | - | ||||||||||||||||||||||||||||||
| 1123 | } executed 114 times by 2 tests: end of blockExecuted by:
| 114 | ||||||||||||||||||||||||||||||
| 1124 | return false; executed 114 times by 2 tests: return false;Executed by:
| 114 | ||||||||||||||||||||||||||||||
| 1125 | } | - | ||||||||||||||||||||||||||||||
| 1126 | - | |||||||||||||||||||||||||||||||
| 1127 | /*! | - | ||||||||||||||||||||||||||||||
| 1128 | \internal | - | ||||||||||||||||||||||||||||||
| 1129 | - | |||||||||||||||||||||||||||||||
| 1130 | Scan strings with quotes or apostrophes surround them. For instance, | - | ||||||||||||||||||||||||||||||
| 1131 | attributes, the version and encoding field in the XML prolog and | - | ||||||||||||||||||||||||||||||
| 1132 | entity declarations. | - | ||||||||||||||||||||||||||||||
| 1133 | - | |||||||||||||||||||||||||||||||
| 1134 | If normalizeLiterals is set to true, the function also normalizes | - | ||||||||||||||||||||||||||||||
| 1135 | whitespace. It is set to true when the first start tag is | - | ||||||||||||||||||||||||||||||
| 1136 | encountered. | - | ||||||||||||||||||||||||||||||
| 1137 | - | |||||||||||||||||||||||||||||||
| 1138 | */ | - | ||||||||||||||||||||||||||||||
| 1139 | inline int QXmlStreamReaderPrivate::fastScanLiteralContent() | - | ||||||||||||||||||||||||||||||
| 1140 | { | - | ||||||||||||||||||||||||||||||
| 1141 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1142 | uint c; | - | ||||||||||||||||||||||||||||||
| 1143 | while ((c = getChar()) != StreamEOF) {
| 2235-1095169 | ||||||||||||||||||||||||||||||
| 1144 | switch (ushort(c)) { | - | ||||||||||||||||||||||||||||||
| 1145 | case 0xfffe: never executed: case 0xfffe: | 0 | ||||||||||||||||||||||||||||||
| 1146 | case 0xffff: never executed: case 0xffff: | 0 | ||||||||||||||||||||||||||||||
| 1147 | case 0: executed 82 times by 1 test: case 0:Executed by:
| 82 | ||||||||||||||||||||||||||||||
| 1148 | /* The putChar() call is necessary so the parser re-gets | - | ||||||||||||||||||||||||||||||
| 1149 | * the character from the input source, when raising an error. */ | - | ||||||||||||||||||||||||||||||
| 1150 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1151 | return n; executed 82 times by 1 test: return n;Executed by:
| 82 | ||||||||||||||||||||||||||||||
| 1152 | case '\r': executed 24 times by 1 test: case '\r':Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 1153 | if (filterCarriageReturn() == 0)
| 1-23 | ||||||||||||||||||||||||||||||
| 1154 | return n; executed 1 time by 1 test: return n;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1155 | // fall through | - | ||||||||||||||||||||||||||||||
| 1156 | case '\n': code before this statement executed 23 times by 1 test: case '\n':Executed by:
executed 478 times by 2 tests: case '\n':Executed by:
| 23-478 | ||||||||||||||||||||||||||||||
| 1157 | ++lineNumber; | - | ||||||||||||||||||||||||||||||
| 1158 | lastLineStart = characterOffset + readBufferPos; | - | ||||||||||||||||||||||||||||||
| 1159 | // fall through | - | ||||||||||||||||||||||||||||||
| 1160 | case ' ': code before this statement executed 501 times by 2 tests: case ' ':Executed by:
executed 15480 times by 14 tests: case ' ':Executed by:
| 501-15480 | ||||||||||||||||||||||||||||||
| 1161 | case '\t': executed 18 times by 1 test: case '\t':Executed by:
| 18 | ||||||||||||||||||||||||||||||
| 1162 | if (normalizeLiterals)
| 1049-14950 | ||||||||||||||||||||||||||||||
| 1163 | textBuffer += QLatin1Char(' '); executed 14950 times by 4 tests: textBuffer += QLatin1Char(' ');Executed by:
| 14950 | ||||||||||||||||||||||||||||||
| 1164 | else | - | ||||||||||||||||||||||||||||||
| 1165 | textBuffer += QChar(c); executed 1049 times by 12 tests: textBuffer += QChar(c);Executed by:
| 1049 | ||||||||||||||||||||||||||||||
| 1166 | ++n; | - | ||||||||||||||||||||||||||||||
| 1167 | break; executed 15999 times by 14 tests: break;Executed by:
| 15999 | ||||||||||||||||||||||||||||||
| 1168 | case '&': executed 1657 times by 4 tests: case '&':Executed by:
| 1657 | ||||||||||||||||||||||||||||||
| 1169 | case '<': executed 19 times by 1 test: case '<':Executed by:
| 19 | ||||||||||||||||||||||||||||||
| 1170 | case '\"': executed 244773 times by 15 tests: case '\"':Executed by:
| 244773 | ||||||||||||||||||||||||||||||
| 1171 | case '\'': executed 245 times by 2 tests: case '\'':Executed by:
| 245 | ||||||||||||||||||||||||||||||
| 1172 | if (!(c & 0xff0000)) {
| 0-246694 | ||||||||||||||||||||||||||||||
| 1173 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1174 | return n; executed 246694 times by 15 tests: return n;Executed by:
| 246694 | ||||||||||||||||||||||||||||||
| 1175 | } | - | ||||||||||||||||||||||||||||||
| 1176 | // fall through | - | ||||||||||||||||||||||||||||||
| 1177 | default: code before this statement never executed: default:executed 832393 times by 15 tests: default:Executed by:
| 0-832393 | ||||||||||||||||||||||||||||||
| 1178 | if (c < 0x20) {
| 3-832390 | ||||||||||||||||||||||||||||||
| 1179 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1180 | return n; executed 3 times by 1 test: return n;Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 1181 | } | - | ||||||||||||||||||||||||||||||
| 1182 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 1183 | ++n; | - | ||||||||||||||||||||||||||||||
| 1184 | } executed 832390 times by 15 tests: end of blockExecuted by:
| 832390 | ||||||||||||||||||||||||||||||
| 1185 | } | - | ||||||||||||||||||||||||||||||
| 1186 | return n; executed 2235 times by 1 test: return n;Executed by:
| 2235 | ||||||||||||||||||||||||||||||
| 1187 | } | - | ||||||||||||||||||||||||||||||
| 1188 | - | |||||||||||||||||||||||||||||||
| 1189 | inline int QXmlStreamReaderPrivate::fastScanSpace() | - | ||||||||||||||||||||||||||||||
| 1190 | { | - | ||||||||||||||||||||||||||||||
| 1191 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1192 | uint c; | - | ||||||||||||||||||||||||||||||
| 1193 | while ((c = getChar()) != StreamEOF) {
| 6683-309203 | ||||||||||||||||||||||||||||||
| 1194 | switch (c) { | - | ||||||||||||||||||||||||||||||
| 1195 | case '\r': executed 323 times by 1 test: case '\r':Executed by:
| 323 | ||||||||||||||||||||||||||||||
| 1196 | if ((c = filterCarriageReturn()) == 0)
| 45-278 | ||||||||||||||||||||||||||||||
| 1197 | return n; executed 45 times by 1 test: return n;Executed by:
| 45 | ||||||||||||||||||||||||||||||
| 1198 | // fall through | - | ||||||||||||||||||||||||||||||
| 1199 | 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 | ||||||||||||||||||||||||||||||
| 1200 | ++lineNumber; | - | ||||||||||||||||||||||||||||||
| 1201 | lastLineStart = characterOffset + readBufferPos; | - | ||||||||||||||||||||||||||||||
| 1202 | // fall through | - | ||||||||||||||||||||||||||||||
| 1203 | case ' ': code before this statement executed 413 times by 2 tests: case ' ':Executed by:
executed 14003 times by 14 tests: case ' ':Executed by:
| 413-14003 | ||||||||||||||||||||||||||||||
| 1204 | case '\t': executed 562 times by 1 test: case '\t':Executed by:
| 562 | ||||||||||||||||||||||||||||||
| 1205 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 1206 | ++n; | - | ||||||||||||||||||||||||||||||
| 1207 | break; executed 14978 times by 14 tests: break;Executed by:
| 14978 | ||||||||||||||||||||||||||||||
| 1208 | default: executed 294180 times by 15 tests: default:Executed by:
| 294180 | ||||||||||||||||||||||||||||||
| 1209 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1210 | return n; executed 294180 times by 15 tests: return n;Executed by:
| 294180 | ||||||||||||||||||||||||||||||
| 1211 | } | - | ||||||||||||||||||||||||||||||
| 1212 | } | - | ||||||||||||||||||||||||||||||
| 1213 | return n; executed 6683 times by 1 test: return n;Executed by:
| 6683 | ||||||||||||||||||||||||||||||
| 1214 | } | - | ||||||||||||||||||||||||||||||
| 1215 | - | |||||||||||||||||||||||||||||||
| 1216 | /*! | - | ||||||||||||||||||||||||||||||
| 1217 | \internal | - | ||||||||||||||||||||||||||||||
| 1218 | - | |||||||||||||||||||||||||||||||
| 1219 | Used for text nodes essentially. That is, characters appearing | - | ||||||||||||||||||||||||||||||
| 1220 | inside elements. | - | ||||||||||||||||||||||||||||||
| 1221 | */ | - | ||||||||||||||||||||||||||||||
| 1222 | inline int QXmlStreamReaderPrivate::fastScanContentCharList() | - | ||||||||||||||||||||||||||||||
| 1223 | { | - | ||||||||||||||||||||||||||||||
| 1224 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1225 | uint c; | - | ||||||||||||||||||||||||||||||
| 1226 | while ((c = getChar()) != StreamEOF) {
| 8002-3619062 | ||||||||||||||||||||||||||||||
| 1227 | switch (ushort(c)) { | - | ||||||||||||||||||||||||||||||
| 1228 | case 0xfffe: never executed: case 0xfffe: | 0 | ||||||||||||||||||||||||||||||
| 1229 | case 0xffff: executed 1 time by 1 test: case 0xffff:Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1230 | case 0: executed 60 times by 1 test: case 0:Executed by:
| 60 | ||||||||||||||||||||||||||||||
| 1231 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1232 | return n; executed 61 times by 1 test: return n;Executed by:
| 61 | ||||||||||||||||||||||||||||||
| 1233 | case ']': { executed 17 times by 1 test: case ']':Executed by:
| 17 | ||||||||||||||||||||||||||||||
| 1234 | isWhitespace = false; | - | ||||||||||||||||||||||||||||||
| 1235 | int pos = textBuffer.size(); | - | ||||||||||||||||||||||||||||||
| 1236 | textBuffer += QChar(ushort(c)); | - | ||||||||||||||||||||||||||||||
| 1237 | ++n; | - | ||||||||||||||||||||||||||||||
| 1238 | while ((c = getChar()) == ']') {
| 11-17 | ||||||||||||||||||||||||||||||
| 1239 | textBuffer += QChar(ushort(c)); | - | ||||||||||||||||||||||||||||||
| 1240 | ++n; | - | ||||||||||||||||||||||||||||||
| 1241 | } executed 11 times by 1 test: end of blockExecuted by:
| 11 | ||||||||||||||||||||||||||||||
| 1242 | if (c == 0) {
| 0-17 | ||||||||||||||||||||||||||||||
| 1243 | putString(textBuffer, pos); | - | ||||||||||||||||||||||||||||||
| 1244 | textBuffer.resize(pos); | - | ||||||||||||||||||||||||||||||
| 1245 | } else if (c == '>' && textBuffer.at(textBuffer.size()-2) == QLatin1Char(']')) { never executed: end of block
| 0-9 | ||||||||||||||||||||||||||||||
| 1246 | raiseWellFormedError(QXmlStream::tr("Sequence ']]>' not allowed in content.")); | - | ||||||||||||||||||||||||||||||
| 1247 | } else { executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||||||||
| 1248 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1249 | break; executed 9 times by 1 test: break;Executed by:
| 9 | ||||||||||||||||||||||||||||||
| 1250 | } | - | ||||||||||||||||||||||||||||||
| 1251 | return n; executed 8 times by 1 test: return n;Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 1252 | } break; dead code: break; | - | ||||||||||||||||||||||||||||||
| 1253 | case '\r': executed 389 times by 1 test: case '\r':Executed by:
| 389 | ||||||||||||||||||||||||||||||
| 1254 | if ((c = filterCarriageReturn()) == 0)
| 127-262 | ||||||||||||||||||||||||||||||
| 1255 | return n; executed 127 times by 1 test: return n;Executed by:
| 127 | ||||||||||||||||||||||||||||||
| 1256 | // fall through | - | ||||||||||||||||||||||||||||||
| 1257 | 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 | ||||||||||||||||||||||||||||||
| 1258 | ++lineNumber; | - | ||||||||||||||||||||||||||||||
| 1259 | lastLineStart = characterOffset + readBufferPos; | - | ||||||||||||||||||||||||||||||
| 1260 | // fall through | - | ||||||||||||||||||||||||||||||
| 1261 | case ' ': code before this statement executed 701 times by 3 tests: case ' ':Executed by:
executed 1097530 times by 13 tests: case ' ':Executed by:
| 701-1097530 | ||||||||||||||||||||||||||||||
| 1262 | case '\t': never executed: case '\t': | 0 | ||||||||||||||||||||||||||||||
| 1263 | textBuffer += QChar(ushort(c)); | - | ||||||||||||||||||||||||||||||
| 1264 | ++n; | - | ||||||||||||||||||||||||||||||
| 1265 | break; executed 1098231 times by 13 tests: break;Executed by:
| 1098231 | ||||||||||||||||||||||||||||||
| 1266 | case '&': executed 967 times by 2 tests: case '&':Executed by:
| 967 | ||||||||||||||||||||||||||||||
| 1267 | case '<': executed 440423 times by 13 tests: case '<':Executed by:
| 440423 | ||||||||||||||||||||||||||||||
| 1268 | if (!(c & 0xff0000)) {
| 0-441390 | ||||||||||||||||||||||||||||||
| 1269 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1270 | return n; executed 441390 times by 13 tests: return n;Executed by:
| 441390 | ||||||||||||||||||||||||||||||
| 1271 | } | - | ||||||||||||||||||||||||||||||
| 1272 | // fall through | - | ||||||||||||||||||||||||||||||
| 1273 | default: code before this statement never executed: default:executed 2079236 times by 3 tests: default:Executed by:
| 0-2079236 | ||||||||||||||||||||||||||||||
| 1274 | if (c < 0x20) {
| 5-2079231 | ||||||||||||||||||||||||||||||
| 1275 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1276 | return n; executed 5 times by 1 test: return n;Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 1277 | } | - | ||||||||||||||||||||||||||||||
| 1278 | isWhitespace = false; | - | ||||||||||||||||||||||||||||||
| 1279 | textBuffer += QChar(ushort(c)); | - | ||||||||||||||||||||||||||||||
| 1280 | ++n; | - | ||||||||||||||||||||||||||||||
| 1281 | } executed 2079231 times by 3 tests: end of blockExecuted by:
| 2079231 | ||||||||||||||||||||||||||||||
| 1282 | } | - | ||||||||||||||||||||||||||||||
| 1283 | return n; executed 8002 times by 1 test: return n;Executed by:
| 8002 | ||||||||||||||||||||||||||||||
| 1284 | } | - | ||||||||||||||||||||||||||||||
| 1285 | - | |||||||||||||||||||||||||||||||
| 1286 | inline int QXmlStreamReaderPrivate::fastScanName(int *prefix) | - | ||||||||||||||||||||||||||||||
| 1287 | { | - | ||||||||||||||||||||||||||||||
| 1288 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1289 | uint c; | - | ||||||||||||||||||||||||||||||
| 1290 | while ((c = getChar()) != StreamEOF) {
| 9761-5104556 | ||||||||||||||||||||||||||||||
| 1291 | switch (c) { | - | ||||||||||||||||||||||||||||||
| 1292 | case '\n': executed 46 times by 1 test: case '\n':Executed by:
| 46 | ||||||||||||||||||||||||||||||
| 1293 | case ' ': executed 199582 times by 15 tests: case ' ':Executed by:
| 199582 | ||||||||||||||||||||||||||||||
| 1294 | case '\t': executed 63 times by 1 test: case '\t':Executed by:
| 63 | ||||||||||||||||||||||||||||||
| 1295 | case '\r': executed 300 times by 1 test: case '\r':Executed by:
| 300 | ||||||||||||||||||||||||||||||
| 1296 | case '&': executed 1 time by 1 test: case '&':Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1297 | case '#': executed 1 time by 1 test: case '#':Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1298 | case '\'': executed 1 time by 1 test: case '\'':Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1299 | case '\"': executed 13 times by 1 test: case '\"':Executed by:
| 13 | ||||||||||||||||||||||||||||||
| 1300 | case '<': executed 2 times by 1 test: case '<':Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1301 | case '>': executed 251479 times by 15 tests: case '>':Executed by:
| 251479 | ||||||||||||||||||||||||||||||
| 1302 | case '[': executed 1 time by 1 test: case '[':Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1303 | case ']': executed 2 times by 1 test: case ']':Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1304 | case '=': executed 270432 times by 15 tests: case '=':Executed by:
| 270432 | ||||||||||||||||||||||||||||||
| 1305 | case '%': never executed: case '%': | 0 | ||||||||||||||||||||||||||||||
| 1306 | case '/': executed 374 times by 4 tests: case '/':Executed by:
| 374 | ||||||||||||||||||||||||||||||
| 1307 | case ';': executed 2130 times by 4 tests: case ';':Executed by:
| 2130 | ||||||||||||||||||||||||||||||
| 1308 | case '?': executed 61 times by 2 tests: case '?':Executed by:
| 61 | ||||||||||||||||||||||||||||||
| 1309 | case '!': executed 2 times by 1 test: case '!':Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1310 | case '^': executed 2 times by 1 test: case '^':Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1311 | case '|': executed 102 times by 1 test: case '|':Executed by:
| 102 | ||||||||||||||||||||||||||||||
| 1312 | case ',': executed 97 times by 2 tests: case ',':Executed by:
| 97 | ||||||||||||||||||||||||||||||
| 1313 | case '(': executed 7 times by 1 test: case '(':Executed by:
| 7 | ||||||||||||||||||||||||||||||
| 1314 | case ')': executed 227 times by 2 tests: case ')':Executed by:
| 227 | ||||||||||||||||||||||||||||||
| 1315 | case '+': executed 14 times by 2 tests: case '+':Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 1316 | case '*': executed 31 times by 1 test: case '*':Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 1317 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1318 | if (prefix && *prefix == n+1) {
| 4-721747 | ||||||||||||||||||||||||||||||
| 1319 | *prefix = 0; | - | ||||||||||||||||||||||||||||||
| 1320 | putChar(':'); | - | ||||||||||||||||||||||||||||||
| 1321 | --n; | - | ||||||||||||||||||||||||||||||
| 1322 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 1323 | return n; executed 724970 times by 15 tests: return n;Executed by:
| 724970 | ||||||||||||||||||||||||||||||
| 1324 | case ':': executed 132009 times by 3 tests: case ':':Executed by:
| 132009 | ||||||||||||||||||||||||||||||
| 1325 | if (prefix) {
| 7-132002 | ||||||||||||||||||||||||||||||
| 1326 | if (*prefix == 0) {
| 2-132000 | ||||||||||||||||||||||||||||||
| 1327 | *prefix = n+2; | - | ||||||||||||||||||||||||||||||
| 1328 | } else { // only one colon allowed according to the namespace spec. executed 132000 times by 3 tests: end of blockExecuted by:
| 132000 | ||||||||||||||||||||||||||||||
| 1329 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1330 | return n; executed 2 times by 1 test: return n;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1331 | } | - | ||||||||||||||||||||||||||||||
| 1332 | } else { | - | ||||||||||||||||||||||||||||||
| 1333 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1334 | return n; executed 7 times by 1 test: return n;Executed by:
| 7 | ||||||||||||||||||||||||||||||
| 1335 | } | - | ||||||||||||||||||||||||||||||
| 1336 | // fall through | - | ||||||||||||||||||||||||||||||
| 1337 | default: code before this statement executed 132000 times by 3 tests: default:Executed by:
executed 4247577 times by 15 tests: default:Executed by:
| 132000-4247577 | ||||||||||||||||||||||||||||||
| 1338 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 1339 | ++n; | - | ||||||||||||||||||||||||||||||
| 1340 | } executed 4379577 times by 15 tests: end of blockExecuted by:
| 4379577 | ||||||||||||||||||||||||||||||
| 1341 | } | - | ||||||||||||||||||||||||||||||
| 1342 | - | |||||||||||||||||||||||||||||||
| 1343 | if (prefix)
| 991-8770 | ||||||||||||||||||||||||||||||
| 1344 | *prefix = 0; executed 8770 times by 1 test: *prefix = 0;Executed by:
| 8770 | ||||||||||||||||||||||||||||||
| 1345 | int pos = textBuffer.size() - n; | - | ||||||||||||||||||||||||||||||
| 1346 | putString(textBuffer, pos); | - | ||||||||||||||||||||||||||||||
| 1347 | textBuffer.resize(pos); | - | ||||||||||||||||||||||||||||||
| 1348 | return 0; executed 9761 times by 1 test: return 0;Executed by:
| 9761 | ||||||||||||||||||||||||||||||
| 1349 | } | - | ||||||||||||||||||||||||||||||
| 1350 | - | |||||||||||||||||||||||||||||||
| 1351 | enum NameChar { NameBeginning, NameNotBeginning, NotName }; | - | ||||||||||||||||||||||||||||||
| 1352 | - | |||||||||||||||||||||||||||||||
| 1353 | static const char Begi = static_cast<char>(NameBeginning); | - | ||||||||||||||||||||||||||||||
| 1354 | static const char NtBg = static_cast<char>(NameNotBeginning); | - | ||||||||||||||||||||||||||||||
| 1355 | static const char NotN = static_cast<char>(NotName); | - | ||||||||||||||||||||||||||||||
| 1356 | - | |||||||||||||||||||||||||||||||
| 1357 | static const char nameCharTable[128] = | - | ||||||||||||||||||||||||||||||
| 1358 | { | - | ||||||||||||||||||||||||||||||
| 1359 | // 0x00 | - | ||||||||||||||||||||||||||||||
| 1360 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1361 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1362 | // 0x10 | - | ||||||||||||||||||||||||||||||
| 1363 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1364 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1365 | // 0x20 (0x2D is '-', 0x2E is '.') | - | ||||||||||||||||||||||||||||||
| 1366 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1367 | NotN, NotN, NotN, NotN, NotN, NtBg, NtBg, NotN, | - | ||||||||||||||||||||||||||||||
| 1368 | // 0x30 (0x30..0x39 are '0'..'9', 0x3A is ':') | - | ||||||||||||||||||||||||||||||
| 1369 | NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, | - | ||||||||||||||||||||||||||||||
| 1370 | NtBg, NtBg, Begi, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||||||||
| 1371 | // 0x40 (0x41..0x5A are 'A'..'Z') | - | ||||||||||||||||||||||||||||||
| 1372 | NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1373 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1374 | // 0x50 (0x5F is '_') | - | ||||||||||||||||||||||||||||||
| 1375 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1376 | Begi, Begi, Begi, NotN, NotN, NotN, NotN, Begi, | - | ||||||||||||||||||||||||||||||
| 1377 | // 0x60 (0x61..0x7A are 'a'..'z') | - | ||||||||||||||||||||||||||||||
| 1378 | NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1379 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1380 | // 0x70 | - | ||||||||||||||||||||||||||||||
| 1381 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||||||||
| 1382 | Begi, Begi, Begi, NotN, NotN, NotN, NotN, NotN | - | ||||||||||||||||||||||||||||||
| 1383 | }; | - | ||||||||||||||||||||||||||||||
| 1384 | - | |||||||||||||||||||||||||||||||
| 1385 | static inline NameChar fastDetermineNameChar(QChar ch) | - | ||||||||||||||||||||||||||||||
| 1386 | { | - | ||||||||||||||||||||||||||||||
| 1387 | ushort uc = ch.unicode(); | - | ||||||||||||||||||||||||||||||
| 1388 | if (!(uc & ~0x7f)) // uc < 128
| 0-2874 | ||||||||||||||||||||||||||||||
| 1389 | return static_cast<NameChar>(nameCharTable[uc]); executed 2874 times by 2 tests: return static_cast<NameChar>(nameCharTable[uc]);Executed by:
| 2874 | ||||||||||||||||||||||||||||||
| 1390 | - | |||||||||||||||||||||||||||||||
| 1391 | QChar::Category cat = ch.category(); | - | ||||||||||||||||||||||||||||||
| 1392 | // ### some these categories might be slightly wrong | - | ||||||||||||||||||||||||||||||
| 1393 | if ((cat >= QChar::Letter_Uppercase && cat <= QChar::Letter_Other)
| 0 | ||||||||||||||||||||||||||||||
| 1394 | || cat == QChar::Number_Letter)
| 0 | ||||||||||||||||||||||||||||||
| 1395 | return NameBeginning; never executed: return NameBeginning; | 0 | ||||||||||||||||||||||||||||||
| 1396 | if ((cat >= QChar::Number_DecimalDigit && cat <= QChar::Number_Other)
| 0 | ||||||||||||||||||||||||||||||
| 1397 | || (cat >= QChar::Mark_NonSpacing && cat <= QChar::Mark_Enclosing))
| 0 | ||||||||||||||||||||||||||||||
| 1398 | return NameNotBeginning; never executed: return NameNotBeginning; | 0 | ||||||||||||||||||||||||||||||
| 1399 | return NotName; never executed: return NotName; | 0 | ||||||||||||||||||||||||||||||
| 1400 | } | - | ||||||||||||||||||||||||||||||
| 1401 | - | |||||||||||||||||||||||||||||||
| 1402 | inline int QXmlStreamReaderPrivate::fastScanNMTOKEN() | - | ||||||||||||||||||||||||||||||
| 1403 | { | - | ||||||||||||||||||||||||||||||
| 1404 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1405 | uint c; | - | ||||||||||||||||||||||||||||||
| 1406 | while ((c = getChar()) != StreamEOF) {
| 229-2874 | ||||||||||||||||||||||||||||||
| 1407 | if (fastDetermineNameChar(c) == NotName) {
| 350-2524 | ||||||||||||||||||||||||||||||
| 1408 | putChar(c); | - | ||||||||||||||||||||||||||||||
| 1409 | return n; executed 350 times by 2 tests: return n;Executed by:
| 350 | ||||||||||||||||||||||||||||||
| 1410 | } else { | - | ||||||||||||||||||||||||||||||
| 1411 | ++n; | - | ||||||||||||||||||||||||||||||
| 1412 | textBuffer += QChar(c); | - | ||||||||||||||||||||||||||||||
| 1413 | } executed 2524 times by 2 tests: end of blockExecuted by:
| 2524 | ||||||||||||||||||||||||||||||
| 1414 | } | - | ||||||||||||||||||||||||||||||
| 1415 | - | |||||||||||||||||||||||||||||||
| 1416 | int pos = textBuffer.size() - n; | - | ||||||||||||||||||||||||||||||
| 1417 | putString(textBuffer, pos); | - | ||||||||||||||||||||||||||||||
| 1418 | textBuffer.resize(pos); | - | ||||||||||||||||||||||||||||||
| 1419 | - | |||||||||||||||||||||||||||||||
| 1420 | return n; executed 229 times by 1 test: return n;Executed by:
| 229 | ||||||||||||||||||||||||||||||
| 1421 | } | - | ||||||||||||||||||||||||||||||
| 1422 | - | |||||||||||||||||||||||||||||||
| 1423 | void QXmlStreamReaderPrivate::putString(const QString &s, int from) | - | ||||||||||||||||||||||||||||||
| 1424 | { | - | ||||||||||||||||||||||||||||||
| 1425 | putStack.reserve(s.size()); | - | ||||||||||||||||||||||||||||||
| 1426 | for (int i = s.size()-1; i >= from; --i)
| 18909-205554 | ||||||||||||||||||||||||||||||
| 1427 | putStack.rawPush() = s.at(i).unicode(); executed 205554 times by 1 test: putStack.rawPush() = s.at(i).unicode();Executed by:
| 205554 | ||||||||||||||||||||||||||||||
| 1428 | } executed 18909 times by 1 test: end of blockExecuted by:
| 18909 | ||||||||||||||||||||||||||||||
| 1429 | - | |||||||||||||||||||||||||||||||
| 1430 | void QXmlStreamReaderPrivate::putStringLiteral(const QString &s) | - | ||||||||||||||||||||||||||||||
| 1431 | { | - | ||||||||||||||||||||||||||||||
| 1432 | putStack.reserve(s.size()); | - | ||||||||||||||||||||||||||||||
| 1433 | for (int i = s.size()-1; i >= 0; --i)
| 1792-1805 | ||||||||||||||||||||||||||||||
| 1434 | 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 | ||||||||||||||||||||||||||||||
| 1435 | } executed 1792 times by 4 tests: end of blockExecuted by:
| 1792 | ||||||||||||||||||||||||||||||
| 1436 | - | |||||||||||||||||||||||||||||||
| 1437 | void QXmlStreamReaderPrivate::putReplacement(const QString &s) | - | ||||||||||||||||||||||||||||||
| 1438 | { | - | ||||||||||||||||||||||||||||||
| 1439 | putStack.reserve(s.size()); | - | ||||||||||||||||||||||||||||||
| 1440 | for (int i = s.size()-1; i >= 0; --i) {
| 117-1077 | ||||||||||||||||||||||||||||||
| 1441 | ushort c = s.at(i).unicode(); | - | ||||||||||||||||||||||||||||||
| 1442 | if (c == '\n' || c == '\r')
| 2-1075 | ||||||||||||||||||||||||||||||
| 1443 | putStack.rawPush() = ((LETTER << 16) | c); executed 4 times by 1 test: putStack.rawPush() = ((LETTER << 16) | c);Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 1444 | else | - | ||||||||||||||||||||||||||||||
| 1445 | putStack.rawPush() = c; executed 1073 times by 1 test: putStack.rawPush() = c;Executed by:
| 1073 | ||||||||||||||||||||||||||||||
| 1446 | } | - | ||||||||||||||||||||||||||||||
| 1447 | } executed 117 times by 1 test: end of blockExecuted by:
| 117 | ||||||||||||||||||||||||||||||
| 1448 | void QXmlStreamReaderPrivate::putReplacementInAttributeValue(const QString &s) | - | ||||||||||||||||||||||||||||||
| 1449 | { | - | ||||||||||||||||||||||||||||||
| 1450 | putStack.reserve(s.size()); | - | ||||||||||||||||||||||||||||||
| 1451 | for (int i = s.size()-1; i >= 0; --i) {
| 98-990 | ||||||||||||||||||||||||||||||
| 1452 | ushort c = s.at(i).unicode(); | - | ||||||||||||||||||||||||||||||
| 1453 | if (c == '&' || c == ';')
| 49-941 | ||||||||||||||||||||||||||||||
| 1454 | putStack.rawPush() = c; executed 109 times by 1 test: putStack.rawPush() = c;Executed by:
| 109 | ||||||||||||||||||||||||||||||
| 1455 | else if (c == '\n' || c == '\r')
| 2-877 | ||||||||||||||||||||||||||||||
| 1456 | putStack.rawPush() = ' '; executed 6 times by 1 test: putStack.rawPush() = ' ';Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 1457 | else | - | ||||||||||||||||||||||||||||||
| 1458 | putStack.rawPush() = ((LETTER << 16) | c); executed 875 times by 1 test: putStack.rawPush() = ((LETTER << 16) | c);Executed by:
| 875 | ||||||||||||||||||||||||||||||
| 1459 | } | - | ||||||||||||||||||||||||||||||
| 1460 | } executed 98 times by 1 test: end of blockExecuted by:
| 98 | ||||||||||||||||||||||||||||||
| 1461 | - | |||||||||||||||||||||||||||||||
| 1462 | uint QXmlStreamReaderPrivate::getChar_helper() | - | ||||||||||||||||||||||||||||||
| 1463 | { | - | ||||||||||||||||||||||||||||||
| 1464 | const int BUFFER_SIZE = 8192; | - | ||||||||||||||||||||||||||||||
| 1465 | characterOffset += readBufferPos; | - | ||||||||||||||||||||||||||||||
| 1466 | readBufferPos = 0; | - | ||||||||||||||||||||||||||||||
| 1467 | readBuffer.resize(0); | - | ||||||||||||||||||||||||||||||
| 1468 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 1469 | if (decoder)
| 5317-116020 | ||||||||||||||||||||||||||||||
| 1470 | #endif | - | ||||||||||||||||||||||||||||||
| 1471 | nbytesread = 0; executed 116020 times by 15 tests: nbytesread = 0;Executed by:
| 116020 | ||||||||||||||||||||||||||||||
| 1472 | if (device) {
| 3400-117937 | ||||||||||||||||||||||||||||||
| 1473 | rawReadBuffer.resize(BUFFER_SIZE); | - | ||||||||||||||||||||||||||||||
| 1474 | int nbytesreadOrMinus1 = device->read(rawReadBuffer.data() + nbytesread, BUFFER_SIZE - nbytesread); | - | ||||||||||||||||||||||||||||||
| 1475 | nbytesread += qMax(nbytesreadOrMinus1, 0); | - | ||||||||||||||||||||||||||||||
| 1476 | } else { executed 3400 times by 2 tests: end of blockExecuted by:
| 3400 | ||||||||||||||||||||||||||||||
| 1477 | if (nbytesread)
| 780-117157 | ||||||||||||||||||||||||||||||
| 1478 | rawReadBuffer += dataBuffer; executed 780 times by 1 test: rawReadBuffer += dataBuffer;Executed by:
| 780 | ||||||||||||||||||||||||||||||
| 1479 | else | - | ||||||||||||||||||||||||||||||
| 1480 | rawReadBuffer = dataBuffer; executed 117157 times by 14 tests: rawReadBuffer = dataBuffer;Executed by:
| 117157 | ||||||||||||||||||||||||||||||
| 1481 | nbytesread = rawReadBuffer.size(); | - | ||||||||||||||||||||||||||||||
| 1482 | dataBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 1483 | } executed 117937 times by 14 tests: end of blockExecuted by:
| 117937 | ||||||||||||||||||||||||||||||
| 1484 | if (!nbytesread) {
| 59780-61557 | ||||||||||||||||||||||||||||||
| 1485 | atEnd = true; | - | ||||||||||||||||||||||||||||||
| 1486 | return StreamEOF; executed 59780 times by 15 tests: return StreamEOF;Executed by:
| 59780 | ||||||||||||||||||||||||||||||
| 1487 | } | - | ||||||||||||||||||||||||||||||
| 1488 | - | |||||||||||||||||||||||||||||||
| 1489 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 1490 | if (!decoder) {
| 3679-57878 | ||||||||||||||||||||||||||||||
| 1491 | if (nbytesread < 4) { // the 4 is to cover 0xef 0xbb 0xbf plus
| 782-2897 | ||||||||||||||||||||||||||||||
| 1492 | // one extra for the utf8 codec | - | ||||||||||||||||||||||||||||||
| 1493 | atEnd = true; | - | ||||||||||||||||||||||||||||||
| 1494 | return StreamEOF; executed 782 times by 1 test: return StreamEOF;Executed by:
| 782 | ||||||||||||||||||||||||||||||
| 1495 | } | - | ||||||||||||||||||||||||||||||
| 1496 | int mib = 106; // UTF-8 | - | ||||||||||||||||||||||||||||||
| 1497 | - | |||||||||||||||||||||||||||||||
| 1498 | // look for byte order mark | - | ||||||||||||||||||||||||||||||
| 1499 | uchar ch1 = rawReadBuffer.at(0); | - | ||||||||||||||||||||||||||||||
| 1500 | uchar ch2 = rawReadBuffer.at(1); | - | ||||||||||||||||||||||||||||||
| 1501 | uchar ch3 = rawReadBuffer.at(2); | - | ||||||||||||||||||||||||||||||
| 1502 | uchar ch4 = rawReadBuffer.at(3); | - | ||||||||||||||||||||||||||||||
| 1503 | - | |||||||||||||||||||||||||||||||
| 1504 | if ((ch1 == 0 && ch2 == 0 && ch3 == 0xfe && ch4 == 0xff) ||
| 0-2896 | ||||||||||||||||||||||||||||||
| 1505 | (ch1 == 0xff && ch2 == 0xfe && ch3 == 0 && ch4 == 0))
| 0-2857 | ||||||||||||||||||||||||||||||
| 1506 | mib = 1017; // UTF-32 with byte order mark never executed: mib = 1017; | 0 | ||||||||||||||||||||||||||||||
| 1507 | else if (ch1 == 0x3c && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x00)
| 0-2819 | ||||||||||||||||||||||||||||||
| 1508 | mib = 1019; // UTF-32LE never executed: mib = 1019; | 0 | ||||||||||||||||||||||||||||||
| 1509 | else if (ch1 == 0x00 && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x3c)
| 0-2896 | ||||||||||||||||||||||||||||||
| 1510 | mib = 1018; // UTF-32BE never executed: mib = 1018; | 0 | ||||||||||||||||||||||||||||||
| 1511 | else if ((ch1 == 0xfe && ch2 == 0xff) || (ch1 == 0xff && ch2 == 0xfe))
| 0-2896 | ||||||||||||||||||||||||||||||
| 1512 | mib = 1015; // UTF-16 with byte order mark executed 41 times by 1 test: mib = 1015;Executed by:
| 41 | ||||||||||||||||||||||||||||||
| 1513 | else if (ch1 == 0x3c && ch2 == 0x00)
| 0-2819 | ||||||||||||||||||||||||||||||
| 1514 | mib = 1014; // UTF-16LE never executed: mib = 1014; | 0 | ||||||||||||||||||||||||||||||
| 1515 | else if (ch1 == 0x00 && ch2 == 0x3c)
| 0-2855 | ||||||||||||||||||||||||||||||
| 1516 | mib = 1013; // UTF-16BE executed 1 time by 1 test: mib = 1013;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1517 | codec = QTextCodec::codecForMib(mib); | - | ||||||||||||||||||||||||||||||
| 1518 | Q_ASSERT(codec); | - | ||||||||||||||||||||||||||||||
| 1519 | decoder = codec->makeDecoder(); | - | ||||||||||||||||||||||||||||||
| 1520 | } executed 2897 times by 3 tests: end of blockExecuted by:
| 2897 | ||||||||||||||||||||||||||||||
| 1521 | - | |||||||||||||||||||||||||||||||
| 1522 | decoder->toUnicode(&readBuffer, rawReadBuffer.constData(), nbytesread); | - | ||||||||||||||||||||||||||||||
| 1523 | - | |||||||||||||||||||||||||||||||
| 1524 | if(lockEncoding && decoder->hasFailure()) {
| 0-55226 | ||||||||||||||||||||||||||||||
| 1525 | raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content.")); | - | ||||||||||||||||||||||||||||||
| 1526 | readBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 1527 | return StreamEOF; never executed: return StreamEOF; | 0 | ||||||||||||||||||||||||||||||
| 1528 | } | - | ||||||||||||||||||||||||||||||
| 1529 | #else | - | ||||||||||||||||||||||||||||||
| 1530 | readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread); | - | ||||||||||||||||||||||||||||||
| 1531 | #endif // QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 1532 | - | |||||||||||||||||||||||||||||||
| 1533 | readBuffer.reserve(1); // keep capacity when calling resize() next time | - | ||||||||||||||||||||||||||||||
| 1534 | - | |||||||||||||||||||||||||||||||
| 1535 | if (readBufferPos < readBuffer.size()) {
| 243-60532 | ||||||||||||||||||||||||||||||
| 1536 | ushort c = readBuffer.at(readBufferPos++).unicode(); | - | ||||||||||||||||||||||||||||||
| 1537 | return c; executed 60532 times by 15 tests: return c;Executed by:
| 60532 | ||||||||||||||||||||||||||||||
| 1538 | } | - | ||||||||||||||||||||||||||||||
| 1539 | - | |||||||||||||||||||||||||||||||
| 1540 | atEnd = true; | - | ||||||||||||||||||||||||||||||
| 1541 | return StreamEOF; executed 243 times by 1 test: return StreamEOF;Executed by:
| 243 | ||||||||||||||||||||||||||||||
| 1542 | } | - | ||||||||||||||||||||||||||||||
| 1543 | - | |||||||||||||||||||||||||||||||
| 1544 | QStringRef QXmlStreamReaderPrivate::namespaceForPrefix(const QStringRef &prefix) | - | ||||||||||||||||||||||||||||||
| 1545 | { | - | ||||||||||||||||||||||||||||||
| 1546 | for (int j = namespaceDeclarations.size() - 1; j >= 0; --j) {
| 78422-627652 | ||||||||||||||||||||||||||||||
| 1547 | const NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(j); | - | ||||||||||||||||||||||||||||||
| 1548 | if (namespaceDeclaration.prefix == prefix) {
| 286132-341520 | ||||||||||||||||||||||||||||||
| 1549 | return namespaceDeclaration.namespaceUri; executed 286132 times by 3 tests: return namespaceDeclaration.namespaceUri;Executed by:
| 286132 | ||||||||||||||||||||||||||||||
| 1550 | } | - | ||||||||||||||||||||||||||||||
| 1551 | } executed 341520 times by 15 tests: end of blockExecuted by:
| 341520 | ||||||||||||||||||||||||||||||
| 1552 | - | |||||||||||||||||||||||||||||||
| 1553 | #if 1 | - | ||||||||||||||||||||||||||||||
| 1554 | if (namespaceProcessing && !prefix.isEmpty())
| 0-78422 | ||||||||||||||||||||||||||||||
| 1555 | 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 | ||||||||||||||||||||||||||||||
| 1556 | #endif | - | ||||||||||||||||||||||||||||||
| 1557 | - | |||||||||||||||||||||||||||||||
| 1558 | return QStringRef(); executed 78422 times by 14 tests: return QStringRef();Executed by:
| 78422 | ||||||||||||||||||||||||||||||
| 1559 | } | - | ||||||||||||||||||||||||||||||
| 1560 | - | |||||||||||||||||||||||||||||||
| 1561 | /* | - | ||||||||||||||||||||||||||||||
| 1562 | uses namespaceForPrefix and builds the attribute vector | - | ||||||||||||||||||||||||||||||
| 1563 | */ | - | ||||||||||||||||||||||||||||||
| 1564 | void QXmlStreamReaderPrivate::resolveTag() | - | ||||||||||||||||||||||||||||||
| 1565 | { | - | ||||||||||||||||||||||||||||||
| 1566 | int n = attributeStack.size(); | - | ||||||||||||||||||||||||||||||
| 1567 | - | |||||||||||||||||||||||||||||||
| 1568 | if (namespaceProcessing) {
| 0-232942 | ||||||||||||||||||||||||||||||
| 1569 | for (int a = 0; a < dtdAttributes.size(); ++a) {
| 232942-3832797 | ||||||||||||||||||||||||||||||
| 1570 | DtdAttribute &dtdAttribute = dtdAttributes[a]; | - | ||||||||||||||||||||||||||||||
| 1571 | if (!dtdAttribute.isNamespaceAttribute
| 153669-3679128 | ||||||||||||||||||||||||||||||
| 1572 | || dtdAttribute.defaultValue.isNull()
| 91-153578 | ||||||||||||||||||||||||||||||
| 1573 | || dtdAttribute.tagName != qualifiedName
| 9-153569 | ||||||||||||||||||||||||||||||
| 1574 | || dtdAttribute.attributeQualifiedName.isNull())
| 0-9 | ||||||||||||||||||||||||||||||
| 1575 | continue; executed 3832788 times by 2 tests: continue;Executed by:
| 3832788 | ||||||||||||||||||||||||||||||
| 1576 | int i = 0; | - | ||||||||||||||||||||||||||||||
| 1577 | while (i < n && symName(attributeStack[i].key) != dtdAttribute.attributeQualifiedName)
| 0-9 | ||||||||||||||||||||||||||||||
| 1578 | ++i; executed 3 times by 1 test: ++i;Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 1579 | if (i != n)
| 0-9 | ||||||||||||||||||||||||||||||
| 1580 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 1581 | if (dtdAttribute.attributePrefix.isEmpty() && dtdAttribute.attributeName == QLatin1String("xmlns")) {
| 0-7 | ||||||||||||||||||||||||||||||
| 1582 | NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 1583 | namespaceDeclaration.prefix.clear(); | - | ||||||||||||||||||||||||||||||
| 1584 | - | |||||||||||||||||||||||||||||||
| 1585 | const QStringRef ns(dtdAttribute.defaultValue); | - | ||||||||||||||||||||||||||||||
| 1586 | if(ns == QLatin1String("http://www.w3.org/2000/xmlns/") ||
| 0-7 | ||||||||||||||||||||||||||||||
| 1587 | ns == QLatin1String("http://www.w3.org/XML/1998/namespace"))
| 0-7 | ||||||||||||||||||||||||||||||
| 1588 | raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration.")); never executed: raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration.")); | 0 | ||||||||||||||||||||||||||||||
| 1589 | else | - | ||||||||||||||||||||||||||||||
| 1590 | namespaceDeclaration.namespaceUri = ns; executed 7 times by 2 tests: namespaceDeclaration.namespaceUri = ns;Executed by:
| 7 | ||||||||||||||||||||||||||||||
| 1591 | } else if (dtdAttribute.attributePrefix == QLatin1String("xmlns")) {
| 0-2 | ||||||||||||||||||||||||||||||
| 1592 | NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 1593 | QStringRef namespacePrefix = dtdAttribute.attributeName; | - | ||||||||||||||||||||||||||||||
| 1594 | QStringRef namespaceUri = dtdAttribute.defaultValue; | - | ||||||||||||||||||||||||||||||
| 1595 | if (((namespacePrefix == QLatin1String("xml"))
| 0-2 | ||||||||||||||||||||||||||||||
| 1596 | ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))
| 0-2 | ||||||||||||||||||||||||||||||
| 1597 | || namespaceUri == QLatin1String("http://www.w3.org/2000/xmlns/")
| 0-2 | ||||||||||||||||||||||||||||||
| 1598 | || namespaceUri.isEmpty()
| 0-2 | ||||||||||||||||||||||||||||||
| 1599 | || namespacePrefix == QLatin1String("xmlns"))
| 0-2 | ||||||||||||||||||||||||||||||
| 1600 | raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration.")); never executed: raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration.")); | 0 | ||||||||||||||||||||||||||||||
| 1601 | - | |||||||||||||||||||||||||||||||
| 1602 | namespaceDeclaration.prefix = namespacePrefix; | - | ||||||||||||||||||||||||||||||
| 1603 | namespaceDeclaration.namespaceUri = namespaceUri; | - | ||||||||||||||||||||||||||||||
| 1604 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 1605 | } executed 9 times by 2 tests: end of blockExecuted by:
| 9 | ||||||||||||||||||||||||||||||
| 1606 | } executed 232942 times by 15 tests: end of blockExecuted by:
| 232942 | ||||||||||||||||||||||||||||||
| 1607 | - | |||||||||||||||||||||||||||||||
| 1608 | tagStack.top().namespaceDeclaration.namespaceUri = namespaceUri = namespaceForPrefix(prefix); | - | ||||||||||||||||||||||||||||||
| 1609 | - | |||||||||||||||||||||||||||||||
| 1610 | attributes.resize(n); | - | ||||||||||||||||||||||||||||||
| 1611 | - | |||||||||||||||||||||||||||||||
| 1612 | for (int i = 0; i < n; ++i) {
| 232942-269638 | ||||||||||||||||||||||||||||||
| 1613 | QXmlStreamAttribute &attribute = attributes[i]; | - | ||||||||||||||||||||||||||||||
| 1614 | Attribute &attrib = attributeStack[i]; | - | ||||||||||||||||||||||||||||||
| 1615 | QStringRef prefix(symPrefix(attrib.key)); | - | ||||||||||||||||||||||||||||||
| 1616 | QStringRef name(symString(attrib.key)); | - | ||||||||||||||||||||||||||||||
| 1617 | QStringRef qualifiedName(symName(attrib.key)); | - | ||||||||||||||||||||||||||||||
| 1618 | QStringRef value(symString(attrib.value)); | - | ||||||||||||||||||||||||||||||
| 1619 | - | |||||||||||||||||||||||||||||||
| 1620 | attribute.m_name = QXmlStreamStringRef(name); | - | ||||||||||||||||||||||||||||||
| 1621 | attribute.m_qualifiedName = QXmlStreamStringRef(qualifiedName); | - | ||||||||||||||||||||||||||||||
| 1622 | attribute.m_value = QXmlStreamStringRef(value); | - | ||||||||||||||||||||||||||||||
| 1623 | - | |||||||||||||||||||||||||||||||
| 1624 | if (!prefix.isEmpty()) {
| 131612-138026 | ||||||||||||||||||||||||||||||
| 1625 | QStringRef attributeNamespaceUri = namespaceForPrefix(prefix); | - | ||||||||||||||||||||||||||||||
| 1626 | attribute.m_namespaceUri = QXmlStreamStringRef(attributeNamespaceUri); | - | ||||||||||||||||||||||||||||||
| 1627 | } executed 131612 times by 2 tests: end of blockExecuted by:
| 131612 | ||||||||||||||||||||||||||||||
| 1628 | - | |||||||||||||||||||||||||||||||
| 1629 | for (int j = 0; j < i; ++j) {
| 114354-269638 | ||||||||||||||||||||||||||||||
| 1630 | if (attributes[j].name() == attribute.name()
| 38-114316 | ||||||||||||||||||||||||||||||
| 1631 | && attributes[j].namespaceUri() == attribute.namespaceUri()
| 16-22 | ||||||||||||||||||||||||||||||
| 1632 | && (namespaceProcessing || attributes[j].qualifiedName() == attribute.qualifiedName()))
| 0-16 | ||||||||||||||||||||||||||||||
| 1633 | 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 | ||||||||||||||||||||||||||||||
| 1634 | } executed 114354 times by 15 tests: end of blockExecuted by:
| 114354 | ||||||||||||||||||||||||||||||
| 1635 | } executed 269638 times by 15 tests: end of blockExecuted by:
| 269638 | ||||||||||||||||||||||||||||||
| 1636 | - | |||||||||||||||||||||||||||||||
| 1637 | for (int a = 0; a < dtdAttributes.size(); ++a) {
| 232942-3832797 | ||||||||||||||||||||||||||||||
| 1638 | DtdAttribute &dtdAttribute = dtdAttributes[a]; | - | ||||||||||||||||||||||||||||||
| 1639 | if (dtdAttribute.isNamespaceAttribute
| 153669-3679128 | ||||||||||||||||||||||||||||||
| 1640 | || dtdAttribute.defaultValue.isNull()
| 168-3678960 | ||||||||||||||||||||||||||||||
| 1641 | || dtdAttribute.tagName != qualifiedName
| 75-93 | ||||||||||||||||||||||||||||||
| 1642 | || dtdAttribute.attributeQualifiedName.isNull())
| 2-91 | ||||||||||||||||||||||||||||||
| 1643 | continue; executed 3832706 times by 2 tests: continue;Executed by:
| 3832706 | ||||||||||||||||||||||||||||||
| 1644 | int i = 0; | - | ||||||||||||||||||||||||||||||
| 1645 | while (i < n && symName(attributeStack[i].key) != dtdAttribute.attributeQualifiedName)
| 36-117 | ||||||||||||||||||||||||||||||
| 1646 | ++i; executed 62 times by 1 test: ++i;Executed by:
| 62 | ||||||||||||||||||||||||||||||
| 1647 | if (i != n)
| 36-55 | ||||||||||||||||||||||||||||||
| 1648 | continue; executed 55 times by 1 test: continue;Executed by:
| 55 | ||||||||||||||||||||||||||||||
| 1649 | - | |||||||||||||||||||||||||||||||
| 1650 | - | |||||||||||||||||||||||||||||||
| 1651 | - | |||||||||||||||||||||||||||||||
| 1652 | QXmlStreamAttribute attribute; | - | ||||||||||||||||||||||||||||||
| 1653 | attribute.m_name = QXmlStreamStringRef(dtdAttribute.attributeName); | - | ||||||||||||||||||||||||||||||
| 1654 | attribute.m_qualifiedName = QXmlStreamStringRef(dtdAttribute.attributeQualifiedName); | - | ||||||||||||||||||||||||||||||
| 1655 | attribute.m_value = QXmlStreamStringRef(dtdAttribute.defaultValue); | - | ||||||||||||||||||||||||||||||
| 1656 | - | |||||||||||||||||||||||||||||||
| 1657 | if (!dtdAttribute.attributePrefix.isEmpty()) {
| 0-36 | ||||||||||||||||||||||||||||||
| 1658 | QStringRef attributeNamespaceUri = namespaceForPrefix(dtdAttribute.attributePrefix); | - | ||||||||||||||||||||||||||||||
| 1659 | attribute.m_namespaceUri = QXmlStreamStringRef(attributeNamespaceUri); | - | ||||||||||||||||||||||||||||||
| 1660 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1661 | attribute.m_isDefault = true; | - | ||||||||||||||||||||||||||||||
| 1662 | attributes.append(attribute); | - | ||||||||||||||||||||||||||||||
| 1663 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||||||||||||||
| 1664 | - | |||||||||||||||||||||||||||||||
| 1665 | attributeStack.clear(); | - | ||||||||||||||||||||||||||||||
| 1666 | } executed 232942 times by 15 tests: end of blockExecuted by:
| 232942 | ||||||||||||||||||||||||||||||
| 1667 | - | |||||||||||||||||||||||||||||||
| 1668 | void QXmlStreamReaderPrivate::resolvePublicNamespaces() | - | ||||||||||||||||||||||||||||||
| 1669 | { | - | ||||||||||||||||||||||||||||||
| 1670 | const Tag &tag = tagStack.top(); | - | ||||||||||||||||||||||||||||||
| 1671 | int n = namespaceDeclarations.size() - tag.namespaceDeclarationsSize; | - | ||||||||||||||||||||||||||||||
| 1672 | publicNamespaceDeclarations.resize(n); | - | ||||||||||||||||||||||||||||||
| 1673 | for (int i = 0; i < n; ++i) {
| 54-446 | ||||||||||||||||||||||||||||||
| 1674 | const NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(tag.namespaceDeclarationsSize + i); | - | ||||||||||||||||||||||||||||||
| 1675 | QXmlStreamNamespaceDeclaration &publicNamespaceDeclaration = publicNamespaceDeclarations[i]; | - | ||||||||||||||||||||||||||||||
| 1676 | publicNamespaceDeclaration.m_prefix = QXmlStreamStringRef(namespaceDeclaration.prefix); | - | ||||||||||||||||||||||||||||||
| 1677 | publicNamespaceDeclaration.m_namespaceUri = QXmlStreamStringRef(namespaceDeclaration.namespaceUri); | - | ||||||||||||||||||||||||||||||
| 1678 | } executed 54 times by 1 test: end of blockExecuted by:
| 54 | ||||||||||||||||||||||||||||||
| 1679 | } executed 446 times by 1 test: end of blockExecuted by:
| 446 | ||||||||||||||||||||||||||||||
| 1680 | - | |||||||||||||||||||||||||||||||
| 1681 | void QXmlStreamReaderPrivate::resolveDtd() | - | ||||||||||||||||||||||||||||||
| 1682 | { | - | ||||||||||||||||||||||||||||||
| 1683 | publicNotationDeclarations.resize(notationDeclarations.size()); | - | ||||||||||||||||||||||||||||||
| 1684 | for (int i = 0; i < notationDeclarations.size(); ++i) {
| 52-79 | ||||||||||||||||||||||||||||||
| 1685 | const QXmlStreamReaderPrivate::NotationDeclaration ¬ationDeclaration = notationDeclarations.at(i); | - | ||||||||||||||||||||||||||||||
| 1686 | QXmlStreamNotationDeclaration &publicNotationDeclaration = publicNotationDeclarations[i]; | - | ||||||||||||||||||||||||||||||
| 1687 | publicNotationDeclaration.m_name = QXmlStreamStringRef(notationDeclaration.name); | - | ||||||||||||||||||||||||||||||
| 1688 | publicNotationDeclaration.m_systemId = QXmlStreamStringRef(notationDeclaration.systemId); | - | ||||||||||||||||||||||||||||||
| 1689 | publicNotationDeclaration.m_publicId = QXmlStreamStringRef(notationDeclaration.publicId); | - | ||||||||||||||||||||||||||||||
| 1690 | - | |||||||||||||||||||||||||||||||
| 1691 | } executed 79 times by 1 test: end of blockExecuted by:
| 79 | ||||||||||||||||||||||||||||||
| 1692 | notationDeclarations.clear(); | - | ||||||||||||||||||||||||||||||
| 1693 | publicEntityDeclarations.resize(entityDeclarations.size()); | - | ||||||||||||||||||||||||||||||
| 1694 | for (int i = 0; i < entityDeclarations.size(); ++i) {
| 44-52 | ||||||||||||||||||||||||||||||
| 1695 | const QXmlStreamReaderPrivate::EntityDeclaration &entityDeclaration = entityDeclarations.at(i); | - | ||||||||||||||||||||||||||||||
| 1696 | QXmlStreamEntityDeclaration &publicEntityDeclaration = publicEntityDeclarations[i]; | - | ||||||||||||||||||||||||||||||
| 1697 | publicEntityDeclaration.m_name = QXmlStreamStringRef(entityDeclaration.name); | - | ||||||||||||||||||||||||||||||
| 1698 | publicEntityDeclaration.m_notationName = QXmlStreamStringRef(entityDeclaration.notationName); | - | ||||||||||||||||||||||||||||||
| 1699 | publicEntityDeclaration.m_systemId = QXmlStreamStringRef(entityDeclaration.systemId); | - | ||||||||||||||||||||||||||||||
| 1700 | publicEntityDeclaration.m_publicId = QXmlStreamStringRef(entityDeclaration.publicId); | - | ||||||||||||||||||||||||||||||
| 1701 | publicEntityDeclaration.m_value = QXmlStreamStringRef(entityDeclaration.value); | - | ||||||||||||||||||||||||||||||
| 1702 | } executed 44 times by 1 test: end of blockExecuted by:
| 44 | ||||||||||||||||||||||||||||||
| 1703 | entityDeclarations.clear(); | - | ||||||||||||||||||||||||||||||
| 1704 | parameterEntityHash.clear(); | - | ||||||||||||||||||||||||||||||
| 1705 | } executed 52 times by 1 test: end of blockExecuted by:
| 52 | ||||||||||||||||||||||||||||||
| 1706 | - | |||||||||||||||||||||||||||||||
| 1707 | uint QXmlStreamReaderPrivate::resolveCharRef(int symbolIndex) | - | ||||||||||||||||||||||||||||||
| 1708 | { | - | ||||||||||||||||||||||||||||||
| 1709 | bool ok = true; | - | ||||||||||||||||||||||||||||||
| 1710 | uint s; | - | ||||||||||||||||||||||||||||||
| 1711 | // ### add toXShort to QStringRef? | - | ||||||||||||||||||||||||||||||
| 1712 | if (sym(symbolIndex).c == 'x')
| 143-1284 | ||||||||||||||||||||||||||||||
| 1713 | s = symString(symbolIndex, 1).toUInt(&ok, 16); executed 1284 times by 2 tests: s = symString(symbolIndex, 1).toUInt(&ok, 16);Executed by:
| 1284 | ||||||||||||||||||||||||||||||
| 1714 | else | - | ||||||||||||||||||||||||||||||
| 1715 | s = symString(symbolIndex).toUInt(&ok, 10); executed 143 times by 1 test: s = symString(symbolIndex).toUInt(&ok, 10);Executed by:
| 143 | ||||||||||||||||||||||||||||||
| 1716 | - | |||||||||||||||||||||||||||||||
| 1717 | ok &= (s == 0x9 || s == 0xa || s == 0xd || (s >= 0x20 && s <= 0xd7ff)
| 13-1413 | ||||||||||||||||||||||||||||||
| 1718 | || (s >= 0xe000 && s <= 0xfffd) || (s >= 0x10000 && s <= QChar::LastValidCodePoint));
| 1-25 | ||||||||||||||||||||||||||||||
| 1719 | - | |||||||||||||||||||||||||||||||
| 1720 | return ok ? s : 0; executed 1427 times by 2 tests: return ok ? s : 0;Executed by:
| 26-1427 | ||||||||||||||||||||||||||||||
| 1721 | } | - | ||||||||||||||||||||||||||||||
| 1722 | - | |||||||||||||||||||||||||||||||
| 1723 | - | |||||||||||||||||||||||||||||||
| 1724 | void QXmlStreamReaderPrivate::checkPublicLiteral(const QStringRef &publicId) | - | ||||||||||||||||||||||||||||||
| 1725 | { | - | ||||||||||||||||||||||||||||||
| 1726 | //#x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] | - | ||||||||||||||||||||||||||||||
| 1727 | - | |||||||||||||||||||||||||||||||
| 1728 | const ushort *data = reinterpret_cast<const ushort *>(publicId.constData()); | - | ||||||||||||||||||||||||||||||
| 1729 | uchar c = 0; | - | ||||||||||||||||||||||||||||||
| 1730 | int i; | - | ||||||||||||||||||||||||||||||
| 1731 | for (i = publicId.size() - 1; i >= 0; --i) {
| 295-13888 | ||||||||||||||||||||||||||||||
| 1732 | if (data[i] < 256)
| 0-13888 | ||||||||||||||||||||||||||||||
| 1733 | switch ((c = data[i])) { | - | ||||||||||||||||||||||||||||||
| 1734 | 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 | ||||||||||||||||||||||||||||||
| 1735 | 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 | ||||||||||||||||||||||||||||||
| 1736 | 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 | ||||||||||||||||||||||||||||||
| 1737 | 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 | ||||||||||||||||||||||||||||||
| 1738 | continue; executed 3345 times by 12 tests: continue;Executed by:
| 3345 | ||||||||||||||||||||||||||||||
| 1739 | default: executed 10543 times by 12 tests: default:Executed by:
| 10543 | ||||||||||||||||||||||||||||||
| 1740 | if ((c >= 'a' && c <= 'z')
| 0-7242 | ||||||||||||||||||||||||||||||
| 1741 | || (c >= 'A' && c <= 'Z')
| 0-2782 | ||||||||||||||||||||||||||||||
| 1742 | || (c >= '0' && c <= '9'))
| 0-519 | ||||||||||||||||||||||||||||||
| 1743 | continue; executed 10543 times by 12 tests: continue;Executed by:
| 10543 | ||||||||||||||||||||||||||||||
| 1744 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1745 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1746 | } | - | ||||||||||||||||||||||||||||||
| 1747 | if (i >= 0)
| 0-295 | ||||||||||||||||||||||||||||||
| 1748 | 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 | ||||||||||||||||||||||||||||||
| 1749 | } executed 295 times by 12 tests: end of blockExecuted by:
| 295 | ||||||||||||||||||||||||||||||
| 1750 | - | |||||||||||||||||||||||||||||||
| 1751 | /* | - | ||||||||||||||||||||||||||||||
| 1752 | Checks whether the document starts with an xml declaration. If it | - | ||||||||||||||||||||||||||||||
| 1753 | does, this function returns \c true; otherwise it sets up everything | - | ||||||||||||||||||||||||||||||
| 1754 | for a synthetic start document event and returns \c false. | - | ||||||||||||||||||||||||||||||
| 1755 | */ | - | ||||||||||||||||||||||||||||||
| 1756 | bool QXmlStreamReaderPrivate::checkStartDocument() | - | ||||||||||||||||||||||||||||||
| 1757 | { | - | ||||||||||||||||||||||||||||||
| 1758 | hasCheckedStartDocument = true; | - | ||||||||||||||||||||||||||||||
| 1759 | - | |||||||||||||||||||||||||||||||
| 1760 | if (scanString(spell[XML], XML))
| 1285-4669 | ||||||||||||||||||||||||||||||
| 1761 | return true; executed 1285 times by 5 tests: return true;Executed by:
| 1285 | ||||||||||||||||||||||||||||||
| 1762 | - | |||||||||||||||||||||||||||||||
| 1763 | type = QXmlStreamReader::StartDocument; | - | ||||||||||||||||||||||||||||||
| 1764 | if (atEnd) {
| 1984-2685 | ||||||||||||||||||||||||||||||
| 1765 | hasCheckedStartDocument = false; | - | ||||||||||||||||||||||||||||||
| 1766 | raiseError(QXmlStreamReader::PrematureEndOfDocumentError); | - | ||||||||||||||||||||||||||||||
| 1767 | } executed 2685 times by 2 tests: end of blockExecuted by:
| 2685 | ||||||||||||||||||||||||||||||
| 1768 | return false; executed 4669 times by 13 tests: return false;Executed by:
| 4669 | ||||||||||||||||||||||||||||||
| 1769 | } | - | ||||||||||||||||||||||||||||||
| 1770 | - | |||||||||||||||||||||||||||||||
| 1771 | void QXmlStreamReaderPrivate::startDocument() | - | ||||||||||||||||||||||||||||||
| 1772 | { | - | ||||||||||||||||||||||||||||||
| 1773 | QString err; | - | ||||||||||||||||||||||||||||||
| 1774 | if (documentVersion != QLatin1String("1.0")) {
| 4-1237 | ||||||||||||||||||||||||||||||
| 1775 | if (documentVersion.contains(QLatin1Char(' ')))
| 1-3 | ||||||||||||||||||||||||||||||
| 1776 | err = QXmlStream::tr("Invalid XML version string."); executed 1 time by 1 test: err = QXmlStream::tr("Invalid XML version string.");Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1777 | else | - | ||||||||||||||||||||||||||||||
| 1778 | err = QXmlStream::tr("Unsupported XML version."); executed 3 times by 1 test: err = QXmlStream::tr("Unsupported XML version.");Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 1779 | } | - | ||||||||||||||||||||||||||||||
| 1780 | int n = attributeStack.size(); | - | ||||||||||||||||||||||||||||||
| 1781 | - | |||||||||||||||||||||||||||||||
| 1782 | /* We use this bool to ensure that the pesudo attributes are in the | - | ||||||||||||||||||||||||||||||
| 1783 | * proper order: | - | ||||||||||||||||||||||||||||||
| 1784 | * | - | ||||||||||||||||||||||||||||||
| 1785 | * [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>' */ | - | ||||||||||||||||||||||||||||||
| 1786 | bool hasStandalone = false; | - | ||||||||||||||||||||||||||||||
| 1787 | - | |||||||||||||||||||||||||||||||
| 1788 | for (int i = 0; err.isNull() && i < n; ++i) {
| 31-1902 | ||||||||||||||||||||||||||||||
| 1789 | Attribute &attrib = attributeStack[i]; | - | ||||||||||||||||||||||||||||||
| 1790 | QStringRef prefix(symPrefix(attrib.key)); | - | ||||||||||||||||||||||||||||||
| 1791 | QStringRef key(symString(attrib.key)); | - | ||||||||||||||||||||||||||||||
| 1792 | QStringRef value(symString(attrib.value)); | - | ||||||||||||||||||||||||||||||
| 1793 | - | |||||||||||||||||||||||||||||||
| 1794 | if (prefix.isEmpty() && key == QLatin1String("encoding")) {
| 0-692 | ||||||||||||||||||||||||||||||
| 1795 | const QString name(value.toString()); | - | ||||||||||||||||||||||||||||||
| 1796 | documentEncoding = value; | - | ||||||||||||||||||||||||||||||
| 1797 | - | |||||||||||||||||||||||||||||||
| 1798 | if(hasStandalone)
| 1-658 | ||||||||||||||||||||||||||||||
| 1799 | 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 | ||||||||||||||||||||||||||||||
| 1800 | if(!QXmlUtils::isEncName(name))
| 16-643 | ||||||||||||||||||||||||||||||
| 1801 | 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 | ||||||||||||||||||||||||||||||
| 1802 | else { | - | ||||||||||||||||||||||||||||||
| 1803 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 1804 | readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread); | - | ||||||||||||||||||||||||||||||
| 1805 | #else | - | ||||||||||||||||||||||||||||||
| 1806 | QTextCodec *const newCodec = QTextCodec::codecForName(name.toLatin1()); | - | ||||||||||||||||||||||||||||||
| 1807 | if (!newCodec)
| 0-643 | ||||||||||||||||||||||||||||||
| 1808 | err = QXmlStream::tr("Encoding %1 is unsupported").arg(name); never executed: err = QXmlStream::tr("Encoding %1 is unsupported").arg(name); | 0 | ||||||||||||||||||||||||||||||
| 1809 | else if (newCodec != codec && !lockEncoding) {
| 0-639 | ||||||||||||||||||||||||||||||
| 1810 | codec = newCodec; | - | ||||||||||||||||||||||||||||||
| 1811 | delete decoder; | - | ||||||||||||||||||||||||||||||
| 1812 | decoder = codec->makeDecoder(); | - | ||||||||||||||||||||||||||||||
| 1813 | decoder->toUnicode(&readBuffer, rawReadBuffer.data(), nbytesread); | - | ||||||||||||||||||||||||||||||
| 1814 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 1815 | #endif // QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 1816 | } executed 643 times by 4 tests: end of blockExecuted by:
| 643 | ||||||||||||||||||||||||||||||
| 1817 | } else if (prefix.isEmpty() && key == QLatin1String("standalone")) {
| 0-33 | ||||||||||||||||||||||||||||||
| 1818 | hasStandalone = true; | - | ||||||||||||||||||||||||||||||
| 1819 | if (value == QLatin1String("yes"))
| 8-21 | ||||||||||||||||||||||||||||||
| 1820 | standalone = true; executed 21 times by 1 test: standalone = true;Executed by:
| 21 | ||||||||||||||||||||||||||||||
| 1821 | else if (value == QLatin1String("no"))
| 2-6 | ||||||||||||||||||||||||||||||
| 1822 | standalone = false; executed 2 times by 1 test: standalone = false;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1823 | else | - | ||||||||||||||||||||||||||||||
| 1824 | 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 | ||||||||||||||||||||||||||||||
| 1825 | } else { | - | ||||||||||||||||||||||||||||||
| 1826 | err = QXmlStream::tr("Invalid attribute in XML declaration."); | - | ||||||||||||||||||||||||||||||
| 1827 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 1828 | } | - | ||||||||||||||||||||||||||||||
| 1829 | - | |||||||||||||||||||||||||||||||
| 1830 | if (!err.isNull())
| 31-1210 | ||||||||||||||||||||||||||||||
| 1831 | raiseWellFormedError(err); executed 31 times by 1 test: raiseWellFormedError(err);Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 1832 | attributeStack.clear(); | - | ||||||||||||||||||||||||||||||
| 1833 | } executed 1241 times by 5 tests: end of blockExecuted by:
| 1241 | ||||||||||||||||||||||||||||||
| 1834 | - | |||||||||||||||||||||||||||||||
| 1835 | - | |||||||||||||||||||||||||||||||
| 1836 | void QXmlStreamReaderPrivate::raiseError(QXmlStreamReader::Error error, const QString& message) | - | ||||||||||||||||||||||||||||||
| 1837 | { | - | ||||||||||||||||||||||||||||||
| 1838 | this->error = error; | - | ||||||||||||||||||||||||||||||
| 1839 | errorString = message; | - | ||||||||||||||||||||||||||||||
| 1840 | if (errorString.isNull()) {
| 1235-58733 | ||||||||||||||||||||||||||||||
| 1841 | if (error == QXmlStreamReader::PrematureEndOfDocumentError)
| 0-58733 | ||||||||||||||||||||||||||||||
| 1842 | errorString = QXmlStream::tr("Premature end of document."); executed 58733 times by 2 tests: errorString = QXmlStream::tr("Premature end of document.");Executed by:
| 58733 | ||||||||||||||||||||||||||||||
| 1843 | else if (error == QXmlStreamReader::CustomError)
| 0 | ||||||||||||||||||||||||||||||
| 1844 | errorString = QXmlStream::tr("Invalid document."); never executed: errorString = QXmlStream::tr("Invalid document."); | 0 | ||||||||||||||||||||||||||||||
| 1845 | } executed 58733 times by 2 tests: end of blockExecuted by:
| 58733 | ||||||||||||||||||||||||||||||
| 1846 | - | |||||||||||||||||||||||||||||||
| 1847 | type = QXmlStreamReader::Invalid; | - | ||||||||||||||||||||||||||||||
| 1848 | } executed 59968 times by 3 tests: end of blockExecuted by:
| 59968 | ||||||||||||||||||||||||||||||
| 1849 | - | |||||||||||||||||||||||||||||||
| 1850 | void QXmlStreamReaderPrivate::raiseWellFormedError(const QString &message) | - | ||||||||||||||||||||||||||||||
| 1851 | { | - | ||||||||||||||||||||||||||||||
| 1852 | raiseError(QXmlStreamReader::NotWellFormedError, message); | - | ||||||||||||||||||||||||||||||
| 1853 | } executed 1196 times by 2 tests: end of blockExecuted by:
| 1196 | ||||||||||||||||||||||||||||||
| 1854 | - | |||||||||||||||||||||||||||||||
| 1855 | void QXmlStreamReaderPrivate::parseError() | - | ||||||||||||||||||||||||||||||
| 1856 | { | - | ||||||||||||||||||||||||||||||
| 1857 | - | |||||||||||||||||||||||||||||||
| 1858 | if (token == EOF_SYMBOL) {
| 613-6305 | ||||||||||||||||||||||||||||||
| 1859 | raiseError(QXmlStreamReader::PrematureEndOfDocumentError); | - | ||||||||||||||||||||||||||||||
| 1860 | return; executed 6305 times by 1 test: return;Executed by:
| 6305 | ||||||||||||||||||||||||||||||
| 1861 | } | - | ||||||||||||||||||||||||||||||
| 1862 | const int nmax = 4; | - | ||||||||||||||||||||||||||||||
| 1863 | QString error_message; | - | ||||||||||||||||||||||||||||||
| 1864 | int ers = state_stack[tos]; | - | ||||||||||||||||||||||||||||||
| 1865 | int nexpected = 0; | - | ||||||||||||||||||||||||||||||
| 1866 | int expected[nmax]; | - | ||||||||||||||||||||||||||||||
| 1867 | if (token != ERROR)
| 7-606 | ||||||||||||||||||||||||||||||
| 1868 | for (int tk = 0; tk < TERMINAL_COUNT; ++tk) {
| 606-34542 | ||||||||||||||||||||||||||||||
| 1869 | int k = t_action(ers, tk); | - | ||||||||||||||||||||||||||||||
| 1870 | if (k <= 0)
| 3323-31219 | ||||||||||||||||||||||||||||||
| 1871 | continue; executed 31219 times by 1 test: continue;Executed by:
| 31219 | ||||||||||||||||||||||||||||||
| 1872 | if (spell[tk]) {
| 96-3227 | ||||||||||||||||||||||||||||||
| 1873 | if (nexpected < nmax)
| 1391-1836 | ||||||||||||||||||||||||||||||
| 1874 | expected[nexpected++] = tk; executed 1391 times by 1 test: expected[nexpected++] = tk;Executed by:
| 1391 | ||||||||||||||||||||||||||||||
| 1875 | } executed 3227 times by 1 test: end of blockExecuted by:
| 3227 | ||||||||||||||||||||||||||||||
| 1876 | } executed 3323 times by 1 test: end of blockExecuted by:
| 3323 | ||||||||||||||||||||||||||||||
| 1877 | - | |||||||||||||||||||||||||||||||
| 1878 | error_message.clear (); | - | ||||||||||||||||||||||||||||||
| 1879 | if (nexpected && nexpected < nmax) {
| 7-606 | ||||||||||||||||||||||||||||||
| 1880 | bool first = true; | - | ||||||||||||||||||||||||||||||
| 1881 | - | |||||||||||||||||||||||||||||||
| 1882 | for (int s = 0; s < nexpected; ++s) {
| 448-759 | ||||||||||||||||||||||||||||||
| 1883 | if (first)
| 311-448 | ||||||||||||||||||||||||||||||
| 1884 | error_message += QXmlStream::tr ("Expected "); executed 448 times by 1 test: error_message += QXmlStream::tr ("Expected ");Executed by:
| 448 | ||||||||||||||||||||||||||||||
| 1885 | else if (s == nexpected - 1)
| 89-222 | ||||||||||||||||||||||||||||||
| 1886 | error_message += QLatin1String (nexpected > 2 ? ", or " : " or "); executed 222 times by 1 test: error_message += QLatin1String (nexpected > 2 ? ", or " : " or ");Executed by:
| 222 | ||||||||||||||||||||||||||||||
| 1887 | else | - | ||||||||||||||||||||||||||||||
| 1888 | error_message += QLatin1String (", "); executed 89 times by 1 test: error_message += QLatin1String (", ");Executed by:
| 89 | ||||||||||||||||||||||||||||||
| 1889 | - | |||||||||||||||||||||||||||||||
| 1890 | first = false; | - | ||||||||||||||||||||||||||||||
| 1891 | error_message += QLatin1String("\'"); | - | ||||||||||||||||||||||||||||||
| 1892 | error_message += QLatin1String (spell [expected[s]]); | - | ||||||||||||||||||||||||||||||
| 1893 | error_message += QLatin1String("\'"); | - | ||||||||||||||||||||||||||||||
| 1894 | } executed 759 times by 1 test: end of blockExecuted by:
| 759 | ||||||||||||||||||||||||||||||
| 1895 | error_message += QXmlStream::tr(", but got \'"); | - | ||||||||||||||||||||||||||||||
| 1896 | error_message += QLatin1String(spell [token]); | - | ||||||||||||||||||||||||||||||
| 1897 | error_message += QLatin1String("\'"); | - | ||||||||||||||||||||||||||||||
| 1898 | } else { executed 448 times by 1 test: end of blockExecuted by:
| 448 | ||||||||||||||||||||||||||||||
| 1899 | error_message += QXmlStream::tr("Unexpected \'"); | - | ||||||||||||||||||||||||||||||
| 1900 | error_message += QLatin1String(spell [token]); | - | ||||||||||||||||||||||||||||||
| 1901 | error_message += QLatin1String("\'"); | - | ||||||||||||||||||||||||||||||
| 1902 | } executed 165 times by 1 test: end of blockExecuted by:
| 165 | ||||||||||||||||||||||||||||||
| 1903 | error_message += QLatin1Char('.'); | - | ||||||||||||||||||||||||||||||
| 1904 | - | |||||||||||||||||||||||||||||||
| 1905 | raiseWellFormedError(error_message); | - | ||||||||||||||||||||||||||||||
| 1906 | } executed 613 times by 1 test: end of blockExecuted by:
| 613 | ||||||||||||||||||||||||||||||
| 1907 | - | |||||||||||||||||||||||||||||||
| 1908 | void QXmlStreamReaderPrivate::resume(int rule) { | - | ||||||||||||||||||||||||||||||
| 1909 | resumeReduction = rule; | - | ||||||||||||||||||||||||||||||
| 1910 | if (error == QXmlStreamReader::NoError)
| 26-44571 | ||||||||||||||||||||||||||||||
| 1911 | raiseError(QXmlStreamReader::PrematureEndOfDocumentError); executed 26 times by 1 test: raiseError(QXmlStreamReader::PrematureEndOfDocumentError);Executed by:
| 26 | ||||||||||||||||||||||||||||||
| 1912 | } executed 44597 times by 1 test: end of blockExecuted by:
| 44597 | ||||||||||||||||||||||||||||||
| 1913 | - | |||||||||||||||||||||||||||||||
| 1914 | /*! Returns the current line number, starting with 1. | - | ||||||||||||||||||||||||||||||
| 1915 | - | |||||||||||||||||||||||||||||||
| 1916 | \sa columnNumber(), characterOffset() | - | ||||||||||||||||||||||||||||||
| 1917 | */ | - | ||||||||||||||||||||||||||||||
| 1918 | qint64 QXmlStreamReader::lineNumber() const | - | ||||||||||||||||||||||||||||||
| 1919 | { | - | ||||||||||||||||||||||||||||||
| 1920 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1921 | return d->lineNumber + 1; // in public we start with 1 executed 584 times by 1 test: return d->lineNumber + 1;Executed by:
| 584 | ||||||||||||||||||||||||||||||
| 1922 | } | - | ||||||||||||||||||||||||||||||
| 1923 | - | |||||||||||||||||||||||||||||||
| 1924 | /*! Returns the current column number, starting with 0. | - | ||||||||||||||||||||||||||||||
| 1925 | - | |||||||||||||||||||||||||||||||
| 1926 | \sa lineNumber(), characterOffset() | - | ||||||||||||||||||||||||||||||
| 1927 | */ | - | ||||||||||||||||||||||||||||||
| 1928 | qint64 QXmlStreamReader::columnNumber() const | - | ||||||||||||||||||||||||||||||
| 1929 | { | - | ||||||||||||||||||||||||||||||
| 1930 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1931 | return d->characterOffset - d->lastLineStart + d->readBufferPos; executed 584 times by 1 test: return d->characterOffset - d->lastLineStart + d->readBufferPos;Executed by:
| 584 | ||||||||||||||||||||||||||||||
| 1932 | } | - | ||||||||||||||||||||||||||||||
| 1933 | - | |||||||||||||||||||||||||||||||
| 1934 | /*! Returns the current character offset, starting with 0. | - | ||||||||||||||||||||||||||||||
| 1935 | - | |||||||||||||||||||||||||||||||
| 1936 | \sa lineNumber(), columnNumber() | - | ||||||||||||||||||||||||||||||
| 1937 | */ | - | ||||||||||||||||||||||||||||||
| 1938 | qint64 QXmlStreamReader::characterOffset() const | - | ||||||||||||||||||||||||||||||
| 1939 | { | - | ||||||||||||||||||||||||||||||
| 1940 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1941 | return d->characterOffset + d->readBufferPos; never executed: return d->characterOffset + d->readBufferPos; | 0 | ||||||||||||||||||||||||||||||
| 1942 | } | - | ||||||||||||||||||||||||||||||
| 1943 | - | |||||||||||||||||||||||||||||||
| 1944 | - | |||||||||||||||||||||||||||||||
| 1945 | /*! Returns the text of \l Characters, \l Comment, \l DTD, or | - | ||||||||||||||||||||||||||||||
| 1946 | EntityReference. | - | ||||||||||||||||||||||||||||||
| 1947 | */ | - | ||||||||||||||||||||||||||||||
| 1948 | QStringRef QXmlStreamReader::text() const | - | ||||||||||||||||||||||||||||||
| 1949 | { | - | ||||||||||||||||||||||||||||||
| 1950 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1951 | return d->text; executed 3556 times by 1 test: return d->text;Executed by:
| 3556 | ||||||||||||||||||||||||||||||
| 1952 | } | - | ||||||||||||||||||||||||||||||
| 1953 | - | |||||||||||||||||||||||||||||||
| 1954 | - | |||||||||||||||||||||||||||||||
| 1955 | /*! If the tokenType() is \l DTD, this function returns the DTD's | - | ||||||||||||||||||||||||||||||
| 1956 | notation declarations. Otherwise an empty vector is returned. | - | ||||||||||||||||||||||||||||||
| 1957 | - | |||||||||||||||||||||||||||||||
| 1958 | The QXmlStreamNotationDeclarations class is defined to be a QVector | - | ||||||||||||||||||||||||||||||
| 1959 | of QXmlStreamNotationDeclaration. | - | ||||||||||||||||||||||||||||||
| 1960 | */ | - | ||||||||||||||||||||||||||||||
| 1961 | QXmlStreamNotationDeclarations QXmlStreamReader::notationDeclarations() const | - | ||||||||||||||||||||||||||||||
| 1962 | { | - | ||||||||||||||||||||||||||||||
| 1963 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1964 | if (d->notationDeclarations.size())
| 47-2545 | ||||||||||||||||||||||||||||||
| 1965 | const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd(); executed 47 times by 1 test: const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd();Executed by:
| 47 | ||||||||||||||||||||||||||||||
| 1966 | return d->publicNotationDeclarations; executed 2592 times by 1 test: return d->publicNotationDeclarations;Executed by:
| 2592 | ||||||||||||||||||||||||||||||
| 1967 | } | - | ||||||||||||||||||||||||||||||
| 1968 | - | |||||||||||||||||||||||||||||||
| 1969 | - | |||||||||||||||||||||||||||||||
| 1970 | /*! If the tokenType() is \l DTD, this function returns the DTD's | - | ||||||||||||||||||||||||||||||
| 1971 | unparsed (external) entity declarations. Otherwise an empty vector is returned. | - | ||||||||||||||||||||||||||||||
| 1972 | - | |||||||||||||||||||||||||||||||
| 1973 | The QXmlStreamEntityDeclarations class is defined to be a QVector | - | ||||||||||||||||||||||||||||||
| 1974 | of QXmlStreamEntityDeclaration. | - | ||||||||||||||||||||||||||||||
| 1975 | */ | - | ||||||||||||||||||||||||||||||
| 1976 | QXmlStreamEntityDeclarations QXmlStreamReader::entityDeclarations() const | - | ||||||||||||||||||||||||||||||
| 1977 | { | - | ||||||||||||||||||||||||||||||
| 1978 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1979 | if (d->entityDeclarations.size())
| 5-1903 | ||||||||||||||||||||||||||||||
| 1980 | const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd(); executed 5 times by 1 test: const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd();Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 1981 | return d->publicEntityDeclarations; executed 1908 times by 1 test: return d->publicEntityDeclarations;Executed by:
| 1908 | ||||||||||||||||||||||||||||||
| 1982 | } | - | ||||||||||||||||||||||||||||||
| 1983 | - | |||||||||||||||||||||||||||||||
| 1984 | /*! | - | ||||||||||||||||||||||||||||||
| 1985 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 1986 | - | |||||||||||||||||||||||||||||||
| 1987 | If the tokenType() is \l DTD, this function returns the DTD's | - | ||||||||||||||||||||||||||||||
| 1988 | name. Otherwise an empty string is returned. | - | ||||||||||||||||||||||||||||||
| 1989 | - | |||||||||||||||||||||||||||||||
| 1990 | */ | - | ||||||||||||||||||||||||||||||
| 1991 | QStringRef QXmlStreamReader::dtdName() const | - | ||||||||||||||||||||||||||||||
| 1992 | { | - | ||||||||||||||||||||||||||||||
| 1993 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 1994 | if (d->type == QXmlStreamReader::DTD)
| 50-1878 | ||||||||||||||||||||||||||||||
| 1995 | return d->dtdName; executed 50 times by 1 test: return d->dtdName;Executed by:
| 50 | ||||||||||||||||||||||||||||||
| 1996 | return QStringRef(); executed 1878 times by 1 test: return QStringRef();Executed by:
| 1878 | ||||||||||||||||||||||||||||||
| 1997 | } | - | ||||||||||||||||||||||||||||||
| 1998 | - | |||||||||||||||||||||||||||||||
| 1999 | /*! | - | ||||||||||||||||||||||||||||||
| 2000 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2001 | - | |||||||||||||||||||||||||||||||
| 2002 | If the tokenType() is \l DTD, this function returns the DTD's | - | ||||||||||||||||||||||||||||||
| 2003 | public identifier. Otherwise an empty string is returned. | - | ||||||||||||||||||||||||||||||
| 2004 | - | |||||||||||||||||||||||||||||||
| 2005 | */ | - | ||||||||||||||||||||||||||||||
| 2006 | QStringRef QXmlStreamReader::dtdPublicId() const | - | ||||||||||||||||||||||||||||||
| 2007 | { | - | ||||||||||||||||||||||||||||||
| 2008 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2009 | if (d->type == QXmlStreamReader::DTD)
| 27-1878 | ||||||||||||||||||||||||||||||
| 2010 | return d->dtdPublicId; executed 27 times by 1 test: return d->dtdPublicId;Executed by:
| 27 | ||||||||||||||||||||||||||||||
| 2011 | return QStringRef(); executed 1878 times by 1 test: return QStringRef();Executed by:
| 1878 | ||||||||||||||||||||||||||||||
| 2012 | } | - | ||||||||||||||||||||||||||||||
| 2013 | - | |||||||||||||||||||||||||||||||
| 2014 | /*! | - | ||||||||||||||||||||||||||||||
| 2015 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2016 | - | |||||||||||||||||||||||||||||||
| 2017 | If the tokenType() is \l DTD, this function returns the DTD's | - | ||||||||||||||||||||||||||||||
| 2018 | system identifier. Otherwise an empty string is returned. | - | ||||||||||||||||||||||||||||||
| 2019 | - | |||||||||||||||||||||||||||||||
| 2020 | */ | - | ||||||||||||||||||||||||||||||
| 2021 | QStringRef QXmlStreamReader::dtdSystemId() const | - | ||||||||||||||||||||||||||||||
| 2022 | { | - | ||||||||||||||||||||||||||||||
| 2023 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2024 | if (d->type == QXmlStreamReader::DTD)
| 27-1878 | ||||||||||||||||||||||||||||||
| 2025 | return d->dtdSystemId; executed 27 times by 1 test: return d->dtdSystemId;Executed by:
| 27 | ||||||||||||||||||||||||||||||
| 2026 | return QStringRef(); executed 1878 times by 1 test: return QStringRef();Executed by:
| 1878 | ||||||||||||||||||||||||||||||
| 2027 | } | - | ||||||||||||||||||||||||||||||
| 2028 | - | |||||||||||||||||||||||||||||||
| 2029 | /*! If the tokenType() is \l StartElement, this function returns the | - | ||||||||||||||||||||||||||||||
| 2030 | element's namespace declarations. Otherwise an empty vector is | - | ||||||||||||||||||||||||||||||
| 2031 | returned. | - | ||||||||||||||||||||||||||||||
| 2032 | - | |||||||||||||||||||||||||||||||
| 2033 | The QXmlStreamNamespaceDeclarations class is defined to be a QVector | - | ||||||||||||||||||||||||||||||
| 2034 | of QXmlStreamNamespaceDeclaration. | - | ||||||||||||||||||||||||||||||
| 2035 | - | |||||||||||||||||||||||||||||||
| 2036 | \sa addExtraNamespaceDeclaration(), addExtraNamespaceDeclarations() | - | ||||||||||||||||||||||||||||||
| 2037 | */ | - | ||||||||||||||||||||||||||||||
| 2038 | QXmlStreamNamespaceDeclarations QXmlStreamReader::namespaceDeclarations() const | - | ||||||||||||||||||||||||||||||
| 2039 | { | - | ||||||||||||||||||||||||||||||
| 2040 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2041 | if (d->publicNamespaceDeclarations.isEmpty() && d->type == StartElement)
| 38-1907 | ||||||||||||||||||||||||||||||
| 2042 | const_cast<QXmlStreamReaderPrivate *>(d)->resolvePublicNamespaces(); executed 446 times by 1 test: const_cast<QXmlStreamReaderPrivate *>(d)->resolvePublicNamespaces();Executed by:
| 446 | ||||||||||||||||||||||||||||||
| 2043 | return d->publicNamespaceDeclarations; executed 1945 times by 1 test: return d->publicNamespaceDeclarations;Executed by:
| 1945 | ||||||||||||||||||||||||||||||
| 2044 | } | - | ||||||||||||||||||||||||||||||
| 2045 | - | |||||||||||||||||||||||||||||||
| 2046 | - | |||||||||||||||||||||||||||||||
| 2047 | /*! | - | ||||||||||||||||||||||||||||||
| 2048 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2049 | - | |||||||||||||||||||||||||||||||
| 2050 | Adds an \a extraNamespaceDeclaration. The declaration will be | - | ||||||||||||||||||||||||||||||
| 2051 | valid for children of the current element, or - should the function | - | ||||||||||||||||||||||||||||||
| 2052 | be called before any elements are read - for the entire XML | - | ||||||||||||||||||||||||||||||
| 2053 | document. | - | ||||||||||||||||||||||||||||||
| 2054 | - | |||||||||||||||||||||||||||||||
| 2055 | \sa namespaceDeclarations(), addExtraNamespaceDeclarations(), setNamespaceProcessing() | - | ||||||||||||||||||||||||||||||
| 2056 | */ | - | ||||||||||||||||||||||||||||||
| 2057 | void QXmlStreamReader::addExtraNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &extraNamespaceDeclaration) | - | ||||||||||||||||||||||||||||||
| 2058 | { | - | ||||||||||||||||||||||||||||||
| 2059 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2060 | QXmlStreamReaderPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 2061 | namespaceDeclaration.prefix = d->addToStringStorage(extraNamespaceDeclaration.prefix()); | - | ||||||||||||||||||||||||||||||
| 2062 | namespaceDeclaration.namespaceUri = d->addToStringStorage(extraNamespaceDeclaration.namespaceUri()); | - | ||||||||||||||||||||||||||||||
| 2063 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 2064 | - | |||||||||||||||||||||||||||||||
| 2065 | /*! | - | ||||||||||||||||||||||||||||||
| 2066 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2067 | - | |||||||||||||||||||||||||||||||
| 2068 | Adds a vector of declarations specified by \a extraNamespaceDeclarations. | - | ||||||||||||||||||||||||||||||
| 2069 | - | |||||||||||||||||||||||||||||||
| 2070 | \sa namespaceDeclarations(), addExtraNamespaceDeclaration() | - | ||||||||||||||||||||||||||||||
| 2071 | */ | - | ||||||||||||||||||||||||||||||
| 2072 | void QXmlStreamReader::addExtraNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &extraNamespaceDeclarations) | - | ||||||||||||||||||||||||||||||
| 2073 | { | - | ||||||||||||||||||||||||||||||
| 2074 | for (int i = 0; i < extraNamespaceDeclarations.size(); ++i)
| 0 | ||||||||||||||||||||||||||||||
| 2075 | addExtraNamespaceDeclaration(extraNamespaceDeclarations.at(i)); never executed: addExtraNamespaceDeclaration(extraNamespaceDeclarations.at(i)); | 0 | ||||||||||||||||||||||||||||||
| 2076 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2077 | - | |||||||||||||||||||||||||||||||
| 2078 | - | |||||||||||||||||||||||||||||||
| 2079 | /*! Convenience function to be called in case a StartElement was | - | ||||||||||||||||||||||||||||||
| 2080 | read. Reads until the corresponding EndElement and returns all text | - | ||||||||||||||||||||||||||||||
| 2081 | in-between. In case of no error, the current token (see tokenType()) | - | ||||||||||||||||||||||||||||||
| 2082 | after having called this function is EndElement. | - | ||||||||||||||||||||||||||||||
| 2083 | - | |||||||||||||||||||||||||||||||
| 2084 | The function concatenates text() when it reads either \l Characters | - | ||||||||||||||||||||||||||||||
| 2085 | or EntityReference tokens, but skips ProcessingInstruction and \l | - | ||||||||||||||||||||||||||||||
| 2086 | Comment. If the current token is not StartElement, an empty string is | - | ||||||||||||||||||||||||||||||
| 2087 | returned. | - | ||||||||||||||||||||||||||||||
| 2088 | - | |||||||||||||||||||||||||||||||
| 2089 | The \a behaviour defines what happens in case anything else is | - | ||||||||||||||||||||||||||||||
| 2090 | read before reaching EndElement. The function can include the text from | - | ||||||||||||||||||||||||||||||
| 2091 | child elements (useful for example for HTML), ignore child elements, or | - | ||||||||||||||||||||||||||||||
| 2092 | raise an UnexpectedElementError and return what was read so far (default). | - | ||||||||||||||||||||||||||||||
| 2093 | - | |||||||||||||||||||||||||||||||
| 2094 | \since 4.6 | - | ||||||||||||||||||||||||||||||
| 2095 | */ | - | ||||||||||||||||||||||||||||||
| 2096 | QString QXmlStreamReader::readElementText(ReadElementTextBehaviour behaviour) | - | ||||||||||||||||||||||||||||||
| 2097 | { | - | ||||||||||||||||||||||||||||||
| 2098 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2099 | if (isStartElement()) {
| 0-134858 | ||||||||||||||||||||||||||||||
| 2100 | QString result; | - | ||||||||||||||||||||||||||||||
| 2101 | forever { | - | ||||||||||||||||||||||||||||||
| 2102 | switch (readNext()) { | - | ||||||||||||||||||||||||||||||
| 2103 | case Characters: executed 134861 times by 2 tests: case Characters:Executed by:
| 134861 | ||||||||||||||||||||||||||||||
| 2104 | case EntityReference: never executed: case EntityReference: | 0 | ||||||||||||||||||||||||||||||
| 2105 | result.insert(result.size(), d->text.unicode(), d->text.size()); | - | ||||||||||||||||||||||||||||||
| 2106 | break; executed 134861 times by 2 tests: break;Executed by:
| 134861 | ||||||||||||||||||||||||||||||
| 2107 | case EndElement: executed 134853 times by 2 tests: case EndElement:Executed by:
| 134853 | ||||||||||||||||||||||||||||||
| 2108 | return result; executed 134853 times by 2 tests: return result;Executed by:
| 134853 | ||||||||||||||||||||||||||||||
| 2109 | case ProcessingInstruction: never executed: case ProcessingInstruction: | 0 | ||||||||||||||||||||||||||||||
| 2110 | case Comment: executed 2 times by 1 test: case Comment:Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2111 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2112 | case StartElement: executed 6 times by 1 test: case StartElement:Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 2113 | if (behaviour == SkipChildElements) {
| 2-4 | ||||||||||||||||||||||||||||||
| 2114 | skipCurrentElement(); | - | ||||||||||||||||||||||||||||||
| 2115 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2116 | } else if (behaviour == IncludeChildElements) {
| 2 | ||||||||||||||||||||||||||||||
| 2117 | result += readElementText(behaviour); | - | ||||||||||||||||||||||||||||||
| 2118 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 2119 | } | - | ||||||||||||||||||||||||||||||
| 2120 | // Fall through (for ErrorOnUnexpectedElement) | - | ||||||||||||||||||||||||||||||
| 2121 | 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 | ||||||||||||||||||||||||||||||
| 2122 | if (d->error || behaviour == ErrorOnUnexpectedElement) {
| 0-2 | ||||||||||||||||||||||||||||||
| 2123 | if (!d->error)
| 2-3 | ||||||||||||||||||||||||||||||
| 2124 | 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 | ||||||||||||||||||||||||||||||
| 2125 | return result; executed 5 times by 1 test: return result;Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 2126 | } | - | ||||||||||||||||||||||||||||||
| 2127 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2128 | } | - | ||||||||||||||||||||||||||||||
| 2129 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2130 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||
| 2131 | } | - | ||||||||||||||||||||||||||||||
| 2132 | - | |||||||||||||||||||||||||||||||
| 2133 | /*! Raises a custom error with an optional error \a message. | - | ||||||||||||||||||||||||||||||
| 2134 | - | |||||||||||||||||||||||||||||||
| 2135 | \sa error(), errorString() | - | ||||||||||||||||||||||||||||||
| 2136 | */ | - | ||||||||||||||||||||||||||||||
| 2137 | void QXmlStreamReader::raiseError(const QString& message) | - | ||||||||||||||||||||||||||||||
| 2138 | { | - | ||||||||||||||||||||||||||||||
| 2139 | Q_D(QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2140 | d->raiseError(CustomError, message); | - | ||||||||||||||||||||||||||||||
| 2141 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2142 | - | |||||||||||||||||||||||||||||||
| 2143 | /*! | - | ||||||||||||||||||||||||||||||
| 2144 | Returns the error message that was set with raiseError(). | - | ||||||||||||||||||||||||||||||
| 2145 | - | |||||||||||||||||||||||||||||||
| 2146 | \sa error(), lineNumber(), columnNumber(), characterOffset() | - | ||||||||||||||||||||||||||||||
| 2147 | */ | - | ||||||||||||||||||||||||||||||
| 2148 | QString QXmlStreamReader::errorString() const | - | ||||||||||||||||||||||||||||||
| 2149 | { | - | ||||||||||||||||||||||||||||||
| 2150 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2151 | if (d->type == QXmlStreamReader::Invalid)
| 39-586 | ||||||||||||||||||||||||||||||
| 2152 | return d->errorString; executed 39 times by 1 test: return d->errorString;Executed by:
| 39 | ||||||||||||||||||||||||||||||
| 2153 | return QString(); executed 586 times by 2 tests: return QString();Executed by:
| 586 | ||||||||||||||||||||||||||||||
| 2154 | } | - | ||||||||||||||||||||||||||||||
| 2155 | - | |||||||||||||||||||||||||||||||
| 2156 | /*! Returns the type of the current error, or NoError if no error occurred. | - | ||||||||||||||||||||||||||||||
| 2157 | - | |||||||||||||||||||||||||||||||
| 2158 | \sa errorString(), raiseError() | - | ||||||||||||||||||||||||||||||
| 2159 | */ | - | ||||||||||||||||||||||||||||||
| 2160 | QXmlStreamReader::Error QXmlStreamReader::error() const | - | ||||||||||||||||||||||||||||||
| 2161 | { | - | ||||||||||||||||||||||||||||||
| 2162 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2163 | if (d->type == QXmlStreamReader::Invalid)
| 2921-59946 | ||||||||||||||||||||||||||||||
| 2164 | return d->error; executed 59946 times by 3 tests: return d->error;Executed by:
| 59946 | ||||||||||||||||||||||||||||||
| 2165 | return NoError; executed 2921 times by 15 tests: return NoError;Executed by:
| 2921 | ||||||||||||||||||||||||||||||
| 2166 | } | - | ||||||||||||||||||||||||||||||
| 2167 | - | |||||||||||||||||||||||||||||||
| 2168 | /*! | - | ||||||||||||||||||||||||||||||
| 2169 | Returns the target of a ProcessingInstruction. | - | ||||||||||||||||||||||||||||||
| 2170 | */ | - | ||||||||||||||||||||||||||||||
| 2171 | QStringRef QXmlStreamReader::processingInstructionTarget() const | - | ||||||||||||||||||||||||||||||
| 2172 | { | - | ||||||||||||||||||||||||||||||
| 2173 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2174 | return d->processingInstructionTarget; executed 1988 times by 1 test: return d->processingInstructionTarget;Executed by:
| 1988 | ||||||||||||||||||||||||||||||
| 2175 | } | - | ||||||||||||||||||||||||||||||
| 2176 | - | |||||||||||||||||||||||||||||||
| 2177 | /*! | - | ||||||||||||||||||||||||||||||
| 2178 | Returns the data of a ProcessingInstruction. | - | ||||||||||||||||||||||||||||||
| 2179 | */ | - | ||||||||||||||||||||||||||||||
| 2180 | QStringRef QXmlStreamReader::processingInstructionData() const | - | ||||||||||||||||||||||||||||||
| 2181 | { | - | ||||||||||||||||||||||||||||||
| 2182 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2183 | return d->processingInstructionData; executed 2024 times by 1 test: return d->processingInstructionData;Executed by:
| 2024 | ||||||||||||||||||||||||||||||
| 2184 | } | - | ||||||||||||||||||||||||||||||
| 2185 | - | |||||||||||||||||||||||||||||||
| 2186 | - | |||||||||||||||||||||||||||||||
| 2187 | - | |||||||||||||||||||||||||||||||
| 2188 | /*! | - | ||||||||||||||||||||||||||||||
| 2189 | Returns the local name of a StartElement, EndElement, or an EntityReference. | - | ||||||||||||||||||||||||||||||
| 2190 | - | |||||||||||||||||||||||||||||||
| 2191 | \sa namespaceUri(), qualifiedName() | - | ||||||||||||||||||||||||||||||
| 2192 | */ | - | ||||||||||||||||||||||||||||||
| 2193 | QStringRef QXmlStreamReader::name() const | - | ||||||||||||||||||||||||||||||
| 2194 | { | - | ||||||||||||||||||||||||||||||
| 2195 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2196 | return d->name; executed 190123 times by 14 tests: return d->name;Executed by:
| 190123 | ||||||||||||||||||||||||||||||
| 2197 | } | - | ||||||||||||||||||||||||||||||
| 2198 | - | |||||||||||||||||||||||||||||||
| 2199 | /*! | - | ||||||||||||||||||||||||||||||
| 2200 | Returns the namespaceUri of a StartElement or EndElement. | - | ||||||||||||||||||||||||||||||
| 2201 | - | |||||||||||||||||||||||||||||||
| 2202 | \sa name(), qualifiedName() | - | ||||||||||||||||||||||||||||||
| 2203 | */ | - | ||||||||||||||||||||||||||||||
| 2204 | QStringRef QXmlStreamReader::namespaceUri() const | - | ||||||||||||||||||||||||||||||
| 2205 | { | - | ||||||||||||||||||||||||||||||
| 2206 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2207 | return d->namespaceUri; executed 3754 times by 1 test: return d->namespaceUri;Executed by:
| 3754 | ||||||||||||||||||||||||||||||
| 2208 | } | - | ||||||||||||||||||||||||||||||
| 2209 | - | |||||||||||||||||||||||||||||||
| 2210 | /*! | - | ||||||||||||||||||||||||||||||
| 2211 | Returns the qualified name of a StartElement or EndElement; | - | ||||||||||||||||||||||||||||||
| 2212 | - | |||||||||||||||||||||||||||||||
| 2213 | A qualified name is the raw name of an element in the XML data. It | - | ||||||||||||||||||||||||||||||
| 2214 | consists of the namespace prefix, followed by colon, followed by the | - | ||||||||||||||||||||||||||||||
| 2215 | element's local name. Since the namespace prefix is not unique (the | - | ||||||||||||||||||||||||||||||
| 2216 | same prefix can point to different namespaces and different prefixes | - | ||||||||||||||||||||||||||||||
| 2217 | can point to the same namespace), you shouldn't use qualifiedName(), | - | ||||||||||||||||||||||||||||||
| 2218 | but the resolved namespaceUri() and the attribute's local name(). | - | ||||||||||||||||||||||||||||||
| 2219 | - | |||||||||||||||||||||||||||||||
| 2220 | \sa name(), prefix(), namespaceUri() | - | ||||||||||||||||||||||||||||||
| 2221 | */ | - | ||||||||||||||||||||||||||||||
| 2222 | QStringRef QXmlStreamReader::qualifiedName() const | - | ||||||||||||||||||||||||||||||
| 2223 | { | - | ||||||||||||||||||||||||||||||
| 2224 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2225 | return d->qualifiedName; executed 3055 times by 1 test: return d->qualifiedName;Executed by:
| 3055 | ||||||||||||||||||||||||||||||
| 2226 | } | - | ||||||||||||||||||||||||||||||
| 2227 | - | |||||||||||||||||||||||||||||||
| 2228 | - | |||||||||||||||||||||||||||||||
| 2229 | - | |||||||||||||||||||||||||||||||
| 2230 | /*! | - | ||||||||||||||||||||||||||||||
| 2231 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2232 | - | |||||||||||||||||||||||||||||||
| 2233 | Returns the prefix of a StartElement or EndElement. | - | ||||||||||||||||||||||||||||||
| 2234 | - | |||||||||||||||||||||||||||||||
| 2235 | \sa name(), qualifiedName() | - | ||||||||||||||||||||||||||||||
| 2236 | */ | - | ||||||||||||||||||||||||||||||
| 2237 | QStringRef QXmlStreamReader::prefix() const | - | ||||||||||||||||||||||||||||||
| 2238 | { | - | ||||||||||||||||||||||||||||||
| 2239 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2240 | return d->prefix; executed 1943 times by 2 tests: return d->prefix;Executed by:
| 1943 | ||||||||||||||||||||||||||||||
| 2241 | } | - | ||||||||||||||||||||||||||||||
| 2242 | - | |||||||||||||||||||||||||||||||
| 2243 | /*! | - | ||||||||||||||||||||||||||||||
| 2244 | Returns the attributes of a StartElement. | - | ||||||||||||||||||||||||||||||
| 2245 | */ | - | ||||||||||||||||||||||||||||||
| 2246 | QXmlStreamAttributes QXmlStreamReader::attributes() const | - | ||||||||||||||||||||||||||||||
| 2247 | { | - | ||||||||||||||||||||||||||||||
| 2248 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2249 | return d->attributes; executed 162995 times by 14 tests: return d->attributes;Executed by:
| 162995 | ||||||||||||||||||||||||||||||
| 2250 | } | - | ||||||||||||||||||||||||||||||
| 2251 | - | |||||||||||||||||||||||||||||||
| 2252 | #endif // QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 2253 | - | |||||||||||||||||||||||||||||||
| 2254 | /*! | - | ||||||||||||||||||||||||||||||
| 2255 | \class QXmlStreamAttribute | - | ||||||||||||||||||||||||||||||
| 2256 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2257 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2258 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2259 | \brief The QXmlStreamAttribute class represents a single XML attribute | - | ||||||||||||||||||||||||||||||
| 2260 | - | |||||||||||||||||||||||||||||||
| 2261 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2262 | - | |||||||||||||||||||||||||||||||
| 2263 | An attribute consists of an optionally empty namespaceUri(), a | - | ||||||||||||||||||||||||||||||
| 2264 | name(), a value(), and an isDefault() attribute. | - | ||||||||||||||||||||||||||||||
| 2265 | - | |||||||||||||||||||||||||||||||
| 2266 | The raw XML attribute name is returned as qualifiedName(). | - | ||||||||||||||||||||||||||||||
| 2267 | */ | - | ||||||||||||||||||||||||||||||
| 2268 | - | |||||||||||||||||||||||||||||||
| 2269 | /*! | - | ||||||||||||||||||||||||||||||
| 2270 | Creates an empty attribute. | - | ||||||||||||||||||||||||||||||
| 2271 | */ | - | ||||||||||||||||||||||||||||||
| 2272 | QXmlStreamAttribute::QXmlStreamAttribute() | - | ||||||||||||||||||||||||||||||
| 2273 | { | - | ||||||||||||||||||||||||||||||
| 2274 | m_isDefault = false; | - | ||||||||||||||||||||||||||||||
| 2275 | } executed 269674 times by 15 tests: end of blockExecuted by:
| 269674 | ||||||||||||||||||||||||||||||
| 2276 | - | |||||||||||||||||||||||||||||||
| 2277 | /*! | - | ||||||||||||||||||||||||||||||
| 2278 | Destructs an attribute. | - | ||||||||||||||||||||||||||||||
| 2279 | */ | - | ||||||||||||||||||||||||||||||
| 2280 | QXmlStreamAttribute::~QXmlStreamAttribute() | - | ||||||||||||||||||||||||||||||
| 2281 | { | - | ||||||||||||||||||||||||||||||
| 2282 | } | - | ||||||||||||||||||||||||||||||
| 2283 | - | |||||||||||||||||||||||||||||||
| 2284 | /*! Constructs an attribute in the namespace described with \a | - | ||||||||||||||||||||||||||||||
| 2285 | namespaceUri with \a name and value \a value. | - | ||||||||||||||||||||||||||||||
| 2286 | */ | - | ||||||||||||||||||||||||||||||
| 2287 | QXmlStreamAttribute::QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value) | - | ||||||||||||||||||||||||||||||
| 2288 | { | - | ||||||||||||||||||||||||||||||
| 2289 | m_namespaceUri = QXmlStreamStringRef(QStringRef(&namespaceUri)); | - | ||||||||||||||||||||||||||||||
| 2290 | m_name = m_qualifiedName = QXmlStreamStringRef(QStringRef(&name)); | - | ||||||||||||||||||||||||||||||
| 2291 | m_value = QXmlStreamStringRef(QStringRef(&value)); | - | ||||||||||||||||||||||||||||||
| 2292 | m_namespaceUri = QXmlStreamStringRef(QStringRef(&namespaceUri)); | - | ||||||||||||||||||||||||||||||
| 2293 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2294 | - | |||||||||||||||||||||||||||||||
| 2295 | /*! | - | ||||||||||||||||||||||||||||||
| 2296 | Constructs an attribute with qualified name \a qualifiedName and value \a value. | - | ||||||||||||||||||||||||||||||
| 2297 | */ | - | ||||||||||||||||||||||||||||||
| 2298 | QXmlStreamAttribute::QXmlStreamAttribute(const QString &qualifiedName, const QString &value) | - | ||||||||||||||||||||||||||||||
| 2299 | { | - | ||||||||||||||||||||||||||||||
| 2300 | int colon = qualifiedName.indexOf(QLatin1Char(':')); | - | ||||||||||||||||||||||||||||||
| 2301 | m_name = QXmlStreamStringRef(QStringRef(&qualifiedName, | - | ||||||||||||||||||||||||||||||
| 2302 | colon + 1, | - | ||||||||||||||||||||||||||||||
| 2303 | qualifiedName.size() - (colon + 1))); | - | ||||||||||||||||||||||||||||||
| 2304 | m_qualifiedName = QXmlStreamStringRef(QStringRef(&qualifiedName)); | - | ||||||||||||||||||||||||||||||
| 2305 | m_value = QXmlStreamStringRef(QStringRef(&value)); | - | ||||||||||||||||||||||||||||||
| 2306 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2307 | - | |||||||||||||||||||||||||||||||
| 2308 | /*! \fn QStringRef QXmlStreamAttribute::namespaceUri() const | - | ||||||||||||||||||||||||||||||
| 2309 | - | |||||||||||||||||||||||||||||||
| 2310 | Returns the attribute's resolved namespaceUri, or an empty string | - | ||||||||||||||||||||||||||||||
| 2311 | reference if the attribute does not have a defined namespace. | - | ||||||||||||||||||||||||||||||
| 2312 | */ | - | ||||||||||||||||||||||||||||||
| 2313 | /*! \fn QStringRef QXmlStreamAttribute::name() const | - | ||||||||||||||||||||||||||||||
| 2314 | Returns the attribute's local name. | - | ||||||||||||||||||||||||||||||
| 2315 | */ | - | ||||||||||||||||||||||||||||||
| 2316 | /*! \fn QStringRef QXmlStreamAttribute::qualifiedName() const | - | ||||||||||||||||||||||||||||||
| 2317 | Returns the attribute's qualified name. | - | ||||||||||||||||||||||||||||||
| 2318 | - | |||||||||||||||||||||||||||||||
| 2319 | A qualified name is the raw name of an attribute in the XML | - | ||||||||||||||||||||||||||||||
| 2320 | data. It consists of the namespace prefix(), followed by colon, | - | ||||||||||||||||||||||||||||||
| 2321 | followed by the attribute's local name(). Since the namespace prefix | - | ||||||||||||||||||||||||||||||
| 2322 | is not unique (the same prefix can point to different namespaces | - | ||||||||||||||||||||||||||||||
| 2323 | and different prefixes can point to the same namespace), you | - | ||||||||||||||||||||||||||||||
| 2324 | shouldn't use qualifiedName(), but the resolved namespaceUri() and | - | ||||||||||||||||||||||||||||||
| 2325 | the attribute's local name(). | - | ||||||||||||||||||||||||||||||
| 2326 | */ | - | ||||||||||||||||||||||||||||||
| 2327 | /*! | - | ||||||||||||||||||||||||||||||
| 2328 | \fn QStringRef QXmlStreamAttribute::prefix() const | - | ||||||||||||||||||||||||||||||
| 2329 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2330 | Returns the attribute's namespace prefix. | - | ||||||||||||||||||||||||||||||
| 2331 | - | |||||||||||||||||||||||||||||||
| 2332 | \sa name(), qualifiedName() | - | ||||||||||||||||||||||||||||||
| 2333 | - | |||||||||||||||||||||||||||||||
| 2334 | */ | - | ||||||||||||||||||||||||||||||
| 2335 | - | |||||||||||||||||||||||||||||||
| 2336 | /*! \fn QStringRef QXmlStreamAttribute::value() const | - | ||||||||||||||||||||||||||||||
| 2337 | Returns the attribute's value. | - | ||||||||||||||||||||||||||||||
| 2338 | */ | - | ||||||||||||||||||||||||||||||
| 2339 | - | |||||||||||||||||||||||||||||||
| 2340 | /*! \fn bool QXmlStreamAttribute::isDefault() const | - | ||||||||||||||||||||||||||||||
| 2341 | - | |||||||||||||||||||||||||||||||
| 2342 | Returns \c true if the parser added this attribute with a default | - | ||||||||||||||||||||||||||||||
| 2343 | value following an ATTLIST declaration in the DTD; otherwise | - | ||||||||||||||||||||||||||||||
| 2344 | returns \c false. | - | ||||||||||||||||||||||||||||||
| 2345 | */ | - | ||||||||||||||||||||||||||||||
| 2346 | /*! \fn bool QXmlStreamAttribute::operator==(const QXmlStreamAttribute &other) const | - | ||||||||||||||||||||||||||||||
| 2347 | - | |||||||||||||||||||||||||||||||
| 2348 | Compares this attribute with \a other and returns \c true if they are | - | ||||||||||||||||||||||||||||||
| 2349 | equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2350 | */ | - | ||||||||||||||||||||||||||||||
| 2351 | /*! \fn bool QXmlStreamAttribute::operator!=(const QXmlStreamAttribute &other) const | - | ||||||||||||||||||||||||||||||
| 2352 | - | |||||||||||||||||||||||||||||||
| 2353 | Compares this attribute with \a other and returns \c true if they are | - | ||||||||||||||||||||||||||||||
| 2354 | not equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2355 | */ | - | ||||||||||||||||||||||||||||||
| 2356 | - | |||||||||||||||||||||||||||||||
| 2357 | - | |||||||||||||||||||||||||||||||
| 2358 | /*! | - | ||||||||||||||||||||||||||||||
| 2359 | Creates a copy of \a other. | - | ||||||||||||||||||||||||||||||
| 2360 | */ | - | ||||||||||||||||||||||||||||||
| 2361 | QXmlStreamAttribute::QXmlStreamAttribute(const QXmlStreamAttribute &other) | - | ||||||||||||||||||||||||||||||
| 2362 | { | - | ||||||||||||||||||||||||||||||
| 2363 | *this = other; | - | ||||||||||||||||||||||||||||||
| 2364 | } executed 2543 times by 1 test: end of blockExecuted by:
| 2543 | ||||||||||||||||||||||||||||||
| 2365 | - | |||||||||||||||||||||||||||||||
| 2366 | /*! | - | ||||||||||||||||||||||||||||||
| 2367 | Assigns \a other to this attribute. | - | ||||||||||||||||||||||||||||||
| 2368 | */ | - | ||||||||||||||||||||||||||||||
| 2369 | QXmlStreamAttribute& QXmlStreamAttribute::operator=(const QXmlStreamAttribute &other) | - | ||||||||||||||||||||||||||||||
| 2370 | { | - | ||||||||||||||||||||||||||||||
| 2371 | m_name = other.m_name; | - | ||||||||||||||||||||||||||||||
| 2372 | m_namespaceUri = other.m_namespaceUri; | - | ||||||||||||||||||||||||||||||
| 2373 | m_qualifiedName = other.m_qualifiedName; | - | ||||||||||||||||||||||||||||||
| 2374 | m_value = other.m_value; | - | ||||||||||||||||||||||||||||||
| 2375 | m_isDefault = other.m_isDefault; | - | ||||||||||||||||||||||||||||||
| 2376 | return *this; executed 2552 times by 1 test: return *this;Executed by:
| 2552 | ||||||||||||||||||||||||||||||
| 2377 | } | - | ||||||||||||||||||||||||||||||
| 2378 | - | |||||||||||||||||||||||||||||||
| 2379 | - | |||||||||||||||||||||||||||||||
| 2380 | /*! | - | ||||||||||||||||||||||||||||||
| 2381 | \class QXmlStreamAttributes | - | ||||||||||||||||||||||||||||||
| 2382 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2383 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2384 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2385 | \brief The QXmlStreamAttributes class represents a vector of QXmlStreamAttribute. | - | ||||||||||||||||||||||||||||||
| 2386 | - | |||||||||||||||||||||||||||||||
| 2387 | Attributes are returned by a QXmlStreamReader in | - | ||||||||||||||||||||||||||||||
| 2388 | \l{QXmlStreamReader::attributes()} {attributes()} when the reader | - | ||||||||||||||||||||||||||||||
| 2389 | reports a \l {QXmlStreamReader::StartElement}{start element}. The | - | ||||||||||||||||||||||||||||||
| 2390 | class can also be used with a QXmlStreamWriter as an argument to | - | ||||||||||||||||||||||||||||||
| 2391 | \l {QXmlStreamWriter::writeAttributes()}{writeAttributes()}. | - | ||||||||||||||||||||||||||||||
| 2392 | - | |||||||||||||||||||||||||||||||
| 2393 | The convenience function value() loops over the vector and returns | - | ||||||||||||||||||||||||||||||
| 2394 | an attribute value for a given namespaceUri and an attribute's | - | ||||||||||||||||||||||||||||||
| 2395 | name. | - | ||||||||||||||||||||||||||||||
| 2396 | - | |||||||||||||||||||||||||||||||
| 2397 | New attributes can be added with append(). | - | ||||||||||||||||||||||||||||||
| 2398 | - | |||||||||||||||||||||||||||||||
| 2399 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2400 | */ | - | ||||||||||||||||||||||||||||||
| 2401 | - | |||||||||||||||||||||||||||||||
| 2402 | /*! | - | ||||||||||||||||||||||||||||||
| 2403 | \fn QXmlStreamAttributes::QXmlStreamAttributes() | - | ||||||||||||||||||||||||||||||
| 2404 | - | |||||||||||||||||||||||||||||||
| 2405 | A constructor for QXmlStreamAttributes. | - | ||||||||||||||||||||||||||||||
| 2406 | */ | - | ||||||||||||||||||||||||||||||
| 2407 | - | |||||||||||||||||||||||||||||||
| 2408 | /*! | - | ||||||||||||||||||||||||||||||
| 2409 | \typedef QXmlStreamNotationDeclarations | - | ||||||||||||||||||||||||||||||
| 2410 | \relates QXmlStreamNotationDeclaration | - | ||||||||||||||||||||||||||||||
| 2411 | - | |||||||||||||||||||||||||||||||
| 2412 | Synonym for QVector<QXmlStreamNotationDeclaration>. | - | ||||||||||||||||||||||||||||||
| 2413 | */ | - | ||||||||||||||||||||||||||||||
| 2414 | - | |||||||||||||||||||||||||||||||
| 2415 | - | |||||||||||||||||||||||||||||||
| 2416 | /*! | - | ||||||||||||||||||||||||||||||
| 2417 | \class QXmlStreamNotationDeclaration | - | ||||||||||||||||||||||||||||||
| 2418 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2419 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2420 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2421 | \brief The QXmlStreamNotationDeclaration class represents a DTD notation declaration. | - | ||||||||||||||||||||||||||||||
| 2422 | - | |||||||||||||||||||||||||||||||
| 2423 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2424 | - | |||||||||||||||||||||||||||||||
| 2425 | An notation declaration consists of a name(), a systemId(), and a publicId(). | - | ||||||||||||||||||||||||||||||
| 2426 | */ | - | ||||||||||||||||||||||||||||||
| 2427 | - | |||||||||||||||||||||||||||||||
| 2428 | /*! | - | ||||||||||||||||||||||||||||||
| 2429 | Creates an empty notation declaration. | - | ||||||||||||||||||||||||||||||
| 2430 | */ | - | ||||||||||||||||||||||||||||||
| 2431 | QXmlStreamNotationDeclaration::QXmlStreamNotationDeclaration() | - | ||||||||||||||||||||||||||||||
| 2432 | { | - | ||||||||||||||||||||||||||||||
| 2433 | } | - | ||||||||||||||||||||||||||||||
| 2434 | /*! | - | ||||||||||||||||||||||||||||||
| 2435 | Creates a copy of \a other. | - | ||||||||||||||||||||||||||||||
| 2436 | */ | - | ||||||||||||||||||||||||||||||
| 2437 | QXmlStreamNotationDeclaration::QXmlStreamNotationDeclaration(const QXmlStreamNotationDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2438 | { | - | ||||||||||||||||||||||||||||||
| 2439 | *this = other; | - | ||||||||||||||||||||||||||||||
| 2440 | } executed 304 times by 1 test: end of blockExecuted by:
| 304 | ||||||||||||||||||||||||||||||
| 2441 | - | |||||||||||||||||||||||||||||||
| 2442 | /*! | - | ||||||||||||||||||||||||||||||
| 2443 | Assigns \a other to this notation declaration. | - | ||||||||||||||||||||||||||||||
| 2444 | */ | - | ||||||||||||||||||||||||||||||
| 2445 | QXmlStreamNotationDeclaration& QXmlStreamNotationDeclaration::operator=(const QXmlStreamNotationDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2446 | { | - | ||||||||||||||||||||||||||||||
| 2447 | m_name = other.m_name; | - | ||||||||||||||||||||||||||||||
| 2448 | m_systemId = other.m_systemId; | - | ||||||||||||||||||||||||||||||
| 2449 | m_publicId = other.m_publicId; | - | ||||||||||||||||||||||||||||||
| 2450 | return *this; executed 304 times by 1 test: return *this;Executed by:
| 304 | ||||||||||||||||||||||||||||||
| 2451 | } | - | ||||||||||||||||||||||||||||||
| 2452 | - | |||||||||||||||||||||||||||||||
| 2453 | /*! | - | ||||||||||||||||||||||||||||||
| 2454 | Destructs this notation declaration. | - | ||||||||||||||||||||||||||||||
| 2455 | */ | - | ||||||||||||||||||||||||||||||
| 2456 | QXmlStreamNotationDeclaration::~QXmlStreamNotationDeclaration() | - | ||||||||||||||||||||||||||||||
| 2457 | { | - | ||||||||||||||||||||||||||||||
| 2458 | } | - | ||||||||||||||||||||||||||||||
| 2459 | - | |||||||||||||||||||||||||||||||
| 2460 | /*! \fn QStringRef QXmlStreamNotationDeclaration::name() const | - | ||||||||||||||||||||||||||||||
| 2461 | - | |||||||||||||||||||||||||||||||
| 2462 | Returns the notation name. | - | ||||||||||||||||||||||||||||||
| 2463 | */ | - | ||||||||||||||||||||||||||||||
| 2464 | /*! \fn QStringRef QXmlStreamNotationDeclaration::systemId() const | - | ||||||||||||||||||||||||||||||
| 2465 | - | |||||||||||||||||||||||||||||||
| 2466 | Returns the system identifier. | - | ||||||||||||||||||||||||||||||
| 2467 | */ | - | ||||||||||||||||||||||||||||||
| 2468 | /*! \fn QStringRef QXmlStreamNotationDeclaration::publicId() const | - | ||||||||||||||||||||||||||||||
| 2469 | - | |||||||||||||||||||||||||||||||
| 2470 | Returns the public identifier. | - | ||||||||||||||||||||||||||||||
| 2471 | */ | - | ||||||||||||||||||||||||||||||
| 2472 | - | |||||||||||||||||||||||||||||||
| 2473 | /*! \fn inline bool QXmlStreamNotationDeclaration::operator==(const QXmlStreamNotationDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2474 | - | |||||||||||||||||||||||||||||||
| 2475 | Compares this notation declaration with \a other and returns \c true | - | ||||||||||||||||||||||||||||||
| 2476 | if they are equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2477 | */ | - | ||||||||||||||||||||||||||||||
| 2478 | /*! \fn inline bool QXmlStreamNotationDeclaration::operator!=(const QXmlStreamNotationDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2479 | - | |||||||||||||||||||||||||||||||
| 2480 | Compares this notation declaration with \a other and returns \c true | - | ||||||||||||||||||||||||||||||
| 2481 | if they are not equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2482 | */ | - | ||||||||||||||||||||||||||||||
| 2483 | - | |||||||||||||||||||||||||||||||
| 2484 | /*! | - | ||||||||||||||||||||||||||||||
| 2485 | \typedef QXmlStreamNamespaceDeclarations | - | ||||||||||||||||||||||||||||||
| 2486 | \relates QXmlStreamNamespaceDeclaration | - | ||||||||||||||||||||||||||||||
| 2487 | - | |||||||||||||||||||||||||||||||
| 2488 | Synonym for QVector<QXmlStreamNamespaceDeclaration>. | - | ||||||||||||||||||||||||||||||
| 2489 | */ | - | ||||||||||||||||||||||||||||||
| 2490 | - | |||||||||||||||||||||||||||||||
| 2491 | /*! | - | ||||||||||||||||||||||||||||||
| 2492 | \class QXmlStreamNamespaceDeclaration | - | ||||||||||||||||||||||||||||||
| 2493 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2494 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2495 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2496 | \brief The QXmlStreamNamespaceDeclaration class represents a namespace declaration. | - | ||||||||||||||||||||||||||||||
| 2497 | - | |||||||||||||||||||||||||||||||
| 2498 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2499 | - | |||||||||||||||||||||||||||||||
| 2500 | An namespace declaration consists of a prefix() and a namespaceUri(). | - | ||||||||||||||||||||||||||||||
| 2501 | */ | - | ||||||||||||||||||||||||||||||
| 2502 | /*! \fn inline bool QXmlStreamNamespaceDeclaration::operator==(const QXmlStreamNamespaceDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2503 | - | |||||||||||||||||||||||||||||||
| 2504 | Compares this namespace declaration with \a other and returns \c true | - | ||||||||||||||||||||||||||||||
| 2505 | if they are equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2506 | */ | - | ||||||||||||||||||||||||||||||
| 2507 | /*! \fn inline bool QXmlStreamNamespaceDeclaration::operator!=(const QXmlStreamNamespaceDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2508 | - | |||||||||||||||||||||||||||||||
| 2509 | Compares this namespace declaration with \a other and returns \c true | - | ||||||||||||||||||||||||||||||
| 2510 | if they are not equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2511 | */ | - | ||||||||||||||||||||||||||||||
| 2512 | - | |||||||||||||||||||||||||||||||
| 2513 | /*! | - | ||||||||||||||||||||||||||||||
| 2514 | Creates an empty namespace declaration. | - | ||||||||||||||||||||||||||||||
| 2515 | */ | - | ||||||||||||||||||||||||||||||
| 2516 | QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration() | - | ||||||||||||||||||||||||||||||
| 2517 | { | - | ||||||||||||||||||||||||||||||
| 2518 | } | - | ||||||||||||||||||||||||||||||
| 2519 | - | |||||||||||||||||||||||||||||||
| 2520 | /*! | - | ||||||||||||||||||||||||||||||
| 2521 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2522 | - | |||||||||||||||||||||||||||||||
| 2523 | Creates a namespace declaration with \a prefix and \a namespaceUri. | - | ||||||||||||||||||||||||||||||
| 2524 | */ | - | ||||||||||||||||||||||||||||||
| 2525 | QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration(const QString &prefix, const QString &namespaceUri) | - | ||||||||||||||||||||||||||||||
| 2526 | { | - | ||||||||||||||||||||||||||||||
| 2527 | m_prefix = prefix; | - | ||||||||||||||||||||||||||||||
| 2528 | m_namespaceUri = namespaceUri; | - | ||||||||||||||||||||||||||||||
| 2529 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 2530 | - | |||||||||||||||||||||||||||||||
| 2531 | /*! | - | ||||||||||||||||||||||||||||||
| 2532 | Creates a copy of \a other. | - | ||||||||||||||||||||||||||||||
| 2533 | */ | - | ||||||||||||||||||||||||||||||
| 2534 | QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2535 | { | - | ||||||||||||||||||||||||||||||
| 2536 | *this = other; | - | ||||||||||||||||||||||||||||||
| 2537 | } executed 54 times by 1 test: end of blockExecuted by:
| 54 | ||||||||||||||||||||||||||||||
| 2538 | - | |||||||||||||||||||||||||||||||
| 2539 | /*! | - | ||||||||||||||||||||||||||||||
| 2540 | Assigns \a other to this namespace declaration. | - | ||||||||||||||||||||||||||||||
| 2541 | */ | - | ||||||||||||||||||||||||||||||
| 2542 | QXmlStreamNamespaceDeclaration& QXmlStreamNamespaceDeclaration::operator=(const QXmlStreamNamespaceDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2543 | { | - | ||||||||||||||||||||||||||||||
| 2544 | m_prefix = other.m_prefix; | - | ||||||||||||||||||||||||||||||
| 2545 | m_namespaceUri = other.m_namespaceUri; | - | ||||||||||||||||||||||||||||||
| 2546 | return *this; executed 54 times by 1 test: return *this;Executed by:
| 54 | ||||||||||||||||||||||||||||||
| 2547 | } | - | ||||||||||||||||||||||||||||||
| 2548 | /*! | - | ||||||||||||||||||||||||||||||
| 2549 | Destructs this namespace declaration. | - | ||||||||||||||||||||||||||||||
| 2550 | */ | - | ||||||||||||||||||||||||||||||
| 2551 | QXmlStreamNamespaceDeclaration::~QXmlStreamNamespaceDeclaration() | - | ||||||||||||||||||||||||||||||
| 2552 | { | - | ||||||||||||||||||||||||||||||
| 2553 | } | - | ||||||||||||||||||||||||||||||
| 2554 | - | |||||||||||||||||||||||||||||||
| 2555 | /*! \fn QStringRef QXmlStreamNamespaceDeclaration::prefix() const | - | ||||||||||||||||||||||||||||||
| 2556 | - | |||||||||||||||||||||||||||||||
| 2557 | Returns the prefix. | - | ||||||||||||||||||||||||||||||
| 2558 | */ | - | ||||||||||||||||||||||||||||||
| 2559 | /*! \fn QStringRef QXmlStreamNamespaceDeclaration::namespaceUri() const | - | ||||||||||||||||||||||||||||||
| 2560 | - | |||||||||||||||||||||||||||||||
| 2561 | Returns the namespaceUri. | - | ||||||||||||||||||||||||||||||
| 2562 | */ | - | ||||||||||||||||||||||||||||||
| 2563 | - | |||||||||||||||||||||||||||||||
| 2564 | - | |||||||||||||||||||||||||||||||
| 2565 | - | |||||||||||||||||||||||||||||||
| 2566 | - | |||||||||||||||||||||||||||||||
| 2567 | /*! | - | ||||||||||||||||||||||||||||||
| 2568 | \typedef QXmlStreamEntityDeclarations | - | ||||||||||||||||||||||||||||||
| 2569 | \relates QXmlStreamEntityDeclaration | - | ||||||||||||||||||||||||||||||
| 2570 | - | |||||||||||||||||||||||||||||||
| 2571 | Synonym for QVector<QXmlStreamEntityDeclaration>. | - | ||||||||||||||||||||||||||||||
| 2572 | */ | - | ||||||||||||||||||||||||||||||
| 2573 | - | |||||||||||||||||||||||||||||||
| 2574 | /*! | - | ||||||||||||||||||||||||||||||
| 2575 | \class QXmlStreamStringRef | - | ||||||||||||||||||||||||||||||
| 2576 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2577 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2578 | \internal | - | ||||||||||||||||||||||||||||||
| 2579 | */ | - | ||||||||||||||||||||||||||||||
| 2580 | - | |||||||||||||||||||||||||||||||
| 2581 | /*! | - | ||||||||||||||||||||||||||||||
| 2582 | \class QXmlStreamEntityDeclaration | - | ||||||||||||||||||||||||||||||
| 2583 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2584 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2585 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2586 | \brief The QXmlStreamEntityDeclaration class represents a DTD entity declaration. | - | ||||||||||||||||||||||||||||||
| 2587 | - | |||||||||||||||||||||||||||||||
| 2588 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2589 | - | |||||||||||||||||||||||||||||||
| 2590 | An entity declaration consists of a name(), a notationName(), a | - | ||||||||||||||||||||||||||||||
| 2591 | systemId(), a publicId(), and a value(). | - | ||||||||||||||||||||||||||||||
| 2592 | */ | - | ||||||||||||||||||||||||||||||
| 2593 | - | |||||||||||||||||||||||||||||||
| 2594 | /*! | - | ||||||||||||||||||||||||||||||
| 2595 | Creates an empty entity declaration. | - | ||||||||||||||||||||||||||||||
| 2596 | */ | - | ||||||||||||||||||||||||||||||
| 2597 | QXmlStreamEntityDeclaration::QXmlStreamEntityDeclaration() | - | ||||||||||||||||||||||||||||||
| 2598 | { | - | ||||||||||||||||||||||||||||||
| 2599 | } | - | ||||||||||||||||||||||||||||||
| 2600 | - | |||||||||||||||||||||||||||||||
| 2601 | /*! | - | ||||||||||||||||||||||||||||||
| 2602 | Creates a copy of \a other. | - | ||||||||||||||||||||||||||||||
| 2603 | */ | - | ||||||||||||||||||||||||||||||
| 2604 | QXmlStreamEntityDeclaration::QXmlStreamEntityDeclaration(const QXmlStreamEntityDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2605 | { | - | ||||||||||||||||||||||||||||||
| 2606 | *this = other; | - | ||||||||||||||||||||||||||||||
| 2607 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 2608 | - | |||||||||||||||||||||||||||||||
| 2609 | /*! | - | ||||||||||||||||||||||||||||||
| 2610 | Assigns \a other to this entity declaration. | - | ||||||||||||||||||||||||||||||
| 2611 | */ | - | ||||||||||||||||||||||||||||||
| 2612 | QXmlStreamEntityDeclaration& QXmlStreamEntityDeclaration::operator=(const QXmlStreamEntityDeclaration &other) | - | ||||||||||||||||||||||||||||||
| 2613 | { | - | ||||||||||||||||||||||||||||||
| 2614 | m_name = other.m_name; | - | ||||||||||||||||||||||||||||||
| 2615 | m_notationName = other.m_notationName; | - | ||||||||||||||||||||||||||||||
| 2616 | m_systemId = other.m_systemId; | - | ||||||||||||||||||||||||||||||
| 2617 | m_publicId = other.m_publicId; | - | ||||||||||||||||||||||||||||||
| 2618 | m_value = other.m_value; | - | ||||||||||||||||||||||||||||||
| 2619 | return *this; executed 10 times by 1 test: return *this;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 2620 | } | - | ||||||||||||||||||||||||||||||
| 2621 | - | |||||||||||||||||||||||||||||||
| 2622 | /*! | - | ||||||||||||||||||||||||||||||
| 2623 | Destructs this entity declaration. | - | ||||||||||||||||||||||||||||||
| 2624 | */ | - | ||||||||||||||||||||||||||||||
| 2625 | QXmlStreamEntityDeclaration::~QXmlStreamEntityDeclaration() | - | ||||||||||||||||||||||||||||||
| 2626 | { | - | ||||||||||||||||||||||||||||||
| 2627 | } | - | ||||||||||||||||||||||||||||||
| 2628 | - | |||||||||||||||||||||||||||||||
| 2629 | /*! \fn QXmlStreamStringRef::swap(QXmlStreamStringRef &other) | - | ||||||||||||||||||||||||||||||
| 2630 | \since 5.6 | - | ||||||||||||||||||||||||||||||
| 2631 | - | |||||||||||||||||||||||||||||||
| 2632 | Swaps this string reference's contents with \a other. | - | ||||||||||||||||||||||||||||||
| 2633 | This function is very fast and never fails. | - | ||||||||||||||||||||||||||||||
| 2634 | */ | - | ||||||||||||||||||||||||||||||
| 2635 | - | |||||||||||||||||||||||||||||||
| 2636 | /*! \fn QStringRef QXmlStreamEntityDeclaration::name() const | - | ||||||||||||||||||||||||||||||
| 2637 | - | |||||||||||||||||||||||||||||||
| 2638 | Returns the entity name. | - | ||||||||||||||||||||||||||||||
| 2639 | */ | - | ||||||||||||||||||||||||||||||
| 2640 | /*! \fn QStringRef QXmlStreamEntityDeclaration::notationName() const | - | ||||||||||||||||||||||||||||||
| 2641 | - | |||||||||||||||||||||||||||||||
| 2642 | Returns the notation name. | - | ||||||||||||||||||||||||||||||
| 2643 | */ | - | ||||||||||||||||||||||||||||||
| 2644 | /*! \fn QStringRef QXmlStreamEntityDeclaration::systemId() const | - | ||||||||||||||||||||||||||||||
| 2645 | - | |||||||||||||||||||||||||||||||
| 2646 | Returns the system identifier. | - | ||||||||||||||||||||||||||||||
| 2647 | */ | - | ||||||||||||||||||||||||||||||
| 2648 | /*! \fn QStringRef QXmlStreamEntityDeclaration::publicId() const | - | ||||||||||||||||||||||||||||||
| 2649 | - | |||||||||||||||||||||||||||||||
| 2650 | Returns the public identifier. | - | ||||||||||||||||||||||||||||||
| 2651 | */ | - | ||||||||||||||||||||||||||||||
| 2652 | /*! \fn QStringRef QXmlStreamEntityDeclaration::value() const | - | ||||||||||||||||||||||||||||||
| 2653 | - | |||||||||||||||||||||||||||||||
| 2654 | Returns the entity's value. | - | ||||||||||||||||||||||||||||||
| 2655 | */ | - | ||||||||||||||||||||||||||||||
| 2656 | - | |||||||||||||||||||||||||||||||
| 2657 | /*! \fn bool QXmlStreamEntityDeclaration::operator==(const QXmlStreamEntityDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2658 | - | |||||||||||||||||||||||||||||||
| 2659 | Compares this entity declaration with \a other and returns \c true if | - | ||||||||||||||||||||||||||||||
| 2660 | they are equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2661 | */ | - | ||||||||||||||||||||||||||||||
| 2662 | /*! \fn bool QXmlStreamEntityDeclaration::operator!=(const QXmlStreamEntityDeclaration &other) const | - | ||||||||||||||||||||||||||||||
| 2663 | - | |||||||||||||||||||||||||||||||
| 2664 | Compares this entity declaration with \a other and returns \c true if | - | ||||||||||||||||||||||||||||||
| 2665 | they are not equal; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2666 | */ | - | ||||||||||||||||||||||||||||||
| 2667 | - | |||||||||||||||||||||||||||||||
| 2668 | /*! Returns the value of the attribute \a name in the namespace | - | ||||||||||||||||||||||||||||||
| 2669 | described with \a namespaceUri, or an empty string reference if the | - | ||||||||||||||||||||||||||||||
| 2670 | attribute is not defined. The \a namespaceUri can be empty. | - | ||||||||||||||||||||||||||||||
| 2671 | */ | - | ||||||||||||||||||||||||||||||
| 2672 | QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, const QString &name) const | - | ||||||||||||||||||||||||||||||
| 2673 | { | - | ||||||||||||||||||||||||||||||
| 2674 | for (int i = 0; i < size(); ++i) {
| 6-28 | ||||||||||||||||||||||||||||||
| 2675 | const QXmlStreamAttribute &attribute = at(i); | - | ||||||||||||||||||||||||||||||
| 2676 | if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
| 2-21 | ||||||||||||||||||||||||||||||
| 2677 | return attribute.value(); executed 5 times by 1 test: return attribute.value();Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 2678 | } executed 23 times by 1 test: end of blockExecuted by:
| 23 | ||||||||||||||||||||||||||||||
| 2679 | return QStringRef(); executed 6 times by 1 test: return QStringRef();Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 2680 | } | - | ||||||||||||||||||||||||||||||
| 2681 | - | |||||||||||||||||||||||||||||||
| 2682 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 2683 | Returns the value of the attribute \a name in the namespace | - | ||||||||||||||||||||||||||||||
| 2684 | described with \a namespaceUri, or an empty string reference if the | - | ||||||||||||||||||||||||||||||
| 2685 | attribute is not defined. The \a namespaceUri can be empty. | - | ||||||||||||||||||||||||||||||
| 2686 | */ | - | ||||||||||||||||||||||||||||||
| 2687 | QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1String name) const | - | ||||||||||||||||||||||||||||||
| 2688 | { | - | ||||||||||||||||||||||||||||||
| 2689 | for (int i = 0; i < size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 2690 | const QXmlStreamAttribute &attribute = at(i); | - | ||||||||||||||||||||||||||||||
| 2691 | if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
| 0 | ||||||||||||||||||||||||||||||
| 2692 | return attribute.value(); never executed: return attribute.value(); | 0 | ||||||||||||||||||||||||||||||
| 2693 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2694 | return QStringRef(); never executed: return QStringRef(); | 0 | ||||||||||||||||||||||||||||||
| 2695 | } | - | ||||||||||||||||||||||||||||||
| 2696 | - | |||||||||||||||||||||||||||||||
| 2697 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 2698 | Returns the value of the attribute \a name in the namespace | - | ||||||||||||||||||||||||||||||
| 2699 | described with \a namespaceUri, or an empty string reference if the | - | ||||||||||||||||||||||||||||||
| 2700 | attribute is not defined. The \a namespaceUri can be empty. | - | ||||||||||||||||||||||||||||||
| 2701 | */ | - | ||||||||||||||||||||||||||||||
| 2702 | QStringRef QXmlStreamAttributes::value(QLatin1String namespaceUri, QLatin1String name) const | - | ||||||||||||||||||||||||||||||
| 2703 | { | - | ||||||||||||||||||||||||||||||
| 2704 | for (int i = 0; i < size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 2705 | const QXmlStreamAttribute &attribute = at(i); | - | ||||||||||||||||||||||||||||||
| 2706 | if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
| 0 | ||||||||||||||||||||||||||||||
| 2707 | return attribute.value(); never executed: return attribute.value(); | 0 | ||||||||||||||||||||||||||||||
| 2708 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2709 | return QStringRef(); never executed: return QStringRef(); | 0 | ||||||||||||||||||||||||||||||
| 2710 | } | - | ||||||||||||||||||||||||||||||
| 2711 | - | |||||||||||||||||||||||||||||||
| 2712 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 2713 | - | |||||||||||||||||||||||||||||||
| 2714 | Returns the value of the attribute with qualified name \a | - | ||||||||||||||||||||||||||||||
| 2715 | qualifiedName , or an empty string reference if the attribute is not | - | ||||||||||||||||||||||||||||||
| 2716 | defined. A qualified name is the raw name of an attribute in the XML | - | ||||||||||||||||||||||||||||||
| 2717 | data. It consists of the namespace prefix, followed by colon, | - | ||||||||||||||||||||||||||||||
| 2718 | followed by the attribute's local name. Since the namespace prefix | - | ||||||||||||||||||||||||||||||
| 2719 | is not unique (the same prefix can point to different namespaces and | - | ||||||||||||||||||||||||||||||
| 2720 | different prefixes can point to the same namespace), you shouldn't | - | ||||||||||||||||||||||||||||||
| 2721 | use qualified names, but a resolved namespaceUri and the attribute's | - | ||||||||||||||||||||||||||||||
| 2722 | local name. | - | ||||||||||||||||||||||||||||||
| 2723 | */ | - | ||||||||||||||||||||||||||||||
| 2724 | QStringRef QXmlStreamAttributes::value(const QString &qualifiedName) const | - | ||||||||||||||||||||||||||||||
| 2725 | { | - | ||||||||||||||||||||||||||||||
| 2726 | for (int i = 0; i < size(); ++i) {
| 3-19 | ||||||||||||||||||||||||||||||
| 2727 | const QXmlStreamAttribute &attribute = at(i); | - | ||||||||||||||||||||||||||||||
| 2728 | if (attribute.qualifiedName() == qualifiedName)
| 5-14 | ||||||||||||||||||||||||||||||
| 2729 | return attribute.value(); executed 5 times by 1 test: return attribute.value();Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 2730 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 2731 | return QStringRef(); executed 3 times by 1 test: return QStringRef();Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 2732 | } | - | ||||||||||||||||||||||||||||||
| 2733 | - | |||||||||||||||||||||||||||||||
| 2734 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 2735 | - | |||||||||||||||||||||||||||||||
| 2736 | Returns the value of the attribute with qualified name \a | - | ||||||||||||||||||||||||||||||
| 2737 | qualifiedName , or an empty string reference if the attribute is not | - | ||||||||||||||||||||||||||||||
| 2738 | defined. A qualified name is the raw name of an attribute in the XML | - | ||||||||||||||||||||||||||||||
| 2739 | data. It consists of the namespace prefix, followed by colon, | - | ||||||||||||||||||||||||||||||
| 2740 | followed by the attribute's local name. Since the namespace prefix | - | ||||||||||||||||||||||||||||||
| 2741 | is not unique (the same prefix can point to different namespaces and | - | ||||||||||||||||||||||||||||||
| 2742 | different prefixes can point to the same namespace), you shouldn't | - | ||||||||||||||||||||||||||||||
| 2743 | use qualified names, but a resolved namespaceUri and the attribute's | - | ||||||||||||||||||||||||||||||
| 2744 | local name. | - | ||||||||||||||||||||||||||||||
| 2745 | */ | - | ||||||||||||||||||||||||||||||
| 2746 | QStringRef QXmlStreamAttributes::value(QLatin1String qualifiedName) const | - | ||||||||||||||||||||||||||||||
| 2747 | { | - | ||||||||||||||||||||||||||||||
| 2748 | for (int i = 0; i < size(); ++i) {
| 16832-224211 | ||||||||||||||||||||||||||||||
| 2749 | const QXmlStreamAttribute &attribute = at(i); | - | ||||||||||||||||||||||||||||||
| 2750 | if (attribute.qualifiedName() == qualifiedName)
| 51027-173184 | ||||||||||||||||||||||||||||||
| 2751 | return attribute.value(); executed 173184 times by 14 tests: return attribute.value();Executed by:
| 173184 | ||||||||||||||||||||||||||||||
| 2752 | } executed 51027 times by 14 tests: end of blockExecuted by:
| 51027 | ||||||||||||||||||||||||||||||
| 2753 | return QStringRef(); executed 16832 times by 14 tests: return QStringRef();Executed by:
| 16832 | ||||||||||||||||||||||||||||||
| 2754 | } | - | ||||||||||||||||||||||||||||||
| 2755 | - | |||||||||||||||||||||||||||||||
| 2756 | /*!Appends a new attribute with \a name in the namespace | - | ||||||||||||||||||||||||||||||
| 2757 | described with \a namespaceUri, and value \a value. The \a | - | ||||||||||||||||||||||||||||||
| 2758 | namespaceUri can be empty. | - | ||||||||||||||||||||||||||||||
| 2759 | */ | - | ||||||||||||||||||||||||||||||
| 2760 | void QXmlStreamAttributes::append(const QString &namespaceUri, const QString &name, const QString &value) | - | ||||||||||||||||||||||||||||||
| 2761 | { | - | ||||||||||||||||||||||||||||||
| 2762 | append(QXmlStreamAttribute(namespaceUri, name, value)); | - | ||||||||||||||||||||||||||||||
| 2763 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2764 | - | |||||||||||||||||||||||||||||||
| 2765 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 2766 | Appends a new attribute with qualified name \a qualifiedName and | - | ||||||||||||||||||||||||||||||
| 2767 | value \a value. | - | ||||||||||||||||||||||||||||||
| 2768 | */ | - | ||||||||||||||||||||||||||||||
| 2769 | void QXmlStreamAttributes::append(const QString &qualifiedName, const QString &value) | - | ||||||||||||||||||||||||||||||
| 2770 | { | - | ||||||||||||||||||||||||||||||
| 2771 | append(QXmlStreamAttribute(qualifiedName, value)); | - | ||||||||||||||||||||||||||||||
| 2772 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2773 | - | |||||||||||||||||||||||||||||||
| 2774 | #ifndef QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 2775 | - | |||||||||||||||||||||||||||||||
| 2776 | /*! \fn bool QXmlStreamReader::isStartDocument() const | - | ||||||||||||||||||||||||||||||
| 2777 | Returns \c true if tokenType() equals \l StartDocument; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2778 | */ | - | ||||||||||||||||||||||||||||||
| 2779 | /*! \fn bool QXmlStreamReader::isEndDocument() const | - | ||||||||||||||||||||||||||||||
| 2780 | Returns \c true if tokenType() equals \l EndDocument; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2781 | */ | - | ||||||||||||||||||||||||||||||
| 2782 | /*! \fn bool QXmlStreamReader::isStartElement() const | - | ||||||||||||||||||||||||||||||
| 2783 | Returns \c true if tokenType() equals \l StartElement; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2784 | */ | - | ||||||||||||||||||||||||||||||
| 2785 | /*! \fn bool QXmlStreamReader::isEndElement() const | - | ||||||||||||||||||||||||||||||
| 2786 | Returns \c true if tokenType() equals \l EndElement; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2787 | */ | - | ||||||||||||||||||||||||||||||
| 2788 | /*! \fn bool QXmlStreamReader::isCharacters() const | - | ||||||||||||||||||||||||||||||
| 2789 | Returns \c true if tokenType() equals \l Characters; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2790 | - | |||||||||||||||||||||||||||||||
| 2791 | \sa isWhitespace(), isCDATA() | - | ||||||||||||||||||||||||||||||
| 2792 | */ | - | ||||||||||||||||||||||||||||||
| 2793 | /*! \fn bool QXmlStreamReader::isComment() const | - | ||||||||||||||||||||||||||||||
| 2794 | Returns \c true if tokenType() equals \l Comment; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2795 | */ | - | ||||||||||||||||||||||||||||||
| 2796 | /*! \fn bool QXmlStreamReader::isDTD() const | - | ||||||||||||||||||||||||||||||
| 2797 | Returns \c true if tokenType() equals \l DTD; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2798 | */ | - | ||||||||||||||||||||||||||||||
| 2799 | /*! \fn bool QXmlStreamReader::isEntityReference() const | - | ||||||||||||||||||||||||||||||
| 2800 | Returns \c true if tokenType() equals \l EntityReference; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2801 | */ | - | ||||||||||||||||||||||||||||||
| 2802 | /*! \fn bool QXmlStreamReader::isProcessingInstruction() const | - | ||||||||||||||||||||||||||||||
| 2803 | Returns \c true if tokenType() equals \l ProcessingInstruction; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2804 | */ | - | ||||||||||||||||||||||||||||||
| 2805 | - | |||||||||||||||||||||||||||||||
| 2806 | /*! Returns \c true if the reader reports characters that only consist | - | ||||||||||||||||||||||||||||||
| 2807 | of white-space; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2808 | - | |||||||||||||||||||||||||||||||
| 2809 | \sa isCharacters(), text() | - | ||||||||||||||||||||||||||||||
| 2810 | */ | - | ||||||||||||||||||||||||||||||
| 2811 | bool QXmlStreamReader::isWhitespace() const | - | ||||||||||||||||||||||||||||||
| 2812 | { | - | ||||||||||||||||||||||||||||||
| 2813 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2814 | return d->type == QXmlStreamReader::Characters && d->isWhitespace; executed 1903 times by 1 test: return d->type == QXmlStreamReader::Characters && d->isWhitespace;Executed by:
| 221-1903 | ||||||||||||||||||||||||||||||
| 2815 | } | - | ||||||||||||||||||||||||||||||
| 2816 | - | |||||||||||||||||||||||||||||||
| 2817 | /*! Returns \c true if the reader reports characters that stem from a | - | ||||||||||||||||||||||||||||||
| 2818 | CDATA section; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2819 | - | |||||||||||||||||||||||||||||||
| 2820 | \sa isCharacters(), text() | - | ||||||||||||||||||||||||||||||
| 2821 | */ | - | ||||||||||||||||||||||||||||||
| 2822 | bool QXmlStreamReader::isCDATA() const | - | ||||||||||||||||||||||||||||||
| 2823 | { | - | ||||||||||||||||||||||||||||||
| 2824 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2825 | return d->type == QXmlStreamReader::Characters && d->isCDATA; executed 1903 times by 1 test: return d->type == QXmlStreamReader::Characters && d->isCDATA;Executed by:
| 10-1903 | ||||||||||||||||||||||||||||||
| 2826 | } | - | ||||||||||||||||||||||||||||||
| 2827 | - | |||||||||||||||||||||||||||||||
| 2828 | - | |||||||||||||||||||||||||||||||
| 2829 | - | |||||||||||||||||||||||||||||||
| 2830 | /*! | - | ||||||||||||||||||||||||||||||
| 2831 | Returns \c true if this document has been declared standalone in the | - | ||||||||||||||||||||||||||||||
| 2832 | XML declaration; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 2833 | - | |||||||||||||||||||||||||||||||
| 2834 | If no XML declaration has been parsed, this function returns \c false. | - | ||||||||||||||||||||||||||||||
| 2835 | */ | - | ||||||||||||||||||||||||||||||
| 2836 | bool QXmlStreamReader::isStandaloneDocument() const | - | ||||||||||||||||||||||||||||||
| 2837 | { | - | ||||||||||||||||||||||||||||||
| 2838 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2839 | return d->standalone; executed 77 times by 1 test: return d->standalone;Executed by:
| 77 | ||||||||||||||||||||||||||||||
| 2840 | } | - | ||||||||||||||||||||||||||||||
| 2841 | - | |||||||||||||||||||||||||||||||
| 2842 | - | |||||||||||||||||||||||||||||||
| 2843 | /*! | - | ||||||||||||||||||||||||||||||
| 2844 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2845 | - | |||||||||||||||||||||||||||||||
| 2846 | If the tokenType() is \l StartDocument, this function returns the | - | ||||||||||||||||||||||||||||||
| 2847 | version string as specified in the XML declaration. | - | ||||||||||||||||||||||||||||||
| 2848 | Otherwise an empty string is returned. | - | ||||||||||||||||||||||||||||||
| 2849 | */ | - | ||||||||||||||||||||||||||||||
| 2850 | QStringRef QXmlStreamReader::documentVersion() const | - | ||||||||||||||||||||||||||||||
| 2851 | { | - | ||||||||||||||||||||||||||||||
| 2852 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2853 | if (d->type == QXmlStreamReader::StartDocument)
| 133-1826 | ||||||||||||||||||||||||||||||
| 2854 | return d->documentVersion; executed 133 times by 1 test: return d->documentVersion;Executed by:
| 133 | ||||||||||||||||||||||||||||||
| 2855 | return QStringRef(); executed 1826 times by 1 test: return QStringRef();Executed by:
| 1826 | ||||||||||||||||||||||||||||||
| 2856 | } | - | ||||||||||||||||||||||||||||||
| 2857 | - | |||||||||||||||||||||||||||||||
| 2858 | /*! | - | ||||||||||||||||||||||||||||||
| 2859 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 2860 | - | |||||||||||||||||||||||||||||||
| 2861 | If the tokenType() is \l StartDocument, this function returns the | - | ||||||||||||||||||||||||||||||
| 2862 | encoding string as specified in the XML declaration. | - | ||||||||||||||||||||||||||||||
| 2863 | Otherwise an empty string is returned. | - | ||||||||||||||||||||||||||||||
| 2864 | */ | - | ||||||||||||||||||||||||||||||
| 2865 | QStringRef QXmlStreamReader::documentEncoding() const | - | ||||||||||||||||||||||||||||||
| 2866 | { | - | ||||||||||||||||||||||||||||||
| 2867 | Q_D(const QXmlStreamReader); | - | ||||||||||||||||||||||||||||||
| 2868 | if (d->type == QXmlStreamReader::StartDocument)
| 83-1826 | ||||||||||||||||||||||||||||||
| 2869 | return d->documentEncoding; executed 83 times by 1 test: return d->documentEncoding;Executed by:
| 83 | ||||||||||||||||||||||||||||||
| 2870 | return QStringRef(); executed 1826 times by 1 test: return QStringRef();Executed by:
| 1826 | ||||||||||||||||||||||||||||||
| 2871 | } | - | ||||||||||||||||||||||||||||||
| 2872 | - | |||||||||||||||||||||||||||||||
| 2873 | #endif // QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 2874 | - | |||||||||||||||||||||||||||||||
| 2875 | /*! | - | ||||||||||||||||||||||||||||||
| 2876 | \class QXmlStreamWriter | - | ||||||||||||||||||||||||||||||
| 2877 | \inmodule QtCore | - | ||||||||||||||||||||||||||||||
| 2878 | \since 4.3 | - | ||||||||||||||||||||||||||||||
| 2879 | \reentrant | - | ||||||||||||||||||||||||||||||
| 2880 | - | |||||||||||||||||||||||||||||||
| 2881 | \brief The QXmlStreamWriter class provides an XML writer with a | - | ||||||||||||||||||||||||||||||
| 2882 | simple streaming API. | - | ||||||||||||||||||||||||||||||
| 2883 | - | |||||||||||||||||||||||||||||||
| 2884 | \ingroup xml-tools | - | ||||||||||||||||||||||||||||||
| 2885 | - | |||||||||||||||||||||||||||||||
| 2886 | QXmlStreamWriter is the counterpart to QXmlStreamReader for writing | - | ||||||||||||||||||||||||||||||
| 2887 | XML. Like its related class, it operates on a QIODevice specified | - | ||||||||||||||||||||||||||||||
| 2888 | with setDevice(). The API is simple and straightforward: for every | - | ||||||||||||||||||||||||||||||
| 2889 | XML token or event you want to write, the writer provides a | - | ||||||||||||||||||||||||||||||
| 2890 | specialized function. | - | ||||||||||||||||||||||||||||||
| 2891 | - | |||||||||||||||||||||||||||||||
| 2892 | You start a document with writeStartDocument() and end it with | - | ||||||||||||||||||||||||||||||
| 2893 | writeEndDocument(). This will implicitly close all remaining open | - | ||||||||||||||||||||||||||||||
| 2894 | tags. | - | ||||||||||||||||||||||||||||||
| 2895 | - | |||||||||||||||||||||||||||||||
| 2896 | Element tags are opened with writeStartElement() followed by | - | ||||||||||||||||||||||||||||||
| 2897 | writeAttribute() or writeAttributes(), element content, and then | - | ||||||||||||||||||||||||||||||
| 2898 | writeEndElement(). A shorter form writeEmptyElement() can be used | - | ||||||||||||||||||||||||||||||
| 2899 | to write empty elements, followed by writeAttributes(). | - | ||||||||||||||||||||||||||||||
| 2900 | - | |||||||||||||||||||||||||||||||
| 2901 | Element content consists of either characters, entity references or | - | ||||||||||||||||||||||||||||||
| 2902 | nested elements. It is written with writeCharacters(), which also | - | ||||||||||||||||||||||||||||||
| 2903 | takes care of escaping all forbidden characters and character | - | ||||||||||||||||||||||||||||||
| 2904 | sequences, writeEntityReference(), or subsequent calls to | - | ||||||||||||||||||||||||||||||
| 2905 | writeStartElement(). A convenience method writeTextElement() can be | - | ||||||||||||||||||||||||||||||
| 2906 | used for writing terminal elements that contain nothing but text. | - | ||||||||||||||||||||||||||||||
| 2907 | - | |||||||||||||||||||||||||||||||
| 2908 | The following abridged code snippet shows the basic use of the class | - | ||||||||||||||||||||||||||||||
| 2909 | to write formatted XML with indentation: | - | ||||||||||||||||||||||||||||||
| 2910 | - | |||||||||||||||||||||||||||||||
| 2911 | \snippet qxmlstreamwriter/main.cpp start stream | - | ||||||||||||||||||||||||||||||
| 2912 | \dots | - | ||||||||||||||||||||||||||||||
| 2913 | \snippet qxmlstreamwriter/main.cpp write element | - | ||||||||||||||||||||||||||||||
| 2914 | \dots | - | ||||||||||||||||||||||||||||||
| 2915 | \snippet qxmlstreamwriter/main.cpp finish stream | - | ||||||||||||||||||||||||||||||
| 2916 | - | |||||||||||||||||||||||||||||||
| 2917 | QXmlStreamWriter takes care of prefixing namespaces, all you have to | - | ||||||||||||||||||||||||||||||
| 2918 | do is specify the \c namespaceUri when writing elements or | - | ||||||||||||||||||||||||||||||
| 2919 | attributes. If you must conform to certain prefixes, you can force | - | ||||||||||||||||||||||||||||||
| 2920 | the writer to use them by declaring the namespaces manually with | - | ||||||||||||||||||||||||||||||
| 2921 | either writeNamespace() or writeDefaultNamespace(). Alternatively, | - | ||||||||||||||||||||||||||||||
| 2922 | you can bypass the stream writer's namespace support and use | - | ||||||||||||||||||||||||||||||
| 2923 | overloaded methods that take a qualified name instead. The namespace | - | ||||||||||||||||||||||||||||||
| 2924 | \e http://www.w3.org/XML/1998/namespace is implicit and mapped to the | - | ||||||||||||||||||||||||||||||
| 2925 | prefix \e xml. | - | ||||||||||||||||||||||||||||||
| 2926 | - | |||||||||||||||||||||||||||||||
| 2927 | The stream writer can automatically format the generated XML data by | - | ||||||||||||||||||||||||||||||
| 2928 | adding line-breaks and indentation to empty sections between | - | ||||||||||||||||||||||||||||||
| 2929 | elements, making the XML data more readable for humans and easier to | - | ||||||||||||||||||||||||||||||
| 2930 | work with for most source code management systems. The feature can | - | ||||||||||||||||||||||||||||||
| 2931 | be turned on with the \l autoFormatting property, and customized | - | ||||||||||||||||||||||||||||||
| 2932 | with the \l autoFormattingIndent property. | - | ||||||||||||||||||||||||||||||
| 2933 | - | |||||||||||||||||||||||||||||||
| 2934 | Other functions are writeCDATA(), writeComment(), | - | ||||||||||||||||||||||||||||||
| 2935 | writeProcessingInstruction(), and writeDTD(). Chaining of XML | - | ||||||||||||||||||||||||||||||
| 2936 | streams is supported with writeCurrentToken(). | - | ||||||||||||||||||||||||||||||
| 2937 | - | |||||||||||||||||||||||||||||||
| 2938 | By default, QXmlStreamWriter encodes XML in UTF-8. Different | - | ||||||||||||||||||||||||||||||
| 2939 | encodings can be enforced using setCodec(). | - | ||||||||||||||||||||||||||||||
| 2940 | - | |||||||||||||||||||||||||||||||
| 2941 | If an error occurs while writing to the underlying device, hasError() | - | ||||||||||||||||||||||||||||||
| 2942 | starts returning true and subsequent writes are ignored. | - | ||||||||||||||||||||||||||||||
| 2943 | - | |||||||||||||||||||||||||||||||
| 2944 | The \l{QXmlStream Bookmarks Example} illustrates how to use a | - | ||||||||||||||||||||||||||||||
| 2945 | stream writer to write an XML bookmark file (XBEL) that | - | ||||||||||||||||||||||||||||||
| 2946 | was previously read in by a QXmlStreamReader. | - | ||||||||||||||||||||||||||||||
| 2947 | - | |||||||||||||||||||||||||||||||
| 2948 | */ | - | ||||||||||||||||||||||||||||||
| 2949 | - | |||||||||||||||||||||||||||||||
| 2950 | #ifndef QT_NO_XMLSTREAMWRITER | - | ||||||||||||||||||||||||||||||
| 2951 | - | |||||||||||||||||||||||||||||||
| 2952 | class QXmlStreamWriterPrivate : public QXmlStreamPrivateTagStack { | - | ||||||||||||||||||||||||||||||
| 2953 | QXmlStreamWriter *q_ptr; | - | ||||||||||||||||||||||||||||||
| 2954 | Q_DECLARE_PUBLIC(QXmlStreamWriter) | - | ||||||||||||||||||||||||||||||
| 2955 | public: | - | ||||||||||||||||||||||||||||||
| 2956 | QXmlStreamWriterPrivate(QXmlStreamWriter *q); | - | ||||||||||||||||||||||||||||||
| 2957 | ~QXmlStreamWriterPrivate() { | - | ||||||||||||||||||||||||||||||
| 2958 | if (deleteDevice)
| 34-710 | ||||||||||||||||||||||||||||||
| 2959 | delete device; executed 710 times by 1 test: delete device;Executed by:
| 710 | ||||||||||||||||||||||||||||||
| 2960 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 2961 | delete encoder; | - | ||||||||||||||||||||||||||||||
| 2962 | #endif | - | ||||||||||||||||||||||||||||||
| 2963 | } executed 744 times by 3 tests: end of blockExecuted by:
| 744 | ||||||||||||||||||||||||||||||
| 2964 | - | |||||||||||||||||||||||||||||||
| 2965 | void write(const QStringRef &); | - | ||||||||||||||||||||||||||||||
| 2966 | void write(const QString &); | - | ||||||||||||||||||||||||||||||
| 2967 | void writeEscaped(const QString &, bool escapeWhitespace = false); | - | ||||||||||||||||||||||||||||||
| 2968 | void write(const char *s, int len); | - | ||||||||||||||||||||||||||||||
| 2969 | template <int N> void write(const char (&s)[N]) { write(s, N - 1); } executed 9934 times by 3 tests: end of blockExecuted by:
| 9934 | ||||||||||||||||||||||||||||||
| 2970 | bool finishStartElement(bool contents = true); | - | ||||||||||||||||||||||||||||||
| 2971 | void writeStartElement(const QString &namespaceUri, const QString &name); | - | ||||||||||||||||||||||||||||||
| 2972 | QIODevice *device; | - | ||||||||||||||||||||||||||||||
| 2973 | QString *stringDevice; | - | ||||||||||||||||||||||||||||||
| 2974 | uint deleteDevice :1; | - | ||||||||||||||||||||||||||||||
| 2975 | uint inStartElement :1; | - | ||||||||||||||||||||||||||||||
| 2976 | uint inEmptyElement :1; | - | ||||||||||||||||||||||||||||||
| 2977 | uint lastWasStartElement :1; | - | ||||||||||||||||||||||||||||||
| 2978 | uint wroteSomething :1; | - | ||||||||||||||||||||||||||||||
| 2979 | uint hasError :1; | - | ||||||||||||||||||||||||||||||
| 2980 | uint autoFormatting :1; | - | ||||||||||||||||||||||||||||||
| 2981 | uint isCodecASCIICompatible :1; | - | ||||||||||||||||||||||||||||||
| 2982 | QByteArray autoFormattingIndent; | - | ||||||||||||||||||||||||||||||
| 2983 | NamespaceDeclaration emptyNamespace; | - | ||||||||||||||||||||||||||||||
| 2984 | int lastNamespaceDeclaration; | - | ||||||||||||||||||||||||||||||
| 2985 | - | |||||||||||||||||||||||||||||||
| 2986 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 2987 | QTextCodec *codec; | - | ||||||||||||||||||||||||||||||
| 2988 | QTextEncoder *encoder; | - | ||||||||||||||||||||||||||||||
| 2989 | #endif | - | ||||||||||||||||||||||||||||||
| 2990 | void checkIfASCIICompatibleCodec(); | - | ||||||||||||||||||||||||||||||
| 2991 | - | |||||||||||||||||||||||||||||||
| 2992 | NamespaceDeclaration &findNamespace(const QString &namespaceUri, bool writeDeclaration = false, bool noDefault = false); | - | ||||||||||||||||||||||||||||||
| 2993 | void writeNamespaceDeclaration(const NamespaceDeclaration &namespaceDeclaration); | - | ||||||||||||||||||||||||||||||
| 2994 | - | |||||||||||||||||||||||||||||||
| 2995 | int namespacePrefixCount; | - | ||||||||||||||||||||||||||||||
| 2996 | - | |||||||||||||||||||||||||||||||
| 2997 | void indent(int level); | - | ||||||||||||||||||||||||||||||
| 2998 | }; | - | ||||||||||||||||||||||||||||||
| 2999 | - | |||||||||||||||||||||||||||||||
| 3000 | - | |||||||||||||||||||||||||||||||
| 3001 | QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) | - | ||||||||||||||||||||||||||||||
| 3002 | :autoFormattingIndent(4, ' ') | - | ||||||||||||||||||||||||||||||
| 3003 | { | - | ||||||||||||||||||||||||||||||
| 3004 | q_ptr = q; | - | ||||||||||||||||||||||||||||||
| 3005 | device = 0; | - | ||||||||||||||||||||||||||||||
| 3006 | stringDevice = 0; | - | ||||||||||||||||||||||||||||||
| 3007 | deleteDevice = false; | - | ||||||||||||||||||||||||||||||
| 3008 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3009 | codec = QTextCodec::codecForMib(106); // utf8 | - | ||||||||||||||||||||||||||||||
| 3010 | encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8 | - | ||||||||||||||||||||||||||||||
| 3011 | #endif | - | ||||||||||||||||||||||||||||||
| 3012 | checkIfASCIICompatibleCodec(); | - | ||||||||||||||||||||||||||||||
| 3013 | inStartElement = inEmptyElement = false; | - | ||||||||||||||||||||||||||||||
| 3014 | wroteSomething = false; | - | ||||||||||||||||||||||||||||||
| 3015 | hasError = false; | - | ||||||||||||||||||||||||||||||
| 3016 | lastWasStartElement = false; | - | ||||||||||||||||||||||||||||||
| 3017 | lastNamespaceDeclaration = 1; | - | ||||||||||||||||||||||||||||||
| 3018 | autoFormatting = false; | - | ||||||||||||||||||||||||||||||
| 3019 | namespacePrefixCount = 0; | - | ||||||||||||||||||||||||||||||
| 3020 | } executed 744 times by 3 tests: end of blockExecuted by:
| 744 | ||||||||||||||||||||||||||||||
| 3021 | - | |||||||||||||||||||||||||||||||
| 3022 | void QXmlStreamWriterPrivate::checkIfASCIICompatibleCodec() | - | ||||||||||||||||||||||||||||||
| 3023 | { | - | ||||||||||||||||||||||||||||||
| 3024 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3025 | Q_ASSERT(encoder); | - | ||||||||||||||||||||||||||||||
| 3026 | // test ASCII-compatibility using the letter 'a' | - | ||||||||||||||||||||||||||||||
| 3027 | QChar letterA = QLatin1Char('a'); | - | ||||||||||||||||||||||||||||||
| 3028 | const QByteArray bytesA = encoder->fromUnicode(&letterA, 1); | - | ||||||||||||||||||||||||||||||
| 3029 | const bool isCodecASCIICompatibleA = (bytesA.count() == 1) && (bytesA[0] == 0x61) ;
| 1-757 | ||||||||||||||||||||||||||||||
| 3030 | QChar letterLess = QLatin1Char('<'); | - | ||||||||||||||||||||||||||||||
| 3031 | const QByteArray bytesLess = encoder->fromUnicode(&letterLess, 1); | - | ||||||||||||||||||||||||||||||
| 3032 | const bool isCodecASCIICompatibleLess = (bytesLess.count() == 1) && (bytesLess[0] == 0x3C) ;
| 1-757 | ||||||||||||||||||||||||||||||
| 3033 | isCodecASCIICompatible = isCodecASCIICompatibleA && isCodecASCIICompatibleLess ;
| 0-756 | ||||||||||||||||||||||||||||||
| 3034 | #else | - | ||||||||||||||||||||||||||||||
| 3035 | isCodecASCIICompatible = true; | - | ||||||||||||||||||||||||||||||
| 3036 | #endif | - | ||||||||||||||||||||||||||||||
| 3037 | } executed 758 times by 3 tests: end of blockExecuted by:
| 758 | ||||||||||||||||||||||||||||||
| 3038 | - | |||||||||||||||||||||||||||||||
| 3039 | void QXmlStreamWriterPrivate::write(const QStringRef &s) | - | ||||||||||||||||||||||||||||||
| 3040 | { | - | ||||||||||||||||||||||||||||||
| 3041 | if (device) {
| 8-3151 | ||||||||||||||||||||||||||||||
| 3042 | if (hasError)
| 4-3147 | ||||||||||||||||||||||||||||||
| 3043 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 3044 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3045 | QByteArray bytes = s.toLatin1(); | - | ||||||||||||||||||||||||||||||
| 3046 | #else | - | ||||||||||||||||||||||||||||||
| 3047 | QByteArray bytes = encoder->fromUnicode(s.constData(), s.size()); | - | ||||||||||||||||||||||||||||||
| 3048 | #endif | - | ||||||||||||||||||||||||||||||
| 3049 | if (device->write(bytes) != bytes.size())
| 1-3146 | ||||||||||||||||||||||||||||||
| 3050 | hasError = true; executed 1 time by 1 test: hasError = true;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3051 | } executed 3147 times by 3 tests: end of blockExecuted by:
| 3147 | ||||||||||||||||||||||||||||||
| 3052 | else if (stringDevice)
| 0-8 | ||||||||||||||||||||||||||||||
| 3053 | s.appendTo(stringDevice); executed 8 times by 1 test: s.appendTo(stringDevice);Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 3054 | else | - | ||||||||||||||||||||||||||||||
| 3055 | qWarning("QXmlStreamWriter: No device"); never executed: QMessageLogger(__FILE__, 3055, __PRETTY_FUNCTION__).warning("QXmlStreamWriter: No device"); | 0 | ||||||||||||||||||||||||||||||
| 3056 | } | - | ||||||||||||||||||||||||||||||
| 3057 | - | |||||||||||||||||||||||||||||||
| 3058 | void QXmlStreamWriterPrivate::write(const QString &s) | - | ||||||||||||||||||||||||||||||
| 3059 | { | - | ||||||||||||||||||||||||||||||
| 3060 | if (device) {
| 72-5148 | ||||||||||||||||||||||||||||||
| 3061 | if (hasError)
| 1-5147 | ||||||||||||||||||||||||||||||
| 3062 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3063 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3064 | QByteArray bytes = s.toLatin1(); | - | ||||||||||||||||||||||||||||||
| 3065 | #else | - | ||||||||||||||||||||||||||||||
| 3066 | QByteArray bytes = encoder->fromUnicode(s); | - | ||||||||||||||||||||||||||||||
| 3067 | #endif | - | ||||||||||||||||||||||||||||||
| 3068 | if (device->write(bytes) != bytes.size())
| 1-5146 | ||||||||||||||||||||||||||||||
| 3069 | hasError = true; executed 1 time by 1 test: hasError = true;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3070 | } executed 5147 times by 3 tests: end of blockExecuted by:
| 5147 | ||||||||||||||||||||||||||||||
| 3071 | else if (stringDevice)
| 0-72 | ||||||||||||||||||||||||||||||
| 3072 | stringDevice->append(s); executed 72 times by 1 test: stringDevice->append(s);Executed by:
| 72 | ||||||||||||||||||||||||||||||
| 3073 | else | - | ||||||||||||||||||||||||||||||
| 3074 | qWarning("QXmlStreamWriter: No device"); never executed: QMessageLogger(__FILE__, 3074, __PRETTY_FUNCTION__).warning("QXmlStreamWriter: No device"); | 0 | ||||||||||||||||||||||||||||||
| 3075 | } | - | ||||||||||||||||||||||||||||||
| 3076 | - | |||||||||||||||||||||||||||||||
| 3077 | void QXmlStreamWriterPrivate::writeEscaped(const QString &s, bool escapeWhitespace) | - | ||||||||||||||||||||||||||||||
| 3078 | { | - | ||||||||||||||||||||||||||||||
| 3079 | QString escaped; | - | ||||||||||||||||||||||||||||||
| 3080 | escaped.reserve(s.size()); | - | ||||||||||||||||||||||||||||||
| 3081 | for ( int i = 0; i < s.size(); ++i ) {
| 3437-20852 | ||||||||||||||||||||||||||||||
| 3082 | QChar c = s.at(i); | - | ||||||||||||||||||||||||||||||
| 3083 | if (c.unicode() == '<' )
| 50-20802 | ||||||||||||||||||||||||||||||
| 3084 | escaped.append(QLatin1String("<")); executed 50 times by 1 test: escaped.append(QLatin1String("<"));Executed by:
| 50 | ||||||||||||||||||||||||||||||
| 3085 | else if (c.unicode() == '>' )
| 52-20750 | ||||||||||||||||||||||||||||||
| 3086 | escaped.append(QLatin1String(">")); executed 52 times by 1 test: escaped.append(QLatin1String(">"));Executed by:
| 52 | ||||||||||||||||||||||||||||||
| 3087 | else if (c.unicode() == '&' )
| 29-20721 | ||||||||||||||||||||||||||||||
| 3088 | escaped.append(QLatin1String("&")); executed 29 times by 1 test: escaped.append(QLatin1String("&"));Executed by:
| 29 | ||||||||||||||||||||||||||||||
| 3089 | else if (c.unicode() == '\"' )
| 21-20700 | ||||||||||||||||||||||||||||||
| 3090 | escaped.append(QLatin1String(""")); executed 21 times by 1 test: escaped.append(QLatin1String("""));Executed by:
| 21 | ||||||||||||||||||||||||||||||
| 3091 | else if (escapeWhitespace && c.isSpace()) {
| 173-16644 | ||||||||||||||||||||||||||||||
| 3092 | if (c.unicode() == '\n')
| 2-171 | ||||||||||||||||||||||||||||||
| 3093 | escaped.append(QLatin1String(" ")); executed 2 times by 1 test: escaped.append(QLatin1String(" "));Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3094 | else if (c.unicode() == '\r')
| 2-169 | ||||||||||||||||||||||||||||||
| 3095 | escaped.append(QLatin1String(" ")); executed 2 times by 1 test: escaped.append(QLatin1String(" "));Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3096 | else if (c.unicode() == '\t')
| 3-166 | ||||||||||||||||||||||||||||||
| 3097 | escaped.append(QLatin1String("	")); executed 3 times by 1 test: escaped.append(QLatin1String("	"));Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 3098 | else | - | ||||||||||||||||||||||||||||||
| 3099 | escaped += c; executed 166 times by 1 test: escaped += c;Executed by:
| 166 | ||||||||||||||||||||||||||||||
| 3100 | } else { | - | ||||||||||||||||||||||||||||||
| 3101 | escaped += QChar(c); | - | ||||||||||||||||||||||||||||||
| 3102 | } executed 20527 times by 3 tests: end of blockExecuted by:
| 20527 | ||||||||||||||||||||||||||||||
| 3103 | } | - | ||||||||||||||||||||||||||||||
| 3104 | write(escaped); | - | ||||||||||||||||||||||||||||||
| 3105 | } executed 3437 times by 3 tests: end of blockExecuted by:
| 3437 | ||||||||||||||||||||||||||||||
| 3106 | - | |||||||||||||||||||||||||||||||
| 3107 | // Converts from ASCII to output encoding | - | ||||||||||||||||||||||||||||||
| 3108 | void QXmlStreamWriterPrivate::write(const char *s, int len) | - | ||||||||||||||||||||||||||||||
| 3109 | { | - | ||||||||||||||||||||||||||||||
| 3110 | if (device) {
| 64-10239 | ||||||||||||||||||||||||||||||
| 3111 | if (hasError)
| 14-10225 | ||||||||||||||||||||||||||||||
| 3112 | return; executed 14 times by 1 test: return;Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 3113 | if (isCodecASCIICompatible) {
| 14-10211 | ||||||||||||||||||||||||||||||
| 3114 | if (device->write(s, len) != len)
| 2-10209 | ||||||||||||||||||||||||||||||
| 3115 | hasError = true; executed 2 times by 1 test: hasError = true;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3116 | return; executed 10211 times by 3 tests: return;Executed by:
| 10211 | ||||||||||||||||||||||||||||||
| 3117 | } | - | ||||||||||||||||||||||||||||||
| 3118 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 3119 | - | |||||||||||||||||||||||||||||||
| 3120 | write(QString::fromLatin1(s, len)); | - | ||||||||||||||||||||||||||||||
| 3121 | } executed 78 times by 1 test: end of blockExecuted by:
| 78 | ||||||||||||||||||||||||||||||
| 3122 | - | |||||||||||||||||||||||||||||||
| 3123 | void QXmlStreamWriterPrivate::writeNamespaceDeclaration(const NamespaceDeclaration &namespaceDeclaration) { | - | ||||||||||||||||||||||||||||||
| 3124 | if (namespaceDeclaration.prefix.isEmpty()) {
| 0-102 | ||||||||||||||||||||||||||||||
| 3125 | write(" xmlns=\""); | - | ||||||||||||||||||||||||||||||
| 3126 | write(namespaceDeclaration.namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3127 | write("\""); | - | ||||||||||||||||||||||||||||||
| 3128 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3129 | write(" xmlns:"); | - | ||||||||||||||||||||||||||||||
| 3130 | write(namespaceDeclaration.prefix); | - | ||||||||||||||||||||||||||||||
| 3131 | write("=\""); | - | ||||||||||||||||||||||||||||||
| 3132 | write(namespaceDeclaration.namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3133 | write("\""); | - | ||||||||||||||||||||||||||||||
| 3134 | } executed 102 times by 3 tests: end of blockExecuted by:
| 102 | ||||||||||||||||||||||||||||||
| 3135 | } | - | ||||||||||||||||||||||||||||||
| 3136 | - | |||||||||||||||||||||||||||||||
| 3137 | bool QXmlStreamWriterPrivate::finishStartElement(bool contents) | - | ||||||||||||||||||||||||||||||
| 3138 | { | - | ||||||||||||||||||||||||||||||
| 3139 | bool hadSomethingWritten = wroteSomething; | - | ||||||||||||||||||||||||||||||
| 3140 | wroteSomething = contents; | - | ||||||||||||||||||||||||||||||
| 3141 | if (!inStartElement)
| 1276-5103 | ||||||||||||||||||||||||||||||
| 3142 | return hadSomethingWritten; executed 5103 times by 3 tests: return hadSomethingWritten;Executed by:
| 5103 | ||||||||||||||||||||||||||||||
| 3143 | - | |||||||||||||||||||||||||||||||
| 3144 | if (inEmptyElement) {
| 39-1237 | ||||||||||||||||||||||||||||||
| 3145 | write("/>"); | - | ||||||||||||||||||||||||||||||
| 3146 | QXmlStreamWriterPrivate::Tag &tag = tagStack_pop(); | - | ||||||||||||||||||||||||||||||
| 3147 | lastNamespaceDeclaration = tag.namespaceDeclarationsSize; | - | ||||||||||||||||||||||||||||||
| 3148 | lastWasStartElement = false; | - | ||||||||||||||||||||||||||||||
| 3149 | } else { executed 39 times by 3 tests: end of blockExecuted by:
| 39 | ||||||||||||||||||||||||||||||
| 3150 | write(">"); | - | ||||||||||||||||||||||||||||||
| 3151 | } executed 1237 times by 3 tests: end of blockExecuted by:
| 1237 | ||||||||||||||||||||||||||||||
| 3152 | inStartElement = inEmptyElement = false; | - | ||||||||||||||||||||||||||||||
| 3153 | lastNamespaceDeclaration = namespaceDeclarations.size(); | - | ||||||||||||||||||||||||||||||
| 3154 | return hadSomethingWritten; executed 1276 times by 3 tests: return hadSomethingWritten;Executed by:
| 1276 | ||||||||||||||||||||||||||||||
| 3155 | } | - | ||||||||||||||||||||||||||||||
| 3156 | - | |||||||||||||||||||||||||||||||
| 3157 | QXmlStreamPrivateTagStack::NamespaceDeclaration &QXmlStreamWriterPrivate::findNamespace(const QString &namespaceUri, bool writeDeclaration, bool noDefault) | - | ||||||||||||||||||||||||||||||
| 3158 | { | - | ||||||||||||||||||||||||||||||
| 3159 | for (int j = namespaceDeclarations.size() - 1; j >= 0; --j) {
| 1162-2565 | ||||||||||||||||||||||||||||||
| 3160 | NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations[j]; | - | ||||||||||||||||||||||||||||||
| 3161 | if (namespaceDeclaration.namespaceUri == namespaceUri) {
| 302-2263 | ||||||||||||||||||||||||||||||
| 3162 | if (!noDefault || !namespaceDeclaration.prefix.isEmpty())
| 0-168 | ||||||||||||||||||||||||||||||
| 3163 | return namespaceDeclaration; executed 302 times by 3 tests: return namespaceDeclaration;Executed by:
| 302 | ||||||||||||||||||||||||||||||
| 3164 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3165 | } executed 2263 times by 3 tests: end of blockExecuted by:
| 2263 | ||||||||||||||||||||||||||||||
| 3166 | if (namespaceUri.isEmpty())
| 19-1143 | ||||||||||||||||||||||||||||||
| 3167 | return emptyNamespace; executed 1143 times by 1 test: return emptyNamespace;Executed by:
| 1143 | ||||||||||||||||||||||||||||||
| 3168 | NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 3169 | if (namespaceUri.isEmpty()) {
| 0-19 | ||||||||||||||||||||||||||||||
| 3170 | namespaceDeclaration.prefix.clear(); | - | ||||||||||||||||||||||||||||||
| 3171 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3172 | QString s; | - | ||||||||||||||||||||||||||||||
| 3173 | int n = ++namespacePrefixCount; | - | ||||||||||||||||||||||||||||||
| 3174 | forever { | - | ||||||||||||||||||||||||||||||
| 3175 | s = QLatin1Char('n') + QString::number(n++); | - | ||||||||||||||||||||||||||||||
| 3176 | int j = namespaceDeclarations.size() - 2; | - | ||||||||||||||||||||||||||||||
| 3177 | while (j >= 0 && namespaceDeclarations.at(j).prefix != s)
| 0-22 | ||||||||||||||||||||||||||||||
| 3178 | --j; executed 22 times by 1 test: --j;Executed by:
| 22 | ||||||||||||||||||||||||||||||
| 3179 | if (j < 0)
| 0-19 | ||||||||||||||||||||||||||||||
| 3180 | break; executed 19 times by 1 test: break;Executed by:
| 19 | ||||||||||||||||||||||||||||||
| 3181 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3182 | namespaceDeclaration.prefix = addToStringStorage(s); | - | ||||||||||||||||||||||||||||||
| 3183 | } executed 19 times by 1 test: end of blockExecuted by:
| 19 | ||||||||||||||||||||||||||||||
| 3184 | namespaceDeclaration.namespaceUri = addToStringStorage(namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3185 | if (writeDeclaration)
| 4-15 | ||||||||||||||||||||||||||||||
| 3186 | writeNamespaceDeclaration(namespaceDeclaration); executed 4 times by 1 test: writeNamespaceDeclaration(namespaceDeclaration);Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 3187 | return namespaceDeclaration; executed 19 times by 1 test: return namespaceDeclaration;Executed by:
| 19 | ||||||||||||||||||||||||||||||
| 3188 | } | - | ||||||||||||||||||||||||||||||
| 3189 | - | |||||||||||||||||||||||||||||||
| 3190 | - | |||||||||||||||||||||||||||||||
| 3191 | - | |||||||||||||||||||||||||||||||
| 3192 | void QXmlStreamWriterPrivate::indent(int level) | - | ||||||||||||||||||||||||||||||
| 3193 | { | - | ||||||||||||||||||||||||||||||
| 3194 | write("\n"); | - | ||||||||||||||||||||||||||||||
| 3195 | for (int i = level; i > 0; --i)
| 218-332 | ||||||||||||||||||||||||||||||
| 3196 | write(autoFormattingIndent.constData(), autoFormattingIndent.length()); executed 332 times by 3 tests: write(autoFormattingIndent.constData(), autoFormattingIndent.length());Executed by:
| 332 | ||||||||||||||||||||||||||||||
| 3197 | } executed 218 times by 3 tests: end of blockExecuted by:
| 218 | ||||||||||||||||||||||||||||||
| 3198 | - | |||||||||||||||||||||||||||||||
| 3199 | - | |||||||||||||||||||||||||||||||
| 3200 | /*! | - | ||||||||||||||||||||||||||||||
| 3201 | Constructs a stream writer. | - | ||||||||||||||||||||||||||||||
| 3202 | - | |||||||||||||||||||||||||||||||
| 3203 | \sa setDevice() | - | ||||||||||||||||||||||||||||||
| 3204 | */ | - | ||||||||||||||||||||||||||||||
| 3205 | QXmlStreamWriter::QXmlStreamWriter() | - | ||||||||||||||||||||||||||||||
| 3206 | : d_ptr(new QXmlStreamWriterPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 3207 | { | - | ||||||||||||||||||||||||||||||
| 3208 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3209 | - | |||||||||||||||||||||||||||||||
| 3210 | /*! | - | ||||||||||||||||||||||||||||||
| 3211 | Constructs a stream writer that writes into \a device; | - | ||||||||||||||||||||||||||||||
| 3212 | */ | - | ||||||||||||||||||||||||||||||
| 3213 | QXmlStreamWriter::QXmlStreamWriter(QIODevice *device) | - | ||||||||||||||||||||||||||||||
| 3214 | : d_ptr(new QXmlStreamWriterPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 3215 | { | - | ||||||||||||||||||||||||||||||
| 3216 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3217 | d->device = device; | - | ||||||||||||||||||||||||||||||
| 3218 | } executed 32 times by 3 tests: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||||||||
| 3219 | - | |||||||||||||||||||||||||||||||
| 3220 | /*! Constructs a stream writer that writes into \a array. This is the | - | ||||||||||||||||||||||||||||||
| 3221 | same as creating an xml writer that operates on a QBuffer device | - | ||||||||||||||||||||||||||||||
| 3222 | which in turn operates on \a array. | - | ||||||||||||||||||||||||||||||
| 3223 | */ | - | ||||||||||||||||||||||||||||||
| 3224 | QXmlStreamWriter::QXmlStreamWriter(QByteArray *array) | - | ||||||||||||||||||||||||||||||
| 3225 | : d_ptr(new QXmlStreamWriterPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 3226 | { | - | ||||||||||||||||||||||||||||||
| 3227 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3228 | d->device = new QBuffer(array); | - | ||||||||||||||||||||||||||||||
| 3229 | d->device->open(QIODevice::WriteOnly); | - | ||||||||||||||||||||||||||||||
| 3230 | d->deleteDevice = true; | - | ||||||||||||||||||||||||||||||
| 3231 | } executed 710 times by 1 test: end of blockExecuted by:
| 710 | ||||||||||||||||||||||||||||||
| 3232 | - | |||||||||||||||||||||||||||||||
| 3233 | - | |||||||||||||||||||||||||||||||
| 3234 | /*! Constructs a stream writer that writes into \a string. | - | ||||||||||||||||||||||||||||||
| 3235 | */ | - | ||||||||||||||||||||||||||||||
| 3236 | QXmlStreamWriter::QXmlStreamWriter(QString *string) | - | ||||||||||||||||||||||||||||||
| 3237 | : d_ptr(new QXmlStreamWriterPrivate(this)) | - | ||||||||||||||||||||||||||||||
| 3238 | { | - | ||||||||||||||||||||||||||||||
| 3239 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3240 | d->stringDevice = string; | - | ||||||||||||||||||||||||||||||
| 3241 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 3242 | - | |||||||||||||||||||||||||||||||
| 3243 | /*! | - | ||||||||||||||||||||||||||||||
| 3244 | Destructor. | - | ||||||||||||||||||||||||||||||
| 3245 | */ | - | ||||||||||||||||||||||||||||||
| 3246 | QXmlStreamWriter::~QXmlStreamWriter() | - | ||||||||||||||||||||||||||||||
| 3247 | { | - | ||||||||||||||||||||||||||||||
| 3248 | } | - | ||||||||||||||||||||||||||||||
| 3249 | - | |||||||||||||||||||||||||||||||
| 3250 | - | |||||||||||||||||||||||||||||||
| 3251 | /*! | - | ||||||||||||||||||||||||||||||
| 3252 | Sets the current device to \a device. If you want the stream to | - | ||||||||||||||||||||||||||||||
| 3253 | write into a QByteArray, you can create a QBuffer device. | - | ||||||||||||||||||||||||||||||
| 3254 | - | |||||||||||||||||||||||||||||||
| 3255 | \sa device() | - | ||||||||||||||||||||||||||||||
| 3256 | */ | - | ||||||||||||||||||||||||||||||
| 3257 | void QXmlStreamWriter::setDevice(QIODevice *device) | - | ||||||||||||||||||||||||||||||
| 3258 | { | - | ||||||||||||||||||||||||||||||
| 3259 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3260 | if (device == d->device)
| 0 | ||||||||||||||||||||||||||||||
| 3261 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3262 | d->stringDevice = 0; | - | ||||||||||||||||||||||||||||||
| 3263 | if (d->deleteDevice) {
| 0 | ||||||||||||||||||||||||||||||
| 3264 | delete d->device; | - | ||||||||||||||||||||||||||||||
| 3265 | d->deleteDevice = false; | - | ||||||||||||||||||||||||||||||
| 3266 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3267 | d->device = device; | - | ||||||||||||||||||||||||||||||
| 3268 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3269 | - | |||||||||||||||||||||||||||||||
| 3270 | /*! | - | ||||||||||||||||||||||||||||||
| 3271 | Returns the current device associated with the QXmlStreamWriter, | - | ||||||||||||||||||||||||||||||
| 3272 | or 0 if no device has been assigned. | - | ||||||||||||||||||||||||||||||
| 3273 | - | |||||||||||||||||||||||||||||||
| 3274 | \sa setDevice() | - | ||||||||||||||||||||||||||||||
| 3275 | */ | - | ||||||||||||||||||||||||||||||
| 3276 | QIODevice *QXmlStreamWriter::device() const | - | ||||||||||||||||||||||||||||||
| 3277 | { | - | ||||||||||||||||||||||||||||||
| 3278 | Q_D(const QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3279 | return d->device; never executed: return d->device; | 0 | ||||||||||||||||||||||||||||||
| 3280 | } | - | ||||||||||||||||||||||||||||||
| 3281 | - | |||||||||||||||||||||||||||||||
| 3282 | - | |||||||||||||||||||||||||||||||
| 3283 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3284 | /*! | - | ||||||||||||||||||||||||||||||
| 3285 | Sets the codec for this stream to \a codec. The codec is used for | - | ||||||||||||||||||||||||||||||
| 3286 | encoding any data that is written. By default, QXmlStreamWriter | - | ||||||||||||||||||||||||||||||
| 3287 | uses UTF-8. | - | ||||||||||||||||||||||||||||||
| 3288 | - | |||||||||||||||||||||||||||||||
| 3289 | The encoding information is stored in the initial xml tag which | - | ||||||||||||||||||||||||||||||
| 3290 | gets written when you call writeStartDocument(). Call this | - | ||||||||||||||||||||||||||||||
| 3291 | function before calling writeStartDocument(). | - | ||||||||||||||||||||||||||||||
| 3292 | - | |||||||||||||||||||||||||||||||
| 3293 | \sa codec() | - | ||||||||||||||||||||||||||||||
| 3294 | */ | - | ||||||||||||||||||||||||||||||
| 3295 | void QXmlStreamWriter::setCodec(QTextCodec *codec) | - | ||||||||||||||||||||||||||||||
| 3296 | { | - | ||||||||||||||||||||||||||||||
| 3297 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3298 | if (codec) {
| 0-14 | ||||||||||||||||||||||||||||||
| 3299 | d->codec = codec; | - | ||||||||||||||||||||||||||||||
| 3300 | delete d->encoder; | - | ||||||||||||||||||||||||||||||
| 3301 | d->encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8 | - | ||||||||||||||||||||||||||||||
| 3302 | d->checkIfASCIICompatibleCodec(); | - | ||||||||||||||||||||||||||||||
| 3303 | } executed 14 times by 3 tests: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 3304 | } executed 14 times by 3 tests: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 3305 | - | |||||||||||||||||||||||||||||||
| 3306 | /*! | - | ||||||||||||||||||||||||||||||
| 3307 | Sets the codec for this stream to the QTextCodec for the encoding | - | ||||||||||||||||||||||||||||||
| 3308 | specified by \a codecName. Common values for \c codecName include | - | ||||||||||||||||||||||||||||||
| 3309 | "ISO 8859-1", "UTF-8", and "UTF-16". If the encoding isn't | - | ||||||||||||||||||||||||||||||
| 3310 | recognized, nothing happens. | - | ||||||||||||||||||||||||||||||
| 3311 | - | |||||||||||||||||||||||||||||||
| 3312 | \sa QTextCodec::codecForName() | - | ||||||||||||||||||||||||||||||
| 3313 | */ | - | ||||||||||||||||||||||||||||||
| 3314 | void QXmlStreamWriter::setCodec(const char *codecName) | - | ||||||||||||||||||||||||||||||
| 3315 | { | - | ||||||||||||||||||||||||||||||
| 3316 | setCodec(QTextCodec::codecForName(codecName)); | - | ||||||||||||||||||||||||||||||
| 3317 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 3318 | - | |||||||||||||||||||||||||||||||
| 3319 | /*! | - | ||||||||||||||||||||||||||||||
| 3320 | Returns the codec that is currently assigned to the stream. | - | ||||||||||||||||||||||||||||||
| 3321 | - | |||||||||||||||||||||||||||||||
| 3322 | \sa setCodec() | - | ||||||||||||||||||||||||||||||
| 3323 | */ | - | ||||||||||||||||||||||||||||||
| 3324 | QTextCodec *QXmlStreamWriter::codec() const | - | ||||||||||||||||||||||||||||||
| 3325 | { | - | ||||||||||||||||||||||||||||||
| 3326 | Q_D(const QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3327 | return d->codec; never executed: return d->codec; | 0 | ||||||||||||||||||||||||||||||
| 3328 | } | - | ||||||||||||||||||||||||||||||
| 3329 | #endif // QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3330 | - | |||||||||||||||||||||||||||||||
| 3331 | /*! | - | ||||||||||||||||||||||||||||||
| 3332 | \property QXmlStreamWriter::autoFormatting | - | ||||||||||||||||||||||||||||||
| 3333 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 3334 | The auto-formatting flag of the stream writer | - | ||||||||||||||||||||||||||||||
| 3335 | - | |||||||||||||||||||||||||||||||
| 3336 | This property controls whether or not the stream writer | - | ||||||||||||||||||||||||||||||
| 3337 | automatically formats the generated XML data. If enabled, the | - | ||||||||||||||||||||||||||||||
| 3338 | writer automatically adds line-breaks and indentation to empty | - | ||||||||||||||||||||||||||||||
| 3339 | sections between elements (ignorable whitespace). The main purpose | - | ||||||||||||||||||||||||||||||
| 3340 | of auto-formatting is to split the data into several lines, and to | - | ||||||||||||||||||||||||||||||
| 3341 | increase readability for a human reader. The indentation depth can | - | ||||||||||||||||||||||||||||||
| 3342 | be controlled through the \l autoFormattingIndent property. | - | ||||||||||||||||||||||||||||||
| 3343 | - | |||||||||||||||||||||||||||||||
| 3344 | By default, auto-formatting is disabled. | - | ||||||||||||||||||||||||||||||
| 3345 | */ | - | ||||||||||||||||||||||||||||||
| 3346 | - | |||||||||||||||||||||||||||||||
| 3347 | /*! | - | ||||||||||||||||||||||||||||||
| 3348 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 3349 | - | |||||||||||||||||||||||||||||||
| 3350 | Enables auto formatting if \a enable is \c true, otherwise | - | ||||||||||||||||||||||||||||||
| 3351 | disables it. | - | ||||||||||||||||||||||||||||||
| 3352 | - | |||||||||||||||||||||||||||||||
| 3353 | The default value is \c false. | - | ||||||||||||||||||||||||||||||
| 3354 | */ | - | ||||||||||||||||||||||||||||||
| 3355 | void QXmlStreamWriter::setAutoFormatting(bool enable) | - | ||||||||||||||||||||||||||||||
| 3356 | { | - | ||||||||||||||||||||||||||||||
| 3357 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3358 | d->autoFormatting = enable; | - | ||||||||||||||||||||||||||||||
| 3359 | } executed 28 times by 3 tests: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||||||||
| 3360 | - | |||||||||||||||||||||||||||||||
| 3361 | /*! | - | ||||||||||||||||||||||||||||||
| 3362 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 3363 | - | |||||||||||||||||||||||||||||||
| 3364 | Returns \c true if auto formattting is enabled, otherwise \c false. | - | ||||||||||||||||||||||||||||||
| 3365 | */ | - | ||||||||||||||||||||||||||||||
| 3366 | bool QXmlStreamWriter::autoFormatting() const | - | ||||||||||||||||||||||||||||||
| 3367 | { | - | ||||||||||||||||||||||||||||||
| 3368 | Q_D(const QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3369 | return d->autoFormatting; never executed: return d->autoFormatting; | 0 | ||||||||||||||||||||||||||||||
| 3370 | } | - | ||||||||||||||||||||||||||||||
| 3371 | - | |||||||||||||||||||||||||||||||
| 3372 | /*! | - | ||||||||||||||||||||||||||||||
| 3373 | \property QXmlStreamWriter::autoFormattingIndent | - | ||||||||||||||||||||||||||||||
| 3374 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 3375 | - | |||||||||||||||||||||||||||||||
| 3376 | \brief the number of spaces or tabs used for indentation when | - | ||||||||||||||||||||||||||||||
| 3377 | auto-formatting is enabled. Positive numbers indicate spaces, | - | ||||||||||||||||||||||||||||||
| 3378 | negative numbers tabs. | - | ||||||||||||||||||||||||||||||
| 3379 | - | |||||||||||||||||||||||||||||||
| 3380 | The default indentation is 4. | - | ||||||||||||||||||||||||||||||
| 3381 | - | |||||||||||||||||||||||||||||||
| 3382 | \sa autoFormatting | - | ||||||||||||||||||||||||||||||
| 3383 | */ | - | ||||||||||||||||||||||||||||||
| 3384 | - | |||||||||||||||||||||||||||||||
| 3385 | - | |||||||||||||||||||||||||||||||
| 3386 | void QXmlStreamWriter::setAutoFormattingIndent(int spacesOrTabs) | - | ||||||||||||||||||||||||||||||
| 3387 | { | - | ||||||||||||||||||||||||||||||
| 3388 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3389 | d->autoFormattingIndent = QByteArray(qAbs(spacesOrTabs), spacesOrTabs >= 0 ? ' ' : '\t'); | - | ||||||||||||||||||||||||||||||
| 3390 | } executed 21 times by 3 tests: end of blockExecuted by:
| 21 | ||||||||||||||||||||||||||||||
| 3391 | - | |||||||||||||||||||||||||||||||
| 3392 | int QXmlStreamWriter::autoFormattingIndent() const | - | ||||||||||||||||||||||||||||||
| 3393 | { | - | ||||||||||||||||||||||||||||||
| 3394 | Q_D(const QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3395 | 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 | ||||||||||||||||||||||||||||||
| 3396 | } | - | ||||||||||||||||||||||||||||||
| 3397 | - | |||||||||||||||||||||||||||||||
| 3398 | /*! | - | ||||||||||||||||||||||||||||||
| 3399 | Returns \c true if the stream failed to write to the underlying device. | - | ||||||||||||||||||||||||||||||
| 3400 | - | |||||||||||||||||||||||||||||||
| 3401 | The error status is never reset. Writes happening after the error | - | ||||||||||||||||||||||||||||||
| 3402 | occurred are ignored, even if the error condition is cleared. | - | ||||||||||||||||||||||||||||||
| 3403 | */ | - | ||||||||||||||||||||||||||||||
| 3404 | bool QXmlStreamWriter::hasError() const | - | ||||||||||||||||||||||||||||||
| 3405 | { | - | ||||||||||||||||||||||||||||||
| 3406 | Q_D(const QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3407 | return d->hasError; executed 6 times by 1 test: return d->hasError;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 3408 | } | - | ||||||||||||||||||||||||||||||
| 3409 | - | |||||||||||||||||||||||||||||||
| 3410 | /*! | - | ||||||||||||||||||||||||||||||
| 3411 | \overload | - | ||||||||||||||||||||||||||||||
| 3412 | Writes an attribute with \a qualifiedName and \a value. | - | ||||||||||||||||||||||||||||||
| 3413 | - | |||||||||||||||||||||||||||||||
| 3414 | - | |||||||||||||||||||||||||||||||
| 3415 | This function can only be called after writeStartElement() before | - | ||||||||||||||||||||||||||||||
| 3416 | any content is written, or after writeEmptyElement(). | - | ||||||||||||||||||||||||||||||
| 3417 | */ | - | ||||||||||||||||||||||||||||||
| 3418 | void QXmlStreamWriter::writeAttribute(const QString &qualifiedName, const QString &value) | - | ||||||||||||||||||||||||||||||
| 3419 | { | - | ||||||||||||||||||||||||||||||
| 3420 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3421 | Q_ASSERT(d->inStartElement); | - | ||||||||||||||||||||||||||||||
| 3422 | Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1); | - | ||||||||||||||||||||||||||||||
| 3423 | d->write(" "); | - | ||||||||||||||||||||||||||||||
| 3424 | d->write(qualifiedName); | - | ||||||||||||||||||||||||||||||
| 3425 | d->write("=\""); | - | ||||||||||||||||||||||||||||||
| 3426 | d->writeEscaped(value, true); | - | ||||||||||||||||||||||||||||||
| 3427 | d->write("\""); | - | ||||||||||||||||||||||||||||||
| 3428 | } executed 440 times by 1 test: end of blockExecuted by:
| 440 | ||||||||||||||||||||||||||||||
| 3429 | - | |||||||||||||||||||||||||||||||
| 3430 | /*! Writes an attribute with \a name and \a value, prefixed for | - | ||||||||||||||||||||||||||||||
| 3431 | the specified \a namespaceUri. If the namespace has not been | - | ||||||||||||||||||||||||||||||
| 3432 | declared yet, QXmlStreamWriter will generate a namespace declaration | - | ||||||||||||||||||||||||||||||
| 3433 | for it. | - | ||||||||||||||||||||||||||||||
| 3434 | - | |||||||||||||||||||||||||||||||
| 3435 | This function can only be called after writeStartElement() before | - | ||||||||||||||||||||||||||||||
| 3436 | any content is written, or after writeEmptyElement(). | - | ||||||||||||||||||||||||||||||
| 3437 | */ | - | ||||||||||||||||||||||||||||||
| 3438 | void QXmlStreamWriter::writeAttribute(const QString &namespaceUri, const QString &name, const QString &value) | - | ||||||||||||||||||||||||||||||
| 3439 | { | - | ||||||||||||||||||||||||||||||
| 3440 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3441 | Q_ASSERT(d->inStartElement); | - | ||||||||||||||||||||||||||||||
| 3442 | Q_ASSERT(!name.contains(QLatin1Char(':'))); | - | ||||||||||||||||||||||||||||||
| 3443 | QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->findNamespace(namespaceUri, true, true); | - | ||||||||||||||||||||||||||||||
| 3444 | d->write(" "); | - | ||||||||||||||||||||||||||||||
| 3445 | if (!namespaceDeclaration.prefix.isEmpty()) {
| 0-172 | ||||||||||||||||||||||||||||||
| 3446 | d->write(namespaceDeclaration.prefix); | - | ||||||||||||||||||||||||||||||
| 3447 | d->write(":"); | - | ||||||||||||||||||||||||||||||
| 3448 | } executed 172 times by 3 tests: end of blockExecuted by:
| 172 | ||||||||||||||||||||||||||||||
| 3449 | d->write(name); | - | ||||||||||||||||||||||||||||||
| 3450 | d->write("=\""); | - | ||||||||||||||||||||||||||||||
| 3451 | d->writeEscaped(value, true); | - | ||||||||||||||||||||||||||||||
| 3452 | d->write("\""); | - | ||||||||||||||||||||||||||||||
| 3453 | } executed 172 times by 3 tests: end of blockExecuted by:
| 172 | ||||||||||||||||||||||||||||||
| 3454 | - | |||||||||||||||||||||||||||||||
| 3455 | /*! | - | ||||||||||||||||||||||||||||||
| 3456 | \overload | - | ||||||||||||||||||||||||||||||
| 3457 | - | |||||||||||||||||||||||||||||||
| 3458 | Writes the \a attribute. | - | ||||||||||||||||||||||||||||||
| 3459 | - | |||||||||||||||||||||||||||||||
| 3460 | This function can only be called after writeStartElement() before | - | ||||||||||||||||||||||||||||||
| 3461 | any content is written, or after writeEmptyElement(). | - | ||||||||||||||||||||||||||||||
| 3462 | */ | - | ||||||||||||||||||||||||||||||
| 3463 | void QXmlStreamWriter::writeAttribute(const QXmlStreamAttribute& attribute) | - | ||||||||||||||||||||||||||||||
| 3464 | { | - | ||||||||||||||||||||||||||||||
| 3465 | if (attribute.namespaceUri().isEmpty())
| 34-433 | ||||||||||||||||||||||||||||||
| 3466 | writeAttribute(attribute.qualifiedName().toString(), executed 433 times by 1 test: writeAttribute(attribute.qualifiedName().toString(), attribute.value().toString());Executed by:
| 433 | ||||||||||||||||||||||||||||||
| 3467 | attribute.value().toString()); executed 433 times by 1 test: writeAttribute(attribute.qualifiedName().toString(), attribute.value().toString());Executed by:
| 433 | ||||||||||||||||||||||||||||||
| 3468 | else | - | ||||||||||||||||||||||||||||||
| 3469 | writeAttribute(attribute.namespaceUri().toString(), executed 34 times by 1 test: writeAttribute(attribute.namespaceUri().toString(), attribute.name().toString(), attribute.value().toString());Executed by:
| 34 | ||||||||||||||||||||||||||||||
| 3470 | attribute.name().toString(), executed 34 times by 1 test: writeAttribute(attribute.namespaceUri().toString(), attribute.name().toString(), attribute.value().toString());Executed by:
| 34 | ||||||||||||||||||||||||||||||
| 3471 | attribute.value().toString()); executed 34 times by 1 test: writeAttribute(attribute.namespaceUri().toString(), attribute.name().toString(), attribute.value().toString());Executed by:
| 34 | ||||||||||||||||||||||||||||||
| 3472 | } | - | ||||||||||||||||||||||||||||||
| 3473 | - | |||||||||||||||||||||||||||||||
| 3474 | - | |||||||||||||||||||||||||||||||
| 3475 | /*! Writes the attribute vector \a attributes. If a namespace | - | ||||||||||||||||||||||||||||||
| 3476 | referenced in an attribute not been declared yet, QXmlStreamWriter | - | ||||||||||||||||||||||||||||||
| 3477 | will generate a namespace declaration for it. | - | ||||||||||||||||||||||||||||||
| 3478 | - | |||||||||||||||||||||||||||||||
| 3479 | This function can only be called after writeStartElement() before | - | ||||||||||||||||||||||||||||||
| 3480 | any content is written, or after writeEmptyElement(). | - | ||||||||||||||||||||||||||||||
| 3481 | - | |||||||||||||||||||||||||||||||
| 3482 | \sa writeAttribute(), writeNamespace() | - | ||||||||||||||||||||||||||||||
| 3483 | */ | - | ||||||||||||||||||||||||||||||
| 3484 | void QXmlStreamWriter::writeAttributes(const QXmlStreamAttributes& attributes) | - | ||||||||||||||||||||||||||||||
| 3485 | { | - | ||||||||||||||||||||||||||||||
| 3486 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3487 | Q_ASSERT(d->inStartElement); | - | ||||||||||||||||||||||||||||||
| 3488 | Q_UNUSED(d); | - | ||||||||||||||||||||||||||||||
| 3489 | for (int i = 0; i < attributes.size(); ++i)
| 0-4 | ||||||||||||||||||||||||||||||
| 3490 | writeAttribute(attributes.at(i)); never executed: writeAttribute(attributes.at(i)); | 0 | ||||||||||||||||||||||||||||||
| 3491 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 3492 | - | |||||||||||||||||||||||||||||||
| 3493 | - | |||||||||||||||||||||||||||||||
| 3494 | /*! Writes \a text as CDATA section. If \a text contains the | - | ||||||||||||||||||||||||||||||
| 3495 | forbidden character sequence "]]>", it is split into different CDATA | - | ||||||||||||||||||||||||||||||
| 3496 | sections. | - | ||||||||||||||||||||||||||||||
| 3497 | - | |||||||||||||||||||||||||||||||
| 3498 | This function mainly exists for completeness. Normally you should | - | ||||||||||||||||||||||||||||||
| 3499 | not need use it, because writeCharacters() automatically escapes all | - | ||||||||||||||||||||||||||||||
| 3500 | non-content characters. | - | ||||||||||||||||||||||||||||||
| 3501 | */ | - | ||||||||||||||||||||||||||||||
| 3502 | void QXmlStreamWriter::writeCDATA(const QString &text) | - | ||||||||||||||||||||||||||||||
| 3503 | { | - | ||||||||||||||||||||||||||||||
| 3504 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3505 | d->finishStartElement(); | - | ||||||||||||||||||||||||||||||
| 3506 | QString copy(text); | - | ||||||||||||||||||||||||||||||
| 3507 | copy.replace(QLatin1String("]]>"), QLatin1String("]]]]><![CDATA[>")); | - | ||||||||||||||||||||||||||||||
| 3508 | d->write("<![CDATA["); | - | ||||||||||||||||||||||||||||||
| 3509 | d->write(copy); | - | ||||||||||||||||||||||||||||||
| 3510 | d->write("]]>"); | - | ||||||||||||||||||||||||||||||
| 3511 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3512 | - | |||||||||||||||||||||||||||||||
| 3513 | - | |||||||||||||||||||||||||||||||
| 3514 | /*! Writes \a text. The characters "<", "&", and "\"" are escaped as entity | - | ||||||||||||||||||||||||||||||
| 3515 | references "<", "&, and """. To avoid the forbidden sequence | - | ||||||||||||||||||||||||||||||
| 3516 | "]]>", ">" is also escaped as ">". | - | ||||||||||||||||||||||||||||||
| 3517 | - | |||||||||||||||||||||||||||||||
| 3518 | \sa writeEntityReference() | - | ||||||||||||||||||||||||||||||
| 3519 | */ | - | ||||||||||||||||||||||||||||||
| 3520 | void QXmlStreamWriter::writeCharacters(const QString &text) | - | ||||||||||||||||||||||||||||||
| 3521 | { | - | ||||||||||||||||||||||||||||||
| 3522 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3523 | d->finishStartElement(); | - | ||||||||||||||||||||||||||||||
| 3524 | d->writeEscaped(text); | - | ||||||||||||||||||||||||||||||
| 3525 | } executed 2825 times by 3 tests: end of blockExecuted by:
| 2825 | ||||||||||||||||||||||||||||||
| 3526 | - | |||||||||||||||||||||||||||||||
| 3527 | - | |||||||||||||||||||||||||||||||
| 3528 | /*! Writes \a text as XML comment, where \a text must not contain the | - | ||||||||||||||||||||||||||||||
| 3529 | forbidden sequence "--" or end with "-". Note that XML does not | - | ||||||||||||||||||||||||||||||
| 3530 | provide any way to escape "-" in a comment. | - | ||||||||||||||||||||||||||||||
| 3531 | */ | - | ||||||||||||||||||||||||||||||
| 3532 | void QXmlStreamWriter::writeComment(const QString &text) | - | ||||||||||||||||||||||||||||||
| 3533 | { | - | ||||||||||||||||||||||||||||||
| 3534 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3535 | Q_ASSERT(!text.contains(QLatin1String("--")) && !text.endsWith(QLatin1Char('-'))); | - | ||||||||||||||||||||||||||||||
| 3536 | if (!d->finishStartElement(false) && d->autoFormatting)
| 0-7 | ||||||||||||||||||||||||||||||
| 3537 | d->indent(d->tagStack.size()); executed 7 times by 1 test: d->indent(d->tagStack.size());Executed by:
| 7 | ||||||||||||||||||||||||||||||
| 3538 | d->write("<!--"); | - | ||||||||||||||||||||||||||||||
| 3539 | d->write(text); | - | ||||||||||||||||||||||||||||||
| 3540 | d->write("-->"); | - | ||||||||||||||||||||||||||||||
| 3541 | d->inStartElement = d->lastWasStartElement = false; | - | ||||||||||||||||||||||||||||||
| 3542 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||||||||
| 3543 | - | |||||||||||||||||||||||||||||||
| 3544 | - | |||||||||||||||||||||||||||||||
| 3545 | /*! Writes a DTD section. The \a dtd represents the entire | - | ||||||||||||||||||||||||||||||
| 3546 | doctypedecl production from the XML 1.0 specification. | - | ||||||||||||||||||||||||||||||
| 3547 | */ | - | ||||||||||||||||||||||||||||||
| 3548 | void QXmlStreamWriter::writeDTD(const QString &dtd) | - | ||||||||||||||||||||||||||||||
| 3549 | { | - | ||||||||||||||||||||||||||||||
| 3550 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3551 | d->finishStartElement(); | - | ||||||||||||||||||||||||||||||
| 3552 | if (d->autoFormatting)
| 0-46 | ||||||||||||||||||||||||||||||
| 3553 | d->write("\n"); never executed: d->write("\n"); | 0 | ||||||||||||||||||||||||||||||
| 3554 | d->write(dtd); | - | ||||||||||||||||||||||||||||||
| 3555 | if (d->autoFormatting)
| 0-46 | ||||||||||||||||||||||||||||||
| 3556 | d->write("\n"); never executed: d->write("\n"); | 0 | ||||||||||||||||||||||||||||||
| 3557 | } executed 46 times by 1 test: end of blockExecuted by:
| 46 | ||||||||||||||||||||||||||||||
| 3558 | - | |||||||||||||||||||||||||||||||
| 3559 | - | |||||||||||||||||||||||||||||||
| 3560 | - | |||||||||||||||||||||||||||||||
| 3561 | /*! \overload | - | ||||||||||||||||||||||||||||||
| 3562 | Writes an empty element with qualified name \a qualifiedName. | - | ||||||||||||||||||||||||||||||
| 3563 | Subsequent calls to writeAttribute() will add attributes to this element. | - | ||||||||||||||||||||||||||||||
| 3564 | */ | - | ||||||||||||||||||||||||||||||
| 3565 | void QXmlStreamWriter::writeEmptyElement(const QString &qualifiedName) | - | ||||||||||||||||||||||||||||||
| 3566 | { | - | ||||||||||||||||||||||||||||||
| 3567 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3568 | Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1); | - | ||||||||||||||||||||||||||||||
| 3569 | d->writeStartElement(QString(), qualifiedName); | - | ||||||||||||||||||||||||||||||
| 3570 | d->inEmptyElement = true; | - | ||||||||||||||||||||||||||||||
| 3571 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||||||||
| 3572 | - | |||||||||||||||||||||||||||||||
| 3573 | - | |||||||||||||||||||||||||||||||
| 3574 | /*! Writes an empty element with \a name, prefixed for the specified | - | ||||||||||||||||||||||||||||||
| 3575 | \a namespaceUri. If the namespace has not been declared, | - | ||||||||||||||||||||||||||||||
| 3576 | QXmlStreamWriter will generate a namespace declaration for it. | - | ||||||||||||||||||||||||||||||
| 3577 | Subsequent calls to writeAttribute() will add attributes to this element. | - | ||||||||||||||||||||||||||||||
| 3578 | - | |||||||||||||||||||||||||||||||
| 3579 | \sa writeNamespace() | - | ||||||||||||||||||||||||||||||
| 3580 | */ | - | ||||||||||||||||||||||||||||||
| 3581 | void QXmlStreamWriter::writeEmptyElement(const QString &namespaceUri, const QString &name) | - | ||||||||||||||||||||||||||||||
| 3582 | { | - | ||||||||||||||||||||||||||||||
| 3583 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3584 | Q_ASSERT(!name.contains(QLatin1Char(':'))); | - | ||||||||||||||||||||||||||||||
| 3585 | d->writeStartElement(namespaceUri, name); | - | ||||||||||||||||||||||||||||||
| 3586 | d->inEmptyElement = true; | - | ||||||||||||||||||||||||||||||
| 3587 | } executed 34 times by 2 tests: end of blockExecuted by:
| 34 | ||||||||||||||||||||||||||||||
| 3588 | - | |||||||||||||||||||||||||||||||
| 3589 | - | |||||||||||||||||||||||||||||||
| 3590 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 3591 | Writes a text element with \a qualifiedName and \a text. | - | ||||||||||||||||||||||||||||||
| 3592 | - | |||||||||||||||||||||||||||||||
| 3593 | - | |||||||||||||||||||||||||||||||
| 3594 | This is a convenience function equivalent to: | - | ||||||||||||||||||||||||||||||
| 3595 | \snippet code/src_corelib_xml_qxmlstream.cpp 1 | - | ||||||||||||||||||||||||||||||
| 3596 | - | |||||||||||||||||||||||||||||||
| 3597 | */ | - | ||||||||||||||||||||||||||||||
| 3598 | void QXmlStreamWriter::writeTextElement(const QString &qualifiedName, const QString &text) | - | ||||||||||||||||||||||||||||||
| 3599 | { | - | ||||||||||||||||||||||||||||||
| 3600 | writeStartElement(qualifiedName); | - | ||||||||||||||||||||||||||||||
| 3601 | writeCharacters(text); | - | ||||||||||||||||||||||||||||||
| 3602 | writeEndElement(); | - | ||||||||||||||||||||||||||||||
| 3603 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 3604 | - | |||||||||||||||||||||||||||||||
| 3605 | /*! Writes a text element with \a name, prefixed for the specified \a | - | ||||||||||||||||||||||||||||||
| 3606 | namespaceUri, and \a text. If the namespace has not been | - | ||||||||||||||||||||||||||||||
| 3607 | declared, QXmlStreamWriter will generate a namespace declaration | - | ||||||||||||||||||||||||||||||
| 3608 | for it. | - | ||||||||||||||||||||||||||||||
| 3609 | - | |||||||||||||||||||||||||||||||
| 3610 | - | |||||||||||||||||||||||||||||||
| 3611 | This is a convenience function equivalent to: | - | ||||||||||||||||||||||||||||||
| 3612 | \snippet code/src_corelib_xml_qxmlstream.cpp 2 | - | ||||||||||||||||||||||||||||||
| 3613 | - | |||||||||||||||||||||||||||||||
| 3614 | */ | - | ||||||||||||||||||||||||||||||
| 3615 | void QXmlStreamWriter::writeTextElement(const QString &namespaceUri, const QString &name, const QString &text) | - | ||||||||||||||||||||||||||||||
| 3616 | { | - | ||||||||||||||||||||||||||||||
| 3617 | writeStartElement(namespaceUri, name); | - | ||||||||||||||||||||||||||||||
| 3618 | writeCharacters(text); | - | ||||||||||||||||||||||||||||||
| 3619 | writeEndElement(); | - | ||||||||||||||||||||||||||||||
| 3620 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3621 | - | |||||||||||||||||||||||||||||||
| 3622 | - | |||||||||||||||||||||||||||||||
| 3623 | /*! | - | ||||||||||||||||||||||||||||||
| 3624 | Closes all remaining open start elements and writes a newline. | - | ||||||||||||||||||||||||||||||
| 3625 | - | |||||||||||||||||||||||||||||||
| 3626 | \sa writeStartDocument() | - | ||||||||||||||||||||||||||||||
| 3627 | */ | - | ||||||||||||||||||||||||||||||
| 3628 | void QXmlStreamWriter::writeEndDocument() | - | ||||||||||||||||||||||||||||||
| 3629 | { | - | ||||||||||||||||||||||||||||||
| 3630 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3631 | while (d->tagStack.size())
| 14-33 | ||||||||||||||||||||||||||||||
| 3632 | writeEndElement(); executed 14 times by 3 tests: writeEndElement();Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 3633 | d->write("\n"); | - | ||||||||||||||||||||||||||||||
| 3634 | } executed 33 times by 3 tests: end of blockExecuted by:
| 33 | ||||||||||||||||||||||||||||||
| 3635 | - | |||||||||||||||||||||||||||||||
| 3636 | /*! | - | ||||||||||||||||||||||||||||||
| 3637 | Closes the previous start element. | - | ||||||||||||||||||||||||||||||
| 3638 | - | |||||||||||||||||||||||||||||||
| 3639 | \sa writeStartElement() | - | ||||||||||||||||||||||||||||||
| 3640 | */ | - | ||||||||||||||||||||||||||||||
| 3641 | void QXmlStreamWriter::writeEndElement() | - | ||||||||||||||||||||||||||||||
| 3642 | { | - | ||||||||||||||||||||||||||||||
| 3643 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3644 | if (d->tagStack.isEmpty())
| 1-1255 | ||||||||||||||||||||||||||||||
| 3645 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3646 | - | |||||||||||||||||||||||||||||||
| 3647 | // shortcut: if nothing was written, close as empty tag | - | ||||||||||||||||||||||||||||||
| 3648 | if (d->inStartElement && !d->inEmptyElement) {
| 14-1213 | ||||||||||||||||||||||||||||||
| 3649 | d->write("/>"); | - | ||||||||||||||||||||||||||||||
| 3650 | d->lastWasStartElement = d->inStartElement = false; | - | ||||||||||||||||||||||||||||||
| 3651 | QXmlStreamWriterPrivate::Tag &tag = d->tagStack_pop(); | - | ||||||||||||||||||||||||||||||
| 3652 | d->lastNamespaceDeclaration = tag.namespaceDeclarationsSize; | - | ||||||||||||||||||||||||||||||
| 3653 | return; executed 14 times by 3 tests: return;Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 3654 | } | - | ||||||||||||||||||||||||||||||
| 3655 | - | |||||||||||||||||||||||||||||||
| 3656 | if (!d->finishStartElement(false) && !d->lastWasStartElement && d->autoFormatting)
| 7-1096 | ||||||||||||||||||||||||||||||
| 3657 | d->indent(d->tagStack.size()-1); executed 77 times by 3 tests: d->indent(d->tagStack.size()-1);Executed by:
| 77 | ||||||||||||||||||||||||||||||
| 3658 | if (d->tagStack.isEmpty())
| 4-1237 | ||||||||||||||||||||||||||||||
| 3659 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 3660 | d->lastWasStartElement = false; | - | ||||||||||||||||||||||||||||||
| 3661 | QXmlStreamWriterPrivate::Tag &tag = d->tagStack_pop(); | - | ||||||||||||||||||||||||||||||
| 3662 | d->lastNamespaceDeclaration = tag.namespaceDeclarationsSize; | - | ||||||||||||||||||||||||||||||
| 3663 | d->write("</"); | - | ||||||||||||||||||||||||||||||
| 3664 | if (!tag.namespaceDeclaration.prefix.isEmpty()) {
| 105-1132 | ||||||||||||||||||||||||||||||
| 3665 | d->write(tag.namespaceDeclaration.prefix); | - | ||||||||||||||||||||||||||||||
| 3666 | d->write(":"); | - | ||||||||||||||||||||||||||||||
| 3667 | } executed 105 times by 3 tests: end of blockExecuted by:
| 105 | ||||||||||||||||||||||||||||||
| 3668 | d->write(tag.name); | - | ||||||||||||||||||||||||||||||
| 3669 | d->write(">"); | - | ||||||||||||||||||||||||||||||
| 3670 | } executed 1237 times by 3 tests: end of blockExecuted by:
| 1237 | ||||||||||||||||||||||||||||||
| 3671 | - | |||||||||||||||||||||||||||||||
| 3672 | - | |||||||||||||||||||||||||||||||
| 3673 | - | |||||||||||||||||||||||||||||||
| 3674 | /*! | - | ||||||||||||||||||||||||||||||
| 3675 | Writes the entity reference \a name to the stream, as "&\a{name};". | - | ||||||||||||||||||||||||||||||
| 3676 | */ | - | ||||||||||||||||||||||||||||||
| 3677 | void QXmlStreamWriter::writeEntityReference(const QString &name) | - | ||||||||||||||||||||||||||||||
| 3678 | { | - | ||||||||||||||||||||||||||||||
| 3679 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3680 | d->finishStartElement(); | - | ||||||||||||||||||||||||||||||
| 3681 | d->write("&"); | - | ||||||||||||||||||||||||||||||
| 3682 | d->write(name); | - | ||||||||||||||||||||||||||||||
| 3683 | d->write(";"); | - | ||||||||||||||||||||||||||||||
| 3684 | } executed 857 times by 1 test: end of blockExecuted by:
| 857 | ||||||||||||||||||||||||||||||
| 3685 | - | |||||||||||||||||||||||||||||||
| 3686 | - | |||||||||||||||||||||||||||||||
| 3687 | /*! Writes a namespace declaration for \a namespaceUri with \a | - | ||||||||||||||||||||||||||||||
| 3688 | prefix. If \a prefix is empty, QXmlStreamWriter assigns a unique | - | ||||||||||||||||||||||||||||||
| 3689 | prefix consisting of the letter 'n' followed by a number. | - | ||||||||||||||||||||||||||||||
| 3690 | - | |||||||||||||||||||||||||||||||
| 3691 | If writeStartElement() or writeEmptyElement() was called, the | - | ||||||||||||||||||||||||||||||
| 3692 | declaration applies to the current element; otherwise it applies to | - | ||||||||||||||||||||||||||||||
| 3693 | the next child element. | - | ||||||||||||||||||||||||||||||
| 3694 | - | |||||||||||||||||||||||||||||||
| 3695 | Note that the prefix \e xml is both predefined and reserved for | - | ||||||||||||||||||||||||||||||
| 3696 | \e http://www.w3.org/XML/1998/namespace, which in turn cannot be | - | ||||||||||||||||||||||||||||||
| 3697 | bound to any other prefix. The prefix \e xmlns and its URI | - | ||||||||||||||||||||||||||||||
| 3698 | \e http://www.w3.org/2000/xmlns/ are used for the namespace mechanism | - | ||||||||||||||||||||||||||||||
| 3699 | itself and thus completely forbidden in declarations. | - | ||||||||||||||||||||||||||||||
| 3700 | - | |||||||||||||||||||||||||||||||
| 3701 | */ | - | ||||||||||||||||||||||||||||||
| 3702 | void QXmlStreamWriter::writeNamespace(const QString &namespaceUri, const QString &prefix) | - | ||||||||||||||||||||||||||||||
| 3703 | { | - | ||||||||||||||||||||||||||||||
| 3704 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3705 | Q_ASSERT(!namespaceUri.isEmpty()); | - | ||||||||||||||||||||||||||||||
| 3706 | Q_ASSERT(prefix != QLatin1String("xmlns")); | - | ||||||||||||||||||||||||||||||
| 3707 | if (prefix.isEmpty()) {
| 0-83 | ||||||||||||||||||||||||||||||
| 3708 | d->findNamespace(namespaceUri, d->inStartElement); | - | ||||||||||||||||||||||||||||||
| 3709 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3710 | Q_ASSERT(!((prefix == QLatin1String("xml")) ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))); | - | ||||||||||||||||||||||||||||||
| 3711 | Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/2000/xmlns/")); | - | ||||||||||||||||||||||||||||||
| 3712 | QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 3713 | namespaceDeclaration.prefix = d->addToStringStorage(prefix); | - | ||||||||||||||||||||||||||||||
| 3714 | namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3715 | if (d->inStartElement)
| 2-81 | ||||||||||||||||||||||||||||||
| 3716 | d->writeNamespaceDeclaration(namespaceDeclaration); executed 2 times by 1 test: d->writeNamespaceDeclaration(namespaceDeclaration);Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3717 | } executed 83 times by 3 tests: end of blockExecuted by:
| 83 | ||||||||||||||||||||||||||||||
| 3718 | } | - | ||||||||||||||||||||||||||||||
| 3719 | - | |||||||||||||||||||||||||||||||
| 3720 | - | |||||||||||||||||||||||||||||||
| 3721 | /*! Writes a default namespace declaration for \a namespaceUri. | - | ||||||||||||||||||||||||||||||
| 3722 | - | |||||||||||||||||||||||||||||||
| 3723 | If writeStartElement() or writeEmptyElement() was called, the | - | ||||||||||||||||||||||||||||||
| 3724 | declaration applies to the current element; otherwise it applies to | - | ||||||||||||||||||||||||||||||
| 3725 | the next child element. | - | ||||||||||||||||||||||||||||||
| 3726 | - | |||||||||||||||||||||||||||||||
| 3727 | Note that the namespaces \e http://www.w3.org/XML/1998/namespace | - | ||||||||||||||||||||||||||||||
| 3728 | (bound to \e xmlns) and \e http://www.w3.org/2000/xmlns/ (bound to | - | ||||||||||||||||||||||||||||||
| 3729 | \e xml) by definition cannot be declared as default. | - | ||||||||||||||||||||||||||||||
| 3730 | */ | - | ||||||||||||||||||||||||||||||
| 3731 | void QXmlStreamWriter::writeDefaultNamespace(const QString &namespaceUri) | - | ||||||||||||||||||||||||||||||
| 3732 | { | - | ||||||||||||||||||||||||||||||
| 3733 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3734 | Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/XML/1998/namespace")); | - | ||||||||||||||||||||||||||||||
| 3735 | Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/2000/xmlns/")); | - | ||||||||||||||||||||||||||||||
| 3736 | QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push(); | - | ||||||||||||||||||||||||||||||
| 3737 | namespaceDeclaration.prefix.clear(); | - | ||||||||||||||||||||||||||||||
| 3738 | namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3739 | if (d->inStartElement)
| 0 | ||||||||||||||||||||||||||||||
| 3740 | d->writeNamespaceDeclaration(namespaceDeclaration); never executed: d->writeNamespaceDeclaration(namespaceDeclaration); | 0 | ||||||||||||||||||||||||||||||
| 3741 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3742 | - | |||||||||||||||||||||||||||||||
| 3743 | - | |||||||||||||||||||||||||||||||
| 3744 | /*! | - | ||||||||||||||||||||||||||||||
| 3745 | Writes an XML processing instruction with \a target and \a data, | - | ||||||||||||||||||||||||||||||
| 3746 | where \a data must not contain the sequence "?>". | - | ||||||||||||||||||||||||||||||
| 3747 | */ | - | ||||||||||||||||||||||||||||||
| 3748 | void QXmlStreamWriter::writeProcessingInstruction(const QString &target, const QString &data) | - | ||||||||||||||||||||||||||||||
| 3749 | { | - | ||||||||||||||||||||||||||||||
| 3750 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3751 | Q_ASSERT(!data.contains(QLatin1String("?>"))); | - | ||||||||||||||||||||||||||||||
| 3752 | if (!d->finishStartElement(false) && d->autoFormatting)
| 1-61 | ||||||||||||||||||||||||||||||
| 3753 | d->indent(d->tagStack.size()); executed 1 time by 1 test: d->indent(d->tagStack.size());Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3754 | d->write("<?"); | - | ||||||||||||||||||||||||||||||
| 3755 | d->write(target); | - | ||||||||||||||||||||||||||||||
| 3756 | if (!data.isNull()) {
| 0-72 | ||||||||||||||||||||||||||||||
| 3757 | d->write(" "); | - | ||||||||||||||||||||||||||||||
| 3758 | d->write(data); | - | ||||||||||||||||||||||||||||||
| 3759 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||||||||||||||
| 3760 | d->write("?>"); | - | ||||||||||||||||||||||||||||||
| 3761 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||||||||||||||
| 3762 | - | |||||||||||||||||||||||||||||||
| 3763 | - | |||||||||||||||||||||||||||||||
| 3764 | - | |||||||||||||||||||||||||||||||
| 3765 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 3766 | - | |||||||||||||||||||||||||||||||
| 3767 | Writes a document start with XML version number "1.0". This also | - | ||||||||||||||||||||||||||||||
| 3768 | writes the encoding information. | - | ||||||||||||||||||||||||||||||
| 3769 | - | |||||||||||||||||||||||||||||||
| 3770 | \sa writeEndDocument(), setCodec() | - | ||||||||||||||||||||||||||||||
| 3771 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 3772 | */ | - | ||||||||||||||||||||||||||||||
| 3773 | void QXmlStreamWriter::writeStartDocument() | - | ||||||||||||||||||||||||||||||
| 3774 | { | - | ||||||||||||||||||||||||||||||
| 3775 | writeStartDocument(QLatin1String("1.0")); | - | ||||||||||||||||||||||||||||||
| 3776 | } executed 34 times by 3 tests: end of blockExecuted by:
| 34 | ||||||||||||||||||||||||||||||
| 3777 | - | |||||||||||||||||||||||||||||||
| 3778 | - | |||||||||||||||||||||||||||||||
| 3779 | /*! | - | ||||||||||||||||||||||||||||||
| 3780 | Writes a document start with the XML version number \a version. | - | ||||||||||||||||||||||||||||||
| 3781 | - | |||||||||||||||||||||||||||||||
| 3782 | \sa writeEndDocument() | - | ||||||||||||||||||||||||||||||
| 3783 | */ | - | ||||||||||||||||||||||||||||||
| 3784 | void QXmlStreamWriter::writeStartDocument(const QString &version) | - | ||||||||||||||||||||||||||||||
| 3785 | { | - | ||||||||||||||||||||||||||||||
| 3786 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3787 | d->finishStartElement(false); | - | ||||||||||||||||||||||||||||||
| 3788 | d->write("<?xml version=\""); | - | ||||||||||||||||||||||||||||||
| 3789 | d->write(version); | - | ||||||||||||||||||||||||||||||
| 3790 | if (d->device) { // stringDevice does not get any encoding
| 2-35 | ||||||||||||||||||||||||||||||
| 3791 | d->write("\" encoding=\""); | - | ||||||||||||||||||||||||||||||
| 3792 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3793 | d->write("iso-8859-1"); | - | ||||||||||||||||||||||||||||||
| 3794 | #else | - | ||||||||||||||||||||||||||||||
| 3795 | d->write(d->codec->name().constData(), d->codec->name().length()); | - | ||||||||||||||||||||||||||||||
| 3796 | #endif | - | ||||||||||||||||||||||||||||||
| 3797 | } executed 35 times by 3 tests: end of blockExecuted by:
| 35 | ||||||||||||||||||||||||||||||
| 3798 | d->write("\"?>"); | - | ||||||||||||||||||||||||||||||
| 3799 | } executed 37 times by 3 tests: end of blockExecuted by:
| 37 | ||||||||||||||||||||||||||||||
| 3800 | - | |||||||||||||||||||||||||||||||
| 3801 | /*! Writes a document start with the XML version number \a version | - | ||||||||||||||||||||||||||||||
| 3802 | and a standalone attribute \a standalone. | - | ||||||||||||||||||||||||||||||
| 3803 | - | |||||||||||||||||||||||||||||||
| 3804 | \sa writeEndDocument() | - | ||||||||||||||||||||||||||||||
| 3805 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 3806 | */ | - | ||||||||||||||||||||||||||||||
| 3807 | void QXmlStreamWriter::writeStartDocument(const QString &version, bool standalone) | - | ||||||||||||||||||||||||||||||
| 3808 | { | - | ||||||||||||||||||||||||||||||
| 3809 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3810 | d->finishStartElement(false); | - | ||||||||||||||||||||||||||||||
| 3811 | d->write("<?xml version=\""); | - | ||||||||||||||||||||||||||||||
| 3812 | d->write(version); | - | ||||||||||||||||||||||||||||||
| 3813 | if (d->device) { // stringDevice does not get any encoding
| 0-2 | ||||||||||||||||||||||||||||||
| 3814 | d->write("\" encoding=\""); | - | ||||||||||||||||||||||||||||||
| 3815 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||||||||
| 3816 | d->write("iso-8859-1"); | - | ||||||||||||||||||||||||||||||
| 3817 | #else | - | ||||||||||||||||||||||||||||||
| 3818 | d->write(d->codec->name().constData(), d->codec->name().length()); | - | ||||||||||||||||||||||||||||||
| 3819 | #endif | - | ||||||||||||||||||||||||||||||
| 3820 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 3821 | if (standalone)
| 1 | ||||||||||||||||||||||||||||||
| 3822 | d->write("\" standalone=\"yes\"?>"); executed 1 time by 1 test: d->write("\" standalone=\"yes\"?>");Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3823 | else | - | ||||||||||||||||||||||||||||||
| 3824 | d->write("\" standalone=\"no\"?>"); executed 1 time by 1 test: d->write("\" standalone=\"no\"?>");Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3825 | } | - | ||||||||||||||||||||||||||||||
| 3826 | - | |||||||||||||||||||||||||||||||
| 3827 | - | |||||||||||||||||||||||||||||||
| 3828 | /*!\overload | - | ||||||||||||||||||||||||||||||
| 3829 | - | |||||||||||||||||||||||||||||||
| 3830 | Writes a start element with \a qualifiedName. Subsequent calls to | - | ||||||||||||||||||||||||||||||
| 3831 | writeAttribute() will add attributes to this element. | - | ||||||||||||||||||||||||||||||
| 3832 | - | |||||||||||||||||||||||||||||||
| 3833 | \sa writeEndElement(), writeEmptyElement() | - | ||||||||||||||||||||||||||||||
| 3834 | */ | - | ||||||||||||||||||||||||||||||
| 3835 | void QXmlStreamWriter::writeStartElement(const QString &qualifiedName) | - | ||||||||||||||||||||||||||||||
| 3836 | { | - | ||||||||||||||||||||||||||||||
| 3837 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3838 | Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1); | - | ||||||||||||||||||||||||||||||
| 3839 | d->writeStartElement(QString(), qualifiedName); | - | ||||||||||||||||||||||||||||||
| 3840 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 3841 | - | |||||||||||||||||||||||||||||||
| 3842 | - | |||||||||||||||||||||||||||||||
| 3843 | /*! Writes a start element with \a name, prefixed for the specified | - | ||||||||||||||||||||||||||||||
| 3844 | \a namespaceUri. If the namespace has not been declared yet, | - | ||||||||||||||||||||||||||||||
| 3845 | QXmlStreamWriter will generate a namespace declaration for | - | ||||||||||||||||||||||||||||||
| 3846 | it. Subsequent calls to writeAttribute() will add attributes to this | - | ||||||||||||||||||||||||||||||
| 3847 | element. | - | ||||||||||||||||||||||||||||||
| 3848 | - | |||||||||||||||||||||||||||||||
| 3849 | \sa writeNamespace(), writeEndElement(), writeEmptyElement() | - | ||||||||||||||||||||||||||||||
| 3850 | */ | - | ||||||||||||||||||||||||||||||
| 3851 | void QXmlStreamWriter::writeStartElement(const QString &namespaceUri, const QString &name) | - | ||||||||||||||||||||||||||||||
| 3852 | { | - | ||||||||||||||||||||||||||||||
| 3853 | Q_D(QXmlStreamWriter); | - | ||||||||||||||||||||||||||||||
| 3854 | Q_ASSERT(!name.contains(QLatin1Char(':'))); | - | ||||||||||||||||||||||||||||||
| 3855 | d->writeStartElement(namespaceUri, name); | - | ||||||||||||||||||||||||||||||
| 3856 | } executed 1243 times by 3 tests: end of blockExecuted by:
| 1243 | ||||||||||||||||||||||||||||||
| 3857 | - | |||||||||||||||||||||||||||||||
| 3858 | void QXmlStreamWriterPrivate::writeStartElement(const QString &namespaceUri, const QString &name) | - | ||||||||||||||||||||||||||||||
| 3859 | { | - | ||||||||||||||||||||||||||||||
| 3860 | if (!finishStartElement(false) && autoFormatting)
| 133-845 | ||||||||||||||||||||||||||||||
| 3861 | indent(tagStack.size()); executed 133 times by 3 tests: indent(tagStack.size());Executed by:
| 133 | ||||||||||||||||||||||||||||||
| 3862 | - | |||||||||||||||||||||||||||||||
| 3863 | Tag &tag = tagStack_push(); | - | ||||||||||||||||||||||||||||||
| 3864 | tag.name = addToStringStorage(name); | - | ||||||||||||||||||||||||||||||
| 3865 | tag.namespaceDeclaration = findNamespace(namespaceUri); | - | ||||||||||||||||||||||||||||||
| 3866 | write("<"); | - | ||||||||||||||||||||||||||||||
| 3867 | if (!tag.namespaceDeclaration.prefix.isEmpty()) {
| 149-1143 | ||||||||||||||||||||||||||||||
| 3868 | write(tag.namespaceDeclaration.prefix); | - | ||||||||||||||||||||||||||||||
| 3869 | write(":"); | - | ||||||||||||||||||||||||||||||
| 3870 | } executed 149 times by 3 tests: end of blockExecuted by:
| 149 | ||||||||||||||||||||||||||||||
| 3871 | write(tag.name); | - | ||||||||||||||||||||||||||||||
| 3872 | inStartElement = lastWasStartElement = true; | - | ||||||||||||||||||||||||||||||
| 3873 | - | |||||||||||||||||||||||||||||||
| 3874 | for (int i = lastNamespaceDeclaration; i < namespaceDeclarations.size(); ++i)
| 96-1292 | ||||||||||||||||||||||||||||||
| 3875 | writeNamespaceDeclaration(namespaceDeclarations[i]); executed 96 times by 3 tests: writeNamespaceDeclaration(namespaceDeclarations[i]);Executed by:
| 96 | ||||||||||||||||||||||||||||||
| 3876 | tag.namespaceDeclarationsSize = lastNamespaceDeclaration; | - | ||||||||||||||||||||||||||||||
| 3877 | } executed 1292 times by 3 tests: end of blockExecuted by:
| 1292 | ||||||||||||||||||||||||||||||
| 3878 | - | |||||||||||||||||||||||||||||||
| 3879 | #ifndef QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 3880 | /*! Writes the current state of the \a reader. All possible valid | - | ||||||||||||||||||||||||||||||
| 3881 | states are supported. | - | ||||||||||||||||||||||||||||||
| 3882 | - | |||||||||||||||||||||||||||||||
| 3883 | The purpose of this function is to support chained processing of XML data. | - | ||||||||||||||||||||||||||||||
| 3884 | - | |||||||||||||||||||||||||||||||
| 3885 | \sa QXmlStreamReader::tokenType() | - | ||||||||||||||||||||||||||||||
| 3886 | */ | - | ||||||||||||||||||||||||||||||
| 3887 | void QXmlStreamWriter::writeCurrentToken(const QXmlStreamReader &reader) | - | ||||||||||||||||||||||||||||||
| 3888 | { | - | ||||||||||||||||||||||||||||||
| 3889 | switch (reader.tokenType()) { | - | ||||||||||||||||||||||||||||||
| 3890 | case QXmlStreamReader::NoToken: never executed: case QXmlStreamReader::NoToken: | 0 | ||||||||||||||||||||||||||||||
| 3891 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 3892 | case QXmlStreamReader::StartDocument: executed 2 times by 1 test: case QXmlStreamReader::StartDocument:Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3893 | writeStartDocument(); | - | ||||||||||||||||||||||||||||||
| 3894 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3895 | case QXmlStreamReader::EndDocument: executed 2 times by 1 test: case QXmlStreamReader::EndDocument:Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3896 | writeEndDocument(); | - | ||||||||||||||||||||||||||||||
| 3897 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 3898 | case QXmlStreamReader::StartElement: { executed 4 times by 1 test: case QXmlStreamReader::StartElement:Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 3899 | QXmlStreamNamespaceDeclarations namespaceDeclarations = reader.namespaceDeclarations(); | - | ||||||||||||||||||||||||||||||
| 3900 | for (int i = 0; i < namespaceDeclarations.size(); ++i) {
| 0-4 | ||||||||||||||||||||||||||||||
| 3901 | const QXmlStreamNamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(i); | - | ||||||||||||||||||||||||||||||
| 3902 | writeNamespace(namespaceDeclaration.namespaceUri().toString(), | - | ||||||||||||||||||||||||||||||
| 3903 | namespaceDeclaration.prefix().toString()); | - | ||||||||||||||||||||||||||||||
| 3904 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3905 | writeStartElement(reader.namespaceUri().toString(), reader.name().toString()); | - | ||||||||||||||||||||||||||||||
| 3906 | writeAttributes(reader.attributes()); | - | ||||||||||||||||||||||||||||||
| 3907 | } break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 3908 | case QXmlStreamReader::EndElement: executed 1144 times by 1 test: case QXmlStreamReader::EndElement:Executed by:
| 1144 | ||||||||||||||||||||||||||||||
| 3909 | writeEndElement(); | - | ||||||||||||||||||||||||||||||
| 3910 | break; executed 1144 times by 1 test: break;Executed by:
| 1144 | ||||||||||||||||||||||||||||||
| 3911 | case QXmlStreamReader::Characters: never executed: case QXmlStreamReader::Characters: | 0 | ||||||||||||||||||||||||||||||
| 3912 | if (reader.isCDATA())
| 0 | ||||||||||||||||||||||||||||||
| 3913 | writeCDATA(reader.text().toString()); never executed: writeCDATA(reader.text().toString()); | 0 | ||||||||||||||||||||||||||||||
| 3914 | else | - | ||||||||||||||||||||||||||||||
| 3915 | writeCharacters(reader.text().toString()); never executed: writeCharacters(reader.text().toString()); | 0 | ||||||||||||||||||||||||||||||
| 3916 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 3917 | case QXmlStreamReader::Comment: executed 6 times by 1 test: case QXmlStreamReader::Comment:Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 3918 | writeComment(reader.text().toString()); | - | ||||||||||||||||||||||||||||||
| 3919 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 3920 | case QXmlStreamReader::DTD: never executed: case QXmlStreamReader::DTD: | 0 | ||||||||||||||||||||||||||||||
| 3921 | writeDTD(reader.text().toString()); | - | ||||||||||||||||||||||||||||||
| 3922 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 3923 | case QXmlStreamReader::EntityReference: executed 1 time by 1 test: case QXmlStreamReader::EntityReference:Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3924 | writeEntityReference(reader.name().toString()); | - | ||||||||||||||||||||||||||||||
| 3925 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 3926 | case QXmlStreamReader::ProcessingInstruction: executed 48 times by 1 test: case QXmlStreamReader::ProcessingInstruction:Executed by:
| 48 | ||||||||||||||||||||||||||||||
| 3927 | writeProcessingInstruction(reader.processingInstructionTarget().toString(), | - | ||||||||||||||||||||||||||||||
| 3928 | reader.processingInstructionData().toString()); | - | ||||||||||||||||||||||||||||||
| 3929 | break; executed 48 times by 1 test: break;Executed by:
| 48 | ||||||||||||||||||||||||||||||
| 3930 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 3931 | Q_ASSERT(reader.tokenType() != QXmlStreamReader::Invalid); | - | ||||||||||||||||||||||||||||||
| 3932 | qWarning("QXmlStreamWriter: writeCurrentToken() with invalid state."); | - | ||||||||||||||||||||||||||||||
| 3933 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 3934 | } | - | ||||||||||||||||||||||||||||||
| 3935 | } | - | ||||||||||||||||||||||||||||||
| 3936 | - | |||||||||||||||||||||||||||||||
| 3937 | /*! | - | ||||||||||||||||||||||||||||||
| 3938 | \fn bool QXmlStreamAttributes::hasAttribute(const QString &qualifiedName) const | - | ||||||||||||||||||||||||||||||
| 3939 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 3940 | - | |||||||||||||||||||||||||||||||
| 3941 | Returns \c true if this QXmlStreamAttributes has an attribute whose | - | ||||||||||||||||||||||||||||||
| 3942 | qualified name is \a qualifiedName; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 3943 | - | |||||||||||||||||||||||||||||||
| 3944 | Note that this is not namespace aware. For instance, if this | - | ||||||||||||||||||||||||||||||
| 3945 | QXmlStreamAttributes contains an attribute whose lexical name is "xlink:href" | - | ||||||||||||||||||||||||||||||
| 3946 | this doesn't tell that an attribute named \c href in the XLink namespace is | - | ||||||||||||||||||||||||||||||
| 3947 | present, since the \c xlink prefix can be bound to any namespace. Use the | - | ||||||||||||||||||||||||||||||
| 3948 | overload that takes a namespace URI and a local name as parameter, for | - | ||||||||||||||||||||||||||||||
| 3949 | namespace aware code. | - | ||||||||||||||||||||||||||||||
| 3950 | */ | - | ||||||||||||||||||||||||||||||
| 3951 | - | |||||||||||||||||||||||||||||||
| 3952 | /*! | - | ||||||||||||||||||||||||||||||
| 3953 | \fn bool QXmlStreamAttributes::hasAttribute(QLatin1String qualifiedName) const | - | ||||||||||||||||||||||||||||||
| 3954 | \overload | - | ||||||||||||||||||||||||||||||
| 3955 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 3956 | */ | - | ||||||||||||||||||||||||||||||
| 3957 | - | |||||||||||||||||||||||||||||||
| 3958 | /*! | - | ||||||||||||||||||||||||||||||
| 3959 | \fn bool QXmlStreamAttributes::hasAttribute(const QString &namespaceUri, | - | ||||||||||||||||||||||||||||||
| 3960 | const QString &name) const | - | ||||||||||||||||||||||||||||||
| 3961 | \overload | - | ||||||||||||||||||||||||||||||
| 3962 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 3963 | - | |||||||||||||||||||||||||||||||
| 3964 | Returns \c true if this QXmlStreamAttributes has an attribute whose | - | ||||||||||||||||||||||||||||||
| 3965 | namespace URI and name correspond to \a namespaceUri and \a name; | - | ||||||||||||||||||||||||||||||
| 3966 | otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 3967 | */ | - | ||||||||||||||||||||||||||||||
| 3968 | - | |||||||||||||||||||||||||||||||
| 3969 | #endif // QT_NO_XMLSTREAMREADER | - | ||||||||||||||||||||||||||||||
| 3970 | #endif // QT_NO_XMLSTREAMWRITER | - | ||||||||||||||||||||||||||||||
| 3971 | - | |||||||||||||||||||||||||||||||
| 3972 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 3973 | - | |||||||||||||||||||||||||||||||
| 3974 | #endif // QT_NO_XMLSTREAM | - | ||||||||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |