summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qhostaddress.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-03-11 14:12:00 -0800
committerThiago Macieira <thiago.macieira@intel.com>2021-03-18 19:54:01 -0800
commit969337bcfd6af6d91b988e4b412703274a0b5877 (patch)
tree4901f0572e08af78709731f355ac7bb6aad22d64 /src/network/kernel/qhostaddress.h
parent8614491aa1a19973f2039c5c5f2e5551cc535b8c (diff)
QHostAddress: prepare moving NetworkLayerProtocol from QAbstractSocket
This can only be completed in Qt 7, due to BC guarantees. I've only updated the source code for QHostAddress and its unit test and even then I did not touch the documentation. This needs to be completed in Qt 7.0 Change-Id: I26b8286f61534f88b649fffd166b695882f8f3b5 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/network/kernel/qhostaddress.h')
-rw-r--r--src/network/kernel/qhostaddress.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h
index 4b1bdfced8..b462a68009 100644
--- a/src/network/kernel/qhostaddress.h
+++ b/src/network/kernel/qhostaddress.h
@@ -45,7 +45,9 @@
#include <QtCore/qpair.h>
#include <QtCore/qstring.h>
#include <QtCore/qshareddata.h>
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
#include <QtNetwork/qabstractsocket.h>
+#endif
struct sockaddr;
@@ -70,6 +72,7 @@ Q_NETWORK_EXPORT size_t qHash(const QHostAddress &key, size_t seed = 0) noexcept
class Q_NETWORK_EXPORT QHostAddress
{
+ Q_GADGET
public:
enum SpecialAddress {
Null,
@@ -91,6 +94,22 @@ public:
};
Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ using NetworkLayerProtocol = QAbstractSocket::NetworkLayerProtocol;
+ static constexpr auto IPv4Protocol = QAbstractSocket::IPv4Protocol;
+ static constexpr auto IPv6Protocol = QAbstractSocket::IPv6Protocol;
+ static constexpr auto AnyIPProtocol = QAbstractSocket::AnyIPProtocol;
+ static constexpr auto UnknownNetworkLayerProtocol = QAbstractSocket::UnknownNetworkLayerProtocol;
+#else
+ enum NetworkLayerProtocol {
+ IPv4Protocol,
+ IPv6Protocol,
+ AnyIPProtocol,
+ UnknownNetworkLayerProtocol = -1
+ };
+ Q_ENUM(NetworkLayerProtocol)
+#endif
+
QHostAddress();
explicit QHostAddress(quint32 ip4Addr);
explicit QHostAddress(const quint8 *ip6Addr);
@@ -115,9 +134,7 @@ public:
bool setAddress(const QString &address);
void setAddress(SpecialAddress address);
- // ### Qt7: consider moving NetworkLayerProtocol to QHostAddress so we
- // don't depend on QAbstractSocket
- QAbstractSocket::NetworkLayerProtocol protocol() const;
+ NetworkLayerProtocol protocol() const;
quint32 toIPv4Address(bool *ok = nullptr) const;
Q_IPV6ADDR toIPv6Address() const;