1 // Copyright 2005-2019 The Mumble Developers. All rights reserved.
2 // Use of this source code is governed by a BSD-style license
3 // that can be found in the LICENSE file at the root of the
4 // Mumble source tree or at <https://www.mumble.info/LICENSE>.
5 
6 #ifndef MUMBLE_UNRESOLVEDSERVERADDRESS_H_
7 #define MUMBLE_UNRESOLVEDSERVERADDRESS_H_
8 
9 #include <QtCore/QString>
10 
11 /// UnresolvedServerAddress represents a
12 /// server address consisting of a hostname
13 /// and a port.
14 struct UnresolvedServerAddress {
15 	QString hostname;
16 	unsigned short port;
17 
18 	/// Construct a default UnresolvedServerAddress.
19 	/// The default UnresolvedServerAddress value is considered
20 	/// invalid per the |isValid| method.
21 	UnresolvedServerAddress();
22 
23 	/// Construct a UnresolvedServerAddress pointing to |hostname| and |port|.
24 	/// The passed-in hostname is normalized to lowercase.
25 	UnresolvedServerAddress(QString hostname, unsigned short port);
26 
27 	/// Check whether the UnresolvedServerAddress is valid.
28 	/// An UnresolvedServerAddress is valid if it has a non-empty
29 	/// |hostname| and if its |port| > 0.
30 	bool isValid() const;
31 };
32 
33 /// Check whether |lhs| and |rhs| are equal.
34 bool operator==(const UnresolvedServerAddress &lhs, const UnresolvedServerAddress &rhs);
35 
36 /// Check whether |lhs| and |rhs| are not equal.
37 bool operator!=(const UnresolvedServerAddress &lhs, const UnresolvedServerAddress &rhs);
38 
39 /// Check whether |lhs| is less than |rhs|.
40 /// This is implemented such that UnresolvedServerAddress can be used in QMap.
41 bool operator<(const UnresolvedServerAddress &lhs, const UnresolvedServerAddress &rhs);
42 
43 /// Implementation of qHash for UnresolvedServerAddress, such that
44 /// UnresolvedServerAddress can be used as a key in QHash, QMap, etc.
45 uint qHash(const UnresolvedServerAddress &key);
46 
47 #endif
48