blob: 4b634d14486b94e4562b47c5f0450162dc1fdb65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright 2005-2019 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"
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;
}
uint qHash(const UnresolvedServerAddress &key) {
return qHash(key.hostname) ^ uint(key.port);
}
|