From de8229f37054b195bab4ca8e8a994832a60ae3a0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 25 Jul 2015 12:25:15 +0200 Subject: 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 Reviewed-by: Lars Knoll --- src/corelib/mimetypes/qmimeglobpattern_p.h | 10 +++++++++- src/corelib/mimetypes/qmimemagicrule_p.h | 15 ++++++++++++++- src/corelib/mimetypes/qmimemagicrulematcher_p.h | 8 ++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) (limited to 'src/corelib/mimetypes') diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h index 0088931b5c..7b4ecd2f6a 100644 --- a/src/corelib/mimetypes/qmimeglobpattern_p.h +++ b/src/corelib/mimetypes/qmimeglobpattern_p.h @@ -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 { diff --git a/src/corelib/mimetypes/qmimemagicrule_p.h b/src/corelib/mimetypes/qmimemagicrule_p.h index 1a6ca81e11..26f93d96cc 100644 --- a/src/corelib/mimetypes/qmimemagicrule_p.h +++ b/src/corelib/mimetypes/qmimemagicrule_p.h @@ -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 bool matchNumber(const QByteArray &data) const; }; -Q_DECLARE_TYPEINFO(QMimeMagicRule, Q_MOVABLE_TYPE); +Q_DECLARE_SHARED(QMimeMagicRule) QT_END_NAMESPACE diff --git a/src/corelib/mimetypes/qmimemagicrulematcher_p.h b/src/corelib/mimetypes/qmimemagicrulematcher_p.h index b2e171ec1f..5e3d5306c0 100644 --- a/src/corelib/mimetypes/qmimemagicrulematcher_p.h +++ b/src/corelib/mimetypes/qmimemagicrulematcher_p.h @@ -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 -- cgit v1.2.3