summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-30 14:23:27 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-30 17:27:29 +0100
commit57e57d9bcda868abcfb552e1247b391162c0dff9 (patch)
tree7752a32e796d74c8d01a447d1d7376a02cbf7fcc /src/network
parentd51d312c86128150283b6a41f0daac18d9e57f32 (diff)
Hide comparison operators for QtNetwork value types from non-ADL
Make them hidden friends, add a private isEqual helper where needed. Adjust and add documentation. Fixes: QTBUG-87976 Change-Id: If7c19eeab5be7452364eb76193981100f5516d6b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhstspolicy.cpp21
-rw-r--r--src/network/access/qhstspolicy.h13
-rw-r--r--src/network/access/qhttp2configuration.cpp23
-rw-r--r--src/network/access/qhttp2configuration.h18
-rw-r--r--src/network/ssl/qocspresponse.cpp28
-rw-r--r--src/network/ssl/qocspresponse.h9
-rw-r--r--src/network/ssl/qssldiffiehellmanparameters.cpp17
-rw-r--r--src/network/ssl/qssldiffiehellmanparameters.h39
-rw-r--r--src/network/ssl/qsslellipticcurve.cpp6
-rw-r--r--src/network/ssl/qsslellipticcurve.h11
-rw-r--r--src/network/ssl/qsslpresharedkeyauthenticator.cpp31
-rw-r--r--src/network/ssl/qsslpresharedkeyauthenticator.h12
12 files changed, 130 insertions, 98 deletions
diff --git a/src/network/access/qhstspolicy.cpp b/src/network/access/qhstspolicy.cpp
index 46c9c22510..3d15cba407 100644
--- a/src/network/access/qhstspolicy.cpp
+++ b/src/network/access/qhstspolicy.cpp
@@ -86,12 +86,25 @@ public:
};
/*!
- Returns \c true if the two policies have the same host and expiration date
- while agreeing on whether to include or exclude subdomains.
+ \fn bool QHstsPolicy::operator==(const QHstsPolicy &lhs, const QHstsPolicy &rhs)
+
+ Returns \c true if the two policies \a lhs and \a rhs have the same host and
+ expiration date while agreeing on whether to include or exclude subdomains.
+*/
+
+/*!
+ \fn bool QHstsPolicy::operator!=(const QHstsPolicy &lhs, const QHstsPolicy &rhs)
+
+ Returns \c true if the two policies \a lhs and \a rhs do not have the same host
+ or expiration date, or do not agree on whether to include or exclude subdomains.
+*/
+
+/*!
+ \internal
*/
-bool operator==(const QHstsPolicy &lhs, const QHstsPolicy &rhs)
+bool QHstsPolicy::isEqual(const QHstsPolicy &other) const
{
- return *lhs.d == *rhs.d;
+ return *d == *other.d;
}
/*!
diff --git a/src/network/access/qhstspolicy.h b/src/network/access/qhstspolicy.h
index f1b2ee99e5..0cf0c73f9c 100644
--- a/src/network/access/qhstspolicy.h
+++ b/src/network/access/qhstspolicy.h
@@ -80,21 +80,18 @@ public:
bool isExpired() const;
private:
-
QSharedDataPointer<QHstsPolicyPrivate> d;
- friend Q_NETWORK_EXPORT bool operator==(const QHstsPolicy &lhs, const QHstsPolicy &rhs);
+ bool isEqual(const QHstsPolicy &other) const;
+ friend bool operator==(const QHstsPolicy &lhs, const QHstsPolicy &rhs)
+ { return lhs.isEqual(rhs); }
+ friend bool operator!=(const QHstsPolicy &lhs, const QHstsPolicy &rhs)
+ { return !lhs.isEqual(rhs); }
};
Q_DECLARE_SHARED(QHstsPolicy)
Q_DECLARE_OPERATORS_FOR_FLAGS(QHstsPolicy::PolicyFlags)
-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
diff --git a/src/network/access/qhttp2configuration.cpp b/src/network/access/qhttp2configuration.cpp
index 408f141e77..c9eba3e8fd 100644
--- a/src/network/access/qhttp2configuration.cpp
+++ b/src/network/access/qhttp2configuration.cpp
@@ -301,18 +301,29 @@ void QHttp2Configuration::swap(QHttp2Configuration &other) noexcept
}
/*!
+ \fn bool QHttp2Configuration::operator==(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs) noexcept
Returns \c true if \a lhs and \a rhs have the same set of HTTP/2
parameters.
*/
-bool operator==(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs)
+
+/*!
+ \fn bool QHttp2Configuration::operator!=(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs) noexcept
+ Returns \c true if \a lhs and \a rhs do not have the same set of HTTP/2
+ parameters.
+*/
+
+/*!
+ \internal
+*/
+bool QHttp2Configuration::isEqual(const QHttp2Configuration &other) const noexcept
{
- if (lhs.d == rhs.d)
+ if (d == other.d)
return true;
- return lhs.d->pushEnabled == rhs.d->pushEnabled
- && lhs.d->huffmanCompressionEnabled == rhs.d->huffmanCompressionEnabled
- && lhs.d->sessionWindowSize == rhs.d->sessionWindowSize
- && lhs.d->streamWindowSize == rhs.d->streamWindowSize;
+ return d->pushEnabled == other.d->pushEnabled
+ && d->huffmanCompressionEnabled == other.d->huffmanCompressionEnabled
+ && d->sessionWindowSize == other.d->sessionWindowSize
+ && d->streamWindowSize == other.d->streamWindowSize;
}
QT_END_NAMESPACE
diff --git a/src/network/access/qhttp2configuration.h b/src/network/access/qhttp2configuration.h
index e5c235e2be..3d8ba771b4 100644
--- a/src/network/access/qhttp2configuration.h
+++ b/src/network/access/qhttp2configuration.h
@@ -53,8 +53,6 @@ QT_BEGIN_NAMESPACE
class QHttp2ConfigurationPrivate;
class Q_NETWORK_EXPORT QHttp2Configuration
{
- friend Q_NETWORK_EXPORT bool operator==(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs);
-
public:
QHttp2Configuration();
QHttp2Configuration(const QHttp2Configuration &other);
@@ -82,18 +80,18 @@ public:
void swap(QHttp2Configuration &other) noexcept;
private:
-
QSharedDataPointer<QHttp2ConfigurationPrivate> d;
-};
-Q_DECLARE_SHARED(QHttp2Configuration)
+ bool isEqual(const QHttp2Configuration &other) const noexcept;
-Q_NETWORK_EXPORT bool operator==(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs);
+ friend bool operator==(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs) noexcept
+ { return lhs.isEqual(rhs); }
+ friend bool operator!=(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs) noexcept
+ { return !lhs.isEqual(rhs); }
-inline bool operator!=(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs)
-{
- return !(lhs == rhs);
-}
+};
+
+Q_DECLARE_SHARED(QHttp2Configuration)
QT_END_NAMESPACE
diff --git a/src/network/ssl/qocspresponse.cpp b/src/network/ssl/qocspresponse.cpp
index ab046b74c1..b63312506d 100644
--- a/src/network/ssl/qocspresponse.cpp
+++ b/src/network/ssl/qocspresponse.cpp
@@ -206,30 +206,32 @@ QSslCertificate QOcspResponse::subject() const
}
/*!
- \fn bool operator==(const QOcspResponse &lhs, const QOcspResponse &rhs)
+ \fn bool QOcspResponse::operator==(const QOcspResponse &lhs, const QOcspResponse &rhs)
Returns \c true if \a lhs and \a rhs are the responses for the same
certificate, signed by the same responder, have the same
revocation reason and the same certificate status.
\since 5.13
- \relates QOcspResponse
- */
-Q_NETWORK_EXPORT bool operator==(const QOcspResponse &lhs, const QOcspResponse &rhs)
-{
- return lhs.d == rhs.d || *lhs.d == *rhs.d;
-}
+*/
/*!
- \fn bool operator != (const QOcspResponse &lhs, const QOcspResponse &rhs)
+ \fn bool QOcspResponse::operator!=(const QOcspResponse &lhs, const QOcspResponse &rhs)
+
+ Returns \c true if \a lhs and \a rhs are responses for different certificates,
+ or signed by different responders, or have different revocation reasons, or different
+ certificate statuses.
- Returns \c true if \a lhs and \a rhs are responses for different certificates,
- or signed by different responders, or have different revocation reasons, or different
- certificate statuses.
+ \since 5.13
+*/
- \since 5.13
- \relates QOcspResponse
+/*!
+ \internal
*/
+bool QOcspResponse::isEqual(const QOcspResponse &other) const
+{
+ return d == other.d || *d == *other.d;
+}
/*!
\fn size_t qHash(const QOcspResponse &response, size_t seed)
diff --git a/src/network/ssl/qocspresponse.h b/src/network/ssl/qocspresponse.h
index 1fc3377d58..8f184924c7 100644
--- a/src/network/ssl/qocspresponse.h
+++ b/src/network/ssl/qocspresponse.h
@@ -97,16 +97,19 @@ public:
void swap(QOcspResponse &other) noexcept { d.swap(other.d); }
private:
+ bool isEqual(const QOcspResponse &other) const;
friend class QSslSocketBackendPrivate;
- friend Q_NETWORK_EXPORT bool operator==(const QOcspResponse &lhs, const QOcspResponse &rhs);
+ friend bool operator==(const QOcspResponse &lhs, const QOcspResponse &rhs)
+ { return lhs.isEqual(rhs); }
+ friend bool operator!=(const QOcspResponse &lhs, const QOcspResponse &rhs)
+ { return !lhs.isEqual(rhs); }
+
friend Q_NETWORK_EXPORT size_t qHash(const QOcspResponse &response, size_t seed) noexcept;
QSharedDataPointer<QOcspResponsePrivate> d;
};
-inline bool operator!=(const QOcspResponse &lhs, const QOcspResponse &rhs) { return !(lhs == rhs); }
-
Q_DECLARE_SHARED(QOcspResponse)
QT_END_NAMESPACE
diff --git a/src/network/ssl/qssldiffiehellmanparameters.cpp b/src/network/ssl/qssldiffiehellmanparameters.cpp
index c8f3e564a5..e5574b2e09 100644
--- a/src/network/ssl/qssldiffiehellmanparameters.cpp
+++ b/src/network/ssl/qssldiffiehellmanparameters.cpp
@@ -278,14 +278,25 @@ QString QSslDiffieHellmanParameters::errorString() const noexcept
}
/*!
+ \fn bool QSslDiffieHellmanParameters::operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept
\since 5.8
- \relates QSslDiffieHellmanParameters
Returns \c true if \a lhs is equal to \a rhs; otherwise returns \c false.
*/
-bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept
+
+/*!
+ \fn bool QSslDiffieHellmanParameters::operator!=(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept
+ \since 5.8
+
+ Returns \c true if \a lhs is not equal to \a rhs; otherwise returns \c false.
+*/
+
+/*!
+ \internal
+*/
+bool QSslDiffieHellmanParameters::isEqual(const QSslDiffieHellmanParameters &other) const noexcept
{
- return lhs.d->derData == rhs.d->derData;
+ return d->derData == other.d->derData;
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/network/ssl/qssldiffiehellmanparameters.h b/src/network/ssl/qssldiffiehellmanparameters.h
index 6a3cf01ddc..c65697796b 100644
--- a/src/network/ssl/qssldiffiehellmanparameters.h
+++ b/src/network/ssl/qssldiffiehellmanparameters.h
@@ -63,14 +63,7 @@ class QDebug;
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparams);
#endif
-Q_NETWORK_EXPORT bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept;
-
-inline bool operator!=(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept
-{
- return !operator==(lhs, rhs);
-}
-
-class QSslDiffieHellmanParameters
+class Q_NETWORK_EXPORT QSslDiffieHellmanParameters
{
public:
enum Error {
@@ -79,30 +72,36 @@ public:
UnsafeParametersError
};
- Q_NETWORK_EXPORT static QSslDiffieHellmanParameters defaultParameters();
+ static QSslDiffieHellmanParameters defaultParameters();
- Q_NETWORK_EXPORT QSslDiffieHellmanParameters();
- Q_NETWORK_EXPORT QSslDiffieHellmanParameters(const QSslDiffieHellmanParameters &other);
+ QSslDiffieHellmanParameters();
+ QSslDiffieHellmanParameters(const QSslDiffieHellmanParameters &other);
QSslDiffieHellmanParameters(QSslDiffieHellmanParameters &&other) noexcept : d(other.d) { other.d = nullptr; }
- Q_NETWORK_EXPORT ~QSslDiffieHellmanParameters();
+ ~QSslDiffieHellmanParameters();
- Q_NETWORK_EXPORT QSslDiffieHellmanParameters &operator=(const QSslDiffieHellmanParameters &other);
+ QSslDiffieHellmanParameters &operator=(const QSslDiffieHellmanParameters &other);
QSslDiffieHellmanParameters &operator=(QSslDiffieHellmanParameters &&other) noexcept { swap(other); return *this; }
void swap(QSslDiffieHellmanParameters &other) noexcept { qSwap(d, other.d); }
- Q_NETWORK_EXPORT static QSslDiffieHellmanParameters fromEncoded(const QByteArray &encoded, QSsl::EncodingFormat format = QSsl::Pem);
- Q_NETWORK_EXPORT static QSslDiffieHellmanParameters fromEncoded(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
+ static QSslDiffieHellmanParameters fromEncoded(const QByteArray &encoded, QSsl::EncodingFormat format = QSsl::Pem);
+ static QSslDiffieHellmanParameters fromEncoded(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
- Q_NETWORK_EXPORT bool isEmpty() const noexcept;
- Q_NETWORK_EXPORT bool isValid() const noexcept;
- Q_NETWORK_EXPORT Error error() const noexcept;
- Q_NETWORK_EXPORT QString errorString() const noexcept;
+ bool isEmpty() const noexcept;
+ bool isValid() const noexcept;
+ Error error() const noexcept;
+ QString errorString() const noexcept;
private:
QSslDiffieHellmanParametersPrivate *d;
friend class QSslContext;
- friend Q_NETWORK_EXPORT bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept;
+
+ bool isEqual(const QSslDiffieHellmanParameters &other) const noexcept;
+ friend bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept
+ { return lhs.isEqual(rhs); }
+ friend bool operator!=(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept
+ { return !lhs.isEqual(rhs); }
+
#ifndef QT_NO_DEBUG_STREAM
friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam);
#endif
diff --git a/src/network/ssl/qsslellipticcurve.cpp b/src/network/ssl/qsslellipticcurve.cpp
index f7faa607bd..6bc5ee6286 100644
--- a/src/network/ssl/qsslellipticcurve.cpp
+++ b/src/network/ssl/qsslellipticcurve.cpp
@@ -139,17 +139,15 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs)
+ \fn bool QSslEllipticCurve::operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs)
\since 5.5
- \relates QSslEllipticCurve
Returns true if the curve \a lhs represents the same curve of \a rhs;
*/
/*!
- \fn bool operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs)
+ \fn bool QSslEllipticCurve::operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs)
\since 5.5
- \relates QSslEllipticCurve
Returns true if the curve \a lhs represents a different curve than \a rhs;
false otherwise.
diff --git a/src/network/ssl/qsslellipticcurve.h b/src/network/ssl/qsslellipticcurve.h
index 37f77bde68..2906891fdc 100644
--- a/src/network/ssl/qsslellipticcurve.h
+++ b/src/network/ssl/qsslellipticcurve.h
@@ -74,7 +74,10 @@ public:
private:
int id;
- friend constexpr bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept;
+ friend constexpr bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept
+ { return lhs.id == rhs.id; }
+ friend constexpr bool operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept
+ { return !(lhs == rhs); }
friend constexpr size_t qHash(QSslEllipticCurve curve, size_t seed) noexcept;
friend class QSslContext;
@@ -87,12 +90,6 @@ Q_DECLARE_TYPEINFO(QSslEllipticCurve, Q_PRIMITIVE_TYPE);
constexpr inline size_t qHash(QSslEllipticCurve curve, size_t seed) noexcept
{ return qHash(curve.id, seed); }
-constexpr inline bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept
-{ return lhs.id == rhs.id; }
-
-constexpr inline bool operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept
-{ return !operator==(lhs, rhs); }
-
#ifndef QT_NO_DEBUG_STREAM
class QDebug;
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, QSslEllipticCurve curve);
diff --git a/src/network/ssl/qsslpresharedkeyauthenticator.cpp b/src/network/ssl/qsslpresharedkeyauthenticator.cpp
index abb3f3c45c..fe797ef883 100644
--- a/src/network/ssl/qsslpresharedkeyauthenticator.cpp
+++ b/src/network/ssl/qsslpresharedkeyauthenticator.cpp
@@ -240,7 +240,7 @@ int QSslPreSharedKeyAuthenticator::maximumPreSharedKeyLength() const
}
/*!
- \fn QSslPreSharedKeyAuthenticator::operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
+ \fn bool QSslPreSharedKeyAuthenticator::operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
\since 5.5
Returns \c true if the authenticator object \a lhs is equal to \a rhs;
@@ -249,26 +249,27 @@ int QSslPreSharedKeyAuthenticator::maximumPreSharedKeyLength() const
Two authenticator objects are equal if and only if they have the same
identity hint, identity, pre shared key, maximum length for the identity
and maximum length for the pre shared key.
-
*/
-bool operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
-{
- return ((lhs.d == rhs.d) ||
- (lhs.d->identityHint == rhs.d->identityHint &&
- lhs.d->identity == rhs.d->identity &&
- lhs.d->maximumIdentityLength == rhs.d->maximumIdentityLength &&
- lhs.d->preSharedKey == rhs.d->preSharedKey &&
- lhs.d->maximumPreSharedKeyLength == rhs.d->maximumPreSharedKeyLength));
-}
/*!
- \fn bool operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
- \relates QSslPreSharedKeyAuthenticator
+ \fn bool QSslPreSharedKeyAuthenticator::operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
\since 5.5
- Returns true if the authenticator object \a lhs is different than \a rhs;
- false otherwise.
+ Returns \c true if the authenticator object \a lhs is not equal to \a rhs;
+ \c false otherwise.
+*/
+/*!
+ \internal
*/
+bool QSslPreSharedKeyAuthenticator::isEqual(const QSslPreSharedKeyAuthenticator &other) const
+{
+ return ((d == other.d) ||
+ (d->identityHint == other.d->identityHint &&
+ d->identity == other.d->identity &&
+ d->maximumIdentityLength == other.d->maximumIdentityLength &&
+ d->preSharedKey == other.d->preSharedKey &&
+ d->maximumPreSharedKeyLength == other.d->maximumPreSharedKeyLength));
+}
QT_END_NAMESPACE
diff --git a/src/network/ssl/qsslpresharedkeyauthenticator.h b/src/network/ssl/qsslpresharedkeyauthenticator.h
index 5d714dc34e..026d3f43e5 100644
--- a/src/network/ssl/qsslpresharedkeyauthenticator.h
+++ b/src/network/ssl/qsslpresharedkeyauthenticator.h
@@ -74,17 +74,19 @@ public:
Q_NETWORK_EXPORT int maximumPreSharedKeyLength() const;
private:
- friend Q_NETWORK_EXPORT bool operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs);
+ bool isEqual(const QSslPreSharedKeyAuthenticator &other) const;
+
friend class QSslSocketBackendPrivate;
friend class QDtlsPrivateOpenSSL;
+ friend bool operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
+ { return lhs.isEqual(rhs); }
+ friend bool operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
+ { return !lhs.isEqual(rhs); }
+
QSharedDataPointer<QSslPreSharedKeyAuthenticatorPrivate> d;
};
-inline bool operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
-{
- return !operator==(lhs, rhs);
-}
Q_DECLARE_SHARED(QSslPreSharedKeyAuthenticator)