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
167#if QT_CONFIG(xmlstreamreader)
173 QXmlStreamReader reader(dev);
174 ParseState ps = ParseBeginning;
175 while (!reader.atEnd()) {
176 switch (reader.readNext()) {
177 case QXmlStreamReader::StartElement: {
178 ps = nextState(ps, reader.name());
181 case ParseMimeType: {
183 if (
name.isEmpty()) {
190 case ParseGenericIcon:
196 case ParseGlobPattern: {
211 case ParseGlobDeleteAll:
212 data.globPatterns.clear();
213 data.hasGlobDeleteAll =
true;
215 case ParseSubClass: {
224 const QString comment = reader.readElementText();
225 if (locale.isEmpty())
239 if (!priorityS.isEmpty()) {
244 currentRules.
clear();
248 case ParseMagicMatchRule: {
249 auto result = createMagicMatchRule(atts);
251 qWarning(
"QMimeDatabase: Error parsing %ls\n%ls",
257 ruleList = ¤tRules.
top()->m_subMatches;
260 currentRules.
push(&ruleList->
last());
264 reader.raiseError(
"Unexpected element <"_L1 + reader.name() + u
'>');
272 case QXmlStreamReader::EndElement:
274 const auto elementName = reader.name();
\inmodule QtCore \reentrant
QString errorString() const
Returns a human readable description of the last error that occurred.
bool isEmpty() const noexcept
void append(parameter_type t)
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".
void addRules(const QList< QMimeMagicRule > &rules)
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 QMimeType &t, QString *errorMessage)=0
Overwrite to process the sequence of parsed data.
virtual void processParent(const QString &child, const QString &parent)=0
virtual void processAlias(const QString &alias, const QString &name)=0
T & top()
Returns a reference to the stack's top item.
T pop()
Removes the top item from the stack and returns it.
void push(const T &t)
Adds element t to the top of the stack.
QString toString() const
Returns a deep copy of this string view's data as a QString.
int toInt(bool *ok=nullptr, int base=10) const
Returns the string view converted to an int using base base, which is 10 by default and must be betwe...
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString & insert(qsizetype i, QChar c)
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
Q_CORE_EXPORT QStringView value(QAnyStringView namespaceUri, QAnyStringView name) const noexcept
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[]
GLuint GLuint GLfloat weight
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
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]