summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network/HostAddressPort.h')
-rw-r--r--Swiften/Network/HostAddressPort.h67
1 files changed, 37 insertions, 30 deletions
diff --git a/Swiften/Network/HostAddressPort.h b/Swiften/Network/HostAddressPort.h
index 68f3a1c..759af01 100644
--- a/Swiften/Network/HostAddressPort.h
+++ b/Swiften/Network/HostAddressPort.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
+ * Copyright (c) 2010-2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
*/
#pragma once
@@ -12,31 +12,38 @@
#include <Swiften/Network/HostAddress.h>
namespace Swift {
- class SWIFTEN_API HostAddressPort {
- public:
- HostAddressPort(const HostAddress& address = HostAddress(), int port = -1);
- HostAddressPort(const boost::asio::ip::tcp::endpoint& endpoint);
-
- const HostAddress& getAddress() const {
- return address_;
- }
-
- int getPort() const {
- return port_;
- }
-
- bool operator==(const HostAddressPort& o) const {
- return address_ == o.address_ && port_ == o.port_;
- }
-
- bool isValid() const {
- return address_.isValid() && port_ > 0;
- }
-
- std::string toString() const;
-
- private:
- HostAddress address_;
- int port_;
- };
+ class SWIFTEN_API HostAddressPort {
+ public:
+ HostAddressPort(const HostAddress& address = HostAddress(), unsigned short port = 0);
+ HostAddressPort(const boost::asio::ip::tcp::endpoint& endpoint);
+
+ const HostAddress& getAddress() const {
+ return address_;
+ }
+
+ unsigned short getPort() const {
+ return port_;
+ }
+
+ bool operator==(const HostAddressPort& o) const {
+ return address_ == o.address_ && port_ == o.port_;
+ }
+
+ bool operator<(const HostAddressPort& o) const {
+ if (address_ < o.address_) {
+ return true;
+ }
+ return address_ == o.address_ && port_ < o.port_;
+ }
+
+ bool isValid() const {
+ return address_.isValid() && port_ > 0;
+ }
+
+ std::string toString() const;
+
+ private:
+ HostAddress address_;
+ unsigned short port_;
+ };
}