mumble/src/UnresolvedServerAddress.cpp
Robert Adam 330c356e71 MAINT: Remove copyright year from all copyright notices
Keeping these up-to-date is just super tedious and they don't really
fulfill any purpose these days.
2024-09-30 18:06:20 +02:00

44 lines
1.2 KiB
C++

// Copyright The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#include "UnresolvedServerAddress.h"
#include <QtCore/QHash>
UnresolvedServerAddress::UnresolvedServerAddress() : port(0) {
}
UnresolvedServerAddress::UnresolvedServerAddress(QString hostname_, unsigned short port_)
: hostname(hostname_.toLower()), port(port_) {
}
bool UnresolvedServerAddress::isValid() const {
return !hostname.isEmpty() && port != 0;
}
bool operator==(const UnresolvedServerAddress &lhs, const UnresolvedServerAddress &rhs) {
return lhs.hostname == rhs.hostname && lhs.port == rhs.port;
}
bool operator!=(const UnresolvedServerAddress &lhs, const UnresolvedServerAddress &rhs) {
return !operator==(lhs, rhs);
}
bool operator<(const UnresolvedServerAddress &lhs, const UnresolvedServerAddress &rhs) {
if (lhs.hostname < rhs.hostname) {
return true;
}
if (lhs.hostname == rhs.hostname) {
if (lhs.port < rhs.port) {
return true;
}
}
return false;
}
std::size_t qHash(const UnresolvedServerAddress &key) {
return qHash(key.hostname) ^ static_cast< std::size_t >(key.port);
}