From 969337bcfd6af6d91b988e4b412703274a0b5877 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Mar 2021 14:12:00 -0800 Subject: QHostAddress: prepare moving NetworkLayerProtocol from QAbstractSocket MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: MÃ¥rten Nordheim --- src/network/kernel/qhostaddress.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/network/kernel/qhostaddress.h') 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 #include #include +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) #include +#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; -- cgit v1.2.3