mirror of
https://github.com/pocoproject/poco.git
synced 2025-05-03 15:58:23 +02:00
IPAddress Mac clang compile
This commit is contained in:
parent
ddfa52eefa
commit
1523a87926
@ -86,10 +86,11 @@
|
|||||||
// #define POCO_THREAD_PRIORITY_MAX 31
|
// #define POCO_THREAD_PRIORITY_MAX 31
|
||||||
|
|
||||||
|
|
||||||
// Define to disable small object optimization.
|
// Define to disable small object optimization. If not
|
||||||
// If not defined, Any and Dynamic::Var (and similar
|
// defined, Any and Dynamic::Var (and similar optimization
|
||||||
// optimization candidates) will be auto-allocated on the
|
// candidates) will be auto-allocated on the stack in
|
||||||
// stack in cases when value holder fits into .
|
// cases when value holder fits into POCO_SMALL_OBJECT_SIZE
|
||||||
|
// (see Poco/Types.h for default values).
|
||||||
// #define POCO_NO_SOO
|
// #define POCO_NO_SOO
|
||||||
|
|
||||||
// Following are options to remove certain features
|
// Following are options to remove certain features
|
||||||
|
@ -12,7 +12,7 @@ SHAREDOPT_CXX += -DNet_EXPORTS
|
|||||||
|
|
||||||
objects = \
|
objects = \
|
||||||
DNS HTTPResponse HostEntry Socket \
|
DNS HTTPResponse HostEntry Socket \
|
||||||
DatagramSocket HTTPServer IPAddress SocketAddress \
|
DatagramSocket HTTPServer IPAddress IPAddressImpl SocketAddress \
|
||||||
HTTPBasicCredentials HTTPCookie HTMLForm MediaType DialogSocket \
|
HTTPBasicCredentials HTTPCookie HTMLForm MediaType DialogSocket \
|
||||||
DatagramSocketImpl FilePartSource HTTPServerConnection MessageHeader \
|
DatagramSocketImpl FilePartSource HTTPServerConnection MessageHeader \
|
||||||
HTTPChunkedStream HTTPServerConnectionFactory MulticastSocket SocketStream \
|
HTTPChunkedStream HTTPServerConnectionFactory MulticastSocket SocketStream \
|
||||||
|
@ -392,6 +392,9 @@ private:
|
|||||||
Ptr pImpl() const;
|
Ptr pImpl() const;
|
||||||
|
|
||||||
char _memory[sizeof(Poco::Net::Impl::IPv6AddressImpl)];
|
char _memory[sizeof(Poco::Net::Impl::IPv6AddressImpl)];
|
||||||
|
|
||||||
|
friend class IPv4AddressImpl;
|
||||||
|
friend class IPv6AddressImpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ IPAddress::IPAddress()
|
|||||||
IPAddress::IPAddress(const IPAddress& addr)
|
IPAddress::IPAddress(const IPAddress& addr)
|
||||||
{
|
{
|
||||||
if (addr.family() == IPv4)
|
if (addr.family() == IPv4)
|
||||||
std::memcpy(pImpl(), addr.pImpl(), sizeof (IPv4AddressImpl));
|
new (_memory) IPv4AddressImpl(addr.addr());
|
||||||
else
|
else
|
||||||
std::memcpy(pImpl(), addr.pImpl(), sizeof (IPv6AddressImpl));
|
new (_memory) IPv6AddressImpl(addr.addr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,14 +95,14 @@ IPAddress::IPAddress(const std::string& addr)
|
|||||||
IPv4AddressImpl empty4 = IPv4AddressImpl();
|
IPv4AddressImpl empty4 = IPv4AddressImpl();
|
||||||
if (addr.empty() || trim(addr) == "0.0.0.0")
|
if (addr.empty() || trim(addr) == "0.0.0.0")
|
||||||
{
|
{
|
||||||
std::memcpy(pImpl(), &empty4, sizeof(empty4));
|
new (_memory) IPv4AddressImpl(empty4.addr());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPv4AddressImpl addr4(IPv4AddressImpl::parse(addr));
|
IPv4AddressImpl addr4(IPv4AddressImpl::parse(addr));
|
||||||
if (addr4 != empty4)
|
if (addr4 != empty4)
|
||||||
{
|
{
|
||||||
std::memcpy(pImpl(), &addr4, sizeof(addr4));
|
new (_memory) IPv4AddressImpl(addr4.addr());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,14 +110,14 @@ IPAddress::IPAddress(const std::string& addr)
|
|||||||
IPv6AddressImpl empty6 = IPv6AddressImpl();
|
IPv6AddressImpl empty6 = IPv6AddressImpl();
|
||||||
if (addr.empty() || trim(addr) == "::")
|
if (addr.empty() || trim(addr) == "::")
|
||||||
{
|
{
|
||||||
std::memcpy(pImpl(), &empty6, sizeof(empty6));
|
new (_memory) IPv6AddressImpl(empty6.addr());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPv6AddressImpl addr6(IPv6AddressImpl::parse(addr));
|
IPv6AddressImpl addr6(IPv6AddressImpl::parse(addr));
|
||||||
if (addr6 != IPv6AddressImpl())
|
if (addr6 != IPv6AddressImpl())
|
||||||
{
|
{
|
||||||
std::memcpy(pImpl(), &addr6, sizeof(addr6));
|
new (_memory) IPv6AddressImpl(addr6.addr());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -131,14 +131,14 @@ IPAddress::IPAddress(const std::string& addr, Family family)
|
|||||||
if (family == IPv4)
|
if (family == IPv4)
|
||||||
{
|
{
|
||||||
IPv4AddressImpl addr4(IPv4AddressImpl::parse(addr));
|
IPv4AddressImpl addr4(IPv4AddressImpl::parse(addr));
|
||||||
std::memcpy(pImpl(), &addr4, sizeof(addr4));
|
new (_memory) IPv4AddressImpl(addr4.addr());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if defined(POCO_HAVE_IPv6)
|
#if defined(POCO_HAVE_IPv6)
|
||||||
else if (family == IPv6)
|
else if (family == IPv6)
|
||||||
{
|
{
|
||||||
IPv6AddressImpl addr6(IPv6AddressImpl::parse(addr));
|
IPv6AddressImpl addr6(IPv6AddressImpl::parse(addr));
|
||||||
std::memcpy(pImpl(), &addr6, sizeof(addr6));
|
new (_memory) IPv6AddressImpl(addr6.addr());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -230,9 +230,9 @@ IPAddress& IPAddress::operator = (const IPAddress& addr)
|
|||||||
if (&addr != this)
|
if (&addr != this)
|
||||||
{
|
{
|
||||||
if (addr.family() == IPAddress::IPv4)
|
if (addr.family() == IPAddress::IPv4)
|
||||||
std::memcpy(pImpl(), addr.pImpl(), sizeof(IPv4AddressImpl));
|
new (_memory) IPv4AddressImpl(addr.addr());
|
||||||
else
|
else
|
||||||
std::memcpy(pImpl(), addr.pImpl(), sizeof(IPv6AddressImpl));
|
new (_memory) IPv6AddressImpl(addr.addr());
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -544,14 +544,15 @@ bool IPAddress::tryParse(const std::string& addr, IPAddress& result)
|
|||||||
IPv4AddressImpl impl4(IPv4AddressImpl::parse(addr));
|
IPv4AddressImpl impl4(IPv4AddressImpl::parse(addr));
|
||||||
if (impl4 != IPv4AddressImpl())
|
if (impl4 != IPv4AddressImpl())
|
||||||
{
|
{
|
||||||
std::memcpy(result.pImpl(), &impl4, sizeof(impl4));
|
|
||||||
|
new (result._memory) IPv4AddressImpl(impl4.addr());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#if defined(POCO_HAVE_IPv6)
|
#if defined(POCO_HAVE_IPv6)
|
||||||
IPv6AddressImpl impl6(IPv6AddressImpl::parse(addr));
|
IPv6AddressImpl impl6(IPv6AddressImpl::parse(addr));
|
||||||
if (impl6 != IPv6AddressImpl())
|
if (impl6 != IPv6AddressImpl())
|
||||||
{
|
{
|
||||||
std::memcpy(result.pImpl(), &impl6, sizeof(impl6));
|
new (result._memory) IPv6AddressImpl(impl6.addr());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -641,18 +641,18 @@ IPv6AddressImpl IPv6AddressImpl::parse(const std::string& addr)
|
|||||||
std::string scope(addr, pos + 1, addr.size() - start - pos);
|
std::string scope(addr, pos + 1, addr.size() - start - pos);
|
||||||
Poco::UInt32 scopeId(0);
|
Poco::UInt32 scopeId(0);
|
||||||
if (!(scopeId = if_nametoindex(scope.c_str())))
|
if (!(scopeId = if_nametoindex(scope.c_str())))
|
||||||
return 0;
|
return IPv6AddressImpl();
|
||||||
if (inet_pton(AF_INET6, unscopedAddr.c_str(), &ia) == 1)
|
if (inet_pton(AF_INET6, unscopedAddr.c_str(), &ia) == 1)
|
||||||
return IPv6AddressImpl(&ia, scopeId);
|
return IPv6AddressImpl(&ia, scopeId);
|
||||||
else
|
else
|
||||||
return 0;
|
return IPv6AddressImpl();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (inet_pton(AF_INET6, addr.c_str(), &ia) == 1)
|
if (inet_pton(AF_INET6, addr.c_str(), &ia) == 1)
|
||||||
return new IPv6AddressImpl(&ia);
|
return IPv6AddressImpl(&ia);
|
||||||
else
|
else
|
||||||
return 0;
|
return IPv6AddressImpl();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user