Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/xml/sax/qxml.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 QtXml 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 "qxml.h" | - | ||||||||||||||||||||||||
35 | #include "qxml_p.h" | - | ||||||||||||||||||||||||
36 | #include "qtextcodec.h" | - | ||||||||||||||||||||||||
37 | #include "qbuffer.h" | - | ||||||||||||||||||||||||
38 | #include "qregexp.h" | - | ||||||||||||||||||||||||
39 | #include "qmap.h" | - | ||||||||||||||||||||||||
40 | #include "qhash.h" | - | ||||||||||||||||||||||||
41 | #include "qstack.h" | - | ||||||||||||||||||||||||
42 | #include <qdebug.h> | - | ||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||
45 | #ifdef Q_CC_BOR // borland 6 finds bogus warnings when building this file in uic3 | - | ||||||||||||||||||||||||
46 | # pragma warn -8080 | - | ||||||||||||||||||||||||
47 | #endif | - | ||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | //#define QT_QXML_DEBUG | - | ||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||
51 | // Error strings for the XML reader | - | ||||||||||||||||||||||||
52 | #define XMLERR_OK QT_TRANSLATE_NOOP("QXml", "no error occurred") | - | ||||||||||||||||||||||||
53 | #define XMLERR_ERRORBYCONSUMER QT_TRANSLATE_NOOP("QXml", "error triggered by consumer") | - | ||||||||||||||||||||||||
54 | #define XMLERR_UNEXPECTEDEOF QT_TRANSLATE_NOOP("QXml", "unexpected end of file") | - | ||||||||||||||||||||||||
55 | #define XMLERR_MORETHANONEDOCTYPE QT_TRANSLATE_NOOP("QXml", "more than one document type definition") | - | ||||||||||||||||||||||||
56 | #define XMLERR_ERRORPARSINGELEMENT QT_TRANSLATE_NOOP("QXml", "error occurred while parsing element") | - | ||||||||||||||||||||||||
57 | #define XMLERR_TAGMISMATCH QT_TRANSLATE_NOOP("QXml", "tag mismatch") | - | ||||||||||||||||||||||||
58 | #define XMLERR_ERRORPARSINGCONTENT QT_TRANSLATE_NOOP("QXml", "error occurred while parsing content") | - | ||||||||||||||||||||||||
59 | #define XMLERR_UNEXPECTEDCHARACTER QT_TRANSLATE_NOOP("QXml", "unexpected character") | - | ||||||||||||||||||||||||
60 | #define XMLERR_INVALIDNAMEFORPI QT_TRANSLATE_NOOP("QXml", "invalid name for processing instruction") | - | ||||||||||||||||||||||||
61 | #define XMLERR_VERSIONEXPECTED QT_TRANSLATE_NOOP("QXml", "version expected while reading the XML declaration") | - | ||||||||||||||||||||||||
62 | #define XMLERR_WRONGVALUEFORSDECL QT_TRANSLATE_NOOP("QXml", "wrong value for standalone declaration") | - | ||||||||||||||||||||||||
63 | #define XMLERR_EDECLORSDDECLEXPECTED QT_TRANSLATE_NOOP("QXml", "encoding declaration or standalone declaration expected while reading the XML declaration") | - | ||||||||||||||||||||||||
64 | #define XMLERR_SDDECLEXPECTED QT_TRANSLATE_NOOP("QXml", "standalone declaration expected while reading the XML declaration") | - | ||||||||||||||||||||||||
65 | #define XMLERR_ERRORPARSINGDOCTYPE QT_TRANSLATE_NOOP("QXml", "error occurred while parsing document type definition") | - | ||||||||||||||||||||||||
66 | #define XMLERR_LETTEREXPECTED QT_TRANSLATE_NOOP("QXml", "letter is expected") | - | ||||||||||||||||||||||||
67 | #define XMLERR_ERRORPARSINGCOMMENT QT_TRANSLATE_NOOP("QXml", "error occurred while parsing comment") | - | ||||||||||||||||||||||||
68 | #define XMLERR_ERRORPARSINGREFERENCE QT_TRANSLATE_NOOP("QXml", "error occurred while parsing reference") | - | ||||||||||||||||||||||||
69 | #define XMLERR_INTERNALGENERALENTITYINDTD QT_TRANSLATE_NOOP("QXml", "internal general entity reference not allowed in DTD") | - | ||||||||||||||||||||||||
70 | #define XMLERR_EXTERNALGENERALENTITYINAV QT_TRANSLATE_NOOP("QXml", "external parsed general entity reference not allowed in attribute value") | - | ||||||||||||||||||||||||
71 | #define XMLERR_EXTERNALGENERALENTITYINDTD QT_TRANSLATE_NOOP("QXml", "external parsed general entity reference not allowed in DTD") | - | ||||||||||||||||||||||||
72 | #define XMLERR_UNPARSEDENTITYREFERENCE QT_TRANSLATE_NOOP("QXml", "unparsed entity reference in wrong context") | - | ||||||||||||||||||||||||
73 | #define XMLERR_RECURSIVEENTITIES QT_TRANSLATE_NOOP("QXml", "recursive entities") | - | ||||||||||||||||||||||||
74 | #define XMLERR_ERRORINTEXTDECL QT_TRANSLATE_NOOP("QXml", "error in the text declaration of an external entity") | - | ||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | // the constants for the lookup table | - | ||||||||||||||||||||||||
79 | static const signed char cltWS = 0; // white space | - | ||||||||||||||||||||||||
80 | static const signed char cltPer = 1; // % | - | ||||||||||||||||||||||||
81 | static const signed char cltAmp = 2; // & | - | ||||||||||||||||||||||||
82 | static const signed char cltGt = 3; // > | - | ||||||||||||||||||||||||
83 | static const signed char cltLt = 4; // < | - | ||||||||||||||||||||||||
84 | static const signed char cltSlash = 5; // / | - | ||||||||||||||||||||||||
85 | static const signed char cltQm = 6; // ? | - | ||||||||||||||||||||||||
86 | static const signed char cltEm = 7; // ! | - | ||||||||||||||||||||||||
87 | static const signed char cltDash = 8; // - | - | ||||||||||||||||||||||||
88 | static const signed char cltCB = 9; // ] | - | ||||||||||||||||||||||||
89 | static const signed char cltOB = 10; // [ | - | ||||||||||||||||||||||||
90 | static const signed char cltEq = 11; // = | - | ||||||||||||||||||||||||
91 | static const signed char cltDq = 12; // " | - | ||||||||||||||||||||||||
92 | static const signed char cltSq = 13; // ' | - | ||||||||||||||||||||||||
93 | static const signed char cltUnknown = 14; | - | ||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||
95 | // character lookup table | - | ||||||||||||||||||||||||
96 | static const signed char charLookupTable[256]={ | - | ||||||||||||||||||||||||
97 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x00 - 0x07 | - | ||||||||||||||||||||||||
98 | cltUnknown, // 0x08 | - | ||||||||||||||||||||||||
99 | cltWS, // 0x09 \t | - | ||||||||||||||||||||||||
100 | cltWS, // 0x0A \n | - | ||||||||||||||||||||||||
101 | cltUnknown, // 0x0B | - | ||||||||||||||||||||||||
102 | cltUnknown, // 0x0C | - | ||||||||||||||||||||||||
103 | cltWS, // 0x0D \r | - | ||||||||||||||||||||||||
104 | cltUnknown, // 0x0E | - | ||||||||||||||||||||||||
105 | cltUnknown, // 0x0F | - | ||||||||||||||||||||||||
106 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x17 - 0x16 | - | ||||||||||||||||||||||||
107 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x18 - 0x1F | - | ||||||||||||||||||||||||
108 | cltWS, // 0x20 Space | - | ||||||||||||||||||||||||
109 | cltEm, // 0x21 ! | - | ||||||||||||||||||||||||
110 | cltDq, // 0x22 " | - | ||||||||||||||||||||||||
111 | cltUnknown, // 0x23 | - | ||||||||||||||||||||||||
112 | cltUnknown, // 0x24 | - | ||||||||||||||||||||||||
113 | cltPer, // 0x25 % | - | ||||||||||||||||||||||||
114 | cltAmp, // 0x26 & | - | ||||||||||||||||||||||||
115 | cltSq, // 0x27 ' | - | ||||||||||||||||||||||||
116 | cltUnknown, // 0x28 | - | ||||||||||||||||||||||||
117 | cltUnknown, // 0x29 | - | ||||||||||||||||||||||||
118 | cltUnknown, // 0x2A | - | ||||||||||||||||||||||||
119 | cltUnknown, // 0x2B | - | ||||||||||||||||||||||||
120 | cltUnknown, // 0x2C | - | ||||||||||||||||||||||||
121 | cltDash, // 0x2D - | - | ||||||||||||||||||||||||
122 | cltUnknown, // 0x2E | - | ||||||||||||||||||||||||
123 | cltSlash, // 0x2F / | - | ||||||||||||||||||||||||
124 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x30 - 0x37 | - | ||||||||||||||||||||||||
125 | cltUnknown, // 0x38 | - | ||||||||||||||||||||||||
126 | cltUnknown, // 0x39 | - | ||||||||||||||||||||||||
127 | cltUnknown, // 0x3A | - | ||||||||||||||||||||||||
128 | cltUnknown, // 0x3B | - | ||||||||||||||||||||||||
129 | cltLt, // 0x3C < | - | ||||||||||||||||||||||||
130 | cltEq, // 0x3D = | - | ||||||||||||||||||||||||
131 | cltGt, // 0x3E > | - | ||||||||||||||||||||||||
132 | cltQm, // 0x3F ? | - | ||||||||||||||||||||||||
133 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x40 - 0x47 | - | ||||||||||||||||||||||||
134 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x48 - 0x4F | - | ||||||||||||||||||||||||
135 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x50 - 0x57 | - | ||||||||||||||||||||||||
136 | cltUnknown, // 0x58 | - | ||||||||||||||||||||||||
137 | cltUnknown, // 0x59 | - | ||||||||||||||||||||||||
138 | cltUnknown, // 0x5A | - | ||||||||||||||||||||||||
139 | cltOB, // 0x5B [ | - | ||||||||||||||||||||||||
140 | cltUnknown, // 0x5C | - | ||||||||||||||||||||||||
141 | cltCB, // 0x5D] | - | ||||||||||||||||||||||||
142 | cltUnknown, // 0x5E | - | ||||||||||||||||||||||||
143 | cltUnknown, // 0x5F | - | ||||||||||||||||||||||||
144 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x60 - 0x67 | - | ||||||||||||||||||||||||
145 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x68 - 0x6F | - | ||||||||||||||||||||||||
146 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x70 - 0x77 | - | ||||||||||||||||||||||||
147 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x78 - 0x7F | - | ||||||||||||||||||||||||
148 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x80 - 0x87 | - | ||||||||||||||||||||||||
149 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x88 - 0x8F | - | ||||||||||||||||||||||||
150 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x90 - 0x97 | - | ||||||||||||||||||||||||
151 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0x98 - 0x9F | - | ||||||||||||||||||||||||
152 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xA0 - 0xA7 | - | ||||||||||||||||||||||||
153 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xA8 - 0xAF | - | ||||||||||||||||||||||||
154 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xB0 - 0xB7 | - | ||||||||||||||||||||||||
155 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xB8 - 0xBF | - | ||||||||||||||||||||||||
156 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xC0 - 0xC7 | - | ||||||||||||||||||||||||
157 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xC8 - 0xCF | - | ||||||||||||||||||||||||
158 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xD0 - 0xD7 | - | ||||||||||||||||||||||||
159 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xD8 - 0xDF | - | ||||||||||||||||||||||||
160 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xE0 - 0xE7 | - | ||||||||||||||||||||||||
161 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xE8 - 0xEF | - | ||||||||||||||||||||||||
162 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, // 0xF0 - 0xF7 | - | ||||||||||||||||||||||||
163 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown // 0xF8 - 0xFF | - | ||||||||||||||||||||||||
164 | }; | - | ||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | // | - | ||||||||||||||||||||||||
167 | // local helper functions | - | ||||||||||||||||||||||||
168 | // | - | ||||||||||||||||||||||||
169 | - | |||||||||||||||||||||||||
170 | /* | - | ||||||||||||||||||||||||
171 | This function strips the TextDecl [77] ("<?xml ...?>") from the string \a | - | ||||||||||||||||||||||||
172 | str. The stripped version is stored in \a str. If this function finds an | - | ||||||||||||||||||||||||
173 | invalid TextDecl, it returns \c false, otherwise true. | - | ||||||||||||||||||||||||
174 | - | |||||||||||||||||||||||||
175 | This function is used for external entities since those can include an | - | ||||||||||||||||||||||||
176 | TextDecl that must be stripped before inserting the entity. | - | ||||||||||||||||||||||||
177 | */ | - | ||||||||||||||||||||||||
178 | static bool stripTextDecl(QString& str) | - | ||||||||||||||||||||||||
179 | { | - | ||||||||||||||||||||||||
180 | QString textDeclStart(QLatin1String("<?xml")); | - | ||||||||||||||||||||||||
181 | if (str.startsWith(textDeclStart)) {
| 0 | ||||||||||||||||||||||||
182 | QRegExp textDecl(QString::fromLatin1( | - | ||||||||||||||||||||||||
183 | "^<\\?xml\\s+" | - | ||||||||||||||||||||||||
184 | "(version\\s*=\\s*((['\"])[-a-zA-Z0-9_.:]+\\3))?" | - | ||||||||||||||||||||||||
185 | "\\s*" | - | ||||||||||||||||||||||||
186 | "(encoding\\s*=\\s*((['\"])[A-Za-z][-a-zA-Z0-9_.]*\\6))?" | - | ||||||||||||||||||||||||
187 | "\\s*\\?>" | - | ||||||||||||||||||||||||
188 | )); | - | ||||||||||||||||||||||||
189 | QString strTmp = str.replace(textDecl, QLatin1String("")); | - | ||||||||||||||||||||||||
190 | if (strTmp.length() != str.length())
| 0 | ||||||||||||||||||||||||
191 | return false; // external entity has wrong TextDecl never executed: return false; | 0 | ||||||||||||||||||||||||
192 | str = strTmp; | - | ||||||||||||||||||||||||
193 | } never executed: end of block | 0 | ||||||||||||||||||||||||
194 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
195 | } | - | ||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||
197 | - | |||||||||||||||||||||||||
198 | class QXmlAttributesPrivate | - | ||||||||||||||||||||||||
199 | { | - | ||||||||||||||||||||||||
200 | }; | - | ||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||
202 | /* \class QXmlInputSourcePrivate | - | ||||||||||||||||||||||||
203 | \internal | - | ||||||||||||||||||||||||
204 | - | |||||||||||||||||||||||||
205 | There's a slight misdesign in this class that can | - | ||||||||||||||||||||||||
206 | be worth to keep in mind: the `str' member is | - | ||||||||||||||||||||||||
207 | a buffer which QXmlInputSource::next() returns from, | - | ||||||||||||||||||||||||
208 | and which is populated from the input device or input | - | ||||||||||||||||||||||||
209 | stream. However, when the input is a QString(the user called | - | ||||||||||||||||||||||||
210 | QXmlInputSource::setData()), `str' has two roles: it's the | - | ||||||||||||||||||||||||
211 | buffer, but also the source. This /seems/ to be no problem | - | ||||||||||||||||||||||||
212 | because in the case of having no device or stream, the QString | - | ||||||||||||||||||||||||
213 | is read in one go. | - | ||||||||||||||||||||||||
214 | */ | - | ||||||||||||||||||||||||
215 | class QXmlInputSourcePrivate | - | ||||||||||||||||||||||||
216 | { | - | ||||||||||||||||||||||||
217 | public: | - | ||||||||||||||||||||||||
218 | QIODevice *inputDevice; | - | ||||||||||||||||||||||||
219 | QTextStream *inputStream; | - | ||||||||||||||||||||||||
220 | - | |||||||||||||||||||||||||
221 | QString str; | - | ||||||||||||||||||||||||
222 | const QChar *unicode; | - | ||||||||||||||||||||||||
223 | int pos; | - | ||||||||||||||||||||||||
224 | int length; | - | ||||||||||||||||||||||||
225 | bool nextReturnedEndOfData; | - | ||||||||||||||||||||||||
226 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||
227 | QTextDecoder *encMapper; | - | ||||||||||||||||||||||||
228 | #endif | - | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | QByteArray encodingDeclBytes; | - | ||||||||||||||||||||||||
231 | QString encodingDeclChars; | - | ||||||||||||||||||||||||
232 | bool lookingForEncodingDecl; | - | ||||||||||||||||||||||||
233 | }; | - | ||||||||||||||||||||||||
234 | class QXmlParseExceptionPrivate | - | ||||||||||||||||||||||||
235 | { | - | ||||||||||||||||||||||||
236 | public: | - | ||||||||||||||||||||||||
237 | QXmlParseExceptionPrivate() | - | ||||||||||||||||||||||||
238 | : column(-1), line(-1) | - | ||||||||||||||||||||||||
239 | { | - | ||||||||||||||||||||||||
240 | } executed 155 times by 1 test: end of block Executed by:
| 155 | ||||||||||||||||||||||||
241 | QXmlParseExceptionPrivate(const QXmlParseExceptionPrivate &other) | - | ||||||||||||||||||||||||
242 | : msg(other.msg), column(other.column), line(other.line), | - | ||||||||||||||||||||||||
243 | pub(other.pub), sys(other.sys) | - | ||||||||||||||||||||||||
244 | { | - | ||||||||||||||||||||||||
245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | QString msg; | - | ||||||||||||||||||||||||
248 | int column; | - | ||||||||||||||||||||||||
249 | int line; | - | ||||||||||||||||||||||||
250 | QString pub; | - | ||||||||||||||||||||||||
251 | QString sys; | - | ||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||
253 | }; | - | ||||||||||||||||||||||||
254 | - | |||||||||||||||||||||||||
255 | class QXmlLocatorPrivate | - | ||||||||||||||||||||||||
256 | { | - | ||||||||||||||||||||||||
257 | }; | - | ||||||||||||||||||||||||
258 | - | |||||||||||||||||||||||||
259 | class QXmlDefaultHandlerPrivate | - | ||||||||||||||||||||||||
260 | { | - | ||||||||||||||||||||||||
261 | }; | - | ||||||||||||||||||||||||
262 | - | |||||||||||||||||||||||||
263 | /*! | - | ||||||||||||||||||||||||
264 | \class QXmlParseException | - | ||||||||||||||||||||||||
265 | \reentrant | - | ||||||||||||||||||||||||
266 | \brief The QXmlParseException class is used to report errors with | - | ||||||||||||||||||||||||
267 | the QXmlErrorHandler interface. | - | ||||||||||||||||||||||||
268 | - | |||||||||||||||||||||||||
269 | \inmodule QtXml | - | ||||||||||||||||||||||||
270 | \ingroup xml-tools | - | ||||||||||||||||||||||||
271 | - | |||||||||||||||||||||||||
272 | The XML subsystem constructs an instance of this class when it | - | ||||||||||||||||||||||||
273 | detects an error. You can retrieve the place where the error | - | ||||||||||||||||||||||||
274 | occurred using systemId(), publicId(), lineNumber() and | - | ||||||||||||||||||||||||
275 | columnNumber(), along with the error message(). The possible error | - | ||||||||||||||||||||||||
276 | messages are: | - | ||||||||||||||||||||||||
277 | - | |||||||||||||||||||||||||
278 | - | |||||||||||||||||||||||||
279 | \list | - | ||||||||||||||||||||||||
280 | \li "no error occurred" | - | ||||||||||||||||||||||||
281 | \li "error triggered by consumer" | - | ||||||||||||||||||||||||
282 | \li "unexpected end of file" | - | ||||||||||||||||||||||||
283 | \li "more than one document type definition" | - | ||||||||||||||||||||||||
284 | \li "error occurred while parsing element" | - | ||||||||||||||||||||||||
285 | \li "tag mismatch" | - | ||||||||||||||||||||||||
286 | \li "error occurred while parsing content" | - | ||||||||||||||||||||||||
287 | \li "unexpected character" | - | ||||||||||||||||||||||||
288 | \li "invalid name for processing instruction" | - | ||||||||||||||||||||||||
289 | \li "version expected while reading the XML declaration" | - | ||||||||||||||||||||||||
290 | \li "wrong value for standalone declaration" | - | ||||||||||||||||||||||||
291 | \li "encoding declaration or standalone declaration expected while reading the XML declaration" | - | ||||||||||||||||||||||||
292 | \li "standalone declaration expected while reading the XML declaration" | - | ||||||||||||||||||||||||
293 | \li "error occurred while parsing document type definition" | - | ||||||||||||||||||||||||
294 | \li "letter is expected" | - | ||||||||||||||||||||||||
295 | \li "error occurred while parsing comment" | - | ||||||||||||||||||||||||
296 | \li "error occurred while parsing reference" | - | ||||||||||||||||||||||||
297 | \li "internal general entity reference not allowed in DTD" | - | ||||||||||||||||||||||||
298 | \li "external parsed general entity reference not allowed in attribute value" | - | ||||||||||||||||||||||||
299 | \li "external parsed general entity reference not allowed in DTD" | - | ||||||||||||||||||||||||
300 | \li "unparsed entity reference n wrong context" | - | ||||||||||||||||||||||||
301 | \li "recursive entities" | - | ||||||||||||||||||||||||
302 | \li "error in the text declaration of an external entity" | - | ||||||||||||||||||||||||
303 | \endlist | - | ||||||||||||||||||||||||
304 | - | |||||||||||||||||||||||||
305 | Note that, if you want to display these error messages to your | - | ||||||||||||||||||||||||
306 | application's users, they will be displayed in English unless | - | ||||||||||||||||||||||||
307 | they are explicitly translated. | - | ||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||
309 | \sa QXmlErrorHandler, QXmlReader | - | ||||||||||||||||||||||||
310 | */ | - | ||||||||||||||||||||||||
311 | - | |||||||||||||||||||||||||
312 | /*! | - | ||||||||||||||||||||||||
313 | Constructs a parse exception with the error string \a name for | - | ||||||||||||||||||||||||
314 | column \a c and line \a l for the public identifier \a p and the | - | ||||||||||||||||||||||||
315 | system identifier \a s. | - | ||||||||||||||||||||||||
316 | */ | - | ||||||||||||||||||||||||
317 | - | |||||||||||||||||||||||||
318 | QXmlParseException::QXmlParseException(const QString& name, int c, int l, | - | ||||||||||||||||||||||||
319 | const QString& p, const QString& s) | - | ||||||||||||||||||||||||
320 | : d(new QXmlParseExceptionPrivate) | - | ||||||||||||||||||||||||
321 | { | - | ||||||||||||||||||||||||
322 | d->msg = name; | - | ||||||||||||||||||||||||
323 | d->column = c; | - | ||||||||||||||||||||||||
324 | d->line = l; | - | ||||||||||||||||||||||||
325 | d->pub = p; | - | ||||||||||||||||||||||||
326 | d->sys = s; | - | ||||||||||||||||||||||||
327 | } executed 155 times by 1 test: end of block Executed by:
| 155 | ||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||
329 | /*! | - | ||||||||||||||||||||||||
330 | Creates a copy of \a other. | - | ||||||||||||||||||||||||
331 | */ | - | ||||||||||||||||||||||||
332 | QXmlParseException::QXmlParseException(const QXmlParseException& other) : | - | ||||||||||||||||||||||||
333 | d(new QXmlParseExceptionPrivate(*other.d)) | - | ||||||||||||||||||||||||
334 | { | - | ||||||||||||||||||||||||
335 | - | |||||||||||||||||||||||||
336 | } never executed: end of block | 0 | ||||||||||||||||||||||||
337 | - | |||||||||||||||||||||||||
338 | /*! | - | ||||||||||||||||||||||||
339 | Destroys the QXmlParseException. | - | ||||||||||||||||||||||||
340 | */ | - | ||||||||||||||||||||||||
341 | QXmlParseException::~QXmlParseException() | - | ||||||||||||||||||||||||
342 | { | - | ||||||||||||||||||||||||
343 | } | - | ||||||||||||||||||||||||
344 | - | |||||||||||||||||||||||||
345 | /*! | - | ||||||||||||||||||||||||
346 | Returns the error message. | - | ||||||||||||||||||||||||
347 | */ | - | ||||||||||||||||||||||||
348 | QString QXmlParseException::message() const | - | ||||||||||||||||||||||||
349 | { | - | ||||||||||||||||||||||||
350 | return d->msg; executed 300 times by 1 test: return d->msg; Executed by:
| 300 | ||||||||||||||||||||||||
351 | } | - | ||||||||||||||||||||||||
352 | /*! | - | ||||||||||||||||||||||||
353 | Returns the column number where the error occurred. | - | ||||||||||||||||||||||||
354 | */ | - | ||||||||||||||||||||||||
355 | int QXmlParseException::columnNumber() const | - | ||||||||||||||||||||||||
356 | { | - | ||||||||||||||||||||||||
357 | return d->column; executed 300 times by 1 test: return d->column; Executed by:
| 300 | ||||||||||||||||||||||||
358 | } | - | ||||||||||||||||||||||||
359 | /*! | - | ||||||||||||||||||||||||
360 | Returns the line number where the error occurred. | - | ||||||||||||||||||||||||
361 | */ | - | ||||||||||||||||||||||||
362 | int QXmlParseException::lineNumber() const | - | ||||||||||||||||||||||||
363 | { | - | ||||||||||||||||||||||||
364 | return d->line; executed 300 times by 1 test: return d->line; Executed by:
| 300 | ||||||||||||||||||||||||
365 | } | - | ||||||||||||||||||||||||
366 | /*! | - | ||||||||||||||||||||||||
367 | Returns the public identifier where the error occurred. | - | ||||||||||||||||||||||||
368 | */ | - | ||||||||||||||||||||||||
369 | QString QXmlParseException::publicId() const | - | ||||||||||||||||||||||||
370 | { | - | ||||||||||||||||||||||||
371 | return d->pub; executed 152 times by 1 test: return d->pub; Executed by:
| 152 | ||||||||||||||||||||||||
372 | } | - | ||||||||||||||||||||||||
373 | /*! | - | ||||||||||||||||||||||||
374 | Returns the system identifier where the error occurred. | - | ||||||||||||||||||||||||
375 | */ | - | ||||||||||||||||||||||||
376 | QString QXmlParseException::systemId() const | - | ||||||||||||||||||||||||
377 | { | - | ||||||||||||||||||||||||
378 | return d->sys; executed 152 times by 1 test: return d->sys; Executed by:
| 152 | ||||||||||||||||||||||||
379 | } | - | ||||||||||||||||||||||||
380 | - | |||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||
382 | /*! | - | ||||||||||||||||||||||||
383 | \class QXmlLocator | - | ||||||||||||||||||||||||
384 | \reentrant | - | ||||||||||||||||||||||||
385 | \brief The QXmlLocator class provides the XML handler classes with | - | ||||||||||||||||||||||||
386 | information about the parsing position within a file. | - | ||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||
388 | \inmodule QtXml | - | ||||||||||||||||||||||||
389 | \ingroup xml-tools | - | ||||||||||||||||||||||||
390 | - | |||||||||||||||||||||||||
391 | The reader reports a QXmlLocator to the content handler before it | - | ||||||||||||||||||||||||
392 | starts to parse the document. This is done with the | - | ||||||||||||||||||||||||
393 | QXmlContentHandler::setDocumentLocator() function. The handler | - | ||||||||||||||||||||||||
394 | classes can now use this locator to get the position (lineNumber() | - | ||||||||||||||||||||||||
395 | and columnNumber()) that the reader has reached. | - | ||||||||||||||||||||||||
396 | */ | - | ||||||||||||||||||||||||
397 | - | |||||||||||||||||||||||||
398 | /*! | - | ||||||||||||||||||||||||
399 | Constructor. | - | ||||||||||||||||||||||||
400 | */ | - | ||||||||||||||||||||||||
401 | QXmlLocator::QXmlLocator() | - | ||||||||||||||||||||||||
402 | { | - | ||||||||||||||||||||||||
403 | } | - | ||||||||||||||||||||||||
404 | - | |||||||||||||||||||||||||
405 | /*! | - | ||||||||||||||||||||||||
406 | Destructor. | - | ||||||||||||||||||||||||
407 | */ | - | ||||||||||||||||||||||||
408 | QXmlLocator::~QXmlLocator() | - | ||||||||||||||||||||||||
409 | { | - | ||||||||||||||||||||||||
410 | } | - | ||||||||||||||||||||||||
411 | - | |||||||||||||||||||||||||
412 | /*! | - | ||||||||||||||||||||||||
413 | \fn int QXmlLocator::columnNumber() const | - | ||||||||||||||||||||||||
414 | - | |||||||||||||||||||||||||
415 | Returns the column number (starting at 1) or -1 if there is no | - | ||||||||||||||||||||||||
416 | column number available. | - | ||||||||||||||||||||||||
417 | */ | - | ||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | /*! | - | ||||||||||||||||||||||||
420 | \fn int QXmlLocator::lineNumber() const | - | ||||||||||||||||||||||||
421 | - | |||||||||||||||||||||||||
422 | Returns the line number (starting at 1) or -1 if there is no line | - | ||||||||||||||||||||||||
423 | number available. | - | ||||||||||||||||||||||||
424 | */ | - | ||||||||||||||||||||||||
425 | - | |||||||||||||||||||||||||
426 | class QXmlSimpleReaderLocator : public QXmlLocator | - | ||||||||||||||||||||||||
427 | { | - | ||||||||||||||||||||||||
428 | public: | - | ||||||||||||||||||||||||
429 | QXmlSimpleReaderLocator(QXmlSimpleReader* parent) | - | ||||||||||||||||||||||||
430 | { | - | ||||||||||||||||||||||||
431 | reader = parent; | - | ||||||||||||||||||||||||
432 | } executed 2104 times by 6 tests: end of block Executed by:
| 2104 | ||||||||||||||||||||||||
433 | ~QXmlSimpleReaderLocator() | - | ||||||||||||||||||||||||
434 | { | - | ||||||||||||||||||||||||
435 | } | - | ||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | int columnNumber() const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
438 | { | - | ||||||||||||||||||||||||
439 | return (reader->d_ptr->columnNr == -1 ? -1 : reader->d_ptr->columnNr + 1); executed 2993 times by 5 tests: return (reader->d_ptr->columnNr == -1 ? -1 : reader->d_ptr->columnNr + 1); Executed by:
| 0-2993 | ||||||||||||||||||||||||
440 | } | - | ||||||||||||||||||||||||
441 | int lineNumber() const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
442 | { | - | ||||||||||||||||||||||||
443 | return (reader->d_ptr->lineNr == -1 ? -1 : reader->d_ptr->lineNr + 1); executed 2993 times by 5 tests: return (reader->d_ptr->lineNr == -1 ? -1 : reader->d_ptr->lineNr + 1); Executed by:
| 0-2993 | ||||||||||||||||||||||||
444 | } | - | ||||||||||||||||||||||||
445 | // QString getPublicId() | - | ||||||||||||||||||||||||
446 | // QString getSystemId() | - | ||||||||||||||||||||||||
447 | - | |||||||||||||||||||||||||
448 | private: | - | ||||||||||||||||||||||||
449 | QXmlSimpleReader *reader; | - | ||||||||||||||||||||||||
450 | }; | - | ||||||||||||||||||||||||
451 | - | |||||||||||||||||||||||||
452 | /********************************************* | - | ||||||||||||||||||||||||
453 | * | - | ||||||||||||||||||||||||
454 | * QXmlNamespaceSupport | - | ||||||||||||||||||||||||
455 | * | - | ||||||||||||||||||||||||
456 | *********************************************/ | - | ||||||||||||||||||||||||
457 | - | |||||||||||||||||||||||||
458 | typedef QMap<QString, QString> NamespaceMap; | - | ||||||||||||||||||||||||
459 | - | |||||||||||||||||||||||||
460 | class QXmlNamespaceSupportPrivate | - | ||||||||||||||||||||||||
461 | { | - | ||||||||||||||||||||||||
462 | public: | - | ||||||||||||||||||||||||
463 | QXmlNamespaceSupportPrivate() | - | ||||||||||||||||||||||||
464 | { | - | ||||||||||||||||||||||||
465 | ns.insert(QLatin1String("xml"), QLatin1String("http://www.w3.org/XML/1998/namespace")); // the XML namespace | - | ||||||||||||||||||||||||
466 | } executed 2104 times by 6 tests: end of block Executed by:
| 2104 | ||||||||||||||||||||||||
467 | - | |||||||||||||||||||||||||
468 | ~QXmlNamespaceSupportPrivate() | - | ||||||||||||||||||||||||
469 | { | - | ||||||||||||||||||||||||
470 | } | - | ||||||||||||||||||||||||
471 | - | |||||||||||||||||||||||||
472 | QStack<NamespaceMap> nsStack; | - | ||||||||||||||||||||||||
473 | NamespaceMap ns; | - | ||||||||||||||||||||||||
474 | }; | - | ||||||||||||||||||||||||
475 | - | |||||||||||||||||||||||||
476 | /*! | - | ||||||||||||||||||||||||
477 | \class QXmlNamespaceSupport | - | ||||||||||||||||||||||||
478 | \since 4.4 | - | ||||||||||||||||||||||||
479 | \reentrant | - | ||||||||||||||||||||||||
480 | \brief The QXmlNamespaceSupport class is a helper class for XML | - | ||||||||||||||||||||||||
481 | readers which want to include namespace support. | - | ||||||||||||||||||||||||
482 | - | |||||||||||||||||||||||||
483 | \inmodule QtXml | - | ||||||||||||||||||||||||
484 | \ingroup xml-tools | - | ||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||
486 | You can set the prefix for the current namespace with setPrefix(), | - | ||||||||||||||||||||||||
487 | and get the list of current prefixes (or those for a given URI) | - | ||||||||||||||||||||||||
488 | with prefixes(). The namespace URI is available from uri(). Use | - | ||||||||||||||||||||||||
489 | pushContext() to start a new namespace context, and popContext() | - | ||||||||||||||||||||||||
490 | to return to the previous namespace context. Use splitName() or | - | ||||||||||||||||||||||||
491 | processName() to split a name into its prefix and local name. | - | ||||||||||||||||||||||||
492 | - | |||||||||||||||||||||||||
493 | \sa {Namespace Support via Features} | - | ||||||||||||||||||||||||
494 | */ | - | ||||||||||||||||||||||||
495 | - | |||||||||||||||||||||||||
496 | /*! | - | ||||||||||||||||||||||||
497 | Constructs a QXmlNamespaceSupport. | - | ||||||||||||||||||||||||
498 | */ | - | ||||||||||||||||||||||||
499 | QXmlNamespaceSupport::QXmlNamespaceSupport() | - | ||||||||||||||||||||||||
500 | { | - | ||||||||||||||||||||||||
501 | d = new QXmlNamespaceSupportPrivate; | - | ||||||||||||||||||||||||
502 | } executed 2104 times by 6 tests: end of block Executed by:
| 2104 | ||||||||||||||||||||||||
503 | - | |||||||||||||||||||||||||
504 | /*! | - | ||||||||||||||||||||||||
505 | Destroys a QXmlNamespaceSupport. | - | ||||||||||||||||||||||||
506 | */ | - | ||||||||||||||||||||||||
507 | QXmlNamespaceSupport::~QXmlNamespaceSupport() | - | ||||||||||||||||||||||||
508 | { | - | ||||||||||||||||||||||||
509 | delete d; | - | ||||||||||||||||||||||||
510 | } executed 2104 times by 6 tests: end of block Executed by:
| 2104 | ||||||||||||||||||||||||
511 | - | |||||||||||||||||||||||||
512 | /*! | - | ||||||||||||||||||||||||
513 | This function declares a prefix \a pre in the current namespace | - | ||||||||||||||||||||||||
514 | context to be the namespace URI \a uri. The prefix remains in | - | ||||||||||||||||||||||||
515 | force until this context is popped, unless it is shadowed in a | - | ||||||||||||||||||||||||
516 | descendant context. | - | ||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | Note that there is an asymmetry in this library. prefix() does not | - | ||||||||||||||||||||||||
519 | return the default "" prefix, even if you have declared one; to | - | ||||||||||||||||||||||||
520 | check for a default prefix, you must look it up explicitly using | - | ||||||||||||||||||||||||
521 | uri(). This asymmetry exists to make it easier to look up prefixes | - | ||||||||||||||||||||||||
522 | for attribute names, where the default prefix is not allowed. | - | ||||||||||||||||||||||||
523 | */ | - | ||||||||||||||||||||||||
524 | void QXmlNamespaceSupport::setPrefix(const QString& pre, const QString& uri) | - | ||||||||||||||||||||||||
525 | { | - | ||||||||||||||||||||||||
526 | if(pre.isNull()) {
| 3-4 | ||||||||||||||||||||||||
527 | d->ns.insert(QLatin1String(""), uri); | - | ||||||||||||||||||||||||
528 | } else { executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||
529 | d->ns.insert(pre, uri); | - | ||||||||||||||||||||||||
530 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
531 | } | - | ||||||||||||||||||||||||
532 | - | |||||||||||||||||||||||||
533 | /*! | - | ||||||||||||||||||||||||
534 | Returns one of the prefixes mapped to the namespace URI \a uri. | - | ||||||||||||||||||||||||
535 | - | |||||||||||||||||||||||||
536 | If more than one prefix is currently mapped to the same URI, this | - | ||||||||||||||||||||||||
537 | function makes an arbitrary selection; if you want all of the | - | ||||||||||||||||||||||||
538 | prefixes, use prefixes() instead. | - | ||||||||||||||||||||||||
539 | - | |||||||||||||||||||||||||
540 | Note: to check for a default prefix, use the uri() function with | - | ||||||||||||||||||||||||
541 | an argument of "". | - | ||||||||||||||||||||||||
542 | */ | - | ||||||||||||||||||||||||
543 | QString QXmlNamespaceSupport::prefix(const QString& uri) const | - | ||||||||||||||||||||||||
544 | { | - | ||||||||||||||||||||||||
545 | NamespaceMap::const_iterator itc, it = d->ns.constBegin(); | - | ||||||||||||||||||||||||
546 | while ((itc=it) != d->ns.constEnd()) {
| 0 | ||||||||||||||||||||||||
547 | ++it; | - | ||||||||||||||||||||||||
548 | if (*itc == uri && !itc.key().isEmpty())
| 0 | ||||||||||||||||||||||||
549 | return itc.key(); never executed: return itc.key(); | 0 | ||||||||||||||||||||||||
550 | } never executed: end of block | 0 | ||||||||||||||||||||||||
551 | return QLatin1String(""); never executed: return QLatin1String(""); | 0 | ||||||||||||||||||||||||
552 | } | - | ||||||||||||||||||||||||
553 | - | |||||||||||||||||||||||||
554 | /*! | - | ||||||||||||||||||||||||
555 | Looks up the prefix \a prefix in the current context and returns | - | ||||||||||||||||||||||||
556 | the currently-mapped namespace URI. Use the empty string ("") for | - | ||||||||||||||||||||||||
557 | the default namespace. | - | ||||||||||||||||||||||||
558 | */ | - | ||||||||||||||||||||||||
559 | QString QXmlNamespaceSupport::uri(const QString& prefix) const | - | ||||||||||||||||||||||||
560 | { | - | ||||||||||||||||||||||||
561 | return d->ns[prefix]; executed 27 times by 2 tests: return d->ns[prefix]; Executed by:
| 27 | ||||||||||||||||||||||||
562 | } | - | ||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | /*! | - | ||||||||||||||||||||||||
565 | Splits the name \a qname at the ':' and returns the prefix in \a | - | ||||||||||||||||||||||||
566 | prefix and the local name in \a localname. | - | ||||||||||||||||||||||||
567 | - | |||||||||||||||||||||||||
568 | \sa processName() | - | ||||||||||||||||||||||||
569 | */ | - | ||||||||||||||||||||||||
570 | void QXmlNamespaceSupport::splitName(const QString& qname, QString& prefix, | - | ||||||||||||||||||||||||
571 | QString& localname) const | - | ||||||||||||||||||||||||
572 | { | - | ||||||||||||||||||||||||
573 | int pos = qname.indexOf(QLatin1Char(':')); | - | ||||||||||||||||||||||||
574 | if (pos == -1)
| 30-11998 | ||||||||||||||||||||||||
575 | pos = qname.size(); executed 11998 times by 3 tests: pos = qname.size(); Executed by:
| 11998 | ||||||||||||||||||||||||
576 | - | |||||||||||||||||||||||||
577 | prefix = qname.left(pos); | - | ||||||||||||||||||||||||
578 | localname = qname.mid(pos+1); | - | ||||||||||||||||||||||||
579 | } executed 12028 times by 3 tests: end of block Executed by:
| 12028 | ||||||||||||||||||||||||
580 | - | |||||||||||||||||||||||||
581 | /*! | - | ||||||||||||||||||||||||
582 | Processes a raw XML 1.0 name in the current context by removing | - | ||||||||||||||||||||||||
583 | the prefix and looking it up among the prefixes currently | - | ||||||||||||||||||||||||
584 | declared. | - | ||||||||||||||||||||||||
585 | - | |||||||||||||||||||||||||
586 | \a qname is the raw XML 1.0 name to be processed. \a isAttribute | - | ||||||||||||||||||||||||
587 | is true if the name is an attribute name. | - | ||||||||||||||||||||||||
588 | - | |||||||||||||||||||||||||
589 | This function stores the namespace URI in \a nsuri (which will be | - | ||||||||||||||||||||||||
590 | set to an empty string if the raw name has an undeclared prefix), | - | ||||||||||||||||||||||||
591 | and stores the local name (without prefix) in \a localname (which | - | ||||||||||||||||||||||||
592 | will be set to an empty string if no namespace is in use). | - | ||||||||||||||||||||||||
593 | - | |||||||||||||||||||||||||
594 | Note that attribute names are processed differently than element | - | ||||||||||||||||||||||||
595 | names: an unprefixed element name gets the default namespace (if | - | ||||||||||||||||||||||||
596 | any), while an unprefixed attribute name does not. | - | ||||||||||||||||||||||||
597 | */ | - | ||||||||||||||||||||||||
598 | void QXmlNamespaceSupport::processName(const QString& qname, | - | ||||||||||||||||||||||||
599 | bool isAttribute, | - | ||||||||||||||||||||||||
600 | QString& nsuri, QString& localname) const | - | ||||||||||||||||||||||||
601 | { | - | ||||||||||||||||||||||||
602 | int len = qname.size(); | - | ||||||||||||||||||||||||
603 | const QChar *data = qname.constData(); | - | ||||||||||||||||||||||||
604 | for (int pos = 0; pos < len; ++pos) {
| 21219-96470 | ||||||||||||||||||||||||
605 | if (data[pos] == QLatin1Char(':')) {
| 27-96443 | ||||||||||||||||||||||||
606 | nsuri = uri(qname.left(pos)); | - | ||||||||||||||||||||||||
607 | localname = qname.mid(pos + 1); | - | ||||||||||||||||||||||||
608 | return; executed 27 times by 2 tests: return; Executed by:
| 27 | ||||||||||||||||||||||||
609 | } | - | ||||||||||||||||||||||||
610 | } executed 96443 times by 3 tests: end of block Executed by:
| 96443 | ||||||||||||||||||||||||
611 | - | |||||||||||||||||||||||||
612 | // there was no ':' | - | ||||||||||||||||||||||||
613 | nsuri.clear(); | - | ||||||||||||||||||||||||
614 | // attributes don't take default namespace | - | ||||||||||||||||||||||||
615 | if (!isAttribute && !d->ns.isEmpty()) {
| 0-11995 | ||||||||||||||||||||||||
616 | /* | - | ||||||||||||||||||||||||
617 | We want to access d->ns.value(""), but as an optimization | - | ||||||||||||||||||||||||
618 | we use the fact that "" compares less than any other | - | ||||||||||||||||||||||||
619 | string, so it's either first in the map or not there. | - | ||||||||||||||||||||||||
620 | */ | - | ||||||||||||||||||||||||
621 | NamespaceMap::const_iterator first = d->ns.constBegin(); | - | ||||||||||||||||||||||||
622 | if (first.key().isEmpty())
| 21-9203 | ||||||||||||||||||||||||
623 | nsuri = first.value(); // get default namespace executed 21 times by 1 test: nsuri = first.value(); Executed by:
| 21 | ||||||||||||||||||||||||
624 | } executed 9224 times by 3 tests: end of block Executed by:
| 9224 | ||||||||||||||||||||||||
625 | localname = qname; | - | ||||||||||||||||||||||||
626 | } executed 21219 times by 3 tests: end of block Executed by:
| 21219 | ||||||||||||||||||||||||
627 | - | |||||||||||||||||||||||||
628 | /*! | - | ||||||||||||||||||||||||
629 | Returns a list of all the prefixes currently declared. | - | ||||||||||||||||||||||||
630 | - | |||||||||||||||||||||||||
631 | If there is a default prefix, this function does not return it in | - | ||||||||||||||||||||||||
632 | the list; check for the default prefix using uri() with an | - | ||||||||||||||||||||||||
633 | argument of "". | - | ||||||||||||||||||||||||
634 | */ | - | ||||||||||||||||||||||||
635 | QStringList QXmlNamespaceSupport::prefixes() const | - | ||||||||||||||||||||||||
636 | { | - | ||||||||||||||||||||||||
637 | QStringList list; | - | ||||||||||||||||||||||||
638 | - | |||||||||||||||||||||||||
639 | NamespaceMap::const_iterator itc, it = d->ns.constBegin(); | - | ||||||||||||||||||||||||
640 | while ((itc=it) != d->ns.constEnd()) {
| 434-439 | ||||||||||||||||||||||||
641 | ++it; | - | ||||||||||||||||||||||||
642 | if (!itc.key().isEmpty())
| 1-438 | ||||||||||||||||||||||||
643 | list.append(itc.key()); executed 438 times by 2 tests: list.append(itc.key()); Executed by:
| 438 | ||||||||||||||||||||||||
644 | } executed 439 times by 2 tests: end of block Executed by:
| 439 | ||||||||||||||||||||||||
645 | return list; executed 434 times by 2 tests: return list; Executed by:
| 434 | ||||||||||||||||||||||||
646 | } | - | ||||||||||||||||||||||||
647 | - | |||||||||||||||||||||||||
648 | /*! | - | ||||||||||||||||||||||||
649 | \overload | - | ||||||||||||||||||||||||
650 | - | |||||||||||||||||||||||||
651 | Returns a list of all prefixes currently declared for the | - | ||||||||||||||||||||||||
652 | namespace URI \a uri. | - | ||||||||||||||||||||||||
653 | - | |||||||||||||||||||||||||
654 | The "xml:" prefix is included. If you only want one prefix that is | - | ||||||||||||||||||||||||
655 | mapped to the namespace URI, and you don't care which one you get, | - | ||||||||||||||||||||||||
656 | use the prefix() function instead. | - | ||||||||||||||||||||||||
657 | - | |||||||||||||||||||||||||
658 | Note: The empty (default) prefix is never included in this list; | - | ||||||||||||||||||||||||
659 | to check for the presence of a default namespace, call uri() with | - | ||||||||||||||||||||||||
660 | "" as the argument. | - | ||||||||||||||||||||||||
661 | */ | - | ||||||||||||||||||||||||
662 | QStringList QXmlNamespaceSupport::prefixes(const QString& uri) const | - | ||||||||||||||||||||||||
663 | { | - | ||||||||||||||||||||||||
664 | QStringList list; | - | ||||||||||||||||||||||||
665 | - | |||||||||||||||||||||||||
666 | NamespaceMap::const_iterator itc, it = d->ns.constBegin(); | - | ||||||||||||||||||||||||
667 | while ((itc=it) != d->ns.constEnd()) {
| 0 | ||||||||||||||||||||||||
668 | ++it; | - | ||||||||||||||||||||||||
669 | if (*itc == uri && !itc.key().isEmpty())
| 0 | ||||||||||||||||||||||||
670 | list.append(itc.key()); never executed: list.append(itc.key()); | 0 | ||||||||||||||||||||||||
671 | } never executed: end of block | 0 | ||||||||||||||||||||||||
672 | return list; never executed: return list; | 0 | ||||||||||||||||||||||||
673 | } | - | ||||||||||||||||||||||||
674 | - | |||||||||||||||||||||||||
675 | /*! | - | ||||||||||||||||||||||||
676 | Starts a new namespace context. | - | ||||||||||||||||||||||||
677 | - | |||||||||||||||||||||||||
678 | Normally, you should push a new context at the beginning of each | - | ||||||||||||||||||||||||
679 | XML element: the new context automatically inherits the | - | ||||||||||||||||||||||||
680 | declarations of its parent context, and it also keeps track of | - | ||||||||||||||||||||||||
681 | which declarations were made within this context. | - | ||||||||||||||||||||||||
682 | - | |||||||||||||||||||||||||
683 | \sa popContext() | - | ||||||||||||||||||||||||
684 | */ | - | ||||||||||||||||||||||||
685 | void QXmlNamespaceSupport::pushContext() | - | ||||||||||||||||||||||||
686 | { | - | ||||||||||||||||||||||||
687 | d->nsStack.push(d->ns); | - | ||||||||||||||||||||||||
688 | } executed 4781 times by 3 tests: end of block Executed by:
| 4781 | ||||||||||||||||||||||||
689 | - | |||||||||||||||||||||||||
690 | /*! | - | ||||||||||||||||||||||||
691 | Reverts to the previous namespace context. | - | ||||||||||||||||||||||||
692 | - | |||||||||||||||||||||||||
693 | Normally, you should pop the context at the end of each XML | - | ||||||||||||||||||||||||
694 | element. After popping the context, all namespace prefix mappings | - | ||||||||||||||||||||||||
695 | that were previously in force are restored. | - | ||||||||||||||||||||||||
696 | - | |||||||||||||||||||||||||
697 | \sa pushContext() | - | ||||||||||||||||||||||||
698 | */ | - | ||||||||||||||||||||||||
699 | void QXmlNamespaceSupport::popContext() | - | ||||||||||||||||||||||||
700 | { | - | ||||||||||||||||||||||||
701 | d->ns.clear(); | - | ||||||||||||||||||||||||
702 | if(!d->nsStack.isEmpty())
| 0-4705 | ||||||||||||||||||||||||
703 | d->ns = d->nsStack.pop(); executed 4705 times by 3 tests: d->ns = d->nsStack.pop(); Executed by:
| 4705 | ||||||||||||||||||||||||
704 | } executed 4705 times by 3 tests: end of block Executed by:
| 4705 | ||||||||||||||||||||||||
705 | - | |||||||||||||||||||||||||
706 | /*! | - | ||||||||||||||||||||||||
707 | Resets this namespace support object ready for reuse. | - | ||||||||||||||||||||||||
708 | */ | - | ||||||||||||||||||||||||
709 | void QXmlNamespaceSupport::reset() | - | ||||||||||||||||||||||||
710 | { | - | ||||||||||||||||||||||||
711 | QXmlNamespaceSupportPrivate *newD = new QXmlNamespaceSupportPrivate; | - | ||||||||||||||||||||||||
712 | delete d; | - | ||||||||||||||||||||||||
713 | d = newD; | - | ||||||||||||||||||||||||
714 | } never executed: end of block | 0 | ||||||||||||||||||||||||
715 | - | |||||||||||||||||||||||||
716 | - | |||||||||||||||||||||||||
717 | - | |||||||||||||||||||||||||
718 | /********************************************* | - | ||||||||||||||||||||||||
719 | * | - | ||||||||||||||||||||||||
720 | * QXmlAttributes | - | ||||||||||||||||||||||||
721 | * | - | ||||||||||||||||||||||||
722 | *********************************************/ | - | ||||||||||||||||||||||||
723 | - | |||||||||||||||||||||||||
724 | /*! | - | ||||||||||||||||||||||||
725 | \class QXmlAttributes | - | ||||||||||||||||||||||||
726 | \reentrant | - | ||||||||||||||||||||||||
727 | \brief The QXmlAttributes class provides XML attributes. | - | ||||||||||||||||||||||||
728 | - | |||||||||||||||||||||||||
729 | \inmodule QtXml | - | ||||||||||||||||||||||||
730 | \ingroup xml-tools | - | ||||||||||||||||||||||||
731 | - | |||||||||||||||||||||||||
732 | If attributes are reported by QXmlContentHandler::startElement() | - | ||||||||||||||||||||||||
733 | this class is used to pass the attribute values. | - | ||||||||||||||||||||||||
734 | - | |||||||||||||||||||||||||
735 | Use index() to locate the position of an attribute in the list, | - | ||||||||||||||||||||||||
736 | count() to retrieve the number of attributes, and clear() to | - | ||||||||||||||||||||||||
737 | remove the attributes. New attributes can be added with append(). | - | ||||||||||||||||||||||||
738 | Use type() to get an attribute's type and value() to get its | - | ||||||||||||||||||||||||
739 | value. The attribute's name is available from localName() or | - | ||||||||||||||||||||||||
740 | qName(), and its namespace URI from uri(). | - | ||||||||||||||||||||||||
741 | - | |||||||||||||||||||||||||
742 | */ | - | ||||||||||||||||||||||||
743 | - | |||||||||||||||||||||||||
744 | /*! | - | ||||||||||||||||||||||||
745 | \fn QXmlAttributes::QXmlAttributes() | - | ||||||||||||||||||||||||
746 | - | |||||||||||||||||||||||||
747 | Constructs an empty attribute list. | - | ||||||||||||||||||||||||
748 | */ | - | ||||||||||||||||||||||||
749 | QXmlAttributes::QXmlAttributes() | - | ||||||||||||||||||||||||
750 | { | - | ||||||||||||||||||||||||
751 | // ### In Qt 5.0, this function was inlined and d was not initialized | - | ||||||||||||||||||||||||
752 | // The member cannot be used until Qt 6.0 | - | ||||||||||||||||||||||||
753 | Q_UNUSED(d); | - | ||||||||||||||||||||||||
754 | } executed 2104 times by 6 tests: end of block Executed by:
| 2104 | ||||||||||||||||||||||||
755 | - | |||||||||||||||||||||||||
756 | /*! | - | ||||||||||||||||||||||||
757 | \fn QXmlAttributes::~QXmlAttributes() | - | ||||||||||||||||||||||||
758 | - | |||||||||||||||||||||||||
759 | Destroys the attributes object. | - | ||||||||||||||||||||||||
760 | */ | - | ||||||||||||||||||||||||
761 | QXmlAttributes::~QXmlAttributes() | - | ||||||||||||||||||||||||
762 | { | - | ||||||||||||||||||||||||
763 | } | - | ||||||||||||||||||||||||
764 | - | |||||||||||||||||||||||||
765 | - | |||||||||||||||||||||||||
766 | /*! | - | ||||||||||||||||||||||||
767 | Looks up the index of an attribute by the qualified name \a qName. | - | ||||||||||||||||||||||||
768 | - | |||||||||||||||||||||||||
769 | Returns the index of the attribute or -1 if it wasn't found. | - | ||||||||||||||||||||||||
770 | - | |||||||||||||||||||||||||
771 | \sa {Namespace Support via Features} | - | ||||||||||||||||||||||||
772 | */ | - | ||||||||||||||||||||||||
773 | int QXmlAttributes::index(const QString& qName) const | - | ||||||||||||||||||||||||
774 | { | - | ||||||||||||||||||||||||
775 | for (int i = 0; i < attList.size(); ++i) {
| 0 | ||||||||||||||||||||||||
776 | if (attList.at(i).qname == qName)
| 0 | ||||||||||||||||||||||||
777 | return i; never executed: return i; | 0 | ||||||||||||||||||||||||
778 | } never executed: end of block | 0 | ||||||||||||||||||||||||
779 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
780 | } | - | ||||||||||||||||||||||||
781 | - | |||||||||||||||||||||||||
782 | /*! \overload | - | ||||||||||||||||||||||||
783 | */ | - | ||||||||||||||||||||||||
784 | int QXmlAttributes::index(QLatin1String qName) const | - | ||||||||||||||||||||||||
785 | { | - | ||||||||||||||||||||||||
786 | for (int i = 0; i < attList.size(); ++i) {
| 2589-11810 | ||||||||||||||||||||||||
787 | if (attList.at(i).qname == qName)
| 24-11786 | ||||||||||||||||||||||||
788 | return i; executed 24 times by 1 test: return i; Executed by:
| 24 | ||||||||||||||||||||||||
789 | } executed 11786 times by 1 test: end of block Executed by:
| 11786 | ||||||||||||||||||||||||
790 | return -1; executed 2589 times by 1 test: return -1; Executed by:
| 2589 | ||||||||||||||||||||||||
791 | } | - | ||||||||||||||||||||||||
792 | - | |||||||||||||||||||||||||
793 | /*! | - | ||||||||||||||||||||||||
794 | \overload | - | ||||||||||||||||||||||||
795 | - | |||||||||||||||||||||||||
796 | Looks up the index of an attribute by a namespace name. | - | ||||||||||||||||||||||||
797 | - | |||||||||||||||||||||||||
798 | \a uri specifies the namespace URI, or an empty string if the name | - | ||||||||||||||||||||||||
799 | has no namespace URI. \a localPart specifies the attribute's local | - | ||||||||||||||||||||||||
800 | name. | - | ||||||||||||||||||||||||
801 | - | |||||||||||||||||||||||||
802 | Returns the index of the attribute, or -1 if it wasn't found. | - | ||||||||||||||||||||||||
803 | - | |||||||||||||||||||||||||
804 | \sa {Namespace Support via Features} | - | ||||||||||||||||||||||||
805 | */ | - | ||||||||||||||||||||||||
806 | int QXmlAttributes::index(const QString& uri, const QString& localPart) const | - | ||||||||||||||||||||||||
807 | { | - | ||||||||||||||||||||||||
808 | for (int i = 0; i < attList.size(); ++i) {
| 5843-51512 | ||||||||||||||||||||||||
809 | const Attribute &att = attList.at(i); | - | ||||||||||||||||||||||||
810 | if (att.uri == uri && att.localname == localPart)
| 0-51512 | ||||||||||||||||||||||||
811 | return i; executed 8130 times by 1 test: return i; Executed by:
| 8130 | ||||||||||||||||||||||||
812 | } executed 43382 times by 1 test: end of block Executed by:
| 43382 | ||||||||||||||||||||||||
813 | return -1; executed 5843 times by 1 test: return -1; Executed by:
| 5843 | ||||||||||||||||||||||||
814 | } | - | ||||||||||||||||||||||||
815 | - | |||||||||||||||||||||||||
816 | /*! | - | ||||||||||||||||||||||||
817 | Returns the number of attributes in the list. | - | ||||||||||||||||||||||||
818 | - | |||||||||||||||||||||||||
819 | \sa count() | - | ||||||||||||||||||||||||
820 | */ | - | ||||||||||||||||||||||||
821 | int QXmlAttributes::length() const | - | ||||||||||||||||||||||||
822 | { | - | ||||||||||||||||||||||||
823 | return attList.count(); executed 4017 times by 5 tests: return attList.count(); Executed by:
| 4017 | ||||||||||||||||||||||||
824 | } | - | ||||||||||||||||||||||||
825 | - | |||||||||||||||||||||||||
826 | /*! | - | ||||||||||||||||||||||||
827 | \fn int QXmlAttributes::count() const | - | ||||||||||||||||||||||||
828 | - | |||||||||||||||||||||||||
829 | Returns the number of attributes in the list. This function is | - | ||||||||||||||||||||||||
830 | equivalent to length(). | - | ||||||||||||||||||||||||
831 | */ | - | ||||||||||||||||||||||||
832 | - | |||||||||||||||||||||||||
833 | /*! | - | ||||||||||||||||||||||||
834 | Looks up an attribute's local name for the attribute at position | - | ||||||||||||||||||||||||
835 | \a index. If no namespace processing is done, the local name is | - | ||||||||||||||||||||||||
836 | an empty string. | - | ||||||||||||||||||||||||
837 | - | |||||||||||||||||||||||||
838 | \sa {Namespace Support via Features} | - | ||||||||||||||||||||||||
839 | */ | - | ||||||||||||||||||||||||
840 | QString QXmlAttributes::localName(int index) const | - | ||||||||||||||||||||||||
841 | { | - | ||||||||||||||||||||||||
842 | return attList.at(index).localname; executed 407 times by 1 test: return attList.at(index).localname; Executed by:
| 407 | ||||||||||||||||||||||||
843 | } | - | ||||||||||||||||||||||||
844 | - | |||||||||||||||||||||||||
845 | /*! | - | ||||||||||||||||||||||||
846 | Looks up an attribute's XML 1.0 qualified name for the attribute | - | ||||||||||||||||||||||||
847 | at position \a index. | - | ||||||||||||||||||||||||
848 | - | |||||||||||||||||||||||||
849 | \sa {Namespace Support via Features} | - | ||||||||||||||||||||||||
850 | */ | - | ||||||||||||||||||||||||
851 | QString QXmlAttributes::qName(int index) const | - | ||||||||||||||||||||||||
852 | { | - | ||||||||||||||||||||||||
853 | return attList.at(index).qname; executed 1275 times by 4 tests: return attList.at(index).qname; Executed by:
| 1275 | ||||||||||||||||||||||||
854 | } | - | ||||||||||||||||||||||||
855 | - | |||||||||||||||||||||||||
856 | /*! | - | ||||||||||||||||||||||||
857 | Looks up an attribute's namespace URI for the attribute at | - | ||||||||||||||||||||||||
858 | position \a index. If no namespace processing is done or if the | - | ||||||||||||||||||||||||
859 | attribute has no namespace, the namespace URI is an empty string. | - | ||||||||||||||||||||||||
860 | - | |||||||||||||||||||||||||
861 | \sa {Namespace Support via Features} | - | ||||||||||||||||||||||||
862 | */ | - | ||||||||||||||||||||||||
863 | QString QXmlAttributes::uri(int index) const | - | ||||||||||||||||||||||||
864 | { | - | ||||||||||||||||||||||||
865 | return attList.at(index).uri; executed 409 times by 1 test: return attList.at(index).uri; Executed by:
| 409 | ||||||||||||||||||||||||
866 | } | - | ||||||||||||||||||||||||
867 | - | |||||||||||||||||||||||||
868 | /*! | - | ||||||||||||||||||||||||
869 | Looks up an attribute's type for the attribute at position \a | - | ||||||||||||||||||||||||
870 | index. | - | ||||||||||||||||||||||||
871 | - | |||||||||||||||||||||||||
872 | Currently only "CDATA" is returned. | - | ||||||||||||||||||||||||
873 | */ | - | ||||||||||||||||||||||||
874 | QString QXmlAttributes::type(int) const | - | ||||||||||||||||||||||||
875 | { | - | ||||||||||||||||||||||||
876 | return QLatin1String("CDATA"); executed 407 times by 1 test: return QLatin1String("CDATA"); Executed by:
| 407 | ||||||||||||||||||||||||
877 | } | - | ||||||||||||||||||||||||
878 | - | |||||||||||||||||||||||||
879 | /*! | - | ||||||||||||||||||||||||
880 | \overload | - | ||||||||||||||||||||||||
881 | - | |||||||||||||||||||||||||
882 | Looks up an attribute's type for the qualified name \a qName. | - | ||||||||||||||||||||||||
883 | - | |||||||||||||||||||||||||
884 | Currently only "CDATA" is returned. | - | ||||||||||||||||||||||||
885 | */ | - | ||||||||||||||||||||||||
886 | QString QXmlAttributes::type(const QString&) const | - | ||||||||||||||||||||||||
887 | { | - | ||||||||||||||||||||||||
888 | return QLatin1String("CDATA"); never executed: return QLatin1String("CDATA"); | 0 | ||||||||||||||||||||||||
889 | } | - | ||||||||||||||||||||||||
890 | - | |||||||||||||||||||||||||
891 | /*! | - | ||||||||||||||||||||||||
892 | \overload | - | ||||||||||||||||||||||||
893 | - | |||||||||||||||||||||||||
894 | Looks up an attribute's type by namespace name. | - | ||||||||||||||||||||||||
895 | - | |||||||||||||||||||||||||
896 | \a uri specifies the namespace URI and \a localName specifies the | - | ||||||||||||||||||||||||
897 | local name. If the name has no namespace URI, use an empty string | - | ||||||||||||||||||||||||
898 | for \a uri. | - | ||||||||||||||||||||||||
899 | - | |||||||||||||||||||||||||
900 | Currently only "CDATA" is returned. | - | ||||||||||||||||||||||||
901 | */ | - | ||||||||||||||||||||||||
902 | QString QXmlAttributes::type(const QString&, const QString&) const | - | ||||||||||||||||||||||||
903 | { | - | ||||||||||||||||||||||||
904 | return QLatin1String("CDATA"); never executed: return QLatin1String("CDATA"); | 0 | ||||||||||||||||||||||||
905 | } | - | ||||||||||||||||||||||||
906 | - | |||||||||||||||||||||||||
907 | /*! | - | ||||||||||||||||||||||||
908 | Returns an attribute's value for the attribute at position \a | - | ||||||||||||||||||||||||
909 | index. The index must be a valid position | - | ||||||||||||||||||||||||
910 | (i.e., 0 <= \a index < count()). | - | ||||||||||||||||||||||||
911 | */ | - | ||||||||||||||||||||||||
912 | QString QXmlAttributes::value(int index) const | - | ||||||||||||||||||||||||
913 | { | - | ||||||||||||||||||||||||
914 | return attList.at(index).value; executed 1287 times by 5 tests: return attList.at(index).value; Executed by:
| 1287 | ||||||||||||||||||||||||
915 | } | - | ||||||||||||||||||||||||
916 | - | |||||||||||||||||||||||||
917 | /*! | - | ||||||||||||||||||||||||
918 | \overload | - | ||||||||||||||||||||||||
919 | - | |||||||||||||||||||||||||
920 | Returns an attribute's value for the qualified name \a qName, or an | - | ||||||||||||||||||||||||
921 | empty string if no attribute exists for the name given. | - | ||||||||||||||||||||||||
922 | - | |||||||||||||||||||||||||
923 | \sa {Namespace Support via Features} | - | ||||||||||||||||||||||||
924 | */ | - | ||||||||||||||||||||||||
925 | QString QXmlAttributes::value(const QString& qName) const | - | ||||||||||||||||||||||||
926 | { | - | ||||||||||||||||||||||||
927 | int i = index(qName); | - | ||||||||||||||||||||||||
928 | if (i == -1)
| 0 | ||||||||||||||||||||||||
929 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
930 | return attList.at(i).value; never executed: return attList.at(i).value; | 0 | ||||||||||||||||||||||||
931 | } | - | ||||||||||||||||||||||||
932 | - | |||||||||||||||||||||||||
933 | /*! | - | ||||||||||||||||||||||||
934 | \overload | - | ||||||||||||||||||||||||
935 | - | |||||||||||||||||||||||||
936 | Returns an attribute's value for the qualified name \a qName, or an | - | ||||||||||||||||||||||||
937 | empty string if no attribute exists for the name given. | - | ||||||||||||||||||||||||
938 | - | |||||||||||||||||||||||||
939 | \sa {Namespace Support via Features} | - | ||||||||||||||||||||||||
940 | */ | - | ||||||||||||||||||||||||
941 | QString QXmlAttributes::value(QLatin1String qName) const | - | ||||||||||||||||||||||||
942 | { | - | ||||||||||||||||||||||||
943 | int i = index(qName); | - | ||||||||||||||||||||||||
944 | if (i == -1)
| 0 | ||||||||||||||||||||||||
945 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
946 | return attList.at(i).value; never executed: return attList.at(i).value; | 0 | ||||||||||||||||||||||||
947 | } | - | ||||||||||||||||||||||||
948 | - | |||||||||||||||||||||||||
949 | /*! | - | ||||||||||||||||||||||||
950 | \overload | - | ||||||||||||||||||||||||
951 | - | |||||||||||||||||||||||||
952 | Returns an attribute's value by namespace name. | - | ||||||||||||||||||||||||
953 | - | |||||||||||||||||||||||||
954 | \a uri specifies the namespace URI, or an empty string if the name | - | ||||||||||||||||||||||||
955 | has no namespace URI. \a localName specifies the attribute's local | - | ||||||||||||||||||||||||
956 | name. | - | ||||||||||||||||||||||||
957 | */ | - | ||||||||||||||||||||||||
958 | QString QXmlAttributes::value(const QString& uri, const QString& localName) const | - | ||||||||||||||||||||||||
959 | { | - | ||||||||||||||||||||||||
960 | int i = index(uri, localName); | - | ||||||||||||||||||||||||
961 | if (i == -1)
| 4320-7751 | ||||||||||||||||||||||||
962 | return QString(); executed 4320 times by 1 test: return QString(); Executed by:
| 4320 | ||||||||||||||||||||||||
963 | return attList.at(i).value; executed 7751 times by 1 test: return attList.at(i).value; Executed by:
| 7751 | ||||||||||||||||||||||||
964 | } | - | ||||||||||||||||||||||||
965 | - | |||||||||||||||||||||||||
966 | /*! | - | ||||||||||||||||||||||||
967 | Clears the list of attributes. | - | ||||||||||||||||||||||||
968 | - | |||||||||||||||||||||||||
969 | \sa append() | - | ||||||||||||||||||||||||
970 | */ | - | ||||||||||||||||||||||||
971 | void QXmlAttributes::clear() | - | ||||||||||||||||||||||||
972 | { | - | ||||||||||||||||||||||||
973 | attList.clear(); | - | ||||||||||||||||||||||||
974 | } executed 5802 times by 6 tests: end of block Executed by:
| 5802 | ||||||||||||||||||||||||
975 | - | |||||||||||||||||||||||||
976 | /*! | - | ||||||||||||||||||||||||
977 | Appends a new attribute entry to the list of attributes. The | - | ||||||||||||||||||||||||
978 | qualified name of the attribute is \a qName, the namespace URI is | - | ||||||||||||||||||||||||
979 | \a uri and the local name is \a localPart. The value of the | - | ||||||||||||||||||||||||
980 | attribute is \a value. | - | ||||||||||||||||||||||||
981 | - | |||||||||||||||||||||||||
982 | \sa qName(), uri(), localName(), value() | - | ||||||||||||||||||||||||
983 | */ | - | ||||||||||||||||||||||||
984 | void QXmlAttributes::append(const QString &qName, const QString &uri, const QString &localPart, const QString &value) | - | ||||||||||||||||||||||||
985 | { | - | ||||||||||||||||||||||||
986 | Attribute att; | - | ||||||||||||||||||||||||
987 | att.qname = qName; | - | ||||||||||||||||||||||||
988 | att.uri = uri; | - | ||||||||||||||||||||||||
989 | att.localname = localPart; | - | ||||||||||||||||||||||||
990 | att.value = value; | - | ||||||||||||||||||||||||
991 | - | |||||||||||||||||||||||||
992 | attList.append(att); | - | ||||||||||||||||||||||||
993 | } executed 12887 times by 6 tests: end of block Executed by:
| 12887 | ||||||||||||||||||||||||
994 | - | |||||||||||||||||||||||||
995 | - | |||||||||||||||||||||||||
996 | /********************************************* | - | ||||||||||||||||||||||||
997 | * | - | ||||||||||||||||||||||||
998 | * QXmlInputSource | - | ||||||||||||||||||||||||
999 | * | - | ||||||||||||||||||||||||
1000 | *********************************************/ | - | ||||||||||||||||||||||||
1001 | - | |||||||||||||||||||||||||
1002 | /*! | - | ||||||||||||||||||||||||
1003 | \class QXmlInputSource | - | ||||||||||||||||||||||||
1004 | \reentrant | - | ||||||||||||||||||||||||
1005 | \brief The QXmlInputSource class provides the input data for the | - | ||||||||||||||||||||||||
1006 | QXmlReader subclasses. | - | ||||||||||||||||||||||||
1007 | - | |||||||||||||||||||||||||
1008 | \inmodule QtXml | - | ||||||||||||||||||||||||
1009 | \ingroup xml-tools | - | ||||||||||||||||||||||||
1010 | - | |||||||||||||||||||||||||
1011 | All subclasses of QXmlReader read the input XML document from this | - | ||||||||||||||||||||||||
1012 | class. | - | ||||||||||||||||||||||||
1013 | - | |||||||||||||||||||||||||
1014 | This class recognizes the encoding of the data by reading the | - | ||||||||||||||||||||||||
1015 | encoding declaration in the XML file if it finds one, and reading | - | ||||||||||||||||||||||||
1016 | the data using the corresponding encoding. If it does not find an | - | ||||||||||||||||||||||||
1017 | encoding declaration, then it assumes that the data is either in | - | ||||||||||||||||||||||||
1018 | UTF-8 or UTF-16, depending on whether it can find a byte-order | - | ||||||||||||||||||||||||
1019 | mark. | - | ||||||||||||||||||||||||
1020 | - | |||||||||||||||||||||||||
1021 | There are two ways to populate the input source with data: you can | - | ||||||||||||||||||||||||
1022 | construct it with a QIODevice* so that the input source reads the | - | ||||||||||||||||||||||||
1023 | data from that device. Or you can set the data explicitly with one | - | ||||||||||||||||||||||||
1024 | of the setData() functions. | - | ||||||||||||||||||||||||
1025 | - | |||||||||||||||||||||||||
1026 | Usually you either construct a QXmlInputSource that works on a | - | ||||||||||||||||||||||||
1027 | QIODevice* or you construct an empty QXmlInputSource and set the | - | ||||||||||||||||||||||||
1028 | data with setData(). There are only rare occasions where you would | - | ||||||||||||||||||||||||
1029 | want to mix both methods. | - | ||||||||||||||||||||||||
1030 | - | |||||||||||||||||||||||||
1031 | The QXmlReader subclasses use the next() function to read the | - | ||||||||||||||||||||||||
1032 | input character by character. If you want to start from the | - | ||||||||||||||||||||||||
1033 | beginning again, use reset(). | - | ||||||||||||||||||||||||
1034 | - | |||||||||||||||||||||||||
1035 | The functions data() and fetchData() are useful if you want to do | - | ||||||||||||||||||||||||
1036 | something with the data other than parsing, e.g. displaying the | - | ||||||||||||||||||||||||
1037 | raw XML file. The benefit of using the QXmlInputClass in such | - | ||||||||||||||||||||||||
1038 | cases is that it tries to use the correct encoding. | - | ||||||||||||||||||||||||
1039 | - | |||||||||||||||||||||||||
1040 | \sa QXmlReader, QXmlSimpleReader | - | ||||||||||||||||||||||||
1041 | */ | - | ||||||||||||||||||||||||
1042 | - | |||||||||||||||||||||||||
1043 | // the following two are guaranteed not to be a character | - | ||||||||||||||||||||||||
1044 | const ushort QXmlInputSource::EndOfData = 0xfffe; | - | ||||||||||||||||||||||||
1045 | const ushort QXmlInputSource::EndOfDocument = 0xffff; | - | ||||||||||||||||||||||||
1046 | - | |||||||||||||||||||||||||
1047 | /* | - | ||||||||||||||||||||||||
1048 | Common part of the constructors. | - | ||||||||||||||||||||||||
1049 | */ | - | ||||||||||||||||||||||||
1050 | void QXmlInputSource::init() | - | ||||||||||||||||||||||||
1051 | { | - | ||||||||||||||||||||||||
1052 | d = new QXmlInputSourcePrivate; | - | ||||||||||||||||||||||||
1053 | - | |||||||||||||||||||||||||
1054 | QT_TRY { | - | ||||||||||||||||||||||||
1055 | d->inputDevice = 0; | - | ||||||||||||||||||||||||
1056 | d->inputStream = 0; | - | ||||||||||||||||||||||||
1057 | - | |||||||||||||||||||||||||
1058 | setData(QString()); | - | ||||||||||||||||||||||||
1059 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||
1060 | d->encMapper = 0; | - | ||||||||||||||||||||||||
1061 | #endif | - | ||||||||||||||||||||||||
1062 | d->nextReturnedEndOfData = true; // first call to next() will call fetchData() | - | ||||||||||||||||||||||||
1063 | - | |||||||||||||||||||||||||
1064 | d->encodingDeclBytes.clear(); | - | ||||||||||||||||||||||||
1065 | d->encodingDeclChars.clear(); | - | ||||||||||||||||||||||||
1066 | d->lookingForEncodingDecl = true; | - | ||||||||||||||||||||||||
1067 | } QT_CATCH(...) { executed 2106 times by 6 tests: end of block Executed by:
dead code: { delete(d); qt_noop(); } | - | ||||||||||||||||||||||||
1068 | delete(d); dead code: { delete(d); qt_noop(); } | - | ||||||||||||||||||||||||
1069 | QT_RETHROW; dead code: { delete(d); qt_noop(); } | - | ||||||||||||||||||||||||
1070 | } dead code: { delete(d); qt_noop(); } | - | ||||||||||||||||||||||||
1071 | } | - | ||||||||||||||||||||||||
1072 | - | |||||||||||||||||||||||||
1073 | /*! | - | ||||||||||||||||||||||||
1074 | Constructs an input source which contains no data. | - | ||||||||||||||||||||||||
1075 | - | |||||||||||||||||||||||||
1076 | \sa setData() | - | ||||||||||||||||||||||||
1077 | */ | - | ||||||||||||||||||||||||
1078 | QXmlInputSource::QXmlInputSource() | - | ||||||||||||||||||||||||
1079 | { | - | ||||||||||||||||||||||||
1080 | init(); | - | ||||||||||||||||||||||||
1081 | } executed 1734 times by 5 tests: end of block Executed by:
| 1734 | ||||||||||||||||||||||||
1082 | - | |||||||||||||||||||||||||
1083 | /*! | - | ||||||||||||||||||||||||
1084 | Constructs an input source and gets the data from device \a dev. | - | ||||||||||||||||||||||||
1085 | If \a dev is not open, it is opened in read-only mode. If \a dev | - | ||||||||||||||||||||||||
1086 | is 0 or it is not possible to read from the device, the input | - | ||||||||||||||||||||||||
1087 | source will contain no data. | - | ||||||||||||||||||||||||
1088 | - | |||||||||||||||||||||||||
1089 | \sa setData(), fetchData(), QIODevice | - | ||||||||||||||||||||||||
1090 | */ | - | ||||||||||||||||||||||||
1091 | QXmlInputSource::QXmlInputSource(QIODevice *dev) | - | ||||||||||||||||||||||||
1092 | { | - | ||||||||||||||||||||||||
1093 | init(); | - | ||||||||||||||||||||||||
1094 | d->inputDevice = dev; | - | ||||||||||||||||||||||||
1095 | if (dev->isOpen())
| 9-363 | ||||||||||||||||||||||||
1096 | d->inputDevice->setTextModeEnabled(false); executed 363 times by 2 tests: d->inputDevice->setTextModeEnabled(false); Executed by:
| 363 | ||||||||||||||||||||||||
1097 | } executed 372 times by 3 tests: end of block Executed by:
| 372 | ||||||||||||||||||||||||
1098 | - | |||||||||||||||||||||||||
1099 | /*! | - | ||||||||||||||||||||||||
1100 | Destructor. | - | ||||||||||||||||||||||||
1101 | */ | - | ||||||||||||||||||||||||
1102 | QXmlInputSource::~QXmlInputSource() | - | ||||||||||||||||||||||||
1103 | { | - | ||||||||||||||||||||||||
1104 | // ### close the input device. | - | ||||||||||||||||||||||||
1105 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||
1106 | delete d->encMapper; | - | ||||||||||||||||||||||||
1107 | #endif | - | ||||||||||||||||||||||||
1108 | delete d; | - | ||||||||||||||||||||||||
1109 | } executed 2106 times by 6 tests: end of block Executed by:
| 2106 | ||||||||||||||||||||||||
1110 | - | |||||||||||||||||||||||||
1111 | /*! | - | ||||||||||||||||||||||||
1112 | Returns the next character of the input source. If this function | - | ||||||||||||||||||||||||
1113 | reaches the end of available data, it returns | - | ||||||||||||||||||||||||
1114 | QXmlInputSource::EndOfData. If you call next() after that, it | - | ||||||||||||||||||||||||
1115 | tries to fetch more data by calling fetchData(). If the | - | ||||||||||||||||||||||||
1116 | fetchData() call results in new data, this function returns the | - | ||||||||||||||||||||||||
1117 | first character of that data; otherwise it returns | - | ||||||||||||||||||||||||
1118 | QXmlInputSource::EndOfDocument. | - | ||||||||||||||||||||||||
1119 | - | |||||||||||||||||||||||||
1120 | Readers, such as QXmlSimpleReader, will assume that the end of | - | ||||||||||||||||||||||||
1121 | the XML document has been reached if the this function returns | - | ||||||||||||||||||||||||
1122 | QXmlInputSource::EndOfDocument, and will check that the | - | ||||||||||||||||||||||||
1123 | supplied input is well-formed. Therefore, when reimplementing | - | ||||||||||||||||||||||||
1124 | this function, it is important to ensure that this behavior is | - | ||||||||||||||||||||||||
1125 | duplicated. | - | ||||||||||||||||||||||||
1126 | - | |||||||||||||||||||||||||
1127 | \sa reset(), fetchData(), QXmlSimpleReader::parse(), | - | ||||||||||||||||||||||||
1128 | QXmlSimpleReader::parseContinue() | - | ||||||||||||||||||||||||
1129 | */ | - | ||||||||||||||||||||||||
1130 | QChar QXmlInputSource::next() | - | ||||||||||||||||||||||||
1131 | { | - | ||||||||||||||||||||||||
1132 | if (d->pos >= d->length) {
| 48748-744723 | ||||||||||||||||||||||||
1133 | if (d->nextReturnedEndOfData) {
| 2851-45897 | ||||||||||||||||||||||||
1134 | d->nextReturnedEndOfData = false; | - | ||||||||||||||||||||||||
1135 | fetchData(); | - | ||||||||||||||||||||||||
1136 | if (d->pos >= d->length) {
| 890-1961 | ||||||||||||||||||||||||
1137 | return EndOfDocument; executed 1961 times by 6 tests: return EndOfDocument; Executed by:
| 1961 | ||||||||||||||||||||||||
1138 | } | - | ||||||||||||||||||||||||
1139 | return next(); executed 890 times by 3 tests: return next(); Executed by:
| 890 | ||||||||||||||||||||||||
1140 | } | - | ||||||||||||||||||||||||
1141 | d->nextReturnedEndOfData = true; | - | ||||||||||||||||||||||||
1142 | return EndOfData; executed 45897 times by 6 tests: return EndOfData; Executed by:
| 45897 | ||||||||||||||||||||||||
1143 | } | - | ||||||||||||||||||||||||
1144 | - | |||||||||||||||||||||||||
1145 | // QXmlInputSource has no way to signal encoding errors. The best we can do | - | ||||||||||||||||||||||||
1146 | // is return EndOfDocument. We do *not* return EndOfData, because the reader | - | ||||||||||||||||||||||||
1147 | // will then just call this function again to get the next char. | - | ||||||||||||||||||||||||
1148 | QChar c = d->unicode[d->pos++]; | - | ||||||||||||||||||||||||
1149 | if (c.unicode() == EndOfData)
| 1-744722 | ||||||||||||||||||||||||
1150 | c = EndOfDocument; executed 1 time by 1 test: c = EndOfDocument; Executed by:
| 1 | ||||||||||||||||||||||||
1151 | return c; executed 744723 times by 6 tests: return c; Executed by:
| 744723 | ||||||||||||||||||||||||
1152 | } | - | ||||||||||||||||||||||||
1153 | - | |||||||||||||||||||||||||
1154 | /*! | - | ||||||||||||||||||||||||
1155 | This function sets the position used by next() to the beginning of | - | ||||||||||||||||||||||||
1156 | the data returned by data(). This is useful if you want to use the | - | ||||||||||||||||||||||||
1157 | input source for more than one parse. | - | ||||||||||||||||||||||||
1158 | - | |||||||||||||||||||||||||
1159 | \note In the case that the underlying data source is a QIODevice, | - | ||||||||||||||||||||||||
1160 | the current position in the device is not automatically set to the | - | ||||||||||||||||||||||||
1161 | start of input. Call QIODevice::seek(0) on the device to do this. | - | ||||||||||||||||||||||||
1162 | - | |||||||||||||||||||||||||
1163 | \sa next() | - | ||||||||||||||||||||||||
1164 | */ | - | ||||||||||||||||||||||||
1165 | void QXmlInputSource::reset() | - | ||||||||||||||||||||||||
1166 | { | - | ||||||||||||||||||||||||
1167 | d->nextReturnedEndOfData = false; | - | ||||||||||||||||||||||||
1168 | d->pos = 0; | - | ||||||||||||||||||||||||
1169 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1170 | - | |||||||||||||||||||||||||
1171 | /*! | - | ||||||||||||||||||||||||
1172 | Returns the data the input source contains or an empty string if the | - | ||||||||||||||||||||||||
1173 | input source does not contain any data. | - | ||||||||||||||||||||||||
1174 | - | |||||||||||||||||||||||||
1175 | \sa setData(), QXmlInputSource(), fetchData() | - | ||||||||||||||||||||||||
1176 | */ | - | ||||||||||||||||||||||||
1177 | QString QXmlInputSource::data() const | - | ||||||||||||||||||||||||
1178 | { | - | ||||||||||||||||||||||||
1179 | if (d->nextReturnedEndOfData) {
| 0-4 | ||||||||||||||||||||||||
1180 | QXmlInputSource *that = const_cast<QXmlInputSource*>(this); | - | ||||||||||||||||||||||||
1181 | that->d->nextReturnedEndOfData = false; | - | ||||||||||||||||||||||||
1182 | that->fetchData(); | - | ||||||||||||||||||||||||
1183 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1184 | return d->str; executed 4 times by 1 test: return d->str; Executed by:
| 4 | ||||||||||||||||||||||||
1185 | } | - | ||||||||||||||||||||||||
1186 | - | |||||||||||||||||||||||||
1187 | /*! | - | ||||||||||||||||||||||||
1188 | Sets the data of the input source to \a dat. | - | ||||||||||||||||||||||||
1189 | - | |||||||||||||||||||||||||
1190 | If the input source already contains data, this function deletes | - | ||||||||||||||||||||||||
1191 | that data first. | - | ||||||||||||||||||||||||
1192 | - | |||||||||||||||||||||||||
1193 | \sa data() | - | ||||||||||||||||||||||||
1194 | */ | - | ||||||||||||||||||||||||
1195 | void QXmlInputSource::setData(const QString& dat) | - | ||||||||||||||||||||||||
1196 | { | - | ||||||||||||||||||||||||
1197 | d->str = dat; | - | ||||||||||||||||||||||||
1198 | d->unicode = dat.unicode(); | - | ||||||||||||||||||||||||
1199 | d->pos = 0; | - | ||||||||||||||||||||||||
1200 | d->length = d->str.length(); | - | ||||||||||||||||||||||||
1201 | d->nextReturnedEndOfData = false; | - | ||||||||||||||||||||||||
1202 | } executed 48375 times by 6 tests: end of block Executed by:
| 48375 | ||||||||||||||||||||||||
1203 | - | |||||||||||||||||||||||||
1204 | /*! | - | ||||||||||||||||||||||||
1205 | \overload | - | ||||||||||||||||||||||||
1206 | - | |||||||||||||||||||||||||
1207 | The data \a dat is passed through the correct text-codec, before | - | ||||||||||||||||||||||||
1208 | it is set. | - | ||||||||||||||||||||||||
1209 | */ | - | ||||||||||||||||||||||||
1210 | void QXmlInputSource::setData(const QByteArray& dat) | - | ||||||||||||||||||||||||
1211 | { | - | ||||||||||||||||||||||||
1212 | setData(fromRawData(dat)); | - | ||||||||||||||||||||||||
1213 | } executed 44908 times by 1 test: end of block Executed by:
| 44908 | ||||||||||||||||||||||||
1214 | - | |||||||||||||||||||||||||
1215 | /*! | - | ||||||||||||||||||||||||
1216 | This function reads more data from the device that was set during | - | ||||||||||||||||||||||||
1217 | construction. If the input source already contained data, this | - | ||||||||||||||||||||||||
1218 | function deletes that data first. | - | ||||||||||||||||||||||||
1219 | - | |||||||||||||||||||||||||
1220 | This object contains no data after a call to this function if the | - | ||||||||||||||||||||||||
1221 | object was constructed without a device to read data from or if | - | ||||||||||||||||||||||||
1222 | this function was not able to get more data from the device. | - | ||||||||||||||||||||||||
1223 | - | |||||||||||||||||||||||||
1224 | There are two occasions where a fetch is done implicitly by | - | ||||||||||||||||||||||||
1225 | another function call: during construction (so that the object | - | ||||||||||||||||||||||||
1226 | starts out with some initial data where available), and during a | - | ||||||||||||||||||||||||
1227 | call to next() (if the data had run out). | - | ||||||||||||||||||||||||
1228 | - | |||||||||||||||||||||||||
1229 | You don't normally need to use this function if you use next(). | - | ||||||||||||||||||||||||
1230 | - | |||||||||||||||||||||||||
1231 | \sa data(), next(), QXmlInputSource() | - | ||||||||||||||||||||||||
1232 | */ | - | ||||||||||||||||||||||||
1233 | - | |||||||||||||||||||||||||
1234 | void QXmlInputSource::fetchData() | - | ||||||||||||||||||||||||
1235 | { | - | ||||||||||||||||||||||||
1236 | enum | - | ||||||||||||||||||||||||
1237 | { | - | ||||||||||||||||||||||||
1238 | BufferSize = 1024 | - | ||||||||||||||||||||||||
1239 | }; | - | ||||||||||||||||||||||||
1240 | - | |||||||||||||||||||||||||
1241 | QByteArray rawData; | - | ||||||||||||||||||||||||
1242 | - | |||||||||||||||||||||||||
1243 | if (d->inputDevice || d->inputStream) {
| 0-1734 | ||||||||||||||||||||||||
1244 | QIODevice *device = d->inputDevice ? d->inputDevice : d->inputStream->device();
| 0-1117 | ||||||||||||||||||||||||
1245 | - | |||||||||||||||||||||||||
1246 | if (!device) {
| 0-1117 | ||||||||||||||||||||||||
1247 | if (d->inputStream && d->inputStream->string()) {
| 0 | ||||||||||||||||||||||||
1248 | QString *s = d->inputStream->string(); | - | ||||||||||||||||||||||||
1249 | rawData = QByteArray((const char *) s->constData(), s->size() * sizeof(QChar)); | - | ||||||||||||||||||||||||
1250 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1251 | } else if (device->isOpen() || device->open(QIODevice::ReadOnly)) { never executed: end of block
| 0-1108 | ||||||||||||||||||||||||
1252 | rawData.resize(BufferSize); | - | ||||||||||||||||||||||||
1253 | qint64 size = device->read(rawData.data(), BufferSize); | - | ||||||||||||||||||||||||
1254 | - | |||||||||||||||||||||||||
1255 | if (size != -1) {
| 0-1117 | ||||||||||||||||||||||||
1256 | // We don't want to give fromRawData() less than four bytes if we can avoid it. | - | ||||||||||||||||||||||||
1257 | while (size < 4) {
| 235-890 | ||||||||||||||||||||||||
1258 | if (!device->waitForReadyRead(-1))
| 8-227 | ||||||||||||||||||||||||
1259 | break; executed 227 times by 3 tests: break; Executed by:
| 227 | ||||||||||||||||||||||||
1260 | int ret = device->read(rawData.data() + size, BufferSize - size); | - | ||||||||||||||||||||||||
1261 | if (ret <= 0)
| 0-8 | ||||||||||||||||||||||||
1262 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1263 | size += ret; | - | ||||||||||||||||||||||||
1264 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1265 | } executed 1117 times by 3 tests: end of block Executed by:
| 1117 | ||||||||||||||||||||||||
1266 | - | |||||||||||||||||||||||||
1267 | rawData.resize(qMax(qint64(0), size)); | - | ||||||||||||||||||||||||
1268 | } executed 1117 times by 3 tests: end of block Executed by:
| 1117 | ||||||||||||||||||||||||
1269 | - | |||||||||||||||||||||||||
1270 | /* We do this inside the "if (d->inputDevice ..." scope | - | ||||||||||||||||||||||||
1271 | * because if we're not using a stream or device, that is, | - | ||||||||||||||||||||||||
1272 | * the user set a QString manually, we don't want to set | - | ||||||||||||||||||||||||
1273 | * d->str. */ | - | ||||||||||||||||||||||||
1274 | setData(fromRawData(rawData)); | - | ||||||||||||||||||||||||
1275 | } executed 1117 times by 3 tests: end of block Executed by:
| 1117 | ||||||||||||||||||||||||
1276 | } executed 2851 times by 6 tests: end of block Executed by:
| 2851 | ||||||||||||||||||||||||
1277 | - | |||||||||||||||||||||||||
1278 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||
1279 | static QString extractEncodingDecl(const QString &text, bool *needMoreText) | - | ||||||||||||||||||||||||
1280 | { | - | ||||||||||||||||||||||||
1281 | *needMoreText = false; | - | ||||||||||||||||||||||||
1282 | - | |||||||||||||||||||||||||
1283 | int l = text.length(); | - | ||||||||||||||||||||||||
1284 | QString snip = QString::fromLatin1("<?xml").left(l); | - | ||||||||||||||||||||||||
1285 | if (l > 0 && !text.startsWith(snip))
| 6-3097 | ||||||||||||||||||||||||
1286 | return QString(); executed 1742 times by 2 tests: return QString(); Executed by:
| 1742 | ||||||||||||||||||||||||
1287 | - | |||||||||||||||||||||||||
1288 | int endPos = text.indexOf(QLatin1Char('>')); | - | ||||||||||||||||||||||||
1289 | if (endPos == -1) {
| 119-1242 | ||||||||||||||||||||||||
1290 | *needMoreText = l < 255; // we won't look forever | - | ||||||||||||||||||||||||
1291 | return QString(); executed 1242 times by 1 test: return QString(); Executed by:
| 1242 | ||||||||||||||||||||||||
1292 | } | - | ||||||||||||||||||||||||
1293 | - | |||||||||||||||||||||||||
1294 | int pos = text.indexOf(QLatin1String("encoding")); | - | ||||||||||||||||||||||||
1295 | if (pos == -1 || pos >= endPos)
| 0-67 | ||||||||||||||||||||||||
1296 | return QString(); executed 52 times by 1 test: return QString(); Executed by:
| 52 | ||||||||||||||||||||||||
1297 | - | |||||||||||||||||||||||||
1298 | while (pos < endPos) {
| 0-670 | ||||||||||||||||||||||||
1299 | ushort uc = text.at(pos).unicode(); | - | ||||||||||||||||||||||||
1300 | if (uc == '\'' || uc == '"')
| 0-670 | ||||||||||||||||||||||||
1301 | break; executed 67 times by 2 tests: break; Executed by:
| 67 | ||||||||||||||||||||||||
1302 | ++pos; | - | ||||||||||||||||||||||||
1303 | } executed 603 times by 2 tests: end of block Executed by:
| 603 | ||||||||||||||||||||||||
1304 | - | |||||||||||||||||||||||||
1305 | if (pos == endPos)
| 0-67 | ||||||||||||||||||||||||
1306 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
1307 | - | |||||||||||||||||||||||||
1308 | QString encoding; | - | ||||||||||||||||||||||||
1309 | ++pos; | - | ||||||||||||||||||||||||
1310 | while (pos < endPos) {
| 0-404 | ||||||||||||||||||||||||
1311 | ushort uc = text.at(pos).unicode(); | - | ||||||||||||||||||||||||
1312 | if (uc == '\'' || uc == '"')
| 0-404 | ||||||||||||||||||||||||
1313 | break; executed 67 times by 2 tests: break; Executed by:
| 67 | ||||||||||||||||||||||||
1314 | encoding.append(uc); | - | ||||||||||||||||||||||||
1315 | ++pos; | - | ||||||||||||||||||||||||
1316 | } executed 337 times by 2 tests: end of block Executed by:
| 337 | ||||||||||||||||||||||||
1317 | - | |||||||||||||||||||||||||
1318 | return encoding; executed 67 times by 2 tests: return encoding; Executed by:
| 67 | ||||||||||||||||||||||||
1319 | } | - | ||||||||||||||||||||||||
1320 | #endif // QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||
1321 | - | |||||||||||||||||||||||||
1322 | /*! | - | ||||||||||||||||||||||||
1323 | This function reads the XML file from \a data and tries to | - | ||||||||||||||||||||||||
1324 | recognize the encoding. It converts the raw data \a data into a | - | ||||||||||||||||||||||||
1325 | QString and returns it. It tries its best to get the correct | - | ||||||||||||||||||||||||
1326 | encoding for the XML file. | - | ||||||||||||||||||||||||
1327 | - | |||||||||||||||||||||||||
1328 | If \a beginning is true, this function assumes that the data | - | ||||||||||||||||||||||||
1329 | starts at the beginning of a new XML document and looks for an | - | ||||||||||||||||||||||||
1330 | encoding declaration. If \a beginning is false, it converts the | - | ||||||||||||||||||||||||
1331 | raw data using the encoding determined from prior calls. | - | ||||||||||||||||||||||||
1332 | */ | - | ||||||||||||||||||||||||
1333 | QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) | - | ||||||||||||||||||||||||
1334 | { | - | ||||||||||||||||||||||||
1335 | #ifdef QT_NO_TEXTCODEC | - | ||||||||||||||||||||||||
1336 | Q_UNUSED(beginning); | - | ||||||||||||||||||||||||
1337 | return QString::fromLatin1(data.constData(), data.size()); | - | ||||||||||||||||||||||||
1338 | #else | - | ||||||||||||||||||||||||
1339 | if (data.size() == 0)
| 227-45798 | ||||||||||||||||||||||||
1340 | return QString(); executed 227 times by 3 tests: return QString(); Executed by:
| 227 | ||||||||||||||||||||||||
1341 | if (beginning) {
| 0-45798 | ||||||||||||||||||||||||
1342 | delete d->encMapper; | - | ||||||||||||||||||||||||
1343 | d->encMapper = 0; | - | ||||||||||||||||||||||||
1344 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1345 | - | |||||||||||||||||||||||||
1346 | int mib = 106; // UTF-8 | - | ||||||||||||||||||||||||
1347 | - | |||||||||||||||||||||||||
1348 | // This is the initial UTF codec we will read the encoding declaration with | - | ||||||||||||||||||||||||
1349 | if (d->encMapper == 0) {
| 1861-43937 | ||||||||||||||||||||||||
1350 | d->encodingDeclBytes.clear(); | - | ||||||||||||||||||||||||
1351 | d->encodingDeclChars.clear(); | - | ||||||||||||||||||||||||
1352 | d->lookingForEncodingDecl = true; | - | ||||||||||||||||||||||||
1353 | - | |||||||||||||||||||||||||
1354 | // look for byte order mark and read the first 5 characters | - | ||||||||||||||||||||||||
1355 | if (data.size() >= 4) {
| 494-1367 | ||||||||||||||||||||||||
1356 | uchar ch1 = data.at(0); | - | ||||||||||||||||||||||||
1357 | uchar ch2 = data.at(1); | - | ||||||||||||||||||||||||
1358 | uchar ch3 = data.at(2); | - | ||||||||||||||||||||||||
1359 | uchar ch4 = data.at(3); | - | ||||||||||||||||||||||||
1360 | - | |||||||||||||||||||||||||
1361 | if ((ch1 == 0 && ch2 == 0 && ch3 == 0xfe && ch4 == 0xff) ||
| 0-1367 | ||||||||||||||||||||||||
1362 | (ch1 == 0xff && ch2 == 0xfe && ch3 == 0 && ch4 == 0))
| 0-1345 | ||||||||||||||||||||||||
1363 | mib = 1017; // UTF-32 with byte order mark never executed: mib = 1017; | 0 | ||||||||||||||||||||||||
1364 | else if (ch1 == 0x3c && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x00)
| 0-1343 | ||||||||||||||||||||||||
1365 | mib = 1019; // UTF-32LE never executed: mib = 1019; | 0 | ||||||||||||||||||||||||
1366 | else if (ch1 == 0x00 && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x3c)
| 0-1367 | ||||||||||||||||||||||||
1367 | mib = 1018; // UTF-32BE never executed: mib = 1018; | 0 | ||||||||||||||||||||||||
1368 | } executed 1367 times by 3 tests: end of block Executed by:
| 1367 | ||||||||||||||||||||||||
1369 | if (mib == 106 && data.size() >= 2) {
| 0-1861 | ||||||||||||||||||||||||
1370 | uchar ch1 = data.at(0); | - | ||||||||||||||||||||||||
1371 | uchar ch2 = data.at(1); | - | ||||||||||||||||||||||||
1372 | - | |||||||||||||||||||||||||
1373 | if ((ch1 == 0xfe && ch2 == 0xff) || (ch1 == 0xff && ch2 == 0xfe))
| 0-1698 | ||||||||||||||||||||||||
1374 | mib = 1015; // UTF-16 with byte order mark executed 29 times by 1 test: mib = 1015; Executed by:
| 29 | ||||||||||||||||||||||||
1375 | else if (ch1 == 0x3c && ch2 == 0x00)
| 1-1669 | ||||||||||||||||||||||||
1376 | mib = 1014; // UTF-16LE executed 1 time by 1 test: mib = 1014; Executed by:
| 1 | ||||||||||||||||||||||||
1377 | else if (ch1 == 0x00 && ch2 == 0x3c)
| 0-1669 | ||||||||||||||||||||||||
1378 | mib = 1013; // UTF-16BE never executed: mib = 1013; | 0 | ||||||||||||||||||||||||
1379 | } executed 1699 times by 3 tests: end of block Executed by:
| 1699 | ||||||||||||||||||||||||
1380 | - | |||||||||||||||||||||||||
1381 | QTextCodec *codec = QTextCodec::codecForMib(mib); | - | ||||||||||||||||||||||||
1382 | Q_ASSERT(codec); | - | ||||||||||||||||||||||||
1383 | - | |||||||||||||||||||||||||
1384 | d->encMapper = codec->makeDecoder(); | - | ||||||||||||||||||||||||
1385 | } executed 1861 times by 3 tests: end of block Executed by:
| 1861 | ||||||||||||||||||||||||
1386 | - | |||||||||||||||||||||||||
1387 | QString input = d->encMapper->toUnicode(data.constData(), data.size()); | - | ||||||||||||||||||||||||
1388 | - | |||||||||||||||||||||||||
1389 | if (d->lookingForEncodingDecl) {
| 3103-42695 | ||||||||||||||||||||||||
1390 | d->encodingDeclChars += input; | - | ||||||||||||||||||||||||
1391 | - | |||||||||||||||||||||||||
1392 | bool needMoreText; | - | ||||||||||||||||||||||||
1393 | QString encoding = extractEncodingDecl(d->encodingDeclChars, &needMoreText); | - | ||||||||||||||||||||||||
1394 | - | |||||||||||||||||||||||||
1395 | if (!encoding.isEmpty()) {
| 67-3036 | ||||||||||||||||||||||||
1396 | if (QTextCodec *codec = QTextCodec::codecForName(encoding.toLatin1())) {
| 0-67 | ||||||||||||||||||||||||
1397 | /* If the encoding is the same, we don't have to do toUnicode() all over again. */ | - | ||||||||||||||||||||||||
1398 | if(codec->mibEnum() != mib) {
| 1-66 | ||||||||||||||||||||||||
1399 | delete d->encMapper; | - | ||||||||||||||||||||||||
1400 | d->encMapper = codec->makeDecoder(); | - | ||||||||||||||||||||||||
1401 | - | |||||||||||||||||||||||||
1402 | /* The variable input can potentially be large, so we deallocate | - | ||||||||||||||||||||||||
1403 | * it before calling toUnicode() in order to avoid having two | - | ||||||||||||||||||||||||
1404 | * large QStrings in memory simultaneously. */ | - | ||||||||||||||||||||||||
1405 | input.clear(); | - | ||||||||||||||||||||||||
1406 | - | |||||||||||||||||||||||||
1407 | // prime the decoder with the data so far | - | ||||||||||||||||||||||||
1408 | d->encMapper->toUnicode(d->encodingDeclBytes.constData(), d->encodingDeclBytes.size()); | - | ||||||||||||||||||||||||
1409 | // now feed it the new data | - | ||||||||||||||||||||||||
1410 | input = d->encMapper->toUnicode(data.constData(), data.size()); | - | ||||||||||||||||||||||||
1411 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
1412 | } executed 67 times by 2 tests: end of block Executed by:
| 67 | ||||||||||||||||||||||||
1413 | } executed 67 times by 2 tests: end of block Executed by:
| 67 | ||||||||||||||||||||||||
1414 | - | |||||||||||||||||||||||||
1415 | d->encodingDeclBytes += data; | - | ||||||||||||||||||||||||
1416 | d->lookingForEncodingDecl = needMoreText; | - | ||||||||||||||||||||||||
1417 | } executed 3103 times by 3 tests: end of block Executed by:
| 3103 | ||||||||||||||||||||||||
1418 | - | |||||||||||||||||||||||||
1419 | return input; executed 45798 times by 3 tests: return input; Executed by:
| 45798 | ||||||||||||||||||||||||
1420 | #endif | - | ||||||||||||||||||||||||
1421 | } | - | ||||||||||||||||||||||||
1422 | - | |||||||||||||||||||||||||
1423 | - | |||||||||||||||||||||||||
1424 | /********************************************* | - | ||||||||||||||||||||||||
1425 | * | - | ||||||||||||||||||||||||
1426 | * QXmlDefaultHandler | - | ||||||||||||||||||||||||
1427 | * | - | ||||||||||||||||||||||||
1428 | *********************************************/ | - | ||||||||||||||||||||||||
1429 | - | |||||||||||||||||||||||||
1430 | /*! | - | ||||||||||||||||||||||||
1431 | \class QXmlContentHandler | - | ||||||||||||||||||||||||
1432 | \reentrant | - | ||||||||||||||||||||||||
1433 | \brief The QXmlContentHandler class provides an interface to | - | ||||||||||||||||||||||||
1434 | report the logical content of XML data. | - | ||||||||||||||||||||||||
1435 | - | |||||||||||||||||||||||||
1436 | \inmodule QtXml | - | ||||||||||||||||||||||||
1437 | \ingroup xml-tools | - | ||||||||||||||||||||||||
1438 | - | |||||||||||||||||||||||||
1439 | If the application needs to be informed of basic parsing events, | - | ||||||||||||||||||||||||
1440 | it can implement this interface and activate it using | - | ||||||||||||||||||||||||
1441 | QXmlReader::setContentHandler(). The reader can then report basic | - | ||||||||||||||||||||||||
1442 | document-related events like the start and end of elements and | - | ||||||||||||||||||||||||
1443 | character data through this interface. | - | ||||||||||||||||||||||||
1444 | - | |||||||||||||||||||||||||
1445 | The order of events in this interface is very important, and | - | ||||||||||||||||||||||||
1446 | mirrors the order of information in the document itself. For | - | ||||||||||||||||||||||||
1447 | example, all of an element's content (character data, processing | - | ||||||||||||||||||||||||
1448 | instructions, and sub-elements) appears, in order, between the | - | ||||||||||||||||||||||||
1449 | startElement() event and the corresponding endElement() event. | - | ||||||||||||||||||||||||
1450 | - | |||||||||||||||||||||||||
1451 | The class QXmlDefaultHandler provides a default implementation for | - | ||||||||||||||||||||||||
1452 | this interface; subclassing from the QXmlDefaultHandler class is | - | ||||||||||||||||||||||||
1453 | very convenient if you only want to be informed of some parsing | - | ||||||||||||||||||||||||
1454 | events. | - | ||||||||||||||||||||||||
1455 | - | |||||||||||||||||||||||||
1456 | The startDocument() function is called at the start of the | - | ||||||||||||||||||||||||
1457 | document, and endDocument() is called at the end. Before parsing | - | ||||||||||||||||||||||||
1458 | begins setDocumentLocator() is called. For each element | - | ||||||||||||||||||||||||
1459 | startElement() is called, with endElement() being called at the | - | ||||||||||||||||||||||||
1460 | end of each element. The characters() function is called with | - | ||||||||||||||||||||||||
1461 | chunks of character data; ignorableWhitespace() is called with | - | ||||||||||||||||||||||||
1462 | chunks of whitespace and processingInstruction() is called with | - | ||||||||||||||||||||||||
1463 | processing instructions. If an entity is skipped skippedEntity() | - | ||||||||||||||||||||||||
1464 | is called. At the beginning of prefix-URI scopes | - | ||||||||||||||||||||||||
1465 | startPrefixMapping() is called. | - | ||||||||||||||||||||||||
1466 | - | |||||||||||||||||||||||||
1467 | \sa QXmlDTDHandler, QXmlDeclHandler, QXmlEntityResolver, QXmlErrorHandler, | - | ||||||||||||||||||||||||
1468 | QXmlLexicalHandler, {Introduction to SAX2} | - | ||||||||||||||||||||||||
1469 | */ | - | ||||||||||||||||||||||||
1470 | - | |||||||||||||||||||||||||
1471 | /*! | - | ||||||||||||||||||||||||
1472 | \fn QXmlContentHandler::~QXmlContentHandler() | - | ||||||||||||||||||||||||
1473 | - | |||||||||||||||||||||||||
1474 | Destroys the content handler. | - | ||||||||||||||||||||||||
1475 | */ | - | ||||||||||||||||||||||||
1476 | - | |||||||||||||||||||||||||
1477 | /*! | - | ||||||||||||||||||||||||
1478 | \fn void QXmlContentHandler::setDocumentLocator(QXmlLocator* locator) | - | ||||||||||||||||||||||||
1479 | - | |||||||||||||||||||||||||
1480 | The reader calls this function before it starts parsing the | - | ||||||||||||||||||||||||
1481 | document. The argument \a locator is a pointer to a QXmlLocator | - | ||||||||||||||||||||||||
1482 | which allows the application to get the parsing position within | - | ||||||||||||||||||||||||
1483 | the document. | - | ||||||||||||||||||||||||
1484 | - | |||||||||||||||||||||||||
1485 | Do not destroy the \a locator; it is destroyed when the reader is | - | ||||||||||||||||||||||||
1486 | destroyed. (Do not use the \a locator after the reader is | - | ||||||||||||||||||||||||
1487 | destroyed). | - | ||||||||||||||||||||||||
1488 | */ | - | ||||||||||||||||||||||||
1489 | - | |||||||||||||||||||||||||
1490 | /*! | - | ||||||||||||||||||||||||
1491 | \fn bool QXmlContentHandler::startDocument() | - | ||||||||||||||||||||||||
1492 | - | |||||||||||||||||||||||||
1493 | The reader calls this function when it starts parsing the | - | ||||||||||||||||||||||||
1494 | document. The reader calls this function just once, after the call | - | ||||||||||||||||||||||||
1495 | to setDocumentLocator(), and before any other functions in this | - | ||||||||||||||||||||||||
1496 | class or in the QXmlDTDHandler class are called. | - | ||||||||||||||||||||||||
1497 | - | |||||||||||||||||||||||||
1498 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1499 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1500 | get the error message. | - | ||||||||||||||||||||||||
1501 | - | |||||||||||||||||||||||||
1502 | \sa endDocument() | - | ||||||||||||||||||||||||
1503 | */ | - | ||||||||||||||||||||||||
1504 | - | |||||||||||||||||||||||||
1505 | /*! | - | ||||||||||||||||||||||||
1506 | \fn bool QXmlContentHandler::endDocument() | - | ||||||||||||||||||||||||
1507 | - | |||||||||||||||||||||||||
1508 | The reader calls this function after it has finished parsing. It | - | ||||||||||||||||||||||||
1509 | is called just once, and is the last handler function called. It | - | ||||||||||||||||||||||||
1510 | is called after the reader has read all input or has abandoned | - | ||||||||||||||||||||||||
1511 | parsing because of a fatal error. | - | ||||||||||||||||||||||||
1512 | - | |||||||||||||||||||||||||
1513 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1514 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1515 | get the error message. | - | ||||||||||||||||||||||||
1516 | - | |||||||||||||||||||||||||
1517 | \sa startDocument() | - | ||||||||||||||||||||||||
1518 | */ | - | ||||||||||||||||||||||||
1519 | - | |||||||||||||||||||||||||
1520 | /*! | - | ||||||||||||||||||||||||
1521 | \fn bool QXmlContentHandler::startPrefixMapping(const QString& prefix, const QString& uri) | - | ||||||||||||||||||||||||
1522 | - | |||||||||||||||||||||||||
1523 | The reader calls this function to signal the begin of a prefix-URI | - | ||||||||||||||||||||||||
1524 | namespace mapping scope. This information is not necessary for | - | ||||||||||||||||||||||||
1525 | normal namespace processing since the reader automatically | - | ||||||||||||||||||||||||
1526 | replaces prefixes for element and attribute names. | - | ||||||||||||||||||||||||
1527 | - | |||||||||||||||||||||||||
1528 | Note that startPrefixMapping() and endPrefixMapping() calls are | - | ||||||||||||||||||||||||
1529 | not guaranteed to be properly nested relative to each other: all | - | ||||||||||||||||||||||||
1530 | startPrefixMapping() events occur before the corresponding | - | ||||||||||||||||||||||||
1531 | startElement() event, and all endPrefixMapping() events occur | - | ||||||||||||||||||||||||
1532 | after the corresponding endElement() event, but their order is not | - | ||||||||||||||||||||||||
1533 | otherwise guaranteed. | - | ||||||||||||||||||||||||
1534 | - | |||||||||||||||||||||||||
1535 | The argument \a prefix is the namespace prefix being declared and | - | ||||||||||||||||||||||||
1536 | the argument \a uri is the namespace URI the prefix is mapped to. | - | ||||||||||||||||||||||||
1537 | - | |||||||||||||||||||||||||
1538 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1539 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1540 | get the error message. | - | ||||||||||||||||||||||||
1541 | - | |||||||||||||||||||||||||
1542 | \sa endPrefixMapping(), {Namespace Support via Features} | - | ||||||||||||||||||||||||
1543 | */ | - | ||||||||||||||||||||||||
1544 | - | |||||||||||||||||||||||||
1545 | /*! | - | ||||||||||||||||||||||||
1546 | \fn bool QXmlContentHandler::endPrefixMapping(const QString& prefix) | - | ||||||||||||||||||||||||
1547 | - | |||||||||||||||||||||||||
1548 | The reader calls this function to signal the end of a prefix | - | ||||||||||||||||||||||||
1549 | mapping for the prefix \a prefix. | - | ||||||||||||||||||||||||
1550 | - | |||||||||||||||||||||||||
1551 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1552 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1553 | get the error message. | - | ||||||||||||||||||||||||
1554 | - | |||||||||||||||||||||||||
1555 | \sa startPrefixMapping(), {Namespace Support via Features} | - | ||||||||||||||||||||||||
1556 | */ | - | ||||||||||||||||||||||||
1557 | - | |||||||||||||||||||||||||
1558 | /*! | - | ||||||||||||||||||||||||
1559 | \fn bool QXmlContentHandler::startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts) | - | ||||||||||||||||||||||||
1560 | - | |||||||||||||||||||||||||
1561 | The reader calls this function when it has parsed a start element | - | ||||||||||||||||||||||||
1562 | tag. | - | ||||||||||||||||||||||||
1563 | - | |||||||||||||||||||||||||
1564 | There is a corresponding endElement() call when the corresponding | - | ||||||||||||||||||||||||
1565 | end element tag is read. The startElement() and endElement() calls | - | ||||||||||||||||||||||||
1566 | are always nested correctly. Empty element tags (e.g. \c{<x/>}) | - | ||||||||||||||||||||||||
1567 | cause a startElement() call to be immediately followed by an | - | ||||||||||||||||||||||||
1568 | endElement() call. | - | ||||||||||||||||||||||||
1569 | - | |||||||||||||||||||||||||
1570 | The attribute list provided only contains attributes with explicit | - | ||||||||||||||||||||||||
1571 | values. The attribute list contains attributes used for namespace | - | ||||||||||||||||||||||||
1572 | declaration (i.e. attributes starting with xmlns) only if the | - | ||||||||||||||||||||||||
1573 | namespace-prefix property of the reader is true. | - | ||||||||||||||||||||||||
1574 | - | |||||||||||||||||||||||||
1575 | The argument \a namespaceURI is the namespace URI, or | - | ||||||||||||||||||||||||
1576 | an empty string if the element has no namespace URI or if no | - | ||||||||||||||||||||||||
1577 | namespace processing is done. \a localName is the local name | - | ||||||||||||||||||||||||
1578 | (without prefix), or an empty string if no namespace processing is | - | ||||||||||||||||||||||||
1579 | done, \a qName is the qualified name (with prefix) and \a atts are | - | ||||||||||||||||||||||||
1580 | the attributes attached to the element. If there are no | - | ||||||||||||||||||||||||
1581 | attributes, \a atts is an empty attributes object. | - | ||||||||||||||||||||||||
1582 | - | |||||||||||||||||||||||||
1583 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1584 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1585 | get the error message. | - | ||||||||||||||||||||||||
1586 | - | |||||||||||||||||||||||||
1587 | \sa endElement(), {Namespace Support via Features} | - | ||||||||||||||||||||||||
1588 | */ | - | ||||||||||||||||||||||||
1589 | - | |||||||||||||||||||||||||
1590 | /*! | - | ||||||||||||||||||||||||
1591 | \fn bool QXmlContentHandler::endElement(const QString& namespaceURI, const QString& localName, const QString& qName) | - | ||||||||||||||||||||||||
1592 | - | |||||||||||||||||||||||||
1593 | The reader calls this function when it has parsed an end element | - | ||||||||||||||||||||||||
1594 | tag with the qualified name \a qName, the local name \a localName | - | ||||||||||||||||||||||||
1595 | and the namespace URI \a namespaceURI. | - | ||||||||||||||||||||||||
1596 | - | |||||||||||||||||||||||||
1597 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1598 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1599 | get the error message. | - | ||||||||||||||||||||||||
1600 | - | |||||||||||||||||||||||||
1601 | \sa startElement(), {Namespace Support via Features} | - | ||||||||||||||||||||||||
1602 | */ | - | ||||||||||||||||||||||||
1603 | - | |||||||||||||||||||||||||
1604 | /*! | - | ||||||||||||||||||||||||
1605 | \fn bool QXmlContentHandler::characters(const QString& ch) | - | ||||||||||||||||||||||||
1606 | - | |||||||||||||||||||||||||
1607 | The reader calls this function when it has parsed a chunk of | - | ||||||||||||||||||||||||
1608 | character data (either normal character data or character data | - | ||||||||||||||||||||||||
1609 | inside a CDATA section; if you need to distinguish between those | - | ||||||||||||||||||||||||
1610 | two types you must use QXmlLexicalHandler::startCDATA() and | - | ||||||||||||||||||||||||
1611 | QXmlLexicalHandler::endCDATA()). The character data is reported in | - | ||||||||||||||||||||||||
1612 | \a ch. | - | ||||||||||||||||||||||||
1613 | - | |||||||||||||||||||||||||
1614 | Some readers report whitespace in element content using the | - | ||||||||||||||||||||||||
1615 | ignorableWhitespace() function rather than using this one. | - | ||||||||||||||||||||||||
1616 | - | |||||||||||||||||||||||||
1617 | A reader may report the character data of an element in more than | - | ||||||||||||||||||||||||
1618 | one chunk; e.g. a reader might want to report "a\<b" in three | - | ||||||||||||||||||||||||
1619 | characters() events ("a ", "\<" and " b"). | - | ||||||||||||||||||||||||
1620 | - | |||||||||||||||||||||||||
1621 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1622 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1623 | get the error message. | - | ||||||||||||||||||||||||
1624 | */ | - | ||||||||||||||||||||||||
1625 | - | |||||||||||||||||||||||||
1626 | /*! | - | ||||||||||||||||||||||||
1627 | \fn bool QXmlContentHandler::ignorableWhitespace(const QString& ch) | - | ||||||||||||||||||||||||
1628 | - | |||||||||||||||||||||||||
1629 | Some readers may use this function to report each chunk of | - | ||||||||||||||||||||||||
1630 | whitespace in element content. The whitespace is reported in \a ch. | - | ||||||||||||||||||||||||
1631 | - | |||||||||||||||||||||||||
1632 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1633 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1634 | get the error message. | - | ||||||||||||||||||||||||
1635 | */ | - | ||||||||||||||||||||||||
1636 | - | |||||||||||||||||||||||||
1637 | /*! | - | ||||||||||||||||||||||||
1638 | \fn bool QXmlContentHandler::processingInstruction(const QString& target, const QString& data) | - | ||||||||||||||||||||||||
1639 | - | |||||||||||||||||||||||||
1640 | The reader calls this function when it has parsed a processing | - | ||||||||||||||||||||||||
1641 | instruction. | - | ||||||||||||||||||||||||
1642 | - | |||||||||||||||||||||||||
1643 | \a target is the target name of the processing instruction and \a | - | ||||||||||||||||||||||||
1644 | data is the data in the processing instruction. | - | ||||||||||||||||||||||||
1645 | - | |||||||||||||||||||||||||
1646 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1647 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1648 | get the error message. | - | ||||||||||||||||||||||||
1649 | */ | - | ||||||||||||||||||||||||
1650 | - | |||||||||||||||||||||||||
1651 | /*! | - | ||||||||||||||||||||||||
1652 | \fn bool QXmlContentHandler::skippedEntity(const QString& name) | - | ||||||||||||||||||||||||
1653 | - | |||||||||||||||||||||||||
1654 | Some readers may skip entities if they have not seen the | - | ||||||||||||||||||||||||
1655 | declarations (e.g. because they are in an external DTD). If they | - | ||||||||||||||||||||||||
1656 | do so they report that they skipped the entity called \a name by | - | ||||||||||||||||||||||||
1657 | calling this function. | - | ||||||||||||||||||||||||
1658 | - | |||||||||||||||||||||||||
1659 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1660 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1661 | get the error message. | - | ||||||||||||||||||||||||
1662 | */ | - | ||||||||||||||||||||||||
1663 | - | |||||||||||||||||||||||||
1664 | /*! | - | ||||||||||||||||||||||||
1665 | \fn QString QXmlContentHandler::errorString() const | - | ||||||||||||||||||||||||
1666 | - | |||||||||||||||||||||||||
1667 | The reader calls this function to get an error string, e.g. if any | - | ||||||||||||||||||||||||
1668 | of the handler functions returns \c false. | - | ||||||||||||||||||||||||
1669 | */ | - | ||||||||||||||||||||||||
1670 | - | |||||||||||||||||||||||||
1671 | - | |||||||||||||||||||||||||
1672 | /*! | - | ||||||||||||||||||||||||
1673 | \class QXmlErrorHandler | - | ||||||||||||||||||||||||
1674 | \reentrant | - | ||||||||||||||||||||||||
1675 | \brief The QXmlErrorHandler class provides an interface to report | - | ||||||||||||||||||||||||
1676 | errors in XML data. | - | ||||||||||||||||||||||||
1677 | - | |||||||||||||||||||||||||
1678 | \inmodule QtXml | - | ||||||||||||||||||||||||
1679 | \ingroup xml-tools | - | ||||||||||||||||||||||||
1680 | - | |||||||||||||||||||||||||
1681 | If you want your application to report errors to the user or to | - | ||||||||||||||||||||||||
1682 | perform customized error handling, you should subclass this class. | - | ||||||||||||||||||||||||
1683 | - | |||||||||||||||||||||||||
1684 | You can set the error handler with QXmlReader::setErrorHandler(). | - | ||||||||||||||||||||||||
1685 | - | |||||||||||||||||||||||||
1686 | Errors can be reported using warning(), error() and fatalError(), | - | ||||||||||||||||||||||||
1687 | with the error text being reported with errorString(). | - | ||||||||||||||||||||||||
1688 | - | |||||||||||||||||||||||||
1689 | \sa QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver, | - | ||||||||||||||||||||||||
1690 | QXmlLexicalHandler, {Introduction to SAX2} | - | ||||||||||||||||||||||||
1691 | */ | - | ||||||||||||||||||||||||
1692 | - | |||||||||||||||||||||||||
1693 | /*! | - | ||||||||||||||||||||||||
1694 | \fn QXmlErrorHandler::~QXmlErrorHandler() | - | ||||||||||||||||||||||||
1695 | - | |||||||||||||||||||||||||
1696 | Destroys the error handler. | - | ||||||||||||||||||||||||
1697 | */ | - | ||||||||||||||||||||||||
1698 | - | |||||||||||||||||||||||||
1699 | /*! | - | ||||||||||||||||||||||||
1700 | \fn bool QXmlErrorHandler::warning(const QXmlParseException& exception) | - | ||||||||||||||||||||||||
1701 | - | |||||||||||||||||||||||||
1702 | A reader might use this function to report a warning. Warnings are | - | ||||||||||||||||||||||||
1703 | conditions that are not errors or fatal errors as defined by the | - | ||||||||||||||||||||||||
1704 | XML 1.0 specification. Details of the warning are stored in \a | - | ||||||||||||||||||||||||
1705 | exception. | - | ||||||||||||||||||||||||
1706 | - | |||||||||||||||||||||||||
1707 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1708 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1709 | get the error message. | - | ||||||||||||||||||||||||
1710 | */ | - | ||||||||||||||||||||||||
1711 | - | |||||||||||||||||||||||||
1712 | /*! | - | ||||||||||||||||||||||||
1713 | \fn bool QXmlErrorHandler::error(const QXmlParseException& exception) | - | ||||||||||||||||||||||||
1714 | - | |||||||||||||||||||||||||
1715 | A reader might use this function to report a recoverable error. A | - | ||||||||||||||||||||||||
1716 | recoverable error corresponds to the definiton of "error" in | - | ||||||||||||||||||||||||
1717 | section 1.2 of the XML 1.0 specification. Details of the error are | - | ||||||||||||||||||||||||
1718 | stored in \a exception. | - | ||||||||||||||||||||||||
1719 | - | |||||||||||||||||||||||||
1720 | The reader must continue to provide normal parsing events after | - | ||||||||||||||||||||||||
1721 | invoking this function. | - | ||||||||||||||||||||||||
1722 | - | |||||||||||||||||||||||||
1723 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1724 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1725 | get the error message. | - | ||||||||||||||||||||||||
1726 | */ | - | ||||||||||||||||||||||||
1727 | - | |||||||||||||||||||||||||
1728 | /*! | - | ||||||||||||||||||||||||
1729 | \fn bool QXmlErrorHandler::fatalError(const QXmlParseException& exception) | - | ||||||||||||||||||||||||
1730 | - | |||||||||||||||||||||||||
1731 | A reader must use this function to report a non-recoverable error. | - | ||||||||||||||||||||||||
1732 | Details of the error are stored in \a exception. | - | ||||||||||||||||||||||||
1733 | - | |||||||||||||||||||||||||
1734 | If this function returns \c true the reader might try to go on | - | ||||||||||||||||||||||||
1735 | parsing and reporting further errors, but no regular parsing | - | ||||||||||||||||||||||||
1736 | events are reported. | - | ||||||||||||||||||||||||
1737 | */ | - | ||||||||||||||||||||||||
1738 | - | |||||||||||||||||||||||||
1739 | /*! | - | ||||||||||||||||||||||||
1740 | \fn QString QXmlErrorHandler::errorString() const | - | ||||||||||||||||||||||||
1741 | - | |||||||||||||||||||||||||
1742 | The reader calls this function to get an error string if any of | - | ||||||||||||||||||||||||
1743 | the handler functions returns \c false. | - | ||||||||||||||||||||||||
1744 | */ | - | ||||||||||||||||||||||||
1745 | - | |||||||||||||||||||||||||
1746 | - | |||||||||||||||||||||||||
1747 | /*! | - | ||||||||||||||||||||||||
1748 | \class QXmlDTDHandler | - | ||||||||||||||||||||||||
1749 | \reentrant | - | ||||||||||||||||||||||||
1750 | \brief The QXmlDTDHandler class provides an interface to report | - | ||||||||||||||||||||||||
1751 | DTD content of XML data. | - | ||||||||||||||||||||||||
1752 | - | |||||||||||||||||||||||||
1753 | \inmodule QtXml | - | ||||||||||||||||||||||||
1754 | \ingroup xml-tools | - | ||||||||||||||||||||||||
1755 | - | |||||||||||||||||||||||||
1756 | If an application needs information about notations and unparsed | - | ||||||||||||||||||||||||
1757 | entities, it can implement this interface and register an instance | - | ||||||||||||||||||||||||
1758 | with QXmlReader::setDTDHandler(). | - | ||||||||||||||||||||||||
1759 | - | |||||||||||||||||||||||||
1760 | Note that this interface includes only those DTD events that the | - | ||||||||||||||||||||||||
1761 | XML recommendation requires processors to report, i.e. notation | - | ||||||||||||||||||||||||
1762 | and unparsed entity declarations using notationDecl() and | - | ||||||||||||||||||||||||
1763 | unparsedEntityDecl() respectively. | - | ||||||||||||||||||||||||
1764 | - | |||||||||||||||||||||||||
1765 | \sa QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver, QXmlErrorHandler, | - | ||||||||||||||||||||||||
1766 | QXmlLexicalHandler, {Introduction to SAX2} | - | ||||||||||||||||||||||||
1767 | */ | - | ||||||||||||||||||||||||
1768 | - | |||||||||||||||||||||||||
1769 | /*! | - | ||||||||||||||||||||||||
1770 | \fn QXmlDTDHandler::~QXmlDTDHandler() | - | ||||||||||||||||||||||||
1771 | - | |||||||||||||||||||||||||
1772 | Destroys the DTD handler. | - | ||||||||||||||||||||||||
1773 | */ | - | ||||||||||||||||||||||||
1774 | - | |||||||||||||||||||||||||
1775 | /*! | - | ||||||||||||||||||||||||
1776 | \fn bool QXmlDTDHandler::notationDecl(const QString& name, const QString& publicId, const QString& systemId) | - | ||||||||||||||||||||||||
1777 | - | |||||||||||||||||||||||||
1778 | The reader calls this function when it has parsed a notation | - | ||||||||||||||||||||||||
1779 | declaration. | - | ||||||||||||||||||||||||
1780 | - | |||||||||||||||||||||||||
1781 | The argument \a name is the notation name, \a publicId is the | - | ||||||||||||||||||||||||
1782 | notation's public identifier and \a systemId is the notation's | - | ||||||||||||||||||||||||
1783 | system identifier. | - | ||||||||||||||||||||||||
1784 | - | |||||||||||||||||||||||||
1785 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1786 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1787 | get the error message. | - | ||||||||||||||||||||||||
1788 | */ | - | ||||||||||||||||||||||||
1789 | - | |||||||||||||||||||||||||
1790 | /*! | - | ||||||||||||||||||||||||
1791 | \fn bool QXmlDTDHandler::unparsedEntityDecl(const QString& name, const QString& publicId, const QString& systemId, const QString& notationName) | - | ||||||||||||||||||||||||
1792 | - | |||||||||||||||||||||||||
1793 | The reader calls this function when it finds an unparsed entity | - | ||||||||||||||||||||||||
1794 | declaration. | - | ||||||||||||||||||||||||
1795 | - | |||||||||||||||||||||||||
1796 | The argument \a name is the unparsed entity's name, \a publicId is | - | ||||||||||||||||||||||||
1797 | the entity's public identifier, \a systemId is the entity's system | - | ||||||||||||||||||||||||
1798 | identifier and \a notationName is the name of the associated | - | ||||||||||||||||||||||||
1799 | notation. | - | ||||||||||||||||||||||||
1800 | - | |||||||||||||||||||||||||
1801 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1802 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1803 | get the error message. | - | ||||||||||||||||||||||||
1804 | */ | - | ||||||||||||||||||||||||
1805 | - | |||||||||||||||||||||||||
1806 | /*! | - | ||||||||||||||||||||||||
1807 | \fn QString QXmlDTDHandler::errorString() const | - | ||||||||||||||||||||||||
1808 | - | |||||||||||||||||||||||||
1809 | The reader calls this function to get an error string if any of | - | ||||||||||||||||||||||||
1810 | the handler functions returns \c false. | - | ||||||||||||||||||||||||
1811 | */ | - | ||||||||||||||||||||||||
1812 | - | |||||||||||||||||||||||||
1813 | - | |||||||||||||||||||||||||
1814 | /*! | - | ||||||||||||||||||||||||
1815 | \class QXmlEntityResolver | - | ||||||||||||||||||||||||
1816 | \reentrant | - | ||||||||||||||||||||||||
1817 | \brief The QXmlEntityResolver class provides an interface to | - | ||||||||||||||||||||||||
1818 | resolve external entities contained in XML data. | - | ||||||||||||||||||||||||
1819 | - | |||||||||||||||||||||||||
1820 | \inmodule QtXml | - | ||||||||||||||||||||||||
1821 | \ingroup xml-tools | - | ||||||||||||||||||||||||
1822 | - | |||||||||||||||||||||||||
1823 | If an application needs to implement customized handling for | - | ||||||||||||||||||||||||
1824 | external entities, it must implement this interface, i.e. | - | ||||||||||||||||||||||||
1825 | resolveEntity(), and register it with | - | ||||||||||||||||||||||||
1826 | QXmlReader::setEntityResolver(). | - | ||||||||||||||||||||||||
1827 | - | |||||||||||||||||||||||||
1828 | \sa QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlErrorHandler, | - | ||||||||||||||||||||||||
1829 | QXmlLexicalHandler, {Introduction to SAX2} | - | ||||||||||||||||||||||||
1830 | */ | - | ||||||||||||||||||||||||
1831 | - | |||||||||||||||||||||||||
1832 | /*! | - | ||||||||||||||||||||||||
1833 | \fn QXmlEntityResolver::~QXmlEntityResolver() | - | ||||||||||||||||||||||||
1834 | - | |||||||||||||||||||||||||
1835 | Destroys the entity resolver. | - | ||||||||||||||||||||||||
1836 | */ | - | ||||||||||||||||||||||||
1837 | - | |||||||||||||||||||||||||
1838 | /*! | - | ||||||||||||||||||||||||
1839 | \fn bool QXmlEntityResolver::resolveEntity(const QString& publicId, const QString& systemId, QXmlInputSource*& ret) | - | ||||||||||||||||||||||||
1840 | - | |||||||||||||||||||||||||
1841 | The reader calls this function before it opens any external | - | ||||||||||||||||||||||||
1842 | entity, except the top-level document entity. The application may | - | ||||||||||||||||||||||||
1843 | request the reader to resolve the entity itself (\a ret is 0) or | - | ||||||||||||||||||||||||
1844 | to use an entirely different input source (\a ret points to the | - | ||||||||||||||||||||||||
1845 | input source). | - | ||||||||||||||||||||||||
1846 | - | |||||||||||||||||||||||||
1847 | The reader deletes the input source \a ret when it no longer needs | - | ||||||||||||||||||||||||
1848 | it, so you should allocate it on the heap with \c new. | - | ||||||||||||||||||||||||
1849 | - | |||||||||||||||||||||||||
1850 | The argument \a publicId is the public identifier of the external | - | ||||||||||||||||||||||||
1851 | entity, \a systemId is the system identifier of the external | - | ||||||||||||||||||||||||
1852 | entity and \a ret is the return value of this function. If \a ret | - | ||||||||||||||||||||||||
1853 | is 0 the reader should resolve the entity itself, if it is | - | ||||||||||||||||||||||||
1854 | non-zero it must point to an input source which the reader uses | - | ||||||||||||||||||||||||
1855 | instead. | - | ||||||||||||||||||||||||
1856 | - | |||||||||||||||||||||||||
1857 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1858 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1859 | get the error message. | - | ||||||||||||||||||||||||
1860 | */ | - | ||||||||||||||||||||||||
1861 | - | |||||||||||||||||||||||||
1862 | /*! | - | ||||||||||||||||||||||||
1863 | \fn QString QXmlEntityResolver::errorString() const | - | ||||||||||||||||||||||||
1864 | - | |||||||||||||||||||||||||
1865 | The reader calls this function to get an error string if any of | - | ||||||||||||||||||||||||
1866 | the handler functions returns \c false. | - | ||||||||||||||||||||||||
1867 | */ | - | ||||||||||||||||||||||||
1868 | - | |||||||||||||||||||||||||
1869 | - | |||||||||||||||||||||||||
1870 | /*! | - | ||||||||||||||||||||||||
1871 | \class QXmlLexicalHandler | - | ||||||||||||||||||||||||
1872 | \reentrant | - | ||||||||||||||||||||||||
1873 | \brief The QXmlLexicalHandler class provides an interface to | - | ||||||||||||||||||||||||
1874 | report the lexical content of XML data. | - | ||||||||||||||||||||||||
1875 | - | |||||||||||||||||||||||||
1876 | \inmodule QtXml | - | ||||||||||||||||||||||||
1877 | \ingroup xml-tools | - | ||||||||||||||||||||||||
1878 | - | |||||||||||||||||||||||||
1879 | The events in the lexical handler apply to the entire document, | - | ||||||||||||||||||||||||
1880 | not just to the document element, and all lexical handler events | - | ||||||||||||||||||||||||
1881 | appear between the content handler's startDocument and endDocument | - | ||||||||||||||||||||||||
1882 | events. | - | ||||||||||||||||||||||||
1883 | - | |||||||||||||||||||||||||
1884 | You can set the lexical handler with | - | ||||||||||||||||||||||||
1885 | QXmlReader::setLexicalHandler(). | - | ||||||||||||||||||||||||
1886 | - | |||||||||||||||||||||||||
1887 | This interface's design is based on the SAX2 extension | - | ||||||||||||||||||||||||
1888 | LexicalHandler. | - | ||||||||||||||||||||||||
1889 | - | |||||||||||||||||||||||||
1890 | The interface provides the startDTD(), endDTD(), startEntity(), | - | ||||||||||||||||||||||||
1891 | endEntity(), startCDATA(), endCDATA() and comment() functions. | - | ||||||||||||||||||||||||
1892 | - | |||||||||||||||||||||||||
1893 | \sa QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver, | - | ||||||||||||||||||||||||
1894 | QXmlErrorHandler, {Introduction to SAX2} | - | ||||||||||||||||||||||||
1895 | */ | - | ||||||||||||||||||||||||
1896 | - | |||||||||||||||||||||||||
1897 | /*! | - | ||||||||||||||||||||||||
1898 | \fn QXmlLexicalHandler::~QXmlLexicalHandler() | - | ||||||||||||||||||||||||
1899 | - | |||||||||||||||||||||||||
1900 | Destroys the lexical handler. | - | ||||||||||||||||||||||||
1901 | */ | - | ||||||||||||||||||||||||
1902 | - | |||||||||||||||||||||||||
1903 | /*! | - | ||||||||||||||||||||||||
1904 | \fn bool QXmlLexicalHandler::startDTD(const QString& name, const QString& publicId, const QString& systemId) | - | ||||||||||||||||||||||||
1905 | - | |||||||||||||||||||||||||
1906 | The reader calls this function to report the start of a DTD | - | ||||||||||||||||||||||||
1907 | declaration, if any. It reports the name of the document type in | - | ||||||||||||||||||||||||
1908 | \a name, the public identifier in \a publicId and the system | - | ||||||||||||||||||||||||
1909 | identifier in \a systemId. | - | ||||||||||||||||||||||||
1910 | - | |||||||||||||||||||||||||
1911 | If the public identifier is missing, \a publicId is set to | - | ||||||||||||||||||||||||
1912 | an empty string. If the system identifier is missing, \a systemId is | - | ||||||||||||||||||||||||
1913 | set to an empty string. Note that it is not valid XML to have a | - | ||||||||||||||||||||||||
1914 | public identifier but no system identifier; in such cases a parse | - | ||||||||||||||||||||||||
1915 | error will occur. | - | ||||||||||||||||||||||||
1916 | - | |||||||||||||||||||||||||
1917 | All declarations reported through QXmlDTDHandler or | - | ||||||||||||||||||||||||
1918 | QXmlDeclHandler appear between the startDTD() and endDTD() calls. | - | ||||||||||||||||||||||||
1919 | - | |||||||||||||||||||||||||
1920 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1921 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1922 | get the error message. | - | ||||||||||||||||||||||||
1923 | - | |||||||||||||||||||||||||
1924 | \sa endDTD() | - | ||||||||||||||||||||||||
1925 | */ | - | ||||||||||||||||||||||||
1926 | - | |||||||||||||||||||||||||
1927 | /*! | - | ||||||||||||||||||||||||
1928 | \fn bool QXmlLexicalHandler::endDTD() | - | ||||||||||||||||||||||||
1929 | - | |||||||||||||||||||||||||
1930 | The reader calls this function to report the end of a DTD | - | ||||||||||||||||||||||||
1931 | declaration, if any. | - | ||||||||||||||||||||||||
1932 | - | |||||||||||||||||||||||||
1933 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1934 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1935 | get the error message. | - | ||||||||||||||||||||||||
1936 | - | |||||||||||||||||||||||||
1937 | \sa startDTD() | - | ||||||||||||||||||||||||
1938 | */ | - | ||||||||||||||||||||||||
1939 | - | |||||||||||||||||||||||||
1940 | /*! | - | ||||||||||||||||||||||||
1941 | \fn bool QXmlLexicalHandler::startEntity(const QString& name) | - | ||||||||||||||||||||||||
1942 | - | |||||||||||||||||||||||||
1943 | The reader calls this function to report the start of an entity | - | ||||||||||||||||||||||||
1944 | called \a name. | - | ||||||||||||||||||||||||
1945 | - | |||||||||||||||||||||||||
1946 | Note that if the entity is unknown, the reader reports it through | - | ||||||||||||||||||||||||
1947 | QXmlContentHandler::skippedEntity() and not through this | - | ||||||||||||||||||||||||
1948 | function. | - | ||||||||||||||||||||||||
1949 | - | |||||||||||||||||||||||||
1950 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1951 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1952 | get the error message. | - | ||||||||||||||||||||||||
1953 | - | |||||||||||||||||||||||||
1954 | \sa endEntity(), QXmlSimpleReader::setFeature() | - | ||||||||||||||||||||||||
1955 | */ | - | ||||||||||||||||||||||||
1956 | - | |||||||||||||||||||||||||
1957 | /*! | - | ||||||||||||||||||||||||
1958 | \fn bool QXmlLexicalHandler::endEntity(const QString& name) | - | ||||||||||||||||||||||||
1959 | - | |||||||||||||||||||||||||
1960 | The reader calls this function to report the end of an entity | - | ||||||||||||||||||||||||
1961 | called \a name. | - | ||||||||||||||||||||||||
1962 | - | |||||||||||||||||||||||||
1963 | For every startEntity() call, there is a corresponding endEntity() | - | ||||||||||||||||||||||||
1964 | call. The calls to startEntity() and endEntity() are properly | - | ||||||||||||||||||||||||
1965 | nested. | - | ||||||||||||||||||||||||
1966 | - | |||||||||||||||||||||||||
1967 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1968 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1969 | get the error message. | - | ||||||||||||||||||||||||
1970 | - | |||||||||||||||||||||||||
1971 | \sa startEntity(), QXmlContentHandler::skippedEntity(), QXmlSimpleReader::setFeature() | - | ||||||||||||||||||||||||
1972 | */ | - | ||||||||||||||||||||||||
1973 | - | |||||||||||||||||||||||||
1974 | /*! | - | ||||||||||||||||||||||||
1975 | \fn bool QXmlLexicalHandler::startCDATA() | - | ||||||||||||||||||||||||
1976 | - | |||||||||||||||||||||||||
1977 | The reader calls this function to report the start of a CDATA | - | ||||||||||||||||||||||||
1978 | section. The content of the CDATA section is reported through the | - | ||||||||||||||||||||||||
1979 | QXmlContentHandler::characters() function. This function is | - | ||||||||||||||||||||||||
1980 | intended only to report the boundary. | - | ||||||||||||||||||||||||
1981 | - | |||||||||||||||||||||||||
1982 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
1983 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
1984 | get the error message. | - | ||||||||||||||||||||||||
1985 | - | |||||||||||||||||||||||||
1986 | \sa endCDATA() | - | ||||||||||||||||||||||||
1987 | */ | - | ||||||||||||||||||||||||
1988 | - | |||||||||||||||||||||||||
1989 | /*! | - | ||||||||||||||||||||||||
1990 | \fn bool QXmlLexicalHandler::endCDATA() | - | ||||||||||||||||||||||||
1991 | - | |||||||||||||||||||||||||
1992 | The reader calls this function to report the end of a CDATA | - | ||||||||||||||||||||||||
1993 | section. | - | ||||||||||||||||||||||||
1994 | - | |||||||||||||||||||||||||
1995 | If this function returns \c false the reader stops parsing and reports | - | ||||||||||||||||||||||||
1996 | an error. The reader uses the function errorString() to get the error | - | ||||||||||||||||||||||||
1997 | message. | - | ||||||||||||||||||||||||
1998 | - | |||||||||||||||||||||||||
1999 | \sa startCDATA(), QXmlContentHandler::characters() | - | ||||||||||||||||||||||||
2000 | */ | - | ||||||||||||||||||||||||
2001 | - | |||||||||||||||||||||||||
2002 | /*! | - | ||||||||||||||||||||||||
2003 | \fn bool QXmlLexicalHandler::comment(const QString& ch) | - | ||||||||||||||||||||||||
2004 | - | |||||||||||||||||||||||||
2005 | The reader calls this function to report an XML comment anywhere | - | ||||||||||||||||||||||||
2006 | in the document. It reports the text of the comment in \a ch. | - | ||||||||||||||||||||||||
2007 | - | |||||||||||||||||||||||||
2008 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
2009 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
2010 | get the error message. | - | ||||||||||||||||||||||||
2011 | */ | - | ||||||||||||||||||||||||
2012 | - | |||||||||||||||||||||||||
2013 | /*! | - | ||||||||||||||||||||||||
2014 | \fn QString QXmlLexicalHandler::errorString() const | - | ||||||||||||||||||||||||
2015 | - | |||||||||||||||||||||||||
2016 | The reader calls this function to get an error string if any of | - | ||||||||||||||||||||||||
2017 | the handler functions returns \c false. | - | ||||||||||||||||||||||||
2018 | */ | - | ||||||||||||||||||||||||
2019 | - | |||||||||||||||||||||||||
2020 | - | |||||||||||||||||||||||||
2021 | /*! | - | ||||||||||||||||||||||||
2022 | \class QXmlDeclHandler | - | ||||||||||||||||||||||||
2023 | \reentrant | - | ||||||||||||||||||||||||
2024 | \brief The QXmlDeclHandler class provides an interface to report declaration | - | ||||||||||||||||||||||||
2025 | content of XML data. | - | ||||||||||||||||||||||||
2026 | - | |||||||||||||||||||||||||
2027 | \inmodule QtXml | - | ||||||||||||||||||||||||
2028 | \ingroup xml-tools | - | ||||||||||||||||||||||||
2029 | - | |||||||||||||||||||||||||
2030 | You can set the declaration handler with | - | ||||||||||||||||||||||||
2031 | QXmlReader::setDeclHandler(). | - | ||||||||||||||||||||||||
2032 | - | |||||||||||||||||||||||||
2033 | This interface is based on the SAX2 extension DeclHandler. | - | ||||||||||||||||||||||||
2034 | - | |||||||||||||||||||||||||
2035 | The interface provides attributeDecl(), internalEntityDecl() and | - | ||||||||||||||||||||||||
2036 | externalEntityDecl() functions. | - | ||||||||||||||||||||||||
2037 | - | |||||||||||||||||||||||||
2038 | \sa QXmlDTDHandler, QXmlContentHandler, QXmlEntityResolver, QXmlErrorHandler, | - | ||||||||||||||||||||||||
2039 | QXmlLexicalHandler, {Introduction to SAX2} | - | ||||||||||||||||||||||||
2040 | */ | - | ||||||||||||||||||||||||
2041 | - | |||||||||||||||||||||||||
2042 | /*! | - | ||||||||||||||||||||||||
2043 | \fn QXmlDeclHandler::~QXmlDeclHandler() | - | ||||||||||||||||||||||||
2044 | - | |||||||||||||||||||||||||
2045 | Destroys the declaration handler. | - | ||||||||||||||||||||||||
2046 | */ | - | ||||||||||||||||||||||||
2047 | - | |||||||||||||||||||||||||
2048 | /*! | - | ||||||||||||||||||||||||
2049 | \fn bool QXmlDeclHandler::attributeDecl(const QString& eName, const QString& aName, const QString& type, const QString& valueDefault, const QString& value) | - | ||||||||||||||||||||||||
2050 | - | |||||||||||||||||||||||||
2051 | The reader calls this function to report an attribute type | - | ||||||||||||||||||||||||
2052 | declaration. Only the effective (first) declaration for an | - | ||||||||||||||||||||||||
2053 | attribute is reported. | - | ||||||||||||||||||||||||
2054 | - | |||||||||||||||||||||||||
2055 | The reader passes the name of the associated element in \a eName | - | ||||||||||||||||||||||||
2056 | and the name of the attribute in \a aName. It passes a string that | - | ||||||||||||||||||||||||
2057 | represents the attribute type in \a type and a string that | - | ||||||||||||||||||||||||
2058 | represents the attribute default in \a valueDefault. This string | - | ||||||||||||||||||||||||
2059 | is one of "#IMPLIED", "#REQUIRED", "#FIXED" or an empty string (if | - | ||||||||||||||||||||||||
2060 | none of the others applies). The reader passes the attribute's | - | ||||||||||||||||||||||||
2061 | default value in \a value. If no default value is specified in the | - | ||||||||||||||||||||||||
2062 | XML file, \a value is an empty string. | - | ||||||||||||||||||||||||
2063 | - | |||||||||||||||||||||||||
2064 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
2065 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
2066 | get the error message. | - | ||||||||||||||||||||||||
2067 | */ | - | ||||||||||||||||||||||||
2068 | - | |||||||||||||||||||||||||
2069 | /*! | - | ||||||||||||||||||||||||
2070 | \fn bool QXmlDeclHandler::internalEntityDecl(const QString& name, const QString& value) | - | ||||||||||||||||||||||||
2071 | - | |||||||||||||||||||||||||
2072 | The reader calls this function to report an internal entity | - | ||||||||||||||||||||||||
2073 | declaration. Only the effective (first) declaration is reported. | - | ||||||||||||||||||||||||
2074 | - | |||||||||||||||||||||||||
2075 | The reader passes the name of the entity in \a name and the value | - | ||||||||||||||||||||||||
2076 | of the entity in \a value. | - | ||||||||||||||||||||||||
2077 | - | |||||||||||||||||||||||||
2078 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
2079 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
2080 | get the error message. | - | ||||||||||||||||||||||||
2081 | */ | - | ||||||||||||||||||||||||
2082 | - | |||||||||||||||||||||||||
2083 | /*! | - | ||||||||||||||||||||||||
2084 | \fn bool QXmlDeclHandler::externalEntityDecl(const QString& name, const QString& publicId, const QString& systemId) | - | ||||||||||||||||||||||||
2085 | - | |||||||||||||||||||||||||
2086 | The reader calls this function to report a parsed external entity | - | ||||||||||||||||||||||||
2087 | declaration. Only the effective (first) declaration for each | - | ||||||||||||||||||||||||
2088 | entity is reported. | - | ||||||||||||||||||||||||
2089 | - | |||||||||||||||||||||||||
2090 | The reader passes the name of the entity in \a name, the public | - | ||||||||||||||||||||||||
2091 | identifier in \a publicId and the system identifier in \a | - | ||||||||||||||||||||||||
2092 | systemId. If there is no public identifier specified, it passes | - | ||||||||||||||||||||||||
2093 | an empty string in \a publicId. | - | ||||||||||||||||||||||||
2094 | - | |||||||||||||||||||||||||
2095 | If this function returns \c false the reader stops parsing and | - | ||||||||||||||||||||||||
2096 | reports an error. The reader uses the function errorString() to | - | ||||||||||||||||||||||||
2097 | get the error message. | - | ||||||||||||||||||||||||
2098 | */ | - | ||||||||||||||||||||||||
2099 | - | |||||||||||||||||||||||||
2100 | /*! | - | ||||||||||||||||||||||||
2101 | \fn QString QXmlDeclHandler::errorString() const | - | ||||||||||||||||||||||||
2102 | - | |||||||||||||||||||||||||
2103 | The reader calls this function to get an error string if any of | - | ||||||||||||||||||||||||
2104 | the handler functions returns \c false. | - | ||||||||||||||||||||||||
2105 | */ | - | ||||||||||||||||||||||||
2106 | - | |||||||||||||||||||||||||
2107 | - | |||||||||||||||||||||||||
2108 | /*! | - | ||||||||||||||||||||||||
2109 | \class QXmlDefaultHandler | - | ||||||||||||||||||||||||
2110 | \reentrant | - | ||||||||||||||||||||||||
2111 | \brief The QXmlDefaultHandler class provides a default implementation of all | - | ||||||||||||||||||||||||
2112 | the XML handler classes. | - | ||||||||||||||||||||||||
2113 | - | |||||||||||||||||||||||||
2114 | \inmodule QtXml | - | ||||||||||||||||||||||||
2115 | \ingroup xml-tools | - | ||||||||||||||||||||||||
2116 | - | |||||||||||||||||||||||||
2117 | This class gathers together the features of | - | ||||||||||||||||||||||||
2118 | the specialized handler classes, making it a convenient | - | ||||||||||||||||||||||||
2119 | starting point when implementing custom handlers for | - | ||||||||||||||||||||||||
2120 | subclasses of QXmlReader, particularly QXmlSimpleReader. | - | ||||||||||||||||||||||||
2121 | The virtual functions from each of the base classes are | - | ||||||||||||||||||||||||
2122 | reimplemented in this class, providing sensible default behavior | - | ||||||||||||||||||||||||
2123 | for many common cases. By subclassing this class, and | - | ||||||||||||||||||||||||
2124 | overriding these functions, you can concentrate | - | ||||||||||||||||||||||||
2125 | on implementing the parts of the handler relevant to your | - | ||||||||||||||||||||||||
2126 | application. | - | ||||||||||||||||||||||||
2127 | - | |||||||||||||||||||||||||
2128 | The XML reader must be told which handler to use for different | - | ||||||||||||||||||||||||
2129 | kinds of events during parsing. This means that, although | - | ||||||||||||||||||||||||
2130 | QXmlDefaultHandler provides default implementations of functions | - | ||||||||||||||||||||||||
2131 | inherited from all its base classes, we can still use specialized | - | ||||||||||||||||||||||||
2132 | handlers for particular kinds of events. | - | ||||||||||||||||||||||||
2133 | - | |||||||||||||||||||||||||
2134 | For example, QXmlDefaultHandler subclasses both | - | ||||||||||||||||||||||||
2135 | QXmlContentHandler and QXmlErrorHandler, so by subclassing | - | ||||||||||||||||||||||||
2136 | it we can use the same handler for both of the following | - | ||||||||||||||||||||||||
2137 | reader functions: | - | ||||||||||||||||||||||||
2138 | - | |||||||||||||||||||||||||
2139 | \snippet rsslisting/listing.cpp 0 | - | ||||||||||||||||||||||||
2140 | - | |||||||||||||||||||||||||
2141 | Since the reader will inform the handler of parsing errors, it is | - | ||||||||||||||||||||||||
2142 | necessary to reimplement QXmlErrorHandler::fatalError() if, for | - | ||||||||||||||||||||||||
2143 | example, we want to stop parsing when such an error occurs: | - | ||||||||||||||||||||||||
2144 | - | |||||||||||||||||||||||||
2145 | \snippet rsslisting/handler.cpp 0 | - | ||||||||||||||||||||||||
2146 | - | |||||||||||||||||||||||||
2147 | The above function returns \c false, which tells the reader to stop | - | ||||||||||||||||||||||||
2148 | parsing. To continue to use the same reader, | - | ||||||||||||||||||||||||
2149 | it is necessary to create a new handler instance, and set up the | - | ||||||||||||||||||||||||
2150 | reader to use it in the manner described above. | - | ||||||||||||||||||||||||
2151 | - | |||||||||||||||||||||||||
2152 | It is useful to examine some of the functions inherited by | - | ||||||||||||||||||||||||
2153 | QXmlDefaultHandler, and consider why they might be | - | ||||||||||||||||||||||||
2154 | reimplemented in a custom handler. | - | ||||||||||||||||||||||||
2155 | Custom handlers will typically reimplement | - | ||||||||||||||||||||||||
2156 | QXmlContentHandler::startDocument() to prepare the handler for | - | ||||||||||||||||||||||||
2157 | new content. Document elements and the text within them can be | - | ||||||||||||||||||||||||
2158 | processed by reimplementing QXmlContentHandler::startElement(), | - | ||||||||||||||||||||||||
2159 | QXmlContentHandler::endElement(), and | - | ||||||||||||||||||||||||
2160 | QXmlContentHandler::characters(). | - | ||||||||||||||||||||||||
2161 | You may want to reimplement QXmlContentHandler::endDocument() | - | ||||||||||||||||||||||||
2162 | to perform some finalization or validation on the content once the | - | ||||||||||||||||||||||||
2163 | document has been read completely. | - | ||||||||||||||||||||||||
2164 | - | |||||||||||||||||||||||||
2165 | \sa QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver, | - | ||||||||||||||||||||||||
2166 | QXmlErrorHandler, QXmlLexicalHandler, {Introduction to SAX2} | - | ||||||||||||||||||||||||
2167 | */ | - | ||||||||||||||||||||||||
2168 | - | |||||||||||||||||||||||||
2169 | /*! | - | ||||||||||||||||||||||||
2170 | \fn QXmlDefaultHandler::QXmlDefaultHandler() | - | ||||||||||||||||||||||||
2171 | - | |||||||||||||||||||||||||
2172 | Constructs a handler for use with subclasses of QXmlReader. | - | ||||||||||||||||||||||||
2173 | */ | - | ||||||||||||||||||||||||
2174 | QXmlDefaultHandler::QXmlDefaultHandler() | - | ||||||||||||||||||||||||
2175 | { | - | ||||||||||||||||||||||||
2176 | // ### In Qt 5.0, this function was inlined and d was not initialized | - | ||||||||||||||||||||||||
2177 | // The member cannot be used until Qt 6.0 | - | ||||||||||||||||||||||||
2178 | Q_UNUSED(d); | - | ||||||||||||||||||||||||
2179 | } executed 2103 times by 6 tests: end of block Executed by:
| 2103 | ||||||||||||||||||||||||
2180 | - | |||||||||||||||||||||||||
2181 | /*! | - | ||||||||||||||||||||||||
2182 | \fn QXmlDefaultHandler::~QXmlDefaultHandler() | - | ||||||||||||||||||||||||
2183 | - | |||||||||||||||||||||||||
2184 | Destroys the handler. | - | ||||||||||||||||||||||||
2185 | */ | - | ||||||||||||||||||||||||
2186 | QXmlDefaultHandler::~QXmlDefaultHandler() | - | ||||||||||||||||||||||||
2187 | { | - | ||||||||||||||||||||||||
2188 | } | - | ||||||||||||||||||||||||
2189 | - | |||||||||||||||||||||||||
2190 | /*! | - | ||||||||||||||||||||||||
2191 | \reimp | - | ||||||||||||||||||||||||
2192 | - | |||||||||||||||||||||||||
2193 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2194 | */ | - | ||||||||||||||||||||||||
2195 | void QXmlDefaultHandler::setDocumentLocator(QXmlLocator*) | - | ||||||||||||||||||||||||
2196 | { | - | ||||||||||||||||||||||||
2197 | } | - | ||||||||||||||||||||||||
2198 | - | |||||||||||||||||||||||||
2199 | /*! | - | ||||||||||||||||||||||||
2200 | \reimp | - | ||||||||||||||||||||||||
2201 | - | |||||||||||||||||||||||||
2202 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2203 | */ | - | ||||||||||||||||||||||||
2204 | bool QXmlDefaultHandler::startDocument() | - | ||||||||||||||||||||||||
2205 | { | - | ||||||||||||||||||||||||
2206 | return true; executed 255 times by 6 tests: return true; Executed by:
| 255 | ||||||||||||||||||||||||
2207 | } | - | ||||||||||||||||||||||||
2208 | - | |||||||||||||||||||||||||
2209 | /*! | - | ||||||||||||||||||||||||
2210 | \reimp | - | ||||||||||||||||||||||||
2211 | - | |||||||||||||||||||||||||
2212 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2213 | */ | - | ||||||||||||||||||||||||
2214 | bool QXmlDefaultHandler::endDocument() | - | ||||||||||||||||||||||||
2215 | { | - | ||||||||||||||||||||||||
2216 | return true; executed 11 times by 3 tests: return true; Executed by:
| 11 | ||||||||||||||||||||||||
2217 | } | - | ||||||||||||||||||||||||
2218 | - | |||||||||||||||||||||||||
2219 | /*! | - | ||||||||||||||||||||||||
2220 | \reimp | - | ||||||||||||||||||||||||
2221 | - | |||||||||||||||||||||||||
2222 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2223 | */ | - | ||||||||||||||||||||||||
2224 | bool QXmlDefaultHandler::startPrefixMapping(const QString&, const QString&) | - | ||||||||||||||||||||||||
2225 | { | - | ||||||||||||||||||||||||
2226 | return true; executed 5 times by 1 test: return true; Executed by:
| 5 | ||||||||||||||||||||||||
2227 | } | - | ||||||||||||||||||||||||
2228 | - | |||||||||||||||||||||||||
2229 | /*! | - | ||||||||||||||||||||||||
2230 | \reimp | - | ||||||||||||||||||||||||
2231 | - | |||||||||||||||||||||||||
2232 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2233 | */ | - | ||||||||||||||||||||||||
2234 | bool QXmlDefaultHandler::endPrefixMapping(const QString&) | - | ||||||||||||||||||||||||
2235 | { | - | ||||||||||||||||||||||||
2236 | return true; executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||||||||||||||
2237 | } | - | ||||||||||||||||||||||||
2238 | - | |||||||||||||||||||||||||
2239 | /*! | - | ||||||||||||||||||||||||
2240 | \reimp | - | ||||||||||||||||||||||||
2241 | - | |||||||||||||||||||||||||
2242 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2243 | */ | - | ||||||||||||||||||||||||
2244 | bool QXmlDefaultHandler::startElement(const QString&, const QString&, | - | ||||||||||||||||||||||||
2245 | const QString&, const QXmlAttributes&) | - | ||||||||||||||||||||||||
2246 | { | - | ||||||||||||||||||||||||
2247 | return true; executed 206 times by 2 tests: return true; Executed by:
| 206 | ||||||||||||||||||||||||
2248 | } | - | ||||||||||||||||||||||||
2249 | - | |||||||||||||||||||||||||
2250 | /*! | - | ||||||||||||||||||||||||
2251 | \reimp | - | ||||||||||||||||||||||||
2252 | - | |||||||||||||||||||||||||
2253 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2254 | */ | - | ||||||||||||||||||||||||
2255 | bool QXmlDefaultHandler::endElement(const QString&, const QString&, | - | ||||||||||||||||||||||||
2256 | const QString&) | - | ||||||||||||||||||||||||
2257 | { | - | ||||||||||||||||||||||||
2258 | return true; executed 206 times by 2 tests: return true; Executed by:
| 206 | ||||||||||||||||||||||||
2259 | } | - | ||||||||||||||||||||||||
2260 | - | |||||||||||||||||||||||||
2261 | /*! | - | ||||||||||||||||||||||||
2262 | \reimp | - | ||||||||||||||||||||||||
2263 | - | |||||||||||||||||||||||||
2264 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2265 | */ | - | ||||||||||||||||||||||||
2266 | bool QXmlDefaultHandler::characters(const QString&) | - | ||||||||||||||||||||||||
2267 | { | - | ||||||||||||||||||||||||
2268 | return true; executed 394 times by 1 test: return true; Executed by:
| 394 | ||||||||||||||||||||||||
2269 | } | - | ||||||||||||||||||||||||
2270 | - | |||||||||||||||||||||||||
2271 | /*! | - | ||||||||||||||||||||||||
2272 | \reimp | - | ||||||||||||||||||||||||
2273 | - | |||||||||||||||||||||||||
2274 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2275 | */ | - | ||||||||||||||||||||||||
2276 | bool QXmlDefaultHandler::ignorableWhitespace(const QString&) | - | ||||||||||||||||||||||||
2277 | { | - | ||||||||||||||||||||||||
2278 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2279 | } | - | ||||||||||||||||||||||||
2280 | - | |||||||||||||||||||||||||
2281 | /*! | - | ||||||||||||||||||||||||
2282 | \reimp | - | ||||||||||||||||||||||||
2283 | - | |||||||||||||||||||||||||
2284 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2285 | */ | - | ||||||||||||||||||||||||
2286 | bool QXmlDefaultHandler::processingInstruction(const QString&, | - | ||||||||||||||||||||||||
2287 | const QString&) | - | ||||||||||||||||||||||||
2288 | { | - | ||||||||||||||||||||||||
2289 | return true; executed 6 times by 2 tests: return true; Executed by:
| 6 | ||||||||||||||||||||||||
2290 | } | - | ||||||||||||||||||||||||
2291 | - | |||||||||||||||||||||||||
2292 | /*! | - | ||||||||||||||||||||||||
2293 | \reimp | - | ||||||||||||||||||||||||
2294 | - | |||||||||||||||||||||||||
2295 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2296 | */ | - | ||||||||||||||||||||||||
2297 | bool QXmlDefaultHandler::skippedEntity(const QString&) | - | ||||||||||||||||||||||||
2298 | { | - | ||||||||||||||||||||||||
2299 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2300 | } | - | ||||||||||||||||||||||||
2301 | - | |||||||||||||||||||||||||
2302 | /*! | - | ||||||||||||||||||||||||
2303 | \reimp | - | ||||||||||||||||||||||||
2304 | - | |||||||||||||||||||||||||
2305 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2306 | */ | - | ||||||||||||||||||||||||
2307 | bool QXmlDefaultHandler::warning(const QXmlParseException&) | - | ||||||||||||||||||||||||
2308 | { | - | ||||||||||||||||||||||||
2309 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2310 | } | - | ||||||||||||||||||||||||
2311 | - | |||||||||||||||||||||||||
2312 | /*! | - | ||||||||||||||||||||||||
2313 | \reimp | - | ||||||||||||||||||||||||
2314 | - | |||||||||||||||||||||||||
2315 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2316 | */ | - | ||||||||||||||||||||||||
2317 | bool QXmlDefaultHandler::error(const QXmlParseException&) | - | ||||||||||||||||||||||||
2318 | { | - | ||||||||||||||||||||||||
2319 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2320 | } | - | ||||||||||||||||||||||||
2321 | - | |||||||||||||||||||||||||
2322 | /*! | - | ||||||||||||||||||||||||
2323 | \reimp | - | ||||||||||||||||||||||||
2324 | - | |||||||||||||||||||||||||
2325 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2326 | */ | - | ||||||||||||||||||||||||
2327 | bool QXmlDefaultHandler::fatalError(const QXmlParseException&) | - | ||||||||||||||||||||||||
2328 | { | - | ||||||||||||||||||||||||
2329 | return true; executed 3 times by 1 test: return true; Executed by:
| 3 | ||||||||||||||||||||||||
2330 | } | - | ||||||||||||||||||||||||
2331 | - | |||||||||||||||||||||||||
2332 | /*! | - | ||||||||||||||||||||||||
2333 | \reimp | - | ||||||||||||||||||||||||
2334 | - | |||||||||||||||||||||||||
2335 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2336 | */ | - | ||||||||||||||||||||||||
2337 | bool QXmlDefaultHandler::notationDecl(const QString&, const QString&, | - | ||||||||||||||||||||||||
2338 | const QString&) | - | ||||||||||||||||||||||||
2339 | { | - | ||||||||||||||||||||||||
2340 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2341 | } | - | ||||||||||||||||||||||||
2342 | - | |||||||||||||||||||||||||
2343 | /*! | - | ||||||||||||||||||||||||
2344 | \reimp | - | ||||||||||||||||||||||||
2345 | - | |||||||||||||||||||||||||
2346 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2347 | */ | - | ||||||||||||||||||||||||
2348 | bool QXmlDefaultHandler::unparsedEntityDecl(const QString&, const QString&, | - | ||||||||||||||||||||||||
2349 | const QString&, const QString&) | - | ||||||||||||||||||||||||
2350 | { | - | ||||||||||||||||||||||||
2351 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2352 | } | - | ||||||||||||||||||||||||
2353 | - | |||||||||||||||||||||||||
2354 | /*! | - | ||||||||||||||||||||||||
2355 | \reimp | - | ||||||||||||||||||||||||
2356 | - | |||||||||||||||||||||||||
2357 | Sets \a ret to 0, so that the reader uses the system identifier | - | ||||||||||||||||||||||||
2358 | provided in the XML document. | - | ||||||||||||||||||||||||
2359 | */ | - | ||||||||||||||||||||||||
2360 | bool QXmlDefaultHandler::resolveEntity(const QString&, const QString&, | - | ||||||||||||||||||||||||
2361 | QXmlInputSource*& ret) | - | ||||||||||||||||||||||||
2362 | { | - | ||||||||||||||||||||||||
2363 | ret = 0; | - | ||||||||||||||||||||||||
2364 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2365 | } | - | ||||||||||||||||||||||||
2366 | - | |||||||||||||||||||||||||
2367 | /*! | - | ||||||||||||||||||||||||
2368 | \reimp | - | ||||||||||||||||||||||||
2369 | - | |||||||||||||||||||||||||
2370 | Returns the default error string. | - | ||||||||||||||||||||||||
2371 | */ | - | ||||||||||||||||||||||||
2372 | QString QXmlDefaultHandler::errorString() const | - | ||||||||||||||||||||||||
2373 | { | - | ||||||||||||||||||||||||
2374 | return QString::fromLatin1(XMLERR_ERRORBYCONSUMER); never executed: return QString::fromLatin1("error triggered by consumer"); | 0 | ||||||||||||||||||||||||
2375 | } | - | ||||||||||||||||||||||||
2376 | - | |||||||||||||||||||||||||
2377 | /*! | - | ||||||||||||||||||||||||
2378 | \reimp | - | ||||||||||||||||||||||||
2379 | - | |||||||||||||||||||||||||
2380 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2381 | */ | - | ||||||||||||||||||||||||
2382 | bool QXmlDefaultHandler::startDTD(const QString&, const QString&, const QString&) | - | ||||||||||||||||||||||||
2383 | { | - | ||||||||||||||||||||||||
2384 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2385 | } | - | ||||||||||||||||||||||||
2386 | - | |||||||||||||||||||||||||
2387 | /*! | - | ||||||||||||||||||||||||
2388 | \reimp | - | ||||||||||||||||||||||||
2389 | - | |||||||||||||||||||||||||
2390 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2391 | */ | - | ||||||||||||||||||||||||
2392 | bool QXmlDefaultHandler::endDTD() | - | ||||||||||||||||||||||||
2393 | { | - | ||||||||||||||||||||||||
2394 | return true; executed 157 times by 2 tests: return true; Executed by:
| 157 | ||||||||||||||||||||||||
2395 | } | - | ||||||||||||||||||||||||
2396 | - | |||||||||||||||||||||||||
2397 | /*! | - | ||||||||||||||||||||||||
2398 | \reimp | - | ||||||||||||||||||||||||
2399 | - | |||||||||||||||||||||||||
2400 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2401 | */ | - | ||||||||||||||||||||||||
2402 | bool QXmlDefaultHandler::startEntity(const QString&) | - | ||||||||||||||||||||||||
2403 | { | - | ||||||||||||||||||||||||
2404 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2405 | } | - | ||||||||||||||||||||||||
2406 | - | |||||||||||||||||||||||||
2407 | /*! | - | ||||||||||||||||||||||||
2408 | \reimp | - | ||||||||||||||||||||||||
2409 | - | |||||||||||||||||||||||||
2410 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2411 | */ | - | ||||||||||||||||||||||||
2412 | bool QXmlDefaultHandler::endEntity(const QString&) | - | ||||||||||||||||||||||||
2413 | { | - | ||||||||||||||||||||||||
2414 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2415 | } | - | ||||||||||||||||||||||||
2416 | - | |||||||||||||||||||||||||
2417 | /*! | - | ||||||||||||||||||||||||
2418 | \reimp | - | ||||||||||||||||||||||||
2419 | - | |||||||||||||||||||||||||
2420 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2421 | */ | - | ||||||||||||||||||||||||
2422 | bool QXmlDefaultHandler::startCDATA() | - | ||||||||||||||||||||||||
2423 | { | - | ||||||||||||||||||||||||
2424 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2425 | } | - | ||||||||||||||||||||||||
2426 | - | |||||||||||||||||||||||||
2427 | /*! | - | ||||||||||||||||||||||||
2428 | \reimp | - | ||||||||||||||||||||||||
2429 | - | |||||||||||||||||||||||||
2430 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2431 | */ | - | ||||||||||||||||||||||||
2432 | bool QXmlDefaultHandler::endCDATA() | - | ||||||||||||||||||||||||
2433 | { | - | ||||||||||||||||||||||||
2434 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2435 | } | - | ||||||||||||||||||||||||
2436 | - | |||||||||||||||||||||||||
2437 | /*! | - | ||||||||||||||||||||||||
2438 | \reimp | - | ||||||||||||||||||||||||
2439 | - | |||||||||||||||||||||||||
2440 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2441 | */ | - | ||||||||||||||||||||||||
2442 | bool QXmlDefaultHandler::comment(const QString&) | - | ||||||||||||||||||||||||
2443 | { | - | ||||||||||||||||||||||||
2444 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2445 | } | - | ||||||||||||||||||||||||
2446 | - | |||||||||||||||||||||||||
2447 | /*! | - | ||||||||||||||||||||||||
2448 | \reimp | - | ||||||||||||||||||||||||
2449 | - | |||||||||||||||||||||||||
2450 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2451 | */ | - | ||||||||||||||||||||||||
2452 | bool QXmlDefaultHandler::attributeDecl(const QString&, const QString&, const QString&, const QString&, const QString&) | - | ||||||||||||||||||||||||
2453 | { | - | ||||||||||||||||||||||||
2454 | return true; executed 1 time by 1 test: return true; Executed by:
| 1 | ||||||||||||||||||||||||
2455 | } | - | ||||||||||||||||||||||||
2456 | - | |||||||||||||||||||||||||
2457 | /*! | - | ||||||||||||||||||||||||
2458 | \reimp | - | ||||||||||||||||||||||||
2459 | - | |||||||||||||||||||||||||
2460 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2461 | */ | - | ||||||||||||||||||||||||
2462 | bool QXmlDefaultHandler::internalEntityDecl(const QString&, const QString&) | - | ||||||||||||||||||||||||
2463 | { | - | ||||||||||||||||||||||||
2464 | return true; executed 5 times by 1 test: return true; Executed by:
| 5 | ||||||||||||||||||||||||
2465 | } | - | ||||||||||||||||||||||||
2466 | - | |||||||||||||||||||||||||
2467 | /*! | - | ||||||||||||||||||||||||
2468 | \reimp | - | ||||||||||||||||||||||||
2469 | - | |||||||||||||||||||||||||
2470 | This reimplementation does nothing. | - | ||||||||||||||||||||||||
2471 | */ | - | ||||||||||||||||||||||||
2472 | bool QXmlDefaultHandler::externalEntityDecl(const QString&, const QString&, const QString&) | - | ||||||||||||||||||||||||
2473 | { | - | ||||||||||||||||||||||||
2474 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2475 | } | - | ||||||||||||||||||||||||
2476 | - | |||||||||||||||||||||||||
2477 | - | |||||||||||||||||||||||||
2478 | /********************************************* | - | ||||||||||||||||||||||||
2479 | * | - | ||||||||||||||||||||||||
2480 | * QXmlSimpleReaderPrivate | - | ||||||||||||||||||||||||
2481 | * | - | ||||||||||||||||||||||||
2482 | *********************************************/ | - | ||||||||||||||||||||||||
2483 | - | |||||||||||||||||||||||||
2484 | inline bool QXmlSimpleReaderPrivate::atEnd() | - | ||||||||||||||||||||||||
2485 | { | - | ||||||||||||||||||||||||
2486 | return (c.unicode()|0x0001) == 0xffff; executed 1050513 times by 6 tests: return (c.unicode()|0x0001) == 0xffff; Executed by:
| 1050513 | ||||||||||||||||||||||||
2487 | } | - | ||||||||||||||||||||||||
2488 | - | |||||||||||||||||||||||||
2489 | inline void QXmlSimpleReaderPrivate::stringClear() | - | ||||||||||||||||||||||||
2490 | { | - | ||||||||||||||||||||||||
2491 | stringValueLen = 0; stringArrayPos = 0; | - | ||||||||||||||||||||||||
2492 | } executed 21975 times by 6 tests: end of block Executed by:
| 21975 | ||||||||||||||||||||||||
2493 | inline void QXmlSimpleReaderPrivate::nameClear() | - | ||||||||||||||||||||||||
2494 | { | - | ||||||||||||||||||||||||
2495 | nameValueLen = 0; nameArrayPos = 0; | - | ||||||||||||||||||||||||
2496 | } executed 30021 times by 6 tests: end of block Executed by:
| 30021 | ||||||||||||||||||||||||
2497 | - | |||||||||||||||||||||||||
2498 | inline void QXmlSimpleReaderPrivate::refClear() | - | ||||||||||||||||||||||||
2499 | { | - | ||||||||||||||||||||||||
2500 | refValueLen = 0; refArrayPos = 0; | - | ||||||||||||||||||||||||
2501 | } executed 2957 times by 3 tests: end of block Executed by:
| 2957 | ||||||||||||||||||||||||
2502 | - | |||||||||||||||||||||||||
2503 | QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate(QXmlSimpleReader *reader) | - | ||||||||||||||||||||||||
2504 | { | - | ||||||||||||||||||||||||
2505 | q_ptr = reader; | - | ||||||||||||||||||||||||
2506 | parseStack = 0; | - | ||||||||||||||||||||||||
2507 | - | |||||||||||||||||||||||||
2508 | locator.reset(new QXmlSimpleReaderLocator(reader)); | - | ||||||||||||||||||||||||
2509 | entityRes = 0; | - | ||||||||||||||||||||||||
2510 | dtdHnd = 0; | - | ||||||||||||||||||||||||
2511 | contentHnd = 0; | - | ||||||||||||||||||||||||
2512 | errorHnd = 0; | - | ||||||||||||||||||||||||
2513 | lexicalHnd = 0; | - | ||||||||||||||||||||||||
2514 | declHnd = 0; | - | ||||||||||||||||||||||||
2515 | - | |||||||||||||||||||||||||
2516 | // default feature settings | - | ||||||||||||||||||||||||
2517 | useNamespaces = true; | - | ||||||||||||||||||||||||
2518 | useNamespacePrefixes = false; | - | ||||||||||||||||||||||||
2519 | reportWhitespaceCharData = true; | - | ||||||||||||||||||||||||
2520 | reportEntities = false; | - | ||||||||||||||||||||||||
2521 | } executed 2104 times by 6 tests: end of block Executed by:
| 2104 | ||||||||||||||||||||||||
2522 | - | |||||||||||||||||||||||||
2523 | QXmlSimpleReaderPrivate::~QXmlSimpleReaderPrivate() | - | ||||||||||||||||||||||||
2524 | { | - | ||||||||||||||||||||||||
2525 | delete parseStack; | - | ||||||||||||||||||||||||
2526 | } executed 2104 times by 6 tests: end of block Executed by:
| 2104 | ||||||||||||||||||||||||
2527 | - | |||||||||||||||||||||||||
2528 | void QXmlSimpleReaderPrivate::initIncrementalParsing() | - | ||||||||||||||||||||||||
2529 | { | - | ||||||||||||||||||||||||
2530 | if(parseStack)
| 0-1490 | ||||||||||||||||||||||||
2531 | parseStack->clear(); never executed: parseStack->clear(); | 0 | ||||||||||||||||||||||||
2532 | else | - | ||||||||||||||||||||||||
2533 | parseStack = new QStack<ParseState>; executed 1490 times by 1 test: parseStack = new QStack<ParseState>; Executed by:
| 1490 | ||||||||||||||||||||||||
2534 | } | - | ||||||||||||||||||||||||
2535 | - | |||||||||||||||||||||||||
2536 | /********************************************* | - | ||||||||||||||||||||||||
2537 | * | - | ||||||||||||||||||||||||
2538 | * QXmlSimpleReader | - | ||||||||||||||||||||||||
2539 | * | - | ||||||||||||||||||||||||
2540 | *********************************************/ | - | ||||||||||||||||||||||||
2541 | - | |||||||||||||||||||||||||
2542 | /*! | - | ||||||||||||||||||||||||
2543 | \class QXmlReader | - | ||||||||||||||||||||||||
2544 | \reentrant | - | ||||||||||||||||||||||||
2545 | \brief The QXmlReader class provides an interface for XML readers (i.e. | - | ||||||||||||||||||||||||
2546 | parsers). | - | ||||||||||||||||||||||||
2547 | - | |||||||||||||||||||||||||
2548 | \inmodule QtXml | - | ||||||||||||||||||||||||
2549 | \ingroup xml-tools | - | ||||||||||||||||||||||||
2550 | - | |||||||||||||||||||||||||
2551 | This abstract class provides an interface for all of Qt's XML | - | ||||||||||||||||||||||||
2552 | readers. Currently there is only one implementation of a reader | - | ||||||||||||||||||||||||
2553 | included in Qt's XML module: QXmlSimpleReader. In future releases | - | ||||||||||||||||||||||||
2554 | there might be more readers with different properties available | - | ||||||||||||||||||||||||
2555 | (e.g. a validating parser). | - | ||||||||||||||||||||||||
2556 | - | |||||||||||||||||||||||||
2557 | The design of the XML classes follows the \l{SAX2 Java interface}, with | - | ||||||||||||||||||||||||
2558 | the names adapted to fit Qt naming conventions. It should be very | - | ||||||||||||||||||||||||
2559 | easy for anybody who has worked with SAX2 to get started with the | - | ||||||||||||||||||||||||
2560 | Qt XML classes. | - | ||||||||||||||||||||||||
2561 | - | |||||||||||||||||||||||||
2562 | All readers use the class QXmlInputSource to read the input | - | ||||||||||||||||||||||||
2563 | document. Since you are normally interested in particular content | - | ||||||||||||||||||||||||
2564 | in the XML document, the reader reports the content through | - | ||||||||||||||||||||||||
2565 | special handler classes (QXmlDTDHandler, QXmlDeclHandler, | - | ||||||||||||||||||||||||
2566 | QXmlContentHandler, QXmlEntityResolver, QXmlErrorHandler and | - | ||||||||||||||||||||||||
2567 | QXmlLexicalHandler), which you must subclass, if you want to | - | ||||||||||||||||||||||||
2568 | process the contents. | - | ||||||||||||||||||||||||
2569 | - | |||||||||||||||||||||||||
2570 | Since the handler classes only describe interfaces you must | - | ||||||||||||||||||||||||
2571 | implement all the functions. We provide the QXmlDefaultHandler | - | ||||||||||||||||||||||||
2572 | class to make this easier: it implements a default behavior (do | - | ||||||||||||||||||||||||
2573 | nothing) for all functions, so you can subclass it and just | - | ||||||||||||||||||||||||
2574 | implement the functions you are interested in. | - | ||||||||||||||||||||||||
2575 | - | |||||||||||||||||||||||||
2576 | Features and properties of the reader can be set with setFeature() | - | ||||||||||||||||||||||||
2577 | and setProperty() respectively. You can set the reader to use your | - | ||||||||||||||||||||||||
2578 | own subclasses with setEntityResolver(), setDTDHandler(), | - | ||||||||||||||||||||||||
2579 | setContentHandler(), setErrorHandler(), setLexicalHandler() and | - | ||||||||||||||||||||||||
2580 | setDeclHandler(). The parse itself is started with a call to | - | ||||||||||||||||||||||||
2581 | parse(). | - | ||||||||||||||||||||||||
2582 | - | |||||||||||||||||||||||||
2583 | \sa QXmlSimpleReader | - | ||||||||||||||||||||||||
2584 | */ | - | ||||||||||||||||||||||||
2585 | - | |||||||||||||||||||||||||
2586 | /*! | - | ||||||||||||||||||||||||
2587 | \fn QXmlReader::~QXmlReader() | - | ||||||||||||||||||||||||
2588 | - | |||||||||||||||||||||||||
2589 | Destroys the reader. | - | ||||||||||||||||||||||||
2590 | */ | - | ||||||||||||||||||||||||
2591 | - | |||||||||||||||||||||||||
2592 | /*! | - | ||||||||||||||||||||||||
2593 | \fn bool QXmlReader::feature(const QString& name, bool *ok) const | - | ||||||||||||||||||||||||
2594 | - | |||||||||||||||||||||||||
2595 | If the reader has the feature called \a name, the feature's value | - | ||||||||||||||||||||||||
2596 | is returned. If no such feature exists the return value is | - | ||||||||||||||||||||||||
2597 | undefined. | - | ||||||||||||||||||||||||
2598 | - | |||||||||||||||||||||||||
2599 | If \a ok is not 0: \c{*}\a{ok} is set to true if the reader has the | - | ||||||||||||||||||||||||
2600 | feature called \a name; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
2601 | - | |||||||||||||||||||||||||
2602 | \sa setFeature(), hasFeature() | - | ||||||||||||||||||||||||
2603 | */ | - | ||||||||||||||||||||||||
2604 | - | |||||||||||||||||||||||||
2605 | /*! | - | ||||||||||||||||||||||||
2606 | \fn void QXmlReader::setFeature(const QString& name, bool value) | - | ||||||||||||||||||||||||
2607 | - | |||||||||||||||||||||||||
2608 | Sets the feature called \a name to the given \a value. If the | - | ||||||||||||||||||||||||
2609 | reader doesn't have the feature nothing happens. | - | ||||||||||||||||||||||||
2610 | - | |||||||||||||||||||||||||
2611 | \sa feature(), hasFeature() | - | ||||||||||||||||||||||||
2612 | */ | - | ||||||||||||||||||||||||
2613 | - | |||||||||||||||||||||||||
2614 | /*! | - | ||||||||||||||||||||||||
2615 | \fn bool QXmlReader::hasFeature(const QString& name) const | - | ||||||||||||||||||||||||
2616 | - | |||||||||||||||||||||||||
2617 | Returns \c true if the reader has the feature called \a name; | - | ||||||||||||||||||||||||
2618 | otherwise returns \c false. | - | ||||||||||||||||||||||||
2619 | - | |||||||||||||||||||||||||
2620 | \sa feature(), setFeature() | - | ||||||||||||||||||||||||
2621 | */ | - | ||||||||||||||||||||||||
2622 | - | |||||||||||||||||||||||||
2623 | /*! | - | ||||||||||||||||||||||||
2624 | \fn void* QXmlReader::property(const QString& name, bool *ok) const | - | ||||||||||||||||||||||||
2625 | - | |||||||||||||||||||||||||
2626 | If the reader has the property \a name, this function returns the | - | ||||||||||||||||||||||||
2627 | value of the property; otherwise the return value is undefined. | - | ||||||||||||||||||||||||
2628 | - | |||||||||||||||||||||||||
2629 | If \a ok is not 0: if the reader has the \a name property | - | ||||||||||||||||||||||||
2630 | \c{*}\a{ok} is set to true; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
2631 | - | |||||||||||||||||||||||||
2632 | \sa setProperty(), hasProperty() | - | ||||||||||||||||||||||||
2633 | */ | - | ||||||||||||||||||||||||
2634 | - | |||||||||||||||||||||||||
2635 | /*! | - | ||||||||||||||||||||||||
2636 | \fn void QXmlReader::setProperty(const QString& name, void* value) | - | ||||||||||||||||||||||||
2637 | - | |||||||||||||||||||||||||
2638 | Sets the property \a name to \a value. If the reader doesn't have | - | ||||||||||||||||||||||||
2639 | the property nothing happens. | - | ||||||||||||||||||||||||
2640 | - | |||||||||||||||||||||||||
2641 | \sa property(), hasProperty() | - | ||||||||||||||||||||||||
2642 | */ | - | ||||||||||||||||||||||||
2643 | - | |||||||||||||||||||||||||
2644 | /*! | - | ||||||||||||||||||||||||
2645 | \fn bool QXmlReader::hasProperty(const QString& name) const | - | ||||||||||||||||||||||||
2646 | - | |||||||||||||||||||||||||
2647 | Returns \c true if the reader has the property \a name; otherwise | - | ||||||||||||||||||||||||
2648 | returns \c false. | - | ||||||||||||||||||||||||
2649 | - | |||||||||||||||||||||||||
2650 | \sa property(), setProperty() | - | ||||||||||||||||||||||||
2651 | */ | - | ||||||||||||||||||||||||
2652 | - | |||||||||||||||||||||||||
2653 | /*! | - | ||||||||||||||||||||||||
2654 | \fn void QXmlReader::setEntityResolver(QXmlEntityResolver* handler) | - | ||||||||||||||||||||||||
2655 | - | |||||||||||||||||||||||||
2656 | Sets the entity resolver to \a handler. | - | ||||||||||||||||||||||||
2657 | - | |||||||||||||||||||||||||
2658 | \sa entityResolver() | - | ||||||||||||||||||||||||
2659 | */ | - | ||||||||||||||||||||||||
2660 | - | |||||||||||||||||||||||||
2661 | /*! | - | ||||||||||||||||||||||||
2662 | \fn QXmlEntityResolver* QXmlReader::entityResolver() const | - | ||||||||||||||||||||||||
2663 | - | |||||||||||||||||||||||||
2664 | Returns the entity resolver or 0 if none was set. | - | ||||||||||||||||||||||||
2665 | - | |||||||||||||||||||||||||
2666 | \sa setEntityResolver() | - | ||||||||||||||||||||||||
2667 | */ | - | ||||||||||||||||||||||||
2668 | - | |||||||||||||||||||||||||
2669 | /*! | - | ||||||||||||||||||||||||
2670 | \fn void QXmlReader::setDTDHandler(QXmlDTDHandler* handler) | - | ||||||||||||||||||||||||
2671 | - | |||||||||||||||||||||||||
2672 | Sets the DTD handler to \a handler. | - | ||||||||||||||||||||||||
2673 | - | |||||||||||||||||||||||||
2674 | \sa DTDHandler() | - | ||||||||||||||||||||||||
2675 | */ | - | ||||||||||||||||||||||||
2676 | - | |||||||||||||||||||||||||
2677 | /*! | - | ||||||||||||||||||||||||
2678 | \fn QXmlDTDHandler* QXmlReader::DTDHandler() const | - | ||||||||||||||||||||||||
2679 | - | |||||||||||||||||||||||||
2680 | Returns the DTD handler or 0 if none was set. | - | ||||||||||||||||||||||||
2681 | - | |||||||||||||||||||||||||
2682 | \sa setDTDHandler() | - | ||||||||||||||||||||||||
2683 | */ | - | ||||||||||||||||||||||||
2684 | - | |||||||||||||||||||||||||
2685 | /*! | - | ||||||||||||||||||||||||
2686 | \fn void QXmlReader::setContentHandler(QXmlContentHandler* handler) | - | ||||||||||||||||||||||||
2687 | - | |||||||||||||||||||||||||
2688 | Sets the content handler to \a handler. | - | ||||||||||||||||||||||||
2689 | - | |||||||||||||||||||||||||
2690 | \sa contentHandler() | - | ||||||||||||||||||||||||
2691 | */ | - | ||||||||||||||||||||||||
2692 | - | |||||||||||||||||||||||||
2693 | /*! | - | ||||||||||||||||||||||||
2694 | \fn QXmlContentHandler* QXmlReader::contentHandler() const | - | ||||||||||||||||||||||||
2695 | - | |||||||||||||||||||||||||
2696 | Returns the content handler or 0 if none was set. | - | ||||||||||||||||||||||||
2697 | - | |||||||||||||||||||||||||
2698 | \sa setContentHandler() | - | ||||||||||||||||||||||||
2699 | */ | - | ||||||||||||||||||||||||
2700 | - | |||||||||||||||||||||||||
2701 | /*! | - | ||||||||||||||||||||||||
2702 | \fn void QXmlReader::setErrorHandler(QXmlErrorHandler* handler) | - | ||||||||||||||||||||||||
2703 | - | |||||||||||||||||||||||||
2704 | Sets the error handler to \a handler. Clears the error handler if | - | ||||||||||||||||||||||||
2705 | \a handler is 0. | - | ||||||||||||||||||||||||
2706 | - | |||||||||||||||||||||||||
2707 | \sa errorHandler() | - | ||||||||||||||||||||||||
2708 | */ | - | ||||||||||||||||||||||||
2709 | - | |||||||||||||||||||||||||
2710 | /*! | - | ||||||||||||||||||||||||
2711 | \fn QXmlErrorHandler* QXmlReader::errorHandler() const | - | ||||||||||||||||||||||||
2712 | - | |||||||||||||||||||||||||
2713 | Returns the error handler or 0 if none is set. | - | ||||||||||||||||||||||||
2714 | - | |||||||||||||||||||||||||
2715 | \sa setErrorHandler() | - | ||||||||||||||||||||||||
2716 | */ | - | ||||||||||||||||||||||||
2717 | - | |||||||||||||||||||||||||
2718 | /*! | - | ||||||||||||||||||||||||
2719 | \fn void QXmlReader::setLexicalHandler(QXmlLexicalHandler* handler) | - | ||||||||||||||||||||||||
2720 | - | |||||||||||||||||||||||||
2721 | Sets the lexical handler to \a handler. | - | ||||||||||||||||||||||||
2722 | - | |||||||||||||||||||||||||
2723 | \sa lexicalHandler() | - | ||||||||||||||||||||||||
2724 | */ | - | ||||||||||||||||||||||||
2725 | - | |||||||||||||||||||||||||
2726 | /*! | - | ||||||||||||||||||||||||
2727 | \fn QXmlLexicalHandler* QXmlReader::lexicalHandler() const | - | ||||||||||||||||||||||||
2728 | - | |||||||||||||||||||||||||
2729 | Returns the lexical handler or 0 if none was set. | - | ||||||||||||||||||||||||
2730 | - | |||||||||||||||||||||||||
2731 | \sa setLexicalHandler() | - | ||||||||||||||||||||||||
2732 | */ | - | ||||||||||||||||||||||||
2733 | - | |||||||||||||||||||||||||
2734 | /*! | - | ||||||||||||||||||||||||
2735 | \fn void QXmlReader::setDeclHandler(QXmlDeclHandler* handler) | - | ||||||||||||||||||||||||
2736 | - | |||||||||||||||||||||||||
2737 | Sets the declaration handler to \a handler. | - | ||||||||||||||||||||||||
2738 | - | |||||||||||||||||||||||||
2739 | \sa declHandler() | - | ||||||||||||||||||||||||
2740 | */ | - | ||||||||||||||||||||||||
2741 | - | |||||||||||||||||||||||||
2742 | /*! | - | ||||||||||||||||||||||||
2743 | \fn QXmlDeclHandler* QXmlReader::declHandler() const | - | ||||||||||||||||||||||||
2744 | - | |||||||||||||||||||||||||
2745 | Returns the declaration handler or 0 if none was set. | - | ||||||||||||||||||||||||
2746 | - | |||||||||||||||||||||||||
2747 | \sa setDeclHandler() | - | ||||||||||||||||||||||||
2748 | */ | - | ||||||||||||||||||||||||
2749 | - | |||||||||||||||||||||||||
2750 | /*! | - | ||||||||||||||||||||||||
2751 | \fn bool QXmlReader::parse(const QXmlInputSource &input) | - | ||||||||||||||||||||||||
2752 | - | |||||||||||||||||||||||||
2753 | \obsolete | - | ||||||||||||||||||||||||
2754 | - | |||||||||||||||||||||||||
2755 | Parses the given \a input. | - | ||||||||||||||||||||||||
2756 | */ | - | ||||||||||||||||||||||||
2757 | - | |||||||||||||||||||||||||
2758 | /*! | - | ||||||||||||||||||||||||
2759 | \fn bool QXmlReader::parse(const QXmlInputSource *input) | - | ||||||||||||||||||||||||
2760 | - | |||||||||||||||||||||||||
2761 | Reads an XML document from \a input and parses it. Returns \c true if | - | ||||||||||||||||||||||||
2762 | the parsing was successful; otherwise returns \c false. | - | ||||||||||||||||||||||||
2763 | */ | - | ||||||||||||||||||||||||
2764 | - | |||||||||||||||||||||||||
2765 | - | |||||||||||||||||||||||||
2766 | /*! | - | ||||||||||||||||||||||||
2767 | \class QXmlSimpleReader | - | ||||||||||||||||||||||||
2768 | \nonreentrant | - | ||||||||||||||||||||||||
2769 | \brief The QXmlSimpleReader class provides an implementation of a | - | ||||||||||||||||||||||||
2770 | simple XML parser. | - | ||||||||||||||||||||||||
2771 | - | |||||||||||||||||||||||||
2772 | \inmodule QtXml | - | ||||||||||||||||||||||||
2773 | \ingroup xml-tools | - | ||||||||||||||||||||||||
2774 | - | |||||||||||||||||||||||||
2775 | - | |||||||||||||||||||||||||
2776 | This XML reader is suitable for a wide range of applications. It | - | ||||||||||||||||||||||||
2777 | is able to parse well-formed XML and can report the namespaces of | - | ||||||||||||||||||||||||
2778 | elements to a content handler; however, it does not parse any | - | ||||||||||||||||||||||||
2779 | external entities. For historical reasons, Attribute Value | - | ||||||||||||||||||||||||
2780 | Normalization and End-of-Line Handling as described in the XML 1.0 | - | ||||||||||||||||||||||||
2781 | specification is not performed. | - | ||||||||||||||||||||||||
2782 | - | |||||||||||||||||||||||||
2783 | The easiest pattern of use for this class is to create a reader | - | ||||||||||||||||||||||||
2784 | instance, define an input source, specify the handlers to be used | - | ||||||||||||||||||||||||
2785 | by the reader, and parse the data. | - | ||||||||||||||||||||||||
2786 | - | |||||||||||||||||||||||||
2787 | For example, we could use a QFile to supply the input. Here, we | - | ||||||||||||||||||||||||
2788 | create a reader, and define an input source to be used by the | - | ||||||||||||||||||||||||
2789 | reader: | - | ||||||||||||||||||||||||
2790 | - | |||||||||||||||||||||||||
2791 | \snippet simpleparse/main.cpp 0 | - | ||||||||||||||||||||||||
2792 | - | |||||||||||||||||||||||||
2793 | A handler lets us perform actions when the reader encounters | - | ||||||||||||||||||||||||
2794 | certain types of content, or if errors in the input are found. The | - | ||||||||||||||||||||||||
2795 | reader must be told which handler to use for each type of | - | ||||||||||||||||||||||||
2796 | event. For many common applications, we can create a custom | - | ||||||||||||||||||||||||
2797 | handler by subclassing QXmlDefaultHandler, and use this to handle | - | ||||||||||||||||||||||||
2798 | both error and content events: | - | ||||||||||||||||||||||||
2799 | - | |||||||||||||||||||||||||
2800 | \snippet simpleparse/main.cpp 1 | - | ||||||||||||||||||||||||
2801 | - | |||||||||||||||||||||||||
2802 | If you don't set at least the content and error handlers, the | - | ||||||||||||||||||||||||
2803 | parser will fall back on its default behavior---and will do | - | ||||||||||||||||||||||||
2804 | nothing. | - | ||||||||||||||||||||||||
2805 | - | |||||||||||||||||||||||||
2806 | The most convenient way to handle the input is to read it in a | - | ||||||||||||||||||||||||
2807 | single pass using the parse() function with an argument that | - | ||||||||||||||||||||||||
2808 | specifies the input source: | - | ||||||||||||||||||||||||
2809 | - | |||||||||||||||||||||||||
2810 | \snippet simpleparse/main.cpp 2 | - | ||||||||||||||||||||||||
2811 | - | |||||||||||||||||||||||||
2812 | If you can't parse the entire input in one go (for example, it is | - | ||||||||||||||||||||||||
2813 | huge, or is being delivered over a network connection), data can | - | ||||||||||||||||||||||||
2814 | be fed to the parser in pieces. This is achieved by telling | - | ||||||||||||||||||||||||
2815 | parse() to work incrementally, and making subsequent calls to the | - | ||||||||||||||||||||||||
2816 | parseContinue() function, until all the data has been processed. | - | ||||||||||||||||||||||||
2817 | - | |||||||||||||||||||||||||
2818 | A common way to perform incremental parsing is to connect the \c | - | ||||||||||||||||||||||||
2819 | readyRead() signal of a \l{QNetworkReply} {network reply} a slot, | - | ||||||||||||||||||||||||
2820 | and handle the incoming data there. See QNetworkAccessManager. | - | ||||||||||||||||||||||||
2821 | - | |||||||||||||||||||||||||
2822 | Aspects of the parsing behavior can be adapted using setFeature() | - | ||||||||||||||||||||||||
2823 | and setProperty(). | - | ||||||||||||||||||||||||
2824 | - | |||||||||||||||||||||||||
2825 | \snippet code/src_xml_sax_qxml.cpp 0 | - | ||||||||||||||||||||||||
2826 | - | |||||||||||||||||||||||||
2827 | QXmlSimpleReader is not reentrant. If you want to use the class | - | ||||||||||||||||||||||||
2828 | in threaded code, lock the code using QXmlSimpleReader with a | - | ||||||||||||||||||||||||
2829 | locking mechanism, such as a QMutex. | - | ||||||||||||||||||||||||
2830 | */ | - | ||||||||||||||||||||||||
2831 | - | |||||||||||||||||||||||||
2832 | static inline bool is_S(QChar ch) | - | ||||||||||||||||||||||||
2833 | { | - | ||||||||||||||||||||||||
2834 | ushort uc = ch.unicode(); | - | ||||||||||||||||||||||||
2835 | return (uc == ' ' || uc == '\t' || uc == '\n' || uc == '\r'); executed 187992 times by 6 tests: return (uc == ' ' || uc == '\t' || uc == '\n' || uc == '\r'); Executed by:
| 0-187992 | ||||||||||||||||||||||||
2836 | } | - | ||||||||||||||||||||||||
2837 | - | |||||||||||||||||||||||||
2838 | enum NameChar { NameBeginning, NameNotBeginning, NotName }; | - | ||||||||||||||||||||||||
2839 | - | |||||||||||||||||||||||||
2840 | static const char Begi = (char)NameBeginning; | - | ||||||||||||||||||||||||
2841 | static const char NtBg = (char)NameNotBeginning; | - | ||||||||||||||||||||||||
2842 | static const char NotN = (char)NotName; | - | ||||||||||||||||||||||||
2843 | - | |||||||||||||||||||||||||
2844 | static const char nameCharTable[128] = | - | ||||||||||||||||||||||||
2845 | { | - | ||||||||||||||||||||||||
2846 | // 0x00 | - | ||||||||||||||||||||||||
2847 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||
2848 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||
2849 | // 0x10 | - | ||||||||||||||||||||||||
2850 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||
2851 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||
2852 | // 0x20 (0x2D is '-', 0x2E is '.') | - | ||||||||||||||||||||||||
2853 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||
2854 | NotN, NotN, NotN, NotN, NotN, NtBg, NtBg, NotN, | - | ||||||||||||||||||||||||
2855 | // 0x30 (0x30..0x39 are '0'..'9', 0x3A is ':') | - | ||||||||||||||||||||||||
2856 | NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, | - | ||||||||||||||||||||||||
2857 | NtBg, NtBg, Begi, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||||||||||||||
2858 | // 0x40 (0x41..0x5A are 'A'..'Z') | - | ||||||||||||||||||||||||
2859 | NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||
2860 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||
2861 | // 0x50 (0x5F is '_') | - | ||||||||||||||||||||||||
2862 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||
2863 | Begi, Begi, Begi, NotN, NotN, NotN, NotN, Begi, | - | ||||||||||||||||||||||||
2864 | // 0x60 (0x61..0x7A are 'a'..'z') | - | ||||||||||||||||||||||||
2865 | NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||
2866 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||
2867 | // 0x70 | - | ||||||||||||||||||||||||
2868 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||||||||||||||
2869 | Begi, Begi, Begi, NotN, NotN, NotN, NotN, NotN | - | ||||||||||||||||||||||||
2870 | }; | - | ||||||||||||||||||||||||
2871 | - | |||||||||||||||||||||||||
2872 | static inline NameChar fastDetermineNameChar(QChar ch) | - | ||||||||||||||||||||||||
2873 | { | - | ||||||||||||||||||||||||
2874 | ushort uc = ch.unicode(); | - | ||||||||||||||||||||||||
2875 | if (!(uc & ~0x7f)) // uc < 128
| 2385-258018 | ||||||||||||||||||||||||
2876 | return (NameChar)nameCharTable[uc]; executed 258018 times by 6 tests: return (NameChar)nameCharTable[uc]; Executed by:
| 258018 | ||||||||||||||||||||||||
2877 | - | |||||||||||||||||||||||||
2878 | QChar::Category cat = ch.category(); | - | ||||||||||||||||||||||||
2879 | // ### some these categories might be slightly wrong | - | ||||||||||||||||||||||||
2880 | if ((cat >= QChar::Letter_Uppercase && cat <= QChar::Letter_Other)
| 12-2297 | ||||||||||||||||||||||||
2881 | || cat == QChar::Number_Letter)
| 0-100 | ||||||||||||||||||||||||
2882 | return NameBeginning; executed 2285 times by 1 test: return NameBeginning; Executed by:
| 2285 | ||||||||||||||||||||||||
2883 | if ((cat >= QChar::Number_DecimalDigit && cat <= QChar::Number_Other)
| 0-77 | ||||||||||||||||||||||||
2884 | || (cat >= QChar::Mark_NonSpacing && cat <= QChar::Mark_Enclosing))
| 0-100 | ||||||||||||||||||||||||
2885 | return NameNotBeginning; executed 77 times by 1 test: return NameNotBeginning; Executed by:
| 77 | ||||||||||||||||||||||||
2886 | return NotName; executed 23 times by 1 test: return NotName; Executed by:
| 23 | ||||||||||||||||||||||||
2887 | } | - | ||||||||||||||||||||||||
2888 | - | |||||||||||||||||||||||||
2889 | static NameChar determineNameChar(QChar ch) | - | ||||||||||||||||||||||||
2890 | { | - | ||||||||||||||||||||||||
2891 | return fastDetermineNameChar(ch); executed 40888 times by 6 tests: return fastDetermineNameChar(ch); Executed by:
| 40888 | ||||||||||||||||||||||||
2892 | } | - | ||||||||||||||||||||||||
2893 | - | |||||||||||||||||||||||||
2894 | /*! | - | ||||||||||||||||||||||||
2895 | Constructs a simple XML reader. | - | ||||||||||||||||||||||||
2896 | - | |||||||||||||||||||||||||
2897 | */ | - | ||||||||||||||||||||||||
2898 | QXmlSimpleReader::QXmlSimpleReader() | - | ||||||||||||||||||||||||
2899 | : d_ptr(new QXmlSimpleReaderPrivate(this)) | - | ||||||||||||||||||||||||
2900 | { | - | ||||||||||||||||||||||||
2901 | } executed 2104 times by 6 tests: end of block Executed by:
| 2104 | ||||||||||||||||||||||||
2902 | - | |||||||||||||||||||||||||
2903 | /*! | - | ||||||||||||||||||||||||
2904 | Destroys the simple XML reader. | - | ||||||||||||||||||||||||
2905 | */ | - | ||||||||||||||||||||||||
2906 | QXmlSimpleReader::~QXmlSimpleReader() | - | ||||||||||||||||||||||||
2907 | { | - | ||||||||||||||||||||||||
2908 | } | - | ||||||||||||||||||||||||
2909 | - | |||||||||||||||||||||||||
2910 | /*! | - | ||||||||||||||||||||||||
2911 | \reimp | - | ||||||||||||||||||||||||
2912 | */ | - | ||||||||||||||||||||||||
2913 | bool QXmlSimpleReader::feature(const QString& name, bool *ok) const | - | ||||||||||||||||||||||||
2914 | { | - | ||||||||||||||||||||||||
2915 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2916 | - | |||||||||||||||||||||||||
2917 | if (ok != 0)
| 0-246 | ||||||||||||||||||||||||
2918 | *ok = true; never executed: *ok = true; | 0 | ||||||||||||||||||||||||
2919 | if (name == QLatin1String("http://xml.org/sax/features/namespaces")) {
| 2-244 | ||||||||||||||||||||||||
2920 | return d->useNamespaces; executed 244 times by 5 tests: return d->useNamespaces; Executed by:
| 244 | ||||||||||||||||||||||||
2921 | } else if (name == QLatin1String("http://xml.org/sax/features/namespace-prefixes")) {
| 0-2 | ||||||||||||||||||||||||
2922 | return d->useNamespacePrefixes; executed 2 times by 1 test: return d->useNamespacePrefixes; Executed by:
| 2 | ||||||||||||||||||||||||
2923 | } else if (name == QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData") // For compat with Qt 4
| 0 | ||||||||||||||||||||||||
2924 | || name == QLatin1String("http://qt-project.org/xml/features/report-whitespace-only-CharData")) {
| 0 | ||||||||||||||||||||||||
2925 | return d->reportWhitespaceCharData; never executed: return d->reportWhitespaceCharData; | 0 | ||||||||||||||||||||||||
2926 | } else if (name == QLatin1String("http://trolltech.com/xml/features/report-start-end-entity") // For compat with Qt 4
| 0 | ||||||||||||||||||||||||
2927 | || name == QLatin1String("http://qt-project.org/xml/features/report-start-end-entity")) {
| 0 | ||||||||||||||||||||||||
2928 | return d->reportEntities; never executed: return d->reportEntities; | 0 | ||||||||||||||||||||||||
2929 | } else { | - | ||||||||||||||||||||||||
2930 | qWarning("Unknown feature %s", name.toLatin1().data()); | - | ||||||||||||||||||||||||
2931 | if (ok != 0)
| 0 | ||||||||||||||||||||||||
2932 | *ok = false; never executed: *ok = false; | 0 | ||||||||||||||||||||||||
2933 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2934 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2935 | } | - | ||||||||||||||||||||||||
2936 | - | |||||||||||||||||||||||||
2937 | /*! | - | ||||||||||||||||||||||||
2938 | Turns on the feature \a name if \a enable is true; otherwise turns it off. | - | ||||||||||||||||||||||||
2939 | - | |||||||||||||||||||||||||
2940 | The \a name parameter must be one of the following strings: | - | ||||||||||||||||||||||||
2941 | \table | - | ||||||||||||||||||||||||
2942 | \header \li Feature \li Default \li Notes | - | ||||||||||||||||||||||||
2943 | \row \li \e http://xml.org/sax/features/namespaces | - | ||||||||||||||||||||||||
2944 | \li true | - | ||||||||||||||||||||||||
2945 | \li If enabled, namespaces are reported to the content handler. | - | ||||||||||||||||||||||||
2946 | \row \li \e http://xml.org/sax/features/namespace-prefixes | - | ||||||||||||||||||||||||
2947 | \li false | - | ||||||||||||||||||||||||
2948 | \li If enabled, the original prefixed names | - | ||||||||||||||||||||||||
2949 | and attributes used for namespace declarations are | - | ||||||||||||||||||||||||
2950 | reported. | - | ||||||||||||||||||||||||
2951 | \row \li \e http://qt-project.org/xml/features/report-whitespace-only-CharData | - | ||||||||||||||||||||||||
2952 | \li true | - | ||||||||||||||||||||||||
2953 | \li If enabled, CharData that consist of | - | ||||||||||||||||||||||||
2954 | only whitespace characters are reported | - | ||||||||||||||||||||||||
2955 | using QXmlContentHandler::characters(). If disabled, whitespace is silently | - | ||||||||||||||||||||||||
2956 | discarded. | - | ||||||||||||||||||||||||
2957 | \row \li \e http://qt-project.org/xml/features/report-start-end-entity | - | ||||||||||||||||||||||||
2958 | \li false | - | ||||||||||||||||||||||||
2959 | \li If enabled, the parser reports | - | ||||||||||||||||||||||||
2960 | QXmlContentHandler::startEntity() and | - | ||||||||||||||||||||||||
2961 | QXmlContentHandler::endEntity() events, so character data | - | ||||||||||||||||||||||||
2962 | might be reported in chunks. | - | ||||||||||||||||||||||||
2963 | If disabled, the parser does not report these events, but | - | ||||||||||||||||||||||||
2964 | silently substitutes the entities, and reports the character | - | ||||||||||||||||||||||||
2965 | data in one chunk. | - | ||||||||||||||||||||||||
2966 | \endtable | - | ||||||||||||||||||||||||
2967 | - | |||||||||||||||||||||||||
2968 | \sa feature(), hasFeature(), {SAX2 Features} | - | ||||||||||||||||||||||||
2969 | */ | - | ||||||||||||||||||||||||
2970 | void QXmlSimpleReader::setFeature(const QString& name, bool enable) | - | ||||||||||||||||||||||||
2971 | { | - | ||||||||||||||||||||||||
2972 | Q_D(QXmlSimpleReader); | - | ||||||||||||||||||||||||
2973 | if (name == QLatin1String("http://xml.org/sax/features/namespaces")) {
| 244-488 | ||||||||||||||||||||||||
2974 | d->useNamespaces = enable; | - | ||||||||||||||||||||||||
2975 | } else if (name == QLatin1String("http://xml.org/sax/features/namespace-prefixes")) { executed 244 times by 5 tests: end of block Executed by:
| 244 | ||||||||||||||||||||||||
2976 | d->useNamespacePrefixes = enable; | - | ||||||||||||||||||||||||
2977 | } else if (name == QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData") // For compat with Qt 4 executed 244 times by 5 tests: end of block Executed by:
| 0-244 | ||||||||||||||||||||||||
2978 | || name == QLatin1String("http://qt-project.org/xml/features/report-whitespace-only-CharData")) {
| 0 | ||||||||||||||||||||||||
2979 | d->reportWhitespaceCharData = enable; | - | ||||||||||||||||||||||||
2980 | } else if (name == QLatin1String("http://trolltech.com/xml/features/report-start-end-entity") // For compat with Qt 4 executed 244 times by 5 tests: end of block Executed by:
| 0-244 | ||||||||||||||||||||||||
2981 | || name == QLatin1String("http://qt-project.org/xml/features/report-start-end-entity")) {
| 0 | ||||||||||||||||||||||||
2982 | d->reportEntities = enable; | - | ||||||||||||||||||||||||
2983 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
2984 | qWarning("Unknown feature %s", name.toLatin1().data()); | - | ||||||||||||||||||||||||
2985 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2986 | } | - | ||||||||||||||||||||||||
2987 | - | |||||||||||||||||||||||||
2988 | /*! \reimp | - | ||||||||||||||||||||||||
2989 | */ | - | ||||||||||||||||||||||||
2990 | bool QXmlSimpleReader::hasFeature(const QString& name) const | - | ||||||||||||||||||||||||
2991 | { | - | ||||||||||||||||||||||||
2992 | if (name == QLatin1String("http://xml.org/sax/features/namespaces")
| 0 | ||||||||||||||||||||||||
2993 | || name == QLatin1String("http://xml.org/sax/features/namespace-prefixes")
| 0 | ||||||||||||||||||||||||
2994 | || name == QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData") // For compat with Qt 4
| 0 | ||||||||||||||||||||||||
2995 | || name == QLatin1String("http://qt-project.org/xml/features/report-whitespace-only-CharData")
| 0 | ||||||||||||||||||||||||
2996 | || name == QLatin1String("http://trolltech.com/xml/features/report-start-end-entity") // For compat with Qt 4
| 0 | ||||||||||||||||||||||||
2997 | || name == QLatin1String("http://qt-project.org/xml/features/report-start-end-entity")) {
| 0 | ||||||||||||||||||||||||
2998 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2999 | } else { | - | ||||||||||||||||||||||||
3000 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3001 | } | - | ||||||||||||||||||||||||
3002 | } | - | ||||||||||||||||||||||||
3003 | - | |||||||||||||||||||||||||
3004 | /*! \reimp | - | ||||||||||||||||||||||||
3005 | */ | - | ||||||||||||||||||||||||
3006 | void* QXmlSimpleReader::property(const QString&, bool *ok) const | - | ||||||||||||||||||||||||
3007 | { | - | ||||||||||||||||||||||||
3008 | if (ok != 0)
| 0 | ||||||||||||||||||||||||
3009 | *ok = false; never executed: *ok = false; | 0 | ||||||||||||||||||||||||
3010 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
3011 | } | - | ||||||||||||||||||||||||
3012 | - | |||||||||||||||||||||||||
3013 | /*! \reimp | - | ||||||||||||||||||||||||
3014 | */ | - | ||||||||||||||||||||||||
3015 | void QXmlSimpleReader::setProperty(const QString&, void*) | - | ||||||||||||||||||||||||
3016 | { | - | ||||||||||||||||||||||||
3017 | } | - | ||||||||||||||||||||||||
3018 | - | |||||||||||||||||||||||||
3019 | /*! | - | ||||||||||||||||||||||||
3020 | \reimp | - | ||||||||||||||||||||||||
3021 | */ | - | ||||||||||||||||||||||||
3022 | bool QXmlSimpleReader::hasProperty(const QString&) const | - | ||||||||||||||||||||||||
3023 | { | - | ||||||||||||||||||||||||
3024 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3025 | } | - | ||||||||||||||||||||||||
3026 | - | |||||||||||||||||||||||||
3027 | /*! | - | ||||||||||||||||||||||||
3028 | \reimp | - | ||||||||||||||||||||||||
3029 | */ | - | ||||||||||||||||||||||||
3030 | void QXmlSimpleReader::setEntityResolver(QXmlEntityResolver* handler) | - | ||||||||||||||||||||||||
3031 | { | - | ||||||||||||||||||||||||
3032 | Q_D(QXmlSimpleReader); | - | ||||||||||||||||||||||||
3033 | d->entityRes = handler; | - | ||||||||||||||||||||||||
3034 | } executed 1845 times by 1 test: end of block Executed by:
| 1845 | ||||||||||||||||||||||||
3035 | - | |||||||||||||||||||||||||
3036 | /*! | - | ||||||||||||||||||||||||
3037 | \reimp | - | ||||||||||||||||||||||||
3038 | */ | - | ||||||||||||||||||||||||
3039 | QXmlEntityResolver* QXmlSimpleReader::entityResolver() const | - | ||||||||||||||||||||||||
3040 | { | - | ||||||||||||||||||||||||
3041 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
3042 | return d->entityRes; never executed: return d->entityRes; | 0 | ||||||||||||||||||||||||
3043 | } | - | ||||||||||||||||||||||||
3044 | - | |||||||||||||||||||||||||
3045 | /*! | - | ||||||||||||||||||||||||
3046 | \reimp | - | ||||||||||||||||||||||||
3047 | */ | - | ||||||||||||||||||||||||
3048 | void QXmlSimpleReader::setDTDHandler(QXmlDTDHandler* handler) | - | ||||||||||||||||||||||||
3049 | { | - | ||||||||||||||||||||||||
3050 | Q_D(QXmlSimpleReader); | - | ||||||||||||||||||||||||
3051 | d->dtdHnd = handler; | - | ||||||||||||||||||||||||
3052 | } executed 2089 times by 5 tests: end of block Executed by:
| 2089 | ||||||||||||||||||||||||
3053 | - | |||||||||||||||||||||||||
3054 | /*! | - | ||||||||||||||||||||||||
3055 | \reimp | - | ||||||||||||||||||||||||
3056 | */ | - | ||||||||||||||||||||||||
3057 | QXmlDTDHandler* QXmlSimpleReader::DTDHandler() const | - | ||||||||||||||||||||||||
3058 | { | - | ||||||||||||||||||||||||
3059 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
3060 | return d->dtdHnd; never executed: return d->dtdHnd; | 0 | ||||||||||||||||||||||||
3061 | } | - | ||||||||||||||||||||||||
3062 | - | |||||||||||||||||||||||||
3063 | /*! | - | ||||||||||||||||||||||||
3064 | \reimp | - | ||||||||||||||||||||||||
3065 | */ | - | ||||||||||||||||||||||||
3066 | void QXmlSimpleReader::setContentHandler(QXmlContentHandler* handler) | - | ||||||||||||||||||||||||
3067 | { | - | ||||||||||||||||||||||||
3068 | Q_D(QXmlSimpleReader); | - | ||||||||||||||||||||||||
3069 | d->contentHnd = handler; | - | ||||||||||||||||||||||||
3070 | } executed 2100 times by 6 tests: end of block Executed by:
| 2100 | ||||||||||||||||||||||||
3071 | - | |||||||||||||||||||||||||
3072 | /*! | - | ||||||||||||||||||||||||
3073 | \reimp | - | ||||||||||||||||||||||||
3074 | */ | - | ||||||||||||||||||||||||
3075 | QXmlContentHandler* QXmlSimpleReader::contentHandler() const | - | ||||||||||||||||||||||||
3076 | { | - | ||||||||||||||||||||||||
3077 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
3078 | return d->contentHnd; never executed: return d->contentHnd; | 0 | ||||||||||||||||||||||||
3079 | } | - | ||||||||||||||||||||||||
3080 | - | |||||||||||||||||||||||||
3081 | /*! | - | ||||||||||||||||||||||||
3082 | \reimp | - | ||||||||||||||||||||||||
3083 | */ | - | ||||||||||||||||||||||||
3084 | void QXmlSimpleReader::setErrorHandler(QXmlErrorHandler* handler) | - | ||||||||||||||||||||||||
3085 | { | - | ||||||||||||||||||||||||
3086 | Q_D(QXmlSimpleReader); | - | ||||||||||||||||||||||||
3087 | d->errorHnd = handler; | - | ||||||||||||||||||||||||
3088 | } executed 2094 times by 5 tests: end of block Executed by:
| 2094 | ||||||||||||||||||||||||
3089 | - | |||||||||||||||||||||||||
3090 | /*! | - | ||||||||||||||||||||||||
3091 | \reimp | - | ||||||||||||||||||||||||
3092 | */ | - | ||||||||||||||||||||||||
3093 | QXmlErrorHandler* QXmlSimpleReader::errorHandler() const | - | ||||||||||||||||||||||||
3094 | { | - | ||||||||||||||||||||||||
3095 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
3096 | return d->errorHnd; never executed: return d->errorHnd; | 0 | ||||||||||||||||||||||||
3097 | } | - | ||||||||||||||||||||||||
3098 | - | |||||||||||||||||||||||||
3099 | /*! | - | ||||||||||||||||||||||||
3100 | \reimp | - | ||||||||||||||||||||||||
3101 | */ | - | ||||||||||||||||||||||||
3102 | void QXmlSimpleReader::setLexicalHandler(QXmlLexicalHandler* handler) | - | ||||||||||||||||||||||||
3103 | { | - | ||||||||||||||||||||||||
3104 | Q_D(QXmlSimpleReader); | - | ||||||||||||||||||||||||
3105 | d->lexicalHnd = handler; | - | ||||||||||||||||||||||||
3106 | } executed 2089 times by 5 tests: end of block Executed by:
| 2089 | ||||||||||||||||||||||||
3107 | - | |||||||||||||||||||||||||
3108 | /*! | - | ||||||||||||||||||||||||
3109 | \reimp | - | ||||||||||||||||||||||||
3110 | */ | - | ||||||||||||||||||||||||
3111 | QXmlLexicalHandler* QXmlSimpleReader::lexicalHandler() const | - | ||||||||||||||||||||||||
3112 | { | - | ||||||||||||||||||||||||
3113 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
3114 | return d->lexicalHnd; never executed: return d->lexicalHnd; | 0 | ||||||||||||||||||||||||
3115 | } | - | ||||||||||||||||||||||||
3116 | - | |||||||||||||||||||||||||
3117 | /*! | - | ||||||||||||||||||||||||
3118 | \reimp | - | ||||||||||||||||||||||||
3119 | */ | - | ||||||||||||||||||||||||
3120 | void QXmlSimpleReader::setDeclHandler(QXmlDeclHandler* handler) | - | ||||||||||||||||||||||||
3121 | { | - | ||||||||||||||||||||||||
3122 | Q_D(QXmlSimpleReader); | - | ||||||||||||||||||||||||
3123 | d->declHnd = handler; | - | ||||||||||||||||||||||||
3124 | } executed 2092 times by 5 tests: end of block Executed by:
| 2092 | ||||||||||||||||||||||||
3125 | - | |||||||||||||||||||||||||
3126 | /*! | - | ||||||||||||||||||||||||
3127 | \reimp | - | ||||||||||||||||||||||||
3128 | */ | - | ||||||||||||||||||||||||
3129 | QXmlDeclHandler* QXmlSimpleReader::declHandler() const | - | ||||||||||||||||||||||||
3130 | { | - | ||||||||||||||||||||||||
3131 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
3132 | return d->declHnd; never executed: return d->declHnd; | 0 | ||||||||||||||||||||||||
3133 | } | - | ||||||||||||||||||||||||
3134 | - | |||||||||||||||||||||||||
3135 | - | |||||||||||||||||||||||||
3136 | - | |||||||||||||||||||||||||
3137 | /*! | - | ||||||||||||||||||||||||
3138 | \reimp | - | ||||||||||||||||||||||||
3139 | */ | - | ||||||||||||||||||||||||
3140 | bool QXmlSimpleReader::parse(const QXmlInputSource& input) | - | ||||||||||||||||||||||||
3141 | { | - | ||||||||||||||||||||||||
3142 | return parse(&input, false); executed 359 times by 2 tests: return parse(&input, false); Executed by:
| 359 | ||||||||||||||||||||||||
3143 | } | - | ||||||||||||||||||||||||
3144 | - | |||||||||||||||||||||||||
3145 | /*! | - | ||||||||||||||||||||||||
3146 | Reads an XML document from \a input and parses it in one pass (non-incrementally). | - | ||||||||||||||||||||||||
3147 | Returns \c true if the parsing was successful; otherwise returns \c false. | - | ||||||||||||||||||||||||
3148 | */ | - | ||||||||||||||||||||||||
3149 | bool QXmlSimpleReader::parse(const QXmlInputSource* input) | - | ||||||||||||||||||||||||
3150 | { | - | ||||||||||||||||||||||||
3151 | return parse(input, false); executed 252 times by 5 tests: return parse(input, false); Executed by:
| 252 | ||||||||||||||||||||||||
3152 | } | - | ||||||||||||||||||||||||
3153 | - | |||||||||||||||||||||||||
3154 | /*! | - | ||||||||||||||||||||||||
3155 | Reads an XML document from \a input and parses it. Returns \c true | - | ||||||||||||||||||||||||
3156 | if the parsing is completed successfully; otherwise returns \c false, | - | ||||||||||||||||||||||||
3157 | indicating that an error occurred. | - | ||||||||||||||||||||||||
3158 | - | |||||||||||||||||||||||||
3159 | If \a incremental is false, this function will return false if the XML | - | ||||||||||||||||||||||||
3160 | file is not read completely. The parsing cannot be continued in this | - | ||||||||||||||||||||||||
3161 | case. | - | ||||||||||||||||||||||||
3162 | - | |||||||||||||||||||||||||
3163 | If \a incremental is true, the parser does not return false if | - | ||||||||||||||||||||||||
3164 | it reaches the end of the \a input before reaching the end | - | ||||||||||||||||||||||||
3165 | of the XML file. Instead, it stores the state of the parser so that | - | ||||||||||||||||||||||||
3166 | parsing can be continued later when more data is available. | - | ||||||||||||||||||||||||
3167 | In such a case, you can use the function parseContinue() to | - | ||||||||||||||||||||||||
3168 | continue with parsing. This class stores a pointer to the input | - | ||||||||||||||||||||||||
3169 | source \a input and the parseContinue() function tries to read from | - | ||||||||||||||||||||||||
3170 | that input source. Therefore, you should not delete the input | - | ||||||||||||||||||||||||
3171 | source \a input until you no longer need to call parseContinue(). | - | ||||||||||||||||||||||||
3172 | - | |||||||||||||||||||||||||
3173 | If this function is called with \a incremental set to true | - | ||||||||||||||||||||||||
3174 | while an incremental parse is in progress, a new parsing | - | ||||||||||||||||||||||||
3175 | session will be started, and the previous session will be lost. | - | ||||||||||||||||||||||||
3176 | - | |||||||||||||||||||||||||
3177 | \sa parseContinue(), QTcpSocket | - | ||||||||||||||||||||||||
3178 | */ | - | ||||||||||||||||||||||||
3179 | bool QXmlSimpleReader::parse(const QXmlInputSource *input, bool incremental) | - | ||||||||||||||||||||||||
3180 | { | - | ||||||||||||||||||||||||
3181 | Q_D(QXmlSimpleReader); | - | ||||||||||||||||||||||||
3182 | - | |||||||||||||||||||||||||
3183 | d->literalEntitySizes.clear(); | - | ||||||||||||||||||||||||
3184 | d->referencesToOtherEntities.clear(); | - | ||||||||||||||||||||||||
3185 | d->expandedSizes.clear(); | - | ||||||||||||||||||||||||
3186 | - | |||||||||||||||||||||||||
3187 | if (incremental) {
| 616-1490 | ||||||||||||||||||||||||
3188 | d->initIncrementalParsing(); | - | ||||||||||||||||||||||||
3189 | } else { executed 1490 times by 1 test: end of block Executed by:
| 1490 | ||||||||||||||||||||||||
3190 | delete d->parseStack; | - | ||||||||||||||||||||||||
3191 | d->parseStack = 0; | - | ||||||||||||||||||||||||
3192 | } executed 616 times by 6 tests: end of block Executed by:
| 616 | ||||||||||||||||||||||||
3193 | d->init(input); | - | ||||||||||||||||||||||||
3194 | - | |||||||||||||||||||||||||
3195 | // call the handler | - | ||||||||||||||||||||||||
3196 | if (d->contentHnd) {
| 6-2100 | ||||||||||||||||||||||||
3197 | d->contentHnd->setDocumentLocator(d->locator.data()); | - | ||||||||||||||||||||||||
3198 | if (!d->contentHnd->startDocument()) {
| 0-2100 | ||||||||||||||||||||||||
3199 | d->reportParseError(d->contentHnd->errorString()); | - | ||||||||||||||||||||||||
3200 | d->tags.clear(); | - | ||||||||||||||||||||||||
3201 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3202 | } | - | ||||||||||||||||||||||||
3203 | } executed 2100 times by 6 tests: end of block Executed by:
| 2100 | ||||||||||||||||||||||||
3204 | d->skipped_entity_in_content = false; | - | ||||||||||||||||||||||||
3205 | return d->parseBeginOrContinue(0, incremental); executed 2106 times by 6 tests: return d->parseBeginOrContinue(0, incremental); Executed by:
| 2106 | ||||||||||||||||||||||||
3206 | } | - | ||||||||||||||||||||||||
3207 | - | |||||||||||||||||||||||||
3208 | /*! | - | ||||||||||||||||||||||||
3209 | Continues incremental parsing, taking input from the | - | ||||||||||||||||||||||||
3210 | QXmlInputSource that was specified with the most recent | - | ||||||||||||||||||||||||
3211 | call to parse(). To use this function, you \e must have called | - | ||||||||||||||||||||||||
3212 | parse() with the incremental argument set to true. | - | ||||||||||||||||||||||||
3213 | - | |||||||||||||||||||||||||
3214 | Returns \c false if a parsing error occurs; otherwise returns \c true, | - | ||||||||||||||||||||||||
3215 | even if the end of the XML file has not been reached. You can | - | ||||||||||||||||||||||||
3216 | continue parsing at a later stage by calling this function again | - | ||||||||||||||||||||||||
3217 | when there is more data available to parse. | - | ||||||||||||||||||||||||
3218 | - | |||||||||||||||||||||||||
3219 | Calling this function when there is no data available in the input | - | ||||||||||||||||||||||||
3220 | source indicates to the reader that the end of the XML file has | - | ||||||||||||||||||||||||
3221 | been reached. If the input supplied up to this point was | - | ||||||||||||||||||||||||
3222 | not well-formed then a parsing error occurs, and false is returned. | - | ||||||||||||||||||||||||
3223 | If the input supplied was well-formed, true is returned. | - | ||||||||||||||||||||||||
3224 | It is important to end the input in this way because it allows you | - | ||||||||||||||||||||||||
3225 | to reuse the reader to parse other XML files. | - | ||||||||||||||||||||||||
3226 | - | |||||||||||||||||||||||||
3227 | Calling this function after the end of file has been reached, but | - | ||||||||||||||||||||||||
3228 | without available data will cause false to be returned whether the | - | ||||||||||||||||||||||||
3229 | previous input was well-formed or not. | - | ||||||||||||||||||||||||
3230 | - | |||||||||||||||||||||||||
3231 | \sa parse(), QXmlInputSource::data(), QXmlInputSource::next() | - | ||||||||||||||||||||||||
3232 | */ | - | ||||||||||||||||||||||||
3233 | bool QXmlSimpleReader::parseContinue() | - | ||||||||||||||||||||||||
3234 | { | - | ||||||||||||||||||||||||
3235 | Q_D(QXmlSimpleReader); | - | ||||||||||||||||||||||||
3236 | if (d->parseStack == 0 || d->parseStack->isEmpty())
| 0-44908 | ||||||||||||||||||||||||
3237 | return false; executed 1490 times by 1 test: return false; Executed by:
| 1490 | ||||||||||||||||||||||||
3238 | d->initData(); | - | ||||||||||||||||||||||||
3239 | int state = d->parseStack->pop().state; | - | ||||||||||||||||||||||||
3240 | return d->parseBeginOrContinue(state, true); executed 44908 times by 1 test: return d->parseBeginOrContinue(state, true); Executed by:
| 44908 | ||||||||||||||||||||||||
3241 | } | - | ||||||||||||||||||||||||
3242 | - | |||||||||||||||||||||||||
3243 | /* | - | ||||||||||||||||||||||||
3244 | Common part of parse() and parseContinue() | - | ||||||||||||||||||||||||
3245 | */ | - | ||||||||||||||||||||||||
3246 | bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) | - | ||||||||||||||||||||||||
3247 | { | - | ||||||||||||||||||||||||
3248 | bool atEndOrig = atEnd(); | - | ||||||||||||||||||||||||
3249 | - | |||||||||||||||||||||||||
3250 | if (state==0) {
| 10967-36047 | ||||||||||||||||||||||||
3251 | if (!parseProlog()) {
| 2029-34018 | ||||||||||||||||||||||||
3252 | if (incremental && error.isNull()) {
| 0-33941 | ||||||||||||||||||||||||
3253 | pushParseState(0, 0); | - | ||||||||||||||||||||||||
3254 | return true; executed 33941 times by 1 test: return true; Executed by:
| 33941 | ||||||||||||||||||||||||
3255 | } else { | - | ||||||||||||||||||||||||
3256 | tags.clear(); | - | ||||||||||||||||||||||||
3257 | return false; executed 77 times by 1 test: return false; Executed by:
| 77 | ||||||||||||||||||||||||
3258 | } | - | ||||||||||||||||||||||||
3259 | } | - | ||||||||||||||||||||||||
3260 | state = 1; | - | ||||||||||||||||||||||||
3261 | } executed 2029 times by 6 tests: end of block Executed by:
| 2029 | ||||||||||||||||||||||||
3262 | if (state==1) {
| 2514-10482 | ||||||||||||||||||||||||
3263 | if (!parseElement()) {
| 1961-8521 | ||||||||||||||||||||||||
3264 | if (incremental && error.isNull()) {
| 0-8453 | ||||||||||||||||||||||||
3265 | pushParseState(0, 1); | - | ||||||||||||||||||||||||
3266 | return true; executed 8453 times by 1 test: return true; Executed by:
| 8453 | ||||||||||||||||||||||||
3267 | } else { | - | ||||||||||||||||||||||||
3268 | tags.clear(); | - | ||||||||||||||||||||||||
3269 | return false; executed 68 times by 1 test: return false; Executed by:
| 68 | ||||||||||||||||||||||||
3270 | } | - | ||||||||||||||||||||||||
3271 | } | - | ||||||||||||||||||||||||
3272 | state = 2; | - | ||||||||||||||||||||||||
3273 | } executed 1961 times by 6 tests: end of block Executed by:
| 1961 | ||||||||||||||||||||||||
3274 | // parse Misc* | - | ||||||||||||||||||||||||
3275 | while (!atEnd()) {
| 2340-2392 | ||||||||||||||||||||||||
3276 | if (!parseMisc()) {
| 257-2083 | ||||||||||||||||||||||||
3277 | if (incremental && error.isNull()) {
| 0-2073 | ||||||||||||||||||||||||
3278 | pushParseState(0, 2); | - | ||||||||||||||||||||||||
3279 | return true; executed 2073 times by 1 test: return true; Executed by:
| 2073 | ||||||||||||||||||||||||
3280 | } else { | - | ||||||||||||||||||||||||
3281 | tags.clear(); | - | ||||||||||||||||||||||||
3282 | return false; executed 10 times by 1 test: return false; Executed by:
| 10 | ||||||||||||||||||||||||
3283 | } | - | ||||||||||||||||||||||||
3284 | } | - | ||||||||||||||||||||||||
3285 | } executed 257 times by 2 tests: end of block Executed by:
| 257 | ||||||||||||||||||||||||
3286 | if (!atEndOrig && incremental) {
| 441-1490 | ||||||||||||||||||||||||
3287 | // we parsed something at all, so be prepared to come back later | - | ||||||||||||||||||||||||
3288 | pushParseState(0, 2); | - | ||||||||||||||||||||||||
3289 | return true; executed 441 times by 1 test: return true; Executed by:
| 441 | ||||||||||||||||||||||||
3290 | } | - | ||||||||||||||||||||||||
3291 | // is stack empty? | - | ||||||||||||||||||||||||
3292 | if (!tags.isEmpty() && !error.isNull()) {
| 0-1951 | ||||||||||||||||||||||||
3293 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDEOF)); | - | ||||||||||||||||||||||||
3294 | tags.clear(); | - | ||||||||||||||||||||||||
3295 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3296 | } | - | ||||||||||||||||||||||||
3297 | // call the handler | - | ||||||||||||||||||||||||
3298 | if (contentHnd) {
| 1-1950 | ||||||||||||||||||||||||
3299 | delete parseStack; | - | ||||||||||||||||||||||||
3300 | parseStack = 0; | - | ||||||||||||||||||||||||
3301 | if (!contentHnd->endDocument()) {
| 0-1950 | ||||||||||||||||||||||||
3302 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3303 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3304 | } | - | ||||||||||||||||||||||||
3305 | } executed 1950 times by 6 tests: end of block Executed by:
| 1950 | ||||||||||||||||||||||||
3306 | return true; executed 1951 times by 6 tests: return true; Executed by:
| 1951 | ||||||||||||||||||||||||
3307 | } | - | ||||||||||||||||||||||||
3308 | - | |||||||||||||||||||||||||
3309 | // | - | ||||||||||||||||||||||||
3310 | // The following private parse functions have another semantics for the return | - | ||||||||||||||||||||||||
3311 | // value: They return true iff parsing has finished successfully (i.e. the end | - | ||||||||||||||||||||||||
3312 | // of the XML file must be reached!). If one of these functions return false, | - | ||||||||||||||||||||||||
3313 | // there is only an error when d->error.isNULL() is also false. | - | ||||||||||||||||||||||||
3314 | // | - | ||||||||||||||||||||||||
3315 | - | |||||||||||||||||||||||||
3316 | /* | - | ||||||||||||||||||||||||
3317 | For the incremental parsing, it is very important that the parse...() | - | ||||||||||||||||||||||||
3318 | functions have a certain structure. Since it might be hard to understand how | - | ||||||||||||||||||||||||
3319 | they work, here is a description of the layout of these functions: | - | ||||||||||||||||||||||||
3320 | - | |||||||||||||||||||||||||
3321 | bool QXmlSimpleReader::parse...() | - | ||||||||||||||||||||||||
3322 | { | - | ||||||||||||||||||||||||
3323 | (1) const signed char Init = 0; | - | ||||||||||||||||||||||||
3324 | ... | - | ||||||||||||||||||||||||
3325 | - | |||||||||||||||||||||||||
3326 | (2) const signed char Inp... = 0; | - | ||||||||||||||||||||||||
3327 | ... | - | ||||||||||||||||||||||||
3328 | - | |||||||||||||||||||||||||
3329 | (3) static const signed char table[3][2] = { | - | ||||||||||||||||||||||||
3330 | ... | - | ||||||||||||||||||||||||
3331 | }; | - | ||||||||||||||||||||||||
3332 | signed char state; | - | ||||||||||||||||||||||||
3333 | signed char input; | - | ||||||||||||||||||||||||
3334 | - | |||||||||||||||||||||||||
3335 | (4) if (d->parseStack == 0 || d->parseStack->isEmpty()) { | - | ||||||||||||||||||||||||
3336 | (4a) ... | - | ||||||||||||||||||||||||
3337 | } else { | - | ||||||||||||||||||||||||
3338 | (4b) ... | - | ||||||||||||||||||||||||
3339 | } | - | ||||||||||||||||||||||||
3340 | - | |||||||||||||||||||||||||
3341 | for (; ;) { | - | ||||||||||||||||||||||||
3342 | (5) switch (state) { | - | ||||||||||||||||||||||||
3343 | ... | - | ||||||||||||||||||||||||
3344 | } | - | ||||||||||||||||||||||||
3345 | - | |||||||||||||||||||||||||
3346 | (6) | - | ||||||||||||||||||||||||
3347 | (6a) if (atEnd()) { | - | ||||||||||||||||||||||||
3348 | unexpectedEof(&QXmlSimpleReader::parseNmtoken, state); | - | ||||||||||||||||||||||||
3349 | return false; | - | ||||||||||||||||||||||||
3350 | } | - | ||||||||||||||||||||||||
3351 | (6b) if (determineNameChar(c) != NotName) { | - | ||||||||||||||||||||||||
3352 | ... | - | ||||||||||||||||||||||||
3353 | } | - | ||||||||||||||||||||||||
3354 | (7) state = table[state][input]; | - | ||||||||||||||||||||||||
3355 | - | |||||||||||||||||||||||||
3356 | (8) switch (state) { | - | ||||||||||||||||||||||||
3357 | ... | - | ||||||||||||||||||||||||
3358 | } | - | ||||||||||||||||||||||||
3359 | } | - | ||||||||||||||||||||||||
3360 | } | - | ||||||||||||||||||||||||
3361 | - | |||||||||||||||||||||||||
3362 | Explanation: | - | ||||||||||||||||||||||||
3363 | ad 1: constants for the states (used in the transition table) | - | ||||||||||||||||||||||||
3364 | ad 2: constants for the input (used in the transition table) | - | ||||||||||||||||||||||||
3365 | ad 3: the transition table for the state machine | - | ||||||||||||||||||||||||
3366 | ad 4: test if we are in a parseContinue() step | - | ||||||||||||||||||||||||
3367 | a) if no, do inititalizations | - | ||||||||||||||||||||||||
3368 | b) if yes, restore the state and call parse functions recursively | - | ||||||||||||||||||||||||
3369 | ad 5: Do some actions according to the state; from the logical execution | - | ||||||||||||||||||||||||
3370 | order, this code belongs after 8 (see there for an explanation) | - | ||||||||||||||||||||||||
3371 | ad 6: Check the character that is at the actual "cursor" position: | - | ||||||||||||||||||||||||
3372 | a) If we reached the EOF, report either error or push the state (in the | - | ||||||||||||||||||||||||
3373 | case of incremental parsing). | - | ||||||||||||||||||||||||
3374 | b) Otherwise, set the input character constant for the transition | - | ||||||||||||||||||||||||
3375 | table. | - | ||||||||||||||||||||||||
3376 | ad 7: Get the new state according to the input that was read. | - | ||||||||||||||||||||||||
3377 | ad 8: Do some actions according to the state. The last line in every case | - | ||||||||||||||||||||||||
3378 | statement reads new data (i.e. it move the cursor). This can also be | - | ||||||||||||||||||||||||
3379 | done by calling another parse...() function. If you need processing for | - | ||||||||||||||||||||||||
3380 | this state after that, you have to put it into the switch statement 5. | - | ||||||||||||||||||||||||
3381 | This ensures that you have a well defined re-entry point, when you ran | - | ||||||||||||||||||||||||
3382 | out of data. | - | ||||||||||||||||||||||||
3383 | */ | - | ||||||||||||||||||||||||
3384 | - | |||||||||||||||||||||||||
3385 | /* | - | ||||||||||||||||||||||||
3386 | Parses the prolog [22]. | - | ||||||||||||||||||||||||
3387 | */ | - | ||||||||||||||||||||||||
3388 | - | |||||||||||||||||||||||||
3389 | bool QXmlSimpleReaderPrivate::parseProlog() | - | ||||||||||||||||||||||||
3390 | { | - | ||||||||||||||||||||||||
3391 | const signed char Init = 0; | - | ||||||||||||||||||||||||
3392 | const signed char EatWS = 1; // eat white spaces | - | ||||||||||||||||||||||||
3393 | const signed char Lt = 2; // '<' read | - | ||||||||||||||||||||||||
3394 | const signed char Em = 3; // '!' read | - | ||||||||||||||||||||||||
3395 | const signed char DocType = 4; // read doctype | - | ||||||||||||||||||||||||
3396 | const signed char Comment = 5; // read comment | - | ||||||||||||||||||||||||
3397 | const signed char CommentR = 6; // same as Comment, but already reported | - | ||||||||||||||||||||||||
3398 | const signed char PInstr = 7; // read PI | - | ||||||||||||||||||||||||
3399 | const signed char PInstrR = 8; // same as PInstr, but already reported | - | ||||||||||||||||||||||||
3400 | const signed char Done = 9; | - | ||||||||||||||||||||||||
3401 | - | |||||||||||||||||||||||||
3402 | const signed char InpWs = 0; | - | ||||||||||||||||||||||||
3403 | const signed char InpLt = 1; // < | - | ||||||||||||||||||||||||
3404 | const signed char InpQm = 2; // ? | - | ||||||||||||||||||||||||
3405 | const signed char InpEm = 3; // ! | - | ||||||||||||||||||||||||
3406 | const signed char InpD = 4; // D | - | ||||||||||||||||||||||||
3407 | const signed char InpDash = 5; // - | - | ||||||||||||||||||||||||
3408 | const signed char InpUnknown = 6; | - | ||||||||||||||||||||||||
3409 | - | |||||||||||||||||||||||||
3410 | static const signed char table[9][7] = { | - | ||||||||||||||||||||||||
3411 | /* InpWs InpLt InpQm InpEm InpD InpDash InpUnknown */ | - | ||||||||||||||||||||||||
3412 | { EatWS, Lt, -1, -1, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
3413 | { -1, Lt, -1, -1, -1, -1, -1 }, // EatWS | - | ||||||||||||||||||||||||
3414 | { -1, -1, PInstr,Em, Done, -1, Done }, // Lt | - | ||||||||||||||||||||||||
3415 | { -1, -1, -1, -1, DocType, Comment, -1 }, // Em | - | ||||||||||||||||||||||||
3416 | { EatWS, Lt, -1, -1, -1, -1, -1 }, // DocType | - | ||||||||||||||||||||||||
3417 | { EatWS, Lt, -1, -1, -1, -1, -1 }, // Comment | - | ||||||||||||||||||||||||
3418 | { EatWS, Lt, -1, -1, -1, -1, -1 }, // CommentR | - | ||||||||||||||||||||||||
3419 | { EatWS, Lt, -1, -1, -1, -1, -1 }, // PInstr | - | ||||||||||||||||||||||||
3420 | { EatWS, Lt, -1, -1, -1, -1, -1 } // PInstrR | - | ||||||||||||||||||||||||
3421 | }; | - | ||||||||||||||||||||||||
3422 | signed char state; | - | ||||||||||||||||||||||||
3423 | signed char input; | - | ||||||||||||||||||||||||
3424 | - | |||||||||||||||||||||||||
3425 | if (parseStack == 0 || parseStack->isEmpty()) {
| 616-35431 | ||||||||||||||||||||||||
3426 | xmldecl_possible = true; | - | ||||||||||||||||||||||||
3427 | doctype_read = false; | - | ||||||||||||||||||||||||
3428 | state = Init; | - | ||||||||||||||||||||||||
3429 | } else { executed 2106 times by 6 tests: end of block Executed by:
| 2106 | ||||||||||||||||||||||||
3430 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
3431 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
3432 | qDebug("QXmlSimpleReader: parseProlog (cont) in state %d", state); | - | ||||||||||||||||||||||||
3433 | #endif | - | ||||||||||||||||||||||||
3434 | if (!parseStack->isEmpty()) {
| 1663-32278 | ||||||||||||||||||||||||
3435 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
3436 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 923-31355 | ||||||||||||||||||||||||
3437 | parseStack->pop(); | - | ||||||||||||||||||||||||
3438 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
3439 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
3440 | #endif | - | ||||||||||||||||||||||||
3441 | } executed 923 times by 1 test: end of block Executed by:
| 923 | ||||||||||||||||||||||||
3442 | if (!(this->*function)()) {
| 2353-29925 | ||||||||||||||||||||||||
3443 | parseFailed(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||||||||||||||
3444 | return false; executed 29925 times by 1 test: return false; Executed by:
| 29925 | ||||||||||||||||||||||||
3445 | } | - | ||||||||||||||||||||||||
3446 | } executed 2353 times by 1 test: end of block Executed by:
| 2353 | ||||||||||||||||||||||||
3447 | } executed 4016 times by 1 test: end of block Executed by:
| 4016 | ||||||||||||||||||||||||
3448 | - | |||||||||||||||||||||||||
3449 | for (;;) { | - | ||||||||||||||||||||||||
3450 | switch (state) { | - | ||||||||||||||||||||||||
3451 | case DocType: executed 2370 times by 4 tests: case DocType: Executed by:
| 2370 | ||||||||||||||||||||||||
3452 | if (doctype_read) {
| 0-2370 | ||||||||||||||||||||||||
3453 | reportParseError(QLatin1String(XMLERR_MORETHANONEDOCTYPE)); | - | ||||||||||||||||||||||||
3454 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3455 | } else { | - | ||||||||||||||||||||||||
3456 | doctype_read = false; | - | ||||||||||||||||||||||||
3457 | } executed 2370 times by 4 tests: end of block Executed by:
| 2370 | ||||||||||||||||||||||||
3458 | break; executed 2370 times by 4 tests: break; Executed by:
| 2370 | ||||||||||||||||||||||||
3459 | case Comment: executed 21 times by 2 tests: case Comment: Executed by:
| 21 | ||||||||||||||||||||||||
3460 | if (lexicalHnd) {
| 8-13 | ||||||||||||||||||||||||
3461 | if (!lexicalHnd->comment(string())) {
| 0-13 | ||||||||||||||||||||||||
3462 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
3463 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3464 | } | - | ||||||||||||||||||||||||
3465 | } executed 13 times by 1 test: end of block Executed by:
| 13 | ||||||||||||||||||||||||
3466 | state = CommentR; | - | ||||||||||||||||||||||||
3467 | break; executed 21 times by 2 tests: break; Executed by:
| 21 | ||||||||||||||||||||||||
3468 | case PInstr: executed 134 times by 2 tests: case PInstr: Executed by:
| 134 | ||||||||||||||||||||||||
3469 | // call the handler | - | ||||||||||||||||||||||||
3470 | if (contentHnd) {
| 3-131 | ||||||||||||||||||||||||
3471 | if (xmldecl_possible && !xmlVersion.isEmpty()) {
| 11-120 | ||||||||||||||||||||||||
3472 | QString value(QLatin1String("version='")); | - | ||||||||||||||||||||||||
3473 | value += xmlVersion; | - | ||||||||||||||||||||||||
3474 | value += QLatin1Char('\''); | - | ||||||||||||||||||||||||
3475 | if (!encoding.isEmpty()) {
| 45-63 | ||||||||||||||||||||||||
3476 | value += QLatin1String(" encoding='"); | - | ||||||||||||||||||||||||
3477 | value += encoding; | - | ||||||||||||||||||||||||
3478 | value += QLatin1Char('\''); | - | ||||||||||||||||||||||||
3479 | } executed 63 times by 2 tests: end of block Executed by:
| 63 | ||||||||||||||||||||||||
3480 | if (standalone == QXmlSimpleReaderPrivate::Yes) {
| 21-87 | ||||||||||||||||||||||||
3481 | value += QLatin1String(" standalone='yes'"); | - | ||||||||||||||||||||||||
3482 | } else if (standalone == QXmlSimpleReaderPrivate::No) { executed 21 times by 1 test: end of block Executed by:
| 21-57 | ||||||||||||||||||||||||
3483 | value += QLatin1String(" standalone='no'"); | - | ||||||||||||||||||||||||
3484 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||
3485 | if (!contentHnd->processingInstruction(QLatin1String("xml"), value)) {
| 0-108 | ||||||||||||||||||||||||
3486 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3487 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3488 | } | - | ||||||||||||||||||||||||
3489 | } else { executed 108 times by 2 tests: end of block Executed by:
| 108 | ||||||||||||||||||||||||
3490 | if (!contentHnd->processingInstruction(name(), string())) {
| 0-23 | ||||||||||||||||||||||||
3491 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3492 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3493 | } | - | ||||||||||||||||||||||||
3494 | } executed 23 times by 2 tests: end of block Executed by:
| 23 | ||||||||||||||||||||||||
3495 | } | - | ||||||||||||||||||||||||
3496 | // XML declaration only on first position possible | - | ||||||||||||||||||||||||
3497 | xmldecl_possible = false; | - | ||||||||||||||||||||||||
3498 | state = PInstrR; | - | ||||||||||||||||||||||||
3499 | break; executed 134 times by 2 tests: break; Executed by:
| 134 | ||||||||||||||||||||||||
3500 | case Done: executed 2029 times by 6 tests: case Done: Executed by:
| 2029 | ||||||||||||||||||||||||
3501 | return true; executed 2029 times by 6 tests: return true; Executed by:
| 2029 | ||||||||||||||||||||||||
3502 | case -1: executed 6 times by 1 test: case -1: Executed by:
| 6 | ||||||||||||||||||||||||
3503 | reportParseError(QLatin1String(XMLERR_ERRORPARSINGELEMENT)); | - | ||||||||||||||||||||||||
3504 | return false; executed 6 times by 1 test: return false; Executed by:
| 6 | ||||||||||||||||||||||||
3505 | } | - | ||||||||||||||||||||||||
3506 | - | |||||||||||||||||||||||||
3507 | if (atEnd()) {
| 1664-12160 | ||||||||||||||||||||||||
3508 | unexpectedEof(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||||||||||||||
3509 | return false; executed 1664 times by 1 test: return false; Executed by:
| 1664 | ||||||||||||||||||||||||
3510 | } | - | ||||||||||||||||||||||||
3511 | if (is_S(c)) {
| 1960-10200 | ||||||||||||||||||||||||
3512 | input = InpWs; | - | ||||||||||||||||||||||||
3513 | } else if (c == QLatin1Char('<')) { executed 1960 times by 4 tests: end of block Executed by:
| 1960-6076 | ||||||||||||||||||||||||
3514 | input = InpLt; | - | ||||||||||||||||||||||||
3515 | } else if (c == QLatin1Char('?')) { executed 4124 times by 6 tests: end of block Executed by:
| 147-5929 | ||||||||||||||||||||||||
3516 | input = InpQm; | - | ||||||||||||||||||||||||
3517 | } else if (c == QLatin1Char('!')) { executed 147 times by 2 tests: end of block Executed by:
| 147-3981 | ||||||||||||||||||||||||
3518 | input = InpEm; | - | ||||||||||||||||||||||||
3519 | } else if (c == QLatin1Char('D')) { executed 1948 times by 4 tests: end of block Executed by:
| 1923-2058 | ||||||||||||||||||||||||
3520 | input = InpD; | - | ||||||||||||||||||||||||
3521 | } else if (c == QLatin1Char('-')) { executed 1923 times by 4 tests: end of block Executed by:
| 23-2035 | ||||||||||||||||||||||||
3522 | input = InpDash; | - | ||||||||||||||||||||||||
3523 | } else { executed 23 times by 2 tests: end of block Executed by:
| 23 | ||||||||||||||||||||||||
3524 | input = InpUnknown; | - | ||||||||||||||||||||||||
3525 | } executed 2035 times by 6 tests: end of block Executed by:
| 2035 | ||||||||||||||||||||||||
3526 | state = table[state][input]; | - | ||||||||||||||||||||||||
3527 | - | |||||||||||||||||||||||||
3528 | switch (state) { | - | ||||||||||||||||||||||||
3529 | case EatWS: executed 1960 times by 4 tests: case EatWS: Executed by:
| 1960 | ||||||||||||||||||||||||
3530 | // XML declaration only on first position possible | - | ||||||||||||||||||||||||
3531 | xmldecl_possible = false; | - | ||||||||||||||||||||||||
3532 | if (!eat_ws()) {
| 746-1214 | ||||||||||||||||||||||||
3533 | parseFailed(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||||||||||||||
3534 | return false; executed 746 times by 1 test: return false; Executed by:
| 746 | ||||||||||||||||||||||||
3535 | } | - | ||||||||||||||||||||||||
3536 | break; executed 1214 times by 4 tests: break; Executed by:
| 1214 | ||||||||||||||||||||||||
3537 | case Lt: executed 4124 times by 6 tests: case Lt: Executed by:
| 4124 | ||||||||||||||||||||||||
3538 | next(); | - | ||||||||||||||||||||||||
3539 | break; executed 4124 times by 6 tests: break; Executed by:
| 4124 | ||||||||||||||||||||||||
3540 | case Em: executed 1948 times by 4 tests: case Em: Executed by:
| 1948 | ||||||||||||||||||||||||
3541 | // XML declaration only on first position possible | - | ||||||||||||||||||||||||
3542 | xmldecl_possible = false; | - | ||||||||||||||||||||||||
3543 | next(); | - | ||||||||||||||||||||||||
3544 | break; executed 1948 times by 4 tests: break; Executed by:
| 1948 | ||||||||||||||||||||||||
3545 | case DocType: executed 1923 times by 4 tests: case DocType: Executed by:
| 1923 | ||||||||||||||||||||||||
3546 | if (!parseDoctype()) {
| 378-1545 | ||||||||||||||||||||||||
3547 | parseFailed(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||||||||||||||
3548 | return false; executed 1545 times by 1 test: return false; Executed by:
| 1545 | ||||||||||||||||||||||||
3549 | } | - | ||||||||||||||||||||||||
3550 | break; executed 378 times by 4 tests: break; Executed by:
| 378 | ||||||||||||||||||||||||
3551 | case Comment: executed 23 times by 2 tests: case Comment: Executed by:
| 23 | ||||||||||||||||||||||||
3552 | case CommentR: never executed: case CommentR: | 0 | ||||||||||||||||||||||||
3553 | if (!parseComment()) {
| 11-12 | ||||||||||||||||||||||||
3554 | parseFailed(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||||||||||||||
3555 | return false; executed 11 times by 1 test: return false; Executed by:
| 11 | ||||||||||||||||||||||||
3556 | } | - | ||||||||||||||||||||||||
3557 | break; executed 12 times by 2 tests: break; Executed by:
| 12 | ||||||||||||||||||||||||
3558 | case PInstr: executed 147 times by 2 tests: case PInstr: Executed by:
| 147 | ||||||||||||||||||||||||
3559 | case PInstrR: never executed: case PInstrR: | 0 | ||||||||||||||||||||||||
3560 | parsePI_xmldecl = xmldecl_possible; | - | ||||||||||||||||||||||||
3561 | if (!parsePI()) {
| 26-121 | ||||||||||||||||||||||||
3562 | parseFailed(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||||||||||||||
3563 | return false; executed 121 times by 1 test: return false; Executed by:
| 121 | ||||||||||||||||||||||||
3564 | } | - | ||||||||||||||||||||||||
3565 | break; executed 26 times by 2 tests: break; Executed by:
| 26 | ||||||||||||||||||||||||
3566 | } | - | ||||||||||||||||||||||||
3567 | } executed 9737 times by 6 tests: end of block Executed by:
| 9737 | ||||||||||||||||||||||||
3568 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3569 | } | - | ||||||||||||||||||||||||
3570 | - | |||||||||||||||||||||||||
3571 | /* | - | ||||||||||||||||||||||||
3572 | Parse an element [39]. | - | ||||||||||||||||||||||||
3573 | - | |||||||||||||||||||||||||
3574 | Precondition: the opening '<' is already read. | - | ||||||||||||||||||||||||
3575 | */ | - | ||||||||||||||||||||||||
3576 | bool QXmlSimpleReaderPrivate::parseElement() | - | ||||||||||||||||||||||||
3577 | { | - | ||||||||||||||||||||||||
3578 | const int Init = 0; | - | ||||||||||||||||||||||||
3579 | const int ReadName = 1; | - | ||||||||||||||||||||||||
3580 | const int Ws1 = 2; | - | ||||||||||||||||||||||||
3581 | const int STagEnd = 3; | - | ||||||||||||||||||||||||
3582 | const int STagEnd2 = 4; | - | ||||||||||||||||||||||||
3583 | const int ETagBegin = 5; | - | ||||||||||||||||||||||||
3584 | const int ETagBegin2 = 6; | - | ||||||||||||||||||||||||
3585 | const int Ws2 = 7; | - | ||||||||||||||||||||||||
3586 | const int EmptyTag = 8; | - | ||||||||||||||||||||||||
3587 | const int Attrib = 9; | - | ||||||||||||||||||||||||
3588 | const int AttribPro = 10; // like Attrib, but processAttribute was already called | - | ||||||||||||||||||||||||
3589 | const int Ws3 = 11; | - | ||||||||||||||||||||||||
3590 | const int Done = 12; | - | ||||||||||||||||||||||||
3591 | - | |||||||||||||||||||||||||
3592 | const int InpWs = 0; // whitespace | - | ||||||||||||||||||||||||
3593 | const int InpNameBe = 1; // NameBeginning | - | ||||||||||||||||||||||||
3594 | const int InpGt = 2; // > | - | ||||||||||||||||||||||||
3595 | const int InpSlash = 3; // / | - | ||||||||||||||||||||||||
3596 | const int InpUnknown = 4; | - | ||||||||||||||||||||||||
3597 | - | |||||||||||||||||||||||||
3598 | static const int table[12][5] = { | - | ||||||||||||||||||||||||
3599 | /* InpWs InpNameBe InpGt InpSlash InpUnknown */ | - | ||||||||||||||||||||||||
3600 | { -1, ReadName, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
3601 | { Ws1, Attrib, STagEnd, EmptyTag, -1 }, // ReadName | - | ||||||||||||||||||||||||
3602 | { -1, Attrib, STagEnd, EmptyTag, -1 }, // Ws1 | - | ||||||||||||||||||||||||
3603 | { STagEnd2, STagEnd2, STagEnd2, STagEnd2, STagEnd2 }, // STagEnd | - | ||||||||||||||||||||||||
3604 | { -1, -1, -1, ETagBegin, -1 }, // STagEnd2 | - | ||||||||||||||||||||||||
3605 | { -1, ETagBegin2, -1, -1, -1 }, // ETagBegin | - | ||||||||||||||||||||||||
3606 | { Ws2, -1, Done, -1, -1 }, // ETagBegin2 | - | ||||||||||||||||||||||||
3607 | { -1, -1, Done, -1, -1 }, // Ws2 | - | ||||||||||||||||||||||||
3608 | { -1, -1, Done, -1, -1 }, // EmptyTag | - | ||||||||||||||||||||||||
3609 | { Ws3, Attrib, STagEnd, EmptyTag, -1 }, // Attrib | - | ||||||||||||||||||||||||
3610 | { Ws3, Attrib, STagEnd, EmptyTag, -1 }, // AttribPro | - | ||||||||||||||||||||||||
3611 | { -1, Attrib, STagEnd, EmptyTag, -1 } // Ws3 | - | ||||||||||||||||||||||||
3612 | }; | - | ||||||||||||||||||||||||
3613 | int state; | - | ||||||||||||||||||||||||
3614 | int input; | - | ||||||||||||||||||||||||
3615 | - | |||||||||||||||||||||||||
3616 | if (parseStack == 0 || parseStack->isEmpty()) {
| 1814-11462 | ||||||||||||||||||||||||
3617 | state = Init; | - | ||||||||||||||||||||||||
3618 | } else { executed 5806 times by 6 tests: end of block Executed by:
| 5806 | ||||||||||||||||||||||||
3619 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
3620 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
3621 | qDebug("QXmlSimpleReader: parseElement (cont) in state %d", state); | - | ||||||||||||||||||||||||
3622 | #endif | - | ||||||||||||||||||||||||
3623 | if (!parseStack->isEmpty()) {
| 1223-8425 | ||||||||||||||||||||||||
3624 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
3625 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 136-8289 | ||||||||||||||||||||||||
3626 | parseStack->pop(); | - | ||||||||||||||||||||||||
3627 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
3628 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
3629 | #endif | - | ||||||||||||||||||||||||
3630 | } executed 136 times by 1 test: end of block Executed by:
| 136 | ||||||||||||||||||||||||
3631 | if (!(this->*function)()) {
| 3566-4859 | ||||||||||||||||||||||||
3632 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||||||||||||||
3633 | return false; executed 4859 times by 1 test: return false; Executed by:
| 4859 | ||||||||||||||||||||||||
3634 | } | - | ||||||||||||||||||||||||
3635 | } executed 3566 times by 1 test: end of block Executed by:
| 3566 | ||||||||||||||||||||||||
3636 | } executed 4789 times by 1 test: end of block Executed by:
| 4789 | ||||||||||||||||||||||||
3637 | - | |||||||||||||||||||||||||
3638 | for (;;) { | - | ||||||||||||||||||||||||
3639 | switch (state) { | - | ||||||||||||||||||||||||
3640 | case ReadName: executed 5802 times by 6 tests: case ReadName: Executed by:
| 5802 | ||||||||||||||||||||||||
3641 | // store it on the stack | - | ||||||||||||||||||||||||
3642 | tags.push(name()); | - | ||||||||||||||||||||||||
3643 | // empty the attributes | - | ||||||||||||||||||||||||
3644 | attList.clear(); | - | ||||||||||||||||||||||||
3645 | if (useNamespaces)
| 1021-4781 | ||||||||||||||||||||||||
3646 | namespaceSupport.pushContext(); executed 4781 times by 3 tests: namespaceSupport.pushContext(); Executed by:
| 4781 | ||||||||||||||||||||||||
3647 | break; executed 5802 times by 6 tests: break; Executed by:
| 5802 | ||||||||||||||||||||||||
3648 | case ETagBegin2: executed 5180 times by 6 tests: case ETagBegin2: Executed by:
| 5180 | ||||||||||||||||||||||||
3649 | if (!processElementETagBegin2())
| 4-5176 | ||||||||||||||||||||||||
3650 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
3651 | break; executed 5176 times by 6 tests: break; Executed by:
| 5176 | ||||||||||||||||||||||||
3652 | case Attrib: executed 12894 times by 6 tests: case Attrib: Executed by:
| 12894 | ||||||||||||||||||||||||
3653 | if (!processElementAttribute())
| 0-12894 | ||||||||||||||||||||||||
3654 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3655 | state = AttribPro; | - | ||||||||||||||||||||||||
3656 | break; executed 12894 times by 6 tests: break; Executed by:
| 12894 | ||||||||||||||||||||||||
3657 | case Done: executed 5723 times by 6 tests: case Done: Executed by:
| 5723 | ||||||||||||||||||||||||
3658 | return true; executed 5723 times by 6 tests: return true; Executed by:
| 5723 | ||||||||||||||||||||||||
3659 | case -1: executed 14 times by 1 test: case -1: Executed by:
| 14 | ||||||||||||||||||||||||
3660 | reportParseError(QLatin1String(XMLERR_ERRORPARSINGELEMENT)); | - | ||||||||||||||||||||||||
3661 | return false; executed 14 times by 1 test: return false; Executed by:
| 14 | ||||||||||||||||||||||||
3662 | } | - | ||||||||||||||||||||||||
3663 | - | |||||||||||||||||||||||||
3664 | if (atEnd()) {
| 1225-58942 | ||||||||||||||||||||||||
3665 | unexpectedEof(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||||||||||||||
3666 | return false; executed 1225 times by 1 test: return false; Executed by:
| 1225 | ||||||||||||||||||||||||
3667 | } | - | ||||||||||||||||||||||||
3668 | if (fastDetermineNameChar(c) == NameBeginning) {
| 24149-34793 | ||||||||||||||||||||||||
3669 | input = InpNameBe; | - | ||||||||||||||||||||||||
3670 | } else if (c == QLatin1Char('>')) { executed 24149 times by 6 tests: end of block Executed by:
| 10954-24149 | ||||||||||||||||||||||||
3671 | input = InpGt; | - | ||||||||||||||||||||||||
3672 | } else if (is_S(c)) { executed 10954 times by 6 tests: end of block Executed by:
| 7870-15969 | ||||||||||||||||||||||||
3673 | input = InpWs; | - | ||||||||||||||||||||||||
3674 | } else if (c == QLatin1Char('/')) { executed 15969 times by 6 tests: end of block Executed by:
| 2139-15969 | ||||||||||||||||||||||||
3675 | input = InpSlash; | - | ||||||||||||||||||||||||
3676 | } else { executed 5731 times by 6 tests: end of block Executed by:
| 5731 | ||||||||||||||||||||||||
3677 | input = InpUnknown; | - | ||||||||||||||||||||||||
3678 | } executed 2139 times by 5 tests: end of block Executed by:
| 2139 | ||||||||||||||||||||||||
3679 | state = table[state][input]; | - | ||||||||||||||||||||||||
3680 | - | |||||||||||||||||||||||||
3681 | switch (state) { | - | ||||||||||||||||||||||||
3682 | case ReadName: executed 5802 times by 6 tests: case ReadName: Executed by:
| 5802 | ||||||||||||||||||||||||
3683 | parseName_useRef = false; | - | ||||||||||||||||||||||||
3684 | if (!parseName()) {
| 1145-4657 | ||||||||||||||||||||||||
3685 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||||||||||||||
3686 | return false; executed 1145 times by 1 test: return false; Executed by:
| 1145 | ||||||||||||||||||||||||
3687 | } | - | ||||||||||||||||||||||||
3688 | break; executed 4657 times by 6 tests: break; Executed by:
| 4657 | ||||||||||||||||||||||||
3689 | case Ws1: executed 3442 times by 6 tests: case Ws1: Executed by:
| 3442 | ||||||||||||||||||||||||
3690 | case Ws2: executed 20 times by 1 test: case Ws2: Executed by:
| 20 | ||||||||||||||||||||||||
3691 | case Ws3: executed 9662 times by 6 tests: case Ws3: Executed by:
| 9662 | ||||||||||||||||||||||||
3692 | if (!eat_ws()) {
| 134-12990 | ||||||||||||||||||||||||
3693 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||||||||||||||
3694 | return false; executed 134 times by 1 test: return false; Executed by:
| 134 | ||||||||||||||||||||||||
3695 | } | - | ||||||||||||||||||||||||
3696 | break; executed 12990 times by 6 tests: break; Executed by:
| 12990 | ||||||||||||||||||||||||
3697 | case STagEnd: executed 5230 times by 6 tests: case STagEnd: Executed by:
| 5230 | ||||||||||||||||||||||||
3698 | // call the handler | - | ||||||||||||||||||||||||
3699 | if (contentHnd) {
| 4-5226 | ||||||||||||||||||||||||
3700 | const QString &tagsTop = tags.top(); | - | ||||||||||||||||||||||||
3701 | if (useNamespaces) {
| 697-4529 | ||||||||||||||||||||||||
3702 | QString uri, lname; | - | ||||||||||||||||||||||||
3703 | namespaceSupport.processName(tagsTop, false, uri, lname); | - | ||||||||||||||||||||||||
3704 | if (!contentHnd->startElement(uri, lname, tagsTop, attList)) {
| 0-4529 | ||||||||||||||||||||||||
3705 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3706 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3707 | } | - | ||||||||||||||||||||||||
3708 | } else { executed 4529 times by 2 tests: end of block Executed by:
| 4529 | ||||||||||||||||||||||||
3709 | if (!contentHnd->startElement(QString(), QString(), tagsTop, attList)) {
| 0-697 | ||||||||||||||||||||||||
3710 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3711 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3712 | } | - | ||||||||||||||||||||||||
3713 | } executed 697 times by 4 tests: end of block Executed by:
| 697 | ||||||||||||||||||||||||
3714 | } | - | ||||||||||||||||||||||||
3715 | next(); | - | ||||||||||||||||||||||||
3716 | break; executed 5230 times by 6 tests: break; Executed by:
| 5230 | ||||||||||||||||||||||||
3717 | case STagEnd2: executed 5228 times by 6 tests: case STagEnd2: Executed by:
| 5228 | ||||||||||||||||||||||||
3718 | if (!parseContent()) {
| 921-4307 | ||||||||||||||||||||||||
3719 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||||||||||||||
3720 | return false; executed 921 times by 1 test: return false; Executed by:
| 921 | ||||||||||||||||||||||||
3721 | } | - | ||||||||||||||||||||||||
3722 | break; executed 4307 times by 6 tests: break; Executed by:
| 4307 | ||||||||||||||||||||||||
3723 | case ETagBegin: executed 5181 times by 6 tests: case ETagBegin: Executed by:
| 5181 | ||||||||||||||||||||||||
3724 | next(); | - | ||||||||||||||||||||||||
3725 | break; executed 5181 times by 6 tests: break; Executed by:
| 5181 | ||||||||||||||||||||||||
3726 | case ETagBegin2: executed 5180 times by 6 tests: case ETagBegin2: Executed by:
| 5180 | ||||||||||||||||||||||||
3727 | // get the name of the tag | - | ||||||||||||||||||||||||
3728 | parseName_useRef = false; | - | ||||||||||||||||||||||||
3729 | if (!parseName()) {
| 1072-4108 | ||||||||||||||||||||||||
3730 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||||||||||||||
3731 | return false; executed 1072 times by 1 test: return false; Executed by:
| 1072 | ||||||||||||||||||||||||
3732 | } | - | ||||||||||||||||||||||||
3733 | break; executed 4108 times by 6 tests: break; Executed by:
| 4108 | ||||||||||||||||||||||||
3734 | case EmptyTag: executed 550 times by 5 tests: case EmptyTag: Executed by:
| 550 | ||||||||||||||||||||||||
3735 | if (tags.isEmpty()) {
| 0-550 | ||||||||||||||||||||||||
3736 | reportParseError(QLatin1String(XMLERR_TAGMISMATCH)); | - | ||||||||||||||||||||||||
3737 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3738 | } | - | ||||||||||||||||||||||||
3739 | if (!processElementEmptyTag())
| 0-550 | ||||||||||||||||||||||||
3740 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3741 | next(); | - | ||||||||||||||||||||||||
3742 | break; executed 550 times by 5 tests: break; Executed by:
| 550 | ||||||||||||||||||||||||
3743 | case Attrib: executed 12910 times by 6 tests: case Attrib: Executed by:
| 12910 | ||||||||||||||||||||||||
3744 | case AttribPro: never executed: case AttribPro: | 0 | ||||||||||||||||||||||||
3745 | // get name and value of attribute | - | ||||||||||||||||||||||||
3746 | if (!parseAttribute()) {
| 357-12553 | ||||||||||||||||||||||||
3747 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||||||||||||||
3748 | return false; executed 357 times by 1 test: return false; Executed by:
| 357 | ||||||||||||||||||||||||
3749 | } | - | ||||||||||||||||||||||||
3750 | break; executed 12553 times by 6 tests: break; Executed by:
| 12553 | ||||||||||||||||||||||||
3751 | case Done: executed 5723 times by 6 tests: case Done: Executed by:
| 5723 | ||||||||||||||||||||||||
3752 | next(); | - | ||||||||||||||||||||||||
3753 | break; executed 5723 times by 6 tests: break; Executed by:
| 5723 | ||||||||||||||||||||||||
3754 | } | - | ||||||||||||||||||||||||
3755 | } executed 55313 times by 6 tests: end of block Executed by:
| 55313 | ||||||||||||||||||||||||
3756 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3757 | } | - | ||||||||||||||||||||||||
3758 | - | |||||||||||||||||||||||||
3759 | /* | - | ||||||||||||||||||||||||
3760 | Helper to break down the size of the code in the case statement. | - | ||||||||||||||||||||||||
3761 | Return false on error, otherwise true. | - | ||||||||||||||||||||||||
3762 | */ | - | ||||||||||||||||||||||||
3763 | bool QXmlSimpleReaderPrivate::processElementEmptyTag() | - | ||||||||||||||||||||||||
3764 | { | - | ||||||||||||||||||||||||
3765 | QString uri, lname; | - | ||||||||||||||||||||||||
3766 | // pop the stack and call the handler | - | ||||||||||||||||||||||||
3767 | if (contentHnd) {
| 9-541 | ||||||||||||||||||||||||
3768 | if (useNamespaces) {
| 217-324 | ||||||||||||||||||||||||
3769 | // report startElement first... | - | ||||||||||||||||||||||||
3770 | namespaceSupport.processName(tags.top(), false, uri, lname); | - | ||||||||||||||||||||||||
3771 | if (!contentHnd->startElement(uri, lname, tags.top(), attList)) {
| 0-217 | ||||||||||||||||||||||||
3772 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3773 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3774 | } | - | ||||||||||||||||||||||||
3775 | // ... followed by endElement... | - | ||||||||||||||||||||||||
3776 | if (!contentHnd->endElement(uri, lname, tags.pop())) {
| 0-217 | ||||||||||||||||||||||||
3777 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3778 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3779 | } | - | ||||||||||||||||||||||||
3780 | // ... followed by endPrefixMapping | - | ||||||||||||||||||||||||
3781 | QStringList prefixesBefore, prefixesAfter; | - | ||||||||||||||||||||||||
3782 | if (contentHnd) {
| 0-217 | ||||||||||||||||||||||||
3783 | prefixesBefore = namespaceSupport.prefixes(); | - | ||||||||||||||||||||||||
3784 | } executed 217 times by 2 tests: end of block Executed by:
| 217 | ||||||||||||||||||||||||
3785 | namespaceSupport.popContext(); | - | ||||||||||||||||||||||||
3786 | // call the handler for prefix mapping | - | ||||||||||||||||||||||||
3787 | prefixesAfter = namespaceSupport.prefixes(); | - | ||||||||||||||||||||||||
3788 | for (QStringList::Iterator it = prefixesBefore.begin(); it != prefixesBefore.end(); ++it) {
| 217-221 | ||||||||||||||||||||||||
3789 | if (!prefixesAfter.contains(*it)) {
| 4-217 | ||||||||||||||||||||||||
3790 | if (!contentHnd->endPrefixMapping(*it)) {
| 0-4 | ||||||||||||||||||||||||
3791 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3792 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3793 | } | - | ||||||||||||||||||||||||
3794 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3795 | } executed 221 times by 2 tests: end of block Executed by:
| 221 | ||||||||||||||||||||||||
3796 | } else { executed 217 times by 2 tests: end of block Executed by:
| 217 | ||||||||||||||||||||||||
3797 | // report startElement first... | - | ||||||||||||||||||||||||
3798 | if (!contentHnd->startElement(QString(), QString(), tags.top(), attList)) {
| 0-324 | ||||||||||||||||||||||||
3799 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3800 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3801 | } | - | ||||||||||||||||||||||||
3802 | // ... followed by endElement | - | ||||||||||||||||||||||||
3803 | if (!contentHnd->endElement(QString(), QString(), tags.pop())) {
| 0-324 | ||||||||||||||||||||||||
3804 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3805 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3806 | } | - | ||||||||||||||||||||||||
3807 | } executed 324 times by 4 tests: end of block Executed by:
| 324 | ||||||||||||||||||||||||
3808 | } else { | - | ||||||||||||||||||||||||
3809 | tags.pop_back(); | - | ||||||||||||||||||||||||
3810 | namespaceSupport.popContext(); | - | ||||||||||||||||||||||||
3811 | } executed 9 times by 2 tests: end of block Executed by:
| 9 | ||||||||||||||||||||||||
3812 | return true; executed 550 times by 5 tests: return true; Executed by:
| 550 | ||||||||||||||||||||||||
3813 | } | - | ||||||||||||||||||||||||
3814 | /* | - | ||||||||||||||||||||||||
3815 | Helper to break down the size of the code in the case statement. | - | ||||||||||||||||||||||||
3816 | Return false on error, otherwise true. | - | ||||||||||||||||||||||||
3817 | */ | - | ||||||||||||||||||||||||
3818 | bool QXmlSimpleReaderPrivate::processElementETagBegin2() | - | ||||||||||||||||||||||||
3819 | { | - | ||||||||||||||||||||||||
3820 | const QString &name = QXmlSimpleReaderPrivate::name(); | - | ||||||||||||||||||||||||
3821 | - | |||||||||||||||||||||||||
3822 | // pop the stack and compare it with the name | - | ||||||||||||||||||||||||
3823 | if (tags.pop() != name) {
| 4-5176 | ||||||||||||||||||||||||
3824 | reportParseError(QLatin1String(XMLERR_TAGMISMATCH)); | - | ||||||||||||||||||||||||
3825 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
3826 | } | - | ||||||||||||||||||||||||
3827 | // call the handler | - | ||||||||||||||||||||||||
3828 | if (contentHnd) {
| 0-5176 | ||||||||||||||||||||||||
3829 | QString uri, lname; | - | ||||||||||||||||||||||||
3830 | - | |||||||||||||||||||||||||
3831 | if (useNamespaces)
| 697-4479 | ||||||||||||||||||||||||
3832 | namespaceSupport.processName(name, false, uri, lname); executed 4479 times by 2 tests: namespaceSupport.processName(name, false, uri, lname); Executed by:
| 4479 | ||||||||||||||||||||||||
3833 | if (!contentHnd->endElement(uri, lname, name)) {
| 0-5176 | ||||||||||||||||||||||||
3834 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3835 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3836 | } | - | ||||||||||||||||||||||||
3837 | } executed 5176 times by 6 tests: end of block Executed by:
| 5176 | ||||||||||||||||||||||||
3838 | if (useNamespaces) {
| 697-4479 | ||||||||||||||||||||||||
3839 | NamespaceMap prefixesBefore, prefixesAfter; | - | ||||||||||||||||||||||||
3840 | if (contentHnd)
| 0-4479 | ||||||||||||||||||||||||
3841 | prefixesBefore = namespaceSupport.d->ns; executed 4479 times by 2 tests: prefixesBefore = namespaceSupport.d->ns; Executed by:
| 4479 | ||||||||||||||||||||||||
3842 | - | |||||||||||||||||||||||||
3843 | namespaceSupport.popContext(); | - | ||||||||||||||||||||||||
3844 | // call the handler for prefix mapping | - | ||||||||||||||||||||||||
3845 | if (contentHnd) {
| 0-4479 | ||||||||||||||||||||||||
3846 | prefixesAfter = namespaceSupport.d->ns; | - | ||||||||||||||||||||||||
3847 | if (prefixesBefore.size() != prefixesAfter.size()) {
| 10-4469 | ||||||||||||||||||||||||
3848 | for (NamespaceMap::const_iterator it = prefixesBefore.constBegin(); it != prefixesBefore.constEnd(); ++it) {
| 10-20 | ||||||||||||||||||||||||
3849 | if (!it.key().isEmpty() && !prefixesAfter.contains(it.key())) {
| 0-10 | ||||||||||||||||||||||||
3850 | if (!contentHnd->endPrefixMapping(it.key())) {
| 0 | ||||||||||||||||||||||||
3851 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3852 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3853 | } | - | ||||||||||||||||||||||||
3854 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3855 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
3856 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
3857 | } executed 4479 times by 2 tests: end of block Executed by:
| 4479 | ||||||||||||||||||||||||
3858 | } executed 4479 times by 2 tests: end of block Executed by:
| 4479 | ||||||||||||||||||||||||
3859 | return true; executed 5176 times by 6 tests: return true; Executed by:
| 5176 | ||||||||||||||||||||||||
3860 | } | - | ||||||||||||||||||||||||
3861 | /* | - | ||||||||||||||||||||||||
3862 | Helper to break down the size of the code in the case statement. | - | ||||||||||||||||||||||||
3863 | Return false on error, otherwise true. | - | ||||||||||||||||||||||||
3864 | */ | - | ||||||||||||||||||||||||
3865 | bool QXmlSimpleReaderPrivate::processElementAttribute() | - | ||||||||||||||||||||||||
3866 | { | - | ||||||||||||||||||||||||
3867 | QString uri, lname, prefix; | - | ||||||||||||||||||||||||
3868 | const QString &name = QXmlSimpleReaderPrivate::name(); | - | ||||||||||||||||||||||||
3869 | const QString &string = QXmlSimpleReaderPrivate::string(); | - | ||||||||||||||||||||||||
3870 | - | |||||||||||||||||||||||||
3871 | // add the attribute to the list | - | ||||||||||||||||||||||||
3872 | if (useNamespaces) {
| 866-12028 | ||||||||||||||||||||||||
3873 | // is it a namespace declaration? | - | ||||||||||||||||||||||||
3874 | namespaceSupport.splitName(name, prefix, lname); | - | ||||||||||||||||||||||||
3875 | if (prefix == QLatin1String("xmlns")) {
| 7-12021 | ||||||||||||||||||||||||
3876 | // namespace declaration | - | ||||||||||||||||||||||||
3877 | namespaceSupport.setPrefix(lname, string); | - | ||||||||||||||||||||||||
3878 | if (useNamespacePrefixes) {
| 0-7 | ||||||||||||||||||||||||
3879 | // according to http://www.w3.org/2000/xmlns/, the "prefix" | - | ||||||||||||||||||||||||
3880 | // xmlns maps to the namespace name | - | ||||||||||||||||||||||||
3881 | // http://www.w3.org/2000/xmlns/ | - | ||||||||||||||||||||||||
3882 | attList.append(name, QLatin1String("http://www.w3.org/2000/xmlns/"), lname, string); | - | ||||||||||||||||||||||||
3883 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3884 | // call the handler for prefix mapping | - | ||||||||||||||||||||||||
3885 | if (contentHnd) {
| 2-5 | ||||||||||||||||||||||||
3886 | if (!contentHnd->startPrefixMapping(lname, string)) {
| 0-5 | ||||||||||||||||||||||||
3887 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
3888 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3889 | } | - | ||||||||||||||||||||||||
3890 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||
3891 | } else { executed 7 times by 1 test: end of block Executed by:
| 7 | ||||||||||||||||||||||||
3892 | // no namespace delcaration | - | ||||||||||||||||||||||||
3893 | namespaceSupport.processName(name, true, uri, lname); | - | ||||||||||||||||||||||||
3894 | attList.append(name, uri, lname, string); | - | ||||||||||||||||||||||||
3895 | } executed 12021 times by 3 tests: end of block Executed by:
| 12021 | ||||||||||||||||||||||||
3896 | } else { | - | ||||||||||||||||||||||||
3897 | // no namespace support | - | ||||||||||||||||||||||||
3898 | attList.append(name, uri, lname, string); | - | ||||||||||||||||||||||||
3899 | } executed 866 times by 3 tests: end of block Executed by:
| 866 | ||||||||||||||||||||||||
3900 | return true; executed 12894 times by 6 tests: return true; Executed by:
| 12894 | ||||||||||||||||||||||||
3901 | } | - | ||||||||||||||||||||||||
3902 | - | |||||||||||||||||||||||||
3903 | /* | - | ||||||||||||||||||||||||
3904 | Parse a content [43]. | - | ||||||||||||||||||||||||
3905 | - | |||||||||||||||||||||||||
3906 | A content is only used between tags. If a end tag is found the < is already | - | ||||||||||||||||||||||||
3907 | read and the head stand on the '/' of the end tag '</name>'. | - | ||||||||||||||||||||||||
3908 | */ | - | ||||||||||||||||||||||||
3909 | bool QXmlSimpleReaderPrivate::parseContent() | - | ||||||||||||||||||||||||
3910 | { | - | ||||||||||||||||||||||||
3911 | const signed char Init = 0; | - | ||||||||||||||||||||||||
3912 | const signed char ChD = 1; // CharData | - | ||||||||||||||||||||||||
3913 | const signed char ChD1 = 2; // CharData help state | - | ||||||||||||||||||||||||
3914 | const signed char ChD2 = 3; // CharData help state | - | ||||||||||||||||||||||||
3915 | const signed char Ref = 4; // Reference | - | ||||||||||||||||||||||||
3916 | const signed char Lt = 5; // '<' read | - | ||||||||||||||||||||||||
3917 | const signed char PInstr = 6; // PI | - | ||||||||||||||||||||||||
3918 | const signed char PInstrR = 7; // same as PInstr, but already reported | - | ||||||||||||||||||||||||
3919 | const signed char Elem = 8; // Element | - | ||||||||||||||||||||||||
3920 | const signed char Em = 9; // '!' read | - | ||||||||||||||||||||||||
3921 | const signed char Com = 10; // Comment | - | ||||||||||||||||||||||||
3922 | const signed char ComR = 11; // same as Com, but already reported | - | ||||||||||||||||||||||||
3923 | const signed char CDS = 12; // CDSect | - | ||||||||||||||||||||||||
3924 | const signed char CDS1 = 13; // read a CDSect | - | ||||||||||||||||||||||||
3925 | const signed char CDS2 = 14; // read a CDSect (help state) | - | ||||||||||||||||||||||||
3926 | const signed char CDS3 = 15; // read a CDSect (help state) | - | ||||||||||||||||||||||||
3927 | const signed char Done = 16; // finished reading content | - | ||||||||||||||||||||||||
3928 | - | |||||||||||||||||||||||||
3929 | const signed char InpLt = 0; // < | - | ||||||||||||||||||||||||
3930 | const signed char InpGt = 1; // > | - | ||||||||||||||||||||||||
3931 | const signed char InpSlash = 2; // / | - | ||||||||||||||||||||||||
3932 | const signed char InpQMark = 3; // ? | - | ||||||||||||||||||||||||
3933 | const signed char InpEMark = 4; // ! | - | ||||||||||||||||||||||||
3934 | const signed char InpAmp = 5; // & | - | ||||||||||||||||||||||||
3935 | const signed char InpDash = 6; // - | - | ||||||||||||||||||||||||
3936 | const signed char InpOpenB = 7; // [ | - | ||||||||||||||||||||||||
3937 | const signed char InpCloseB = 8; //] | - | ||||||||||||||||||||||||
3938 | const signed char InpUnknown = 9; | - | ||||||||||||||||||||||||
3939 | - | |||||||||||||||||||||||||
3940 | static const signed char mapCLT2FSMChar[] = { | - | ||||||||||||||||||||||||
3941 | InpUnknown, // white space | - | ||||||||||||||||||||||||
3942 | InpUnknown, // % | - | ||||||||||||||||||||||||
3943 | InpAmp, // & | - | ||||||||||||||||||||||||
3944 | InpGt, // > | - | ||||||||||||||||||||||||
3945 | InpLt, // < | - | ||||||||||||||||||||||||
3946 | InpSlash, // / | - | ||||||||||||||||||||||||
3947 | InpQMark, // ? | - | ||||||||||||||||||||||||
3948 | InpEMark, // ! | - | ||||||||||||||||||||||||
3949 | InpDash, // - | - | ||||||||||||||||||||||||
3950 | InpCloseB, //] | - | ||||||||||||||||||||||||
3951 | InpOpenB, // [ | - | ||||||||||||||||||||||||
3952 | InpUnknown, // = | - | ||||||||||||||||||||||||
3953 | InpUnknown, // " | - | ||||||||||||||||||||||||
3954 | InpUnknown, // ' | - | ||||||||||||||||||||||||
3955 | InpUnknown // unknown | - | ||||||||||||||||||||||||
3956 | }; | - | ||||||||||||||||||||||||
3957 | - | |||||||||||||||||||||||||
3958 | static const signed char table[16][10] = { | - | ||||||||||||||||||||||||
3959 | /* InpLt InpGt InpSlash InpQMark InpEMark InpAmp InpDash InpOpenB InpCloseB InpUnknown */ | - | ||||||||||||||||||||||||
3960 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD1, ChD }, // Init | - | ||||||||||||||||||||||||
3961 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD1, ChD }, // ChD | - | ||||||||||||||||||||||||
3962 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD2, ChD }, // ChD1 | - | ||||||||||||||||||||||||
3963 | { Lt, -1, ChD, ChD, ChD, Ref, ChD, ChD, ChD2, ChD }, // ChD2 | - | ||||||||||||||||||||||||
3964 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // Ref (same as Init) | - | ||||||||||||||||||||||||
3965 | { -1, -1, Done, PInstr, Em, -1, -1, -1, -1, Elem }, // Lt | - | ||||||||||||||||||||||||
3966 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // PInstr (same as Init) | - | ||||||||||||||||||||||||
3967 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // PInstrR | - | ||||||||||||||||||||||||
3968 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // Elem (same as Init) | - | ||||||||||||||||||||||||
3969 | { -1, -1, -1, -1, -1, -1, Com, CDS, -1, -1 }, // Em | - | ||||||||||||||||||||||||
3970 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // Com (same as Init) | - | ||||||||||||||||||||||||
3971 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // ComR | - | ||||||||||||||||||||||||
3972 | { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS2, CDS1 }, // CDS | - | ||||||||||||||||||||||||
3973 | { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS2, CDS1 }, // CDS1 | - | ||||||||||||||||||||||||
3974 | { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS3, CDS1 }, // CDS2 | - | ||||||||||||||||||||||||
3975 | { CDS1, Init, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS3, CDS1 } // CDS3 | - | ||||||||||||||||||||||||
3976 | }; | - | ||||||||||||||||||||||||
3977 | signed char state; | - | ||||||||||||||||||||||||
3978 | signed char input; | - | ||||||||||||||||||||||||
3979 | - | |||||||||||||||||||||||||
3980 | if (parseStack == 0 || parseStack->isEmpty()) {
| 1634-5718 | ||||||||||||||||||||||||
3981 | contentCharDataRead = false; | - | ||||||||||||||||||||||||
3982 | state = Init; | - | ||||||||||||||||||||||||
3983 | } else { executed 5228 times by 6 tests: end of block Executed by:
| 5228 | ||||||||||||||||||||||||
3984 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
3985 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
3986 | qDebug("QXmlSimpleReader: parseContent (cont) in state %d", state); | - | ||||||||||||||||||||||||
3987 | #endif | - | ||||||||||||||||||||||||
3988 | if (!parseStack->isEmpty()) {
| 1446-2638 | ||||||||||||||||||||||||
3989 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
3990 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 0-2638 | ||||||||||||||||||||||||
3991 | parseStack->pop(); | - | ||||||||||||||||||||||||
3992 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
3993 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
3994 | #endif | - | ||||||||||||||||||||||||
3995 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3996 | if (!(this->*function)()) {
| 825-1813 | ||||||||||||||||||||||||
3997 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||||||||||||||
3998 | return false; executed 1813 times by 1 test: return false; Executed by:
| 1813 | ||||||||||||||||||||||||
3999 | } | - | ||||||||||||||||||||||||
4000 | } executed 825 times by 1 test: end of block Executed by:
| 825 | ||||||||||||||||||||||||
4001 | } executed 2271 times by 1 test: end of block Executed by:
| 2271 | ||||||||||||||||||||||||
4002 | - | |||||||||||||||||||||||||
4003 | for (;;) { | - | ||||||||||||||||||||||||
4004 | switch (state) { | - | ||||||||||||||||||||||||
4005 | case Ref: executed 1137 times by 3 tests: case Ref: Executed by:
| 1137 | ||||||||||||||||||||||||
4006 | if (!contentCharDataRead)
| 372-765 | ||||||||||||||||||||||||
4007 | contentCharDataRead = parseReference_charDataRead; executed 765 times by 3 tests: contentCharDataRead = parseReference_charDataRead; Executed by:
| 765 | ||||||||||||||||||||||||
4008 | break; executed 1137 times by 3 tests: break; Executed by:
| 1137 | ||||||||||||||||||||||||
4009 | case PInstr: executed 31 times by 1 test: case PInstr: Executed by:
| 31 | ||||||||||||||||||||||||
4010 | if (contentHnd) {
| 0-31 | ||||||||||||||||||||||||
4011 | if (!contentHnd->processingInstruction(name(),string())) {
| 0-31 | ||||||||||||||||||||||||
4012 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
4013 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4014 | } | - | ||||||||||||||||||||||||
4015 | } executed 31 times by 1 test: end of block Executed by:
| 31 | ||||||||||||||||||||||||
4016 | state = PInstrR; | - | ||||||||||||||||||||||||
4017 | break; executed 31 times by 1 test: break; Executed by:
| 31 | ||||||||||||||||||||||||
4018 | case Com: executed 98 times by 2 tests: case Com: Executed by:
| 98 | ||||||||||||||||||||||||
4019 | if (lexicalHnd) {
| 42-56 | ||||||||||||||||||||||||
4020 | if (!lexicalHnd->comment(string())) {
| 0-42 | ||||||||||||||||||||||||
4021 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
4022 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4023 | } | - | ||||||||||||||||||||||||
4024 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||||||||||||||
4025 | state = ComR; | - | ||||||||||||||||||||||||
4026 | break; executed 98 times by 2 tests: break; Executed by:
| 98 | ||||||||||||||||||||||||
4027 | case CDS: executed 59 times by 1 test: case CDS: Executed by:
| 59 | ||||||||||||||||||||||||
4028 | stringClear(); | - | ||||||||||||||||||||||||
4029 | break; executed 59 times by 1 test: break; Executed by:
| 59 | ||||||||||||||||||||||||
4030 | case CDS2: executed 80 times by 1 test: case CDS2: Executed by:
| 80 | ||||||||||||||||||||||||
4031 | if (!atEnd() && c != QLatin1Char(']'))
| 10-63 | ||||||||||||||||||||||||
4032 | stringAddC(QLatin1Char(']')); executed 10 times by 1 test: stringAddC(QLatin1Char(']')); Executed by:
| 10 | ||||||||||||||||||||||||
4033 | break; executed 80 times by 1 test: break; Executed by:
| 80 | ||||||||||||||||||||||||
4034 | case CDS3: executed 75 times by 1 test: case CDS3: Executed by:
| 75 | ||||||||||||||||||||||||
4035 | // test if this skipping was legal | - | ||||||||||||||||||||||||
4036 | if (!atEnd()) {
| 11-64 | ||||||||||||||||||||||||
4037 | if (c == QLatin1Char('>')) {
| 11-53 | ||||||||||||||||||||||||
4038 | // the end of the CDSect | - | ||||||||||||||||||||||||
4039 | if (lexicalHnd) {
| 0-53 | ||||||||||||||||||||||||
4040 | if (!lexicalHnd->startCDATA()) {
| 0-53 | ||||||||||||||||||||||||
4041 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
4042 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4043 | } | - | ||||||||||||||||||||||||
4044 | } executed 53 times by 1 test: end of block Executed by:
| 53 | ||||||||||||||||||||||||
4045 | if (contentHnd) {
| 0-53 | ||||||||||||||||||||||||
4046 | if (!contentHnd->characters(string())) {
| 0-53 | ||||||||||||||||||||||||
4047 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
4048 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4049 | } | - | ||||||||||||||||||||||||
4050 | } executed 53 times by 1 test: end of block Executed by:
| 53 | ||||||||||||||||||||||||
4051 | if (lexicalHnd) {
| 0-53 | ||||||||||||||||||||||||
4052 | if (!lexicalHnd->endCDATA()) {
| 0-53 | ||||||||||||||||||||||||
4053 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
4054 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4055 | } | - | ||||||||||||||||||||||||
4056 | } executed 53 times by 1 test: end of block Executed by:
| 53 | ||||||||||||||||||||||||
4057 | } else if (c == QLatin1Char(']')) { executed 53 times by 1 test: end of block Executed by:
| 0-53 | ||||||||||||||||||||||||
4058 | // three or more ']' | - | ||||||||||||||||||||||||
4059 | stringAddC(QLatin1Char(']')); | - | ||||||||||||||||||||||||
4060 | } else { executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||||||||
4061 | // after ']]' comes another character | - | ||||||||||||||||||||||||
4062 | stringAddC(QLatin1Char(']')); | - | ||||||||||||||||||||||||
4063 | stringAddC(QLatin1Char(']')); | - | ||||||||||||||||||||||||
4064 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4065 | } | - | ||||||||||||||||||||||||
4066 | break; executed 75 times by 1 test: break; Executed by:
| 75 | ||||||||||||||||||||||||
4067 | case Done: executed 5181 times by 6 tests: case Done: Executed by:
| 5181 | ||||||||||||||||||||||||
4068 | // call the handler for CharData | - | ||||||||||||||||||||||||
4069 | if (contentHnd) {
| 0-5181 | ||||||||||||||||||||||||
4070 | if (contentCharDataRead) {
| 0-5181 | ||||||||||||||||||||||||
4071 | if (reportWhitespaceCharData || !string().simplified().isEmpty()) {
| 0 | ||||||||||||||||||||||||
4072 | if (!contentHnd->characters(string())) {
| 0 | ||||||||||||||||||||||||
4073 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
4074 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4075 | } | - | ||||||||||||||||||||||||
4076 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4077 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4078 | } executed 5181 times by 6 tests: end of block Executed by:
| 5181 | ||||||||||||||||||||||||
4079 | // Done | - | ||||||||||||||||||||||||
4080 | return true; executed 5181 times by 6 tests: return true; Executed by:
| 5181 | ||||||||||||||||||||||||
4081 | case -1: executed 3 times by 1 test: case -1: Executed by:
| 3 | ||||||||||||||||||||||||
4082 | // Error | - | ||||||||||||||||||||||||
4083 | reportParseError(QLatin1String(XMLERR_ERRORPARSINGCONTENT)); | - | ||||||||||||||||||||||||
4084 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
4085 | } | - | ||||||||||||||||||||||||
4086 | - | |||||||||||||||||||||||||
4087 | // get input (use lookup-table instead of nested ifs for performance | - | ||||||||||||||||||||||||
4088 | // reasons) | - | ||||||||||||||||||||||||
4089 | if (atEnd()) {
| 1453-261643 | ||||||||||||||||||||||||
4090 | unexpectedEof(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||||||||||||||
4091 | return false; executed 1453 times by 1 test: return false; Executed by:
| 1453 | ||||||||||||||||||||||||
4092 | } | - | ||||||||||||||||||||||||
4093 | if (c.row()) {
| 877-260766 | ||||||||||||||||||||||||
4094 | input = InpUnknown; | - | ||||||||||||||||||||||||
4095 | } else { executed 877 times by 1 test: end of block Executed by:
| 877 | ||||||||||||||||||||||||
4096 | input = mapCLT2FSMChar[charLookupTable[c.cell()]]; | - | ||||||||||||||||||||||||
4097 | } executed 260766 times by 6 tests: end of block Executed by:
| 260766 | ||||||||||||||||||||||||
4098 | state = table[state][input]; | - | ||||||||||||||||||||||||
4099 | - | |||||||||||||||||||||||||
4100 | switch (state) { | - | ||||||||||||||||||||||||
4101 | case Init: executed 53 times by 1 test: case Init: Executed by:
| 53 | ||||||||||||||||||||||||
4102 | // skip the ending '>' of a CDATASection | - | ||||||||||||||||||||||||
4103 | next(); | - | ||||||||||||||||||||||||
4104 | break; executed 53 times by 1 test: break; Executed by:
| 53 | ||||||||||||||||||||||||
4105 | case ChD: executed 241738 times by 6 tests: case ChD: Executed by:
| 241738 | ||||||||||||||||||||||||
4106 | // on first call: clear string | - | ||||||||||||||||||||||||
4107 | if (!contentCharDataRead) {
| 6401-235337 | ||||||||||||||||||||||||
4108 | contentCharDataRead = true; | - | ||||||||||||||||||||||||
4109 | stringClear(); | - | ||||||||||||||||||||||||
4110 | } executed 6401 times by 6 tests: end of block Executed by:
| 6401 | ||||||||||||||||||||||||
4111 | stringAddC(); | - | ||||||||||||||||||||||||
4112 | if (reportEntities) {
| 0-241738 | ||||||||||||||||||||||||
4113 | if (!reportEndEntities())
| 0 | ||||||||||||||||||||||||
4114 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4115 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4116 | next(); | - | ||||||||||||||||||||||||
4117 | break; executed 241738 times by 6 tests: break; Executed by:
| 241738 | ||||||||||||||||||||||||
4118 | case ChD1: executed 43 times by 2 tests: case ChD1: Executed by:
| 43 | ||||||||||||||||||||||||
4119 | // on first call: clear string | - | ||||||||||||||||||||||||
4120 | if (!contentCharDataRead) {
| 12-31 | ||||||||||||||||||||||||
4121 | contentCharDataRead = true; | - | ||||||||||||||||||||||||
4122 | stringClear(); | - | ||||||||||||||||||||||||
4123 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
4124 | stringAddC(); | - | ||||||||||||||||||||||||
4125 | if (reportEntities) {
| 0-43 | ||||||||||||||||||||||||
4126 | if (!reportEndEntities())
| 0 | ||||||||||||||||||||||||
4127 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4128 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4129 | next(); | - | ||||||||||||||||||||||||
4130 | break; executed 43 times by 2 tests: break; Executed by:
| 43 | ||||||||||||||||||||||||
4131 | case ChD2: executed 16 times by 2 tests: case ChD2: Executed by:
| 16 | ||||||||||||||||||||||||
4132 | stringAddC(); | - | ||||||||||||||||||||||||
4133 | if (reportEntities) {
| 0-16 | ||||||||||||||||||||||||
4134 | if (!reportEndEntities())
| 0 | ||||||||||||||||||||||||
4135 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4136 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4137 | next(); | - | ||||||||||||||||||||||||
4138 | break; executed 16 times by 2 tests: break; Executed by:
| 16 | ||||||||||||||||||||||||
4139 | case Ref: executed 1014 times by 3 tests: case Ref: Executed by:
| 1014 | ||||||||||||||||||||||||
4140 | if (!contentCharDataRead) {
| 425-589 | ||||||||||||||||||||||||
4141 | // reference may be CharData; so clear string to be safe | - | ||||||||||||||||||||||||
4142 | stringClear(); | - | ||||||||||||||||||||||||
4143 | parseReference_context = InContent; | - | ||||||||||||||||||||||||
4144 | if (!parseReference()) {
| 292-297 | ||||||||||||||||||||||||
4145 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||||||||||||||
4146 | return false; executed 292 times by 1 test: return false; Executed by:
| 292 | ||||||||||||||||||||||||
4147 | } | - | ||||||||||||||||||||||||
4148 | } else { executed 297 times by 3 tests: end of block Executed by:
| 297 | ||||||||||||||||||||||||
4149 | if (reportEntities) {
| 0-425 | ||||||||||||||||||||||||
4150 | // report character data in chunks | - | ||||||||||||||||||||||||
4151 | if (contentHnd) {
| 0 | ||||||||||||||||||||||||
4152 | if (reportWhitespaceCharData || !string().simplified().isEmpty()) {
| 0 | ||||||||||||||||||||||||
4153 | if (!contentHnd->characters(string())) {
| 0 | ||||||||||||||||||||||||
4154 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
4155 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4156 | } | - | ||||||||||||||||||||||||
4157 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4158 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4159 | stringClear(); | - | ||||||||||||||||||||||||
4160 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4161 | parseReference_context = InContent; | - | ||||||||||||||||||||||||
4162 | if (!parseReference()) {
| 180-245 | ||||||||||||||||||||||||
4163 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||||||||||||||
4164 | return false; executed 180 times by 1 test: return false; Executed by:
| 180 | ||||||||||||||||||||||||
4165 | } | - | ||||||||||||||||||||||||
4166 | } executed 245 times by 3 tests: end of block Executed by:
| 245 | ||||||||||||||||||||||||
4167 | break; executed 542 times by 3 tests: break; Executed by:
| 542 | ||||||||||||||||||||||||
4168 | case Lt: executed 9155 times by 6 tests: case Lt: Executed by:
| 9155 | ||||||||||||||||||||||||
4169 | // call the handler for CharData | - | ||||||||||||||||||||||||
4170 | if (contentHnd) {
| 10-9145 | ||||||||||||||||||||||||
4171 | if (contentCharDataRead) {
| 2718-6427 | ||||||||||||||||||||||||
4172 | if (reportWhitespaceCharData || !string().simplified().isEmpty()) {
| 125-5910 | ||||||||||||||||||||||||
4173 | if (!contentHnd->characters(string())) {
| 0-6035 | ||||||||||||||||||||||||
4174 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
4175 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4176 | } | - | ||||||||||||||||||||||||
4177 | } executed 6035 times by 4 tests: end of block Executed by:
| 6035 | ||||||||||||||||||||||||
4178 | } executed 6427 times by 6 tests: end of block Executed by:
| 6427 | ||||||||||||||||||||||||
4179 | } executed 9145 times by 6 tests: end of block Executed by:
| 9145 | ||||||||||||||||||||||||
4180 | contentCharDataRead = false; | - | ||||||||||||||||||||||||
4181 | next(); | - | ||||||||||||||||||||||||
4182 | break; executed 9155 times by 6 tests: break; Executed by:
| 9155 | ||||||||||||||||||||||||
4183 | case PInstr: executed 39 times by 1 test: case PInstr: Executed by:
| 39 | ||||||||||||||||||||||||
4184 | case PInstrR: never executed: case PInstrR: | 0 | ||||||||||||||||||||||||
4185 | parsePI_xmldecl = false; | - | ||||||||||||||||||||||||
4186 | if (!parsePI()) {
| 4-35 | ||||||||||||||||||||||||
4187 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||||||||||||||
4188 | return false; executed 35 times by 1 test: return false; Executed by:
| 35 | ||||||||||||||||||||||||
4189 | } | - | ||||||||||||||||||||||||
4190 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
4191 | case Elem: executed 3777 times by 6 tests: case Elem: Executed by:
| 3777 | ||||||||||||||||||||||||
4192 | if (!parseElement()) {
| 282-3495 | ||||||||||||||||||||||||
4193 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||||||||||||||
4194 | return false; executed 282 times by 1 test: return false; Executed by:
| 282 | ||||||||||||||||||||||||
4195 | } | - | ||||||||||||||||||||||||
4196 | break; executed 3495 times by 6 tests: break; Executed by:
| 3495 | ||||||||||||||||||||||||
4197 | case Em: executed 158 times by 2 tests: case Em: Executed by:
| 158 | ||||||||||||||||||||||||
4198 | next(); | - | ||||||||||||||||||||||||
4199 | break; executed 158 times by 2 tests: break; Executed by:
| 158 | ||||||||||||||||||||||||
4200 | case Com: executed 100 times by 2 tests: case Com: Executed by:
| 100 | ||||||||||||||||||||||||
4201 | case ComR: never executed: case ComR: | 0 | ||||||||||||||||||||||||
4202 | if (!parseComment()) {
| 38-62 | ||||||||||||||||||||||||
4203 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||||||||||||||
4204 | return false; executed 38 times by 1 test: return false; Executed by:
| 38 | ||||||||||||||||||||||||
4205 | } | - | ||||||||||||||||||||||||
4206 | break; executed 62 times by 2 tests: break; Executed by:
| 62 | ||||||||||||||||||||||||
4207 | case CDS: executed 58 times by 1 test: case CDS: Executed by:
| 58 | ||||||||||||||||||||||||
4208 | parseString_s = QLatin1String("[CDATA["); | - | ||||||||||||||||||||||||
4209 | if (!parseString()) {
| 23-35 | ||||||||||||||||||||||||
4210 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||||||||||||||
4211 | return false; executed 35 times by 1 test: return false; Executed by:
| 35 | ||||||||||||||||||||||||
4212 | } | - | ||||||||||||||||||||||||
4213 | break; executed 23 times by 1 test: break; Executed by:
| 23 | ||||||||||||||||||||||||
4214 | case CDS1: executed 181 times by 1 test: case CDS1: Executed by:
| 181 | ||||||||||||||||||||||||
4215 | stringAddC(); | - | ||||||||||||||||||||||||
4216 | next(); | - | ||||||||||||||||||||||||
4217 | break; executed 181 times by 1 test: break; Executed by:
| 181 | ||||||||||||||||||||||||
4218 | case CDS2: executed 63 times by 1 test: case CDS2: Executed by:
| 63 | ||||||||||||||||||||||||
4219 | // skip ']' | - | ||||||||||||||||||||||||
4220 | next(); | - | ||||||||||||||||||||||||
4221 | break; executed 63 times by 1 test: break; Executed by:
| 63 | ||||||||||||||||||||||||
4222 | case CDS3: executed 64 times by 1 test: case CDS3: Executed by:
| 64 | ||||||||||||||||||||||||
4223 | // skip ']'... | - | ||||||||||||||||||||||||
4224 | next(); | - | ||||||||||||||||||||||||
4225 | break; executed 64 times by 1 test: break; Executed by:
| 64 | ||||||||||||||||||||||||
4226 | } | - | ||||||||||||||||||||||||
4227 | } executed 260781 times by 6 tests: end of block Executed by:
| 260781 | ||||||||||||||||||||||||
4228 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4229 | } | - | ||||||||||||||||||||||||
4230 | - | |||||||||||||||||||||||||
4231 | bool QXmlSimpleReaderPrivate::reportEndEntities() | - | ||||||||||||||||||||||||
4232 | { | - | ||||||||||||||||||||||||
4233 | int count = (int)xmlRefStack.count(); | - | ||||||||||||||||||||||||
4234 | while (count != 0 && xmlRefStack.top().isEmpty()) {
| 0 | ||||||||||||||||||||||||
4235 | if (contentHnd) {
| 0 | ||||||||||||||||||||||||
4236 | if (reportWhitespaceCharData || !string().simplified().isEmpty()) {
| 0 | ||||||||||||||||||||||||
4237 | if (!contentHnd->characters(string())) {
| 0 | ||||||||||||||||||||||||
4238 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
4239 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4240 | } | - | ||||||||||||||||||||||||
4241 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4242 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4243 | stringClear(); | - | ||||||||||||||||||||||||
4244 | if (lexicalHnd) {
| 0 | ||||||||||||||||||||||||
4245 | if (!lexicalHnd->endEntity(xmlRefStack.top().name)) {
| 0 | ||||||||||||||||||||||||
4246 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
4247 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4248 | } | - | ||||||||||||||||||||||||
4249 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4250 | xmlRefStack.pop_back(); | - | ||||||||||||||||||||||||
4251 | count--; | - | ||||||||||||||||||||||||
4252 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4253 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
4254 | } | - | ||||||||||||||||||||||||
4255 | - | |||||||||||||||||||||||||
4256 | /* | - | ||||||||||||||||||||||||
4257 | Parse Misc [27]. | - | ||||||||||||||||||||||||
4258 | */ | - | ||||||||||||||||||||||||
4259 | bool QXmlSimpleReaderPrivate::parseMisc() | - | ||||||||||||||||||||||||
4260 | { | - | ||||||||||||||||||||||||
4261 | const signed char Init = 0; | - | ||||||||||||||||||||||||
4262 | const signed char Lt = 1; // '<' was read | - | ||||||||||||||||||||||||
4263 | const signed char Comment = 2; // read comment | - | ||||||||||||||||||||||||
4264 | const signed char eatWS = 3; // eat whitespaces | - | ||||||||||||||||||||||||
4265 | const signed char PInstr = 4; // read PI | - | ||||||||||||||||||||||||
4266 | const signed char Comment2 = 5; // read comment | - | ||||||||||||||||||||||||
4267 | - | |||||||||||||||||||||||||
4268 | const signed char InpWs = 0; // S | - | ||||||||||||||||||||||||
4269 | const signed char InpLt = 1; // < | - | ||||||||||||||||||||||||
4270 | const signed char InpQm = 2; // ? | - | ||||||||||||||||||||||||
4271 | const signed char InpEm = 3; // ! | - | ||||||||||||||||||||||||
4272 | const signed char InpUnknown = 4; | - | ||||||||||||||||||||||||
4273 | - | |||||||||||||||||||||||||
4274 | static const signed char table[3][5] = { | - | ||||||||||||||||||||||||
4275 | /* InpWs InpLt InpQm InpEm InpUnknown */ | - | ||||||||||||||||||||||||
4276 | { eatWS, Lt, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
4277 | { -1, -1, PInstr,Comment, -1 }, // Lt | - | ||||||||||||||||||||||||
4278 | { -1, -1, -1, -1, Comment2 } // Comment | - | ||||||||||||||||||||||||
4279 | }; | - | ||||||||||||||||||||||||
4280 | signed char state; | - | ||||||||||||||||||||||||
4281 | signed char input; | - | ||||||||||||||||||||||||
4282 | - | |||||||||||||||||||||||||
4283 | if (parseStack==0 || parseStack->isEmpty()) {
| 231-2109 | ||||||||||||||||||||||||
4284 | state = Init; | - | ||||||||||||||||||||||||
4285 | } else { executed 1757 times by 2 tests: end of block Executed by:
| 1757 | ||||||||||||||||||||||||
4286 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
4287 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
4288 | qDebug("QXmlSimpleReader: parseMisc (cont) in state %d", state); | - | ||||||||||||||||||||||||
4289 | #endif | - | ||||||||||||||||||||||||
4290 | if (!parseStack->isEmpty()) {
| 4-579 | ||||||||||||||||||||||||
4291 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
4292 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 64-515 | ||||||||||||||||||||||||
4293 | parseStack->pop(); | - | ||||||||||||||||||||||||
4294 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
4295 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
4296 | #endif | - | ||||||||||||||||||||||||
4297 | } executed 515 times by 1 test: end of block Executed by:
| 515 | ||||||||||||||||||||||||
4298 | if (!(this->*function)()) {
| 30-549 | ||||||||||||||||||||||||
4299 | parseFailed(&QXmlSimpleReaderPrivate::parseMisc, state); | - | ||||||||||||||||||||||||
4300 | return false; executed 549 times by 1 test: return false; Executed by:
| 549 | ||||||||||||||||||||||||
4301 | } | - | ||||||||||||||||||||||||
4302 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||
4303 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
4304 | - | |||||||||||||||||||||||||
4305 | for (;;) { | - | ||||||||||||||||||||||||
4306 | switch (state) { | - | ||||||||||||||||||||||||
4307 | case eatWS: executed 237 times by 2 tests: case eatWS: Executed by:
| 237 | ||||||||||||||||||||||||
4308 | return true; executed 237 times by 2 tests: return true; Executed by:
| 237 | ||||||||||||||||||||||||
4309 | case PInstr: executed 10 times by 1 test: case PInstr: Executed by:
| 10 | ||||||||||||||||||||||||
4310 | if (contentHnd) {
| 0-10 | ||||||||||||||||||||||||
4311 | if (!contentHnd->processingInstruction(name(),string())) {
| 0-10 | ||||||||||||||||||||||||
4312 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
4313 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4314 | } | - | ||||||||||||||||||||||||
4315 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
4316 | return true; executed 10 times by 1 test: return true; Executed by:
| 10 | ||||||||||||||||||||||||
4317 | case Comment2: executed 10 times by 1 test: case Comment2: Executed by:
| 10 | ||||||||||||||||||||||||
4318 | if (lexicalHnd) {
| 0-10 | ||||||||||||||||||||||||
4319 | if (!lexicalHnd->comment(string())) {
| 0-10 | ||||||||||||||||||||||||
4320 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
4321 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4322 | } | - | ||||||||||||||||||||||||
4323 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
4324 | return true; executed 10 times by 1 test: return true; Executed by:
| 10 | ||||||||||||||||||||||||
4325 | case -1: executed 8 times by 1 test: case -1: Executed by:
| 8 | ||||||||||||||||||||||||
4326 | // Error | - | ||||||||||||||||||||||||
4327 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
4328 | return false; executed 8 times by 1 test: return false; Executed by:
| 8 | ||||||||||||||||||||||||
4329 | } | - | ||||||||||||||||||||||||
4330 | - | |||||||||||||||||||||||||
4331 | if (atEnd()) {
| 4-1794 | ||||||||||||||||||||||||
4332 | unexpectedEof(&QXmlSimpleReaderPrivate::parseMisc, state); | - | ||||||||||||||||||||||||
4333 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
4334 | } | - | ||||||||||||||||||||||||
4335 | if (is_S(c)) {
| 67-1727 | ||||||||||||||||||||||||
4336 | input = InpWs; | - | ||||||||||||||||||||||||
4337 | } else if (c == QLatin1Char('<')) { executed 1727 times by 2 tests: end of block Executed by:
| 26-1727 | ||||||||||||||||||||||||
4338 | input = InpLt; | - | ||||||||||||||||||||||||
4339 | } else if (c == QLatin1Char('?')) { executed 26 times by 1 test: end of block Executed by:
| 11-30 | ||||||||||||||||||||||||
4340 | input = InpQm; | - | ||||||||||||||||||||||||
4341 | } else if (c == QLatin1Char('!')) { executed 11 times by 1 test: end of block Executed by:
| 11-19 | ||||||||||||||||||||||||
4342 | input = InpEm; | - | ||||||||||||||||||||||||
4343 | } else { executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||||||||
4344 | input = InpUnknown; | - | ||||||||||||||||||||||||
4345 | } executed 19 times by 1 test: end of block Executed by:
| 19 | ||||||||||||||||||||||||
4346 | state = table[state][input]; | - | ||||||||||||||||||||||||
4347 | - | |||||||||||||||||||||||||
4348 | switch (state) { | - | ||||||||||||||||||||||||
4349 | case eatWS: executed 1727 times by 2 tests: case eatWS: Executed by:
| 1727 | ||||||||||||||||||||||||
4350 | if (!eat_ws()) {
| 225-1502 | ||||||||||||||||||||||||
4351 | parseFailed(&QXmlSimpleReaderPrivate::parseMisc, state); | - | ||||||||||||||||||||||||
4352 | return false; executed 1502 times by 1 test: return false; Executed by:
| 1502 | ||||||||||||||||||||||||
4353 | } | - | ||||||||||||||||||||||||
4354 | break; executed 225 times by 2 tests: break; Executed by:
| 225 | ||||||||||||||||||||||||
4355 | case Lt: executed 26 times by 1 test: case Lt: Executed by:
| 26 | ||||||||||||||||||||||||
4356 | next(); | - | ||||||||||||||||||||||||
4357 | break; executed 26 times by 1 test: break; Executed by:
| 26 | ||||||||||||||||||||||||
4358 | case PInstr: executed 11 times by 1 test: case PInstr: Executed by:
| 11 | ||||||||||||||||||||||||
4359 | parsePI_xmldecl = false; | - | ||||||||||||||||||||||||
4360 | if (!parsePI()) {
| 1-10 | ||||||||||||||||||||||||
4361 | parseFailed(&QXmlSimpleReaderPrivate::parseMisc, state); | - | ||||||||||||||||||||||||
4362 | return false; executed 10 times by 1 test: return false; Executed by:
| 10 | ||||||||||||||||||||||||
4363 | } | - | ||||||||||||||||||||||||
4364 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
4365 | case Comment: executed 11 times by 1 test: case Comment: Executed by:
| 11 | ||||||||||||||||||||||||
4366 | next(); | - | ||||||||||||||||||||||||
4367 | break; executed 11 times by 1 test: break; Executed by:
| 11 | ||||||||||||||||||||||||
4368 | case Comment2: executed 11 times by 1 test: case Comment2: Executed by:
| 11 | ||||||||||||||||||||||||
4369 | if (!parseComment()) {
| 1-10 | ||||||||||||||||||||||||
4370 | parseFailed(&QXmlSimpleReaderPrivate::parseMisc, state); | - | ||||||||||||||||||||||||
4371 | return false; executed 10 times by 1 test: return false; Executed by:
| 10 | ||||||||||||||||||||||||
4372 | } | - | ||||||||||||||||||||||||
4373 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
4374 | } | - | ||||||||||||||||||||||||
4375 | } executed 272 times by 2 tests: end of block Executed by:
| 272 | ||||||||||||||||||||||||
4376 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4377 | } | - | ||||||||||||||||||||||||
4378 | - | |||||||||||||||||||||||||
4379 | /* | - | ||||||||||||||||||||||||
4380 | Parse a processing instruction [16]. | - | ||||||||||||||||||||||||
4381 | - | |||||||||||||||||||||||||
4382 | If xmldec is true, it tries to parse a PI or a XML declaration [23]. | - | ||||||||||||||||||||||||
4383 | - | |||||||||||||||||||||||||
4384 | Precondition: the beginning '<' of the PI is already read and the head stand | - | ||||||||||||||||||||||||
4385 | on the '?' of '<?'. | - | ||||||||||||||||||||||||
4386 | - | |||||||||||||||||||||||||
4387 | If this funktion was successful, the head-position is on the first | - | ||||||||||||||||||||||||
4388 | character after the PI. | - | ||||||||||||||||||||||||
4389 | */ | - | ||||||||||||||||||||||||
4390 | bool QXmlSimpleReaderPrivate::parsePI() | - | ||||||||||||||||||||||||
4391 | { | - | ||||||||||||||||||||||||
4392 | const signed char Init = 0; | - | ||||||||||||||||||||||||
4393 | const signed char QmI = 1; // ? was read | - | ||||||||||||||||||||||||
4394 | const signed char Name = 2; // read Name | - | ||||||||||||||||||||||||
4395 | const signed char XMLDecl = 3; // read XMLDecl | - | ||||||||||||||||||||||||
4396 | const signed char Ws1 = 4; // eat ws after "xml" of XMLDecl | - | ||||||||||||||||||||||||
4397 | const signed char PInstr = 5; // read PI | - | ||||||||||||||||||||||||
4398 | const signed char Ws2 = 6; // eat ws after Name of PI | - | ||||||||||||||||||||||||
4399 | const signed char Version = 7; // read versionInfo | - | ||||||||||||||||||||||||
4400 | const signed char Ws3 = 8; // eat ws after versionInfo | - | ||||||||||||||||||||||||
4401 | const signed char EorSD = 9; // read EDecl or SDDecl | - | ||||||||||||||||||||||||
4402 | const signed char Ws4 = 10; // eat ws after EDecl or SDDecl | - | ||||||||||||||||||||||||
4403 | const signed char SD = 11; // read SDDecl | - | ||||||||||||||||||||||||
4404 | const signed char Ws5 = 12; // eat ws after SDDecl | - | ||||||||||||||||||||||||
4405 | const signed char ADone = 13; // almost done | - | ||||||||||||||||||||||||
4406 | const signed char Char = 14; // Char was read | - | ||||||||||||||||||||||||
4407 | const signed char Qm = 15; // Qm was read | - | ||||||||||||||||||||||||
4408 | const signed char Done = 16; // finished reading content | - | ||||||||||||||||||||||||
4409 | - | |||||||||||||||||||||||||
4410 | const signed char InpWs = 0; // whitespace | - | ||||||||||||||||||||||||
4411 | const signed char InpNameBe = 1; // NameBeginning | - | ||||||||||||||||||||||||
4412 | const signed char InpGt = 2; // > | - | ||||||||||||||||||||||||
4413 | const signed char InpQm = 3; // ? | - | ||||||||||||||||||||||||
4414 | const signed char InpUnknown = 4; | - | ||||||||||||||||||||||||
4415 | - | |||||||||||||||||||||||||
4416 | static const signed char table[16][5] = { | - | ||||||||||||||||||||||||
4417 | /* InpWs, InpNameBe InpGt InpQm InpUnknown */ | - | ||||||||||||||||||||||||
4418 | { -1, -1, -1, QmI, -1 }, // Init | - | ||||||||||||||||||||||||
4419 | { -1, Name, -1, -1, -1 }, // QmI | - | ||||||||||||||||||||||||
4420 | { -1, -1, -1, -1, -1 }, // Name (this state is left not through input) | - | ||||||||||||||||||||||||
4421 | { Ws1, -1, -1, -1, -1 }, // XMLDecl | - | ||||||||||||||||||||||||
4422 | { -1, Version, -1, -1, -1 }, // Ws1 | - | ||||||||||||||||||||||||
4423 | { Ws2, -1, -1, Qm, -1 }, // PInstr | - | ||||||||||||||||||||||||
4424 | { Char, Char, Char, Qm, Char }, // Ws2 | - | ||||||||||||||||||||||||
4425 | { Ws3, -1, -1, ADone, -1 }, // Version | - | ||||||||||||||||||||||||
4426 | { -1, EorSD, -1, ADone, -1 }, // Ws3 | - | ||||||||||||||||||||||||
4427 | { Ws4, -1, -1, ADone, -1 }, // EorSD | - | ||||||||||||||||||||||||
4428 | { -1, SD, -1, ADone, -1 }, // Ws4 | - | ||||||||||||||||||||||||
4429 | { Ws5, -1, -1, ADone, -1 }, // SD | - | ||||||||||||||||||||||||
4430 | { -1, -1, -1, ADone, -1 }, // Ws5 | - | ||||||||||||||||||||||||
4431 | { -1, -1, Done, -1, -1 }, // ADone | - | ||||||||||||||||||||||||
4432 | { Char, Char, Char, Qm, Char }, // Char | - | ||||||||||||||||||||||||
4433 | { Char, Char, Done, Qm, Char }, // Qm | - | ||||||||||||||||||||||||
4434 | }; | - | ||||||||||||||||||||||||
4435 | signed char state; | - | ||||||||||||||||||||||||
4436 | signed char input; | - | ||||||||||||||||||||||||
4437 | - | |||||||||||||||||||||||||
4438 | if (parseStack==0 || parseStack->isEmpty()) {
| 54-1386 | ||||||||||||||||||||||||
4439 | state = Init; | - | ||||||||||||||||||||||||
4440 | } else { executed 198 times by 2 tests: end of block Executed by:
| 198 | ||||||||||||||||||||||||
4441 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
4442 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
4443 | qDebug("QXmlSimpleReader: parsePI (cont) in state %d", state); | - | ||||||||||||||||||||||||
4444 | #endif | - | ||||||||||||||||||||||||
4445 | if (!parseStack->isEmpty()) {
| 245-997 | ||||||||||||||||||||||||
4446 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
4447 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 87-910 | ||||||||||||||||||||||||
4448 | parseStack->pop(); | - | ||||||||||||||||||||||||
4449 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
4450 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
4451 | #endif | - | ||||||||||||||||||||||||
4452 | } executed 87 times by 1 test: end of block Executed by:
| 87 | ||||||||||||||||||||||||
4453 | if (!(this->*function)()) {
| 358-639 | ||||||||||||||||||||||||
4454 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||||||||||||||
4455 | return false; executed 639 times by 1 test: return false; Executed by:
| 639 | ||||||||||||||||||||||||
4456 | } | - | ||||||||||||||||||||||||
4457 | } executed 358 times by 1 test: end of block Executed by:
| 358 | ||||||||||||||||||||||||
4458 | } executed 603 times by 1 test: end of block Executed by:
| 603 | ||||||||||||||||||||||||
4459 | - | |||||||||||||||||||||||||
4460 | for (;;) { | - | ||||||||||||||||||||||||
4461 | switch (state) { | - | ||||||||||||||||||||||||
4462 | case Name: executed 197 times by 2 tests: case Name: Executed by:
| 197 | ||||||||||||||||||||||||
4463 | // test what name was read and determine the next state | - | ||||||||||||||||||||||||
4464 | // (not very beautiful, I admit) | - | ||||||||||||||||||||||||
4465 | if (name().toLower() == QLatin1String("xml")) {
| 68-129 | ||||||||||||||||||||||||
4466 | if (parsePI_xmldecl && name() == QLatin1String("xml")) {
| 2-121 | ||||||||||||||||||||||||
4467 | state = XMLDecl; | - | ||||||||||||||||||||||||
4468 | } else { executed 119 times by 2 tests: end of block Executed by:
| 119 | ||||||||||||||||||||||||
4469 | reportParseError(QLatin1String(XMLERR_INVALIDNAMEFORPI)); | - | ||||||||||||||||||||||||
4470 | return false; executed 10 times by 1 test: return false; Executed by:
| 10 | ||||||||||||||||||||||||
4471 | } | - | ||||||||||||||||||||||||
4472 | } else { | - | ||||||||||||||||||||||||
4473 | state = PInstr; | - | ||||||||||||||||||||||||
4474 | stringClear(); | - | ||||||||||||||||||||||||
4475 | } executed 68 times by 2 tests: end of block Executed by:
| 68 | ||||||||||||||||||||||||
4476 | break; executed 187 times by 2 tests: break; Executed by:
| 187 | ||||||||||||||||||||||||
4477 | case Version: executed 131 times by 2 tests: case Version: Executed by:
| 131 | ||||||||||||||||||||||||
4478 | // get version (syntax like an attribute) | - | ||||||||||||||||||||||||
4479 | if (name() != QLatin1String("version")) {
| 3-128 | ||||||||||||||||||||||||
4480 | reportParseError(QLatin1String(XMLERR_VERSIONEXPECTED)); | - | ||||||||||||||||||||||||
4481 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
4482 | } | - | ||||||||||||||||||||||||
4483 | xmlVersion = string(); | - | ||||||||||||||||||||||||
4484 | break; executed 128 times by 2 tests: break; Executed by:
| 128 | ||||||||||||||||||||||||
4485 | case EorSD: executed 119 times by 2 tests: case EorSD: Executed by:
| 119 | ||||||||||||||||||||||||
4486 | // get the EDecl or SDDecl (syntax like an attribute) | - | ||||||||||||||||||||||||
4487 | if (name() == QLatin1String("standalone")) {
| 18-101 | ||||||||||||||||||||||||
4488 | if (string()== QLatin1String("yes")) {
| 1-17 | ||||||||||||||||||||||||
4489 | standalone = QXmlSimpleReaderPrivate::Yes; | - | ||||||||||||||||||||||||
4490 | } else if (string() == QLatin1String("no")) { executed 17 times by 1 test: end of block Executed by:
| 0-17 | ||||||||||||||||||||||||
4491 | standalone = QXmlSimpleReaderPrivate::No; | - | ||||||||||||||||||||||||
4492 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
4493 | reportParseError(QLatin1String(XMLERR_WRONGVALUEFORSDECL)); | - | ||||||||||||||||||||||||
4494 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
4495 | } | - | ||||||||||||||||||||||||
4496 | } else if (name() == QLatin1String("encoding")) {
| 2-99 | ||||||||||||||||||||||||
4497 | encoding = string(); | - | ||||||||||||||||||||||||
4498 | } else { executed 99 times by 2 tests: end of block Executed by:
| 99 | ||||||||||||||||||||||||
4499 | reportParseError(QLatin1String(XMLERR_EDECLORSDDECLEXPECTED)); | - | ||||||||||||||||||||||||
4500 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
4501 | } | - | ||||||||||||||||||||||||
4502 | break; executed 116 times by 2 tests: break; Executed by:
| 116 | ||||||||||||||||||||||||
4503 | case SD: executed 50 times by 1 test: case SD: Executed by:
| 50 | ||||||||||||||||||||||||
4504 | if (name() != QLatin1String("standalone")) {
| 0-50 | ||||||||||||||||||||||||
4505 | reportParseError(QLatin1String(XMLERR_SDDECLEXPECTED)); | - | ||||||||||||||||||||||||
4506 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4507 | } | - | ||||||||||||||||||||||||
4508 | if (string() == QLatin1String("yes")) {
| 11-39 | ||||||||||||||||||||||||
4509 | standalone = QXmlSimpleReaderPrivate::Yes; | - | ||||||||||||||||||||||||
4510 | } else if (string() == QLatin1String("no")) { executed 11 times by 1 test: end of block Executed by:
| 0-39 | ||||||||||||||||||||||||
4511 | standalone = QXmlSimpleReaderPrivate::No; | - | ||||||||||||||||||||||||
4512 | } else { executed 39 times by 1 test: end of block Executed by:
| 39 | ||||||||||||||||||||||||
4513 | reportParseError(QLatin1String(XMLERR_WRONGVALUEFORSDECL)); | - | ||||||||||||||||||||||||
4514 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4515 | } | - | ||||||||||||||||||||||||
4516 | break; executed 50 times by 1 test: break; Executed by:
| 50 | ||||||||||||||||||||||||
4517 | case Qm: executed 104 times by 2 tests: case Qm: Executed by:
| 104 | ||||||||||||||||||||||||
4518 | // test if the skipping was legal | - | ||||||||||||||||||||||||
4519 | if (!atEnd() && c != QLatin1Char('>'))
| 19-85 | ||||||||||||||||||||||||
4520 | stringAddC(QLatin1Char('?')); executed 21 times by 1 test: stringAddC(QLatin1Char('?')); Executed by:
| 21 | ||||||||||||||||||||||||
4521 | break; executed 104 times by 2 tests: break; Executed by:
| 104 | ||||||||||||||||||||||||
4522 | case Done: executed 175 times by 2 tests: case Done: Executed by:
| 175 | ||||||||||||||||||||||||
4523 | return true; executed 175 times by 2 tests: return true; Executed by:
| 175 | ||||||||||||||||||||||||
4524 | case -1: executed 3 times by 1 test: case -1: Executed by:
| 3 | ||||||||||||||||||||||||
4525 | // Error | - | ||||||||||||||||||||||||
4526 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
4527 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
4528 | } | - | ||||||||||||||||||||||||
4529 | - | |||||||||||||||||||||||||
4530 | if (atEnd()) {
| 249-1786 | ||||||||||||||||||||||||
4531 | unexpectedEof(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||||||||||||||
4532 | return false; executed 249 times by 1 test: return false; Executed by:
| 249 | ||||||||||||||||||||||||
4533 | } | - | ||||||||||||||||||||||||
4534 | if (is_S(c)) {
| 412-1374 | ||||||||||||||||||||||||
4535 | input = InpWs; | - | ||||||||||||||||||||||||
4536 | } else if (determineNameChar(c) == NameBeginning) { executed 412 times by 2 tests: end of block Executed by:
| 412-764 | ||||||||||||||||||||||||
4537 | input = InpNameBe; | - | ||||||||||||||||||||||||
4538 | } else if (c == QLatin1Char('>')) { executed 764 times by 2 tests: end of block Executed by:
| 189-764 | ||||||||||||||||||||||||
4539 | input = InpGt; | - | ||||||||||||||||||||||||
4540 | } else if (c == QLatin1Char('?')) { executed 189 times by 2 tests: end of block Executed by:
| 27-394 | ||||||||||||||||||||||||
4541 | input = InpQm; | - | ||||||||||||||||||||||||
4542 | } else { executed 394 times by 2 tests: end of block Executed by:
| 394 | ||||||||||||||||||||||||
4543 | input = InpUnknown; | - | ||||||||||||||||||||||||
4544 | } executed 27 times by 2 tests: end of block Executed by:
| 27 | ||||||||||||||||||||||||
4545 | state = table[state][input]; | - | ||||||||||||||||||||||||
4546 | - | |||||||||||||||||||||||||
4547 | switch (state) { | - | ||||||||||||||||||||||||
4548 | case QmI: executed 198 times by 2 tests: case QmI: Executed by:
| 198 | ||||||||||||||||||||||||
4549 | next(); | - | ||||||||||||||||||||||||
4550 | break; executed 198 times by 2 tests: break; Executed by:
| 198 | ||||||||||||||||||||||||
4551 | case Name: executed 197 times by 2 tests: case Name: Executed by:
| 197 | ||||||||||||||||||||||||
4552 | parseName_useRef = false; | - | ||||||||||||||||||||||||
4553 | if (!parseName()) {
| 83-114 | ||||||||||||||||||||||||
4554 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||||||||||||||
4555 | return false; executed 83 times by 1 test: return false; Executed by:
| 83 | ||||||||||||||||||||||||
4556 | } | - | ||||||||||||||||||||||||
4557 | break; executed 114 times by 2 tests: break; Executed by:
| 114 | ||||||||||||||||||||||||
4558 | case Ws1: executed 119 times by 2 tests: case Ws1: Executed by:
| 119 | ||||||||||||||||||||||||
4559 | case Ws2: executed 58 times by 2 tests: case Ws2: Executed by:
| 58 | ||||||||||||||||||||||||
4560 | case Ws3: executed 78 times by 2 tests: case Ws3: Executed by:
| 78 | ||||||||||||||||||||||||
4561 | case Ws4: executed 40 times by 1 test: case Ws4: Executed by:
| 40 | ||||||||||||||||||||||||
4562 | case Ws5: executed 30 times by 1 test: case Ws5: Executed by:
| 30 | ||||||||||||||||||||||||
4563 | if (!eat_ws()) {
| 86-239 | ||||||||||||||||||||||||
4564 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||||||||||||||
4565 | return false; executed 86 times by 1 test: return false; Executed by:
| 86 | ||||||||||||||||||||||||
4566 | } | - | ||||||||||||||||||||||||
4567 | break; executed 239 times by 2 tests: break; Executed by:
| 239 | ||||||||||||||||||||||||
4568 | case Version: executed 119 times by 2 tests: case Version: Executed by:
| 119 | ||||||||||||||||||||||||
4569 | if (!parseAttribute()) {
| 29-90 | ||||||||||||||||||||||||
4570 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||||||||||||||
4571 | return false; executed 90 times by 1 test: return false; Executed by:
| 90 | ||||||||||||||||||||||||
4572 | } | - | ||||||||||||||||||||||||
4573 | break; executed 29 times by 2 tests: break; Executed by:
| 29 | ||||||||||||||||||||||||
4574 | case EorSD: executed 77 times by 2 tests: case EorSD: Executed by:
| 77 | ||||||||||||||||||||||||
4575 | if (!parseAttribute()) {
| 14-63 | ||||||||||||||||||||||||
4576 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||||||||||||||
4577 | return false; executed 63 times by 1 test: return false; Executed by:
| 63 | ||||||||||||||||||||||||
4578 | } | - | ||||||||||||||||||||||||
4579 | break; executed 14 times by 2 tests: break; Executed by:
| 14 | ||||||||||||||||||||||||
4580 | case SD: executed 40 times by 1 test: case SD: Executed by:
| 40 | ||||||||||||||||||||||||
4581 | // get the SDDecl (syntax like an attribute) | - | ||||||||||||||||||||||||
4582 | if (standalone != QXmlSimpleReaderPrivate::Unknown) {
| 0-40 | ||||||||||||||||||||||||
4583 | // already parsed the standalone declaration | - | ||||||||||||||||||||||||
4584 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
4585 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4586 | } | - | ||||||||||||||||||||||||
4587 | if (!parseAttribute()) {
| 4-36 | ||||||||||||||||||||||||
4588 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||||||||||||||
4589 | return false; executed 36 times by 1 test: return false; Executed by:
| 36 | ||||||||||||||||||||||||
4590 | } | - | ||||||||||||||||||||||||
4591 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
4592 | case ADone: executed 111 times by 2 tests: case ADone: Executed by:
| 111 | ||||||||||||||||||||||||
4593 | next(); | - | ||||||||||||||||||||||||
4594 | break; executed 111 times by 2 tests: break; Executed by:
| 111 | ||||||||||||||||||||||||
4595 | case Char: executed 456 times by 2 tests: case Char: Executed by:
| 456 | ||||||||||||||||||||||||
4596 | stringAddC(); | - | ||||||||||||||||||||||||
4597 | next(); | - | ||||||||||||||||||||||||
4598 | break; executed 456 times by 2 tests: break; Executed by:
| 456 | ||||||||||||||||||||||||
4599 | case Qm: executed 85 times by 2 tests: case Qm: Executed by:
| 85 | ||||||||||||||||||||||||
4600 | // skip the '?' | - | ||||||||||||||||||||||||
4601 | next(); | - | ||||||||||||||||||||||||
4602 | break; executed 85 times by 2 tests: break; Executed by:
| 85 | ||||||||||||||||||||||||
4603 | case Done: executed 175 times by 2 tests: case Done: Executed by:
| 175 | ||||||||||||||||||||||||
4604 | next(); | - | ||||||||||||||||||||||||
4605 | break; executed 175 times by 2 tests: break; Executed by:
| 175 | ||||||||||||||||||||||||
4606 | } | - | ||||||||||||||||||||||||
4607 | } executed 1428 times by 2 tests: end of block Executed by:
| 1428 | ||||||||||||||||||||||||
4608 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4609 | } | - | ||||||||||||||||||||||||
4610 | - | |||||||||||||||||||||||||
4611 | /* | - | ||||||||||||||||||||||||
4612 | Parse a document type definition (doctypedecl [28]). | - | ||||||||||||||||||||||||
4613 | - | |||||||||||||||||||||||||
4614 | Precondition: the beginning '<!' of the doctype is already read the head | - | ||||||||||||||||||||||||
4615 | stands on the 'D' of '<!DOCTYPE'. | - | ||||||||||||||||||||||||
4616 | - | |||||||||||||||||||||||||
4617 | If this function was successful, the head-position is on the first | - | ||||||||||||||||||||||||
4618 | character after the document type definition. | - | ||||||||||||||||||||||||
4619 | */ | - | ||||||||||||||||||||||||
4620 | bool QXmlSimpleReaderPrivate::parseDoctype() | - | ||||||||||||||||||||||||
4621 | { | - | ||||||||||||||||||||||||
4622 | const signed char Init = 0; | - | ||||||||||||||||||||||||
4623 | const signed char Doctype = 1; // read the doctype | - | ||||||||||||||||||||||||
4624 | const signed char Ws1 = 2; // eat_ws | - | ||||||||||||||||||||||||
4625 | const signed char Doctype2 = 3; // read the doctype, part 2 | - | ||||||||||||||||||||||||
4626 | const signed char Ws2 = 4; // eat_ws | - | ||||||||||||||||||||||||
4627 | const signed char Sys = 5; // read SYSTEM or PUBLIC | - | ||||||||||||||||||||||||
4628 | const signed char Ws3 = 6; // eat_ws | - | ||||||||||||||||||||||||
4629 | const signed char MP = 7; // markupdecl or PEReference | - | ||||||||||||||||||||||||
4630 | const signed char MPR = 8; // same as MP, but already reported | - | ||||||||||||||||||||||||
4631 | const signed char PER = 9; // PERReference | - | ||||||||||||||||||||||||
4632 | const signed char Mup = 10; // markupdecl | - | ||||||||||||||||||||||||
4633 | const signed char Ws4 = 11; // eat_ws | - | ||||||||||||||||||||||||
4634 | const signed char MPE = 12; // end of markupdecl or PEReference | - | ||||||||||||||||||||||||
4635 | const signed char Done = 13; | - | ||||||||||||||||||||||||
4636 | - | |||||||||||||||||||||||||
4637 | const signed char InpWs = 0; | - | ||||||||||||||||||||||||
4638 | const signed char InpD = 1; // 'D' | - | ||||||||||||||||||||||||
4639 | const signed char InpS = 2; // 'S' or 'P' | - | ||||||||||||||||||||||||
4640 | const signed char InpOB = 3; // [ | - | ||||||||||||||||||||||||
4641 | const signed char InpCB = 4; //] | - | ||||||||||||||||||||||||
4642 | const signed char InpPer = 5; // % | - | ||||||||||||||||||||||||
4643 | const signed char InpGt = 6; // > | - | ||||||||||||||||||||||||
4644 | const signed char InpUnknown = 7; | - | ||||||||||||||||||||||||
4645 | - | |||||||||||||||||||||||||
4646 | static const signed char table[13][8] = { | - | ||||||||||||||||||||||||
4647 | /* InpWs, InpD InpS InpOB InpCB InpPer InpGt InpUnknown */ | - | ||||||||||||||||||||||||
4648 | { -1, Doctype, -1, -1, -1, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
4649 | { Ws1, -1, -1, -1, -1, -1, -1, -1 }, // Doctype | - | ||||||||||||||||||||||||
4650 | { -1, Doctype2, Doctype2, -1, -1, -1, -1, Doctype2 }, // Ws1 | - | ||||||||||||||||||||||||
4651 | { Ws2, -1, Sys, MP, -1, -1, Done, -1 }, // Doctype2 | - | ||||||||||||||||||||||||
4652 | { -1, -1, Sys, MP, -1, -1, Done, -1 }, // Ws2 | - | ||||||||||||||||||||||||
4653 | { Ws3, -1, -1, MP, -1, -1, Done, -1 }, // Sys | - | ||||||||||||||||||||||||
4654 | { -1, -1, -1, MP, -1, -1, Done, -1 }, // Ws3 | - | ||||||||||||||||||||||||
4655 | { -1, -1, -1, -1, MPE, PER, -1, Mup }, // MP | - | ||||||||||||||||||||||||
4656 | { -1, -1, -1, -1, MPE, PER, -1, Mup }, // MPR | - | ||||||||||||||||||||||||
4657 | { Ws4, -1, -1, -1, MPE, PER, -1, Mup }, // PER | - | ||||||||||||||||||||||||
4658 | { Ws4, -1, -1, -1, MPE, PER, -1, Mup }, // Mup | - | ||||||||||||||||||||||||
4659 | { -1, -1, -1, -1, MPE, PER, -1, Mup }, // Ws4 | - | ||||||||||||||||||||||||
4660 | { -1, -1, -1, -1, -1, -1, Done, -1 } // MPE | - | ||||||||||||||||||||||||
4661 | }; | - | ||||||||||||||||||||||||
4662 | signed char state; | - | ||||||||||||||||||||||||
4663 | signed char input; | - | ||||||||||||||||||||||||
4664 | - | |||||||||||||||||||||||||
4665 | if (parseStack==0 || parseStack->isEmpty()) {
| 433-31694 | ||||||||||||||||||||||||
4666 | startDTDwasReported = false; | - | ||||||||||||||||||||||||
4667 | systemId.clear(); | - | ||||||||||||||||||||||||
4668 | publicId.clear(); | - | ||||||||||||||||||||||||
4669 | state = Init; | - | ||||||||||||||||||||||||
4670 | } else { executed 1923 times by 4 tests: end of block Executed by:
| 1923 | ||||||||||||||||||||||||
4671 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
4672 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
4673 | qDebug("QXmlSimpleReader: parseDoctype (cont) in state %d", state); | - | ||||||||||||||||||||||||
4674 | #endif | - | ||||||||||||||||||||||||
4675 | if (!parseStack->isEmpty()) {
| 1260-28944 | ||||||||||||||||||||||||
4676 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
4677 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 4229-24715 | ||||||||||||||||||||||||
4678 | parseStack->pop(); | - | ||||||||||||||||||||||||
4679 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
4680 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
4681 | #endif | - | ||||||||||||||||||||||||
4682 | } executed 4229 times by 1 test: end of block Executed by:
| 4229 | ||||||||||||||||||||||||
4683 | if (!(this->*function)()) {
| 8495-20449 | ||||||||||||||||||||||||
4684 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||||||||||||||
4685 | return false; executed 20449 times by 1 test: return false; Executed by:
| 20449 | ||||||||||||||||||||||||
4686 | } | - | ||||||||||||||||||||||||
4687 | } executed 8495 times by 1 test: end of block Executed by:
| 8495 | ||||||||||||||||||||||||
4688 | } executed 9755 times by 1 test: end of block Executed by:
| 9755 | ||||||||||||||||||||||||
4689 | - | |||||||||||||||||||||||||
4690 | for (;;) { | - | ||||||||||||||||||||||||
4691 | switch (state) { | - | ||||||||||||||||||||||||
4692 | case Doctype2: executed 1923 times by 4 tests: case Doctype2: Executed by:
| 1923 | ||||||||||||||||||||||||
4693 | doctype = name(); | - | ||||||||||||||||||||||||
4694 | break; executed 1923 times by 4 tests: break; Executed by:
| 1923 | ||||||||||||||||||||||||
4695 | case MP: executed 1558 times by 2 tests: case MP: Executed by:
| 1558 | ||||||||||||||||||||||||
4696 | if (!startDTDwasReported && lexicalHnd ) {
| 0-1558 | ||||||||||||||||||||||||
4697 | startDTDwasReported = true; | - | ||||||||||||||||||||||||
4698 | if (!lexicalHnd->startDTD(doctype, publicId, systemId)) {
| 0-1554 | ||||||||||||||||||||||||
4699 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
4700 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4701 | } | - | ||||||||||||||||||||||||
4702 | } executed 1554 times by 1 test: end of block Executed by:
| 1554 | ||||||||||||||||||||||||
4703 | state = MPR; | - | ||||||||||||||||||||||||
4704 | break; executed 1558 times by 2 tests: break; Executed by:
| 1558 | ||||||||||||||||||||||||
4705 | case Done: executed 1868 times by 4 tests: case Done: Executed by:
| 1868 | ||||||||||||||||||||||||
4706 | return true; executed 1868 times by 4 tests: return true; Executed by:
| 1868 | ||||||||||||||||||||||||
4707 | case -1: executed 2 times by 1 test: case -1: Executed by:
| 2 | ||||||||||||||||||||||||
4708 | // Error | - | ||||||||||||||||||||||||
4709 | reportParseError(QLatin1String(XMLERR_ERRORPARSINGDOCTYPE)); | - | ||||||||||||||||||||||||
4710 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
4711 | } | - | ||||||||||||||||||||||||
4712 | - | |||||||||||||||||||||||||
4713 | if (atEnd()) {
| 1260-18800 | ||||||||||||||||||||||||
4714 | unexpectedEof(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||||||||||||||
4715 | return false; executed 1260 times by 1 test: return false; Executed by:
| 1260 | ||||||||||||||||||||||||
4716 | } | - | ||||||||||||||||||||||||
4717 | if (is_S(c)) {
| 6715-12085 | ||||||||||||||||||||||||
4718 | input = InpWs; | - | ||||||||||||||||||||||||
4719 | } else if (c == QLatin1Char('D')) { executed 6715 times by 4 tests: end of block Executed by:
| 1923-10162 | ||||||||||||||||||||||||
4720 | input = InpD; | - | ||||||||||||||||||||||||
4721 | } else if (c == QLatin1Char('S')) { executed 1923 times by 4 tests: end of block Executed by:
| 296-9866 | ||||||||||||||||||||||||
4722 | input = InpS; | - | ||||||||||||||||||||||||
4723 | } else if (c == QLatin1Char('P')) { executed 296 times by 2 tests: end of block Executed by:
| 87-9779 | ||||||||||||||||||||||||
4724 | input = InpS; | - | ||||||||||||||||||||||||
4725 | } else if (c == QLatin1Char('[')) { executed 87 times by 2 tests: end of block Executed by:
| 87-8221 | ||||||||||||||||||||||||
4726 | input = InpOB; | - | ||||||||||||||||||||||||
4727 | } else if (c == QLatin1Char(']')) { executed 1558 times by 2 tests: end of block Executed by:
| 1505-6716 | ||||||||||||||||||||||||
4728 | input = InpCB; | - | ||||||||||||||||||||||||
4729 | } else if (c == QLatin1Char('%')) { executed 1505 times by 2 tests: end of block Executed by:
| 51-6665 | ||||||||||||||||||||||||
4730 | input = InpPer; | - | ||||||||||||||||||||||||
4731 | } else if (c == QLatin1Char('>')) { executed 51 times by 1 test: end of block Executed by:
| 51-4797 | ||||||||||||||||||||||||
4732 | input = InpGt; | - | ||||||||||||||||||||||||
4733 | } else { executed 1868 times by 4 tests: end of block Executed by:
| 1868 | ||||||||||||||||||||||||
4734 | input = InpUnknown; | - | ||||||||||||||||||||||||
4735 | } executed 4797 times by 4 tests: end of block Executed by:
| 4797 | ||||||||||||||||||||||||
4736 | state = table[state][input]; | - | ||||||||||||||||||||||||
4737 | - | |||||||||||||||||||||||||
4738 | switch (state) { | - | ||||||||||||||||||||||||
4739 | case Doctype: executed 1923 times by 4 tests: case Doctype: Executed by:
| 1923 | ||||||||||||||||||||||||
4740 | parseString_s = QLatin1String("DOCTYPE"); | - | ||||||||||||||||||||||||
4741 | if (!parseString()) {
| 591-1332 | ||||||||||||||||||||||||
4742 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||||||||||||||
4743 | return false; executed 1332 times by 1 test: return false; Executed by:
| 1332 | ||||||||||||||||||||||||
4744 | } | - | ||||||||||||||||||||||||
4745 | break; executed 591 times by 4 tests: break; Executed by:
| 591 | ||||||||||||||||||||||||
4746 | case Ws1: executed 1923 times by 4 tests: case Ws1: Executed by:
| 1923 | ||||||||||||||||||||||||
4747 | case Ws2: executed 1831 times by 3 tests: case Ws2: Executed by:
| 1831 | ||||||||||||||||||||||||
4748 | case Ws3: executed 111 times by 2 tests: case Ws3: Executed by:
| 111 | ||||||||||||||||||||||||
4749 | case Ws4: executed 2850 times by 2 tests: case Ws4: Executed by:
| 2850 | ||||||||||||||||||||||||
4750 | if (!eat_ws()) {
| 2308-4407 | ||||||||||||||||||||||||
4751 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||||||||||||||
4752 | return false; executed 2308 times by 1 test: return false; Executed by:
| 2308 | ||||||||||||||||||||||||
4753 | } | - | ||||||||||||||||||||||||
4754 | break; executed 4407 times by 4 tests: break; Executed by:
| 4407 | ||||||||||||||||||||||||
4755 | case Doctype2: executed 1923 times by 4 tests: case Doctype2: Executed by:
| 1923 | ||||||||||||||||||||||||
4756 | parseName_useRef = false; | - | ||||||||||||||||||||||||
4757 | if (!parseName()) {
| 846-1077 | ||||||||||||||||||||||||
4758 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||||||||||||||
4759 | return false; executed 846 times by 1 test: return false; Executed by:
| 846 | ||||||||||||||||||||||||
4760 | } | - | ||||||||||||||||||||||||
4761 | break; executed 1077 times by 4 tests: break; Executed by:
| 1077 | ||||||||||||||||||||||||
4762 | case Sys: executed 383 times by 3 tests: case Sys: Executed by:
| 383 | ||||||||||||||||||||||||
4763 | parseExternalID_allowPublicID = false; | - | ||||||||||||||||||||||||
4764 | if (!parseExternalID()) {
| 104-279 | ||||||||||||||||||||||||
4765 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||||||||||||||
4766 | return false; executed 279 times by 1 test: return false; Executed by:
| 279 | ||||||||||||||||||||||||
4767 | } | - | ||||||||||||||||||||||||
4768 | thisPublicId = publicId; | - | ||||||||||||||||||||||||
4769 | thisSystemId = systemId; | - | ||||||||||||||||||||||||
4770 | break; executed 104 times by 3 tests: break; Executed by:
| 104 | ||||||||||||||||||||||||
4771 | case MP: executed 1558 times by 2 tests: case MP: Executed by:
| 1558 | ||||||||||||||||||||||||
4772 | case MPR: never executed: case MPR: | 0 | ||||||||||||||||||||||||
4773 | if (!next_eat_ws()) {
| 673-885 | ||||||||||||||||||||||||
4774 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||||||||||||||
4775 | return false; executed 885 times by 1 test: return false; Executed by:
| 885 | ||||||||||||||||||||||||
4776 | } | - | ||||||||||||||||||||||||
4777 | break; executed 673 times by 2 tests: break; Executed by:
| 673 | ||||||||||||||||||||||||
4778 | case PER: executed 50 times by 1 test: case PER: Executed by:
| 50 | ||||||||||||||||||||||||
4779 | parsePEReference_context = InDTD; | - | ||||||||||||||||||||||||
4780 | if (!parsePEReference()) {
| 20-30 | ||||||||||||||||||||||||
4781 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||||||||||||||
4782 | return false; executed 20 times by 1 test: return false; Executed by:
| 20 | ||||||||||||||||||||||||
4783 | } | - | ||||||||||||||||||||||||
4784 | break; executed 30 times by 1 test: break; Executed by:
| 30 | ||||||||||||||||||||||||
4785 | case Mup: executed 2873 times by 2 tests: case Mup: Executed by:
| 2873 | ||||||||||||||||||||||||
4786 | if (dtdRecursionLimit > 0 && parameterEntities.size() > dtdRecursionLimit) {
| 0-2873 | ||||||||||||||||||||||||
4787 | reportParseError(QString::fromLatin1( | - | ||||||||||||||||||||||||
4788 | "DTD parsing exceeded recursion limit of %1.").arg(dtdRecursionLimit)); | - | ||||||||||||||||||||||||
4789 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4790 | } | - | ||||||||||||||||||||||||
4791 | if (!parseMarkupdecl()) {
| 412-2461 | ||||||||||||||||||||||||
4792 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||||||||||||||
4793 | return false; executed 2461 times by 1 test: return false; Executed by:
| 2461 | ||||||||||||||||||||||||
4794 | } | - | ||||||||||||||||||||||||
4795 | break; executed 412 times by 2 tests: break; Executed by:
| 412 | ||||||||||||||||||||||||
4796 | case MPE: executed 1505 times by 2 tests: case MPE: Executed by:
| 1505 | ||||||||||||||||||||||||
4797 | if (!next_eat_ws()) {
| 417-1088 | ||||||||||||||||||||||||
4798 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||||||||||||||
4799 | return false; executed 417 times by 1 test: return false; Executed by:
| 417 | ||||||||||||||||||||||||
4800 | } | - | ||||||||||||||||||||||||
4801 | break; executed 1088 times by 2 tests: break; Executed by:
| 1088 | ||||||||||||||||||||||||
4802 | case Done: executed 1868 times by 4 tests: case Done: Executed by:
| 1868 | ||||||||||||||||||||||||
4803 | if (lexicalHnd) {
| 6-1862 | ||||||||||||||||||||||||
4804 | if (!startDTDwasReported) {
| 359-1503 | ||||||||||||||||||||||||
4805 | startDTDwasReported = true; | - | ||||||||||||||||||||||||
4806 | if (!lexicalHnd->startDTD(doctype, publicId, systemId)) {
| 0-359 | ||||||||||||||||||||||||
4807 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
4808 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4809 | } | - | ||||||||||||||||||||||||
4810 | } executed 359 times by 3 tests: end of block Executed by:
| 359 | ||||||||||||||||||||||||
4811 | if (!lexicalHnd->endDTD()) {
| 0-1862 | ||||||||||||||||||||||||
4812 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
4813 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4814 | } | - | ||||||||||||||||||||||||
4815 | } executed 1862 times by 3 tests: end of block Executed by:
| 1862 | ||||||||||||||||||||||||
4816 | next(); | - | ||||||||||||||||||||||||
4817 | break; executed 1868 times by 4 tests: break; Executed by:
| 1868 | ||||||||||||||||||||||||
4818 | } | - | ||||||||||||||||||||||||
4819 | } executed 10252 times by 4 tests: end of block Executed by:
| 10252 | ||||||||||||||||||||||||
4820 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4821 | } | - | ||||||||||||||||||||||||
4822 | - | |||||||||||||||||||||||||
4823 | /* | - | ||||||||||||||||||||||||
4824 | Parse a ExternalID [75]. | - | ||||||||||||||||||||||||
4825 | - | |||||||||||||||||||||||||
4826 | If allowPublicID is true parse ExternalID [75] or PublicID [83]. | - | ||||||||||||||||||||||||
4827 | */ | - | ||||||||||||||||||||||||
4828 | bool QXmlSimpleReaderPrivate::parseExternalID() | - | ||||||||||||||||||||||||
4829 | { | - | ||||||||||||||||||||||||
4830 | const signed char Init = 0; | - | ||||||||||||||||||||||||
4831 | const signed char Sys = 1; // parse 'SYSTEM' | - | ||||||||||||||||||||||||
4832 | const signed char SysWS = 2; // parse the whitespace after 'SYSTEM' | - | ||||||||||||||||||||||||
4833 | const signed char SysSQ = 3; // parse SystemLiteral with ' | - | ||||||||||||||||||||||||
4834 | const signed char SysSQ2 = 4; // parse SystemLiteral with ' | - | ||||||||||||||||||||||||
4835 | const signed char SysDQ = 5; // parse SystemLiteral with " | - | ||||||||||||||||||||||||
4836 | const signed char SysDQ2 = 6; // parse SystemLiteral with " | - | ||||||||||||||||||||||||
4837 | const signed char Pub = 7; // parse 'PUBLIC' | - | ||||||||||||||||||||||||
4838 | const signed char PubWS = 8; // parse the whitespace after 'PUBLIC' | - | ||||||||||||||||||||||||
4839 | const signed char PubSQ = 9; // parse PubidLiteral with ' | - | ||||||||||||||||||||||||
4840 | const signed char PubSQ2 = 10; // parse PubidLiteral with ' | - | ||||||||||||||||||||||||
4841 | const signed char PubDQ = 11; // parse PubidLiteral with " | - | ||||||||||||||||||||||||
4842 | const signed char PubDQ2 = 12; // parse PubidLiteral with " | - | ||||||||||||||||||||||||
4843 | const signed char PubE = 13; // finished parsing the PubidLiteral | - | ||||||||||||||||||||||||
4844 | const signed char PubWS2 = 14; // parse the whitespace after the PubidLiteral | - | ||||||||||||||||||||||||
4845 | const signed char PDone = 15; // done if allowPublicID is true | - | ||||||||||||||||||||||||
4846 | const signed char Done = 16; | - | ||||||||||||||||||||||||
4847 | - | |||||||||||||||||||||||||
4848 | const signed char InpSQ = 0; // ' | - | ||||||||||||||||||||||||
4849 | const signed char InpDQ = 1; // " | - | ||||||||||||||||||||||||
4850 | const signed char InpS = 2; // S | - | ||||||||||||||||||||||||
4851 | const signed char InpP = 3; // P | - | ||||||||||||||||||||||||
4852 | const signed char InpWs = 4; // white space | - | ||||||||||||||||||||||||
4853 | const signed char InpUnknown = 5; | - | ||||||||||||||||||||||||
4854 | - | |||||||||||||||||||||||||
4855 | static const signed char table[15][6] = { | - | ||||||||||||||||||||||||
4856 | /* InpSQ InpDQ InpS InpP InpWs InpUnknown */ | - | ||||||||||||||||||||||||
4857 | { -1, -1, Sys, Pub, -1, -1 }, // Init | - | ||||||||||||||||||||||||
4858 | { -1, -1, -1, -1, SysWS, -1 }, // Sys | - | ||||||||||||||||||||||||
4859 | { SysSQ, SysDQ, -1, -1, -1, -1 }, // SysWS | - | ||||||||||||||||||||||||
4860 | { Done, SysSQ2, SysSQ2, SysSQ2, SysSQ2, SysSQ2 }, // SysSQ | - | ||||||||||||||||||||||||
4861 | { Done, SysSQ2, SysSQ2, SysSQ2, SysSQ2, SysSQ2 }, // SysSQ2 | - | ||||||||||||||||||||||||
4862 | { SysDQ2, Done, SysDQ2, SysDQ2, SysDQ2, SysDQ2 }, // SysDQ | - | ||||||||||||||||||||||||
4863 | { SysDQ2, Done, SysDQ2, SysDQ2, SysDQ2, SysDQ2 }, // SysDQ2 | - | ||||||||||||||||||||||||
4864 | { -1, -1, -1, -1, PubWS, -1 }, // Pub | - | ||||||||||||||||||||||||
4865 | { PubSQ, PubDQ, -1, -1, -1, -1 }, // PubWS | - | ||||||||||||||||||||||||
4866 | { PubE, -1, PubSQ2, PubSQ2, PubSQ2, PubSQ2 }, // PubSQ | - | ||||||||||||||||||||||||
4867 | { PubE, -1, PubSQ2, PubSQ2, PubSQ2, PubSQ2 }, // PubSQ2 | - | ||||||||||||||||||||||||
4868 | { -1, PubE, PubDQ2, PubDQ2, PubDQ2, PubDQ2 }, // PubDQ | - | ||||||||||||||||||||||||
4869 | { -1, PubE, PubDQ2, PubDQ2, PubDQ2, PubDQ2 }, // PubDQ2 | - | ||||||||||||||||||||||||
4870 | { PDone, PDone, PDone, PDone, PubWS2, PDone }, // PubE | - | ||||||||||||||||||||||||
4871 | { SysSQ, SysDQ, PDone, PDone, PDone, PDone } // PubWS2 | - | ||||||||||||||||||||||||
4872 | }; | - | ||||||||||||||||||||||||
4873 | signed char state; | - | ||||||||||||||||||||||||
4874 | signed char input; | - | ||||||||||||||||||||||||
4875 | - | |||||||||||||||||||||||||
4876 | if (parseStack==0 || parseStack->isEmpty()) {
| 164-3322 | ||||||||||||||||||||||||
4877 | systemId.clear(); | - | ||||||||||||||||||||||||
4878 | publicId.clear(); | - | ||||||||||||||||||||||||
4879 | state = Init; | - | ||||||||||||||||||||||||
4880 | } else { executed 686 times by 3 tests: end of block Executed by:
| 686 | ||||||||||||||||||||||||
4881 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
4882 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
4883 | qDebug("QXmlSimpleReader: parseExternalID (cont) in state %d", state); | - | ||||||||||||||||||||||||
4884 | #endif | - | ||||||||||||||||||||||||
4885 | if (!parseStack->isEmpty()) {
| 956-1844 | ||||||||||||||||||||||||
4886 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
4887 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 173-783 | ||||||||||||||||||||||||
4888 | parseStack->pop(); | - | ||||||||||||||||||||||||
4889 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
4890 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
4891 | #endif | - | ||||||||||||||||||||||||
4892 | } executed 173 times by 1 test: end of block Executed by:
| 173 | ||||||||||||||||||||||||
4893 | if (!(this->*function)()) {
| 341-615 | ||||||||||||||||||||||||
4894 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||||||||||||||
4895 | return false; executed 341 times by 1 test: return false; Executed by:
| 341 | ||||||||||||||||||||||||
4896 | } | - | ||||||||||||||||||||||||
4897 | } executed 615 times by 1 test: end of block Executed by:
| 615 | ||||||||||||||||||||||||
4898 | } executed 2459 times by 1 test: end of block Executed by:
| 2459 | ||||||||||||||||||||||||
4899 | - | |||||||||||||||||||||||||
4900 | for (;;) { | - | ||||||||||||||||||||||||
4901 | switch (state) { | - | ||||||||||||||||||||||||
4902 | case PDone: executed 22 times by 1 test: case PDone: Executed by:
| 22 | ||||||||||||||||||||||||
4903 | if (parseExternalID_allowPublicID) {
| 2-20 | ||||||||||||||||||||||||
4904 | publicId = string(); | - | ||||||||||||||||||||||||
4905 | return true; executed 20 times by 1 test: return true; Executed by:
| 20 | ||||||||||||||||||||||||
4906 | } else { | - | ||||||||||||||||||||||||
4907 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
4908 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
4909 | } | - | ||||||||||||||||||||||||
4910 | case Done: executed 664 times by 3 tests: case Done: Executed by:
| 664 | ||||||||||||||||||||||||
4911 | return true; executed 664 times by 3 tests: return true; Executed by:
| 664 | ||||||||||||||||||||||||
4912 | case -1: never executed: case -1: | 0 | ||||||||||||||||||||||||
4913 | // Error | - | ||||||||||||||||||||||||
4914 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
4915 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
4916 | } | - | ||||||||||||||||||||||||
4917 | - | |||||||||||||||||||||||||
4918 | if (atEnd()) {
| 1844-13326 | ||||||||||||||||||||||||
4919 | unexpectedEof(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||||||||||||||
4920 | return false; executed 1844 times by 1 test: return false; Executed by:
| 1844 | ||||||||||||||||||||||||
4921 | } | - | ||||||||||||||||||||||||
4922 | if (is_S(c)) {
| 981-12345 | ||||||||||||||||||||||||
4923 | input = InpWs; | - | ||||||||||||||||||||||||
4924 | } else if (c == QLatin1Char('\'')) { executed 981 times by 3 tests: end of block Executed by:
| 20-12325 | ||||||||||||||||||||||||
4925 | input = InpSQ; | - | ||||||||||||||||||||||||
4926 | } else if (c == QLatin1Char('"')) { executed 20 times by 1 test: end of block Executed by:
| 20-10732 | ||||||||||||||||||||||||
4927 | input = InpDQ; | - | ||||||||||||||||||||||||
4928 | } else if (c == QLatin1Char('S')) { executed 1593 times by 3 tests: end of block Executed by:
| 545-10187 | ||||||||||||||||||||||||
4929 | input = InpS; | - | ||||||||||||||||||||||||
4930 | } else if (c == QLatin1Char('P')) { executed 545 times by 2 tests: end of block Executed by:
| 142-10045 | ||||||||||||||||||||||||
4931 | input = InpP; | - | ||||||||||||||||||||||||
4932 | } else { executed 142 times by 2 tests: end of block Executed by:
| 142 | ||||||||||||||||||||||||
4933 | input = InpUnknown; | - | ||||||||||||||||||||||||
4934 | } executed 10045 times by 3 tests: end of block Executed by:
| 10045 | ||||||||||||||||||||||||
4935 | state = table[state][input]; | - | ||||||||||||||||||||||||
4936 | - | |||||||||||||||||||||||||
4937 | switch (state) { | - | ||||||||||||||||||||||||
4938 | case Sys: executed 544 times by 2 tests: case Sys: Executed by:
| 544 | ||||||||||||||||||||||||
4939 | parseString_s = QLatin1String("SYSTEM"); | - | ||||||||||||||||||||||||
4940 | if (!parseString()) {
| 152-392 | ||||||||||||||||||||||||
4941 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||||||||||||||
4942 | return false; executed 392 times by 1 test: return false; Executed by:
| 392 | ||||||||||||||||||||||||
4943 | } | - | ||||||||||||||||||||||||
4944 | break; executed 152 times by 2 tests: break; Executed by:
| 152 | ||||||||||||||||||||||||
4945 | case SysWS: executed 544 times by 2 tests: case SysWS: Executed by:
| 544 | ||||||||||||||||||||||||
4946 | if (!eat_ws()) {
| 133-411 | ||||||||||||||||||||||||
4947 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||||||||||||||
4948 | return false; executed 133 times by 1 test: return false; Executed by:
| 133 | ||||||||||||||||||||||||
4949 | } | - | ||||||||||||||||||||||||
4950 | break; executed 411 times by 2 tests: break; Executed by:
| 411 | ||||||||||||||||||||||||
4951 | case SysSQ: never executed: case SysSQ: | 0 | ||||||||||||||||||||||||
4952 | case SysDQ: executed 664 times by 3 tests: case SysDQ: Executed by:
| 664 | ||||||||||||||||||||||||
4953 | stringClear(); | - | ||||||||||||||||||||||||
4954 | next(); | - | ||||||||||||||||||||||||
4955 | break; executed 664 times by 3 tests: break; Executed by:
| 664 | ||||||||||||||||||||||||
4956 | case SysSQ2: never executed: case SysSQ2: | 0 | ||||||||||||||||||||||||
4957 | case SysDQ2: executed 7824 times by 3 tests: case SysDQ2: Executed by:
| 7824 | ||||||||||||||||||||||||
4958 | stringAddC(); | - | ||||||||||||||||||||||||
4959 | next(); | - | ||||||||||||||||||||||||
4960 | break; executed 7824 times by 3 tests: break; Executed by:
| 7824 | ||||||||||||||||||||||||
4961 | case Pub: executed 142 times by 2 tests: case Pub: Executed by:
| 142 | ||||||||||||||||||||||||
4962 | parseString_s = QLatin1String("PUBLIC"); | - | ||||||||||||||||||||||||
4963 | if (!parseString()) {
| 50-92 | ||||||||||||||||||||||||
4964 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||||||||||||||
4965 | return false; executed 50 times by 1 test: return false; Executed by:
| 50 | ||||||||||||||||||||||||
4966 | } | - | ||||||||||||||||||||||||
4967 | break; executed 92 times by 2 tests: break; Executed by:
| 92 | ||||||||||||||||||||||||
4968 | case PubWS: executed 142 times by 2 tests: case PubWS: Executed by:
| 142 | ||||||||||||||||||||||||
4969 | if (!eat_ws()) {
| 22-120 | ||||||||||||||||||||||||
4970 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||||||||||||||
4971 | return false; executed 22 times by 1 test: return false; Executed by:
| 22 | ||||||||||||||||||||||||
4972 | } | - | ||||||||||||||||||||||||
4973 | break; executed 120 times by 2 tests: break; Executed by:
| 120 | ||||||||||||||||||||||||
4974 | case PubSQ: executed 10 times by 1 test: case PubSQ: Executed by:
| 10 | ||||||||||||||||||||||||
4975 | case PubDQ: executed 132 times by 2 tests: case PubDQ: Executed by:
| 132 | ||||||||||||||||||||||||
4976 | stringClear(); | - | ||||||||||||||||||||||||
4977 | next(); | - | ||||||||||||||||||||||||
4978 | break; executed 142 times by 2 tests: break; Executed by:
| 142 | ||||||||||||||||||||||||
4979 | case PubSQ2: executed 80 times by 1 test: case PubSQ2: Executed by:
| 80 | ||||||||||||||||||||||||
4980 | case PubDQ2: executed 2296 times by 2 tests: case PubDQ2: Executed by:
| 2296 | ||||||||||||||||||||||||
4981 | stringAddC(); | - | ||||||||||||||||||||||||
4982 | next(); | - | ||||||||||||||||||||||||
4983 | break; executed 2376 times by 2 tests: break; Executed by:
| 2376 | ||||||||||||||||||||||||
4984 | case PubE: executed 142 times by 2 tests: case PubE: Executed by:
| 142 | ||||||||||||||||||||||||
4985 | next(); | - | ||||||||||||||||||||||||
4986 | break; executed 142 times by 2 tests: break; Executed by:
| 142 | ||||||||||||||||||||||||
4987 | case PubWS2: executed 120 times by 2 tests: case PubWS2: Executed by:
| 120 | ||||||||||||||||||||||||
4988 | publicId = string(); | - | ||||||||||||||||||||||||
4989 | if (!eat_ws()) {
| 18-102 | ||||||||||||||||||||||||
4990 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||||||||||||||
4991 | return false; executed 18 times by 1 test: return false; Executed by:
| 18 | ||||||||||||||||||||||||
4992 | } | - | ||||||||||||||||||||||||
4993 | break; executed 102 times by 2 tests: break; Executed by:
| 102 | ||||||||||||||||||||||||
4994 | case Done: executed 664 times by 3 tests: case Done: Executed by:
| 664 | ||||||||||||||||||||||||
4995 | systemId = string(); | - | ||||||||||||||||||||||||
4996 | next(); | - | ||||||||||||||||||||||||
4997 | break; executed 664 times by 3 tests: break; Executed by:
| 664 | ||||||||||||||||||||||||
4998 | } | - | ||||||||||||||||||||||||
4999 | } executed 12711 times by 3 tests: end of block Executed by:
| 12711 | ||||||||||||||||||||||||
5000 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5001 | } | - | ||||||||||||||||||||||||
5002 | - | |||||||||||||||||||||||||
5003 | /* | - | ||||||||||||||||||||||||
5004 | Parse a markupdecl [29]. | - | ||||||||||||||||||||||||
5005 | */ | - | ||||||||||||||||||||||||
5006 | bool QXmlSimpleReaderPrivate::parseMarkupdecl() | - | ||||||||||||||||||||||||
5007 | { | - | ||||||||||||||||||||||||
5008 | const signed char Init = 0; | - | ||||||||||||||||||||||||
5009 | const signed char Lt = 1; // < was read | - | ||||||||||||||||||||||||
5010 | const signed char Em = 2; // ! was read | - | ||||||||||||||||||||||||
5011 | const signed char CE = 3; // E was read | - | ||||||||||||||||||||||||
5012 | const signed char Qm = 4; // ? was read | - | ||||||||||||||||||||||||
5013 | const signed char Dash = 5; // - was read | - | ||||||||||||||||||||||||
5014 | const signed char CA = 6; // A was read | - | ||||||||||||||||||||||||
5015 | const signed char CEL = 7; // EL was read | - | ||||||||||||||||||||||||
5016 | const signed char CEN = 8; // EN was read | - | ||||||||||||||||||||||||
5017 | const signed char CN = 9; // N was read | - | ||||||||||||||||||||||||
5018 | const signed char Done = 10; | - | ||||||||||||||||||||||||
5019 | - | |||||||||||||||||||||||||
5020 | const signed char InpLt = 0; // < | - | ||||||||||||||||||||||||
5021 | const signed char InpQm = 1; // ? | - | ||||||||||||||||||||||||
5022 | const signed char InpEm = 2; // ! | - | ||||||||||||||||||||||||
5023 | const signed char InpDash = 3; // - | - | ||||||||||||||||||||||||
5024 | const signed char InpA = 4; // A | - | ||||||||||||||||||||||||
5025 | const signed char InpE = 5; // E | - | ||||||||||||||||||||||||
5026 | const signed char InpL = 6; // L | - | ||||||||||||||||||||||||
5027 | const signed char InpN = 7; // N | - | ||||||||||||||||||||||||
5028 | const signed char InpUnknown = 8; | - | ||||||||||||||||||||||||
5029 | - | |||||||||||||||||||||||||
5030 | static const signed char table[4][9] = { | - | ||||||||||||||||||||||||
5031 | /* InpLt InpQm InpEm InpDash InpA InpE InpL InpN InpUnknown */ | - | ||||||||||||||||||||||||
5032 | { Lt, -1, -1, -1, -1, -1, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
5033 | { -1, Qm, Em, -1, -1, -1, -1, -1, -1 }, // Lt | - | ||||||||||||||||||||||||
5034 | { -1, -1, -1, Dash, CA, CE, -1, CN, -1 }, // Em | - | ||||||||||||||||||||||||
5035 | { -1, -1, -1, -1, -1, -1, CEL, CEN, -1 } // CE | - | ||||||||||||||||||||||||
5036 | }; | - | ||||||||||||||||||||||||
5037 | signed char state; | - | ||||||||||||||||||||||||
5038 | signed char input; | - | ||||||||||||||||||||||||
5039 | - | |||||||||||||||||||||||||
5040 | if (parseStack==0 || parseStack->isEmpty()) {
| 456-21658 | ||||||||||||||||||||||||
5041 | state = Init; | - | ||||||||||||||||||||||||
5042 | } else { executed 2873 times by 2 tests: end of block Executed by:
| 2873 | ||||||||||||||||||||||||
5043 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
5044 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5045 | qDebug("QXmlSimpleReader: parseMarkupdecl (cont) in state %d", state); | - | ||||||||||||||||||||||||
5046 | #endif | - | ||||||||||||||||||||||||
5047 | if (!parseStack->isEmpty()) {
| 2353-16888 | ||||||||||||||||||||||||
5048 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
5049 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 0-16888 | ||||||||||||||||||||||||
5050 | parseStack->pop(); | - | ||||||||||||||||||||||||
5051 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5052 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
5053 | #endif | - | ||||||||||||||||||||||||
5054 | } never executed: end of block | 0 | ||||||||||||||||||||||||
5055 | if (!(this->*function)()) {
| 2408-14480 | ||||||||||||||||||||||||
5056 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||||||||||||||
5057 | return false; executed 14480 times by 1 test: return false; Executed by:
| 14480 | ||||||||||||||||||||||||
5058 | } | - | ||||||||||||||||||||||||
5059 | } executed 2408 times by 1 test: end of block Executed by:
| 2408 | ||||||||||||||||||||||||
5060 | } executed 4761 times by 1 test: end of block Executed by:
| 4761 | ||||||||||||||||||||||||
5061 | - | |||||||||||||||||||||||||
5062 | for (;;) { | - | ||||||||||||||||||||||||
5063 | switch (state) { | - | ||||||||||||||||||||||||
5064 | case Qm: never executed: case Qm: | 0 | ||||||||||||||||||||||||
5065 | if (contentHnd) {
| 0 | ||||||||||||||||||||||||
5066 | if (!contentHnd->processingInstruction(name(),string())) {
| 0 | ||||||||||||||||||||||||
5067 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
5068 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5069 | } | - | ||||||||||||||||||||||||
5070 | } never executed: end of block | 0 | ||||||||||||||||||||||||
5071 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
5072 | case Dash: executed 17 times by 2 tests: case Dash: Executed by:
| 17 | ||||||||||||||||||||||||
5073 | if (lexicalHnd) {
| 6-11 | ||||||||||||||||||||||||
5074 | if (!lexicalHnd->comment(string())) {
| 0-11 | ||||||||||||||||||||||||
5075 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
5076 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5077 | } | - | ||||||||||||||||||||||||
5078 | } executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||||||||
5079 | return true; executed 17 times by 2 tests: return true; Executed by:
| 17 | ||||||||||||||||||||||||
5080 | case CA: executed 536 times by 1 test: case CA: Executed by:
| 536 | ||||||||||||||||||||||||
5081 | return true; executed 536 times by 1 test: return true; Executed by:
| 536 | ||||||||||||||||||||||||
5082 | case CEL: executed 1561 times by 1 test: case CEL: Executed by:
| 1561 | ||||||||||||||||||||||||
5083 | return true; executed 1561 times by 1 test: return true; Executed by:
| 1561 | ||||||||||||||||||||||||
5084 | case CEN: executed 652 times by 2 tests: case CEN: Executed by:
| 652 | ||||||||||||||||||||||||
5085 | return true; executed 652 times by 2 tests: return true; Executed by:
| 652 | ||||||||||||||||||||||||
5086 | case CN: executed 54 times by 1 test: case CN: Executed by:
| 54 | ||||||||||||||||||||||||
5087 | return true; executed 54 times by 1 test: return true; Executed by:
| 54 | ||||||||||||||||||||||||
5088 | case Done: never executed: case Done: | 0 | ||||||||||||||||||||||||
5089 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
5090 | case -1: executed 3 times by 1 test: case -1: Executed by:
| 3 | ||||||||||||||||||||||||
5091 | // Error | - | ||||||||||||||||||||||||
5092 | reportParseError(QLatin1String(XMLERR_LETTEREXPECTED)); | - | ||||||||||||||||||||||||
5093 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
5094 | } | - | ||||||||||||||||||||||||
5095 | - | |||||||||||||||||||||||||
5096 | if (atEnd()) {
| 2353-10866 | ||||||||||||||||||||||||
5097 | unexpectedEof(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||||||||||||||
5098 | return false; executed 2353 times by 1 test: return false; Executed by:
| 2353 | ||||||||||||||||||||||||
5099 | } | - | ||||||||||||||||||||||||
5100 | if (c == QLatin1Char('<')) {
| 2873-7993 | ||||||||||||||||||||||||
5101 | input = InpLt; | - | ||||||||||||||||||||||||
5102 | } else if (c == QLatin1Char('?')) { executed 2873 times by 2 tests: end of block Executed by:
| 1-7992 | ||||||||||||||||||||||||
5103 | input = InpQm; | - | ||||||||||||||||||||||||
5104 | } else if (c == QLatin1Char('!')) { executed 1 time by 1 test: end of block Executed by:
| 1-5121 | ||||||||||||||||||||||||
5105 | input = InpEm; | - | ||||||||||||||||||||||||
5106 | } else if (c == QLatin1Char('-')) { executed 2871 times by 2 tests: end of block Executed by:
| 17-5104 | ||||||||||||||||||||||||
5107 | input = InpDash; | - | ||||||||||||||||||||||||
5108 | } else if (c == QLatin1Char('A')) { executed 17 times by 2 tests: end of block Executed by:
| 17-4555 | ||||||||||||||||||||||||
5109 | input = InpA; | - | ||||||||||||||||||||||||
5110 | } else if (c == QLatin1Char('E')) { executed 549 times by 1 test: end of block Executed by:
| 549-2306 | ||||||||||||||||||||||||
5111 | input = InpE; | - | ||||||||||||||||||||||||
5112 | } else if (c == QLatin1Char('L')) { executed 2249 times by 2 tests: end of block Executed by:
| 724-2249 | ||||||||||||||||||||||||
5113 | input = InpL; | - | ||||||||||||||||||||||||
5114 | } else if (c == QLatin1Char('N')) { executed 1582 times by 1 test: end of block Executed by:
| 3-1582 | ||||||||||||||||||||||||
5115 | input = InpN; | - | ||||||||||||||||||||||||
5116 | } else { executed 721 times by 2 tests: end of block Executed by:
| 721 | ||||||||||||||||||||||||
5117 | input = InpUnknown; | - | ||||||||||||||||||||||||
5118 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||
5119 | state = table[state][input]; | - | ||||||||||||||||||||||||
5120 | - | |||||||||||||||||||||||||
5121 | switch (state) { | - | ||||||||||||||||||||||||
5122 | case Lt: executed 2873 times by 2 tests: case Lt: Executed by:
| 2873 | ||||||||||||||||||||||||
5123 | next(); | - | ||||||||||||||||||||||||
5124 | break; executed 2873 times by 2 tests: break; Executed by:
| 2873 | ||||||||||||||||||||||||
5125 | case Em: executed 2871 times by 2 tests: case Em: Executed by:
| 2871 | ||||||||||||||||||||||||
5126 | next(); | - | ||||||||||||||||||||||||
5127 | break; executed 2871 times by 2 tests: break; Executed by:
| 2871 | ||||||||||||||||||||||||
5128 | case CE: executed 2249 times by 2 tests: case CE: Executed by:
| 2249 | ||||||||||||||||||||||||
5129 | next(); | - | ||||||||||||||||||||||||
5130 | break; executed 2249 times by 2 tests: break; Executed by:
| 2249 | ||||||||||||||||||||||||
5131 | case Qm: executed 1 time by 1 test: case Qm: Executed by:
| 1 | ||||||||||||||||||||||||
5132 | parsePI_xmldecl = false; | - | ||||||||||||||||||||||||
5133 | if (!parsePI()) {
| 0-1 | ||||||||||||||||||||||||
5134 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||||||||||||||
5135 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
5136 | } | - | ||||||||||||||||||||||||
5137 | break; never executed: break; | 0 | ||||||||||||||||||||||||
5138 | case Dash: executed 17 times by 2 tests: case Dash: Executed by:
| 17 | ||||||||||||||||||||||||
5139 | if (!parseComment()) {
| 8-9 | ||||||||||||||||||||||||
5140 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||||||||||||||
5141 | return false; executed 9 times by 1 test: return false; Executed by:
| 9 | ||||||||||||||||||||||||
5142 | } | - | ||||||||||||||||||||||||
5143 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
5144 | case CA: executed 549 times by 1 test: case CA: Executed by:
| 549 | ||||||||||||||||||||||||
5145 | if (!parseAttlistDecl()) {
| 59-490 | ||||||||||||||||||||||||
5146 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||||||||||||||
5147 | return false; executed 490 times by 1 test: return false; Executed by:
| 490 | ||||||||||||||||||||||||
5148 | } | - | ||||||||||||||||||||||||
5149 | break; executed 59 times by 1 test: break; Executed by:
| 59 | ||||||||||||||||||||||||
5150 | case CEL: executed 1582 times by 1 test: case CEL: Executed by:
| 1582 | ||||||||||||||||||||||||
5151 | if (!parseElementDecl()) {
| 206-1376 | ||||||||||||||||||||||||
5152 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||||||||||||||
5153 | return false; executed 1376 times by 1 test: return false; Executed by:
| 1376 | ||||||||||||||||||||||||
5154 | } | - | ||||||||||||||||||||||||
5155 | break; executed 206 times by 1 test: break; Executed by:
| 206 | ||||||||||||||||||||||||
5156 | case CEN: executed 667 times by 2 tests: case CEN: Executed by:
| 667 | ||||||||||||||||||||||||
5157 | if (!parseEntityDecl()) {
| 130-537 | ||||||||||||||||||||||||
5158 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||||||||||||||
5159 | return false; executed 537 times by 1 test: return false; Executed by:
| 537 | ||||||||||||||||||||||||
5160 | } | - | ||||||||||||||||||||||||
5161 | break; executed 130 times by 2 tests: break; Executed by:
| 130 | ||||||||||||||||||||||||
5162 | case CN: executed 54 times by 1 test: case CN: Executed by:
| 54 | ||||||||||||||||||||||||
5163 | if (!parseNotationDecl()) {
| 9-45 | ||||||||||||||||||||||||
5164 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||||||||||||||
5165 | return false; executed 45 times by 1 test: return false; Executed by:
| 45 | ||||||||||||||||||||||||
5166 | } | - | ||||||||||||||||||||||||
5167 | break; executed 9 times by 1 test: break; Executed by:
| 9 | ||||||||||||||||||||||||
5168 | } | - | ||||||||||||||||||||||||
5169 | } executed 8408 times by 2 tests: end of block Executed by:
| 8408 | ||||||||||||||||||||||||
5170 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5171 | } | - | ||||||||||||||||||||||||
5172 | - | |||||||||||||||||||||||||
5173 | /* | - | ||||||||||||||||||||||||
5174 | Parse a PEReference [69] | - | ||||||||||||||||||||||||
5175 | */ | - | ||||||||||||||||||||||||
5176 | bool QXmlSimpleReaderPrivate::parsePEReference() | - | ||||||||||||||||||||||||
5177 | { | - | ||||||||||||||||||||||||
5178 | const signed char Init = 0; | - | ||||||||||||||||||||||||
5179 | const signed char Next = 1; | - | ||||||||||||||||||||||||
5180 | const signed char Name = 2; | - | ||||||||||||||||||||||||
5181 | const signed char NameR = 3; // same as Name, but already reported | - | ||||||||||||||||||||||||
5182 | const signed char Done = 4; | - | ||||||||||||||||||||||||
5183 | - | |||||||||||||||||||||||||
5184 | const signed char InpSemi = 0; // ; | - | ||||||||||||||||||||||||
5185 | const signed char InpPer = 1; // % | - | ||||||||||||||||||||||||
5186 | const signed char InpUnknown = 2; | - | ||||||||||||||||||||||||
5187 | - | |||||||||||||||||||||||||
5188 | static const signed char table[4][3] = { | - | ||||||||||||||||||||||||
5189 | /* InpSemi InpPer InpUnknown */ | - | ||||||||||||||||||||||||
5190 | { -1, Next, -1 }, // Init | - | ||||||||||||||||||||||||
5191 | { -1, -1, Name }, // Next | - | ||||||||||||||||||||||||
5192 | { Done, -1, -1 }, // Name | - | ||||||||||||||||||||||||
5193 | { Done, -1, -1 } // NameR | - | ||||||||||||||||||||||||
5194 | }; | - | ||||||||||||||||||||||||
5195 | signed char state; | - | ||||||||||||||||||||||||
5196 | signed char input; | - | ||||||||||||||||||||||||
5197 | - | |||||||||||||||||||||||||
5198 | if (parseStack==0 || parseStack->isEmpty()) {
| 20-70 | ||||||||||||||||||||||||
5199 | state = Init; | - | ||||||||||||||||||||||||
5200 | } else { executed 65 times by 1 test: end of block Executed by:
| 65 | ||||||||||||||||||||||||
5201 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
5202 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5203 | qDebug("QXmlSimpleReader: parsePEReference (cont) in state %d", state); | - | ||||||||||||||||||||||||
5204 | #endif | - | ||||||||||||||||||||||||
5205 | if (!parseStack->isEmpty()) {
| 7-18 | ||||||||||||||||||||||||
5206 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
5207 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 0-7 | ||||||||||||||||||||||||
5208 | parseStack->pop(); | - | ||||||||||||||||||||||||
5209 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5210 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
5211 | #endif | - | ||||||||||||||||||||||||
5212 | } never executed: end of block | 0 | ||||||||||||||||||||||||
5213 | if (!(this->*function)()) {
| 0-7 | ||||||||||||||||||||||||
5214 | parseFailed(&QXmlSimpleReaderPrivate::parsePEReference, state); | - | ||||||||||||||||||||||||
5215 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5216 | } | - | ||||||||||||||||||||||||
5217 | } executed 7 times by 1 test: end of block Executed by:
| 7 | ||||||||||||||||||||||||
5218 | } executed 25 times by 1 test: end of block Executed by:
| 25 | ||||||||||||||||||||||||
5219 | - | |||||||||||||||||||||||||
5220 | for (;;) { | - | ||||||||||||||||||||||||
5221 | switch (state) { | - | ||||||||||||||||||||||||
5222 | case Name: executed 65 times by 1 test: case Name: Executed by:
| 65 | ||||||||||||||||||||||||
5223 | { | - | ||||||||||||||||||||||||
5224 | bool skipIt = true; | - | ||||||||||||||||||||||||
5225 | QString xmlRefString; | - | ||||||||||||||||||||||||
5226 | - | |||||||||||||||||||||||||
5227 | QMap<QString,QString>::Iterator it; | - | ||||||||||||||||||||||||
5228 | it = parameterEntities.find(ref()); | - | ||||||||||||||||||||||||
5229 | if (it != parameterEntities.end()) {
| 25-40 | ||||||||||||||||||||||||
5230 | skipIt = false; | - | ||||||||||||||||||||||||
5231 | xmlRefString = *it; | - | ||||||||||||||||||||||||
5232 | } else if (entityRes) { executed 25 times by 1 test: end of block Executed by:
| 0-40 | ||||||||||||||||||||||||
5233 | QMap<QString,QXmlSimpleReaderPrivate::ExternParameterEntity>::Iterator it2; | - | ||||||||||||||||||||||||
5234 | it2 = externParameterEntities.find(ref()); | - | ||||||||||||||||||||||||
5235 | QXmlInputSource *ret = 0; | - | ||||||||||||||||||||||||
5236 | if (it2 != externParameterEntities.end()) {
| 0-40 | ||||||||||||||||||||||||
5237 | if (!entityRes->resolveEntity((*it2).publicId, (*it2).systemId, ret)) {
| 0-40 | ||||||||||||||||||||||||
5238 | delete ret; | - | ||||||||||||||||||||||||
5239 | reportParseError(entityRes->errorString()); | - | ||||||||||||||||||||||||
5240 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5241 | } | - | ||||||||||||||||||||||||
5242 | if (ret) {
| 0-40 | ||||||||||||||||||||||||
5243 | QString buffer = ret->data(); | - | ||||||||||||||||||||||||
5244 | while (!buffer.isEmpty()) {
| 0 | ||||||||||||||||||||||||
5245 | xmlRefString += buffer; | - | ||||||||||||||||||||||||
5246 | ret->fetchData(); | - | ||||||||||||||||||||||||
5247 | buffer = ret->data(); | - | ||||||||||||||||||||||||
5248 | } never executed: end of block | 0 | ||||||||||||||||||||||||
5249 | delete ret; | - | ||||||||||||||||||||||||
5250 | if (!stripTextDecl(xmlRefString)) {
| 0 | ||||||||||||||||||||||||
5251 | reportParseError(QLatin1String(XMLERR_ERRORINTEXTDECL)); | - | ||||||||||||||||||||||||
5252 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5253 | } | - | ||||||||||||||||||||||||
5254 | skipIt = false; | - | ||||||||||||||||||||||||
5255 | } never executed: end of block | 0 | ||||||||||||||||||||||||
5256 | } executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||||||||
5257 | } executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||||||||
5258 | - | |||||||||||||||||||||||||
5259 | if (skipIt) {
| 25-40 | ||||||||||||||||||||||||
5260 | if (contentHnd) {
| 0-40 | ||||||||||||||||||||||||
5261 | if (!contentHnd->skippedEntity(QLatin1Char('%') + ref())) {
| 0-40 | ||||||||||||||||||||||||
5262 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
5263 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5264 | } | - | ||||||||||||||||||||||||
5265 | } executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||||||||
5266 | } else { executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||||||||
5267 | if (parsePEReference_context == InEntityValue) {
| 10-15 | ||||||||||||||||||||||||
5268 | // Included in literal | - | ||||||||||||||||||||||||
5269 | if (!insertXmlRef(xmlRefString, ref(), true))
| 0-15 | ||||||||||||||||||||||||
5270 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5271 | } else if (parsePEReference_context == InDTD) { executed 15 times by 1 test: end of block Executed by:
| 0-15 | ||||||||||||||||||||||||
5272 | // Included as PE | - | ||||||||||||||||||||||||
5273 | if (!insertXmlRef(QLatin1Char(' ') + xmlRefString + QLatin1Char(' '), ref(), false))
| 0-10 | ||||||||||||||||||||||||
5274 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5275 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
5276 | } executed 25 times by 1 test: end of block Executed by:
| 25 | ||||||||||||||||||||||||
5277 | } | - | ||||||||||||||||||||||||
5278 | state = NameR; | - | ||||||||||||||||||||||||
5279 | break; executed 65 times by 1 test: break; Executed by:
| 65 | ||||||||||||||||||||||||
5280 | case Done: executed 65 times by 1 test: case Done: Executed by:
| 65 | ||||||||||||||||||||||||
5281 | return true; executed 65 times by 1 test: return true; Executed by:
| 65 | ||||||||||||||||||||||||
5282 | case -1: never executed: case -1: | 0 | ||||||||||||||||||||||||
5283 | // Error | - | ||||||||||||||||||||||||
5284 | reportParseError(QLatin1String(XMLERR_LETTEREXPECTED)); | - | ||||||||||||||||||||||||
5285 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5286 | } | - | ||||||||||||||||||||||||
5287 | - | |||||||||||||||||||||||||
5288 | if (atEnd()) {
| 18-195 | ||||||||||||||||||||||||
5289 | unexpectedEof(&QXmlSimpleReaderPrivate::parsePEReference, state); | - | ||||||||||||||||||||||||
5290 | return false; executed 18 times by 1 test: return false; Executed by:
| 18 | ||||||||||||||||||||||||
5291 | } | - | ||||||||||||||||||||||||
5292 | if (c == QLatin1Char(';')) {
| 65-130 | ||||||||||||||||||||||||
5293 | input = InpSemi; | - | ||||||||||||||||||||||||
5294 | } else if (c == QLatin1Char('%')) { executed 65 times by 1 test: end of block Executed by:
| 65 | ||||||||||||||||||||||||
5295 | input = InpPer; | - | ||||||||||||||||||||||||
5296 | } else { executed 65 times by 1 test: end of block Executed by:
| 65 | ||||||||||||||||||||||||
5297 | input = InpUnknown; | - | ||||||||||||||||||||||||
5298 | } executed 65 times by 1 test: end of block Executed by:
| 65 | ||||||||||||||||||||||||
5299 | state = table[state][input]; | - | ||||||||||||||||||||||||
5300 | - | |||||||||||||||||||||||||
5301 | switch (state) { | - | ||||||||||||||||||||||||
5302 | case Next: executed 65 times by 1 test: case Next: Executed by:
| 65 | ||||||||||||||||||||||||
5303 | next(); | - | ||||||||||||||||||||||||
5304 | break; executed 65 times by 1 test: break; Executed by:
| 65 | ||||||||||||||||||||||||
5305 | case Name: executed 65 times by 1 test: case Name: Executed by:
| 65 | ||||||||||||||||||||||||
5306 | case NameR: never executed: case NameR: | 0 | ||||||||||||||||||||||||
5307 | parseName_useRef = true; | - | ||||||||||||||||||||||||
5308 | if (!parseName()) {
| 7-58 | ||||||||||||||||||||||||
5309 | parseFailed(&QXmlSimpleReaderPrivate::parsePEReference, state); | - | ||||||||||||||||||||||||
5310 | return false; executed 7 times by 1 test: return false; Executed by:
| 7 | ||||||||||||||||||||||||
5311 | } | - | ||||||||||||||||||||||||
5312 | break; executed 58 times by 1 test: break; Executed by:
| 58 | ||||||||||||||||||||||||
5313 | case Done: executed 65 times by 1 test: case Done: Executed by:
| 65 | ||||||||||||||||||||||||
5314 | next(); | - | ||||||||||||||||||||||||
5315 | break; executed 65 times by 1 test: break; Executed by:
| 65 | ||||||||||||||||||||||||
5316 | } | - | ||||||||||||||||||||||||
5317 | } executed 188 times by 1 test: end of block Executed by:
| 188 | ||||||||||||||||||||||||
5318 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5319 | } | - | ||||||||||||||||||||||||
5320 | - | |||||||||||||||||||||||||
5321 | /* | - | ||||||||||||||||||||||||
5322 | Parse a AttlistDecl [52]. | - | ||||||||||||||||||||||||
5323 | - | |||||||||||||||||||||||||
5324 | Precondition: the beginning '<!' is already read and the head | - | ||||||||||||||||||||||||
5325 | stands on the 'A' of '<!ATTLIST' | - | ||||||||||||||||||||||||
5326 | */ | - | ||||||||||||||||||||||||
5327 | bool QXmlSimpleReaderPrivate::parseAttlistDecl() | - | ||||||||||||||||||||||||
5328 | { | - | ||||||||||||||||||||||||
5329 | const signed char Init = 0; | - | ||||||||||||||||||||||||
5330 | const signed char Attlist = 1; // parse the string "ATTLIST" | - | ||||||||||||||||||||||||
5331 | const signed char Ws = 2; // whitespace read | - | ||||||||||||||||||||||||
5332 | const signed char Name = 3; // parse name | - | ||||||||||||||||||||||||
5333 | const signed char Ws1 = 4; // whitespace read | - | ||||||||||||||||||||||||
5334 | const signed char Attdef = 5; // parse the AttDef | - | ||||||||||||||||||||||||
5335 | const signed char Ws2 = 6; // whitespace read | - | ||||||||||||||||||||||||
5336 | const signed char Atttype = 7; // parse the AttType | - | ||||||||||||||||||||||||
5337 | const signed char Ws3 = 8; // whitespace read | - | ||||||||||||||||||||||||
5338 | const signed char DDecH = 9; // DefaultDecl with # | - | ||||||||||||||||||||||||
5339 | const signed char DefReq = 10; // parse the string "REQUIRED" | - | ||||||||||||||||||||||||
5340 | const signed char DefImp = 11; // parse the string "IMPLIED" | - | ||||||||||||||||||||||||
5341 | const signed char DefFix = 12; // parse the string "FIXED" | - | ||||||||||||||||||||||||
5342 | const signed char Attval = 13; // parse the AttValue | - | ||||||||||||||||||||||||
5343 | const signed char Ws4 = 14; // whitespace read | - | ||||||||||||||||||||||||
5344 | const signed char Done = 15; | - | ||||||||||||||||||||||||
5345 | - | |||||||||||||||||||||||||
5346 | const signed char InpWs = 0; // white space | - | ||||||||||||||||||||||||
5347 | const signed char InpGt = 1; // > | - | ||||||||||||||||||||||||
5348 | const signed char InpHash = 2; // # | - | ||||||||||||||||||||||||
5349 | const signed char InpA = 3; // A | - | ||||||||||||||||||||||||
5350 | const signed char InpI = 4; // I | - | ||||||||||||||||||||||||
5351 | const signed char InpF = 5; // F | - | ||||||||||||||||||||||||
5352 | const signed char InpR = 6; // R | - | ||||||||||||||||||||||||
5353 | const signed char InpUnknown = 7; | - | ||||||||||||||||||||||||
5354 | - | |||||||||||||||||||||||||
5355 | static const signed char table[15][8] = { | - | ||||||||||||||||||||||||
5356 | /* InpWs InpGt InpHash InpA InpI InpF InpR InpUnknown */ | - | ||||||||||||||||||||||||
5357 | { -1, -1, -1, Attlist, -1, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
5358 | { Ws, -1, -1, -1, -1, -1, -1, -1 }, // Attlist | - | ||||||||||||||||||||||||
5359 | { -1, -1, -1, Name, Name, Name, Name, Name }, // Ws | - | ||||||||||||||||||||||||
5360 | { Ws1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef }, // Name | - | ||||||||||||||||||||||||
5361 | { -1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef }, // Ws1 | - | ||||||||||||||||||||||||
5362 | { Ws2, -1, -1, -1, -1, -1, -1, -1 }, // Attdef | - | ||||||||||||||||||||||||
5363 | { -1, Atttype, Atttype, Atttype, Atttype, Atttype, Atttype, Atttype }, // Ws2 | - | ||||||||||||||||||||||||
5364 | { Ws3, -1, -1, -1, -1, -1, -1, -1 }, // Attype | - | ||||||||||||||||||||||||
5365 | { -1, Attval, DDecH, Attval, Attval, Attval, Attval, Attval }, // Ws3 | - | ||||||||||||||||||||||||
5366 | { -1, -1, -1, -1, DefImp, DefFix, DefReq, -1 }, // DDecH | - | ||||||||||||||||||||||||
5367 | { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, // DefReq | - | ||||||||||||||||||||||||
5368 | { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, // DefImp | - | ||||||||||||||||||||||||
5369 | { Ws3, -1, -1, -1, -1, -1, -1, -1 }, // DefFix | - | ||||||||||||||||||||||||
5370 | { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, // Attval | - | ||||||||||||||||||||||||
5371 | { -1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef } // Ws4 | - | ||||||||||||||||||||||||
5372 | }; | - | ||||||||||||||||||||||||
5373 | signed char state; | - | ||||||||||||||||||||||||
5374 | signed char input; | - | ||||||||||||||||||||||||
5375 | - | |||||||||||||||||||||||||
5376 | if (parseStack==0 || parseStack->isEmpty()) {
| 72-5236 | ||||||||||||||||||||||||
5377 | state = Init; | - | ||||||||||||||||||||||||
5378 | } else { executed 549 times by 1 test: end of block Executed by:
| 549 | ||||||||||||||||||||||||
5379 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
5380 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5381 | qDebug("QXmlSimpleReader: parseAttlistDecl (cont) in state %d", state); | - | ||||||||||||||||||||||||
5382 | #endif | - | ||||||||||||||||||||||||
5383 | if (!parseStack->isEmpty()) {
| 428-4331 | ||||||||||||||||||||||||
5384 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
5385 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 589-3742 | ||||||||||||||||||||||||
5386 | parseStack->pop(); | - | ||||||||||||||||||||||||
5387 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5388 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
5389 | #endif | - | ||||||||||||||||||||||||
5390 | } executed 589 times by 1 test: end of block Executed by:
| 589 | ||||||||||||||||||||||||
5391 | if (!(this->*function)()) {
| 1729-2602 | ||||||||||||||||||||||||
5392 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5393 | return false; executed 1729 times by 1 test: return false; Executed by:
| 1729 | ||||||||||||||||||||||||
5394 | } | - | ||||||||||||||||||||||||
5395 | } executed 2602 times by 1 test: end of block Executed by:
| 2602 | ||||||||||||||||||||||||
5396 | } executed 3030 times by 1 test: end of block Executed by:
| 3030 | ||||||||||||||||||||||||
5397 | - | |||||||||||||||||||||||||
5398 | for (;;) { | - | ||||||||||||||||||||||||
5399 | switch (state) { | - | ||||||||||||||||||||||||
5400 | case Name: executed 548 times by 1 test: case Name: Executed by:
| 548 | ||||||||||||||||||||||||
5401 | attDeclEName = name(); | - | ||||||||||||||||||||||||
5402 | break; executed 548 times by 1 test: break; Executed by:
| 548 | ||||||||||||||||||||||||
5403 | case Attdef: executed 619 times by 1 test: case Attdef: Executed by:
| 619 | ||||||||||||||||||||||||
5404 | attDeclAName = name(); | - | ||||||||||||||||||||||||
5405 | break; executed 619 times by 1 test: break; Executed by:
| 619 | ||||||||||||||||||||||||
5406 | case Done: executed 536 times by 1 test: case Done: Executed by:
| 536 | ||||||||||||||||||||||||
5407 | return true; executed 536 times by 1 test: return true; Executed by:
| 536 | ||||||||||||||||||||||||
5408 | case -1: executed 5 times by 1 test: case -1: Executed by:
| 5 | ||||||||||||||||||||||||
5409 | // Error | - | ||||||||||||||||||||||||
5410 | reportParseError(QLatin1String(XMLERR_LETTEREXPECTED)); | - | ||||||||||||||||||||||||
5411 | return false; executed 5 times by 1 test: return false; Executed by:
| 5 | ||||||||||||||||||||||||
5412 | } | - | ||||||||||||||||||||||||
5413 | - | |||||||||||||||||||||||||
5414 | if (atEnd()) {
| 428-6889 | ||||||||||||||||||||||||
5415 | unexpectedEof(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5416 | return false; executed 428 times by 1 test: return false; Executed by:
| 428 | ||||||||||||||||||||||||
5417 | } | - | ||||||||||||||||||||||||
5418 | if (is_S(c)) {
| 2429-4460 | ||||||||||||||||||||||||
5419 | input = InpWs; | - | ||||||||||||||||||||||||
5420 | } else if (c == QLatin1Char('>')) { executed 2429 times by 1 test: end of block Executed by:
| 1062-3398 | ||||||||||||||||||||||||
5421 | input = InpGt; | - | ||||||||||||||||||||||||
5422 | } else if (c == QLatin1Char('#')) { executed 1062 times by 1 test: end of block Executed by:
| 428-2970 | ||||||||||||||||||||||||
5423 | input = InpHash; | - | ||||||||||||||||||||||||
5424 | } else if (c == QLatin1Char('A')) { executed 428 times by 1 test: end of block Executed by:
| 428-2411 | ||||||||||||||||||||||||
5425 | input = InpA; | - | ||||||||||||||||||||||||
5426 | } else if (c == QLatin1Char('I')) { executed 559 times by 1 test: end of block Executed by:
| 425-1986 | ||||||||||||||||||||||||
5427 | input = InpI; | - | ||||||||||||||||||||||||
5428 | } else if (c == QLatin1Char('F')) { executed 425 times by 1 test: end of block Executed by:
| 21-1965 | ||||||||||||||||||||||||
5429 | input = InpF; | - | ||||||||||||||||||||||||
5430 | } else if (c == QLatin1Char('R')) { executed 21 times by 1 test: end of block Executed by:
| 10-1955 | ||||||||||||||||||||||||
5431 | input = InpR; | - | ||||||||||||||||||||||||
5432 | } else { executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
5433 | input = InpUnknown; | - | ||||||||||||||||||||||||
5434 | } executed 1955 times by 1 test: end of block Executed by:
| 1955 | ||||||||||||||||||||||||
5435 | state = table[state][input]; | - | ||||||||||||||||||||||||
5436 | - | |||||||||||||||||||||||||
5437 | switch (state) { | - | ||||||||||||||||||||||||
5438 | case Attlist: executed 549 times by 1 test: case Attlist: Executed by:
| 549 | ||||||||||||||||||||||||
5439 | parseString_s = QLatin1String("ATTLIST"); | - | ||||||||||||||||||||||||
5440 | if (!parseString()) {
| 121-428 | ||||||||||||||||||||||||
5441 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5442 | return false; executed 428 times by 1 test: return false; Executed by:
| 428 | ||||||||||||||||||||||||
5443 | } | - | ||||||||||||||||||||||||
5444 | break; executed 121 times by 1 test: break; Executed by:
| 121 | ||||||||||||||||||||||||
5445 | case Ws: executed 549 times by 1 test: case Ws: Executed by:
| 549 | ||||||||||||||||||||||||
5446 | case Ws1: executed 548 times by 1 test: case Ws1: Executed by:
| 548 | ||||||||||||||||||||||||
5447 | case Ws2: executed 618 times by 1 test: case Ws2: Executed by:
| 618 | ||||||||||||||||||||||||
5448 | case Ws3: executed 633 times by 1 test: case Ws3: Executed by:
| 633 | ||||||||||||||||||||||||
5449 | if (!eat_ws()) {
| 545-1803 | ||||||||||||||||||||||||
5450 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5451 | return false; executed 545 times by 1 test: return false; Executed by:
| 545 | ||||||||||||||||||||||||
5452 | } | - | ||||||||||||||||||||||||
5453 | break; executed 1803 times by 1 test: break; Executed by:
| 1803 | ||||||||||||||||||||||||
5454 | case Name: executed 548 times by 1 test: case Name: Executed by:
| 548 | ||||||||||||||||||||||||
5455 | parseName_useRef = false; | - | ||||||||||||||||||||||||
5456 | if (!parseName()) {
| 147-401 | ||||||||||||||||||||||||
5457 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5458 | return false; executed 401 times by 1 test: return false; Executed by:
| 401 | ||||||||||||||||||||||||
5459 | } | - | ||||||||||||||||||||||||
5460 | break; executed 147 times by 1 test: break; Executed by:
| 147 | ||||||||||||||||||||||||
5461 | case Attdef: executed 619 times by 1 test: case Attdef: Executed by:
| 619 | ||||||||||||||||||||||||
5462 | parseName_useRef = false; | - | ||||||||||||||||||||||||
5463 | if (!parseName()) {
| 230-389 | ||||||||||||||||||||||||
5464 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5465 | return false; executed 230 times by 1 test: return false; Executed by:
| 230 | ||||||||||||||||||||||||
5466 | } | - | ||||||||||||||||||||||||
5467 | break; executed 389 times by 1 test: break; Executed by:
| 389 | ||||||||||||||||||||||||
5468 | case Atttype: executed 618 times by 1 test: case Atttype: Executed by:
| 618 | ||||||||||||||||||||||||
5469 | if (!parseAttType()) {
| 129-489 | ||||||||||||||||||||||||
5470 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5471 | return false; executed 489 times by 1 test: return false; Executed by:
| 489 | ||||||||||||||||||||||||
5472 | } | - | ||||||||||||||||||||||||
5473 | break; executed 129 times by 1 test: break; Executed by:
| 129 | ||||||||||||||||||||||||
5474 | case DDecH: executed 426 times by 1 test: case DDecH: Executed by:
| 426 | ||||||||||||||||||||||||
5475 | next(); | - | ||||||||||||||||||||||||
5476 | break; executed 426 times by 1 test: break; Executed by:
| 426 | ||||||||||||||||||||||||
5477 | case DefReq: executed 10 times by 1 test: case DefReq: Executed by:
| 10 | ||||||||||||||||||||||||
5478 | parseString_s = QLatin1String("REQUIRED"); | - | ||||||||||||||||||||||||
5479 | if (!parseString()) {
| 1-9 | ||||||||||||||||||||||||
5480 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5481 | return false; executed 9 times by 1 test: return false; Executed by:
| 9 | ||||||||||||||||||||||||
5482 | } | - | ||||||||||||||||||||||||
5483 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
5484 | case DefImp: executed 395 times by 1 test: case DefImp: Executed by:
| 395 | ||||||||||||||||||||||||
5485 | parseString_s = QLatin1String("IMPLIED"); | - | ||||||||||||||||||||||||
5486 | if (!parseString()) {
| 61-334 | ||||||||||||||||||||||||
5487 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5488 | return false; executed 334 times by 1 test: return false; Executed by:
| 334 | ||||||||||||||||||||||||
5489 | } | - | ||||||||||||||||||||||||
5490 | break; executed 61 times by 1 test: break; Executed by:
| 61 | ||||||||||||||||||||||||
5491 | case DefFix: executed 21 times by 1 test: case DefFix: Executed by:
| 21 | ||||||||||||||||||||||||
5492 | parseString_s = QLatin1String("FIXED"); | - | ||||||||||||||||||||||||
5493 | if (!parseString()) {
| 9-12 | ||||||||||||||||||||||||
5494 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5495 | return false; executed 12 times by 1 test: return false; Executed by:
| 12 | ||||||||||||||||||||||||
5496 | } | - | ||||||||||||||||||||||||
5497 | break; executed 9 times by 1 test: break; Executed by:
| 9 | ||||||||||||||||||||||||
5498 | case Attval: executed 207 times by 1 test: case Attval: Executed by:
| 207 | ||||||||||||||||||||||||
5499 | if (!parseAttValue()) {
| 80-127 | ||||||||||||||||||||||||
5500 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5501 | return false; executed 127 times by 1 test: return false; Executed by:
| 127 | ||||||||||||||||||||||||
5502 | } | - | ||||||||||||||||||||||||
5503 | break; executed 80 times by 1 test: break; Executed by:
| 80 | ||||||||||||||||||||||||
5504 | case Ws4: executed 607 times by 1 test: case Ws4: Executed by:
| 607 | ||||||||||||||||||||||||
5505 | if (declHnd) {
| 0-607 | ||||||||||||||||||||||||
5506 | // ### not all values are computed yet... | - | ||||||||||||||||||||||||
5507 | if (!declHnd->attributeDecl(attDeclEName, attDeclAName, QLatin1String(""), QLatin1String(""), QLatin1String(""))) {
| 0-607 | ||||||||||||||||||||||||
5508 | reportParseError(declHnd->errorString()); | - | ||||||||||||||||||||||||
5509 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5510 | } | - | ||||||||||||||||||||||||
5511 | } executed 607 times by 1 test: end of block Executed by:
| 607 | ||||||||||||||||||||||||
5512 | if (!eat_ws()) {
| 35-572 | ||||||||||||||||||||||||
5513 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||||||||||||||
5514 | return false; executed 35 times by 1 test: return false; Executed by:
| 35 | ||||||||||||||||||||||||
5515 | } | - | ||||||||||||||||||||||||
5516 | break; executed 572 times by 1 test: break; Executed by:
| 572 | ||||||||||||||||||||||||
5517 | case Done: executed 536 times by 1 test: case Done: Executed by:
| 536 | ||||||||||||||||||||||||
5518 | next(); | - | ||||||||||||||||||||||||
5519 | break; executed 536 times by 1 test: break; Executed by:
| 536 | ||||||||||||||||||||||||
5520 | } | - | ||||||||||||||||||||||||
5521 | } executed 4279 times by 1 test: end of block Executed by:
| 4279 | ||||||||||||||||||||||||
5522 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5523 | } | - | ||||||||||||||||||||||||
5524 | - | |||||||||||||||||||||||||
5525 | /* | - | ||||||||||||||||||||||||
5526 | Parse a AttType [54] | - | ||||||||||||||||||||||||
5527 | */ | - | ||||||||||||||||||||||||
5528 | bool QXmlSimpleReaderPrivate::parseAttType() | - | ||||||||||||||||||||||||
5529 | { | - | ||||||||||||||||||||||||
5530 | const signed char Init = 0; | - | ||||||||||||||||||||||||
5531 | const signed char ST = 1; // StringType | - | ||||||||||||||||||||||||
5532 | const signed char TTI = 2; // TokenizedType starting with 'I' | - | ||||||||||||||||||||||||
5533 | const signed char TTI2 = 3; // TokenizedType helpstate | - | ||||||||||||||||||||||||
5534 | const signed char TTI3 = 4; // TokenizedType helpstate | - | ||||||||||||||||||||||||
5535 | const signed char TTE = 5; // TokenizedType starting with 'E' | - | ||||||||||||||||||||||||
5536 | const signed char TTEY = 6; // TokenizedType starting with 'ENTITY' | - | ||||||||||||||||||||||||
5537 | const signed char TTEI = 7; // TokenizedType starting with 'ENTITI' | - | ||||||||||||||||||||||||
5538 | const signed char N = 8; // N read (TokenizedType or Notation) | - | ||||||||||||||||||||||||
5539 | const signed char TTNM = 9; // TokenizedType starting with 'NM' | - | ||||||||||||||||||||||||
5540 | const signed char TTNM2 = 10; // TokenizedType helpstate | - | ||||||||||||||||||||||||
5541 | const signed char NO = 11; // Notation | - | ||||||||||||||||||||||||
5542 | const signed char NO2 = 12; // Notation helpstate | - | ||||||||||||||||||||||||
5543 | const signed char NO3 = 13; // Notation helpstate | - | ||||||||||||||||||||||||
5544 | const signed char NOName = 14; // Notation, read name | - | ||||||||||||||||||||||||
5545 | const signed char NO4 = 15; // Notation helpstate | - | ||||||||||||||||||||||||
5546 | const signed char EN = 16; // Enumeration | - | ||||||||||||||||||||||||
5547 | const signed char ENNmt = 17; // Enumeration, read Nmtoken | - | ||||||||||||||||||||||||
5548 | const signed char EN2 = 18; // Enumeration helpstate | - | ||||||||||||||||||||||||
5549 | const signed char ADone = 19; // almost done (make next and accept) | - | ||||||||||||||||||||||||
5550 | const signed char Done = 20; | - | ||||||||||||||||||||||||
5551 | - | |||||||||||||||||||||||||
5552 | const signed char InpWs = 0; // whitespace | - | ||||||||||||||||||||||||
5553 | const signed char InpOp = 1; // ( | - | ||||||||||||||||||||||||
5554 | const signed char InpCp = 2; //) | - | ||||||||||||||||||||||||
5555 | const signed char InpPipe = 3; // | | - | ||||||||||||||||||||||||
5556 | const signed char InpC = 4; // C | - | ||||||||||||||||||||||||
5557 | const signed char InpE = 5; // E | - | ||||||||||||||||||||||||
5558 | const signed char InpI = 6; // I | - | ||||||||||||||||||||||||
5559 | const signed char InpM = 7; // M | - | ||||||||||||||||||||||||
5560 | const signed char InpN = 8; // N | - | ||||||||||||||||||||||||
5561 | const signed char InpO = 9; // O | - | ||||||||||||||||||||||||
5562 | const signed char InpR = 10; // R | - | ||||||||||||||||||||||||
5563 | const signed char InpS = 11; // S | - | ||||||||||||||||||||||||
5564 | const signed char InpY = 12; // Y | - | ||||||||||||||||||||||||
5565 | const signed char InpUnknown = 13; | - | ||||||||||||||||||||||||
5566 | - | |||||||||||||||||||||||||
5567 | static const signed char table[19][14] = { | - | ||||||||||||||||||||||||
5568 | /* InpWs InpOp InpCp InpPipe InpC InpE InpI InpM InpN InpO InpR InpS InpY InpUnknown */ | - | ||||||||||||||||||||||||
5569 | { -1, EN, -1, -1, ST, TTE, TTI, -1, N, -1, -1, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
5570 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // ST | - | ||||||||||||||||||||||||
5571 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTI2, Done, Done, Done }, // TTI | - | ||||||||||||||||||||||||
5572 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTI3, Done, Done }, // TTI2 | - | ||||||||||||||||||||||||
5573 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTI3 | - | ||||||||||||||||||||||||
5574 | { -1, -1, -1, -1, -1, -1, TTEI, -1, -1, -1, -1, -1, TTEY, -1 }, // TTE | - | ||||||||||||||||||||||||
5575 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTEY | - | ||||||||||||||||||||||||
5576 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTEI | - | ||||||||||||||||||||||||
5577 | { -1, -1, -1, -1, -1, -1, -1, TTNM, -1, NO, -1, -1, -1, -1 }, // N | - | ||||||||||||||||||||||||
5578 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTNM2, Done, Done }, // TTNM | - | ||||||||||||||||||||||||
5579 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTNM2 | - | ||||||||||||||||||||||||
5580 | { NO2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NO | - | ||||||||||||||||||||||||
5581 | { -1, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NO2 | - | ||||||||||||||||||||||||
5582 | { NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName }, // NO3 | - | ||||||||||||||||||||||||
5583 | { NO4, -1, ADone, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NOName | - | ||||||||||||||||||||||||
5584 | { -1, -1, ADone, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NO4 | - | ||||||||||||||||||||||||
5585 | { -1, -1, ENNmt, -1, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt }, // EN | - | ||||||||||||||||||||||||
5586 | { EN2, -1, ADone, EN, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // ENNmt | - | ||||||||||||||||||||||||
5587 | { -1, -1, ADone, EN, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } // EN2 | - | ||||||||||||||||||||||||
5588 | }; | - | ||||||||||||||||||||||||
5589 | signed char state; | - | ||||||||||||||||||||||||
5590 | signed char input; | - | ||||||||||||||||||||||||
5591 | - | |||||||||||||||||||||||||
5592 | if (parseStack==0 || parseStack->isEmpty()) {
| 78-1519 | ||||||||||||||||||||||||
5593 | state = Init; | - | ||||||||||||||||||||||||
5594 | } else { executed 618 times by 1 test: end of block Executed by:
| 618 | ||||||||||||||||||||||||
5595 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
5596 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5597 | qDebug("QXmlSimpleReader: parseAttType (cont) in state %d", state); | - | ||||||||||||||||||||||||
5598 | #endif | - | ||||||||||||||||||||||||
5599 | if (!parseStack->isEmpty()) {
| 232-747 | ||||||||||||||||||||||||
5600 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
5601 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 26-721 | ||||||||||||||||||||||||
5602 | parseStack->pop(); | - | ||||||||||||||||||||||||
5603 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5604 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
5605 | #endif | - | ||||||||||||||||||||||||
5606 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||
5607 | if (!(this->*function)()) {
| 267-480 | ||||||||||||||||||||||||
5608 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5609 | return false; executed 267 times by 1 test: return false; Executed by:
| 267 | ||||||||||||||||||||||||
5610 | } | - | ||||||||||||||||||||||||
5611 | } executed 480 times by 1 test: end of block Executed by:
| 480 | ||||||||||||||||||||||||
5612 | } executed 712 times by 1 test: end of block Executed by:
| 712 | ||||||||||||||||||||||||
5613 | - | |||||||||||||||||||||||||
5614 | for (;;) { | - | ||||||||||||||||||||||||
5615 | switch (state) { | - | ||||||||||||||||||||||||
5616 | case ADone: executed 32 times by 1 test: case ADone: Executed by:
| 32 | ||||||||||||||||||||||||
5617 | return true; executed 32 times by 1 test: return true; Executed by:
| 32 | ||||||||||||||||||||||||
5618 | case Done: executed 583 times by 1 test: case Done: Executed by:
| 583 | ||||||||||||||||||||||||
5619 | return true; executed 583 times by 1 test: return true; Executed by:
| 583 | ||||||||||||||||||||||||
5620 | case -1: executed 3 times by 1 test: case -1: Executed by:
| 3 | ||||||||||||||||||||||||
5621 | // Error | - | ||||||||||||||||||||||||
5622 | reportParseError(QLatin1String(XMLERR_LETTEREXPECTED)); | - | ||||||||||||||||||||||||
5623 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
5624 | } | - | ||||||||||||||||||||||||
5625 | - | |||||||||||||||||||||||||
5626 | if (atEnd()) {
| 232-1533 | ||||||||||||||||||||||||
5627 | unexpectedEof(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5628 | return false; executed 232 times by 1 test: return false; Executed by:
| 232 | ||||||||||||||||||||||||
5629 | } | - | ||||||||||||||||||||||||
5630 | if (is_S(c)) {
| 602-931 | ||||||||||||||||||||||||
5631 | input = InpWs; | - | ||||||||||||||||||||||||
5632 | } else if (c == QLatin1Char('(')) { executed 602 times by 1 test: end of block Executed by:
| 34-897 | ||||||||||||||||||||||||
5633 | input = InpOp; | - | ||||||||||||||||||||||||
5634 | } else if (c == QLatin1Char(')')) { executed 34 times by 1 test: end of block Executed by:
| 32-865 | ||||||||||||||||||||||||
5635 | input = InpCp; | - | ||||||||||||||||||||||||
5636 | } else if (c == QLatin1Char('|')) { executed 32 times by 1 test: end of block Executed by:
| 21-844 | ||||||||||||||||||||||||
5637 | input = InpPipe; | - | ||||||||||||||||||||||||
5638 | } else if (c == QLatin1Char('C')) { executed 21 times by 1 test: end of block Executed by:
| 21-472 | ||||||||||||||||||||||||
5639 | input = InpC; | - | ||||||||||||||||||||||||
5640 | } else if (c == QLatin1Char('E')) { executed 472 times by 1 test: end of block Executed by:
| 30-472 | ||||||||||||||||||||||||
5641 | input = InpE; | - | ||||||||||||||||||||||||
5642 | } else if (c == QLatin1Char('I')) { executed 30 times by 1 test: end of block Executed by:
| 30-302 | ||||||||||||||||||||||||
5643 | input = InpI; | - | ||||||||||||||||||||||||
5644 | } else if (c == QLatin1Char('M')) { executed 40 times by 1 test: end of block Executed by:
| 40-251 | ||||||||||||||||||||||||
5645 | input = InpM; | - | ||||||||||||||||||||||||
5646 | } else if (c == QLatin1Char('N')) { executed 51 times by 1 test: end of block Executed by:
| 51-178 | ||||||||||||||||||||||||
5647 | input = InpN; | - | ||||||||||||||||||||||||
5648 | } else if (c == QLatin1Char('O')) { executed 73 times by 1 test: end of block Executed by:
| 21-157 | ||||||||||||||||||||||||
5649 | input = InpO; | - | ||||||||||||||||||||||||
5650 | } else if (c == QLatin1Char('R')) { executed 21 times by 1 test: end of block Executed by:
| 20-137 | ||||||||||||||||||||||||
5651 | input = InpR; | - | ||||||||||||||||||||||||
5652 | } else if (c == QLatin1Char('S')) { executed 20 times by 1 test: end of block Executed by:
| 20-77 | ||||||||||||||||||||||||
5653 | input = InpS; | - | ||||||||||||||||||||||||
5654 | } else if (c == QLatin1Char('Y')) { executed 60 times by 1 test: end of block Executed by:
| 20-60 | ||||||||||||||||||||||||
5655 | input = InpY; | - | ||||||||||||||||||||||||
5656 | } else { executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
5657 | input = InpUnknown; | - | ||||||||||||||||||||||||
5658 | } executed 57 times by 1 test: end of block Executed by:
| 57 | ||||||||||||||||||||||||
5659 | state = table[state][input]; | - | ||||||||||||||||||||||||
5660 | - | |||||||||||||||||||||||||
5661 | switch (state) { | - | ||||||||||||||||||||||||
5662 | case ST: executed 472 times by 1 test: case ST: Executed by:
| 472 | ||||||||||||||||||||||||
5663 | parseString_s = QLatin1String("CDATA"); | - | ||||||||||||||||||||||||
5664 | if (!parseString()) {
| 148-324 | ||||||||||||||||||||||||
5665 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5666 | return false; executed 324 times by 1 test: return false; Executed by:
| 324 | ||||||||||||||||||||||||
5667 | } | - | ||||||||||||||||||||||||
5668 | break; executed 148 times by 1 test: break; Executed by:
| 148 | ||||||||||||||||||||||||
5669 | case TTI: executed 30 times by 1 test: case TTI: Executed by:
| 30 | ||||||||||||||||||||||||
5670 | parseString_s = QLatin1String("ID"); | - | ||||||||||||||||||||||||
5671 | if (!parseString()) {
| 12-18 | ||||||||||||||||||||||||
5672 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5673 | return false; executed 18 times by 1 test: return false; Executed by:
| 18 | ||||||||||||||||||||||||
5674 | } | - | ||||||||||||||||||||||||
5675 | break; executed 12 times by 1 test: break; Executed by:
| 12 | ||||||||||||||||||||||||
5676 | case TTI2: executed 20 times by 1 test: case TTI2: Executed by:
| 20 | ||||||||||||||||||||||||
5677 | parseString_s = QLatin1String("REF"); | - | ||||||||||||||||||||||||
5678 | if (!parseString()) {
| 10 | ||||||||||||||||||||||||
5679 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5680 | return false; executed 10 times by 1 test: return false; Executed by:
| 10 | ||||||||||||||||||||||||
5681 | } | - | ||||||||||||||||||||||||
5682 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
5683 | case TTI3: executed 10 times by 1 test: case TTI3: Executed by:
| 10 | ||||||||||||||||||||||||
5684 | next(); // S | - | ||||||||||||||||||||||||
5685 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
5686 | case TTE: executed 30 times by 1 test: case TTE: Executed by:
| 30 | ||||||||||||||||||||||||
5687 | parseString_s = QLatin1String("ENTIT"); | - | ||||||||||||||||||||||||
5688 | if (!parseString()) {
| 6-24 | ||||||||||||||||||||||||
5689 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5690 | return false; executed 24 times by 1 test: return false; Executed by:
| 24 | ||||||||||||||||||||||||
5691 | } | - | ||||||||||||||||||||||||
5692 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
5693 | case TTEY: executed 20 times by 1 test: case TTEY: Executed by:
| 20 | ||||||||||||||||||||||||
5694 | next(); // Y | - | ||||||||||||||||||||||||
5695 | break; executed 20 times by 1 test: break; Executed by:
| 20 | ||||||||||||||||||||||||
5696 | case TTEI: executed 10 times by 1 test: case TTEI: Executed by:
| 10 | ||||||||||||||||||||||||
5697 | parseString_s = QLatin1String("IES"); | - | ||||||||||||||||||||||||
5698 | if (!parseString()) {
| 5 | ||||||||||||||||||||||||
5699 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5700 | return false; executed 5 times by 1 test: return false; Executed by:
| 5 | ||||||||||||||||||||||||
5701 | } | - | ||||||||||||||||||||||||
5702 | break; executed 5 times by 1 test: break; Executed by:
| 5 | ||||||||||||||||||||||||
5703 | case N: executed 73 times by 1 test: case N: Executed by:
| 73 | ||||||||||||||||||||||||
5704 | next(); // N | - | ||||||||||||||||||||||||
5705 | break; executed 73 times by 1 test: break; Executed by:
| 73 | ||||||||||||||||||||||||
5706 | case TTNM: executed 51 times by 1 test: case TTNM: Executed by:
| 51 | ||||||||||||||||||||||||
5707 | parseString_s = QLatin1String("MTOKEN"); | - | ||||||||||||||||||||||||
5708 | if (!parseString()) {
| 11-40 | ||||||||||||||||||||||||
5709 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5710 | return false; executed 40 times by 1 test: return false; Executed by:
| 40 | ||||||||||||||||||||||||
5711 | } | - | ||||||||||||||||||||||||
5712 | break; executed 11 times by 1 test: break; Executed by:
| 11 | ||||||||||||||||||||||||
5713 | case TTNM2: executed 50 times by 1 test: case TTNM2: Executed by:
| 50 | ||||||||||||||||||||||||
5714 | next(); // S | - | ||||||||||||||||||||||||
5715 | break; executed 50 times by 1 test: break; Executed by:
| 50 | ||||||||||||||||||||||||
5716 | case NO: executed 21 times by 1 test: case NO: Executed by:
| 21 | ||||||||||||||||||||||||
5717 | parseString_s = QLatin1String("OTATION"); | - | ||||||||||||||||||||||||
5718 | if (!parseString()) {
| 4-17 | ||||||||||||||||||||||||
5719 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5720 | return false; executed 17 times by 1 test: return false; Executed by:
| 17 | ||||||||||||||||||||||||
5721 | } | - | ||||||||||||||||||||||||
5722 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
5723 | case NO2: executed 20 times by 1 test: case NO2: Executed by:
| 20 | ||||||||||||||||||||||||
5724 | if (!eat_ws()) {
| 8-12 | ||||||||||||||||||||||||
5725 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5726 | return false; executed 8 times by 1 test: return false; Executed by:
| 8 | ||||||||||||||||||||||||
5727 | } | - | ||||||||||||||||||||||||
5728 | break; executed 12 times by 1 test: break; Executed by:
| 12 | ||||||||||||||||||||||||
5729 | case NO3: executed 30 times by 1 test: case NO3: Executed by:
| 30 | ||||||||||||||||||||||||
5730 | if (!next_eat_ws()) {
| 10-20 | ||||||||||||||||||||||||
5731 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5732 | return false; executed 10 times by 1 test: return false; Executed by:
| 10 | ||||||||||||||||||||||||
5733 | } | - | ||||||||||||||||||||||||
5734 | break; executed 20 times by 1 test: break; Executed by:
| 20 | ||||||||||||||||||||||||
5735 | case NOName: executed 30 times by 1 test: case NOName: Executed by:
| 30 | ||||||||||||||||||||||||
5736 | parseName_useRef = false; | - | ||||||||||||||||||||||||
5737 | if (!parseName()) {
| 11-19 | ||||||||||||||||||||||||
5738 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5739 | return false; executed 11 times by 1 test: return false; Executed by:
| 11 | ||||||||||||||||||||||||
5740 | } | - | ||||||||||||||||||||||||
5741 | break; executed 19 times by 1 test: break; Executed by:
| 19 | ||||||||||||||||||||||||
5742 | case NO4: never executed: case NO4: | 0 | ||||||||||||||||||||||||
5743 | if (!eat_ws()) {
| 0 | ||||||||||||||||||||||||
5744 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5745 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5746 | } | - | ||||||||||||||||||||||||
5747 | break; never executed: break; | 0 | ||||||||||||||||||||||||
5748 | case EN: executed 24 times by 1 test: case EN: Executed by:
| 24 | ||||||||||||||||||||||||
5749 | if (!next_eat_ws()) {
| 8-16 | ||||||||||||||||||||||||
5750 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5751 | return false; executed 8 times by 1 test: return false; Executed by:
| 8 | ||||||||||||||||||||||||
5752 | } | - | ||||||||||||||||||||||||
5753 | break; executed 16 times by 1 test: break; Executed by:
| 16 | ||||||||||||||||||||||||
5754 | case ENNmt: executed 24 times by 1 test: case ENNmt: Executed by:
| 24 | ||||||||||||||||||||||||
5755 | if (!parseNmtoken()) {
| 5-19 | ||||||||||||||||||||||||
5756 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5757 | return false; executed 5 times by 1 test: return false; Executed by:
| 5 | ||||||||||||||||||||||||
5758 | } | - | ||||||||||||||||||||||||
5759 | break; executed 19 times by 1 test: break; Executed by:
| 19 | ||||||||||||||||||||||||
5760 | case EN2: never executed: case EN2: | 0 | ||||||||||||||||||||||||
5761 | if (!eat_ws()) {
| 0 | ||||||||||||||||||||||||
5762 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||||||||||||||
5763 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5764 | } | - | ||||||||||||||||||||||||
5765 | break; never executed: break; | 0 | ||||||||||||||||||||||||
5766 | case ADone: executed 32 times by 1 test: case ADone: Executed by:
| 32 | ||||||||||||||||||||||||
5767 | next(); | - | ||||||||||||||||||||||||
5768 | break; executed 32 times by 1 test: break; Executed by:
| 32 | ||||||||||||||||||||||||
5769 | } | - | ||||||||||||||||||||||||
5770 | } executed 1053 times by 1 test: end of block Executed by:
| 1053 | ||||||||||||||||||||||||
5771 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5772 | } | - | ||||||||||||||||||||||||
5773 | - | |||||||||||||||||||||||||
5774 | /* | - | ||||||||||||||||||||||||
5775 | Parse a AttValue [10] | - | ||||||||||||||||||||||||
5776 | - | |||||||||||||||||||||||||
5777 | Precondition: the head stands on the beginning " or ' | - | ||||||||||||||||||||||||
5778 | - | |||||||||||||||||||||||||
5779 | If this function was successful, the head stands on the first | - | ||||||||||||||||||||||||
5780 | character after the closing " or ' and the value of the attribute | - | ||||||||||||||||||||||||
5781 | is in string(). | - | ||||||||||||||||||||||||
5782 | */ | - | ||||||||||||||||||||||||
5783 | bool QXmlSimpleReaderPrivate::parseAttValue() | - | ||||||||||||||||||||||||
5784 | { | - | ||||||||||||||||||||||||
5785 | const signed char Init = 0; | - | ||||||||||||||||||||||||
5786 | const signed char Dq = 1; // double quotes were read | - | ||||||||||||||||||||||||
5787 | const signed char DqRef = 2; // read references in double quotes | - | ||||||||||||||||||||||||
5788 | const signed char DqC = 3; // signed character read in double quotes | - | ||||||||||||||||||||||||
5789 | const signed char Sq = 4; // single quotes were read | - | ||||||||||||||||||||||||
5790 | const signed char SqRef = 5; // read references in single quotes | - | ||||||||||||||||||||||||
5791 | const signed char SqC = 6; // signed character read in single quotes | - | ||||||||||||||||||||||||
5792 | const signed char Done = 7; | - | ||||||||||||||||||||||||
5793 | - | |||||||||||||||||||||||||
5794 | const signed char InpDq = 0; // " | - | ||||||||||||||||||||||||
5795 | const signed char InpSq = 1; // ' | - | ||||||||||||||||||||||||
5796 | const signed char InpAmp = 2; // & | - | ||||||||||||||||||||||||
5797 | const signed char InpLt = 3; // < | - | ||||||||||||||||||||||||
5798 | const signed char InpUnknown = 4; | - | ||||||||||||||||||||||||
5799 | - | |||||||||||||||||||||||||
5800 | static const signed char table[7][5] = { | - | ||||||||||||||||||||||||
5801 | /* InpDq InpSq InpAmp InpLt InpUnknown */ | - | ||||||||||||||||||||||||
5802 | { Dq, Sq, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
5803 | { Done, DqC, DqRef, -1, DqC }, // Dq | - | ||||||||||||||||||||||||
5804 | { Done, DqC, DqRef, -1, DqC }, // DqRef | - | ||||||||||||||||||||||||
5805 | { Done, DqC, DqRef, -1, DqC }, // DqC | - | ||||||||||||||||||||||||
5806 | { SqC, Done, SqRef, -1, SqC }, // Sq | - | ||||||||||||||||||||||||
5807 | { SqC, Done, SqRef, -1, SqC }, // SqRef | - | ||||||||||||||||||||||||
5808 | { SqC, Done, SqRef, -1, SqC } // SqRef | - | ||||||||||||||||||||||||
5809 | }; | - | ||||||||||||||||||||||||
5810 | signed char state; | - | ||||||||||||||||||||||||
5811 | signed char input; | - | ||||||||||||||||||||||||
5812 | - | |||||||||||||||||||||||||
5813 | if (parseStack==0 || parseStack->isEmpty()) {
| 729-12621 | ||||||||||||||||||||||||
5814 | state = Init; | - | ||||||||||||||||||||||||
5815 | } else { executed 13350 times by 6 tests: end of block Executed by:
| 13350 | ||||||||||||||||||||||||
5816 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
5817 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5818 | qDebug("QXmlSimpleReader: parseAttValue (cont) in state %d", state); | - | ||||||||||||||||||||||||
5819 | #endif | - | ||||||||||||||||||||||||
5820 | if (!parseStack->isEmpty()) {
| 193-948 | ||||||||||||||||||||||||
5821 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
5822 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 0-193 | ||||||||||||||||||||||||
5823 | parseStack->pop(); | - | ||||||||||||||||||||||||
5824 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5825 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
5826 | #endif | - | ||||||||||||||||||||||||
5827 | } never executed: end of block | 0 | ||||||||||||||||||||||||
5828 | if (!(this->*function)()) {
| 69-124 | ||||||||||||||||||||||||
5829 | parseFailed(&QXmlSimpleReaderPrivate::parseAttValue, state); | - | ||||||||||||||||||||||||
5830 | return false; executed 69 times by 1 test: return false; Executed by:
| 69 | ||||||||||||||||||||||||
5831 | } | - | ||||||||||||||||||||||||
5832 | } executed 124 times by 1 test: end of block Executed by:
| 124 | ||||||||||||||||||||||||
5833 | } executed 1072 times by 1 test: end of block Executed by:
| 1072 | ||||||||||||||||||||||||
5834 | - | |||||||||||||||||||||||||
5835 | for (;;) { | - | ||||||||||||||||||||||||
5836 | switch (state) { | - | ||||||||||||||||||||||||
5837 | case Done: executed 13332 times by 6 tests: case Done: Executed by:
| 13332 | ||||||||||||||||||||||||
5838 | return true; executed 13332 times by 6 tests: return true; Executed by:
| 13332 | ||||||||||||||||||||||||
5839 | case -1: executed 6 times by 1 test: case -1: Executed by:
| 6 | ||||||||||||||||||||||||
5840 | // Error | - | ||||||||||||||||||||||||
5841 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
5842 | return false; executed 6 times by 1 test: return false; Executed by:
| 6 | ||||||||||||||||||||||||
5843 | } | - | ||||||||||||||||||||||||
5844 | - | |||||||||||||||||||||||||
5845 | if (atEnd()) {
| 949-187156 | ||||||||||||||||||||||||
5846 | unexpectedEof(&QXmlSimpleReaderPrivate::parseAttValue, state); | - | ||||||||||||||||||||||||
5847 | return false; executed 949 times by 1 test: return false; Executed by:
| 949 | ||||||||||||||||||||||||
5848 | } | - | ||||||||||||||||||||||||
5849 | if (c == QLatin1Char('"')) {
| 26529-160627 | ||||||||||||||||||||||||
5850 | input = InpDq; | - | ||||||||||||||||||||||||
5851 | } else if (c == QLatin1Char('\'')) { executed 26529 times by 5 tests: end of block Executed by:
| 296-160331 | ||||||||||||||||||||||||
5852 | input = InpSq; | - | ||||||||||||||||||||||||
5853 | } else if (c == QLatin1Char('&')) { executed 296 times by 4 tests: end of block Executed by:
| 258-160073 | ||||||||||||||||||||||||
5854 | input = InpAmp; | - | ||||||||||||||||||||||||
5855 | } else if (c == QLatin1Char('<')) { executed 258 times by 2 tests: end of block Executed by:
| 5-160068 | ||||||||||||||||||||||||
5856 | input = InpLt; | - | ||||||||||||||||||||||||
5857 | } else { executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||
5858 | input = InpUnknown; | - | ||||||||||||||||||||||||
5859 | } executed 160068 times by 6 tests: end of block Executed by:
| 160068 | ||||||||||||||||||||||||
5860 | state = table[state][input]; | - | ||||||||||||||||||||||||
5861 | - | |||||||||||||||||||||||||
5862 | switch (state) { | - | ||||||||||||||||||||||||
5863 | case Dq: executed 13272 times by 5 tests: case Dq: Executed by:
| 13272 | ||||||||||||||||||||||||
5864 | case Sq: executed 77 times by 3 tests: case Sq: Executed by:
| 77 | ||||||||||||||||||||||||
5865 | stringClear(); | - | ||||||||||||||||||||||||
5866 | next(); | - | ||||||||||||||||||||||||
5867 | break; executed 13349 times by 6 tests: break; Executed by:
| 13349 | ||||||||||||||||||||||||
5868 | case DqRef: executed 257 times by 2 tests: case DqRef: Executed by:
| 257 | ||||||||||||||||||||||||
5869 | case SqRef: executed 1 time by 1 test: case SqRef: Executed by:
| 1 | ||||||||||||||||||||||||
5870 | parseReference_context = InAttributeValue; | - | ||||||||||||||||||||||||
5871 | if (!parseReference()) {
| 123-135 | ||||||||||||||||||||||||
5872 | parseFailed(&QXmlSimpleReaderPrivate::parseAttValue, state); | - | ||||||||||||||||||||||||
5873 | return false; executed 135 times by 1 test: return false; Executed by:
| 135 | ||||||||||||||||||||||||
5874 | } | - | ||||||||||||||||||||||||
5875 | break; executed 123 times by 2 tests: break; Executed by:
| 123 | ||||||||||||||||||||||||
5876 | case DqC: executed 159958 times by 5 tests: case DqC: Executed by:
| 159958 | ||||||||||||||||||||||||
5877 | case SqC: executed 253 times by 3 tests: case SqC: Executed by:
| 253 | ||||||||||||||||||||||||
5878 | stringAddC(); | - | ||||||||||||||||||||||||
5879 | next(); | - | ||||||||||||||||||||||||
5880 | break; executed 160211 times by 6 tests: break; Executed by:
| 160211 | ||||||||||||||||||||||||
5881 | case Done: executed 13332 times by 6 tests: case Done: Executed by:
| 13332 | ||||||||||||||||||||||||
5882 | next(); | - | ||||||||||||||||||||||||
5883 | break; executed 13332 times by 6 tests: break; Executed by:
| 13332 | ||||||||||||||||||||||||
5884 | } | - | ||||||||||||||||||||||||
5885 | } executed 187021 times by 6 tests: end of block Executed by:
| 187021 | ||||||||||||||||||||||||
5886 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5887 | } | - | ||||||||||||||||||||||||
5888 | - | |||||||||||||||||||||||||
5889 | /* | - | ||||||||||||||||||||||||
5890 | Parse a elementdecl [45]. | - | ||||||||||||||||||||||||
5891 | - | |||||||||||||||||||||||||
5892 | Precondition: the beginning '<!E' is already read and the head | - | ||||||||||||||||||||||||
5893 | stands on the 'L' of '<!ELEMENT' | - | ||||||||||||||||||||||||
5894 | */ | - | ||||||||||||||||||||||||
5895 | bool QXmlSimpleReaderPrivate::parseElementDecl() | - | ||||||||||||||||||||||||
5896 | { | - | ||||||||||||||||||||||||
5897 | const signed char Init = 0; | - | ||||||||||||||||||||||||
5898 | const signed char Elem = 1; // parse the beginning string | - | ||||||||||||||||||||||||
5899 | const signed char Ws1 = 2; // whitespace required | - | ||||||||||||||||||||||||
5900 | const signed char Nam = 3; // parse Name | - | ||||||||||||||||||||||||
5901 | const signed char Ws2 = 4; // whitespace required | - | ||||||||||||||||||||||||
5902 | const signed char Empty = 5; // read EMPTY | - | ||||||||||||||||||||||||
5903 | const signed char Any = 6; // read ANY | - | ||||||||||||||||||||||||
5904 | const signed char Cont = 7; // read contentspec (except ANY or EMPTY) | - | ||||||||||||||||||||||||
5905 | const signed char Mix = 8; // read Mixed | - | ||||||||||||||||||||||||
5906 | const signed char Mix2 = 9; // | - | ||||||||||||||||||||||||
5907 | const signed char Mix3 = 10; // | - | ||||||||||||||||||||||||
5908 | const signed char MixN1 = 11; // | - | ||||||||||||||||||||||||
5909 | const signed char MixN2 = 12; // | - | ||||||||||||||||||||||||
5910 | const signed char MixN3 = 13; // | - | ||||||||||||||||||||||||
5911 | const signed char MixN4 = 14; // | - | ||||||||||||||||||||||||
5912 | const signed char Cp = 15; // parse cp | - | ||||||||||||||||||||||||
5913 | const signed char Cp2 = 16; // | - | ||||||||||||||||||||||||
5914 | const signed char WsD = 17; // eat whitespace before Done | - | ||||||||||||||||||||||||
5915 | const signed char Done = 18; | - | ||||||||||||||||||||||||
5916 | - | |||||||||||||||||||||||||
5917 | const signed char InpWs = 0; | - | ||||||||||||||||||||||||
5918 | const signed char InpGt = 1; // > | - | ||||||||||||||||||||||||
5919 | const signed char InpPipe = 2; // | | - | ||||||||||||||||||||||||
5920 | const signed char InpOp = 3; // ( | - | ||||||||||||||||||||||||
5921 | const signed char InpCp = 4; //) | - | ||||||||||||||||||||||||
5922 | const signed char InpHash = 5; // # | - | ||||||||||||||||||||||||
5923 | const signed char InpQm = 6; // ? | - | ||||||||||||||||||||||||
5924 | const signed char InpAst = 7; // * | - | ||||||||||||||||||||||||
5925 | const signed char InpPlus = 8; // + | - | ||||||||||||||||||||||||
5926 | const signed char InpA = 9; // A | - | ||||||||||||||||||||||||
5927 | const signed char InpE = 10; // E | - | ||||||||||||||||||||||||
5928 | const signed char InpL = 11; // L | - | ||||||||||||||||||||||||
5929 | const signed char InpUnknown = 12; | - | ||||||||||||||||||||||||
5930 | - | |||||||||||||||||||||||||
5931 | static const signed char table[18][13] = { | - | ||||||||||||||||||||||||
5932 | /* InpWs InpGt InpPipe InpOp InpCp InpHash InpQm InpAst InpPlus InpA InpE InpL InpUnknown */ | - | ||||||||||||||||||||||||
5933 | { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, Elem, -1 }, // Init | - | ||||||||||||||||||||||||
5934 | { Ws1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Elem | - | ||||||||||||||||||||||||
5935 | { -1, -1, -1, -1, -1, -1, -1, -1, -1, Nam, Nam, Nam, Nam }, // Ws1 | - | ||||||||||||||||||||||||
5936 | { Ws2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Nam | - | ||||||||||||||||||||||||
5937 | { -1, -1, -1, Cont, -1, -1, -1, -1, -1, Any, Empty, -1, -1 }, // Ws2 | - | ||||||||||||||||||||||||
5938 | { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Empty | - | ||||||||||||||||||||||||
5939 | { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Any | - | ||||||||||||||||||||||||
5940 | { -1, -1, -1, Cp, Cp, Mix, -1, -1, -1, Cp, Cp, Cp, Cp }, // Cont | - | ||||||||||||||||||||||||
5941 | { Mix2, -1, MixN1, -1, Mix3, -1, -1, -1, -1, -1, -1, -1, -1 }, // Mix | - | ||||||||||||||||||||||||
5942 | { -1, -1, MixN1, -1, Mix3, -1, -1, -1, -1, -1, -1, -1, -1 }, // Mix2 | - | ||||||||||||||||||||||||
5943 | { WsD, Done, -1, -1, -1, -1, -1, WsD, -1, -1, -1, -1, -1 }, // Mix3 | - | ||||||||||||||||||||||||
5944 | { -1, -1, -1, -1, -1, -1, -1, -1, -1, MixN2, MixN2, MixN2, MixN2 }, // MixN1 | - | ||||||||||||||||||||||||
5945 | { MixN3, -1, MixN1, -1, MixN4, -1, -1, -1, -1, -1, -1, -1, -1 }, // MixN2 | - | ||||||||||||||||||||||||
5946 | { -1, -1, MixN1, -1, MixN4, -1, -1, -1, -1, -1, -1, -1, -1 }, // MixN3 | - | ||||||||||||||||||||||||
5947 | { -1, -1, -1, -1, -1, -1, -1, WsD, -1, -1, -1, -1, -1 }, // MixN4 | - | ||||||||||||||||||||||||
5948 | { WsD, Done, -1, -1, -1, -1, Cp2, Cp2, Cp2, -1, -1, -1, -1 }, // Cp | - | ||||||||||||||||||||||||
5949 | { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Cp2 | - | ||||||||||||||||||||||||
5950 | { -1, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } // WsD | - | ||||||||||||||||||||||||
5951 | }; | - | ||||||||||||||||||||||||
5952 | signed char state; | - | ||||||||||||||||||||||||
5953 | signed char input; | - | ||||||||||||||||||||||||
5954 | - | |||||||||||||||||||||||||
5955 | if (parseStack==0 || parseStack->isEmpty()) {
| 218-9563 | ||||||||||||||||||||||||
5956 | state = Init; | - | ||||||||||||||||||||||||
5957 | } else { executed 1582 times by 1 test: end of block Executed by:
| 1582 | ||||||||||||||||||||||||
5958 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
5959 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5960 | qDebug("QXmlSimpleReader: parseElementDecl (cont) in state %d", state); | - | ||||||||||||||||||||||||
5961 | #endif | - | ||||||||||||||||||||||||
5962 | if (!parseStack->isEmpty()) {
| 1215-6984 | ||||||||||||||||||||||||
5963 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
5964 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 1242-5742 | ||||||||||||||||||||||||
5965 | parseStack->pop(); | - | ||||||||||||||||||||||||
5966 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
5967 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
5968 | #endif | - | ||||||||||||||||||||||||
5969 | } executed 1242 times by 1 test: end of block Executed by:
| 1242 | ||||||||||||||||||||||||
5970 | if (!(this->*function)()) {
| 2455-4529 | ||||||||||||||||||||||||
5971 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
5972 | return false; executed 2455 times by 1 test: return false; Executed by:
| 2455 | ||||||||||||||||||||||||
5973 | } | - | ||||||||||||||||||||||||
5974 | } executed 4529 times by 1 test: end of block Executed by:
| 4529 | ||||||||||||||||||||||||
5975 | } executed 5744 times by 1 test: end of block Executed by:
| 5744 | ||||||||||||||||||||||||
5976 | - | |||||||||||||||||||||||||
5977 | for (;;) { | - | ||||||||||||||||||||||||
5978 | switch (state) { | - | ||||||||||||||||||||||||
5979 | case Done: executed 1561 times by 1 test: case Done: Executed by:
| 1561 | ||||||||||||||||||||||||
5980 | return true; executed 1561 times by 1 test: return true; Executed by:
| 1561 | ||||||||||||||||||||||||
5981 | case -1: executed 12 times by 1 test: case -1: Executed by:
| 12 | ||||||||||||||||||||||||
5982 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
5983 | return false; executed 12 times by 1 test: return false; Executed by:
| 12 | ||||||||||||||||||||||||
5984 | } | - | ||||||||||||||||||||||||
5985 | - | |||||||||||||||||||||||||
5986 | if (atEnd()) {
| 1215-12237 | ||||||||||||||||||||||||
5987 | unexpectedEof(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
5988 | return false; executed 1215 times by 1 test: return false; Executed by:
| 1215 | ||||||||||||||||||||||||
5989 | } | - | ||||||||||||||||||||||||
5990 | if (is_S(c)) {
| 3168-9069 | ||||||||||||||||||||||||
5991 | input = InpWs; | - | ||||||||||||||||||||||||
5992 | } else if (c == QLatin1Char('>')) { executed 3168 times by 1 test: end of block Executed by:
| 1561-7508 | ||||||||||||||||||||||||
5993 | input = InpGt; | - | ||||||||||||||||||||||||
5994 | } else if (c == QLatin1Char('|')) { executed 1561 times by 1 test: end of block Executed by:
| 12-7496 | ||||||||||||||||||||||||
5995 | input = InpPipe; | - | ||||||||||||||||||||||||
5996 | } else if (c == QLatin1Char('(')) { executed 12 times by 1 test: end of block Executed by:
| 12-6048 | ||||||||||||||||||||||||
5997 | input = InpOp; | - | ||||||||||||||||||||||||
5998 | } else if (c == QLatin1Char(')')) { executed 1448 times by 1 test: end of block Executed by:
| 1247-4801 | ||||||||||||||||||||||||
5999 | input = InpCp; | - | ||||||||||||||||||||||||
6000 | } else if (c == QLatin1Char('#')) { executed 1247 times by 1 test: end of block Executed by:
| 1247-3554 | ||||||||||||||||||||||||
6001 | input = InpHash; | - | ||||||||||||||||||||||||
6002 | } else if (c == QLatin1Char('?')) { executed 1247 times by 1 test: end of block Executed by:
| 3-3551 | ||||||||||||||||||||||||
6003 | input = InpQm; | - | ||||||||||||||||||||||||
6004 | } else if (c == QLatin1Char('*')) { executed 3 times by 1 test: end of block Executed by:
| 3-3519 | ||||||||||||||||||||||||
6005 | input = InpAst; | - | ||||||||||||||||||||||||
6006 | } else if (c == QLatin1Char('+')) { executed 32 times by 1 test: end of block Executed by:
| 12-3507 | ||||||||||||||||||||||||
6007 | input = InpPlus; | - | ||||||||||||||||||||||||
6008 | } else if (c == QLatin1Char('A')) { executed 12 times by 1 test: end of block Executed by:
| 12-3477 | ||||||||||||||||||||||||
6009 | input = InpA; | - | ||||||||||||||||||||||||
6010 | } else if (c == QLatin1Char('E')) { executed 30 times by 1 test: end of block Executed by:
| 30-3373 | ||||||||||||||||||||||||
6011 | input = InpE; | - | ||||||||||||||||||||||||
6012 | } else if (c == QLatin1Char('L')) { executed 104 times by 1 test: end of block Executed by:
| 104-1791 | ||||||||||||||||||||||||
6013 | input = InpL; | - | ||||||||||||||||||||||||
6014 | } else { executed 1582 times by 1 test: end of block Executed by:
| 1582 | ||||||||||||||||||||||||
6015 | input = InpUnknown; | - | ||||||||||||||||||||||||
6016 | } executed 1791 times by 1 test: end of block Executed by:
| 1791 | ||||||||||||||||||||||||
6017 | state = table[state][input]; | - | ||||||||||||||||||||||||
6018 | - | |||||||||||||||||||||||||
6019 | switch (state) { | - | ||||||||||||||||||||||||
6020 | case Elem: executed 1582 times by 1 test: case Elem: Executed by:
| 1582 | ||||||||||||||||||||||||
6021 | parseString_s = QLatin1String("LEMENT"); | - | ||||||||||||||||||||||||
6022 | if (!parseString()) {
| 383-1199 | ||||||||||||||||||||||||
6023 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6024 | return false; executed 1199 times by 1 test: return false; Executed by:
| 1199 | ||||||||||||||||||||||||
6025 | } | - | ||||||||||||||||||||||||
6026 | break; executed 383 times by 1 test: break; Executed by:
| 383 | ||||||||||||||||||||||||
6027 | case Ws1: executed 1582 times by 1 test: case Ws1: Executed by:
| 1582 | ||||||||||||||||||||||||
6028 | if (!eat_ws()) {
| 465-1117 | ||||||||||||||||||||||||
6029 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6030 | return false; executed 465 times by 1 test: return false; Executed by:
| 465 | ||||||||||||||||||||||||
6031 | } | - | ||||||||||||||||||||||||
6032 | break; executed 1117 times by 1 test: break; Executed by:
| 1117 | ||||||||||||||||||||||||
6033 | case Nam: executed 1582 times by 1 test: case Nam: Executed by:
| 1582 | ||||||||||||||||||||||||
6034 | parseName_useRef = false; | - | ||||||||||||||||||||||||
6035 | if (!parseName()) {
| 621-961 | ||||||||||||||||||||||||
6036 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6037 | return false; executed 961 times by 1 test: return false; Executed by:
| 961 | ||||||||||||||||||||||||
6038 | } | - | ||||||||||||||||||||||||
6039 | break; executed 621 times by 1 test: break; Executed by:
| 621 | ||||||||||||||||||||||||
6040 | case Ws2: executed 1581 times by 1 test: case Ws2: Executed by:
| 1581 | ||||||||||||||||||||||||
6041 | if (!eat_ws()) {
| 254-1327 | ||||||||||||||||||||||||
6042 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6043 | return false; executed 254 times by 1 test: return false; Executed by:
| 254 | ||||||||||||||||||||||||
6044 | } | - | ||||||||||||||||||||||||
6045 | break; executed 1327 times by 1 test: break; Executed by:
| 1327 | ||||||||||||||||||||||||
6046 | case Empty: executed 104 times by 1 test: case Empty: Executed by:
| 104 | ||||||||||||||||||||||||
6047 | parseString_s = QLatin1String("EMPTY"); | - | ||||||||||||||||||||||||
6048 | if (!parseString()) {
| 39-65 | ||||||||||||||||||||||||
6049 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6050 | return false; executed 65 times by 1 test: return false; Executed by:
| 65 | ||||||||||||||||||||||||
6051 | } | - | ||||||||||||||||||||||||
6052 | break; executed 39 times by 1 test: break; Executed by:
| 39 | ||||||||||||||||||||||||
6053 | case Any: executed 30 times by 1 test: case Any: Executed by:
| 30 | ||||||||||||||||||||||||
6054 | parseString_s = QLatin1String("ANY"); | - | ||||||||||||||||||||||||
6055 | if (!parseString()) {
| 14-16 | ||||||||||||||||||||||||
6056 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6057 | return false; executed 16 times by 1 test: return false; Executed by:
| 16 | ||||||||||||||||||||||||
6058 | } | - | ||||||||||||||||||||||||
6059 | break; executed 14 times by 1 test: break; Executed by:
| 14 | ||||||||||||||||||||||||
6060 | case Cont: executed 1444 times by 1 test: case Cont: Executed by:
| 1444 | ||||||||||||||||||||||||
6061 | if (!next_eat_ws()) {
| 513-931 | ||||||||||||||||||||||||
6062 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6063 | return false; executed 513 times by 1 test: return false; Executed by:
| 513 | ||||||||||||||||||||||||
6064 | } | - | ||||||||||||||||||||||||
6065 | break; executed 931 times by 1 test: break; Executed by:
| 931 | ||||||||||||||||||||||||
6066 | case Mix: executed 1247 times by 1 test: case Mix: Executed by:
| 1247 | ||||||||||||||||||||||||
6067 | parseString_s = QLatin1String("#PCDATA"); | - | ||||||||||||||||||||||||
6068 | if (!parseString()) {
| 283-964 | ||||||||||||||||||||||||
6069 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6070 | return false; executed 964 times by 1 test: return false; Executed by:
| 964 | ||||||||||||||||||||||||
6071 | } | - | ||||||||||||||||||||||||
6072 | break; executed 283 times by 1 test: break; Executed by:
| 283 | ||||||||||||||||||||||||
6073 | case Mix2: executed 2 times by 1 test: case Mix2: Executed by:
| 2 | ||||||||||||||||||||||||
6074 | if (!eat_ws()) {
| 0-2 | ||||||||||||||||||||||||
6075 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6076 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6077 | } | - | ||||||||||||||||||||||||
6078 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
6079 | case Mix3: executed 1235 times by 1 test: case Mix3: Executed by:
| 1235 | ||||||||||||||||||||||||
6080 | next(); | - | ||||||||||||||||||||||||
6081 | break; executed 1235 times by 1 test: break; Executed by:
| 1235 | ||||||||||||||||||||||||
6082 | case MixN1: executed 12 times by 1 test: case MixN1: Executed by:
| 12 | ||||||||||||||||||||||||
6083 | if (!next_eat_ws()) {
| 5-7 | ||||||||||||||||||||||||
6084 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6085 | return false; executed 5 times by 1 test: return false; Executed by:
| 5 | ||||||||||||||||||||||||
6086 | } | - | ||||||||||||||||||||||||
6087 | break; executed 7 times by 1 test: break; Executed by:
| 7 | ||||||||||||||||||||||||
6088 | case MixN2: executed 11 times by 1 test: case MixN2: Executed by:
| 11 | ||||||||||||||||||||||||
6089 | parseName_useRef = false; | - | ||||||||||||||||||||||||
6090 | if (!parseName()) {
| 1-10 | ||||||||||||||||||||||||
6091 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6092 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
6093 | } | - | ||||||||||||||||||||||||
6094 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
6095 | case MixN3: never executed: case MixN3: | 0 | ||||||||||||||||||||||||
6096 | if (!eat_ws()) {
| 0 | ||||||||||||||||||||||||
6097 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6098 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6099 | } | - | ||||||||||||||||||||||||
6100 | break; never executed: break; | 0 | ||||||||||||||||||||||||
6101 | case MixN4: executed 10 times by 1 test: case MixN4: Executed by:
| 10 | ||||||||||||||||||||||||
6102 | next(); | - | ||||||||||||||||||||||||
6103 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
6104 | case Cp: executed 197 times by 1 test: case Cp: Executed by:
| 197 | ||||||||||||||||||||||||
6105 | if (!parseChoiceSeq()) {
| 94-103 | ||||||||||||||||||||||||
6106 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6107 | return false; executed 94 times by 1 test: return false; Executed by:
| 94 | ||||||||||||||||||||||||
6108 | } | - | ||||||||||||||||||||||||
6109 | break; executed 103 times by 1 test: break; Executed by:
| 103 | ||||||||||||||||||||||||
6110 | case Cp2: executed 32 times by 1 test: case Cp2: Executed by:
| 32 | ||||||||||||||||||||||||
6111 | next(); | - | ||||||||||||||||||||||||
6112 | break; executed 32 times by 1 test: break; Executed by:
| 32 | ||||||||||||||||||||||||
6113 | case WsD: executed 13 times by 1 test: case WsD: Executed by:
| 13 | ||||||||||||||||||||||||
6114 | if (!next_eat_ws()) {
| 1-12 | ||||||||||||||||||||||||
6115 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||||||||||||||
6116 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
6117 | } | - | ||||||||||||||||||||||||
6118 | break; executed 12 times by 1 test: break; Executed by:
| 12 | ||||||||||||||||||||||||
6119 | case Done: executed 1561 times by 1 test: case Done: Executed by:
| 1561 | ||||||||||||||||||||||||
6120 | next(); | - | ||||||||||||||||||||||||
6121 | break; executed 1561 times by 1 test: break; Executed by:
| 1561 | ||||||||||||||||||||||||
6122 | } | - | ||||||||||||||||||||||||
6123 | } executed 7699 times by 1 test: end of block Executed by:
| 7699 | ||||||||||||||||||||||||
6124 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6125 | } | - | ||||||||||||||||||||||||
6126 | - | |||||||||||||||||||||||||
6127 | /* | - | ||||||||||||||||||||||||
6128 | Parse a NotationDecl [82]. | - | ||||||||||||||||||||||||
6129 | - | |||||||||||||||||||||||||
6130 | Precondition: the beginning '<!' is already read and the head | - | ||||||||||||||||||||||||
6131 | stands on the 'N' of '<!NOTATION' | - | ||||||||||||||||||||||||
6132 | */ | - | ||||||||||||||||||||||||
6133 | bool QXmlSimpleReaderPrivate::parseNotationDecl() | - | ||||||||||||||||||||||||
6134 | { | - | ||||||||||||||||||||||||
6135 | const signed char Init = 0; | - | ||||||||||||||||||||||||
6136 | const signed char Not = 1; // read NOTATION | - | ||||||||||||||||||||||||
6137 | const signed char Ws1 = 2; // eat whitespaces | - | ||||||||||||||||||||||||
6138 | const signed char Nam = 3; // read Name | - | ||||||||||||||||||||||||
6139 | const signed char Ws2 = 4; // eat whitespaces | - | ||||||||||||||||||||||||
6140 | const signed char ExtID = 5; // parse ExternalID | - | ||||||||||||||||||||||||
6141 | const signed char ExtIDR = 6; // same as ExtID, but already reported | - | ||||||||||||||||||||||||
6142 | const signed char Ws3 = 7; // eat whitespaces | - | ||||||||||||||||||||||||
6143 | const signed char Done = 8; | - | ||||||||||||||||||||||||
6144 | - | |||||||||||||||||||||||||
6145 | const signed char InpWs = 0; | - | ||||||||||||||||||||||||
6146 | const signed char InpGt = 1; // > | - | ||||||||||||||||||||||||
6147 | const signed char InpN = 2; // N | - | ||||||||||||||||||||||||
6148 | const signed char InpUnknown = 3; | - | ||||||||||||||||||||||||
6149 | - | |||||||||||||||||||||||||
6150 | static const signed char table[8][4] = { | - | ||||||||||||||||||||||||
6151 | /* InpWs InpGt InpN InpUnknown */ | - | ||||||||||||||||||||||||
6152 | { -1, -1, Not, -1 }, // Init | - | ||||||||||||||||||||||||
6153 | { Ws1, -1, -1, -1 }, // Not | - | ||||||||||||||||||||||||
6154 | { -1, -1, Nam, Nam }, // Ws1 | - | ||||||||||||||||||||||||
6155 | { Ws2, Done, -1, -1 }, // Nam | - | ||||||||||||||||||||||||
6156 | { -1, Done, ExtID, ExtID }, // Ws2 | - | ||||||||||||||||||||||||
6157 | { Ws3, Done, -1, -1 }, // ExtID | - | ||||||||||||||||||||||||
6158 | { Ws3, Done, -1, -1 }, // ExtIDR | - | ||||||||||||||||||||||||
6159 | { -1, Done, -1, -1 } // Ws3 | - | ||||||||||||||||||||||||
6160 | }; | - | ||||||||||||||||||||||||
6161 | signed char state; | - | ||||||||||||||||||||||||
6162 | signed char input; | - | ||||||||||||||||||||||||
6163 | - | |||||||||||||||||||||||||
6164 | if (parseStack==0 || parseStack->isEmpty()) {
| 9-536 | ||||||||||||||||||||||||
6165 | state = Init; | - | ||||||||||||||||||||||||
6166 | } else { executed 54 times by 1 test: end of block Executed by:
| 54 | ||||||||||||||||||||||||
6167 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
6168 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
6169 | qDebug("QXmlSimpleReader: parseNotationDecl (cont) in state %d", state); | - | ||||||||||||||||||||||||
6170 | #endif | - | ||||||||||||||||||||||||
6171 | if (!parseStack->isEmpty()) {
| 19-472 | ||||||||||||||||||||||||
6172 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
6173 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 30-442 | ||||||||||||||||||||||||
6174 | parseStack->pop(); | - | ||||||||||||||||||||||||
6175 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
6176 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
6177 | #endif | - | ||||||||||||||||||||||||
6178 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||
6179 | if (!(this->*function)()) {
| 139-333 | ||||||||||||||||||||||||
6180 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||||||||||||||
6181 | return false; executed 333 times by 1 test: return false; Executed by:
| 333 | ||||||||||||||||||||||||
6182 | } | - | ||||||||||||||||||||||||
6183 | } executed 139 times by 1 test: end of block Executed by:
| 139 | ||||||||||||||||||||||||
6184 | } executed 158 times by 1 test: end of block Executed by:
| 158 | ||||||||||||||||||||||||
6185 | - | |||||||||||||||||||||||||
6186 | for (;;) { | - | ||||||||||||||||||||||||
6187 | switch (state) { | - | ||||||||||||||||||||||||
6188 | case ExtID: executed 54 times by 1 test: case ExtID: Executed by:
| 54 | ||||||||||||||||||||||||
6189 | // call the handler | - | ||||||||||||||||||||||||
6190 | if (dtdHnd) {
| 0-54 | ||||||||||||||||||||||||
6191 | if (!dtdHnd->notationDecl(name(), publicId, systemId)) {
| 0-54 | ||||||||||||||||||||||||
6192 | reportParseError(dtdHnd->errorString()); | - | ||||||||||||||||||||||||
6193 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6194 | } | - | ||||||||||||||||||||||||
6195 | } executed 54 times by 1 test: end of block Executed by:
| 54 | ||||||||||||||||||||||||
6196 | state = ExtIDR; | - | ||||||||||||||||||||||||
6197 | break; executed 54 times by 1 test: break; Executed by:
| 54 | ||||||||||||||||||||||||
6198 | case Done: executed 54 times by 1 test: case Done: Executed by:
| 54 | ||||||||||||||||||||||||
6199 | return true; executed 54 times by 1 test: return true; Executed by:
| 54 | ||||||||||||||||||||||||
6200 | case -1: never executed: case -1: | 0 | ||||||||||||||||||||||||
6201 | // Error | - | ||||||||||||||||||||||||
6202 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
6203 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6204 | } | - | ||||||||||||||||||||||||
6205 | - | |||||||||||||||||||||||||
6206 | if (atEnd()) {
| 19-324 | ||||||||||||||||||||||||
6207 | unexpectedEof(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||||||||||||||
6208 | return false; executed 19 times by 1 test: return false; Executed by:
| 19 | ||||||||||||||||||||||||
6209 | } | - | ||||||||||||||||||||||||
6210 | if (is_S(c)) {
| 108-216 | ||||||||||||||||||||||||
6211 | input = InpWs; | - | ||||||||||||||||||||||||
6212 | } else if (c == QLatin1Char('>')) { executed 108 times by 1 test: end of block Executed by:
| 54-162 | ||||||||||||||||||||||||
6213 | input = InpGt; | - | ||||||||||||||||||||||||
6214 | } else if (c == QLatin1Char('N')) { executed 54 times by 1 test: end of block Executed by:
| 54-108 | ||||||||||||||||||||||||
6215 | input = InpN; | - | ||||||||||||||||||||||||
6216 | } else { executed 54 times by 1 test: end of block Executed by:
| 54 | ||||||||||||||||||||||||
6217 | input = InpUnknown; | - | ||||||||||||||||||||||||
6218 | } executed 108 times by 1 test: end of block Executed by:
| 108 | ||||||||||||||||||||||||
6219 | state = table[state][input]; | - | ||||||||||||||||||||||||
6220 | - | |||||||||||||||||||||||||
6221 | switch (state) { | - | ||||||||||||||||||||||||
6222 | case Not: executed 54 times by 1 test: case Not: Executed by:
| 54 | ||||||||||||||||||||||||
6223 | parseString_s = QLatin1String("NOTATION"); | - | ||||||||||||||||||||||||
6224 | if (!parseString()) {
| 11-43 | ||||||||||||||||||||||||
6225 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||||||||||||||
6226 | return false; executed 43 times by 1 test: return false; Executed by:
| 43 | ||||||||||||||||||||||||
6227 | } | - | ||||||||||||||||||||||||
6228 | break; executed 11 times by 1 test: break; Executed by:
| 11 | ||||||||||||||||||||||||
6229 | case Ws1: executed 54 times by 1 test: case Ws1: Executed by:
| 54 | ||||||||||||||||||||||||
6230 | if (!eat_ws()) {
| 16-38 | ||||||||||||||||||||||||
6231 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||||||||||||||
6232 | return false; executed 16 times by 1 test: return false; Executed by:
| 16 | ||||||||||||||||||||||||
6233 | } | - | ||||||||||||||||||||||||
6234 | break; executed 38 times by 1 test: break; Executed by:
| 38 | ||||||||||||||||||||||||
6235 | case Nam: executed 54 times by 1 test: case Nam: Executed by:
| 54 | ||||||||||||||||||||||||
6236 | parseName_useRef = false; | - | ||||||||||||||||||||||||
6237 | if (!parseName()) {
| 21-33 | ||||||||||||||||||||||||
6238 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||||||||||||||
6239 | return false; executed 21 times by 1 test: return false; Executed by:
| 21 | ||||||||||||||||||||||||
6240 | } | - | ||||||||||||||||||||||||
6241 | break; executed 33 times by 1 test: break; Executed by:
| 33 | ||||||||||||||||||||||||
6242 | case Ws2: executed 54 times by 1 test: case Ws2: Executed by:
| 54 | ||||||||||||||||||||||||
6243 | if (!eat_ws()) {
| 14-40 | ||||||||||||||||||||||||
6244 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||||||||||||||
6245 | return false; executed 14 times by 1 test: return false; Executed by:
| 14 | ||||||||||||||||||||||||
6246 | } | - | ||||||||||||||||||||||||
6247 | break; executed 40 times by 1 test: break; Executed by:
| 40 | ||||||||||||||||||||||||
6248 | case ExtID: executed 54 times by 1 test: case ExtID: Executed by:
| 54 | ||||||||||||||||||||||||
6249 | case ExtIDR: never executed: case ExtIDR: | 0 | ||||||||||||||||||||||||
6250 | parseExternalID_allowPublicID = true; | - | ||||||||||||||||||||||||
6251 | if (!parseExternalID()) {
| 9-45 | ||||||||||||||||||||||||
6252 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||||||||||||||
6253 | return false; executed 45 times by 1 test: return false; Executed by:
| 45 | ||||||||||||||||||||||||
6254 | } | - | ||||||||||||||||||||||||
6255 | break; executed 9 times by 1 test: break; Executed by:
| 9 | ||||||||||||||||||||||||
6256 | case Ws3: never executed: case Ws3: | 0 | ||||||||||||||||||||||||
6257 | if (!eat_ws()) {
| 0 | ||||||||||||||||||||||||
6258 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||||||||||||||
6259 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6260 | } | - | ||||||||||||||||||||||||
6261 | break; never executed: break; | 0 | ||||||||||||||||||||||||
6262 | case Done: executed 54 times by 1 test: case Done: Executed by:
| 54 | ||||||||||||||||||||||||
6263 | next(); | - | ||||||||||||||||||||||||
6264 | break; executed 54 times by 1 test: break; Executed by:
| 54 | ||||||||||||||||||||||||
6265 | } | - | ||||||||||||||||||||||||
6266 | } executed 185 times by 1 test: end of block Executed by:
| 185 | ||||||||||||||||||||||||
6267 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6268 | } | - | ||||||||||||||||||||||||
6269 | - | |||||||||||||||||||||||||
6270 | /* | - | ||||||||||||||||||||||||
6271 | Parse choice [49] or seq [50]. | - | ||||||||||||||||||||||||
6272 | - | |||||||||||||||||||||||||
6273 | Precondition: the beginning '('S? is already read and the head | - | ||||||||||||||||||||||||
6274 | stands on the first non-whitespace character after it. | - | ||||||||||||||||||||||||
6275 | */ | - | ||||||||||||||||||||||||
6276 | bool QXmlSimpleReaderPrivate::parseChoiceSeq() | - | ||||||||||||||||||||||||
6277 | { | - | ||||||||||||||||||||||||
6278 | const signed char Init = 0; | - | ||||||||||||||||||||||||
6279 | const signed char Ws1 = 1; // eat whitespace | - | ||||||||||||||||||||||||
6280 | const signed char CoS = 2; // choice or set | - | ||||||||||||||||||||||||
6281 | const signed char Ws2 = 3; // eat whitespace | - | ||||||||||||||||||||||||
6282 | const signed char More = 4; // more cp to read | - | ||||||||||||||||||||||||
6283 | const signed char Name = 5; // read name | - | ||||||||||||||||||||||||
6284 | const signed char Done = 6; // | - | ||||||||||||||||||||||||
6285 | - | |||||||||||||||||||||||||
6286 | const signed char InpWs = 0; // S | - | ||||||||||||||||||||||||
6287 | const signed char InpOp = 1; // ( | - | ||||||||||||||||||||||||
6288 | const signed char InpCp = 2; //) | - | ||||||||||||||||||||||||
6289 | const signed char InpQm = 3; // ? | - | ||||||||||||||||||||||||
6290 | const signed char InpAst = 4; // * | - | ||||||||||||||||||||||||
6291 | const signed char InpPlus = 5; // + | - | ||||||||||||||||||||||||
6292 | const signed char InpPipe = 6; // | | - | ||||||||||||||||||||||||
6293 | const signed char InpComm = 7; // , | - | ||||||||||||||||||||||||
6294 | const signed char InpUnknown = 8; | - | ||||||||||||||||||||||||
6295 | - | |||||||||||||||||||||||||
6296 | static const signed char table[6][9] = { | - | ||||||||||||||||||||||||
6297 | /* InpWs InpOp InpCp InpQm InpAst InpPlus InpPipe InpComm InpUnknown */ | - | ||||||||||||||||||||||||
6298 | { -1, Ws1, -1, -1, -1, -1, -1, -1, Name }, // Init | - | ||||||||||||||||||||||||
6299 | { -1, CoS, -1, -1, -1, -1, -1, -1, CoS }, // Ws1 | - | ||||||||||||||||||||||||
6300 | { Ws2, -1, Done, Ws2, Ws2, Ws2, More, More, -1 }, // CS | - | ||||||||||||||||||||||||
6301 | { -1, -1, Done, -1, -1, -1, More, More, -1 }, // Ws2 | - | ||||||||||||||||||||||||
6302 | { -1, Ws1, -1, -1, -1, -1, -1, -1, Name }, // More (same as Init) | - | ||||||||||||||||||||||||
6303 | { Ws2, -1, Done, Ws2, Ws2, Ws2, More, More, -1 } // Name (same as CS) | - | ||||||||||||||||||||||||
6304 | }; | - | ||||||||||||||||||||||||
6305 | signed char state; | - | ||||||||||||||||||||||||
6306 | signed char input; | - | ||||||||||||||||||||||||
6307 | - | |||||||||||||||||||||||||
6308 | if (parseStack==0 || parseStack->isEmpty()) {
| 41-294 | ||||||||||||||||||||||||
6309 | state = Init; | - | ||||||||||||||||||||||||
6310 | } else { executed 203 times by 1 test: end of block Executed by:
| 203 | ||||||||||||||||||||||||
6311 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
6312 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
6313 | qDebug("QXmlSimpleReader: parseChoiceSeq (cont) in state %d", state); | - | ||||||||||||||||||||||||
6314 | #endif | - | ||||||||||||||||||||||||
6315 | if (!parseStack->isEmpty()) {
| 0-132 | ||||||||||||||||||||||||
6316 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
6317 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 59-73 | ||||||||||||||||||||||||
6318 | parseStack->pop(); | - | ||||||||||||||||||||||||
6319 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
6320 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
6321 | #endif | - | ||||||||||||||||||||||||
6322 | } executed 59 times by 1 test: end of block Executed by:
| 59 | ||||||||||||||||||||||||
6323 | if (!(this->*function)()) {
| 14-118 | ||||||||||||||||||||||||
6324 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||||||||||||||
6325 | return false; executed 14 times by 1 test: return false; Executed by:
| 14 | ||||||||||||||||||||||||
6326 | } | - | ||||||||||||||||||||||||
6327 | } executed 118 times by 1 test: end of block Executed by:
| 118 | ||||||||||||||||||||||||
6328 | } executed 118 times by 1 test: end of block Executed by:
| 118 | ||||||||||||||||||||||||
6329 | - | |||||||||||||||||||||||||
6330 | for (;;) { | - | ||||||||||||||||||||||||
6331 | switch (state) { | - | ||||||||||||||||||||||||
6332 | case Done: executed 193 times by 1 test: case Done: Executed by:
| 193 | ||||||||||||||||||||||||
6333 | return true; executed 193 times by 1 test: return true; Executed by:
| 193 | ||||||||||||||||||||||||
6334 | case -1: executed 4 times by 1 test: case -1: Executed by:
| 4 | ||||||||||||||||||||||||
6335 | // Error | - | ||||||||||||||||||||||||
6336 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
6337 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
6338 | } | - | ||||||||||||||||||||||||
6339 | - | |||||||||||||||||||||||||
6340 | if (atEnd()) {
| 0-623 | ||||||||||||||||||||||||
6341 | unexpectedEof(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||||||||||||||
6342 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6343 | } | - | ||||||||||||||||||||||||
6344 | if (is_S(c)) {
| 24-599 | ||||||||||||||||||||||||
6345 | input = InpWs; | - | ||||||||||||||||||||||||
6346 | } else if (c == QLatin1Char('(')) { executed 24 times by 1 test: end of block Executed by:
| 6-593 | ||||||||||||||||||||||||
6347 | input = InpOp; | - | ||||||||||||||||||||||||
6348 | } else if (c == QLatin1Char(')')) { executed 6 times by 1 test: end of block Executed by:
| 6-399 | ||||||||||||||||||||||||
6349 | input = InpCp; | - | ||||||||||||||||||||||||
6350 | } else if (c == QLatin1Char('?')) { executed 194 times by 1 test: end of block Executed by:
| 14-385 | ||||||||||||||||||||||||
6351 | input = InpQm; | - | ||||||||||||||||||||||||
6352 | } else if (c == QLatin1Char('*')) { executed 14 times by 1 test: end of block Executed by:
| 14-303 | ||||||||||||||||||||||||
6353 | input = InpAst; | - | ||||||||||||||||||||||||
6354 | } else if (c == QLatin1Char('+')) { executed 82 times by 1 test: end of block Executed by:
| 2-301 | ||||||||||||||||||||||||
6355 | input = InpPlus; | - | ||||||||||||||||||||||||
6356 | } else if (c == QLatin1Char('|')) { executed 2 times by 1 test: end of block Executed by:
| 2-278 | ||||||||||||||||||||||||
6357 | input = InpPipe; | - | ||||||||||||||||||||||||
6358 | } else if (c == QLatin1Char(',')) { executed 23 times by 1 test: end of block Executed by:
| 23-252 | ||||||||||||||||||||||||
6359 | input = InpComm; | - | ||||||||||||||||||||||||
6360 | } else { executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||
6361 | input = InpUnknown; | - | ||||||||||||||||||||||||
6362 | } executed 252 times by 1 test: end of block Executed by:
| 252 | ||||||||||||||||||||||||
6363 | state = table[state][input]; | - | ||||||||||||||||||||||||
6364 | - | |||||||||||||||||||||||||
6365 | switch (state) { | - | ||||||||||||||||||||||||
6366 | case Ws1: executed 6 times by 1 test: case Ws1: Executed by:
| 6 | ||||||||||||||||||||||||
6367 | if (!next_eat_ws()) {
| 0-6 | ||||||||||||||||||||||||
6368 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||||||||||||||
6369 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6370 | } | - | ||||||||||||||||||||||||
6371 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
6372 | case CoS: executed 6 times by 1 test: case CoS: Executed by:
| 6 | ||||||||||||||||||||||||
6373 | if (!parseChoiceSeq()) {
| 1-5 | ||||||||||||||||||||||||
6374 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||||||||||||||
6375 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
6376 | } | - | ||||||||||||||||||||||||
6377 | break; executed 5 times by 1 test: break; Executed by:
| 5 | ||||||||||||||||||||||||
6378 | case Ws2: executed 120 times by 1 test: case Ws2: Executed by:
| 120 | ||||||||||||||||||||||||
6379 | if (!next_eat_ws()) {
| 38-82 | ||||||||||||||||||||||||
6380 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||||||||||||||
6381 | return false; executed 38 times by 1 test: return false; Executed by:
| 38 | ||||||||||||||||||||||||
6382 | } | - | ||||||||||||||||||||||||
6383 | break; executed 82 times by 1 test: break; Executed by:
| 82 | ||||||||||||||||||||||||
6384 | case More: executed 49 times by 1 test: case More: Executed by:
| 49 | ||||||||||||||||||||||||
6385 | if (!next_eat_ws()) {
| 17-32 | ||||||||||||||||||||||||
6386 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||||||||||||||
6387 | return false; executed 17 times by 1 test: return false; Executed by:
| 17 | ||||||||||||||||||||||||
6388 | } | - | ||||||||||||||||||||||||
6389 | break; executed 32 times by 1 test: break; Executed by:
| 32 | ||||||||||||||||||||||||
6390 | case Name: executed 245 times by 1 test: case Name: Executed by:
| 245 | ||||||||||||||||||||||||
6391 | parseName_useRef = false; | - | ||||||||||||||||||||||||
6392 | if (!parseName()) {
| 68-177 | ||||||||||||||||||||||||
6393 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||||||||||||||
6394 | return false; executed 68 times by 1 test: return false; Executed by:
| 68 | ||||||||||||||||||||||||
6395 | } | - | ||||||||||||||||||||||||
6396 | break; executed 177 times by 1 test: break; Executed by:
| 177 | ||||||||||||||||||||||||
6397 | case Done: executed 193 times by 1 test: case Done: Executed by:
| 193 | ||||||||||||||||||||||||
6398 | next(); | - | ||||||||||||||||||||||||
6399 | break; executed 193 times by 1 test: break; Executed by:
| 193 | ||||||||||||||||||||||||
6400 | } | - | ||||||||||||||||||||||||
6401 | } executed 499 times by 1 test: end of block Executed by:
| 499 | ||||||||||||||||||||||||
6402 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6403 | } | - | ||||||||||||||||||||||||
6404 | - | |||||||||||||||||||||||||
6405 | bool QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(QString *errorMessage) | - | ||||||||||||||||||||||||
6406 | { | - | ||||||||||||||||||||||||
6407 | QString entityNameBuffer; | - | ||||||||||||||||||||||||
6408 | - | |||||||||||||||||||||||||
6409 | // For every entity, check how many times all entity names were referenced in its value. | - | ||||||||||||||||||||||||
6410 | for (QMap<QString,QString>::const_iterator toSearchIt = entities.constBegin(); | - | ||||||||||||||||||||||||
6411 | toSearchIt != entities.constEnd();
| 145-321 | ||||||||||||||||||||||||
6412 | ++toSearchIt) { | - | ||||||||||||||||||||||||
6413 | const QString &toSearch = toSearchIt.key(); | - | ||||||||||||||||||||||||
6414 | - | |||||||||||||||||||||||||
6415 | // Don't check the same entities twice. | - | ||||||||||||||||||||||||
6416 | if (!literalEntitySizes.contains(toSearch)) {
| 55-90 | ||||||||||||||||||||||||
6417 | // The amount of characters that weren't entity names, but literals, like 'X'. | - | ||||||||||||||||||||||||
6418 | QString leftOvers = entities.value(toSearch); | - | ||||||||||||||||||||||||
6419 | // How many times was entityName referenced by toSearch? | - | ||||||||||||||||||||||||
6420 | for (QMap<QString,QString>::const_iterator referencedIt = entities.constBegin(); | - | ||||||||||||||||||||||||
6421 | referencedIt != entities.constEnd();
| 90-145 | ||||||||||||||||||||||||
6422 | ++referencedIt) { | - | ||||||||||||||||||||||||
6423 | const QString &entityName = referencedIt.key(); | - | ||||||||||||||||||||||||
6424 | - | |||||||||||||||||||||||||
6425 | for (int i = 0; i < leftOvers.size() && i != -1; ) {
| 2-350 | ||||||||||||||||||||||||
6426 | entityNameBuffer = QLatin1Char('&') + entityName + QLatin1Char(';'); | - | ||||||||||||||||||||||||
6427 | - | |||||||||||||||||||||||||
6428 | i = leftOvers.indexOf(entityNameBuffer, i); | - | ||||||||||||||||||||||||
6429 | if (i != -1) {
| 64-143 | ||||||||||||||||||||||||
6430 | leftOvers.remove(i, entityName.size() + 2); | - | ||||||||||||||||||||||||
6431 | // The entityName we're currently trying to find was matched in this string; increase our count. | - | ||||||||||||||||||||||||
6432 | ++referencesToOtherEntities[toSearch][entityName]; | - | ||||||||||||||||||||||||
6433 | } executed 64 times by 1 test: end of block Executed by:
| 64 | ||||||||||||||||||||||||
6434 | } executed 207 times by 1 test: end of block Executed by:
| 207 | ||||||||||||||||||||||||
6435 | } executed 145 times by 1 test: end of block Executed by:
| 145 | ||||||||||||||||||||||||
6436 | literalEntitySizes[toSearch] = leftOvers.size(); | - | ||||||||||||||||||||||||
6437 | } executed 90 times by 1 test: end of block Executed by:
| 90 | ||||||||||||||||||||||||
6438 | } executed 145 times by 1 test: end of block Executed by:
| 145 | ||||||||||||||||||||||||
6439 | - | |||||||||||||||||||||||||
6440 | for (QHash<QString, QHash<QString, int> >::const_iterator entityIt = referencesToOtherEntities.constBegin(); | - | ||||||||||||||||||||||||
6441 | entityIt != referencesToOtherEntities.constEnd();
| 1-320 | ||||||||||||||||||||||||
6442 | ++entityIt) { | - | ||||||||||||||||||||||||
6443 | const QString &entity = entityIt.key(); | - | ||||||||||||||||||||||||
6444 | - | |||||||||||||||||||||||||
6445 | QHash<QString, int>::iterator expandedIt = expandedSizes.find(entity); | - | ||||||||||||||||||||||||
6446 | if (expandedIt == expandedSizes.end()) {
| 0-1 | ||||||||||||||||||||||||
6447 | expandedIt = expandedSizes.insert(entity, literalEntitySizes.value(entity)); | - | ||||||||||||||||||||||||
6448 | for (QHash<QString, int>::const_iterator referenceIt = entityIt->constBegin(); | - | ||||||||||||||||||||||||
6449 | referenceIt != entityIt->constEnd();
| 1 | ||||||||||||||||||||||||
6450 | ++referenceIt) { | - | ||||||||||||||||||||||||
6451 | const QString &referenceTo = referenceIt.key(); | - | ||||||||||||||||||||||||
6452 | const int references = referencesToOtherEntities.value(entity).value(referenceTo); | - | ||||||||||||||||||||||||
6453 | // The total size of an entity's value is the expanded size of all of its referenced entities, plus its literal size. | - | ||||||||||||||||||||||||
6454 | *expandedIt += expandedSizes.value(referenceTo) * references + literalEntitySizes.value(referenceTo) * references; | - | ||||||||||||||||||||||||
6455 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
6456 | - | |||||||||||||||||||||||||
6457 | if (*expandedIt > entityCharacterLimit) {
| 0-1 | ||||||||||||||||||||||||
6458 | if (errorMessage) {
| 0-1 | ||||||||||||||||||||||||
6459 | *errorMessage = QString::fromLatin1("The XML entity \"%1\" expands to a string that is too large to process (%2 characters > %3).") | - | ||||||||||||||||||||||||
6460 | .arg(entity, QString::number(*expandedIt), QString::number(entityCharacterLimit)); | - | ||||||||||||||||||||||||
6461 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
6462 | return true; executed 1 time by 1 test: return true; Executed by:
| 1 | ||||||||||||||||||||||||
6463 | } | - | ||||||||||||||||||||||||
6464 | } never executed: end of block | 0 | ||||||||||||||||||||||||
6465 | } never executed: end of block | 0 | ||||||||||||||||||||||||
6466 | return false; executed 320 times by 1 test: return false; Executed by:
| 320 | ||||||||||||||||||||||||
6467 | } | - | ||||||||||||||||||||||||
6468 | - | |||||||||||||||||||||||||
6469 | /* | - | ||||||||||||||||||||||||
6470 | Parse a EntityDecl [70]. | - | ||||||||||||||||||||||||
6471 | - | |||||||||||||||||||||||||
6472 | Precondition: the beginning '<!E' is already read and the head | - | ||||||||||||||||||||||||
6473 | stand on the 'N' of '<!ENTITY' | - | ||||||||||||||||||||||||
6474 | */ | - | ||||||||||||||||||||||||
6475 | bool QXmlSimpleReaderPrivate::parseEntityDecl() | - | ||||||||||||||||||||||||
6476 | { | - | ||||||||||||||||||||||||
6477 | const signed char Init = 0; | - | ||||||||||||||||||||||||
6478 | const signed char Ent = 1; // parse "ENTITY" | - | ||||||||||||||||||||||||
6479 | const signed char Ws1 = 2; // white space read | - | ||||||||||||||||||||||||
6480 | const signed char Name = 3; // parse name | - | ||||||||||||||||||||||||
6481 | const signed char Ws2 = 4; // white space read | - | ||||||||||||||||||||||||
6482 | const signed char EValue = 5; // parse entity value | - | ||||||||||||||||||||||||
6483 | const signed char EValueR = 6; // same as EValue, but already reported | - | ||||||||||||||||||||||||
6484 | const signed char ExtID = 7; // parse ExternalID | - | ||||||||||||||||||||||||
6485 | const signed char Ws3 = 8; // white space read | - | ||||||||||||||||||||||||
6486 | const signed char Ndata = 9; // parse "NDATA" | - | ||||||||||||||||||||||||
6487 | const signed char Ws4 = 10; // white space read | - | ||||||||||||||||||||||||
6488 | const signed char NNam = 11; // parse name | - | ||||||||||||||||||||||||
6489 | const signed char NNamR = 12; // same as NNam, but already reported | - | ||||||||||||||||||||||||
6490 | const signed char PEDec = 13; // parse PEDecl | - | ||||||||||||||||||||||||
6491 | const signed char Ws6 = 14; // white space read | - | ||||||||||||||||||||||||
6492 | const signed char PENam = 15; // parse name | - | ||||||||||||||||||||||||
6493 | const signed char Ws7 = 16; // white space read | - | ||||||||||||||||||||||||
6494 | const signed char PEVal = 17; // parse entity value | - | ||||||||||||||||||||||||
6495 | const signed char PEValR = 18; // same as PEVal, but already reported | - | ||||||||||||||||||||||||
6496 | const signed char PEEID = 19; // parse ExternalID | - | ||||||||||||||||||||||||
6497 | const signed char PEEIDR = 20; // same as PEEID, but already reported | - | ||||||||||||||||||||||||
6498 | const signed char WsE = 21; // white space read | - | ||||||||||||||||||||||||
6499 | const signed char Done = 22; | - | ||||||||||||||||||||||||
6500 | const signed char EDDone = 23; // done, but also report an external, unparsed entity decl | - | ||||||||||||||||||||||||
6501 | - | |||||||||||||||||||||||||
6502 | const signed char InpWs = 0; // white space | - | ||||||||||||||||||||||||
6503 | const signed char InpPer = 1; // % | - | ||||||||||||||||||||||||
6504 | const signed char InpQuot = 2; // " or ' | - | ||||||||||||||||||||||||
6505 | const signed char InpGt = 3; // > | - | ||||||||||||||||||||||||
6506 | const signed char InpN = 4; // N | - | ||||||||||||||||||||||||
6507 | const signed char InpUnknown = 5; | - | ||||||||||||||||||||||||
6508 | - | |||||||||||||||||||||||||
6509 | static const signed char table[22][6] = { | - | ||||||||||||||||||||||||
6510 | /* InpWs InpPer InpQuot InpGt InpN InpUnknown */ | - | ||||||||||||||||||||||||
6511 | { -1, -1, -1, -1, Ent, -1 }, // Init | - | ||||||||||||||||||||||||
6512 | { Ws1, -1, -1, -1, -1, -1 }, // Ent | - | ||||||||||||||||||||||||
6513 | { -1, PEDec, -1, -1, Name, Name }, // Ws1 | - | ||||||||||||||||||||||||
6514 | { Ws2, -1, -1, -1, -1, -1 }, // Name | - | ||||||||||||||||||||||||
6515 | { -1, -1, EValue, -1, -1, ExtID }, // Ws2 | - | ||||||||||||||||||||||||
6516 | { WsE, -1, -1, Done, -1, -1 }, // EValue | - | ||||||||||||||||||||||||
6517 | { WsE, -1, -1, Done, -1, -1 }, // EValueR | - | ||||||||||||||||||||||||
6518 | { Ws3, -1, -1, EDDone,-1, -1 }, // ExtID | - | ||||||||||||||||||||||||
6519 | { -1, -1, -1, EDDone,Ndata, -1 }, // Ws3 | - | ||||||||||||||||||||||||
6520 | { Ws4, -1, -1, -1, -1, -1 }, // Ndata | - | ||||||||||||||||||||||||
6521 | { -1, -1, -1, -1, NNam, NNam }, // Ws4 | - | ||||||||||||||||||||||||
6522 | { WsE, -1, -1, Done, -1, -1 }, // NNam | - | ||||||||||||||||||||||||
6523 | { WsE, -1, -1, Done, -1, -1 }, // NNamR | - | ||||||||||||||||||||||||
6524 | { Ws6, -1, -1, -1, -1, -1 }, // PEDec | - | ||||||||||||||||||||||||
6525 | { -1, -1, -1, -1, PENam, PENam }, // Ws6 | - | ||||||||||||||||||||||||
6526 | { Ws7, -1, -1, -1, -1, -1 }, // PENam | - | ||||||||||||||||||||||||
6527 | { -1, -1, PEVal, -1, -1, PEEID }, // Ws7 | - | ||||||||||||||||||||||||
6528 | { WsE, -1, -1, Done, -1, -1 }, // PEVal | - | ||||||||||||||||||||||||
6529 | { WsE, -1, -1, Done, -1, -1 }, // PEValR | - | ||||||||||||||||||||||||
6530 | { WsE, -1, -1, Done, -1, -1 }, // PEEID | - | ||||||||||||||||||||||||
6531 | { WsE, -1, -1, Done, -1, -1 }, // PEEIDR | - | ||||||||||||||||||||||||
6532 | { -1, -1, -1, Done, -1, -1 } // WsE | - | ||||||||||||||||||||||||
6533 | }; | - | ||||||||||||||||||||||||
6534 | signed char state; | - | ||||||||||||||||||||||||
6535 | signed char input; | - | ||||||||||||||||||||||||
6536 | - | |||||||||||||||||||||||||
6537 | if (parseStack==0 || parseStack->isEmpty()) {
| 145-3893 | ||||||||||||||||||||||||
6538 | state = Init; | - | ||||||||||||||||||||||||
6539 | } else { executed 667 times by 2 tests: end of block Executed by:
| 667 | ||||||||||||||||||||||||
6540 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
6541 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
6542 | qDebug("QXmlSimpleReader: parseEntityDecl (cont) in state %d", state); | - | ||||||||||||||||||||||||
6543 | #endif | - | ||||||||||||||||||||||||
6544 | if (!parseStack->isEmpty()) {
| 345-3026 | ||||||||||||||||||||||||
6545 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
6546 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 431-2595 | ||||||||||||||||||||||||
6547 | parseStack->pop(); | - | ||||||||||||||||||||||||
6548 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
6549 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
6550 | #endif | - | ||||||||||||||||||||||||
6551 | } executed 431 times by 1 test: end of block Executed by:
| 431 | ||||||||||||||||||||||||
6552 | if (!(this->*function)()) {
| 1477-1549 | ||||||||||||||||||||||||
6553 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6554 | return false; executed 1549 times by 1 test: return false; Executed by:
| 1549 | ||||||||||||||||||||||||
6555 | } | - | ||||||||||||||||||||||||
6556 | } executed 1477 times by 1 test: end of block Executed by:
| 1477 | ||||||||||||||||||||||||
6557 | } executed 1822 times by 1 test: end of block Executed by:
| 1822 | ||||||||||||||||||||||||
6558 | - | |||||||||||||||||||||||||
6559 | for (;;) { | - | ||||||||||||||||||||||||
6560 | switch (state) { | - | ||||||||||||||||||||||||
6561 | case EValue: executed 341 times by 1 test: case EValue: Executed by:
| 341 | ||||||||||||||||||||||||
6562 | if ( !entityExist(name())) {
| 20-321 | ||||||||||||||||||||||||
6563 | QString errorMessage; | - | ||||||||||||||||||||||||
6564 | if (isExpandedEntityValueTooLarge(&errorMessage)) {
| 1-320 | ||||||||||||||||||||||||
6565 | reportParseError(errorMessage); | - | ||||||||||||||||||||||||
6566 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
6567 | } | - | ||||||||||||||||||||||||
6568 | - | |||||||||||||||||||||||||
6569 | entities.insert(name(), string()); | - | ||||||||||||||||||||||||
6570 | if (declHnd) {
| 0-320 | ||||||||||||||||||||||||
6571 | if (!declHnd->internalEntityDecl(name(), string())) {
| 0-320 | ||||||||||||||||||||||||
6572 | reportParseError(declHnd->errorString()); | - | ||||||||||||||||||||||||
6573 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6574 | } | - | ||||||||||||||||||||||||
6575 | } executed 320 times by 1 test: end of block Executed by:
| 320 | ||||||||||||||||||||||||
6576 | } executed 320 times by 1 test: end of block Executed by:
| 320 | ||||||||||||||||||||||||
6577 | state = EValueR; | - | ||||||||||||||||||||||||
6578 | break; executed 340 times by 1 test: break; Executed by:
| 340 | ||||||||||||||||||||||||
6579 | case NNam: executed 12 times by 1 test: case NNam: Executed by:
| 12 | ||||||||||||||||||||||||
6580 | if ( !entityExist(name())) {
| 0-12 | ||||||||||||||||||||||||
6581 | externEntities.insert(name(), QXmlSimpleReaderPrivate::ExternEntity(publicId, systemId, ref())); | - | ||||||||||||||||||||||||
6582 | if (dtdHnd) {
| 0-12 | ||||||||||||||||||||||||
6583 | if (!dtdHnd->unparsedEntityDecl(name(), publicId, systemId, ref())) {
| 0-12 | ||||||||||||||||||||||||
6584 | reportParseError(declHnd->errorString()); | - | ||||||||||||||||||||||||
6585 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6586 | } | - | ||||||||||||||||||||||||
6587 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
6588 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
6589 | state = NNamR; | - | ||||||||||||||||||||||||
6590 | break; executed 12 times by 1 test: break; Executed by:
| 12 | ||||||||||||||||||||||||
6591 | case PEVal: executed 69 times by 1 test: case PEVal: Executed by:
| 69 | ||||||||||||||||||||||||
6592 | if ( !entityExist(name())) {
| 0-69 | ||||||||||||||||||||||||
6593 | parameterEntities.insert(name(), string()); | - | ||||||||||||||||||||||||
6594 | if (declHnd) {
| 0-69 | ||||||||||||||||||||||||
6595 | if (!declHnd->internalEntityDecl(QLatin1Char('%') + name(), string())) {
| 0-69 | ||||||||||||||||||||||||
6596 | reportParseError(declHnd->errorString()); | - | ||||||||||||||||||||||||
6597 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6598 | } | - | ||||||||||||||||||||||||
6599 | } executed 69 times by 1 test: end of block Executed by:
| 69 | ||||||||||||||||||||||||
6600 | } executed 69 times by 1 test: end of block Executed by:
| 69 | ||||||||||||||||||||||||
6601 | state = PEValR; | - | ||||||||||||||||||||||||
6602 | break; executed 69 times by 1 test: break; Executed by:
| 69 | ||||||||||||||||||||||||
6603 | case PEEID: executed 62 times by 1 test: case PEEID: Executed by:
| 62 | ||||||||||||||||||||||||
6604 | if ( !entityExist(name())) {
| 0-62 | ||||||||||||||||||||||||
6605 | externParameterEntities.insert(name(), QXmlSimpleReaderPrivate::ExternParameterEntity(publicId, systemId)); | - | ||||||||||||||||||||||||
6606 | if (declHnd) {
| 0-62 | ||||||||||||||||||||||||
6607 | if (!declHnd->externalEntityDecl(QLatin1Char('%') + name(), publicId, systemId)) {
| 0-62 | ||||||||||||||||||||||||
6608 | reportParseError(declHnd->errorString()); | - | ||||||||||||||||||||||||
6609 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6610 | } | - | ||||||||||||||||||||||||
6611 | } executed 62 times by 1 test: end of block Executed by:
| 62 | ||||||||||||||||||||||||
6612 | } executed 62 times by 1 test: end of block Executed by:
| 62 | ||||||||||||||||||||||||
6613 | state = PEEIDR; | - | ||||||||||||||||||||||||
6614 | break; executed 62 times by 1 test: break; Executed by:
| 62 | ||||||||||||||||||||||||
6615 | case EDDone: executed 172 times by 2 tests: case EDDone: Executed by:
| 172 | ||||||||||||||||||||||||
6616 | if ( !entityExist(name())) {
| 0-172 | ||||||||||||||||||||||||
6617 | externEntities.insert(name(), QXmlSimpleReaderPrivate::ExternEntity(publicId, systemId, QString())); | - | ||||||||||||||||||||||||
6618 | if (declHnd) {
| 19-153 | ||||||||||||||||||||||||
6619 | if (!declHnd->externalEntityDecl(name(), publicId, systemId)) {
| 0-153 | ||||||||||||||||||||||||
6620 | reportParseError(declHnd->errorString()); | - | ||||||||||||||||||||||||
6621 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6622 | } | - | ||||||||||||||||||||||||
6623 | } executed 153 times by 1 test: end of block Executed by:
| 153 | ||||||||||||||||||||||||
6624 | } executed 172 times by 2 tests: end of block Executed by:
| 172 | ||||||||||||||||||||||||
6625 | return true; executed 172 times by 2 tests: return true; Executed by:
| 172 | ||||||||||||||||||||||||
6626 | case Done: executed 480 times by 1 test: case Done: Executed by:
| 480 | ||||||||||||||||||||||||
6627 | return true; executed 480 times by 1 test: return true; Executed by:
| 480 | ||||||||||||||||||||||||
6628 | case -1: executed 6 times by 1 test: case -1: Executed by:
| 6 | ||||||||||||||||||||||||
6629 | // Error | - | ||||||||||||||||||||||||
6630 | reportParseError(QLatin1String(XMLERR_LETTEREXPECTED)); | - | ||||||||||||||||||||||||
6631 | return false; executed 6 times by 1 test: return false; Executed by:
| 6 | ||||||||||||||||||||||||
6632 | } | - | ||||||||||||||||||||||||
6633 | - | |||||||||||||||||||||||||
6634 | if (atEnd()) {
| 345-4302 | ||||||||||||||||||||||||
6635 | unexpectedEof(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6636 | return false; executed 345 times by 1 test: return false; Executed by:
| 345 | ||||||||||||||||||||||||
6637 | } | - | ||||||||||||||||||||||||
6638 | if (is_S(c)) {
| 1490-2812 | ||||||||||||||||||||||||
6639 | input = InpWs; | - | ||||||||||||||||||||||||
6640 | } else if (c == QLatin1Char('%')) { executed 1490 times by 2 tests: end of block Executed by:
| 134-2678 | ||||||||||||||||||||||||
6641 | input = InpPer; | - | ||||||||||||||||||||||||
6642 | } else if (c == QLatin1Char('"') || c == QLatin1Char('\'')) { executed 134 times by 1 test: end of block Executed by:
| 1-2263 | ||||||||||||||||||||||||
6643 | input = InpQuot; | - | ||||||||||||||||||||||||
6644 | } else if (c == QLatin1Char('>')) { executed 416 times by 1 test: end of block Executed by:
| 416-1610 | ||||||||||||||||||||||||
6645 | input = InpGt; | - | ||||||||||||||||||||||||
6646 | } else if (c == QLatin1Char('N')) { executed 652 times by 2 tests: end of block Executed by:
| 652-928 | ||||||||||||||||||||||||
6647 | input = InpN; | - | ||||||||||||||||||||||||
6648 | } else { executed 682 times by 2 tests: end of block Executed by:
| 682 | ||||||||||||||||||||||||
6649 | input = InpUnknown; | - | ||||||||||||||||||||||||
6650 | } executed 928 times by 2 tests: end of block Executed by:
| 928 | ||||||||||||||||||||||||
6651 | state = table[state][input]; | - | ||||||||||||||||||||||||
6652 | - | |||||||||||||||||||||||||
6653 | switch (state) { | - | ||||||||||||||||||||||||
6654 | case Ent: executed 667 times by 2 tests: case Ent: Executed by:
| 667 | ||||||||||||||||||||||||
6655 | parseString_s = QLatin1String("NTITY"); | - | ||||||||||||||||||||||||
6656 | if (!parseString()) {
| 240-427 | ||||||||||||||||||||||||
6657 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6658 | return false; executed 427 times by 1 test: return false; Executed by:
| 427 | ||||||||||||||||||||||||
6659 | } | - | ||||||||||||||||||||||||
6660 | break; executed 240 times by 2 tests: break; Executed by:
| 240 | ||||||||||||||||||||||||
6661 | case Ws1: executed 666 times by 2 tests: case Ws1: Executed by:
| 666 | ||||||||||||||||||||||||
6662 | if (!eat_ws()) {
| 162-504 | ||||||||||||||||||||||||
6663 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6664 | return false; executed 162 times by 1 test: return false; Executed by:
| 162 | ||||||||||||||||||||||||
6665 | } | - | ||||||||||||||||||||||||
6666 | break; executed 504 times by 2 tests: break; Executed by:
| 504 | ||||||||||||||||||||||||
6667 | case Name: executed 533 times by 2 tests: case Name: Executed by:
| 533 | ||||||||||||||||||||||||
6668 | parseName_useRef = false; | - | ||||||||||||||||||||||||
6669 | if (!parseName()) {
| 145-388 | ||||||||||||||||||||||||
6670 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6671 | return false; executed 145 times by 1 test: return false; Executed by:
| 145 | ||||||||||||||||||||||||
6672 | } | - | ||||||||||||||||||||||||
6673 | break; executed 388 times by 2 tests: break; Executed by:
| 388 | ||||||||||||||||||||||||
6674 | case Ws2: executed 531 times by 2 tests: case Ws2: Executed by:
| 531 | ||||||||||||||||||||||||
6675 | if (!eat_ws()) {
| 164-367 | ||||||||||||||||||||||||
6676 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6677 | return false; executed 164 times by 1 test: return false; Executed by:
| 164 | ||||||||||||||||||||||||
6678 | } | - | ||||||||||||||||||||||||
6679 | break; executed 367 times by 2 tests: break; Executed by:
| 367 | ||||||||||||||||||||||||
6680 | case EValue: executed 344 times by 1 test: case EValue: Executed by:
| 344 | ||||||||||||||||||||||||
6681 | case EValueR: never executed: case EValueR: | 0 | ||||||||||||||||||||||||
6682 | if (!parseEntityValue()) {
| 137-207 | ||||||||||||||||||||||||
6683 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6684 | return false; executed 207 times by 1 test: return false; Executed by:
| 207 | ||||||||||||||||||||||||
6685 | } | - | ||||||||||||||||||||||||
6686 | break; executed 137 times by 1 test: break; Executed by:
| 137 | ||||||||||||||||||||||||
6687 | case ExtID: executed 187 times by 2 tests: case ExtID: Executed by:
| 187 | ||||||||||||||||||||||||
6688 | parseExternalID_allowPublicID = false; | - | ||||||||||||||||||||||||
6689 | if (!parseExternalID()) {
| 41-146 | ||||||||||||||||||||||||
6690 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6691 | return false; executed 146 times by 1 test: return false; Executed by:
| 146 | ||||||||||||||||||||||||
6692 | } | - | ||||||||||||||||||||||||
6693 | break; executed 41 times by 2 tests: break; Executed by:
| 41 | ||||||||||||||||||||||||
6694 | case Ws3: executed 12 times by 1 test: case Ws3: Executed by:
| 12 | ||||||||||||||||||||||||
6695 | if (!eat_ws()) {
| 3-9 | ||||||||||||||||||||||||
6696 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6697 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
6698 | } | - | ||||||||||||||||||||||||
6699 | break; executed 9 times by 1 test: break; Executed by:
| 9 | ||||||||||||||||||||||||
6700 | case Ndata: executed 12 times by 1 test: case Ndata: Executed by:
| 12 | ||||||||||||||||||||||||
6701 | parseString_s = QLatin1String("NDATA"); | - | ||||||||||||||||||||||||
6702 | if (!parseString()) {
| 6 | ||||||||||||||||||||||||
6703 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6704 | return false; executed 6 times by 1 test: return false; Executed by:
| 6 | ||||||||||||||||||||||||
6705 | } | - | ||||||||||||||||||||||||
6706 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
6707 | case Ws4: executed 12 times by 1 test: case Ws4: Executed by:
| 12 | ||||||||||||||||||||||||
6708 | if (!eat_ws()) {
| 4-8 | ||||||||||||||||||||||||
6709 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6710 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
6711 | } | - | ||||||||||||||||||||||||
6712 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||||||||||||||
6713 | case NNam: executed 12 times by 1 test: case NNam: Executed by:
| 12 | ||||||||||||||||||||||||
6714 | case NNamR: never executed: case NNamR: | 0 | ||||||||||||||||||||||||
6715 | parseName_useRef = true; | - | ||||||||||||||||||||||||
6716 | if (!parseName()) {
| 2-10 | ||||||||||||||||||||||||
6717 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6718 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
6719 | } | - | ||||||||||||||||||||||||
6720 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
6721 | case PEDec: executed 133 times by 1 test: case PEDec: Executed by:
| 133 | ||||||||||||||||||||||||
6722 | next(); | - | ||||||||||||||||||||||||
6723 | break; executed 133 times by 1 test: break; Executed by:
| 133 | ||||||||||||||||||||||||
6724 | case Ws6: executed 133 times by 1 test: case Ws6: Executed by:
| 133 | ||||||||||||||||||||||||
6725 | if (!eat_ws()) {
| 52-81 | ||||||||||||||||||||||||
6726 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6727 | return false; executed 52 times by 1 test: return false; Executed by:
| 52 | ||||||||||||||||||||||||
6728 | } | - | ||||||||||||||||||||||||
6729 | break; executed 81 times by 1 test: break; Executed by:
| 81 | ||||||||||||||||||||||||
6730 | case PENam: executed 133 times by 1 test: case PENam: Executed by:
| 133 | ||||||||||||||||||||||||
6731 | parseName_useRef = false; | - | ||||||||||||||||||||||||
6732 | if (!parseName()) {
| 18-115 | ||||||||||||||||||||||||
6733 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6734 | return false; executed 18 times by 1 test: return false; Executed by:
| 18 | ||||||||||||||||||||||||
6735 | } | - | ||||||||||||||||||||||||
6736 | break; executed 115 times by 1 test: break; Executed by:
| 115 | ||||||||||||||||||||||||
6737 | case Ws7: executed 133 times by 1 test: case Ws7: Executed by:
| 133 | ||||||||||||||||||||||||
6738 | if (!eat_ws()) {
| 46-87 | ||||||||||||||||||||||||
6739 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6740 | return false; executed 46 times by 1 test: return false; Executed by:
| 46 | ||||||||||||||||||||||||
6741 | } | - | ||||||||||||||||||||||||
6742 | break; executed 87 times by 1 test: break; Executed by:
| 87 | ||||||||||||||||||||||||
6743 | case PEVal: executed 71 times by 1 test: case PEVal: Executed by:
| 71 | ||||||||||||||||||||||||
6744 | case PEValR: never executed: case PEValR: | 0 | ||||||||||||||||||||||||
6745 | if (!parseEntityValue()) {
| 22-49 | ||||||||||||||||||||||||
6746 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6747 | return false; executed 49 times by 1 test: return false; Executed by:
| 49 | ||||||||||||||||||||||||
6748 | } | - | ||||||||||||||||||||||||
6749 | break; executed 22 times by 1 test: break; Executed by:
| 22 | ||||||||||||||||||||||||
6750 | case PEEID: executed 62 times by 1 test: case PEEID: Executed by:
| 62 | ||||||||||||||||||||||||
6751 | case PEEIDR: never executed: case PEEIDR: | 0 | ||||||||||||||||||||||||
6752 | parseExternalID_allowPublicID = false; | - | ||||||||||||||||||||||||
6753 | if (!parseExternalID()) {
| 8-54 | ||||||||||||||||||||||||
6754 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6755 | return false; executed 54 times by 1 test: return false; Executed by:
| 54 | ||||||||||||||||||||||||
6756 | } | - | ||||||||||||||||||||||||
6757 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||||||||||||||
6758 | case WsE: executed 3 times by 1 test: case WsE: Executed by:
| 3 | ||||||||||||||||||||||||
6759 | if (!eat_ws()) {
| 0-3 | ||||||||||||||||||||||||
6760 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||||||||||||||
6761 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6762 | } | - | ||||||||||||||||||||||||
6763 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
6764 | case EDDone: executed 172 times by 2 tests: case EDDone: Executed by:
| 172 | ||||||||||||||||||||||||
6765 | next(); | - | ||||||||||||||||||||||||
6766 | break; executed 172 times by 2 tests: break; Executed by:
| 172 | ||||||||||||||||||||||||
6767 | case Done: executed 480 times by 1 test: case Done: Executed by:
| 480 | ||||||||||||||||||||||||
6768 | next(); | - | ||||||||||||||||||||||||
6769 | break; executed 480 times by 1 test: break; Executed by:
| 480 | ||||||||||||||||||||||||
6770 | } | - | ||||||||||||||||||||||||
6771 | } executed 2817 times by 2 tests: end of block Executed by:
| 2817 | ||||||||||||||||||||||||
6772 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6773 | } | - | ||||||||||||||||||||||||
6774 | - | |||||||||||||||||||||||||
6775 | /* | - | ||||||||||||||||||||||||
6776 | Parse a EntityValue [9] | - | ||||||||||||||||||||||||
6777 | */ | - | ||||||||||||||||||||||||
6778 | bool QXmlSimpleReaderPrivate::parseEntityValue() | - | ||||||||||||||||||||||||
6779 | { | - | ||||||||||||||||||||||||
6780 | const signed char Init = 0; | - | ||||||||||||||||||||||||
6781 | const signed char Dq = 1; // EntityValue is double quoted | - | ||||||||||||||||||||||||
6782 | const signed char DqC = 2; // signed character | - | ||||||||||||||||||||||||
6783 | const signed char DqPER = 3; // PERefence | - | ||||||||||||||||||||||||
6784 | const signed char DqRef = 4; // Reference | - | ||||||||||||||||||||||||
6785 | const signed char Sq = 5; // EntityValue is double quoted | - | ||||||||||||||||||||||||
6786 | const signed char SqC = 6; // signed character | - | ||||||||||||||||||||||||
6787 | const signed char SqPER = 7; // PERefence | - | ||||||||||||||||||||||||
6788 | const signed char SqRef = 8; // Reference | - | ||||||||||||||||||||||||
6789 | const signed char Done = 9; | - | ||||||||||||||||||||||||
6790 | - | |||||||||||||||||||||||||
6791 | const signed char InpDq = 0; // " | - | ||||||||||||||||||||||||
6792 | const signed char InpSq = 1; // ' | - | ||||||||||||||||||||||||
6793 | const signed char InpAmp = 2; // & | - | ||||||||||||||||||||||||
6794 | const signed char InpPer = 3; // % | - | ||||||||||||||||||||||||
6795 | const signed char InpUnknown = 4; | - | ||||||||||||||||||||||||
6796 | - | |||||||||||||||||||||||||
6797 | static const signed char table[9][5] = { | - | ||||||||||||||||||||||||
6798 | /* InpDq InpSq InpAmp InpPer InpUnknown */ | - | ||||||||||||||||||||||||
6799 | { Dq, Sq, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
6800 | { Done, DqC, DqRef, DqPER, DqC }, // Dq | - | ||||||||||||||||||||||||
6801 | { Done, DqC, DqRef, DqPER, DqC }, // DqC | - | ||||||||||||||||||||||||
6802 | { Done, DqC, DqRef, DqPER, DqC }, // DqPER | - | ||||||||||||||||||||||||
6803 | { Done, DqC, DqRef, DqPER, DqC }, // DqRef | - | ||||||||||||||||||||||||
6804 | { SqC, Done, SqRef, SqPER, SqC }, // Sq | - | ||||||||||||||||||||||||
6805 | { SqC, Done, SqRef, SqPER, SqC }, // SqC | - | ||||||||||||||||||||||||
6806 | { SqC, Done, SqRef, SqPER, SqC }, // SqPER | - | ||||||||||||||||||||||||
6807 | { SqC, Done, SqRef, SqPER, SqC } // SqRef | - | ||||||||||||||||||||||||
6808 | }; | - | ||||||||||||||||||||||||
6809 | signed char state; | - | ||||||||||||||||||||||||
6810 | signed char input; | - | ||||||||||||||||||||||||
6811 | - | |||||||||||||||||||||||||
6812 | if (parseStack==0 || parseStack->isEmpty()) {
| 91-957 | ||||||||||||||||||||||||
6813 | state = Init; | - | ||||||||||||||||||||||||
6814 | } else { executed 415 times by 1 test: end of block Executed by:
| 415 | ||||||||||||||||||||||||
6815 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
6816 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
6817 | qDebug("QXmlSimpleReader: parseEntityValue (cont) in state %d", state); | - | ||||||||||||||||||||||||
6818 | #endif | - | ||||||||||||||||||||||||
6819 | if (!parseStack->isEmpty()) {
| 172-461 | ||||||||||||||||||||||||
6820 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
6821 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 0-172 | ||||||||||||||||||||||||
6822 | parseStack->pop(); | - | ||||||||||||||||||||||||
6823 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
6824 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
6825 | #endif | - | ||||||||||||||||||||||||
6826 | } never executed: end of block | 0 | ||||||||||||||||||||||||
6827 | if (!(this->*function)()) {
| 60-112 | ||||||||||||||||||||||||
6828 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityValue, state); | - | ||||||||||||||||||||||||
6829 | return false; executed 60 times by 1 test: return false; Executed by:
| 60 | ||||||||||||||||||||||||
6830 | } | - | ||||||||||||||||||||||||
6831 | } executed 112 times by 1 test: end of block Executed by:
| 112 | ||||||||||||||||||||||||
6832 | } executed 573 times by 1 test: end of block Executed by:
| 573 | ||||||||||||||||||||||||
6833 | - | |||||||||||||||||||||||||
6834 | for (;;) { | - | ||||||||||||||||||||||||
6835 | switch (state) { | - | ||||||||||||||||||||||||
6836 | case Done: executed 410 times by 1 test: case Done: Executed by:
| 410 | ||||||||||||||||||||||||
6837 | return true; executed 410 times by 1 test: return true; Executed by:
| 410 | ||||||||||||||||||||||||
6838 | case -1: never executed: case -1: | 0 | ||||||||||||||||||||||||
6839 | // Error | - | ||||||||||||||||||||||||
6840 | reportParseError(QLatin1String(XMLERR_LETTEREXPECTED)); | - | ||||||||||||||||||||||||
6841 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6842 | } | - | ||||||||||||||||||||||||
6843 | - | |||||||||||||||||||||||||
6844 | if (atEnd()) {
| 463-2711 | ||||||||||||||||||||||||
6845 | unexpectedEof(&QXmlSimpleReaderPrivate::parseEntityValue, state); | - | ||||||||||||||||||||||||
6846 | return false; executed 463 times by 1 test: return false; Executed by:
| 463 | ||||||||||||||||||||||||
6847 | } | - | ||||||||||||||||||||||||
6848 | if (c == QLatin1Char('"')) {
| 824-1887 | ||||||||||||||||||||||||
6849 | input = InpDq; | - | ||||||||||||||||||||||||
6850 | } else if (c == QLatin1Char('\'')) { executed 824 times by 1 test: end of block Executed by:
| 10-1877 | ||||||||||||||||||||||||
6851 | input = InpSq; | - | ||||||||||||||||||||||||
6852 | } else if (c == QLatin1Char('&')) { executed 10 times by 1 test: end of block Executed by:
| 10-1535 | ||||||||||||||||||||||||
6853 | input = InpAmp; | - | ||||||||||||||||||||||||
6854 | } else if (c == QLatin1Char('%')) { executed 342 times by 1 test: end of block Executed by:
| 15-1520 | ||||||||||||||||||||||||
6855 | input = InpPer; | - | ||||||||||||||||||||||||
6856 | } else { executed 15 times by 1 test: end of block Executed by:
| 15 | ||||||||||||||||||||||||
6857 | input = InpUnknown; | - | ||||||||||||||||||||||||
6858 | } executed 1520 times by 1 test: end of block Executed by:
| 1520 | ||||||||||||||||||||||||
6859 | state = table[state][input]; | - | ||||||||||||||||||||||||
6860 | - | |||||||||||||||||||||||||
6861 | switch (state) { | - | ||||||||||||||||||||||||
6862 | case Dq: executed 414 times by 1 test: case Dq: Executed by:
| 414 | ||||||||||||||||||||||||
6863 | case Sq: executed 1 time by 1 test: case Sq: Executed by:
| 1 | ||||||||||||||||||||||||
6864 | stringClear(); | - | ||||||||||||||||||||||||
6865 | next(); | - | ||||||||||||||||||||||||
6866 | break; executed 415 times by 1 test: break; Executed by:
| 415 | ||||||||||||||||||||||||
6867 | case DqC: executed 1528 times by 1 test: case DqC: Executed by:
| 1528 | ||||||||||||||||||||||||
6868 | case SqC: executed 1 time by 1 test: case SqC: Executed by:
| 1 | ||||||||||||||||||||||||
6869 | stringAddC(); | - | ||||||||||||||||||||||||
6870 | next(); | - | ||||||||||||||||||||||||
6871 | break; executed 1529 times by 1 test: break; Executed by:
| 1529 | ||||||||||||||||||||||||
6872 | case DqPER: executed 15 times by 1 test: case DqPER: Executed by:
| 15 | ||||||||||||||||||||||||
6873 | case SqPER: never executed: case SqPER: | 0 | ||||||||||||||||||||||||
6874 | parsePEReference_context = InEntityValue; | - | ||||||||||||||||||||||||
6875 | if (!parsePEReference()) {
| 0-15 | ||||||||||||||||||||||||
6876 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityValue, state); | - | ||||||||||||||||||||||||
6877 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6878 | } | - | ||||||||||||||||||||||||
6879 | break; executed 15 times by 1 test: break; Executed by:
| 15 | ||||||||||||||||||||||||
6880 | case DqRef: executed 342 times by 1 test: case DqRef: Executed by:
| 342 | ||||||||||||||||||||||||
6881 | case SqRef: never executed: case SqRef: | 0 | ||||||||||||||||||||||||
6882 | parseReference_context = InEntityValue; | - | ||||||||||||||||||||||||
6883 | if (!parseReference()) {
| 115-227 | ||||||||||||||||||||||||
6884 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityValue, state); | - | ||||||||||||||||||||||||
6885 | return false; executed 115 times by 1 test: return false; Executed by:
| 115 | ||||||||||||||||||||||||
6886 | } | - | ||||||||||||||||||||||||
6887 | break; executed 227 times by 1 test: break; Executed by:
| 227 | ||||||||||||||||||||||||
6888 | case Done: executed 410 times by 1 test: case Done: Executed by:
| 410 | ||||||||||||||||||||||||
6889 | next(); | - | ||||||||||||||||||||||||
6890 | break; executed 410 times by 1 test: break; Executed by:
| 410 | ||||||||||||||||||||||||
6891 | } | - | ||||||||||||||||||||||||
6892 | } executed 2596 times by 1 test: end of block Executed by:
| 2596 | ||||||||||||||||||||||||
6893 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6894 | } | - | ||||||||||||||||||||||||
6895 | - | |||||||||||||||||||||||||
6896 | /* | - | ||||||||||||||||||||||||
6897 | Parse a comment [15]. | - | ||||||||||||||||||||||||
6898 | - | |||||||||||||||||||||||||
6899 | Precondition: the beginning '<!' of the comment is already read and the head | - | ||||||||||||||||||||||||
6900 | stands on the first '-' of '<!--'. | - | ||||||||||||||||||||||||
6901 | - | |||||||||||||||||||||||||
6902 | If this funktion was successful, the head-position is on the first | - | ||||||||||||||||||||||||
6903 | character after the comment. | - | ||||||||||||||||||||||||
6904 | */ | - | ||||||||||||||||||||||||
6905 | bool QXmlSimpleReaderPrivate::parseComment() | - | ||||||||||||||||||||||||
6906 | { | - | ||||||||||||||||||||||||
6907 | const signed char Init = 0; | - | ||||||||||||||||||||||||
6908 | const signed char Dash1 = 1; // the first dash was read | - | ||||||||||||||||||||||||
6909 | const signed char Dash2 = 2; // the second dash was read | - | ||||||||||||||||||||||||
6910 | const signed char Com = 3; // read comment | - | ||||||||||||||||||||||||
6911 | const signed char Com2 = 4; // read comment (help state) | - | ||||||||||||||||||||||||
6912 | const signed char ComE = 5; // finished reading comment | - | ||||||||||||||||||||||||
6913 | const signed char Done = 6; | - | ||||||||||||||||||||||||
6914 | - | |||||||||||||||||||||||||
6915 | const signed char InpDash = 0; // - | - | ||||||||||||||||||||||||
6916 | const signed char InpGt = 1; // > | - | ||||||||||||||||||||||||
6917 | const signed char InpUnknown = 2; | - | ||||||||||||||||||||||||
6918 | - | |||||||||||||||||||||||||
6919 | static const signed char table[6][3] = { | - | ||||||||||||||||||||||||
6920 | /* InpDash InpGt InpUnknown */ | - | ||||||||||||||||||||||||
6921 | { Dash1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
6922 | { Dash2, -1, -1 }, // Dash1 | - | ||||||||||||||||||||||||
6923 | { Com2, Com, Com }, // Dash2 | - | ||||||||||||||||||||||||
6924 | { Com2, Com, Com }, // Com | - | ||||||||||||||||||||||||
6925 | { ComE, Com, Com }, // Com2 | - | ||||||||||||||||||||||||
6926 | { -1, Done, -1 } // ComE | - | ||||||||||||||||||||||||
6927 | }; | - | ||||||||||||||||||||||||
6928 | signed char state; | - | ||||||||||||||||||||||||
6929 | signed char input; | - | ||||||||||||||||||||||||
6930 | - | |||||||||||||||||||||||||
6931 | if (parseStack==0 || parseStack->isEmpty()) {
| 63-527 | ||||||||||||||||||||||||
6932 | state = Init; | - | ||||||||||||||||||||||||
6933 | } else { executed 151 times by 2 tests: end of block Executed by:
| 151 | ||||||||||||||||||||||||
6934 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
6935 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
6936 | qDebug("QXmlSimpleReader: parseComment (cont) in state %d", state); | - | ||||||||||||||||||||||||
6937 | #endif | - | ||||||||||||||||||||||||
6938 | if (!parseStack->isEmpty()) {
| 0-464 | ||||||||||||||||||||||||
6939 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
6940 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 0 | ||||||||||||||||||||||||
6941 | parseStack->pop(); | - | ||||||||||||||||||||||||
6942 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
6943 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
6944 | #endif | - | ||||||||||||||||||||||||
6945 | } never executed: end of block | 0 | ||||||||||||||||||||||||
6946 | if (!(this->*function)()) {
| 0 | ||||||||||||||||||||||||
6947 | parseFailed(&QXmlSimpleReaderPrivate::parseComment, state); | - | ||||||||||||||||||||||||
6948 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
6949 | } | - | ||||||||||||||||||||||||
6950 | } never executed: end of block | 0 | ||||||||||||||||||||||||
6951 | } executed 464 times by 1 test: end of block Executed by:
| 464 | ||||||||||||||||||||||||
6952 | - | |||||||||||||||||||||||||
6953 | for (;;) { | - | ||||||||||||||||||||||||
6954 | switch (state) { | - | ||||||||||||||||||||||||
6955 | case Dash2: executed 176 times by 2 tests: case Dash2: Executed by:
| 176 | ||||||||||||||||||||||||
6956 | stringClear(); | - | ||||||||||||||||||||||||
6957 | break; executed 176 times by 2 tests: break; Executed by:
| 176 | ||||||||||||||||||||||||
6958 | case Com2: executed 234 times by 2 tests: case Com2: Executed by:
| 234 | ||||||||||||||||||||||||
6959 | // if next character is not a dash than don't skip it | - | ||||||||||||||||||||||||
6960 | if (!atEnd() && c != QLatin1Char('-'))
| 30-204 | ||||||||||||||||||||||||
6961 | stringAddC(QLatin1Char('-')); executed 56 times by 2 tests: stringAddC(QLatin1Char('-')); Executed by:
| 56 | ||||||||||||||||||||||||
6962 | break; executed 234 times by 2 tests: break; Executed by:
| 234 | ||||||||||||||||||||||||
6963 | case Done: executed 146 times by 2 tests: case Done: Executed by:
| 146 | ||||||||||||||||||||||||
6964 | return true; executed 146 times by 2 tests: return true; Executed by:
| 146 | ||||||||||||||||||||||||
6965 | case -1: executed 3 times by 1 test: case -1: Executed by:
| 3 | ||||||||||||||||||||||||
6966 | // Error | - | ||||||||||||||||||||||||
6967 | reportParseError(QLatin1String(XMLERR_ERRORPARSINGCOMMENT)); | - | ||||||||||||||||||||||||
6968 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
6969 | } | - | ||||||||||||||||||||||||
6970 | - | |||||||||||||||||||||||||
6971 | if (atEnd()) {
| 466-10856 | ||||||||||||||||||||||||
6972 | unexpectedEof(&QXmlSimpleReaderPrivate::parseComment, state); | - | ||||||||||||||||||||||||
6973 | return false; executed 466 times by 1 test: return false; Executed by:
| 466 | ||||||||||||||||||||||||
6974 | } | - | ||||||||||||||||||||||||
6975 | if (c == QLatin1Char('-')) {
| 653-10203 | ||||||||||||||||||||||||
6976 | input = InpDash; | - | ||||||||||||||||||||||||
6977 | } else if (c == QLatin1Char('>')) { executed 653 times by 2 tests: end of block Executed by:
| 159-10044 | ||||||||||||||||||||||||
6978 | input = InpGt; | - | ||||||||||||||||||||||||
6979 | } else { executed 159 times by 2 tests: end of block Executed by:
| 159 | ||||||||||||||||||||||||
6980 | input = InpUnknown; | - | ||||||||||||||||||||||||
6981 | } executed 10044 times by 2 tests: end of block Executed by:
| 10044 | ||||||||||||||||||||||||
6982 | state = table[state][input]; | - | ||||||||||||||||||||||||
6983 | - | |||||||||||||||||||||||||
6984 | switch (state) { | - | ||||||||||||||||||||||||
6985 | case Dash1: executed 150 times by 2 tests: case Dash1: Executed by:
| 150 | ||||||||||||||||||||||||
6986 | next(); | - | ||||||||||||||||||||||||
6987 | break; executed 150 times by 2 tests: break; Executed by:
| 150 | ||||||||||||||||||||||||
6988 | case Dash2: executed 150 times by 2 tests: case Dash2: Executed by:
| 150 | ||||||||||||||||||||||||
6989 | next(); | - | ||||||||||||||||||||||||
6990 | break; executed 150 times by 2 tests: break; Executed by:
| 150 | ||||||||||||||||||||||||
6991 | case Com: executed 10055 times by 2 tests: case Com: Executed by:
| 10055 | ||||||||||||||||||||||||
6992 | stringAddC(); | - | ||||||||||||||||||||||||
6993 | next(); | - | ||||||||||||||||||||||||
6994 | break; executed 10055 times by 2 tests: break; Executed by:
| 10055 | ||||||||||||||||||||||||
6995 | case Com2: executed 204 times by 2 tests: case Com2: Executed by:
| 204 | ||||||||||||||||||||||||
6996 | next(); | - | ||||||||||||||||||||||||
6997 | break; executed 204 times by 2 tests: break; Executed by:
| 204 | ||||||||||||||||||||||||
6998 | case ComE: executed 148 times by 2 tests: case ComE: Executed by:
| 148 | ||||||||||||||||||||||||
6999 | next(); | - | ||||||||||||||||||||||||
7000 | break; executed 148 times by 2 tests: break; Executed by:
| 148 | ||||||||||||||||||||||||
7001 | case Done: executed 146 times by 2 tests: case Done: Executed by:
| 146 | ||||||||||||||||||||||||
7002 | next(); | - | ||||||||||||||||||||||||
7003 | break; executed 146 times by 2 tests: break; Executed by:
| 146 | ||||||||||||||||||||||||
7004 | } | - | ||||||||||||||||||||||||
7005 | } executed 10856 times by 2 tests: end of block Executed by:
| 10856 | ||||||||||||||||||||||||
7006 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7007 | } | - | ||||||||||||||||||||||||
7008 | - | |||||||||||||||||||||||||
7009 | /* | - | ||||||||||||||||||||||||
7010 | Parse an Attribute [41]. | - | ||||||||||||||||||||||||
7011 | - | |||||||||||||||||||||||||
7012 | Precondition: the head stands on the first character of the name | - | ||||||||||||||||||||||||
7013 | of the attribute (i.e. all whitespaces are already parsed). | - | ||||||||||||||||||||||||
7014 | - | |||||||||||||||||||||||||
7015 | The head stand on the next character after the end quotes. The | - | ||||||||||||||||||||||||
7016 | variable name contains the name of the attribute and the variable | - | ||||||||||||||||||||||||
7017 | string contains the value of the attribute. | - | ||||||||||||||||||||||||
7018 | */ | - | ||||||||||||||||||||||||
7019 | bool QXmlSimpleReaderPrivate::parseAttribute() | - | ||||||||||||||||||||||||
7020 | { | - | ||||||||||||||||||||||||
7021 | const int Init = 0; | - | ||||||||||||||||||||||||
7022 | const int PName = 1; // parse name | - | ||||||||||||||||||||||||
7023 | const int Ws = 2; // eat ws | - | ||||||||||||||||||||||||
7024 | const int Eq = 3; // the '=' was read | - | ||||||||||||||||||||||||
7025 | const int Quotes = 4; // " or ' were read | - | ||||||||||||||||||||||||
7026 | - | |||||||||||||||||||||||||
7027 | const int InpNameBe = 0; | - | ||||||||||||||||||||||||
7028 | const int InpEq = 1; // = | - | ||||||||||||||||||||||||
7029 | const int InpDq = 2; // " | - | ||||||||||||||||||||||||
7030 | const int InpSq = 3; // ' | - | ||||||||||||||||||||||||
7031 | const int InpUnknown = 4; | - | ||||||||||||||||||||||||
7032 | - | |||||||||||||||||||||||||
7033 | static const int table[4][5] = { | - | ||||||||||||||||||||||||
7034 | /* InpNameBe InpEq InpDq InpSq InpUnknown */ | - | ||||||||||||||||||||||||
7035 | { PName, -1, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
7036 | { -1, Eq, -1, -1, Ws }, // PName | - | ||||||||||||||||||||||||
7037 | { -1, Eq, -1, -1, -1 }, // Ws | - | ||||||||||||||||||||||||
7038 | { -1, -1, Quotes, Quotes, -1 } // Eq | - | ||||||||||||||||||||||||
7039 | }; | - | ||||||||||||||||||||||||
7040 | int state; | - | ||||||||||||||||||||||||
7041 | int input; | - | ||||||||||||||||||||||||
7042 | - | |||||||||||||||||||||||||
7043 | if (parseStack==0 || parseStack->isEmpty()) {
| 549-12597 | ||||||||||||||||||||||||
7044 | state = Init; | - | ||||||||||||||||||||||||
7045 | } else { executed 13146 times by 6 tests: end of block Executed by:
| 13146 | ||||||||||||||||||||||||
7046 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
7047 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
7048 | qDebug("QXmlSimpleReader: parseAttribute (cont) in state %d", state); | - | ||||||||||||||||||||||||
7049 | #endif | - | ||||||||||||||||||||||||
7050 | if (!parseStack->isEmpty()) {
| 0-1897 | ||||||||||||||||||||||||
7051 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
7052 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 158-1739 | ||||||||||||||||||||||||
7053 | parseStack->pop(); | - | ||||||||||||||||||||||||
7054 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
7055 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
7056 | #endif | - | ||||||||||||||||||||||||
7057 | } executed 158 times by 1 test: end of block Executed by:
| 158 | ||||||||||||||||||||||||
7058 | if (!(this->*function)()) {
| 933-964 | ||||||||||||||||||||||||
7059 | parseFailed(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||||||||||||||
7060 | return false; executed 933 times by 1 test: return false; Executed by:
| 933 | ||||||||||||||||||||||||
7061 | } | - | ||||||||||||||||||||||||
7062 | } executed 964 times by 1 test: end of block Executed by:
| 964 | ||||||||||||||||||||||||
7063 | } executed 964 times by 1 test: end of block Executed by:
| 964 | ||||||||||||||||||||||||
7064 | - | |||||||||||||||||||||||||
7065 | for (;;) { | - | ||||||||||||||||||||||||
7066 | switch (state) { | - | ||||||||||||||||||||||||
7067 | case Quotes: executed 13130 times by 6 tests: case Quotes: Executed by:
| 13130 | ||||||||||||||||||||||||
7068 | // Done | - | ||||||||||||||||||||||||
7069 | return true; executed 13130 times by 6 tests: return true; Executed by:
| 13130 | ||||||||||||||||||||||||
7070 | case -1: executed 3 times by 1 test: case -1: Executed by:
| 3 | ||||||||||||||||||||||||
7071 | // Error | - | ||||||||||||||||||||||||
7072 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
7073 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
7074 | } | - | ||||||||||||||||||||||||
7075 | - | |||||||||||||||||||||||||
7076 | if (atEnd()) {
| 0-39458 | ||||||||||||||||||||||||
7077 | unexpectedEof(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||||||||||||||
7078 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7079 | } | - | ||||||||||||||||||||||||
7080 | if (determineNameChar(c) == NameBeginning) {
| 13147-26311 | ||||||||||||||||||||||||
7081 | input = InpNameBe; | - | ||||||||||||||||||||||||
7082 | } else if (c == QLatin1Char('=')) { executed 13147 times by 6 tests: end of block Executed by:
| 13145-13166 | ||||||||||||||||||||||||
7083 | input = InpEq; | - | ||||||||||||||||||||||||
7084 | } else if (c == QLatin1Char('"')) { executed 13145 times by 6 tests: end of block Executed by:
| 100-13145 | ||||||||||||||||||||||||
7085 | input = InpDq; | - | ||||||||||||||||||||||||
7086 | } else if (c == QLatin1Char('\'')) { executed 13066 times by 5 tests: end of block Executed by:
| 23-13066 | ||||||||||||||||||||||||
7087 | input = InpSq; | - | ||||||||||||||||||||||||
7088 | } else { executed 77 times by 3 tests: end of block Executed by:
| 77 | ||||||||||||||||||||||||
7089 | input = InpUnknown; | - | ||||||||||||||||||||||||
7090 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||||||||
7091 | state = table[state][input]; | - | ||||||||||||||||||||||||
7092 | - | |||||||||||||||||||||||||
7093 | switch (state) { | - | ||||||||||||||||||||||||
7094 | case PName: executed 13146 times by 6 tests: case PName: Executed by:
| 13146 | ||||||||||||||||||||||||
7095 | parseName_useRef = false; | - | ||||||||||||||||||||||||
7096 | if (!parseName()) {
| 362-12784 | ||||||||||||||||||||||||
7097 | parseFailed(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||||||||||||||
7098 | return false; executed 362 times by 1 test: return false; Executed by:
| 362 | ||||||||||||||||||||||||
7099 | } | - | ||||||||||||||||||||||||
7100 | break; executed 12784 times by 6 tests: break; Executed by:
| 12784 | ||||||||||||||||||||||||
7101 | case Ws: executed 21 times by 1 test: case Ws: Executed by:
| 21 | ||||||||||||||||||||||||
7102 | if (!eat_ws()) {
| 4-17 | ||||||||||||||||||||||||
7103 | parseFailed(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||||||||||||||
7104 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
7105 | } | - | ||||||||||||||||||||||||
7106 | break; executed 17 times by 1 test: break; Executed by:
| 17 | ||||||||||||||||||||||||
7107 | case Eq: executed 13145 times by 6 tests: case Eq: Executed by:
| 13145 | ||||||||||||||||||||||||
7108 | if (!next_eat_ws()) {
| 152-12993 | ||||||||||||||||||||||||
7109 | parseFailed(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||||||||||||||
7110 | return false; executed 152 times by 1 test: return false; Executed by:
| 152 | ||||||||||||||||||||||||
7111 | } | - | ||||||||||||||||||||||||
7112 | break; executed 12993 times by 6 tests: break; Executed by:
| 12993 | ||||||||||||||||||||||||
7113 | case Quotes: executed 13143 times by 6 tests: case Quotes: Executed by:
| 13143 | ||||||||||||||||||||||||
7114 | if (!parseAttValue()) {
| 459-12684 | ||||||||||||||||||||||||
7115 | parseFailed(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||||||||||||||
7116 | return false; executed 459 times by 1 test: return false; Executed by:
| 459 | ||||||||||||||||||||||||
7117 | } | - | ||||||||||||||||||||||||
7118 | break; executed 12684 times by 6 tests: break; Executed by:
| 12684 | ||||||||||||||||||||||||
7119 | } | - | ||||||||||||||||||||||||
7120 | } executed 38481 times by 6 tests: end of block Executed by:
| 38481 | ||||||||||||||||||||||||
7121 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7122 | } | - | ||||||||||||||||||||||||
7123 | - | |||||||||||||||||||||||||
7124 | /* | - | ||||||||||||||||||||||||
7125 | Parse a Name [5] and store the name in name or ref (if useRef is true). | - | ||||||||||||||||||||||||
7126 | */ | - | ||||||||||||||||||||||||
7127 | bool QXmlSimpleReaderPrivate::parseName() | - | ||||||||||||||||||||||||
7128 | { | - | ||||||||||||||||||||||||
7129 | const int Init = 0; | - | ||||||||||||||||||||||||
7130 | const int Name1 = 1; // parse first character of the name | - | ||||||||||||||||||||||||
7131 | const int Name = 2; // parse name | - | ||||||||||||||||||||||||
7132 | const int Done = 3; | - | ||||||||||||||||||||||||
7133 | - | |||||||||||||||||||||||||
7134 | static const int table[3][3] = { | - | ||||||||||||||||||||||||
7135 | /* InpNameBe InpNameCh InpUnknown */ | - | ||||||||||||||||||||||||
7136 | { Name1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
7137 | { Name, Name, Done }, // Name1 | - | ||||||||||||||||||||||||
7138 | { Name, Name, Done } // Name | - | ||||||||||||||||||||||||
7139 | }; | - | ||||||||||||||||||||||||
7140 | int state; | - | ||||||||||||||||||||||||
7141 | - | |||||||||||||||||||||||||
7142 | if (parseStack==0 || parseStack->isEmpty()) {
| 8415-21597 | ||||||||||||||||||||||||
7143 | state = Init; | - | ||||||||||||||||||||||||
7144 | } else { executed 31355 times by 6 tests: end of block Executed by:
| 31355 | ||||||||||||||||||||||||
7145 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
7146 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
7147 | qDebug("QXmlSimpleReader: parseName (cont) in state %d", state); | - | ||||||||||||||||||||||||
7148 | #endif | - | ||||||||||||||||||||||||
7149 | if (!parseStack->isEmpty()) {
| 0-8415 | ||||||||||||||||||||||||
7150 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
7151 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 0 | ||||||||||||||||||||||||
7152 | parseStack->pop(); | - | ||||||||||||||||||||||||
7153 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
7154 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
7155 | #endif | - | ||||||||||||||||||||||||
7156 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7157 | if (!(this->*function)()) {
| 0 | ||||||||||||||||||||||||
7158 | parseFailed(&QXmlSimpleReaderPrivate::parseName, state); | - | ||||||||||||||||||||||||
7159 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7160 | } | - | ||||||||||||||||||||||||
7161 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7162 | } executed 8415 times by 1 test: end of block Executed by:
| 8415 | ||||||||||||||||||||||||
7163 | - | |||||||||||||||||||||||||
7164 | for (;;) { | - | ||||||||||||||||||||||||
7165 | switch (state) { | - | ||||||||||||||||||||||||
7166 | case Done: executed 31340 times by 6 tests: case Done: Executed by:
| 31340 | ||||||||||||||||||||||||
7167 | return true; executed 31340 times by 6 tests: return true; Executed by:
| 31340 | ||||||||||||||||||||||||
7168 | case -1: executed 15 times by 1 test: case -1: Executed by:
| 15 | ||||||||||||||||||||||||
7169 | // Error | - | ||||||||||||||||||||||||
7170 | reportParseError(QLatin1String(XMLERR_LETTEREXPECTED)); | - | ||||||||||||||||||||||||
7171 | return false; executed 15 times by 1 test: return false; Executed by:
| 15 | ||||||||||||||||||||||||
7172 | } | - | ||||||||||||||||||||||||
7173 | - | |||||||||||||||||||||||||
7174 | if (atEnd()) {
| 8415-160573 | ||||||||||||||||||||||||
7175 | unexpectedEof(&QXmlSimpleReaderPrivate::parseName, state); | - | ||||||||||||||||||||||||
7176 | return false; executed 8415 times by 1 test: return false; Executed by:
| 8415 | ||||||||||||||||||||||||
7177 | } | - | ||||||||||||||||||||||||
7178 | - | |||||||||||||||||||||||||
7179 | // we can safely do the (int) cast thanks to the Q_ASSERTs earlier in this function | - | ||||||||||||||||||||||||
7180 | state = table[state][(int)fastDetermineNameChar(c)]; | - | ||||||||||||||||||||||||
7181 | - | |||||||||||||||||||||||||
7182 | switch (state) { | - | ||||||||||||||||||||||||
7183 | case Name1: executed 31340 times by 6 tests: case Name1: Executed by:
| 31340 | ||||||||||||||||||||||||
7184 | if (parseName_useRef) {
| 1343-29997 | ||||||||||||||||||||||||
7185 | refClear(); | - | ||||||||||||||||||||||||
7186 | refAddC(); | - | ||||||||||||||||||||||||
7187 | } else { executed 1343 times by 3 tests: end of block Executed by:
| 1343 | ||||||||||||||||||||||||
7188 | nameClear(); | - | ||||||||||||||||||||||||
7189 | nameAddC(); | - | ||||||||||||||||||||||||
7190 | } executed 29997 times by 6 tests: end of block Executed by:
| 29997 | ||||||||||||||||||||||||
7191 | next(); | - | ||||||||||||||||||||||||
7192 | break; executed 31340 times by 6 tests: break; Executed by:
| 31340 | ||||||||||||||||||||||||
7193 | case Name: executed 97878 times by 6 tests: case Name: Executed by:
| 97878 | ||||||||||||||||||||||||
7194 | if (parseName_useRef) {
| 1538-96340 | ||||||||||||||||||||||||
7195 | refAddC(); | - | ||||||||||||||||||||||||
7196 | } else { executed 1538 times by 3 tests: end of block Executed by:
| 1538 | ||||||||||||||||||||||||
7197 | nameAddC(); | - | ||||||||||||||||||||||||
7198 | } executed 96340 times by 6 tests: end of block Executed by:
| 96340 | ||||||||||||||||||||||||
7199 | next(); | - | ||||||||||||||||||||||||
7200 | break; executed 97878 times by 6 tests: break; Executed by:
| 97878 | ||||||||||||||||||||||||
7201 | } | - | ||||||||||||||||||||||||
7202 | } executed 160573 times by 6 tests: end of block Executed by:
| 160573 | ||||||||||||||||||||||||
7203 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7204 | } | - | ||||||||||||||||||||||||
7205 | - | |||||||||||||||||||||||||
7206 | /* | - | ||||||||||||||||||||||||
7207 | Parse a Nmtoken [7] and store the name in name. | - | ||||||||||||||||||||||||
7208 | */ | - | ||||||||||||||||||||||||
7209 | bool QXmlSimpleReaderPrivate::parseNmtoken() | - | ||||||||||||||||||||||||
7210 | { | - | ||||||||||||||||||||||||
7211 | const signed char Init = 0; | - | ||||||||||||||||||||||||
7212 | const signed char NameF = 1; | - | ||||||||||||||||||||||||
7213 | const signed char Name = 2; | - | ||||||||||||||||||||||||
7214 | const signed char Done = 3; | - | ||||||||||||||||||||||||
7215 | - | |||||||||||||||||||||||||
7216 | const signed char InpNameCh = 0; // NameChar without InpNameBe | - | ||||||||||||||||||||||||
7217 | const signed char InpUnknown = 1; | - | ||||||||||||||||||||||||
7218 | - | |||||||||||||||||||||||||
7219 | static const signed char table[3][2] = { | - | ||||||||||||||||||||||||
7220 | /* InpNameCh InpUnknown */ | - | ||||||||||||||||||||||||
7221 | { NameF, -1 }, // Init | - | ||||||||||||||||||||||||
7222 | { Name, Done }, // NameF | - | ||||||||||||||||||||||||
7223 | { Name, Done } // Name | - | ||||||||||||||||||||||||
7224 | }; | - | ||||||||||||||||||||||||
7225 | signed char state; | - | ||||||||||||||||||||||||
7226 | signed char input; | - | ||||||||||||||||||||||||
7227 | - | |||||||||||||||||||||||||
7228 | if (parseStack==0 || parseStack->isEmpty()) {
| 5-23 | ||||||||||||||||||||||||
7229 | state = Init; | - | ||||||||||||||||||||||||
7230 | } else { executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
7231 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
7232 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
7233 | qDebug("QXmlSimpleReader: parseNmtoken (cont) in state %d", state); | - | ||||||||||||||||||||||||
7234 | #endif | - | ||||||||||||||||||||||||
7235 | if (!parseStack->isEmpty()) {
| 0-5 | ||||||||||||||||||||||||
7236 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
7237 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 0 | ||||||||||||||||||||||||
7238 | parseStack->pop(); | - | ||||||||||||||||||||||||
7239 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
7240 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
7241 | #endif | - | ||||||||||||||||||||||||
7242 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7243 | if (!(this->*function)()) {
| 0 | ||||||||||||||||||||||||
7244 | parseFailed(&QXmlSimpleReaderPrivate::parseNmtoken, state); | - | ||||||||||||||||||||||||
7245 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7246 | } | - | ||||||||||||||||||||||||
7247 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7248 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||
7249 | - | |||||||||||||||||||||||||
7250 | for (;;) { | - | ||||||||||||||||||||||||
7251 | switch (state) { | - | ||||||||||||||||||||||||
7252 | case Done: executed 24 times by 1 test: case Done: Executed by:
| 24 | ||||||||||||||||||||||||
7253 | return true; executed 24 times by 1 test: return true; Executed by:
| 24 | ||||||||||||||||||||||||
7254 | case -1: never executed: case -1: | 0 | ||||||||||||||||||||||||
7255 | // Error | - | ||||||||||||||||||||||||
7256 | reportParseError(QLatin1String(XMLERR_LETTEREXPECTED)); | - | ||||||||||||||||||||||||
7257 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7258 | } | - | ||||||||||||||||||||||||
7259 | - | |||||||||||||||||||||||||
7260 | if (atEnd()) {
| 5-56 | ||||||||||||||||||||||||
7261 | unexpectedEof(&QXmlSimpleReaderPrivate::parseNmtoken, state); | - | ||||||||||||||||||||||||
7262 | return false; executed 5 times by 1 test: return false; Executed by:
| 5 | ||||||||||||||||||||||||
7263 | } | - | ||||||||||||||||||||||||
7264 | if (determineNameChar(c) == NotName) {
| 24-32 | ||||||||||||||||||||||||
7265 | input = InpUnknown; | - | ||||||||||||||||||||||||
7266 | } else { executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
7267 | input = InpNameCh; | - | ||||||||||||||||||||||||
7268 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
7269 | state = table[state][input]; | - | ||||||||||||||||||||||||
7270 | - | |||||||||||||||||||||||||
7271 | switch (state) { | - | ||||||||||||||||||||||||
7272 | case NameF: executed 24 times by 1 test: case NameF: Executed by:
| 24 | ||||||||||||||||||||||||
7273 | nameClear(); | - | ||||||||||||||||||||||||
7274 | nameAddC(); | - | ||||||||||||||||||||||||
7275 | next(); | - | ||||||||||||||||||||||||
7276 | break; executed 24 times by 1 test: break; Executed by:
| 24 | ||||||||||||||||||||||||
7277 | case Name: executed 8 times by 1 test: case Name: Executed by:
| 8 | ||||||||||||||||||||||||
7278 | nameAddC(); | - | ||||||||||||||||||||||||
7279 | next(); | - | ||||||||||||||||||||||||
7280 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||||||||||||||
7281 | } | - | ||||||||||||||||||||||||
7282 | } executed 56 times by 1 test: end of block Executed by:
| 56 | ||||||||||||||||||||||||
7283 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7284 | } | - | ||||||||||||||||||||||||
7285 | - | |||||||||||||||||||||||||
7286 | /* | - | ||||||||||||||||||||||||
7287 | Parse a Reference [67]. | - | ||||||||||||||||||||||||
7288 | - | |||||||||||||||||||||||||
7289 | parseReference_charDataRead is set to true if the reference must not be | - | ||||||||||||||||||||||||
7290 | parsed. The character(s) which the reference mapped to are appended to | - | ||||||||||||||||||||||||
7291 | string. The head stands on the first character after the reference. | - | ||||||||||||||||||||||||
7292 | - | |||||||||||||||||||||||||
7293 | parseReference_charDataRead is set to false if the reference must be parsed. | - | ||||||||||||||||||||||||
7294 | The charachter(s) which the reference mapped to are inserted at the reference | - | ||||||||||||||||||||||||
7295 | position. The head stands on the first character of the replacement). | - | ||||||||||||||||||||||||
7296 | */ | - | ||||||||||||||||||||||||
7297 | bool QXmlSimpleReaderPrivate::parseReference() | - | ||||||||||||||||||||||||
7298 | { | - | ||||||||||||||||||||||||
7299 | // temporary variables (only used in very local context, so they don't | - | ||||||||||||||||||||||||
7300 | // interfere with incremental parsing) | - | ||||||||||||||||||||||||
7301 | uint tmp; | - | ||||||||||||||||||||||||
7302 | bool ok; | - | ||||||||||||||||||||||||
7303 | - | |||||||||||||||||||||||||
7304 | const signed char Init = 0; | - | ||||||||||||||||||||||||
7305 | const signed char SRef = 1; // start of a reference | - | ||||||||||||||||||||||||
7306 | const signed char ChRef = 2; // parse CharRef | - | ||||||||||||||||||||||||
7307 | const signed char ChDec = 3; // parse CharRef decimal | - | ||||||||||||||||||||||||
7308 | const signed char ChHexS = 4; // start CharRef hexadecimal | - | ||||||||||||||||||||||||
7309 | const signed char ChHex = 5; // parse CharRef hexadecimal | - | ||||||||||||||||||||||||
7310 | const signed char Name = 6; // parse name | - | ||||||||||||||||||||||||
7311 | const signed char DoneD = 7; // done CharRef decimal | - | ||||||||||||||||||||||||
7312 | const signed char DoneH = 8; // done CharRef hexadecimal | - | ||||||||||||||||||||||||
7313 | const signed char DoneN = 9; // done EntityRef | - | ||||||||||||||||||||||||
7314 | - | |||||||||||||||||||||||||
7315 | const signed char InpAmp = 0; // & | - | ||||||||||||||||||||||||
7316 | const signed char InpSemi = 1; // ; | - | ||||||||||||||||||||||||
7317 | const signed char InpHash = 2; // # | - | ||||||||||||||||||||||||
7318 | const signed char InpX = 3; // x | - | ||||||||||||||||||||||||
7319 | const signed char InpNum = 4; // 0-9 | - | ||||||||||||||||||||||||
7320 | const signed char InpHex = 5; // a-f A-F | - | ||||||||||||||||||||||||
7321 | const signed char InpUnknown = 6; | - | ||||||||||||||||||||||||
7322 | - | |||||||||||||||||||||||||
7323 | static const signed char table[8][7] = { | - | ||||||||||||||||||||||||
7324 | /* InpAmp InpSemi InpHash InpX InpNum InpHex InpUnknown */ | - | ||||||||||||||||||||||||
7325 | { SRef, -1, -1, -1, -1, -1, -1 }, // Init | - | ||||||||||||||||||||||||
7326 | { -1, -1, ChRef, Name, Name, Name, Name }, // SRef | - | ||||||||||||||||||||||||
7327 | { -1, -1, -1, ChHexS, ChDec, -1, -1 }, // ChRef | - | ||||||||||||||||||||||||
7328 | { -1, DoneD, -1, -1, ChDec, -1, -1 }, // ChDec | - | ||||||||||||||||||||||||
7329 | { -1, -1, -1, -1, ChHex, ChHex, -1 }, // ChHexS | - | ||||||||||||||||||||||||
7330 | { -1, DoneH, -1, -1, ChHex, ChHex, -1 }, // ChHex | - | ||||||||||||||||||||||||
7331 | { -1, DoneN, -1, -1, -1, -1, -1 } // Name | - | ||||||||||||||||||||||||
7332 | }; | - | ||||||||||||||||||||||||
7333 | signed char state; | - | ||||||||||||||||||||||||
7334 | signed char input; | - | ||||||||||||||||||||||||
7335 | - | |||||||||||||||||||||||||
7336 | if (parseStack==0 || parseStack->isEmpty()) {
| 453-2474 | ||||||||||||||||||||||||
7337 | parseReference_charDataRead = false; | - | ||||||||||||||||||||||||
7338 | state = Init; | - | ||||||||||||||||||||||||
7339 | } else { executed 1614 times by 3 tests: end of block Executed by:
| 1614 | ||||||||||||||||||||||||
7340 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
7341 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
7342 | qDebug("QXmlSimpleReader: parseReference (cont) in state %d", state); | - | ||||||||||||||||||||||||
7343 | #endif | - | ||||||||||||||||||||||||
7344 | if (!parseStack->isEmpty()) {
| 504-809 | ||||||||||||||||||||||||
7345 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
7346 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 0-504 | ||||||||||||||||||||||||
7347 | parseStack->pop(); | - | ||||||||||||||||||||||||
7348 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
7349 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
7350 | #endif | - | ||||||||||||||||||||||||
7351 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7352 | if (!(this->*function)()) {
| 130-374 | ||||||||||||||||||||||||
7353 | parseFailed(&QXmlSimpleReaderPrivate::parseReference, state); | - | ||||||||||||||||||||||||
7354 | return false; executed 130 times by 1 test: return false; Executed by:
| 130 | ||||||||||||||||||||||||
7355 | } | - | ||||||||||||||||||||||||
7356 | } executed 374 times by 1 test: end of block Executed by:
| 374 | ||||||||||||||||||||||||
7357 | } executed 1183 times by 1 test: end of block Executed by:
| 1183 | ||||||||||||||||||||||||
7358 | - | |||||||||||||||||||||||||
7359 | for (;;) { | - | ||||||||||||||||||||||||
7360 | switch (state) { | - | ||||||||||||||||||||||||
7361 | case DoneD: executed 255 times by 1 test: case DoneD: Executed by:
| 255 | ||||||||||||||||||||||||
7362 | return true; executed 255 times by 1 test: return true; Executed by:
| 255 | ||||||||||||||||||||||||
7363 | case DoneH: executed 80 times by 1 test: case DoneH: Executed by:
| 80 | ||||||||||||||||||||||||
7364 | return true; executed 80 times by 1 test: return true; Executed by:
| 80 | ||||||||||||||||||||||||
7365 | case DoneN: executed 1256 times by 3 tests: case DoneN: Executed by:
| 1256 | ||||||||||||||||||||||||
7366 | return true; executed 1256 times by 3 tests: return true; Executed by:
| 1256 | ||||||||||||||||||||||||
7367 | case -1: executed 6 times by 1 test: case -1: Executed by:
| 6 | ||||||||||||||||||||||||
7368 | // Error | - | ||||||||||||||||||||||||
7369 | reportParseError(QLatin1String(XMLERR_ERRORPARSINGREFERENCE)); | - | ||||||||||||||||||||||||
7370 | return false; executed 6 times by 1 test: return false; Executed by:
| 6 | ||||||||||||||||||||||||
7371 | } | - | ||||||||||||||||||||||||
7372 | - | |||||||||||||||||||||||||
7373 | if (atEnd()) {
| 809-6427 | ||||||||||||||||||||||||
7374 | unexpectedEof(&QXmlSimpleReaderPrivate::parseReference, state); | - | ||||||||||||||||||||||||
7375 | return false; executed 809 times by 1 test: return false; Executed by:
| 809 | ||||||||||||||||||||||||
7376 | } | - | ||||||||||||||||||||||||
7377 | if (c.row()) {
| 0-6427 | ||||||||||||||||||||||||
7378 | input = InpUnknown; | - | ||||||||||||||||||||||||
7379 | } else if (c.cell() == '&') { never executed: end of block
| 0-4812 | ||||||||||||||||||||||||
7380 | input = InpAmp; | - | ||||||||||||||||||||||||
7381 | } else if (c.cell() == ';') { executed 1615 times by 3 tests: end of block Executed by:
| 1599-3213 | ||||||||||||||||||||||||
7382 | input = InpSemi; | - | ||||||||||||||||||||||||
7383 | } else if (c.cell() == '#') { executed 1599 times by 3 tests: end of block Executed by:
| 338-2875 | ||||||||||||||||||||||||
7384 | input = InpHash; | - | ||||||||||||||||||||||||
7385 | } else if (c.cell() == 'x') { executed 338 times by 1 test: end of block Executed by:
| 90-2785 | ||||||||||||||||||||||||
7386 | input = InpX; | - | ||||||||||||||||||||||||
7387 | } else if ('0' <= c.cell() && c.cell() <= '9') { executed 90 times by 1 test: end of block Executed by:
| 11-2774 | ||||||||||||||||||||||||
7388 | input = InpNum; | - | ||||||||||||||||||||||||
7389 | } else if ('a' <= c.cell() && c.cell() <= 'f') { executed 1426 times by 1 test: end of block Executed by:
| 67-1426 | ||||||||||||||||||||||||
7390 | input = InpHex; | - | ||||||||||||||||||||||||
7391 | } else if ('A' <= c.cell() && c.cell() <= 'F') { executed 1034 times by 3 tests: end of block Executed by:
| 12-1034 | ||||||||||||||||||||||||
7392 | input = InpHex; | - | ||||||||||||||||||||||||
7393 | } else { executed 53 times by 1 test: end of block Executed by:
| 53 | ||||||||||||||||||||||||
7394 | input = InpUnknown; | - | ||||||||||||||||||||||||
7395 | } executed 272 times by 3 tests: end of block Executed by:
| 272 | ||||||||||||||||||||||||
7396 | state = table[state][input]; | - | ||||||||||||||||||||||||
7397 | - | |||||||||||||||||||||||||
7398 | switch (state) { | - | ||||||||||||||||||||||||
7399 | case SRef: executed 1614 times by 3 tests: case SRef: Executed by:
| 1614 | ||||||||||||||||||||||||
7400 | refClear(); | - | ||||||||||||||||||||||||
7401 | next(); | - | ||||||||||||||||||||||||
7402 | break; executed 1614 times by 3 tests: break; Executed by:
| 1614 | ||||||||||||||||||||||||
7403 | case ChRef: executed 338 times by 1 test: case ChRef: Executed by:
| 338 | ||||||||||||||||||||||||
7404 | next(); | - | ||||||||||||||||||||||||
7405 | break; executed 338 times by 1 test: break; Executed by:
| 338 | ||||||||||||||||||||||||
7406 | case ChDec: executed 850 times by 1 test: case ChDec: Executed by:
| 850 | ||||||||||||||||||||||||
7407 | refAddC(); | - | ||||||||||||||||||||||||
7408 | next(); | - | ||||||||||||||||||||||||
7409 | break; executed 850 times by 1 test: break; Executed by:
| 850 | ||||||||||||||||||||||||
7410 | case ChHexS: executed 80 times by 1 test: case ChHexS: Executed by:
| 80 | ||||||||||||||||||||||||
7411 | next(); | - | ||||||||||||||||||||||||
7412 | break; executed 80 times by 1 test: break; Executed by:
| 80 | ||||||||||||||||||||||||
7413 | case ChHex: executed 665 times by 1 test: case ChHex: Executed by:
| 665 | ||||||||||||||||||||||||
7414 | refAddC(); | - | ||||||||||||||||||||||||
7415 | next(); | - | ||||||||||||||||||||||||
7416 | break; executed 665 times by 1 test: break; Executed by:
| 665 | ||||||||||||||||||||||||
7417 | case Name: executed 1275 times by 3 tests: case Name: Executed by:
| 1275 | ||||||||||||||||||||||||
7418 | // read the name into the ref | - | ||||||||||||||||||||||||
7419 | parseName_useRef = true; | - | ||||||||||||||||||||||||
7420 | if (!parseName()) {
| 383-892 | ||||||||||||||||||||||||
7421 | parseFailed(&QXmlSimpleReaderPrivate::parseReference, state); | - | ||||||||||||||||||||||||
7422 | return false; executed 383 times by 1 test: return false; Executed by:
| 383 | ||||||||||||||||||||||||
7423 | } | - | ||||||||||||||||||||||||
7424 | break; executed 892 times by 3 tests: break; Executed by:
| 892 | ||||||||||||||||||||||||
7425 | case DoneD: executed 255 times by 1 test: case DoneD: Executed by:
| 255 | ||||||||||||||||||||||||
7426 | tmp = ref().toUInt(&ok, 10); | - | ||||||||||||||||||||||||
7427 | if (ok) {
| 0-255 | ||||||||||||||||||||||||
7428 | stringAddC(QChar(tmp)); | - | ||||||||||||||||||||||||
7429 | } else { executed 255 times by 1 test: end of block Executed by:
| 255 | ||||||||||||||||||||||||
7430 | reportParseError(QLatin1String(XMLERR_ERRORPARSINGREFERENCE)); | - | ||||||||||||||||||||||||
7431 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7432 | } | - | ||||||||||||||||||||||||
7433 | parseReference_charDataRead = true; | - | ||||||||||||||||||||||||
7434 | next(); | - | ||||||||||||||||||||||||
7435 | break; executed 255 times by 1 test: break; Executed by:
| 255 | ||||||||||||||||||||||||
7436 | case DoneH: executed 80 times by 1 test: case DoneH: Executed by:
| 80 | ||||||||||||||||||||||||
7437 | tmp = ref().toUInt(&ok, 16); | - | ||||||||||||||||||||||||
7438 | if (ok) {
| 0-80 | ||||||||||||||||||||||||
7439 | stringAddC(QChar(tmp)); | - | ||||||||||||||||||||||||
7440 | } else { executed 80 times by 1 test: end of block Executed by:
| 80 | ||||||||||||||||||||||||
7441 | reportParseError(QLatin1String(XMLERR_ERRORPARSINGREFERENCE)); | - | ||||||||||||||||||||||||
7442 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7443 | } | - | ||||||||||||||||||||||||
7444 | parseReference_charDataRead = true; | - | ||||||||||||||||||||||||
7445 | next(); | - | ||||||||||||||||||||||||
7446 | break; executed 80 times by 1 test: break; Executed by:
| 80 | ||||||||||||||||||||||||
7447 | case DoneN: executed 1264 times by 3 tests: case DoneN: Executed by:
| 1264 | ||||||||||||||||||||||||
7448 | if (!processReference())
| 8-1256 | ||||||||||||||||||||||||
7449 | return false; executed 8 times by 1 test: return false; Executed by:
| 8 | ||||||||||||||||||||||||
7450 | next(); | - | ||||||||||||||||||||||||
7451 | break; executed 1256 times by 3 tests: break; Executed by:
| 1256 | ||||||||||||||||||||||||
7452 | } | - | ||||||||||||||||||||||||
7453 | } executed 6036 times by 3 tests: end of block Executed by:
| 6036 | ||||||||||||||||||||||||
7454 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7455 | } | - | ||||||||||||||||||||||||
7456 | - | |||||||||||||||||||||||||
7457 | /* | - | ||||||||||||||||||||||||
7458 | Helper function for parseReference() | - | ||||||||||||||||||||||||
7459 | */ | - | ||||||||||||||||||||||||
7460 | bool QXmlSimpleReaderPrivate::processReference() | - | ||||||||||||||||||||||||
7461 | { | - | ||||||||||||||||||||||||
7462 | QString reference = ref(); | - | ||||||||||||||||||||||||
7463 | if (reference == QLatin1String("amp")) {
| 36-1228 | ||||||||||||||||||||||||
7464 | if (parseReference_context == InEntityValue) {
| 0-36 | ||||||||||||||||||||||||
7465 | // Bypassed | - | ||||||||||||||||||||||||
7466 | stringAddC(QLatin1Char('&')); stringAddC(QLatin1Char('a')); stringAddC(QLatin1Char('m')); stringAddC(QLatin1Char('p')); stringAddC(QLatin1Char(';')); | - | ||||||||||||||||||||||||
7467 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
7468 | // Included or Included in literal | - | ||||||||||||||||||||||||
7469 | stringAddC(QLatin1Char('&')); | - | ||||||||||||||||||||||||
7470 | } executed 36 times by 3 tests: end of block Executed by:
| 36 | ||||||||||||||||||||||||
7471 | parseReference_charDataRead = true; | - | ||||||||||||||||||||||||
7472 | } else if (reference == QLatin1String("lt")) { executed 36 times by 3 tests: end of block Executed by:
| 36-1159 | ||||||||||||||||||||||||
7473 | if (parseReference_context == InEntityValue) {
| 10-59 | ||||||||||||||||||||||||
7474 | // Bypassed | - | ||||||||||||||||||||||||
7475 | stringAddC(QLatin1Char('&')); stringAddC(QLatin1Char('l')); stringAddC(QLatin1Char('t')); stringAddC(QLatin1Char(';')); | - | ||||||||||||||||||||||||
7476 | } else { executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
7477 | // Included or Included in literal | - | ||||||||||||||||||||||||
7478 | stringAddC(QLatin1Char('<')); | - | ||||||||||||||||||||||||
7479 | } executed 59 times by 3 tests: end of block Executed by:
| 59 | ||||||||||||||||||||||||
7480 | parseReference_charDataRead = true; | - | ||||||||||||||||||||||||
7481 | } else if (reference == QLatin1String("gt")) { executed 69 times by 3 tests: end of block Executed by:
| 54-1105 | ||||||||||||||||||||||||
7482 | if (parseReference_context == InEntityValue) {
| 0-54 | ||||||||||||||||||||||||
7483 | // Bypassed | - | ||||||||||||||||||||||||
7484 | stringAddC(QLatin1Char('&')); stringAddC(QLatin1Char('g')); stringAddC(QLatin1Char('t')); stringAddC(QLatin1Char(';')); | - | ||||||||||||||||||||||||
7485 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
7486 | // Included or Included in literal | - | ||||||||||||||||||||||||
7487 | stringAddC(QLatin1Char('>')); | - | ||||||||||||||||||||||||
7488 | } executed 54 times by 3 tests: end of block Executed by:
| 54 | ||||||||||||||||||||||||
7489 | parseReference_charDataRead = true; | - | ||||||||||||||||||||||||
7490 | } else if (reference == QLatin1String("apos")) { executed 54 times by 3 tests: end of block Executed by:
| 20-1085 | ||||||||||||||||||||||||
7491 | if (parseReference_context == InEntityValue) {
| 0-20 | ||||||||||||||||||||||||
7492 | // Bypassed | - | ||||||||||||||||||||||||
7493 | stringAddC(QLatin1Char('&')); stringAddC(QLatin1Char('a')); stringAddC(QLatin1Char('p')); stringAddC(QLatin1Char('o')); stringAddC(QLatin1Char('s')); stringAddC(QLatin1Char(';')); | - | ||||||||||||||||||||||||
7494 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
7495 | // Included or Included in literal | - | ||||||||||||||||||||||||
7496 | stringAddC(QLatin1Char('\'')); | - | ||||||||||||||||||||||||
7497 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
7498 | parseReference_charDataRead = true; | - | ||||||||||||||||||||||||
7499 | } else if (reference == QLatin1String("quot")) { executed 20 times by 1 test: end of block Executed by:
| 20-1050 | ||||||||||||||||||||||||
7500 | if (parseReference_context == InEntityValue) {
| 0-35 | ||||||||||||||||||||||||
7501 | // Bypassed | - | ||||||||||||||||||||||||
7502 | stringAddC(QLatin1Char('&')); stringAddC(QLatin1Char('q')); stringAddC(QLatin1Char('u')); stringAddC(QLatin1Char('o')); stringAddC(QLatin1Char('t')); stringAddC(QLatin1Char(';')); | - | ||||||||||||||||||||||||
7503 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
7504 | // Included or Included in literal | - | ||||||||||||||||||||||||
7505 | stringAddC(QLatin1Char('"')); | - | ||||||||||||||||||||||||
7506 | } executed 35 times by 2 tests: end of block Executed by:
| 35 | ||||||||||||||||||||||||
7507 | parseReference_charDataRead = true; | - | ||||||||||||||||||||||||
7508 | } else { executed 35 times by 2 tests: end of block Executed by:
| 35 | ||||||||||||||||||||||||
7509 | QMap<QString,QString>::Iterator it; | - | ||||||||||||||||||||||||
7510 | it = entities.find(reference); | - | ||||||||||||||||||||||||
7511 | if (it != entities.end()) {
| 440-610 | ||||||||||||||||||||||||
7512 | // "Internal General" | - | ||||||||||||||||||||||||
7513 | switch (parseReference_context) { | - | ||||||||||||||||||||||||
7514 | case InContent: executed 400 times by 1 test: case InContent: Executed by:
| 400 | ||||||||||||||||||||||||
7515 | // Included | - | ||||||||||||||||||||||||
7516 | if (!insertXmlRef(*it, reference, false))
| 1-399 | ||||||||||||||||||||||||
7517 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
7518 | parseReference_charDataRead = false; | - | ||||||||||||||||||||||||
7519 | break; executed 399 times by 1 test: break; Executed by:
| 399 | ||||||||||||||||||||||||
7520 | case InAttributeValue: executed 78 times by 1 test: case InAttributeValue: Executed by:
| 78 | ||||||||||||||||||||||||
7521 | // Included in literal | - | ||||||||||||||||||||||||
7522 | if (!insertXmlRef(*it, reference, true))
| 3-75 | ||||||||||||||||||||||||
7523 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
7524 | parseReference_charDataRead = false; | - | ||||||||||||||||||||||||
7525 | break; executed 75 times by 1 test: break; Executed by:
| 75 | ||||||||||||||||||||||||
7526 | case InEntityValue: executed 132 times by 1 test: case InEntityValue: Executed by:
| 132 | ||||||||||||||||||||||||
7527 | { | - | ||||||||||||||||||||||||
7528 | // Bypassed | - | ||||||||||||||||||||||||
7529 | stringAddC(QLatin1Char('&')); | - | ||||||||||||||||||||||||
7530 | for (int i=0; i<(int)reference.length(); i++) {
| 132-264 | ||||||||||||||||||||||||
7531 | stringAddC(reference[i]); | - | ||||||||||||||||||||||||
7532 | } executed 264 times by 1 test: end of block Executed by:
| 264 | ||||||||||||||||||||||||
7533 | stringAddC(QLatin1Char(';')); | - | ||||||||||||||||||||||||
7534 | parseReference_charDataRead = true; | - | ||||||||||||||||||||||||
7535 | } | - | ||||||||||||||||||||||||
7536 | break; executed 132 times by 1 test: break; Executed by:
| 132 | ||||||||||||||||||||||||
7537 | case InDTD: never executed: case InDTD: | 0 | ||||||||||||||||||||||||
7538 | // Forbidden | - | ||||||||||||||||||||||||
7539 | parseReference_charDataRead = false; | - | ||||||||||||||||||||||||
7540 | reportParseError(QLatin1String(XMLERR_INTERNALGENERALENTITYINDTD)); | - | ||||||||||||||||||||||||
7541 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7542 | } | - | ||||||||||||||||||||||||
7543 | } else { executed 606 times by 1 test: end of block Executed by:
| 606 | ||||||||||||||||||||||||
7544 | QMap<QString,QXmlSimpleReaderPrivate::ExternEntity>::Iterator itExtern; | - | ||||||||||||||||||||||||
7545 | itExtern = externEntities.find(reference); | - | ||||||||||||||||||||||||
7546 | if (itExtern == externEntities.end()) {
| 144-296 | ||||||||||||||||||||||||
7547 | // entity not declared | - | ||||||||||||||||||||||||
7548 | // ### check this case for conformance | - | ||||||||||||||||||||||||
7549 | if (parseReference_context == InEntityValue) {
| 99-197 | ||||||||||||||||||||||||
7550 | // Bypassed | - | ||||||||||||||||||||||||
7551 | stringAddC(QLatin1Char('&')); | - | ||||||||||||||||||||||||
7552 | for (int i=0; i<(int)reference.length(); i++) {
| 99-209 | ||||||||||||||||||||||||
7553 | stringAddC(reference[i]); | - | ||||||||||||||||||||||||
7554 | } executed 209 times by 1 test: end of block Executed by:
| 209 | ||||||||||||||||||||||||
7555 | stringAddC(QLatin1Char(';')); | - | ||||||||||||||||||||||||
7556 | parseReference_charDataRead = true; | - | ||||||||||||||||||||||||
7557 | } else { executed 99 times by 1 test: end of block Executed by:
| 99 | ||||||||||||||||||||||||
7558 | // if we have some char data read, report it now | - | ||||||||||||||||||||||||
7559 | if (parseReference_context == InContent) {
| 14-183 | ||||||||||||||||||||||||
7560 | if (contentCharDataRead) {
| 83-100 | ||||||||||||||||||||||||
7561 | if (reportWhitespaceCharData || !string().simplified().isEmpty()) {
| 0-100 | ||||||||||||||||||||||||
7562 | if (contentHnd != 0 && !contentHnd->characters(string())) {
| 0-100 | ||||||||||||||||||||||||
7563 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
7564 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7565 | } | - | ||||||||||||||||||||||||
7566 | } executed 100 times by 1 test: end of block Executed by:
| 100 | ||||||||||||||||||||||||
7567 | stringClear(); | - | ||||||||||||||||||||||||
7568 | contentCharDataRead = false; | - | ||||||||||||||||||||||||
7569 | } executed 100 times by 1 test: end of block Executed by:
| 100 | ||||||||||||||||||||||||
7570 | } executed 183 times by 1 test: end of block Executed by:
| 183 | ||||||||||||||||||||||||
7571 | - | |||||||||||||||||||||||||
7572 | if (contentHnd) {
| 0-197 | ||||||||||||||||||||||||
7573 | skipped_entity_in_content = parseReference_context == InContent; | - | ||||||||||||||||||||||||
7574 | if (!contentHnd->skippedEntity(reference)) {
| 0-197 | ||||||||||||||||||||||||
7575 | skipped_entity_in_content = false; | - | ||||||||||||||||||||||||
7576 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
7577 | return false; // error never executed: return false; | 0 | ||||||||||||||||||||||||
7578 | } | - | ||||||||||||||||||||||||
7579 | skipped_entity_in_content = false; | - | ||||||||||||||||||||||||
7580 | } executed 197 times by 1 test: end of block Executed by:
| 197 | ||||||||||||||||||||||||
7581 | } executed 197 times by 1 test: end of block Executed by:
| 197 | ||||||||||||||||||||||||
7582 | } else if ((*itExtern).notation.isNull()) {
| 2-142 | ||||||||||||||||||||||||
7583 | // "External Parsed General" | - | ||||||||||||||||||||||||
7584 | switch (parseReference_context) { | - | ||||||||||||||||||||||||
7585 | case InContent: executed 140 times by 1 test: case InContent: Executed by:
| 140 | ||||||||||||||||||||||||
7586 | { | - | ||||||||||||||||||||||||
7587 | // Included if validating | - | ||||||||||||||||||||||||
7588 | bool skipIt = true; | - | ||||||||||||||||||||||||
7589 | if (entityRes) {
| 0-140 | ||||||||||||||||||||||||
7590 | QXmlInputSource *ret = 0; | - | ||||||||||||||||||||||||
7591 | if (!entityRes->resolveEntity((*itExtern).publicId, (*itExtern).systemId, ret)) {
| 0-140 | ||||||||||||||||||||||||
7592 | delete ret; | - | ||||||||||||||||||||||||
7593 | reportParseError(entityRes->errorString()); | - | ||||||||||||||||||||||||
7594 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7595 | } | - | ||||||||||||||||||||||||
7596 | if (ret) {
| 0-140 | ||||||||||||||||||||||||
7597 | QString xmlRefString; | - | ||||||||||||||||||||||||
7598 | QString buffer = ret->data(); | - | ||||||||||||||||||||||||
7599 | while (!buffer.isEmpty()) {
| 0 | ||||||||||||||||||||||||
7600 | xmlRefString += buffer; | - | ||||||||||||||||||||||||
7601 | ret->fetchData(); | - | ||||||||||||||||||||||||
7602 | buffer = ret->data(); | - | ||||||||||||||||||||||||
7603 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7604 | - | |||||||||||||||||||||||||
7605 | delete ret; | - | ||||||||||||||||||||||||
7606 | if (!stripTextDecl(xmlRefString)) {
| 0 | ||||||||||||||||||||||||
7607 | reportParseError(QLatin1String(XMLERR_ERRORINTEXTDECL)); | - | ||||||||||||||||||||||||
7608 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7609 | } | - | ||||||||||||||||||||||||
7610 | if (!insertXmlRef(xmlRefString, reference, false))
| 0 | ||||||||||||||||||||||||
7611 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7612 | skipIt = false; | - | ||||||||||||||||||||||||
7613 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7614 | } executed 140 times by 1 test: end of block Executed by:
| 140 | ||||||||||||||||||||||||
7615 | if (skipIt && contentHnd) {
| 0-140 | ||||||||||||||||||||||||
7616 | skipped_entity_in_content = true; | - | ||||||||||||||||||||||||
7617 | if (!contentHnd->skippedEntity(reference)) {
| 0-140 | ||||||||||||||||||||||||
7618 | skipped_entity_in_content = false; | - | ||||||||||||||||||||||||
7619 | reportParseError(contentHnd->errorString()); | - | ||||||||||||||||||||||||
7620 | return false; // error never executed: return false; | 0 | ||||||||||||||||||||||||
7621 | } | - | ||||||||||||||||||||||||
7622 | skipped_entity_in_content = false; | - | ||||||||||||||||||||||||
7623 | } executed 140 times by 1 test: end of block Executed by:
| 140 | ||||||||||||||||||||||||
7624 | parseReference_charDataRead = false; | - | ||||||||||||||||||||||||
7625 | } break; executed 140 times by 1 test: break; Executed by:
| 140 | ||||||||||||||||||||||||
7626 | case InAttributeValue: executed 2 times by 1 test: case InAttributeValue: Executed by:
| 2 | ||||||||||||||||||||||||
7627 | // Forbidden | - | ||||||||||||||||||||||||
7628 | parseReference_charDataRead = false; | - | ||||||||||||||||||||||||
7629 | reportParseError(QLatin1String(XMLERR_EXTERNALGENERALENTITYINAV)); | - | ||||||||||||||||||||||||
7630 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
7631 | case InEntityValue: never executed: case InEntityValue: | 0 | ||||||||||||||||||||||||
7632 | { | - | ||||||||||||||||||||||||
7633 | // Bypassed | - | ||||||||||||||||||||||||
7634 | stringAddC(QLatin1Char('&')); | - | ||||||||||||||||||||||||
7635 | for (int i=0; i<(int)reference.length(); i++) {
| 0 | ||||||||||||||||||||||||
7636 | stringAddC(reference[i]); | - | ||||||||||||||||||||||||
7637 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7638 | stringAddC(QLatin1Char(';')); | - | ||||||||||||||||||||||||
7639 | parseReference_charDataRead = true; | - | ||||||||||||||||||||||||
7640 | } | - | ||||||||||||||||||||||||
7641 | break; never executed: break; | 0 | ||||||||||||||||||||||||
7642 | case InDTD: never executed: case InDTD: | 0 | ||||||||||||||||||||||||
7643 | // Forbidden | - | ||||||||||||||||||||||||
7644 | parseReference_charDataRead = false; | - | ||||||||||||||||||||||||
7645 | reportParseError(QLatin1String(XMLERR_EXTERNALGENERALENTITYINDTD)); | - | ||||||||||||||||||||||||
7646 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7647 | } | - | ||||||||||||||||||||||||
7648 | } else { executed 140 times by 1 test: end of block Executed by:
| 140 | ||||||||||||||||||||||||
7649 | // "Unparsed" | - | ||||||||||||||||||||||||
7650 | // ### notify for "Occurs as Attribute Value" missing (but this is no refence, anyway) | - | ||||||||||||||||||||||||
7651 | // Forbidden | - | ||||||||||||||||||||||||
7652 | parseReference_charDataRead = false; | - | ||||||||||||||||||||||||
7653 | reportParseError(QLatin1String(XMLERR_UNPARSEDENTITYREFERENCE)); | - | ||||||||||||||||||||||||
7654 | return false; // error executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
7655 | } | - | ||||||||||||||||||||||||
7656 | } | - | ||||||||||||||||||||||||
7657 | } | - | ||||||||||||||||||||||||
7658 | return true; // no error executed 1256 times by 3 tests: return true; Executed by:
| 1256 | ||||||||||||||||||||||||
7659 | } | - | ||||||||||||||||||||||||
7660 | - | |||||||||||||||||||||||||
7661 | - | |||||||||||||||||||||||||
7662 | /* | - | ||||||||||||||||||||||||
7663 | Parses over a simple string. | - | ||||||||||||||||||||||||
7664 | - | |||||||||||||||||||||||||
7665 | After the string was successfully parsed, the head is on the first | - | ||||||||||||||||||||||||
7666 | character after the string. | - | ||||||||||||||||||||||||
7667 | */ | - | ||||||||||||||||||||||||
7668 | bool QXmlSimpleReaderPrivate::parseString() | - | ||||||||||||||||||||||||
7669 | { | - | ||||||||||||||||||||||||
7670 | const signed char InpCharExpected = 0; // the character that was expected | - | ||||||||||||||||||||||||
7671 | const signed char InpUnknown = 1; | - | ||||||||||||||||||||||||
7672 | - | |||||||||||||||||||||||||
7673 | signed char state; // state in this function is the position in the string s | - | ||||||||||||||||||||||||
7674 | signed char input; | - | ||||||||||||||||||||||||
7675 | - | |||||||||||||||||||||||||
7676 | if (parseStack==0 || parseStack->isEmpty()) {
| 1360-17594 | ||||||||||||||||||||||||
7677 | Done = parseString_s.length(); | - | ||||||||||||||||||||||||
7678 | state = 0; | - | ||||||||||||||||||||||||
7679 | } else { executed 7972 times by 4 tests: end of block Executed by:
| 7972 | ||||||||||||||||||||||||
7680 | state = parseStack->pop().state; | - | ||||||||||||||||||||||||
7681 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
7682 | qDebug("QXmlSimpleReader: parseString (cont) in state %d", state); | - | ||||||||||||||||||||||||
7683 | #endif | - | ||||||||||||||||||||||||
7684 | if (!parseStack->isEmpty()) {
| 0-10982 | ||||||||||||||||||||||||
7685 | ParseFunction function = parseStack->top().function; | - | ||||||||||||||||||||||||
7686 | if (function == &QXmlSimpleReaderPrivate::eat_ws) {
| 0 | ||||||||||||||||||||||||
7687 | parseStack->pop(); | - | ||||||||||||||||||||||||
7688 | #if defined(QT_QXML_DEBUG) | - | ||||||||||||||||||||||||
7689 | qDebug("QXmlSimpleReader: eat_ws (cont)"); | - | ||||||||||||||||||||||||
7690 | #endif | - | ||||||||||||||||||||||||
7691 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7692 | if (!(this->*function)()) {
| 0 | ||||||||||||||||||||||||
7693 | parseFailed(&QXmlSimpleReaderPrivate::parseString, state); | - | ||||||||||||||||||||||||
7694 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7695 | } | - | ||||||||||||||||||||||||
7696 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7697 | } executed 10982 times by 1 test: end of block Executed by:
| 10982 | ||||||||||||||||||||||||
7698 | - | |||||||||||||||||||||||||
7699 | for (;;) { | - | ||||||||||||||||||||||||
7700 | if (state == Done) {
| 7969-61524 | ||||||||||||||||||||||||
7701 | return true; executed 7969 times by 4 tests: return true; Executed by:
| 7969 | ||||||||||||||||||||||||
7702 | } | - | ||||||||||||||||||||||||
7703 | - | |||||||||||||||||||||||||
7704 | if (atEnd()) {
| 10982-50542 | ||||||||||||||||||||||||
7705 | unexpectedEof(&QXmlSimpleReaderPrivate::parseString, state); | - | ||||||||||||||||||||||||
7706 | return false; executed 10982 times by 1 test: return false; Executed by:
| 10982 | ||||||||||||||||||||||||
7707 | } | - | ||||||||||||||||||||||||
7708 | if (c == parseString_s[(int)state]) {
| 3-50539 | ||||||||||||||||||||||||
7709 | input = InpCharExpected; | - | ||||||||||||||||||||||||
7710 | } else { executed 50539 times by 4 tests: end of block Executed by:
| 50539 | ||||||||||||||||||||||||
7711 | input = InpUnknown; | - | ||||||||||||||||||||||||
7712 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||
7713 | if (input == InpCharExpected) {
| 3-50539 | ||||||||||||||||||||||||
7714 | state++; | - | ||||||||||||||||||||||||
7715 | } else { executed 50539 times by 4 tests: end of block Executed by:
| 50539 | ||||||||||||||||||||||||
7716 | // Error | - | ||||||||||||||||||||||||
7717 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDCHARACTER)); | - | ||||||||||||||||||||||||
7718 | return false; executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||||||||||||||||||||
7719 | } | - | ||||||||||||||||||||||||
7720 | - | |||||||||||||||||||||||||
7721 | next(); | - | ||||||||||||||||||||||||
7722 | } executed 50539 times by 4 tests: end of block Executed by:
| 50539 | ||||||||||||||||||||||||
7723 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7724 | } | - | ||||||||||||||||||||||||
7725 | - | |||||||||||||||||||||||||
7726 | /* | - | ||||||||||||||||||||||||
7727 | This private function inserts and reports an entity substitution. The | - | ||||||||||||||||||||||||
7728 | substituted string is \a data and the name of the entity reference is \a | - | ||||||||||||||||||||||||
7729 | name. If \a inLiteral is true, the entity is IncludedInLiteral (i.e., " and ' | - | ||||||||||||||||||||||||
7730 | must be quoted. Otherwise they are not quoted. | - | ||||||||||||||||||||||||
7731 | - | |||||||||||||||||||||||||
7732 | This function returns \c false on error. | - | ||||||||||||||||||||||||
7733 | */ | - | ||||||||||||||||||||||||
7734 | bool QXmlSimpleReaderPrivate::insertXmlRef(const QString &data, const QString &name, bool inLiteral) | - | ||||||||||||||||||||||||
7735 | { | - | ||||||||||||||||||||||||
7736 | if (inLiteral) {
| 93-410 | ||||||||||||||||||||||||
7737 | QString tmp = data; | - | ||||||||||||||||||||||||
7738 | xmlRefStack.push(XmlRef(name, tmp.replace(QLatin1Char('\"'), | - | ||||||||||||||||||||||||
7739 | QLatin1String(""")).replace(QLatin1Char('\''), QLatin1String("'")))); | - | ||||||||||||||||||||||||
7740 | } else { executed 93 times by 1 test: end of block Executed by:
| 93 | ||||||||||||||||||||||||
7741 | xmlRefStack.push(XmlRef(name, data)); | - | ||||||||||||||||||||||||
7742 | } executed 410 times by 1 test: end of block Executed by:
| 410 | ||||||||||||||||||||||||
7743 | int n = qMax(parameterEntities.count(), entities.count()); | - | ||||||||||||||||||||||||
7744 | if (xmlRefStack.count() > n+1) {
| 4-499 | ||||||||||||||||||||||||
7745 | // recursive entities | - | ||||||||||||||||||||||||
7746 | reportParseError(QLatin1String(XMLERR_RECURSIVEENTITIES)); | - | ||||||||||||||||||||||||
7747 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
7748 | } | - | ||||||||||||||||||||||||
7749 | if (reportEntities && lexicalHnd) {
| 0-499 | ||||||||||||||||||||||||
7750 | if (!lexicalHnd->startEntity(name)) {
| 0 | ||||||||||||||||||||||||
7751 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||||||||||||||
7752 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7753 | } | - | ||||||||||||||||||||||||
7754 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7755 | return true; executed 499 times by 1 test: return true; Executed by:
| 499 | ||||||||||||||||||||||||
7756 | } | - | ||||||||||||||||||||||||
7757 | - | |||||||||||||||||||||||||
7758 | /* | - | ||||||||||||||||||||||||
7759 | This private function moves the cursor to the next character. | - | ||||||||||||||||||||||||
7760 | */ | - | ||||||||||||||||||||||||
7761 | void QXmlSimpleReaderPrivate::next() | - | ||||||||||||||||||||||||
7762 | { | - | ||||||||||||||||||||||||
7763 | int count = xmlRefStack.size(); | - | ||||||||||||||||||||||||
7764 | while (count != 0) {
| 2697-791592 | ||||||||||||||||||||||||
7765 | if (xmlRefStack.top().isEmpty()) {
| 477-2220 | ||||||||||||||||||||||||
7766 | xmlRefStack.pop_back(); | - | ||||||||||||||||||||||||
7767 | count--; | - | ||||||||||||||||||||||||
7768 | } else { executed 477 times by 1 test: end of block Executed by:
| 477 | ||||||||||||||||||||||||
7769 | c = xmlRefStack.top().next(); | - | ||||||||||||||||||||||||
7770 | return; executed 2220 times by 1 test: return; Executed by:
| 2220 | ||||||||||||||||||||||||
7771 | } | - | ||||||||||||||||||||||||
7772 | } | - | ||||||||||||||||||||||||
7773 | - | |||||||||||||||||||||||||
7774 | // the following could be written nicer, but since it is a time-critical | - | ||||||||||||||||||||||||
7775 | // function, rather optimize for speed | - | ||||||||||||||||||||||||
7776 | ushort uc = c.unicode(); | - | ||||||||||||||||||||||||
7777 | c = inputSource->next(); | - | ||||||||||||||||||||||||
7778 | // If we are not incremental parsing, we just skip over EndOfData chars to give the | - | ||||||||||||||||||||||||
7779 | // parser an uninterrupted stream of document chars. | - | ||||||||||||||||||||||||
7780 | if (c == QXmlInputSource::EndOfData && parseStack == 0)
| 989-745695 | ||||||||||||||||||||||||
7781 | c = inputSource->next(); executed 989 times by 6 tests: c = inputSource->next(); Executed by:
| 989 | ||||||||||||||||||||||||
7782 | if (uc == '\n') {
| 18010-773582 | ||||||||||||||||||||||||
7783 | lineNr++; | - | ||||||||||||||||||||||||
7784 | columnNr = -1; | - | ||||||||||||||||||||||||
7785 | } else if (uc == '\r') { executed 18010 times by 5 tests: end of block Executed by:
| 8363-765219 | ||||||||||||||||||||||||
7786 | if (c != QLatin1Char('\n')) {
| 2546-5817 | ||||||||||||||||||||||||
7787 | lineNr++; | - | ||||||||||||||||||||||||
7788 | columnNr = -1; | - | ||||||||||||||||||||||||
7789 | } executed 2546 times by 1 test: end of block Executed by:
| 2546 | ||||||||||||||||||||||||
7790 | } executed 8363 times by 2 tests: end of block Executed by:
| 8363 | ||||||||||||||||||||||||
7791 | ++columnNr; | - | ||||||||||||||||||||||||
7792 | } executed 791592 times by 6 tests: end of block Executed by:
| 791592 | ||||||||||||||||||||||||
7793 | - | |||||||||||||||||||||||||
7794 | /* | - | ||||||||||||||||||||||||
7795 | This private function moves the cursor to the next non-whitespace character. | - | ||||||||||||||||||||||||
7796 | This function does not move the cursor if the actual cursor position is a | - | ||||||||||||||||||||||||
7797 | non-whitespace charcter. | - | ||||||||||||||||||||||||
7798 | - | |||||||||||||||||||||||||
7799 | Returns \c false when you use incremental parsing and this function reaches EOF | - | ||||||||||||||||||||||||
7800 | with reading only whitespace characters. In this case it also poplulates the | - | ||||||||||||||||||||||||
7801 | parseStack with useful information. In all other cases, this function returns | - | ||||||||||||||||||||||||
7802 | true. | - | ||||||||||||||||||||||||
7803 | */ | - | ||||||||||||||||||||||||
7804 | bool QXmlSimpleReaderPrivate::eat_ws() | - | ||||||||||||||||||||||||
7805 | { | - | ||||||||||||||||||||||||
7806 | while (!atEnd()) {
| 10298-90379 | ||||||||||||||||||||||||
7807 | if (!is_S(c)) {
| 41757-48622 | ||||||||||||||||||||||||
7808 | return true; executed 48622 times by 6 tests: return true; Executed by:
| 48622 | ||||||||||||||||||||||||
7809 | } | - | ||||||||||||||||||||||||
7810 | next(); | - | ||||||||||||||||||||||||
7811 | } executed 41757 times by 6 tests: end of block Executed by:
| 41757 | ||||||||||||||||||||||||
7812 | if (parseStack != 0) {
| 210-10088 | ||||||||||||||||||||||||
7813 | unexpectedEof(&QXmlSimpleReaderPrivate::eat_ws, 0); | - | ||||||||||||||||||||||||
7814 | return false; executed 10088 times by 1 test: return false; Executed by:
| 10088 | ||||||||||||||||||||||||
7815 | } | - | ||||||||||||||||||||||||
7816 | return true; executed 210 times by 2 tests: return true; Executed by:
| 210 | ||||||||||||||||||||||||
7817 | } | - | ||||||||||||||||||||||||
7818 | - | |||||||||||||||||||||||||
7819 | bool QXmlSimpleReaderPrivate::next_eat_ws() | - | ||||||||||||||||||||||||
7820 | { | - | ||||||||||||||||||||||||
7821 | next(); | - | ||||||||||||||||||||||||
7822 | return eat_ws(); executed 17906 times by 6 tests: return eat_ws(); Executed by:
| 17906 | ||||||||||||||||||||||||
7823 | } | - | ||||||||||||||||||||||||
7824 | - | |||||||||||||||||||||||||
7825 | - | |||||||||||||||||||||||||
7826 | /* | - | ||||||||||||||||||||||||
7827 | This private function initializes the reader. \a i is the input source to | - | ||||||||||||||||||||||||
7828 | read the data from. | - | ||||||||||||||||||||||||
7829 | */ | - | ||||||||||||||||||||||||
7830 | void QXmlSimpleReaderPrivate::init(const QXmlInputSource *i) | - | ||||||||||||||||||||||||
7831 | { | - | ||||||||||||||||||||||||
7832 | lineNr = 0; | - | ||||||||||||||||||||||||
7833 | columnNr = -1; | - | ||||||||||||||||||||||||
7834 | inputSource = const_cast<QXmlInputSource *>(i); | - | ||||||||||||||||||||||||
7835 | initData(); | - | ||||||||||||||||||||||||
7836 | - | |||||||||||||||||||||||||
7837 | externParameterEntities.clear(); | - | ||||||||||||||||||||||||
7838 | parameterEntities.clear(); | - | ||||||||||||||||||||||||
7839 | externEntities.clear(); | - | ||||||||||||||||||||||||
7840 | entities.clear(); | - | ||||||||||||||||||||||||
7841 | - | |||||||||||||||||||||||||
7842 | tags.clear(); | - | ||||||||||||||||||||||||
7843 | - | |||||||||||||||||||||||||
7844 | doctype.clear(); | - | ||||||||||||||||||||||||
7845 | xmlVersion.clear(); | - | ||||||||||||||||||||||||
7846 | encoding.clear(); | - | ||||||||||||||||||||||||
7847 | standalone = QXmlSimpleReaderPrivate::Unknown; | - | ||||||||||||||||||||||||
7848 | error.clear(); | - | ||||||||||||||||||||||||
7849 | } executed 2106 times by 6 tests: end of block Executed by:
| 2106 | ||||||||||||||||||||||||
7850 | - | |||||||||||||||||||||||||
7851 | /* | - | ||||||||||||||||||||||||
7852 | This private function initializes the XML data related variables. Especially, | - | ||||||||||||||||||||||||
7853 | it reads the data from the input source. | - | ||||||||||||||||||||||||
7854 | */ | - | ||||||||||||||||||||||||
7855 | void QXmlSimpleReaderPrivate::initData() | - | ||||||||||||||||||||||||
7856 | { | - | ||||||||||||||||||||||||
7857 | c = QXmlInputSource::EndOfData; | - | ||||||||||||||||||||||||
7858 | xmlRefStack.clear(); | - | ||||||||||||||||||||||||
7859 | next(); | - | ||||||||||||||||||||||||
7860 | } executed 47014 times by 6 tests: end of block Executed by:
| 47014 | ||||||||||||||||||||||||
7861 | - | |||||||||||||||||||||||||
7862 | /* | - | ||||||||||||||||||||||||
7863 | Returns \c true if a entity with the name \a e exists, | - | ||||||||||||||||||||||||
7864 | otherwise returns \c false. | - | ||||||||||||||||||||||||
7865 | */ | - | ||||||||||||||||||||||||
7866 | bool QXmlSimpleReaderPrivate::entityExist(const QString& e) const | - | ||||||||||||||||||||||||
7867 | { | - | ||||||||||||||||||||||||
7868 | if ( parameterEntities.find(e) == parameterEntities.end() &&
| 10-646 | ||||||||||||||||||||||||
7869 | externParameterEntities.find(e) == externParameterEntities.end() &&
| 0-646 | ||||||||||||||||||||||||
7870 | externEntities.find(e) == externEntities.end() &&
| 0-646 | ||||||||||||||||||||||||
7871 | entities.find(e) == entities.end()) {
| 10-636 | ||||||||||||||||||||||||
7872 | return false; executed 636 times by 2 tests: return false; Executed by:
| 636 | ||||||||||||||||||||||||
7873 | } else { | - | ||||||||||||||||||||||||
7874 | return true; executed 20 times by 1 test: return true; Executed by:
| 20 | ||||||||||||||||||||||||
7875 | } | - | ||||||||||||||||||||||||
7876 | } | - | ||||||||||||||||||||||||
7877 | - | |||||||||||||||||||||||||
7878 | void QXmlSimpleReaderPrivate::reportParseError(const QString& error) | - | ||||||||||||||||||||||||
7879 | { | - | ||||||||||||||||||||||||
7880 | this->error = error; | - | ||||||||||||||||||||||||
7881 | if (errorHnd) {
| 0-155 | ||||||||||||||||||||||||
7882 | if (this->error.isNull()) {
| 0-155 | ||||||||||||||||||||||||
7883 | const QXmlParseException ex(QLatin1String(XMLERR_OK), columnNr+1, lineNr+1, | - | ||||||||||||||||||||||||
7884 | thisPublicId, thisSystemId); | - | ||||||||||||||||||||||||
7885 | errorHnd->fatalError(ex); | - | ||||||||||||||||||||||||
7886 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
7887 | const QXmlParseException ex(this->error, columnNr+1, lineNr+1, | - | ||||||||||||||||||||||||
7888 | thisPublicId, thisSystemId); | - | ||||||||||||||||||||||||
7889 | errorHnd->fatalError(ex); | - | ||||||||||||||||||||||||
7890 | } executed 155 times by 1 test: end of block Executed by:
| 155 | ||||||||||||||||||||||||
7891 | } | - | ||||||||||||||||||||||||
7892 | } executed 155 times by 1 test: end of block Executed by:
| 155 | ||||||||||||||||||||||||
7893 | - | |||||||||||||||||||||||||
7894 | /* | - | ||||||||||||||||||||||||
7895 | This private function is called when a parsing function encounters an | - | ||||||||||||||||||||||||
7896 | unexpected EOF. It decides what to do (depending on incremental parsing or | - | ||||||||||||||||||||||||
7897 | not). \a where is a pointer to the function where the error occurred and \a | - | ||||||||||||||||||||||||
7898 | state is the parsing state in this function. | - | ||||||||||||||||||||||||
7899 | */ | - | ||||||||||||||||||||||||
7900 | void QXmlSimpleReaderPrivate::unexpectedEof(ParseFunction where, int state) | - | ||||||||||||||||||||||||
7901 | { | - | ||||||||||||||||||||||||
7902 | if (parseStack == 0) {
| 19-44467 | ||||||||||||||||||||||||
7903 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDEOF)); | - | ||||||||||||||||||||||||
7904 | } else { executed 19 times by 1 test: end of block Executed by:
| 19 | ||||||||||||||||||||||||
7905 | if (c == QXmlInputSource::EndOfDocument) {
| 0-44467 | ||||||||||||||||||||||||
7906 | reportParseError(QLatin1String(XMLERR_UNEXPECTEDEOF)); | - | ||||||||||||||||||||||||
7907 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
7908 | pushParseState(where, state); | - | ||||||||||||||||||||||||
7909 | } executed 44467 times by 1 test: end of block Executed by:
| 44467 | ||||||||||||||||||||||||
7910 | } | - | ||||||||||||||||||||||||
7911 | } | - | ||||||||||||||||||||||||
7912 | - | |||||||||||||||||||||||||
7913 | /* | - | ||||||||||||||||||||||||
7914 | This private function is called when a parse...() function returned false. It | - | ||||||||||||||||||||||||
7915 | determines if there was an error or if incremental parsing simply went out of | - | ||||||||||||||||||||||||
7916 | data and does the right thing for the case. \a where is a pointer to the | - | ||||||||||||||||||||||||
7917 | function where the error occurred and \a state is the parsing state in this | - | ||||||||||||||||||||||||
7918 | function. | - | ||||||||||||||||||||||||
7919 | */ | - | ||||||||||||||||||||||||
7920 | void QXmlSimpleReaderPrivate::parseFailed(ParseFunction where, int state) | - | ||||||||||||||||||||||||
7921 | { | - | ||||||||||||||||||||||||
7922 | if (parseStack!=0 && error.isNull()) {
| 0-111660 | ||||||||||||||||||||||||
7923 | pushParseState(where, state); | - | ||||||||||||||||||||||||
7924 | } executed 111660 times by 1 test: end of block Executed by:
| 111660 | ||||||||||||||||||||||||
7925 | } executed 112002 times by 1 test: end of block Executed by:
| 112002 | ||||||||||||||||||||||||
7926 | - | |||||||||||||||||||||||||
7927 | /* | - | ||||||||||||||||||||||||
7928 | This private function pushes the function pointer \a function and state \a | - | ||||||||||||||||||||||||
7929 | state to the parse stack. This is used when you are doing an incremental | - | ||||||||||||||||||||||||
7930 | parsing and reach the end of file too early. | - | ||||||||||||||||||||||||
7931 | - | |||||||||||||||||||||||||
7932 | Only call this function when d->parseStack!=0. | - | ||||||||||||||||||||||||
7933 | */ | - | ||||||||||||||||||||||||
7934 | void QXmlSimpleReaderPrivate::pushParseState(ParseFunction function, int state) | - | ||||||||||||||||||||||||
7935 | { | - | ||||||||||||||||||||||||
7936 | QXmlSimpleReaderPrivate::ParseState ps; | - | ||||||||||||||||||||||||
7937 | ps.function = function; | - | ||||||||||||||||||||||||
7938 | ps.state = state; | - | ||||||||||||||||||||||||
7939 | parseStack->push(ps); | - | ||||||||||||||||||||||||
7940 | } executed 201035 times by 1 test: end of block Executed by:
| 201035 | ||||||||||||||||||||||||
7941 | - | |||||||||||||||||||||||||
7942 | inline static void updateValue(QString &value, const QChar *array, int &arrayPos, int &valueLen) | - | ||||||||||||||||||||||||
7943 | { | - | ||||||||||||||||||||||||
7944 | value.resize(valueLen + arrayPos); | - | ||||||||||||||||||||||||
7945 | memcpy(value.data() + valueLen, array, arrayPos * sizeof(QChar)); | - | ||||||||||||||||||||||||
7946 | valueLen += arrayPos; | - | ||||||||||||||||||||||||
7947 | arrayPos = 0; | - | ||||||||||||||||||||||||
7948 | } executed 53191 times by 6 tests: end of block Executed by:
| 53191 | ||||||||||||||||||||||||
7949 | - | |||||||||||||||||||||||||
7950 | // use buffers instead of QString::operator+= when single characters are read | - | ||||||||||||||||||||||||
7951 | const QString& QXmlSimpleReaderPrivate::string() | - | ||||||||||||||||||||||||
7952 | { | - | ||||||||||||||||||||||||
7953 | updateValue(stringValue, stringArray, stringArrayPos, stringValueLen); | - | ||||||||||||||||||||||||
7954 | return stringValue; executed 21656 times by 6 tests: return stringValue; Executed by:
| 21656 | ||||||||||||||||||||||||
7955 | } | - | ||||||||||||||||||||||||
7956 | const QString& QXmlSimpleReaderPrivate::name() | - | ||||||||||||||||||||||||
7957 | { | - | ||||||||||||||||||||||||
7958 | updateValue(nameValue, nameArray, nameArrayPos, nameValueLen); | - | ||||||||||||||||||||||||
7959 | return nameValue; executed 29710 times by 6 tests: return nameValue; Executed by:
| 29710 | ||||||||||||||||||||||||
7960 | } | - | ||||||||||||||||||||||||
7961 | const QString& QXmlSimpleReaderPrivate::ref() | - | ||||||||||||||||||||||||
7962 | { | - | ||||||||||||||||||||||||
7963 | updateValue(refValue, refArray, refArrayPos, refValueLen); | - | ||||||||||||||||||||||||
7964 | return refValue; executed 1793 times by 3 tests: return refValue; Executed by:
| 1793 | ||||||||||||||||||||||||
7965 | } | - | ||||||||||||||||||||||||
7966 | - | |||||||||||||||||||||||||
7967 | void QXmlSimpleReaderPrivate::stringAddC(QChar ch) | - | ||||||||||||||||||||||||
7968 | { | - | ||||||||||||||||||||||||
7969 | if (stringArrayPos == 256)
| 32-426009 | ||||||||||||||||||||||||
7970 | updateValue(stringValue, stringArray, stringArrayPos, stringValueLen); executed 32 times by 1 test: updateValue(stringValue, stringArray, stringArrayPos, stringValueLen); Executed by:
| 32 | ||||||||||||||||||||||||
7971 | stringArray[stringArrayPos++] = ch; | - | ||||||||||||||||||||||||
7972 | } executed 426041 times by 6 tests: end of block Executed by:
| 426041 | ||||||||||||||||||||||||
7973 | void QXmlSimpleReaderPrivate::nameAddC(QChar ch) | - | ||||||||||||||||||||||||
7974 | { | - | ||||||||||||||||||||||||
7975 | if (nameArrayPos == 256)
| 0-126369 | ||||||||||||||||||||||||
7976 | updateValue(nameValue, nameArray, nameArrayPos, nameValueLen); never executed: updateValue(nameValue, nameArray, nameArrayPos, nameValueLen); | 0 | ||||||||||||||||||||||||
7977 | nameArray[nameArrayPos++] = ch; | - | ||||||||||||||||||||||||
7978 | } executed 126369 times by 6 tests: end of block Executed by:
| 126369 | ||||||||||||||||||||||||
7979 | void QXmlSimpleReaderPrivate::refAddC(QChar ch) | - | ||||||||||||||||||||||||
7980 | { | - | ||||||||||||||||||||||||
7981 | if (refArrayPos == 256)
| 0-4396 | ||||||||||||||||||||||||
7982 | updateValue(refValue, refArray, refArrayPos, refValueLen); never executed: updateValue(refValue, refArray, refArrayPos, refValueLen); | 0 | ||||||||||||||||||||||||
7983 | refArray[refArrayPos++] = ch; | - | ||||||||||||||||||||||||
7984 | } executed 4396 times by 3 tests: end of block Executed by:
| 4396 | ||||||||||||||||||||||||
7985 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |