Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qmimemagicrulematcher.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
define
QT_NO_CAST_FROM_ASCII
5
6
#
include
"qmimemagicrulematcher_p.h"
7
8
#
include
"qmimetype_p.h"
9
10
QT_BEGIN_NAMESPACE
11
12
/*!
13
\internal
14
\class QMimeMagicRuleMatcher
15
\inmodule QtCore
16
17
\brief The QMimeMagicRuleMatcher class checks a number of rules based on operator "or".
18
19
It is used for rules parsed from XML files.
20
21
\sa QMimeType, QMimeDatabase, MagicRule, MagicStringRule, MagicByteRule, GlobPattern
22
\sa QMimeTypeParserBase, MimeTypeParser
23
*/
24
25
QMimeMagicRuleMatcher::QMimeMagicRuleMatcher(
const
QString &mime,
unsigned
thePriority) :
26
m_list(),
27
m_priority(thePriority),
28
m_mimetype(mime)
29
{
30
}
31
32
bool
QMimeMagicRuleMatcher::operator==(
const
QMimeMagicRuleMatcher &other)
const
33
{
34
return
m_list == other.m_list &&
35
m_priority == other.m_priority;
36
}
37
38
void
QMimeMagicRuleMatcher::addRule(
const
QMimeMagicRule &rule)
39
{
40
m_list.append(rule);
41
}
42
43
void
QMimeMagicRuleMatcher::addRules(
const
QList<QMimeMagicRule> &rules)
44
{
45
m_list.append(rules);
46
}
47
48
QList<QMimeMagicRule> QMimeMagicRuleMatcher::magicRules()
const
49
{
50
return
m_list;
51
}
52
53
// Check for a match on contents of a file
54
bool
QMimeMagicRuleMatcher::matches(
const
QByteArray &data)
const
55
{
56
for
(
const
QMimeMagicRule &magicRule : m_list) {
57
if
(magicRule.matches(data))
58
return
true
;
59
}
60
61
return
false
;
62
}
63
64
// Return a priority value from 1..100
65
unsigned
QMimeMagicRuleMatcher::priority()
const
66
{
67
return
m_priority;
68
}
69
70
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
qtbase
src
corelib
mimetypes
qmimemagicrulematcher.cpp
Generated on Mon Mar 10 2025 00:39:49 for Qt by
1.13.2