4#define QT_NO_CAST_FROM_ASCII
11#include <QtCore/QCoreApplication>
12#include <QtCore/QDebug>
14#include <QtCore/QXmlStreamReader>
15#include <QtCore/QXmlStreamWriter>
16#include <QtCore/QStack>
77QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState currentState,
QStringView startElement)
79 switch (currentState) {
90 case ParseGenericIcon:
92 case ParseGlobPattern:
93 case ParseGlobDeleteAll:
96 case ParseOtherMimeTypeSubTag:
97 case ParseMagicMatchRule:
103 return ParseGenericIcon;
107 return ParseGlobPattern;
109 return ParseGlobDeleteAll;
111 return ParseSubClass;
117 return ParseMagicMatchRule;
118 return ParseOtherMimeTypeSubTag;
121 return ParseMagicMatchRule;
142#if QT_CONFIG(xmlstreamreader)
143struct CreateMagicMatchRuleResult
155static CreateMagicMatchRuleResult createMagicMatchRule(
const QXmlStreamAttributes &atts)
167#if QT_CONFIG(xmlstreamreader)
170 QStack<QMimeMagicRule *> currentRules;
171 QList<QMimeMagicRule> rules;
172 QXmlStreamReader reader(dev);
173 ParseState ps = ParseBeginning;
174 while (!reader.atEnd()) {
175 switch (reader.readNext()) {
176 case QXmlStreamReader::StartElement: {
177 ps = nextState(ps, reader.name());
178 const QXmlStreamAttributes atts = reader.attributes();
180 case ParseMimeType: {
182 if (
name.isEmpty()) {
189 case ParseGenericIcon:
195 case ParseGlobPattern: {
210 case ParseGlobDeleteAll:
211 data.globPatterns.clear();
212 data.hasGlobDeleteAll =
true;
214 case ParseSubClass: {
216 if (!inheritsFrom.isEmpty())
223 const QString comment = reader.readElementText();
224 if (locale.isEmpty())
226 data.localeComments.insert(locale, comment);
238 if (!priorityS.isEmpty()) {
243 currentRules.clear();
247 case ParseMagicMatchRule: {
248 auto result = createMagicMatchRule(atts);
250 qWarning(
"QMimeDatabase: Error parsing %ls\n%ls",
252 QList<QMimeMagicRule> *ruleList;
253 if (currentRules.isEmpty())
256 ruleList = ¤tRules.top()->m_subMatches;
257 ruleList->append(std::move(
result.rule));
259 currentRules.push(&ruleList->last());
263 reader.raiseError(
"Unexpected element <"_L1 + reader.name() + u
'>');
271 case QXmlStreamReader::EndElement:
273 const auto elementName = reader.name();
286 ruleMatcher.addRules(rules);
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
\inmodule QtCore \reentrant
QString errorString() const
Returns a human readable description of the last error that occurred.
The QMimeGlobPattern class contains the glob pattern for file names for MIME type matching.
static const unsigned DefaultWeight
The QMimeMagicRuleMatcher class checks a number of rules based on operator "or".
virtual void processMagicMatcher(const QMimeMagicRuleMatcher &matcher)=0
static bool parseNumber(QStringView n, int *target, QString *errorMessage)
bool parse(QIODevice *dev, const QString &fileName, QString *errorMessage)
virtual bool process(const QMimeTypeXMLData &t, QString *errorMessage)=0
virtual void processParent(const QString &child, const QString &parent)=0
virtual void processAlias(const QString &alias, const QString &name)=0
QMimeTypePrivate::LocaleHash localeComments
void addGlobPattern(const QString &pattern)
\macro QT_RESTRICTED_CAST_FROM_ASCII
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void clear()
Clears the contents of the string and makes it null.
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
Combined button and popup list for selecting options.
DBusConnection const char * rule
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static const char nameAttributeC[]
static const char localeAttributeC[]
static const char mimeTypeAttributeC[]
static const char mimeTypeTagC[]
static const char globDeleteAllTagC[]
static const char patternAttributeC[]
static const char matchTagC[]
static const char matchTypeAttributeC[]
static const char matchValueAttributeC[]
static const char magicTagC[]
static const char matchOffsetAttributeC[]
static const char caseSensitiveAttributeC[]
static const char commentTagC[]
static const char globTagC[]
static const char iconTagC[]
static const char genericIconTagC[]
static const char aliasTagC[]
static const char weightAttributeC[]
static const char subClassTagC[]
static const char matchMaskAttributeC[]
static const char mimeInfoTagC[]
static const char priorityAttributeC[]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint GLuint GLfloat weight
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLuint GLsizei const GLuint const GLintptr * offsets
#define qUtf16Printable(string)
#define QStringLiteral(str)
static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &errorSource, qsizetype errorPosition)
char * toString(const MyType &t)
[31]