mimetypes: Declare some types as shared

It's private API, so we can.

As a consequence, had to add nothrow member-swap and, in
QMimeGlobPattern, remove the user-defined empty destructor
to un-inhibit the (nothrow) move special member functions.

Change-Id: If5bb72db3c823c7b0e372f9bec99c7242d11839b
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
bb10
Marc Mutz 2015-07-25 12:25:15 +02:00
parent 773458ad63
commit de8229f370
3 changed files with 31 additions and 2 deletions

View File

@ -88,7 +88,14 @@ public:
m_pattern = m_pattern.toLower();
}
}
~QMimeGlobPattern() {}
void swap(QMimeGlobPattern &other) Q_DECL_NOTHROW
{
qSwap(m_pattern, other.m_pattern);
qSwap(m_mimeType, other.m_mimeType);
qSwap(m_weight, other.m_weight);
qSwap(m_caseSensitivity, other.m_caseSensitivity);
}
bool matchFileName(const QString &filename) const;
@ -103,6 +110,7 @@ private:
int m_weight;
Qt::CaseSensitivity m_caseSensitivity;
};
Q_DECLARE_SHARED(QMimeGlobPattern)
class QMimeGlobPatternList : public QList<QMimeGlobPattern>
{

View File

@ -69,6 +69,19 @@ public:
QMimeMagicRule(const QString &typeStr, const QByteArray &value, const QString &offsets,
const QByteArray &mask, QString *errorString);
void swap(QMimeMagicRule &other) Q_DECL_NOTHROW
{
qSwap(m_type, other.m_type);
qSwap(m_value, other.m_value);
qSwap(m_startPos, other.m_startPos);
qSwap(m_endPos, other.m_endPos);
qSwap(m_mask, other.m_mask);
qSwap(m_pattern, other.m_pattern);
qSwap(m_number, other.m_number);
qSwap(m_numberMask, other.m_numberMask);
qSwap(m_matchFunction, other.m_matchFunction);
}
bool operator==(const QMimeMagicRule &other) const;
Type type() const { return m_type; }
@ -108,7 +121,7 @@ private:
template <typename T>
bool matchNumber(const QByteArray &data) const;
};
Q_DECLARE_TYPEINFO(QMimeMagicRule, Q_MOVABLE_TYPE);
Q_DECLARE_SHARED(QMimeMagicRule)
QT_END_NAMESPACE

View File

@ -66,6 +66,13 @@ class QMimeMagicRuleMatcher
public:
explicit QMimeMagicRuleMatcher(const QString &mime, unsigned priority = 65535);
void swap(QMimeMagicRuleMatcher &other) Q_DECL_NOTHROW
{
qSwap(m_list, other.m_list);
qSwap(m_priority, other.m_priority);
qSwap(m_mimetype, other.m_mimetype);
}
bool operator==(const QMimeMagicRuleMatcher &other) const;
void addRule(const QMimeMagicRule &rule);
@ -83,6 +90,7 @@ private:
unsigned m_priority;
QString m_mimetype;
};
Q_DECLARE_SHARED(QMimeMagicRuleMatcher)
QT_END_NAMESPACE