32 enum Type { Invalid = 0, String, Host16, Host32, Big16, Big32, Little16, Little32, Byte };
37 static constexpr int MaxRecursionDepth = 50;
39 QMimeMagicRule(
const QString &typeStr,
const QByteArray &value,
const QString &offsets,
40 const QByteArray &mask, QString *errorString);
42 void swap(QMimeMagicRule &other)
noexcept
44 qSwap(m_type, other.m_type);
45 qSwap(m_value, other.m_value);
46 qSwap(m_startPos, other.m_startPos);
47 qSwap(m_endPos, other.m_endPos);
48 qSwap(m_mask, other.m_mask);
49 qSwap(m_pattern, other.m_pattern);
50 qSwap(m_number, other.m_number);
51 qSwap(m_numberMask, other.m_numberMask);
52 qSwap(m_matchFunction, other.m_matchFunction);
55 bool operator==(
const QMimeMagicRule &other)
const;
57 Type type()
const {
return m_type; }
58 QByteArray value()
const {
return m_value; }
59 int startPos()
const {
return m_startPos; }
60 int endPos()
const {
return m_endPos; }
61 QByteArray mask()
const;
63 bool isValid()
const {
return m_matchFunction !=
nullptr; }
65 bool matches(
const QByteArray &data,
int depth = MaxRecursionDepth)
const;
67 QList<QMimeMagicRule> m_subMatches;
69 static Type type(
const QByteArray &type);
70 static QByteArray typeName(Type type);
72 static bool matchSubstring(
const char *dataPtr, qsizetype dataSize, quint64 rangeStart,
73 quint64 rangeLength, quint64 valueLength,
const char *valueData,
87 typedef bool (QMimeMagicRule::*MatchFunction)(
const QByteArray &data)
const;
88 MatchFunction m_matchFunction;
92 bool matchString(
const QByteArray &data)
const;
94 bool matchNumber(
const QByteArray &data)
const;