qmimetypeparser.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/mimetypes/qmimetypeparser.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#define QT_NO_CAST_FROM_ASCII-
35-
36#include "qmimetypeparser_p.h"-
37-
38#ifndef QT_NO_MIMETYPE-
39-
40#include "qmimetype_p.h"-
41#include "qmimemagicrulematcher_p.h"-
42-
43#include <QtCore/QCoreApplication>-
44#include <QtCore/QDebug>-
45#include <QtCore/QDir>-
46#include <QtCore/QPair>-
47#include <QtCore/QXmlStreamReader>-
48#include <QtCore/QXmlStreamWriter>-
49#include <QtCore/QStack>-
50-
51QT_BEGIN_NAMESPACE-
52-
53// XML tags in MIME files-
54static const char mimeInfoTagC[] = "mime-info";-
55static const char mimeTypeTagC[] = "mime-type";-
56static const char mimeTypeAttributeC[] = "type";-
57static const char subClassTagC[] = "sub-class-of";-
58static const char commentTagC[] = "comment";-
59static const char genericIconTagC[] = "generic-icon";-
60static const char iconTagC[] = "icon";-
61static const char nameAttributeC[] = "name";-
62static const char globTagC[] = "glob";-
63static const char aliasTagC[] = "alias";-
64static const char patternAttributeC[] = "pattern";-
65static const char weightAttributeC[] = "weight";-
66static const char caseSensitiveAttributeC[] = "case-sensitive";-
67static const char localeAttributeC[] = "xml:lang";-
68-
69static const char magicTagC[] = "magic";-
70static const char priorityAttributeC[] = "priority";-
71-
72static const char matchTagC[] = "match";-
73static const char matchValueAttributeC[] = "value";-
74static const char matchTypeAttributeC[] = "type";-
75static const char matchOffsetAttributeC[] = "offset";-
76static const char matchMaskAttributeC[] = "mask";-
77-
78/*!-
79 \class QMimeTypeParser-
80 \inmodule QtCore-
81 \internal-
82 \brief The QMimeTypeParser class parses MIME types, and builds a MIME database hierarchy by adding to QMimeDatabasePrivate.-
83-
84 Populates QMimeDataBase-
85-
86 \sa QMimeDatabase, QMimeMagicRuleMatcher, MagicRule, MagicStringRule, MagicByteRule, GlobPattern-
87 \sa QMimeTypeParser-
88*/-
89-
90/*!-
91 \class QMimeTypeParserBase-
92 \inmodule QtCore-
93 \internal-
94 \brief The QMimeTypeParserBase class parses for a sequence of <mime-type> in a generic way.-
95-
96 Calls abstract handler function process for QMimeType it finds.-
97-
98 \sa QMimeDatabase, QMimeMagicRuleMatcher, MagicRule, MagicStringRule, MagicByteRule, GlobPattern-
99 \sa QMimeTypeParser-
100*/-
101-
102/*!-
103 \fn virtual bool QMimeTypeParserBase::process(const QMimeType &t, QString *errorMessage) = 0;-
104 Overwrite to process the sequence of parsed data-
105*/-
106-
107QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState currentState, const QStringRef &startElement)-
108{-
109 switch (currentState) {-
110 case ParseBeginning:
executed 17 times by 1 test: case ParseBeginning:
Executed by:
  • tst_QMimeDatabase
17
111 if (startElement == QLatin1String(mimeInfoTagC))
startElement =...(mimeInfoTagC)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-17
112 return ParseMimeInfo;
executed 17 times by 1 test: return ParseMimeInfo;
Executed by:
  • tst_QMimeDatabase
17
113 if (startElement == QLatin1String(mimeTypeTagC))
startElement =...(mimeTypeTagC)Description
TRUEnever evaluated
FALSEnever evaluated
0
114 return ParseMimeType;
never executed: return ParseMimeType;
0
115 return ParseError;
never executed: return ParseError;
0
116 case ParseMimeInfo:
executed 17 times by 1 test: case ParseMimeInfo:
Executed by:
  • tst_QMimeDatabase
17
117 return startElement == QLatin1String(mimeTypeTagC) ? ParseMimeType : ParseError;
executed 17 times by 1 test: return startElement == QLatin1String(mimeTypeTagC) ? ParseMimeType : ParseError;
Executed by:
  • tst_QMimeDatabase
startElement =...(mimeTypeTagC)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-17
118 case ParseMimeType:
executed 3319 times by 1 test: case ParseMimeType:
Executed by:
  • tst_QMimeDatabase
3319
119 case ParseComment:
executed 134104 times by 1 test: case ParseComment:
Executed by:
  • tst_QMimeDatabase
134104
120 case ParseGenericIcon:
executed 1575 times by 1 test: case ParseGenericIcon:
Executed by:
  • tst_QMimeDatabase
1575
121 case ParseIcon:
never executed: case ParseIcon:
0
122 case ParseGlobPattern:
executed 4132 times by 1 test: case ParseGlobPattern:
Executed by:
  • tst_QMimeDatabase
4132
123 case ParseSubClass:
executed 1560 times by 1 test: case ParseSubClass:
Executed by:
  • tst_QMimeDatabase
1560
124 case ParseAlias:
executed 975 times by 1 test: case ParseAlias:
Executed by:
  • tst_QMimeDatabase
975
125 case ParseOtherMimeTypeSubTag:
executed 1825 times by 1 test: case ParseOtherMimeTypeSubTag:
Executed by:
  • tst_QMimeDatabase
1825
126 case ParseMagicMatchRule:
executed 4052 times by 1 test: case ParseMagicMatchRule:
Executed by:
  • tst_QMimeDatabase
4052
127 if (startElement == QLatin1String(mimeTypeTagC)) // Sequence of <mime-type>
startElement =...(mimeTypeTagC)Description
TRUEevaluated 3302 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 148240 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
3302-148240
128 return ParseMimeType;
executed 3302 times by 1 test: return ParseMimeType;
Executed by:
  • tst_QMimeDatabase
3302
129 if (startElement == QLatin1String(commentTagC ))
startElement =...(commentTagC )Description
TRUEevaluated 134104 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 14136 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
14136-134104
130 return ParseComment;
executed 134104 times by 1 test: return ParseComment;
Executed by:
  • tst_QMimeDatabase
134104
131 if (startElement == QLatin1String(genericIconTagC))
startElement =...nericIconTagC)Description
TRUEevaluated 1575 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 12561 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
1575-12561
132 return ParseGenericIcon;
executed 1575 times by 1 test: return ParseGenericIcon;
Executed by:
  • tst_QMimeDatabase
1575
133 if (startElement == QLatin1String(iconTagC))
startElement =...ring(iconTagC)Description
TRUEnever evaluated
FALSEevaluated 12561 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-12561
134 return ParseIcon;
never executed: return ParseIcon;
0
135 if (startElement == QLatin1String(globTagC))
startElement =...ring(globTagC)Description
TRUEevaluated 4136 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 8425 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
4136-8425
136 return ParseGlobPattern;
executed 4136 times by 1 test: return ParseGlobPattern;
Executed by:
  • tst_QMimeDatabase
4136
137 if (startElement == QLatin1String(subClassTagC))
startElement =...(subClassTagC)Description
TRUEevaluated 1560 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 6865 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
1560-6865
138 return ParseSubClass;
executed 1560 times by 1 test: return ParseSubClass;
Executed by:
  • tst_QMimeDatabase
1560
139 if (startElement == QLatin1String(aliasTagC))
startElement =...ing(aliasTagC)Description
TRUEevaluated 975 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 5890 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
975-5890
140 return ParseAlias;
executed 975 times by 1 test: return ParseAlias;
Executed by:
  • tst_QMimeDatabase
975
141 if (startElement == QLatin1String(magicTagC))
startElement =...ing(magicTagC)Description
TRUEevaluated 1733 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4157 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
1733-4157
142 return ParseMagic;
executed 1733 times by 1 test: return ParseMagic;
Executed by:
  • tst_QMimeDatabase
1733
143 if (startElement == QLatin1String(matchTagC))
startElement =...ing(matchTagC)Description
TRUEevaluated 2325 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 1832 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
1832-2325
144 return ParseMagicMatchRule;
executed 2325 times by 1 test: return ParseMagicMatchRule;
Executed by:
  • tst_QMimeDatabase
2325
145 return ParseOtherMimeTypeSubTag;
executed 1832 times by 1 test: return ParseOtherMimeTypeSubTag;
Executed by:
  • tst_QMimeDatabase
1832
146 case ParseMagic:
executed 1733 times by 1 test: case ParseMagic:
Executed by:
  • tst_QMimeDatabase
1733
147 if (startElement == QLatin1String(matchTagC))
startElement =...ing(matchTagC)Description
TRUEevaluated 1733 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-1733
148 return ParseMagicMatchRule;
executed 1733 times by 1 test: return ParseMagicMatchRule;
Executed by:
  • tst_QMimeDatabase
1733
149 break;
never executed: break;
0
150 case ParseError:
never executed: case ParseError:
0
151 break;
never executed: break;
0
152 }-
153 return ParseError;
never executed: return ParseError;
0
154}-
155-
156// Parse int number from an (attribute) string-
157bool QMimeTypeParserBase::parseNumber(const QString &n, int *target, QString *errorMessage)-
158{-
159 bool ok;-
160 *target = n.toInt(&ok);-
161 if (!ok) {
!okDescription
TRUEnever evaluated
FALSEevaluated 9733 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-9733
162 *errorMessage = QString::fromLatin1("Not a number '%1'.").arg(n);-
163 return false;
never executed: return false;
0
164 }-
165 return true;
executed 9733 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
9733
166}-
167-
168#ifndef QT_NO_XMLSTREAMREADER-
169static QMimeMagicRule *createMagicMatchRule(const QXmlStreamAttributes &atts, QString *errorMessage)-
170{-
171 const QString type = atts.value(QLatin1String(matchTypeAttributeC)).toString();-
172 const QString value = atts.value(QLatin1String(matchValueAttributeC)).toString();-
173 const QString offsets = atts.value(QLatin1String(matchOffsetAttributeC)).toString();-
174 const QString mask = atts.value(QLatin1String(matchMaskAttributeC)).toString();-
175 return new QMimeMagicRule(type, value.toUtf8(), offsets, mask.toLatin1(), errorMessage);
executed 4058 times by 1 test: return new QMimeMagicRule(type, value.toUtf8(), offsets, mask.toLatin1(), errorMessage);
Executed by:
  • tst_QMimeDatabase
4058
176}-
177#endif-
178-
179bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString *errorMessage)-
180{-
181#ifdef QT_NO_XMLSTREAMREADER-
182 if (errorMessage)-
183 *errorMessage = QString::fromLatin1("QXmlStreamReader is not available, cannot parse.");-
184 return false;-
185#else-
186 QMimeTypePrivate data;-
187 int priority = 50;-
188 QStack<QMimeMagicRule *> currentRules; // stack for the nesting of rules-
189 QList<QMimeMagicRule> rules; // toplevel rules-
190 QXmlStreamReader reader(dev);-
191 ParseState ps = ParseBeginning;-
192 QXmlStreamAttributes atts;-
193 while (!reader.atEnd()) {
!reader.atEnd()Description
TRUEevaluated 333413 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 17 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
17-333413
194 switch (reader.readNext()) {-
195 case QXmlStreamReader::StartElement:
executed 153309 times by 1 test: case QXmlStreamReader::StartElement:
Executed by:
  • tst_QMimeDatabase
153309
196 ps = nextState(ps, reader.name());-
197 atts = reader.attributes();-
198 switch (ps) {-
199 case ParseMimeType: { // start parsing a MIME type name
executed 3319 times by 1 test: case ParseMimeType:
Executed by:
  • tst_QMimeDatabase
3319
200 const QString name = atts.value(QLatin1String(mimeTypeAttributeC)).toString();-
201 if (name.isEmpty()) {
name.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 3319 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-3319
202 reader.raiseError(QString::fromLatin1("Missing '%1'-attribute").arg(QString::fromLatin1(mimeTypeAttributeC)));-
203 } else {
never executed: end of block
0
204 data.name = name;-
205 }
executed 3319 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
3319
206 }-
207 break;
executed 3319 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
3319
208 case ParseGenericIcon:
executed 1575 times by 1 test: case ParseGenericIcon:
Executed by:
  • tst_QMimeDatabase
1575
209 data.genericIconName = atts.value(QLatin1String(nameAttributeC)).toString();-
210 break;
executed 1575 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
1575
211 case ParseIcon:
never executed: case ParseIcon:
0
212 data.iconName = atts.value(QLatin1String(nameAttributeC)).toString();-
213 break;
never executed: break;
0
214 case ParseGlobPattern: {
executed 4136 times by 1 test: case ParseGlobPattern:
Executed by:
  • tst_QMimeDatabase
4136
215 const QString pattern = atts.value(QLatin1String(patternAttributeC)).toString();-
216 unsigned weight = atts.value(QLatin1String(weightAttributeC)).toString().toInt();-
217 const bool caseSensitive = atts.value(QLatin1String(caseSensitiveAttributeC)).toString() == QLatin1String("true");-
218-
219 if (weight == 0)
weight == 0Description
TRUEevaluated 4126 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
10-4126
220 weight = QMimeGlobPattern::DefaultWeight;
executed 4126 times by 1 test: weight = QMimeGlobPattern::DefaultWeight;
Executed by:
  • tst_QMimeDatabase
4126
221-
222 Q_ASSERT(!data.name.isEmpty());-
223 const QMimeGlobPattern glob(pattern, data.name, weight, caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);-
224 if (!process(glob, errorMessage)) // for actual glob matching
!process(glob, errorMessage)Description
TRUEnever evaluated
FALSEevaluated 4136 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-4136
225 return false;
never executed: return false;
0
226 data.addGlobPattern(pattern); // just for QMimeType::globPatterns()-
227 }-
228 break;
executed 4136 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
4136
229 case ParseSubClass: {
executed 1560 times by 1 test: case ParseSubClass:
Executed by:
  • tst_QMimeDatabase
1560
230 const QString inheritsFrom = atts.value(QLatin1String(mimeTypeAttributeC)).toString();-
231 if (!inheritsFrom.isEmpty())
!inheritsFrom.isEmpty()Description
TRUEevaluated 1560 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-1560
232 processParent(data.name, inheritsFrom);
executed 1560 times by 1 test: processParent(data.name, inheritsFrom);
Executed by:
  • tst_QMimeDatabase
1560
233 }-
234 break;
executed 1560 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
1560
235 case ParseComment: {
executed 134104 times by 1 test: case ParseComment:
Executed by:
  • tst_QMimeDatabase
134104
236 // comments have locale attributes. We want the default, English one-
237 QString locale = atts.value(QLatin1String(localeAttributeC)).toString();-
238 const QString comment = reader.readElementText();-
239 if (locale.isEmpty())
locale.isEmpty()Description
TRUEevaluated 3319 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 130785 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
3319-130785
240 locale = QString::fromLatin1("en_US");
executed 3319 times by 1 test: locale = QString::fromLatin1("en_US");
Executed by:
  • tst_QMimeDatabase
3319
241 data.localeComments.insert(locale, comment);-
242 }-
243 break;
executed 134104 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
134104
244 case ParseAlias: {
executed 975 times by 1 test: case ParseAlias:
Executed by:
  • tst_QMimeDatabase
975
245 const QString alias = atts.value(QLatin1String(mimeTypeAttributeC)).toString();-
246 if (!alias.isEmpty())
!alias.isEmpty()Description
TRUEevaluated 975 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-975
247 processAlias(alias, data.name);
executed 975 times by 1 test: processAlias(alias, data.name);
Executed by:
  • tst_QMimeDatabase
975
248 }-
249 break;
executed 975 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
975
250 case ParseMagic: {
executed 1733 times by 1 test: case ParseMagic:
Executed by:
  • tst_QMimeDatabase
1733
251 priority = 50;-
252 const QString priorityS = atts.value(QLatin1String(priorityAttributeC)).toString();-
253 if (!priorityS.isEmpty()) {
!priorityS.isEmpty()Description
TRUEevaluated 1617 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 116 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
116-1617
254 if (!parseNumber(priorityS, &priority, errorMessage))
!parseNumber(p... errorMessage)Description
TRUEnever evaluated
FALSEevaluated 1617 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-1617
255 return false;
never executed: return false;
0
256-
257 }
executed 1617 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1617
258 currentRules.clear();-
259 //qDebug() << "MAGIC start for mimetype" << data.name;-
260 }-
261 break;
executed 1733 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
1733
262 case ParseMagicMatchRule: {
executed 4058 times by 1 test: case ParseMagicMatchRule:
Executed by:
  • tst_QMimeDatabase
4058
263 QString magicErrorMessage;-
264 QMimeMagicRule *rule = createMagicMatchRule(atts, &magicErrorMessage);-
265 if (!rule->isValid())
!rule->isValid()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4052 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
6-4052
266 qWarning("QMimeDatabase: Error parsing %s\n%s", qPrintable(fileName), qPrintable(magicErrorMessage));
executed 6 times by 1 test: QMessageLogger(__FILE__, 266, __PRETTY_FUNCTION__).warning("QMimeDatabase: Error parsing %s\n%s", QString(fileName).toLocal8Bit().constData(), QString(magicErrorMessage).toLocal8Bit().constData());
Executed by:
  • tst_QMimeDatabase
6
267 QList<QMimeMagicRule> *ruleList;-
268 if (currentRules.isEmpty())
currentRules.isEmpty()Description
TRUEevaluated 3018 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 1040 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
1040-3018
269 ruleList = &rules;
executed 3018 times by 1 test: ruleList = &rules;
Executed by:
  • tst_QMimeDatabase
3018
270 else // nest this rule into the proper parent-
271 ruleList = &currentRules.top()->m_subMatches;
executed 1040 times by 1 test: ruleList = &currentRules.top()->m_subMatches;
Executed by:
  • tst_QMimeDatabase
1040
272 ruleList->append(*rule);-
273 //qDebug() << " MATCH added. Stack size was" << currentRules.size();-
274 currentRules.push(&ruleList->last());-
275 delete rule;-
276 break;
executed 4058 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
4058
277 }-
278 case ParseError:
never executed: case ParseError:
0
279 reader.raiseError(QString::fromLatin1("Unexpected element <%1>").-
280 arg(reader.name().toString()));-
281 break;
never executed: break;
0
282 default:
executed 1849 times by 1 test: default:
Executed by:
  • tst_QMimeDatabase
1849
283 break;
executed 1849 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
1849
284 }-
285 break;
executed 153309 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
153309
286 // continue switch QXmlStreamReader::Token...-
287 case QXmlStreamReader::EndElement: // Finished element
executed 19205 times by 1 test: case QXmlStreamReader::EndElement:
Executed by:
  • tst_QMimeDatabase
19205
288 {-
289 const QStringRef elementName = reader.name();-
290 if (elementName == QLatin1String(mimeTypeTagC)) {
elementName ==...(mimeTypeTagC)Description
TRUEevaluated 3319 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 15886 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
3319-15886
291 if (!process(QMimeType(data), errorMessage))
!process(QMime... errorMessage)Description
TRUEnever evaluated
FALSEevaluated 3319 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-3319
292 return false;
never executed: return false;
0
293 data.clear();-
294 } else if (elementName == QLatin1String(matchTagC)) {
executed 3319 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
elementName ==...ing(matchTagC)Description
TRUEevaluated 4058 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 11828 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
3319-11828
295 // Closing a <match> tag, pop stack-
296 currentRules.pop();-
297 //qDebug() << " MATCH closed. Stack size is now" << currentRules.size();-
298 } else if (elementName == QLatin1String(magicTagC)) {
executed 4058 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
elementName ==...ing(magicTagC)Description
TRUEevaluated 1733 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 10095 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
1733-10095
299 //qDebug() << "MAGIC ended, we got" << rules.count() << "rules, with prio" << priority;-
300 // Finished a <magic> sequence-
301 QMimeMagicRuleMatcher ruleMatcher(data.name, priority);-
302 ruleMatcher.addRules(rules);-
303 processMagicMatcher(ruleMatcher);-
304 rules.clear();-
305 }
executed 1733 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1733
306 break;
executed 19205 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
19205
307 }-
308 default:
executed 160899 times by 1 test: default:
Executed by:
  • tst_QMimeDatabase
160899
309 break;
executed 160899 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
160899
310 }-
311 }-
312-
313 if (reader.hasError()) {
reader.hasError()Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-17
314 if (errorMessage)
errorMessageDescription
TRUEnever evaluated
FALSEnever evaluated
0
315 *errorMessage = QString::fromLatin1("An error has been encountered at line %1 of %2: %3:").arg(reader.lineNumber()).arg(fileName, reader.errorString());
never executed: *errorMessage = QString::fromLatin1("An error has been encountered at line %1 of %2: %3:").arg(reader.lineNumber()).arg(fileName, reader.errorString());
0
316 return false;
never executed: return false;
0
317 }-
318-
319 return true;
executed 17 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
17
320#endif //QT_NO_XMLSTREAMREADER-
321}-
322-
323QT_END_NAMESPACE-
324-
325#endif // QT_NO_MIMETYPE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9