Welcome to mirror list, hosted at ThFree Co, Russian Federation.

UnresolvedServerAddress.cpp « src - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2308db4aaabe7ad0fcde9cdea6aa18ebb4782e12 (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
42
43
// 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"

#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;
}

uint qHash(const UnresolvedServerAddress &key) {
	return qHash(key.hostname) ^ uint(key.port);
}