diff options
Diffstat (limited to 'Swiften/Network/HostAddressPort.h')
| -rw-r--r-- | Swiften/Network/HostAddressPort.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Swiften/Network/HostAddressPort.h b/Swiften/Network/HostAddressPort.h index e42e1d1..759af01 100644 --- a/Swiften/Network/HostAddressPort.h +++ b/Swiften/Network/HostAddressPort.h @@ -1,42 +1,49 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include <boost/asio/ip/tcp.hpp> #include <Swiften/Base/API.h> #include <Swiften/Network/HostAddress.h> namespace Swift { class SWIFTEN_API HostAddressPort { public: - HostAddressPort(const HostAddress& address = HostAddress(), int port = -1); + HostAddressPort(const HostAddress& address = HostAddress(), unsigned short port = 0); HostAddressPort(const boost::asio::ip::tcp::endpoint& endpoint); const HostAddress& getAddress() const { return address_; } - int getPort() const { + 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_; - int port_; + unsigned short port_; }; } |
Swift