Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qmimemagicrule_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
4#ifndef QMIMEMAGICRULE_P_H
5#define QMIMEMAGICRULE_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 <QtCore/private/qglobal_p.h>
19
21
22#include <QtCore/qbytearray.h>
23#include <QtCore/qscopedpointer.h>
24#include <QtCore/qlist.h>
25
27
29{
30public:
32
34 const QByteArray &mask, QString *errorString);
35
36 void swap(QMimeMagicRule &other) noexcept
37 {
38 qSwap(m_type, other.m_type);
39 qSwap(m_value, other.m_value);
40 qSwap(m_startPos, other.m_startPos);
41 qSwap(m_endPos, other.m_endPos);
42 qSwap(m_mask, other.m_mask);
43 qSwap(m_pattern, other.m_pattern);
44 qSwap(m_number, other.m_number);
45 qSwap(m_numberMask, other.m_numberMask);
46 qSwap(m_matchFunction, other.m_matchFunction);
47 }
48
49 bool operator==(const QMimeMagicRule &other) const;
50
51 Type type() const { return m_type; }
52 QByteArray value() const { return m_value; }
53 int startPos() const { return m_startPos; }
54 int endPos() const { return m_endPos; }
55 QByteArray mask() const;
56
57 bool isValid() const { return m_matchFunction != nullptr; }
58
59 bool matches(const QByteArray &data) const;
60
61 QList<QMimeMagicRule> m_subMatches;
62
63 static Type type(const QByteArray &type);
65
66 static bool matchSubstring(const char *dataPtr, qsizetype dataSize, int rangeStart,
67 int rangeLength, qsizetype valueLength, const char *valueData,
68 const char *mask);
69
70private:
71 Type m_type;
72 QByteArray m_value;
73 int m_startPos;
74 int m_endPos;
75 QByteArray m_mask;
76
77 QByteArray m_pattern;
78 quint32 m_number;
79 quint32 m_numberMask;
80
81 typedef bool (QMimeMagicRule::*MatchFunction)(const QByteArray &data) const;
82 MatchFunction m_matchFunction;
83
84private:
85 // match functions
86 bool matchString(const QByteArray &data) const;
87 template <typename T>
88 bool matchNumber(const QByteArray &data) const;
89};
90Q_DECLARE_SHARED(QMimeMagicRule)
91
93
94#endif // QMIMEMAGICRULE_H
\inmodule QtCore
Definition qbytearray.h:57
int startPos() const
QByteArray mask() const
QList< QMimeMagicRule > m_subMatches
void swap(QMimeMagicRule &other) noexcept
bool isValid() const
static bool matchSubstring(const char *dataPtr, qsizetype dataSize, int rangeStart, int rangeLength, qsizetype valueLength, const char *valueData, const char *mask)
bool matches(const QByteArray &data) const
Type type() const
bool operator==(const QMimeMagicRule &other) const
int endPos() const
QByteArray value() const
QMimeMagicRule(const QString &typeStr, const QByteArray &value, const QString &offsets, const QByteArray &mask, QString *errorString)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
const char * typeName
GLenum GLsizei dataSize
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLuint GLsizei const GLuint const GLintptr * offsets
static QLatin1StringView typeStr(QShaderDescription::VariableType t)
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
Definition qswap.h:20
#define QT_REQUIRE_CONFIG(feature)
unsigned int quint32
Definition qtypes.h:50
ptrdiff_t qsizetype
Definition qtypes.h:165
QSharedPointer< T > other(t)
[5]
Definition moc.h:23