32 enum Type { Invalid = 0, String, Host16, Host32, Big16, Big32, Little16, Little32, Byte };
34 QMimeMagicRule(
const QString &typeStr,
const QByteArray &value,
const QString &offsets,
35 const QByteArray &mask, QString *errorString);
37 void swap(QMimeMagicRule &other)
noexcept
39 qSwap(m_type, other.m_type);
40 qSwap(m_value, other.m_value);
41 qSwap(m_startPos, other.m_startPos);
42 qSwap(m_endPos, other.m_endPos);
43 qSwap(m_mask, other.m_mask);
44 qSwap(m_pattern, other.m_pattern);
45 qSwap(m_number, other.m_number);
46 qSwap(m_numberMask, other.m_numberMask);
47 qSwap(m_matchFunction, other.m_matchFunction);
50 bool operator==(
const QMimeMagicRule &other)
const;
52 Type type()
const {
return m_type; }
53 QByteArray value()
const {
return m_value; }
54 int startPos()
const {
return m_startPos; }
55 int endPos()
const {
return m_endPos; }
56 QByteArray mask()
const;
58 bool isValid()
const {
return m_matchFunction !=
nullptr; }
60 bool matches(
const QByteArray &data)
const;
62 QList<QMimeMagicRule> m_subMatches;
64 static Type type(
const QByteArray &type);
65 static QByteArray typeName(Type type);
67 static bool matchSubstring(
const char *dataPtr, qsizetype dataSize, quint64 rangeStart,
68 quint64 rangeLength, quint64 valueLength,
const char *valueData,
82 typedef bool (QMimeMagicRule::*MatchFunction)(
const QByteArray &data)
const;
83 MatchFunction m_matchFunction;
87 bool matchString(
const QByteArray &data)
const;
89 bool matchNumber(
const QByteArray &data)
const;