mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 16:48:06 +02:00
gcc alignment and warning suppression
This commit is contained in:
@@ -64,26 +64,26 @@ namespace Net {
|
||||
|
||||
IPAddress::IPAddress()
|
||||
{
|
||||
new (storage()) IPv4AddressImpl();
|
||||
newIPv4();
|
||||
}
|
||||
|
||||
|
||||
IPAddress::IPAddress(const IPAddress& addr)
|
||||
{
|
||||
if (addr.family() == IPv4)
|
||||
new (storage()) IPv4AddressImpl(addr.addr());
|
||||
newIPv4(addr.addr());
|
||||
else
|
||||
new (storage()) IPv6AddressImpl(addr.addr());
|
||||
newIPv6(addr.addr());
|
||||
}
|
||||
|
||||
|
||||
IPAddress::IPAddress(Family family)
|
||||
{
|
||||
if (family == IPv4)
|
||||
new (storage()) IPv4AddressImpl();
|
||||
newIPv4();
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (family == IPv6)
|
||||
new (storage()) IPv6AddressImpl();
|
||||
newIPv6();
|
||||
#endif
|
||||
else
|
||||
throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()");
|
||||
@@ -95,14 +95,14 @@ IPAddress::IPAddress(const std::string& addr)
|
||||
IPv4AddressImpl empty4 = IPv4AddressImpl();
|
||||
if (addr.empty() || trim(addr) == "0.0.0.0")
|
||||
{
|
||||
new (storage()) IPv4AddressImpl(empty4.addr());
|
||||
newIPv4(empty4.addr());
|
||||
return;
|
||||
}
|
||||
|
||||
IPv4AddressImpl addr4(IPv4AddressImpl::parse(addr));
|
||||
if (addr4 != empty4)
|
||||
{
|
||||
new (storage()) IPv4AddressImpl(addr4.addr());
|
||||
newIPv4(addr4.addr());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,14 +110,14 @@ IPAddress::IPAddress(const std::string& addr)
|
||||
IPv6AddressImpl empty6 = IPv6AddressImpl();
|
||||
if (addr.empty() || trim(addr) == "::")
|
||||
{
|
||||
new (storage()) IPv6AddressImpl(empty6.addr());
|
||||
newIPv6(empty6.addr());
|
||||
return;
|
||||
}
|
||||
|
||||
IPv6AddressImpl addr6(IPv6AddressImpl::parse(addr));
|
||||
if (addr6 != IPv6AddressImpl())
|
||||
{
|
||||
new (storage()) IPv6AddressImpl(addr6.addr());
|
||||
newIPv6(addr6.addr());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -131,14 +131,14 @@ IPAddress::IPAddress(const std::string& addr, Family family)
|
||||
if (family == IPv4)
|
||||
{
|
||||
IPv4AddressImpl addr4(IPv4AddressImpl::parse(addr));
|
||||
new (storage()) IPv4AddressImpl(addr4.addr());
|
||||
newIPv4(addr4.addr());
|
||||
return;
|
||||
}
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (family == IPv6)
|
||||
{
|
||||
IPv6AddressImpl addr6(IPv6AddressImpl::parse(addr));
|
||||
new (storage()) IPv6AddressImpl(addr6.addr());
|
||||
newIPv6(addr6.addr());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -147,12 +147,15 @@ IPAddress::IPAddress(const std::string& addr, Family family)
|
||||
|
||||
|
||||
IPAddress::IPAddress(const void* addr, poco_socklen_t length)
|
||||
#ifndef POCO_HAVE_ALIGNMENT
|
||||
: _pImpl(0)
|
||||
#endif
|
||||
{
|
||||
if (length == sizeof(struct in_addr))
|
||||
new (storage()) IPv4AddressImpl(addr);
|
||||
newIPv4(addr);
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (length == sizeof(struct in6_addr))
|
||||
new (storage()) IPv6AddressImpl(addr);
|
||||
newIPv6(addr);
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Invalid address length passed to IPAddress()");
|
||||
}
|
||||
@@ -161,10 +164,10 @@ IPAddress::IPAddress(const void* addr, poco_socklen_t length)
|
||||
IPAddress::IPAddress(const void* addr, poco_socklen_t length, Poco::UInt32 scope)
|
||||
{
|
||||
if (length == sizeof(struct in_addr))
|
||||
new (storage()) IPv4AddressImpl(addr);
|
||||
newIPv4(addr);
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (length == sizeof(struct in6_addr))
|
||||
new (storage()) IPv6AddressImpl(addr, scope);
|
||||
newIPv6(addr, scope);
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Invalid address length passed to IPAddress()");
|
||||
}
|
||||
@@ -175,13 +178,13 @@ IPAddress::IPAddress(unsigned prefix, Family family)
|
||||
if (family == IPv4)
|
||||
{
|
||||
if (prefix <= 32)
|
||||
new (storage()) IPv4AddressImpl(prefix);
|
||||
newIPv4(prefix);
|
||||
}
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (family == IPv6)
|
||||
{
|
||||
if (prefix <= 128)
|
||||
new (storage()) IPv6AddressImpl(prefix);
|
||||
newIPv6(prefix);
|
||||
}
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()");
|
||||
@@ -191,13 +194,16 @@ IPAddress::IPAddress(unsigned prefix, Family family)
|
||||
|
||||
#if defined(_WIN32)
|
||||
IPAddress::IPAddress(const SOCKET_ADDRESS& socket_address)
|
||||
#ifndef POCO_HAVE_ALIGNMENT
|
||||
: _pImpl(0)
|
||||
#endif
|
||||
{
|
||||
ADDRESS_FAMILY family = socket_address.lpSockaddr->sa_family;
|
||||
if (family == AF_INET)
|
||||
new (storage()) IPv4AddressImpl(&reinterpret_cast<const struct sockaddr_in*>(socket_address.lpSockaddr)->sin_addr);
|
||||
newIPv4(&reinterpret_cast<const struct sockaddr_in*>(socket_address.lpSockaddr)->sin_addr);
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (family == AF_INET6)
|
||||
new (storage()) IPv6AddressImpl(&reinterpret_cast<const struct sockaddr_in6*>(socket_address.lpSockaddr)->sin6_addr,
|
||||
newIPv6(&reinterpret_cast<const struct sockaddr_in6*>(socket_address.lpSockaddr)->sin6_addr,
|
||||
reinterpret_cast<const struct sockaddr_in6*>(socket_address.lpSockaddr)->sin6_scope_id);
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()");
|
||||
@@ -209,11 +215,11 @@ IPAddress::IPAddress(const struct sockaddr& sockaddr)
|
||||
{
|
||||
unsigned short family = sockaddr.sa_family;
|
||||
if (family == AF_INET)
|
||||
new (storage()) IPv4AddressImpl(&reinterpret_cast<const struct sockaddr_in*>(&sockaddr)->sin_addr);
|
||||
newIPv4(&reinterpret_cast<const struct sockaddr_in*>(&sockaddr)->sin_addr);
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (family == AF_INET6)
|
||||
new (storage()) IPv6AddressImpl(&reinterpret_cast<const struct sockaddr_in6*>(&sockaddr)->sin6_addr,
|
||||
reinterpret_cast<const struct sockaddr_in6*>(&sockaddr)->sin6_scope_id);
|
||||
newIPv6(&reinterpret_cast<const struct sockaddr_in6*>(&sockaddr)->sin6_addr,
|
||||
reinterpret_cast<const struct sockaddr_in6*>(&sockaddr)->sin6_scope_id);
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()");
|
||||
}
|
||||
@@ -231,9 +237,9 @@ IPAddress& IPAddress::operator = (const IPAddress& addr)
|
||||
{
|
||||
destruct();
|
||||
if (addr.family() == IPAddress::IPv4)
|
||||
new (storage()) IPv4AddressImpl(addr.addr());
|
||||
newIPv4(addr.addr());
|
||||
else
|
||||
new (storage()) IPv6AddressImpl(addr.addr());
|
||||
newIPv6(addr.addr());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -540,20 +546,19 @@ IPAddress IPAddress::parse(const std::string& addr)
|
||||
}
|
||||
|
||||
|
||||
bool IPAddress::tryParse(const std::string& addr, IPAddress& result)
|
||||
bool IPAddress::tryParse(const std::string& addr, IPAddress& result)
|
||||
{
|
||||
IPv4AddressImpl impl4(IPv4AddressImpl::parse(addr));
|
||||
if (impl4 != IPv4AddressImpl())
|
||||
{
|
||||
|
||||
new (result.storage()) IPv4AddressImpl(impl4.addr());
|
||||
result.newIPv4(impl4.addr());
|
||||
return true;
|
||||
}
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
IPv6AddressImpl impl6(IPv6AddressImpl::parse(addr));
|
||||
if (impl6 != IPv6AddressImpl())
|
||||
{
|
||||
new (result.storage()) IPv6AddressImpl(impl6.addr());
|
||||
result.newIPv6(impl6.addr());
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user