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