Merge pull request #1971 from Bjoe/remove-soo-in-net

Remove SOO in 1.8
This commit is contained in:
Günter Obiltschnig 2017-11-07 14:46:17 +01:00 committed by GitHub
commit 37927faf66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 3 additions and 178 deletions

View File

@ -365,11 +365,7 @@ public:
private:
typedef Poco::Net::Impl::IPAddressImpl Impl;
#ifdef POCO_HAVE_ALIGNMENT
typedef Impl* Ptr;
#else
typedef Poco::AutoPtr<Impl> Ptr;
#endif
Ptr pImpl() const;
void newIPv4();
@ -381,86 +377,35 @@ private:
void newIPv6(const void* hostAddr, Poco::UInt32 scope);
void newIPv6(unsigned prefix);
#endif
void destruct();
#ifdef POCO_HAVE_ALIGNMENT
char* storage();
#ifdef POCO_ENABLE_CPP11
static const unsigned sz = sizeof(Poco::Net::Impl::IPv6AddressImpl);
typedef std::aligned_storage<sz>::type AlignerType;
union
{
char buffer[sz];
private:
AlignerType aligner;
}
#else // !POCO_ENABLE_CPP11
#if defined(POCO_HAVE_IPv6)
AlignedCharArrayUnion <Poco::Net::Impl::IPv6AddressImpl>
#else
AlignedCharArrayUnion <Poco::Net::Impl::IPv4AddressImpl>
#endif
#endif // POCO_ENABLE_CPP11
_memory;
#else // !POCO_HAVE_ALIGNMENT
Ptr _pImpl;
#endif // POCO_HAVE_ALIGNMENT
};
//
// inlines
//
inline void IPAddress::destruct()
{
#ifdef POCO_HAVE_ALIGNMENT
pImpl()->~IPAddressImpl();
#endif
}
inline IPAddress::Ptr IPAddress::pImpl() const
{
#ifdef POCO_HAVE_ALIGNMENT
return reinterpret_cast<Ptr>(const_cast<char *>(_memory.buffer));
#else
if (_pImpl) return _pImpl;
throw NullPointerException("IPaddress implementation pointer is NULL.");
#endif
}
inline void IPAddress::newIPv4()
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4AddressImpl;
#else
_pImpl = new Poco::Net::Impl::IPv4AddressImpl;
#endif
}
inline void IPAddress::newIPv4(const void* hostAddr)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4AddressImpl(hostAddr);
#else
_pImpl = new Poco::Net::Impl::IPv4AddressImpl(hostAddr);
#endif
}
inline void IPAddress::newIPv4(unsigned prefix)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4AddressImpl(prefix);
#else
_pImpl = new Poco::Net::Impl::IPv4AddressImpl(prefix);
#endif
}
@ -469,55 +414,31 @@ inline void IPAddress::newIPv4(unsigned prefix)
inline void IPAddress::newIPv6()
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6AddressImpl;
#else
_pImpl = new Poco::Net::Impl::IPv6AddressImpl;
#endif
}
inline void IPAddress::newIPv6(const void* hostAddr)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6AddressImpl(hostAddr);
#else
_pImpl = new Poco::Net::Impl::IPv6AddressImpl(hostAddr);
#endif
}
inline void IPAddress::newIPv6(const void* hostAddr, Poco::UInt32 scope)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6AddressImpl(hostAddr, scope);
#else
_pImpl = new Poco::Net::Impl::IPv6AddressImpl(hostAddr, scope);
#endif
}
inline void IPAddress::newIPv6(unsigned prefix)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6AddressImpl(prefix);
#else
_pImpl = new Poco::Net::Impl::IPv6AddressImpl(prefix);
#endif
}
#endif // POCO_HAVE_IPv6
#ifdef POCO_HAVE_ALIGNMENT
inline char* IPAddress::storage()
{
return _memory.buffer;
}
#endif
} } // namespace Poco::Net

View File

