mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 00:07:59 +02:00
SF 3538780 SocketAddress needs operator < function
This commit is contained in:
@@ -16,14 +16,14 @@
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
virtual poco_socklen_t length() const = 0;
|
||||
virtual const struct sockaddr* addr() const = 0;
|
||||
virtual int af() const = 0;
|
||||
|
||||
|
||||
protected:
|
||||
SocketAddressImpl()
|
||||
{
|
||||
@@ -86,14 +86,14 @@ protected:
|
||||
Poco::Net::initializeNetwork();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
virtual ~SocketAddressImpl()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
Poco::Net::uninitializeNetwork();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
SocketAddressImpl(const SocketAddressImpl&);
|
||||
SocketAddressImpl& operator = (const SocketAddressImpl&);
|
||||
@@ -109,12 +109,12 @@ public:
|
||||
_addr.sin_family = AF_INET;
|
||||
poco_set_sin_len(&_addr);
|
||||
}
|
||||
|
||||
|
||||
IPv4SocketAddressImpl(const struct sockaddr_in* addr)
|
||||
{
|
||||
std::memcpy(&_addr, addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
IPv4SocketAddressImpl(const void* addr, UInt16 port)
|
||||
{
|
||||
std::memset(&_addr, 0, sizeof(_addr));
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
{
|
||||
return IPAddress(&_addr.sin_addr, sizeof(_addr.sin_addr));
|
||||
}
|
||||
|
||||
|
||||
UInt16 port() const
|
||||
{
|
||||
return _addr.sin_port;
|
||||
@@ -137,12 +137,12 @@ public:
|
||||
{
|
||||
return sizeof(_addr);
|
||||
}
|
||||
|
||||
|
||||
const struct sockaddr* addr() const
|
||||
{
|
||||
return reinterpret_cast<const struct sockaddr*>(&_addr);
|
||||
}
|
||||
|
||||
|
||||
int af() const
|
||||
{
|
||||
return _addr.sin_family;
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
{
|
||||
std::memcpy(&_addr, addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
IPv6SocketAddressImpl(const void* addr, UInt16 port)
|
||||
{
|
||||
std::memset(&_addr, 0, sizeof(_addr));
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
{
|
||||
return IPAddress(&_addr.sin6_addr, sizeof(_addr.sin6_addr), _addr.sin6_scope_id);
|
||||
}
|
||||
|
||||
|
||||
UInt16 port() const
|
||||
{
|
||||
return _addr.sin6_port;
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
{
|
||||
return sizeof(_addr);
|
||||
}
|
||||
|
||||
|
||||
const struct sockaddr* addr() const
|
||||
{
|
||||
return reinterpret_cast<const struct sockaddr*>(&_addr);
|
||||
@@ -226,13 +226,13 @@ SocketAddress::SocketAddress()
|
||||
_pImpl = new IPv4SocketAddressImpl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SocketAddress::SocketAddress(const IPAddress& addr, Poco::UInt16 port)
|
||||
{
|
||||
init(addr, port);
|
||||
init(addr, port);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SocketAddress::SocketAddress(const std::string& addr, Poco::UInt16 port)
|
||||
{
|
||||
init(addr, port);
|
||||
@@ -248,7 +248,7 @@ SocketAddress::SocketAddress(const std::string& addr, const std::string& port)
|
||||
SocketAddress::SocketAddress(const std::string& hostAndPort)
|
||||
{
|
||||
poco_assert (!hostAndPort.empty());
|
||||
|
||||
|
||||
std::string host;
|
||||
std::string port;
|
||||
std::string::const_iterator it = hostAndPort.begin();
|
||||
@@ -298,7 +298,15 @@ SocketAddress::~SocketAddress()
|
||||
_pImpl->release();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool SocketAddress::operator < (const SocketAddress& addr) const
|
||||
{
|
||||
if (family() < addr.family()) return true;
|
||||
if (host() < addr.host()) return true;
|
||||
return (port() < addr.port());
|
||||
}
|
||||
|
||||
|
||||
SocketAddress& SocketAddress::operator = (const SocketAddress& addr)
|
||||
{
|
||||
if (&addr != this)
|
||||
@@ -316,25 +324,25 @@ void SocketAddress::swap(SocketAddress& addr)
|
||||
std::swap(_pImpl, addr._pImpl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
IPAddress SocketAddress::host() const
|
||||
{
|
||||
return _pImpl->host();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Poco::UInt16 SocketAddress::port() const
|
||||
{
|
||||
return ntohs(_pImpl->port());
|
||||
}
|
||||
|
||||
|
||||
|
||||
poco_socklen_t SocketAddress::length() const
|
||||
{
|
||||
return _pImpl->length();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const struct sockaddr* SocketAddress::addr() const
|
||||
{
|
||||
return _pImpl->addr();
|
||||
|
||||
Reference in New Issue
Block a user