Fix static function warning

This commit is contained in:
Julian Groß 2021-12-28 14:15:30 +01:00
parent fa2b1ea396
commit cd1798a3d3
3 changed files with 17 additions and 15 deletions

View file

@ -113,7 +113,7 @@ void SockAddr::handleLookupResult(const QHostInfo& hostInfo) {
}
QString SockAddr::toString() const {
return socketTypeToString(_socketType) + " " + _address.toString() + ":" + QString::number(_port);
return SocketTypeToString::socketTypeToString(_socketType) + " " + _address.toString() + ":" + QString::number(_port);
}
QString SockAddr::toShortString() const {
@ -133,9 +133,9 @@ bool SockAddr::hasPrivateAddress() const {
}
QDebug operator<<(QDebug debug, const SockAddr& sockAddr) {
debug.nospace()
<< (sockAddr._socketType != SocketType::Unknown
? (socketTypeToString(sockAddr._socketType) + " ").toLocal8Bit().constData() : "")
debug.nospace()
<< (sockAddr._socketType != SocketType::Unknown
? (SocketTypeToString::socketTypeToString(sockAddr._socketType) + " ").toLocal8Bit().constData() : "")
<< sockAddr._address.toString().toLocal8Bit().constData() << ":" << sockAddr._port;
return debug.space();
}

View file

@ -25,14 +25,16 @@ enum class SocketType : uint8_t {
WebRTC ///< WebRTC socket. A WebRTC data channel presented as a UDP-style socket.
};
/// @brief Returns the name of a SocketType value, e.g., <code>"WebRTC"</code>.
/// @param socketType The SocketType value.
/// @return The name of the SocketType value.
static QString socketTypeToString(SocketType socketType) {
static QStringList SOCKET_TYPE_STRINGS { "Unknown", "UDP", "WebRTC" };
return SOCKET_TYPE_STRINGS[(int)socketType];
}
class SocketTypeToString {
public:
/// @brief Returns the name of a SocketType value, e.g., <code>"WebRTC"</code>.
/// @param socketType The SocketType value.
/// @return The name of the SocketType value.
static QString socketTypeToString (SocketType socketType) {
static QStringList SOCKET_TYPE_STRINGS { "Unknown", "UDP", "WebRTC" };
return SOCKET_TYPE_STRINGS[(int)socketType];
}
};
/// @}

View file

@ -559,8 +559,8 @@ void Socket::handleSocketError(SocketType socketType, QAbstractSocket::SocketErr
#endif
int pending = _networkSocket.bytesToWrite(socketType);
QString errorString;
QDebug(&errorString) << "udt::Socket (" << socketTypeToString(socketType) << _networkSocket.state(socketType)
<< ") error - " << wsaError << socketError << "(" << _networkSocket.errorString(socketType) << ")"
QDebug(&errorString) << "udt::Socket (" << SocketTypeToString::socketTypeToString(socketType) << _networkSocket.state(socketType)
<< ") error - " << wsaError << socketError << "(" << _networkSocket.errorString(socketType) << ")"
<< (pending ? "pending bytes:" : "pending:") << pending;
if (previousWsaError.exchange(wsaError) != wsaError) {
@ -576,7 +576,7 @@ void Socket::handleSocketError(SocketType socketType, QAbstractSocket::SocketErr
void Socket::handleStateChanged(SocketType socketType, QAbstractSocket::SocketState socketState) {
if (socketState != QAbstractSocket::BoundState) {
qCDebug(networking) << socketTypeToString(socketType) << "socket state changed - state is now" << socketState;
qCDebug(networking) << SocketTypeToString::socketTypeToString(socketType) << "socket state changed - state is now" << socketState;
}
}