Merge pull request #1556 from JulianGro/fix_static_function_warning

Fix static function warning in SocketType.h.
This commit is contained in:
Kalila 2022-01-05 21:25:43 -05:00 committed by GitHub
commit 44520dacd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 { 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 { QString SockAddr::toShortString() const {
@ -135,7 +135,7 @@ bool SockAddr::hasPrivateAddress() const {
QDebug operator<<(QDebug debug, const SockAddr& sockAddr) { QDebug operator<<(QDebug debug, const SockAddr& sockAddr) {
debug.nospace() debug.nospace()
<< (sockAddr._socketType != SocketType::Unknown << (sockAddr._socketType != SocketType::Unknown
? (socketTypeToString(sockAddr._socketType) + " ").toLocal8Bit().constData() : "") ? (SocketTypeToString::socketTypeToString(sockAddr._socketType) + " ").toLocal8Bit().constData() : "")
<< sockAddr._address.toString().toLocal8Bit().constData() << ":" << sockAddr._port; << sockAddr._address.toString().toLocal8Bit().constData() << ":" << sockAddr._port;
return debug.space(); return debug.space();
} }

View file

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

View file

@ -559,7 +559,7 @@ void Socket::handleSocketError(SocketType socketType, QAbstractSocket::SocketErr
#endif #endif
int pending = _networkSocket.bytesToWrite(socketType); int pending = _networkSocket.bytesToWrite(socketType);
QString errorString; QString errorString;
QDebug(&errorString) << "udt::Socket (" << socketTypeToString(socketType) << _networkSocket.state(socketType) QDebug(&errorString) << "udt::Socket (" << SocketTypeToString::socketTypeToString(socketType) << _networkSocket.state(socketType)
<< ") error - " << wsaError << socketError << "(" << _networkSocket.errorString(socketType) << ")" << ") error - " << wsaError << socketError << "(" << _networkSocket.errorString(socketType) << ")"
<< (pending ? "pending bytes:" : "pending:") << pending; << (pending ? "pending bytes:" : "pending:") << pending;
@ -576,7 +576,7 @@ void Socket::handleSocketError(SocketType socketType, QAbstractSocket::SocketErr
void Socket::handleStateChanged(SocketType socketType, QAbstractSocket::SocketState socketState) { void Socket::handleStateChanged(SocketType socketType, QAbstractSocket::SocketState socketState) {
if (socketState != QAbstractSocket::BoundState) { 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;
} }
} }