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#ifndef QMIMEMAGICRULEMATCHER_P_H
5#define QMIMEMAGICRULEMATCHER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qmimemagicrule_p.h"
19
20QT_REQUIRE_CONFIG(mimetype);
21
22#include <QtCore/qbytearray.h>
23#include <QtCore/qlist.h>
24#include <QtCore/qstring.h>
25
26QT_BEGIN_NAMESPACE
27
28class QMimeMagicRuleMatcher
29{
30public:
31 explicit QMimeMagicRuleMatcher(const QString &mime, unsigned priority = 65535);
32
33 void swap(QMimeMagicRuleMatcher &other) noexcept
34 {
35 qSwap(value1&: m_list, value2&: other.m_list);
36 qSwap(value1&: m_priority, value2&: other.m_priority);
37 qSwap(value1&: m_mimetype, value2&: other.m_mimetype);
38 }
39
40 bool operator==(const QMimeMagicRuleMatcher &other) const;
41
42 void addRule(const QMimeMagicRule &rule);
43 void addRules(const QList<QMimeMagicRule> &rules);
44 QList<QMimeMagicRule> magicRules() const;
45
46 bool matches(const QByteArray &data) const;
47
48 unsigned priority() const;
49
50 QString mimetype() const { return m_mimetype; }
51
52private:
53 QList<QMimeMagicRule> m_list;
54 unsigned m_priority;
55 QString m_mimetype;
56};
57Q_DECLARE_SHARED(QMimeMagicRuleMatcher)
58
59QT_END_NAMESPACE
60
61#endif // QMIMEMAGICRULEMATCHER_P_H
62

source code of qtbase/src/corelib/mimetypes/qmimemagicrulematcher_p.h