@ -20,9 +20,7 @@
#include "Poco/Net/Net.h"
#include "Poco/Net/SocketDefs.h"
#ifndef POCO_HAVE_ALIGNMENT
#include "Poco/RefCountedObject.h"
#endif
#include <vector>
@ -31,10 +29,7 @@ namespace Net {
namespace Impl {
class IPAddressImpl
#ifndef POCO_HAVE_ALIGNMENT
: public Poco::RefCountedObject
#endif
class IPAddressImpl : public Poco::RefCountedObject
{
public:
typedef AddressFamily::Family Family;

View File

@ -195,11 +195,7 @@ protected:
private:
typedef Poco::Net::Impl::SocketAddressImpl Impl;
#ifdef POCO_HAVE_ALIGNMENT
typedef Impl* Ptr;
#else
typedef Poco::AutoPtr<Impl> Ptr;
#endif
Ptr pImpl() const;
@ -217,106 +213,48 @@ private:
void newLocal(const std::string& path);
#endif
void destruct();
#ifdef POCO_HAVE_ALIGNMENT
char* storage();
#ifdef POCO_ENABLE_CPP11
static const unsigned sz = sizeof(Poco::Net::Impl::IPv6SocketAddressImpl);
typedef std::aligned_storage<sz>::type AlignerType;
union
{
char buffer[sz];
private:
AlignerType aligner;
}
#else // !POCO_ENABLE_CPP11
#if defined(POCO_HAVE_IPv6)
AlignedCharArrayUnion <Poco::Net::Impl::IPv6SocketAddressImpl>
#else
AlignedCharArrayUnion <Poco::Net::Impl::IPv4SocketAddressImpl>
#endif
#endif // POCO_ENABLE_CPP11
_memory;
#else // !POCO_HAVE_ALIGNMENT
Ptr _pImpl;
#endif // POCO_HAVE_ALIGNMENT
};
//
// inlines
//
inline void SocketAddress::destruct()
{
#ifdef POCO_HAVE_ALIGNMENT
pImpl()->~SocketAddressImpl();
#endif
}
inline SocketAddress::Ptr SocketAddress::pImpl() const
{
#ifdef POCO_HAVE_ALIGNMENT
return reinterpret_cast<Ptr>(const_cast<char *>(_memory.buffer));
#else
if (_pImpl) return _pImpl;
throw Poco::NullPointerException("Pointer to SocketAddress implementation is NULL.");
#endif
}
inline void SocketAddress::newIPv4()
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4SocketAddressImpl;
#else
_pImpl = new Poco::Net::Impl::IPv4SocketAddressImpl;
#endif
}
inline void SocketAddress::newIPv4(const sockaddr_in* sockAddr)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4SocketAddressImpl(sockAddr);
#else
_pImpl = new Poco::Net::Impl::IPv4SocketAddressImpl(sockAddr);
#endif
}
inline void SocketAddress::newIPv4(const IPAddress& hostAddress, Poco::UInt16 portNumber)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4SocketAddressImpl(hostAddress.addr(), htons(portNumber));
#else
_pImpl = new Poco::Net::Impl::IPv4SocketAddressImpl(hostAddress.addr(), htons(portNumber));
#endif
}
#if defined(POCO_HAVE_IPv6)
inline void SocketAddress::newIPv6(const sockaddr_in6* sockAddr)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6SocketAddressImpl(sockAddr);
#else
_pImpl = new Poco::Net::Impl::IPv6SocketAddressImpl(sockAddr);
#endif
}
inline void SocketAddress::newIPv6(const IPAddress& hostAddress, Poco::UInt16 portNumber)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6SocketAddressImpl(hostAddress.addr(), htons(portNumber), hostAddress.scope());
#else
_pImpl = new Poco::Net::Impl::IPv6SocketAddressImpl(hostAddress.addr(), htons(portNumber), hostAddress.scope());
#endif
}
#endif // POCO_HAVE_IPv6
@ -324,34 +262,18 @@ inline void SocketAddress::newIPv6(const IPAddress& hostAddress, Poco::UInt16 po
#if defined(POCO_OS_FAMILY_UNIX)
inline void SocketAddress::newLocal(const sockaddr_un* sockAddr)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::LocalSocketAddressImpl(sockAddr);
#else
_pImpl = new Poco::Net::Impl::LocalSocketAddressImpl(sockAddr);
#endif
}
inline void SocketAddress::newLocal(const std::string& path)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::LocalSocketAddressImpl(path.c_str());
#else
_pImpl = new Poco::Net::Impl::LocalSocketAddressImpl(path.c_str());
#endif
}
#endif // POCO_OS_FAMILY_UNIX
#ifdef POCO_HAVE_ALIGNMENT
inline char* SocketAddress::storage()
{
return _memory.buffer;
}
#endif
inline bool SocketAddress::operator == (const SocketAddress& socketAddress) const
inline bool SocketAddress::operator == (const SocketAddress& socketAddress) const
{
#if defined(POCO_OS_FAMILY_UNIX)
if (family() == UNIX_LOCAL)

View File

@ -21,9 +21,7 @@
#include "Poco/Net/Net.h"
#include "Poco/Net/SocketDefs.h"
#include "Poco/Net/IPAddress.h"
#ifndef POCO_HAVE_ALIGNMENT
#include "Poco/RefCountedObject.h"
#endif
namespace Poco {
@ -31,10 +29,7 @@ namespace Net {
namespace Impl {
class Net_API SocketAddressImpl
#ifndef POCO_HAVE_ALIGNMENT
: public Poco::RefCountedObject
#endif
class Net_API SocketAddressImpl : public Poco::RefCountedObject
{
public:
typedef AddressFamily::Family Family;

View File

@ -138,9 +138,7 @@ 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))
newIPv4(addr);
@ -188,9 +186,7 @@ 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)
@ -221,7 +217,6 @@ IPAddress::IPAddress(const struct sockaddr& sockaddr)
IPAddress::~IPAddress()
{
destruct();
}
@ -229,7 +224,6 @@ IPAddress& IPAddress::operator = (const IPAddress& addr)
{
if (&addr != this)
{
destruct();
if (addr.family() == IPAddress::IPv4)
newIPv4(addr.addr());
#if defined(POCO_HAVE_IPv6)

View File

@ -168,7 +168,6 @@ SocketAddress::SocketAddress(const struct sockaddr* sockAddr, poco_socklen_t len
SocketAddress::~SocketAddress()
{
destruct();
}
@ -189,7 +188,6 @@ SocketAddress& SocketAddress::operator = (const SocketAddress& socketAddress)
{
if (&socketAddress != this)
{
destruct();
if (socketAddress.family() == IPv4)
newIPv4(reinterpret_cast<const sockaddr_in*>(socketAddress.addr()));
#if defined(POCO_HAVE_IPv6)