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