diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2017-02-23 13:40:30 +0100 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2017-02-24 21:16:09 +0000 |
commit | 14db1d5560254766746446069b6f2456e4444602 (patch) | |
tree | 55db7f088a5f205944865e8177d536071a2d9b5d /src/network/access/qhstspolicy.h | |
parent | e6d23860f08f59caa131bae8ca90f9e36e4dc033 (diff) |
HSTS policy - fix API
API-review follow-up:
1. make a ctor explicit
2. add swap member-function
3. make move-assignment inlined
4. make comparison operators non-members
5. make d_ptr QSharedDataPointer (and private implementation - QSharedData).
Change-Id: I3257ca03cccd0f1254c9b95461752911359352a5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/access/qhstspolicy.h')
-rw-r--r-- | src/network/access/qhstspolicy.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/network/access/qhstspolicy.h b/src/network/access/qhstspolicy.h index 4260ac278c..45fa40dfe8 100644 --- a/src/network/access/qhstspolicy.h +++ b/src/network/access/qhstspolicy.h @@ -42,7 +42,7 @@ #include <QtNetwork/qtnetworkglobal.h> -#include <QtCore/qscopedpointer.h> +#include <QtCore/qshareddata.h> #include <QtCore/qurl.h> QT_BEGIN_NAMESPACE @@ -55,13 +55,15 @@ class Q_NETWORK_EXPORT QHstsPolicy public: QHstsPolicy(); - QHstsPolicy(const QDateTime &expiry, bool includeSubDomains, const QString &host, - QUrl::ParsingMode mode = QUrl::DecodedMode); + explicit QHstsPolicy(const QDateTime &expiry, bool includeSubDomains, const QString &host, + QUrl::ParsingMode mode = QUrl::DecodedMode); QHstsPolicy(const QHstsPolicy &rhs); QHstsPolicy &operator=(const QHstsPolicy &rhs); - QHstsPolicy &operator=(QHstsPolicy &&rhs) Q_DECL_NOTHROW; + QHstsPolicy &operator=(QHstsPolicy &&other) Q_DECL_NOTHROW { swap(other); return *this; } ~QHstsPolicy(); + void swap(QHstsPolicy &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void setHost(const QString &host, QUrl::ParsingMode mode = QUrl::DecodedMode); QString host(QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const; void setExpiry(const QDateTime &expiry); @@ -69,14 +71,25 @@ public: void setIncludesSubDomains(bool include); bool includesSubDomains() const; - bool operator==(const QHstsPolicy &rhs) const; bool isExpired() const; private: - QScopedPointer<QHstsPolicyPrivate> d; + QSharedDataPointer<QHstsPolicyPrivate> d; + + friend Q_NETWORK_EXPORT bool operator==(const QHstsPolicy &lhs, const QHstsPolicy &rhs); }; +Q_DECLARE_SHARED(QHstsPolicy) + +Q_NETWORK_EXPORT bool operator==(const QHstsPolicy &lhs, const QHstsPolicy &rhs); + +inline bool operator!=(const QHstsPolicy &lhs, const QHstsPolicy &rhs) +{ + return !(lhs == rhs); +} + + QT_END_NAMESPACE #endif // QHSTSPOLICY_H |