diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2021-03-11 14:12:00 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2021-03-18 19:54:01 -0800 |
commit | 969337bcfd6af6d91b988e4b412703274a0b5877 (patch) | |
tree | 4901f0572e08af78709731f355ac7bb6aad22d64 /src/network/socket | |
parent | 8614491aa1a19973f2039c5c5f2e5551cc535b8c (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/socket')
-rw-r--r-- | src/network/socket/qabstractsocket.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index 5874ddb8e8..96b86f63f7 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -41,6 +41,9 @@ #define QABSTRACTSOCKET_H #include <QtNetwork/qtnetworkglobal.h> +#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) +#include <QtNetwork/qabstractsocket.h> +#endif #include <QtCore/qiodevice.h> #include <QtCore/qobject.h> #ifndef QT_NO_DEBUG_STREAM @@ -70,6 +73,8 @@ public: UnknownSocketType = -1 }; Q_ENUM(SocketType) + +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) enum NetworkLayerProtocol { IPv4Protocol, IPv6Protocol, @@ -77,6 +82,15 @@ public: UnknownNetworkLayerProtocol = -1 }; Q_ENUM(NetworkLayerProtocol) +#else + // compatibility with Qt 4 to 6 + using NetworkLayerProtocol = QHostAddress::NetworkLayerProtocol; + static constexpr auto IPv4Protocol = QHostAddress::IPv4Protocol; + static constexpr auto IPv6Protocol = QHostAddress::IPv6Protocol; + static constexpr auto AnyIPProtocol = QHostAddress::AnyIPProtocol; + static constexpr auto UnknownNetworkLayerProtocol = QHostAddress::UnknownNetworkLayerProtocol; +#endif + enum SocketError { ConnectionRefusedError, RemoteHostClosedError, @@ -149,7 +163,6 @@ public: virtual bool bind(const QHostAddress &address, quint16 port = 0, BindMode mode = DefaultForPlatform); #if QT_VERSION >= QT_VERSION_CHECK(7,0,0) || defined(Q_CLANG_QDOC) - // ### Qt7: this requires that QHostAddress stop depending on QAbstractSocket::NetworkLayerProtocol bool bind(QHostAddress::SpecialAddress addr, quint16 port = 0, BindMode mode = DefaultForPlatform) { return bind(QHostAddress(addr), port, mode); } bool bind(quint16 port = 0, BindMode mode = DefaultForPlatform) |