diff options
author | Stefan Radomski <github@mintwerk.de> | 2016-05-12 13:12:33 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2016-05-12 13:12:33 (GMT) |
commit | b62e7979600feee23dc7cdb61042a8fc7673122b (patch) | |
tree | f7351372f37979dd2d048e0b68a16a4cd3b2aadb /src/uscxml/Common.h | |
parent | 1b11b310be61e51b3ac5ebb83f7c8a33aef3d6e8 (diff) | |
download | uscxml-b62e7979600feee23dc7cdb61042a8fc7673122b.zip uscxml-b62e7979600feee23dc7cdb61042a8fc7673122b.tar.gz uscxml-b62e7979600feee23dc7cdb61042a8fc7673122b.tar.bz2 |
Major Refactoring v2.0
Diffstat (limited to 'src/uscxml/Common.h')
-rw-r--r-- | src/uscxml/Common.h | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/uscxml/Common.h b/src/uscxml/Common.h index 9d35222..5b29427 100644 --- a/src/uscxml/Common.h +++ b/src/uscxml/Common.h @@ -42,9 +42,11 @@ #endif #ifdef _WIN32 -#include <winsock2.h> +typedef unsigned __int32 uint32_t; + // see http://stackoverflow.com/questions/1372480/c-redefinition-header-files #define _WINSOCKAPI_ // stops windows.h including winsock.h +#include <winsock2.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> #undef WIN32_LEAN_AND_MEAN @@ -52,6 +54,57 @@ #include <sys/socket.h> #endif +#define PIMPL_OPERATORS(type) \ +\ +type() : _impl() { }\ +type(const std::shared_ptr<type##Impl> impl) : _impl(impl) { }\ +type(const type& other) : _impl(other._impl) { }\ +virtual ~type() { };\ +\ +operator bool() const {\ + return !!_impl;\ +}\ +bool operator< (const type& other) const {\ + return _impl < other._impl;\ +}\ +bool operator==(const type& other) const {\ + return _impl == other._impl;\ +}\ +bool operator!=(const type& other) const {\ + return _impl != other._impl;\ +}\ +type& operator= (const type& other) {\ + _impl = other._impl;\ + return *this;\ +} + +#define PIMPL_OPERATORS2(type, base) \ +\ +type() : _impl() {}\ +type(std::shared_ptr<type##Impl> const impl) : base(impl), _impl(impl) { }\ +type(const type& other) : base(other._impl), _impl(other._impl) { }\ +virtual ~type() {};\ +\ +operator bool() const {\ + return !!_impl;\ +}\ +bool operator< (const type& other) const {\ + return _impl < other._impl;\ +}\ +bool operator==(const type& other) const {\ + return _impl == other._impl;\ +}\ +bool operator!=(const type& other) const {\ + return _impl != other._impl;\ +}\ +type& operator= (const type& other) {\ + _impl = other._impl;\ + base::_impl = _impl;\ + return *this;\ +} + + + #if defined(_WIN32) inline int setenv(const char *name, const char *value, int overwrite) { int errcode = 0; |