diff options
author | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-02-11 10:22:01 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-02-12 10:08:20 +0000 |
commit | cd83859bd6310a2cf0a67c489aa597dc87e326b4 (patch) | |
tree | a6c9472f4e668035775b4f9260a2e8d3f02baf27 /src/network/kernel | |
parent | 7997e56a2e5f35fa19da9ccb5dc89586882d951b (diff) |
Network: Fix operator<<(QDebug, ...) operations
Use the
QDebugStateSaver saver(debug);
debug.resetFormat().nospace();
idiom to unify the formatting and whitespace handling.
Change-Id: Id346d63b3f589b60ca19e4459271d587f1a0c003
Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/kernel')
-rw-r--r-- | src/network/kernel/qhostaddress.cpp | 8 | ||||
-rw-r--r-- | src/network/kernel/qnetworkinterface.cpp | 38 | ||||
-rw-r--r-- | src/network/kernel/qnetworkproxy.cpp | 2 |
3 files changed, 27 insertions, 21 deletions
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 75a886ddb6..2054fb2c0a 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -1040,11 +1040,13 @@ bool QHostAddress::isLoopback() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const QHostAddress &address) { + QDebugStateSaver saver(d); + d.resetFormat().nospace(); if (address == QHostAddress::Any) - d.maybeSpace() << "QHostAddress(QHostAddress::Any)"; + d << "QHostAddress(QHostAddress::Any)"; else - d.maybeSpace() << "QHostAddress(" << address.toString() << ')'; - return d.space(); + d << "QHostAddress(" << address.toString() << ')'; + return d; } #endif diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index c62244fab3..8d891733ac 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -580,40 +580,42 @@ QList<QHostAddress> QNetworkInterface::allAddresses() static inline QDebug flagsDebug(QDebug debug, QNetworkInterface::InterfaceFlags flags) { if (flags & QNetworkInterface::IsUp) - debug.nospace() << "IsUp "; + debug << "IsUp "; if (flags & QNetworkInterface::IsRunning) - debug.nospace() << "IsRunning "; + debug << "IsRunning "; if (flags & QNetworkInterface::CanBroadcast) - debug.nospace() << "CanBroadcast "; + debug << "CanBroadcast "; if (flags & QNetworkInterface::IsLoopBack) - debug.nospace() << "IsLoopBack "; + debug << "IsLoopBack "; if (flags & QNetworkInterface::IsPointToPoint) - debug.nospace() << "IsPointToPoint "; + debug << "IsPointToPoint "; if (flags & QNetworkInterface::CanMulticast) - debug.nospace() << "CanMulticast "; - return debug.nospace(); + debug << "CanMulticast "; + return debug; } static inline QDebug operator<<(QDebug debug, const QNetworkAddressEntry &entry) { - debug.nospace() << "(address = " << entry.ip(); + debug << "(address = " << entry.ip(); if (!entry.netmask().isNull()) - debug.nospace() << ", netmask = " << entry.netmask(); + debug << ", netmask = " << entry.netmask(); if (!entry.broadcast().isNull()) - debug.nospace() << ", broadcast = " << entry.broadcast(); - debug.nospace() << ')'; - return debug.space(); + debug << ", broadcast = " << entry.broadcast(); + debug << ')'; + return debug; } QDebug operator<<(QDebug debug, const QNetworkInterface &networkInterface) { - debug.nospace() << "QNetworkInterface(name = " << networkInterface.name() - << ", hardware address = " << networkInterface.hardwareAddress() - << ", flags = "; + QDebugStateSaver saver(debug); + debug.resetFormat().nospace(); + debug << "QNetworkInterface(name = " << networkInterface.name() + << ", hardware address = " << networkInterface.hardwareAddress() + << ", flags = "; flagsDebug(debug, networkInterface.flags()); - debug.nospace() << ", entries = " << networkInterface.addressEntries() - << ")\n"; - return debug.space(); + debug << ", entries = " << networkInterface.addressEntries() + << ")\n"; + return debug; } #endif diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index 53233670e6..53c4410fab 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -1580,6 +1580,8 @@ QList<QNetworkProxy> QNetworkProxyFactory::proxyForQuery(const QNetworkProxyQuer */ QDebug operator<<(QDebug debug, const QNetworkProxy &proxy) { + QDebugStateSaver saver(debug); + debug.resetFormat().nospace(); QNetworkProxy::ProxyType type = proxy.type(); switch (type) { case QNetworkProxy::NoProxy: |