Common.h
Go to the documentation of this file.
1 
20 #ifndef COMMON_H_YZ3CIYP
21 #define COMMON_H_YZ3CIYP
22 
23 #define XERCESC_NS xercesc_3_1
24 
25 #ifndef _MSC_VER
26 #define ELPP_STACKTRACE_ON_CRASH 1
27 #endif
28 
29 #if __cplusplus >= 201402L
30 #define DEPRECATED [[deprecated]]
31 #elif defined(__GNUC__)
32 #define DEPRECATED __attribute__((deprecated))
33 #elif defined(_MSC_VER)
34 #define DEPRECATED __declspec(deprecated)
35 #else
36 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
37 #define DEPRECATED(alternative)
38 #endif
39 
40 #if defined(_WIN32) && !defined(USCXML_STATIC)
41 # ifdef USCXML_EXPORT
42 # define USCXML_API __declspec(dllexport)
43 # else
44 # define USCXML_API __declspec(dllimport)
45 # endif
46 #else
47 # define USCXML_API
48 #endif
49 
50 #ifdef _WIN32
51 #define NOMINMAX
52 
53 typedef unsigned __int32 uint32_t;
54 
55 // see http://stackoverflow.com/questions/1372480/c-redefinition-header-files
56 #define _WINSOCKAPI_ // stops windows.h including winsock.h
57 #include <winsock2.h>
58 #define WIN32_LEAN_AND_MEAN
59 #include <windows.h>
60 #undef WIN32_LEAN_AND_MEAN
61 #else
62 #include <sys/socket.h>
63 #endif
64 
68 #define PIMPL_OPERATORS(type) \
69 type() : _impl() { } \
70 type(const std::shared_ptr<type##Impl> impl) : _impl(impl) { }\
71 type(const type& other) : _impl(other._impl) { }\
72 virtual ~type() { };\
73 \
74 operator bool() const {\
75  return !!_impl;\
76 }\
77 bool operator< (const type& other) const {\
78  return _impl < other._impl;\
79 }\
80 bool operator==(const type& other) const {\
81  return _impl == other._impl;\
82 }\
83 bool operator!=(const type& other) const {\
84  return _impl != other._impl;\
85 }\
86 type& operator= (const type& other) {\
87  _impl = other._impl;\
88  return *this;\
89 }
90 
91 #define PIMPL_OPERATORS_INHERIT(type, base) \
92 type() : _impl() {}\
93 type(std::shared_ptr<type##Impl> const impl);\
94 type(const type& other);\
95 virtual ~type() {};\
96 \
97 operator bool() const {\
98  return !!_impl;\
99 }\
100 bool operator< (const type& other) const {\
101  return _impl < other._impl;\
102 }\
103 bool operator==(const type& other) const {\
104  return _impl == other._impl;\
105 }\
106 bool operator!=(const type& other) const {\
107  return _impl != other._impl;\
108 }\
109 type& operator= (const type& other);
110 
111 
112 #define PIMPL_OPERATORS_INHERIT_IMPL(type, base) \
113 type::type(std::shared_ptr<type##Impl> const impl) : base(impl), _impl(impl) { }\
114 type::type(const type& other) : base(other._impl), _impl(other._impl) { }\
115 type& type::operator= (const type& other) {\
116  _impl = other._impl;\
117  base::_impl = _impl;\
118  return *this;\
119 }
120 
121 
122 #if defined(_WIN32)
123 inline int setenv(const char *name, const char *value, int overwrite) {
124  int errcode = 0;
125  if(!overwrite) {
126  size_t envsize = 0;
127  errcode = getenv_s(&envsize, NULL, 0, name);
128  if(errcode || envsize) return errcode;
129  }
130  return _putenv_s(name, value);
131 }
132 #endif
133 
134 #define _USE_MATH_DEFINES
135 #include <cmath>
136 
137 #if defined(_MSC_VER)
138 // disable signed / unsigned comparison warnings
139 #pragma warning (disable : 4018)
140 // possible loss of data
141 #pragma warning (disable : 4244)
142 #pragma warning (disable : 4267)
143 // 'this' : used in base member initializer list
144 #pragma warning (disable : 4355)
145 
146 // is thrown alot in arabica headers
147 #pragma warning (disable : 4240)
148 #pragma warning (disable : 4250)
149 #pragma warning (disable : 4661)
150 
151 // dll interface
152 #pragma warning (disable : 4251)
153 
154 #endif
155 
156 
157 #endif /* end of include guard: COMMON_H_YZ3CIYP */