QxMacro.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /****************************************************************************
  2. **
  3. ** https://www.qxorm.com/
  4. ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
  5. **
  6. ** This file is part of the QxOrm library
  7. **
  8. ** This software is provided 'as-is', without any express or implied
  9. ** warranty. In no event will the authors be held liable for any
  10. ** damages arising from the use of this software
  11. **
  12. ** Commercial Usage
  13. ** Licensees holding valid commercial QxOrm licenses may use this file in
  14. ** accordance with the commercial license agreement provided with the
  15. ** Software or, alternatively, in accordance with the terms contained in
  16. ** a written agreement between you and Lionel Marty
  17. **
  18. ** GNU General Public License Usage
  19. ** Alternatively, this file may be used under the terms of the GNU
  20. ** General Public License version 3.0 as published by the Free Software
  21. ** Foundation and appearing in the file 'license.gpl3.txt' included in the
  22. ** packaging of this file. Please review the following information to
  23. ** ensure the GNU General Public License version 3.0 requirements will be
  24. ** met : http://www.gnu.org/copyleft/gpl.html
  25. **
  26. ** If you are unsure which license is appropriate for your use, or
  27. ** if you have questions regarding the use of this file, please contact :
  28. ** contact@qxorm.com
  29. **
  30. ****************************************************************************/
  31. #ifndef _QX_MACRO_H_
  32. #define _QX_MACRO_H_
  33. #ifdef _MSC_VER
  34. #pragma once
  35. #endif
  36. /*!
  37. * \file QxMacro.h
  38. * \author Lionel Marty
  39. * \ingroup QxCommon
  40. * \brief List of common macros used by QxOrm library
  41. */
  42. #include <QxCommon/QxConfig.h>
  43. #ifndef qAssert
  44. #if _QX_USE_ASSERT
  45. #define qAssert Q_ASSERT
  46. #else // _QX_USE_ASSERT
  47. #define qAssert(x) /* Nothing */
  48. #endif // _QX_USE_ASSERT
  49. #endif // qAssert
  50. #ifndef qAssertMsg
  51. #if _QX_USE_ASSERT
  52. #define qAssertMsg(test, where, what) Q_ASSERT_X(test, where, what)
  53. #else // _QX_USE_ASSERT
  54. #define qAssertMsg(test, where, what) /* Nothing */
  55. #endif // _QX_USE_ASSERT
  56. #endif // qAssertMsg
  57. #ifndef QX_PRAGMA
  58. #ifdef __GNUC__
  59. #define QX_PRAGMA(x) _Pragma( #x )
  60. #endif // __GNUC__
  61. #ifdef _MSC_VER
  62. #define QX_PRAGMA(x) __pragma( x )
  63. #endif // _MSC_VER
  64. #ifndef QX_PRAGMA
  65. #define QX_PRAGMA(x) /* Nothing */
  66. #endif // QX_PRAGMA
  67. #endif // QX_PRAGMA
  68. #ifndef QX_DLL_EXPORT_HELPER
  69. #ifdef Q_OS_WIN
  70. #define QX_DLL_EXPORT_HELPER __declspec(dllexport)
  71. #elif (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
  72. #define QX_DLL_EXPORT_HELPER __attribute__ ((visibility("default")))
  73. #else
  74. #define QX_DLL_EXPORT_HELPER /* Nothing */
  75. #endif // Q_OS_WIN
  76. #endif // QX_DLL_EXPORT_HELPER
  77. #ifndef QX_DLL_IMPORT_HELPER
  78. #ifdef Q_OS_WIN
  79. #define QX_DLL_IMPORT_HELPER __declspec(dllimport)
  80. #elif (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
  81. #define QX_DLL_IMPORT_HELPER __attribute__ ((visibility("default")))
  82. #else
  83. #define QX_DLL_IMPORT_HELPER /* Nothing */
  84. #endif // Q_OS_WIN
  85. #endif // QX_DLL_IMPORT_HELPER
  86. #ifdef __GNUC__
  87. #if _QX_USE_GCC_EXPORT_ALL_SYMBOLS
  88. #undef QX_DLL_EXPORT_HELPER
  89. #undef QX_DLL_IMPORT_HELPER
  90. #define QX_DLL_EXPORT_HELPER /* Nothing */
  91. #define QX_DLL_IMPORT_HELPER /* Nothing */
  92. #endif // _QX_USE_GCC_EXPORT_ALL_SYMBOLS
  93. #endif // __GNUC__
  94. #ifdef _QX_STATIC_BUILD
  95. #undef QX_DLL_EXPORT_HELPER
  96. #undef QX_DLL_IMPORT_HELPER
  97. #define QX_DLL_EXPORT_HELPER /* Nothing */
  98. #define QX_DLL_IMPORT_HELPER /* Nothing */
  99. #endif // _QX_STATIC_BUILD
  100. #ifndef QX_DLL_INTERNAL_HELPER
  101. #if (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
  102. #define QX_DLL_INTERNAL_HELPER __attribute__ ((visibility("hidden")))
  103. #else
  104. #define QX_DLL_INTERNAL_HELPER /* Nothing */
  105. #endif // (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
  106. #endif // QX_DLL_INTERNAL_HELPER
  107. #ifndef QX_DLL_EXPORT_TEMPLATE_HELPER
  108. #ifdef _MSC_VER
  109. #define QX_DLL_EXPORT_TEMPLATE_HELPER QX_DLL_EXPORT_HELPER
  110. #else // _MSC_VER
  111. #define QX_DLL_EXPORT_TEMPLATE_HELPER /* Nothing */
  112. #endif // _MSC_VER
  113. #endif // QX_DLL_EXPORT_TEMPLATE_HELPER
  114. #ifndef QX_DLL_IMPORT_TEMPLATE_HELPER
  115. #ifdef _MSC_VER
  116. #define QX_DLL_IMPORT_TEMPLATE_HELPER QX_DLL_IMPORT_HELPER
  117. #else // _MSC_VER
  118. #define QX_DLL_IMPORT_TEMPLATE_HELPER /* Nothing */
  119. #endif // _MSC_VER
  120. #endif // QX_DLL_IMPORT_TEMPLATE_HELPER
  121. #ifndef QX_PRAGMA_VISIBILITY_BEGIN
  122. #ifndef Q_OS_WIN
  123. #if (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
  124. #define QX_PRAGMA_VISIBILITY_BEGIN QX_PRAGMA(GCC visibility push( default ))
  125. #endif // (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
  126. #endif // Q_OS_WIN
  127. #ifndef QX_PRAGMA_VISIBILITY_BEGIN
  128. #define QX_PRAGMA_VISIBILITY_BEGIN /* Nothing */
  129. #endif // QX_PRAGMA_VISIBILITY_BEGIN
  130. #endif // QX_PRAGMA_VISIBILITY_BEGIN
  131. #ifndef QX_PRAGMA_VISIBILITY_END
  132. #ifndef Q_OS_WIN
  133. #if (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
  134. #define QX_PRAGMA_VISIBILITY_END QX_PRAGMA(GCC visibility pop)
  135. #endif // (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
  136. #endif // Q_OS_WIN
  137. #ifndef QX_PRAGMA_VISIBILITY_END
  138. #define QX_PRAGMA_VISIBILITY_END /* Nothing */
  139. #endif // QX_PRAGMA_VISIBILITY_END
  140. #endif // QX_PRAGMA_VISIBILITY_END
  141. #define QX_DLL_EXPORT_TEMPLATE_HPP(CL, T) QX_PRAGMA_VISIBILITY_BEGIN extern template CL QX_DLL_IMPORT_TEMPLATE_HELPER T; QX_PRAGMA_VISIBILITY_END
  142. #define QX_DLL_EXPORT_TEMPLATE_T_P1_HPP(CL, T, P1) QX_PRAGMA_VISIBILITY_BEGIN extern template CL QX_DLL_IMPORT_TEMPLATE_HELPER T< P1 >; QX_PRAGMA_VISIBILITY_END
  143. #define QX_DLL_EXPORT_TEMPLATE_T_U_P1_HPP(CL, T, U, P1) QX_PRAGMA_VISIBILITY_BEGIN extern template CL QX_DLL_IMPORT_TEMPLATE_HELPER T< U< P1 > >; QX_PRAGMA_VISIBILITY_END
  144. #define QX_DLL_EXPORT_TEMPLATE_T_P1_P2_HPP(CL, T, P1, P2) QX_PRAGMA_VISIBILITY_BEGIN extern template CL QX_DLL_IMPORT_TEMPLATE_HELPER T< P1, P2 >; QX_PRAGMA_VISIBILITY_END
  145. #define QX_DLL_EXPORT_TEMPLATE_T_U_P1_P2_HPP(CL, T, U, P1, P2) QX_PRAGMA_VISIBILITY_BEGIN extern template CL QX_DLL_IMPORT_TEMPLATE_HELPER T< U< P1, P2 > >; QX_PRAGMA_VISIBILITY_END
  146. #define QX_DLL_EXPORT_TEMPLATE_CPP(CL, T) QX_PRAGMA_VISIBILITY_BEGIN template CL QX_DLL_EXPORT_TEMPLATE_HELPER T; QX_PRAGMA_VISIBILITY_END
  147. #define QX_DLL_EXPORT_TEMPLATE_T_P1_CPP(CL, T, P1) QX_PRAGMA_VISIBILITY_BEGIN template CL QX_DLL_EXPORT_TEMPLATE_HELPER T< P1 >; QX_PRAGMA_VISIBILITY_END
  148. #define QX_DLL_EXPORT_TEMPLATE_T_U_P1_CPP(CL, T, U, P1) QX_PRAGMA_VISIBILITY_BEGIN template CL QX_DLL_EXPORT_TEMPLATE_HELPER T< U< P1 > >; QX_PRAGMA_VISIBILITY_END
  149. #define QX_DLL_EXPORT_TEMPLATE_T_P1_P2_CPP(CL, T, P1, P2) QX_PRAGMA_VISIBILITY_BEGIN template CL QX_DLL_EXPORT_TEMPLATE_HELPER T< P1, P2 >; QX_PRAGMA_VISIBILITY_END
  150. #define QX_DLL_EXPORT_TEMPLATE_T_U_P1_P2_CPP(CL, T, U, P1, P2) QX_PRAGMA_VISIBILITY_BEGIN template CL QX_DLL_EXPORT_TEMPLATE_HELPER T< U< P1, P2 > >; QX_PRAGMA_VISIBILITY_END
  151. #define QX_TEMPLATE_T(T) T<>
  152. #define QX_TEMPLATE_T_P1(T, P1) T< P1 >
  153. #define QX_TEMPLATE_T_P1_P2(T, P1, P2) T< P1, P2 >
  154. #define QX_TEMPLATE_T_P1_P2_P3(T, P1, P2, P3) T< P1, P2, P3 >
  155. #define QX_TEMPLATE_T_U_P1(T, U, P1) T< U< P1 > >
  156. #define QX_TEMPLATE_T_U_P1_P2(T, U, P1, P2) T< U< P1, P2 > >
  157. #define QX_TEMPLATE_T_U_P1_P2_P3(T, U, P1, P2, P3) T< U< P1, P2, P3 > >
  158. #ifndef QX_DLL_EXPORT
  159. #ifdef _QX_BUILDING_QX_ORM
  160. #define QX_DLL_EXPORT QX_DLL_EXPORT_HELPER
  161. #else // _QX_BUILDING_QX_ORM
  162. #define QX_DLL_EXPORT QX_DLL_IMPORT_HELPER
  163. #endif // _QX_BUILDING_QX_ORM
  164. #endif // QX_DLL_EXPORT
  165. #ifndef QX_DLL_EXPORT_QX_SINGLETON_HPP
  166. #ifdef _QX_BUILDING_QX_ORM
  167. #define QX_DLL_EXPORT_QX_SINGLETON_HPP(x) /* Nothing */
  168. #else // _QX_BUILDING_QX_ORM
  169. #define QX_DLL_EXPORT_QX_SINGLETON_HPP(x) QX_DLL_EXPORT_TEMPLATE_HPP(class, qx::QxSingleton< x >)
  170. #endif // _QX_BUILDING_QX_ORM
  171. #endif // QX_DLL_EXPORT_QX_SINGLETON_HPP
  172. #ifndef QX_DLL_EXPORT_QX_SINGLETON_CPP
  173. #ifdef _QX_BUILDING_QX_ORM
  174. #define QX_DLL_EXPORT_QX_SINGLETON_CPP(x) QX_DLL_EXPORT_TEMPLATE_CPP(class, qx::QxSingleton< x >)
  175. #else // _QX_BUILDING_QX_ORM
  176. #define QX_DLL_EXPORT_QX_SINGLETON_CPP(x) /* Nothing */
  177. #endif // _QX_BUILDING_QX_ORM
  178. #endif // QX_DLL_EXPORT_QX_SINGLETON_CPP
  179. #ifndef QX_DLL_EXPORT_INLINE_FCT
  180. #ifdef _MSC_VER
  181. #define QX_DLL_EXPORT_INLINE_FCT QX_DLL_EXPORT
  182. #else // _MSC_VER
  183. #define QX_DLL_EXPORT_INLINE_FCT /* Nothing */
  184. #endif // _MSC_VER
  185. #endif // QX_DLL_EXPORT_INLINE_FCT
  186. #ifdef __GNUC__
  187. #define QX_GCC_WORKAROUND_TEMPLATE_SPEC_INLINE inline
  188. #else
  189. #define QX_GCC_WORKAROUND_TEMPLATE_SPEC_INLINE /* Nothing */
  190. #endif // __GNUC__
  191. #ifdef _MSC_VER
  192. #define QX_STRNCPY strncpy_s
  193. #define QX_VSPRINTF vsprintf_s
  194. #else // _MSC_VER
  195. #define QX_STRNCPY strncpy
  196. #define QX_VSPRINTF vsprintf
  197. #endif // _MSC_VER
  198. #ifdef _QX_MODE_RELEASE
  199. #ifndef NDEBUG
  200. #define NDEBUG
  201. #endif // NDEBUG
  202. #endif // _QX_MODE_RELEASE
  203. // From file <boost/serialization/force_include.hpp> (written by Robert Ramey)
  204. #if ! defined(_WIN32) && ! defined(_WIN64)
  205. # if defined(__GNUC__) && (__GNUC__ >= 3)
  206. # define QX_USED __attribute__ ((__used__))
  207. # elif defined(__IBMCPP__) && (__IBMCPP__ >= 1110)
  208. # define QX_USED __attribute__ ((__used__))
  209. # elif defined(__INTEL_COMPILER)
  210. # define QX_USED __attribute__ ((__used__))
  211. # endif
  212. #endif // ! defined(_WIN32) && ! defined(_WIN64)
  213. #ifndef QX_USED
  214. #define QX_USED /* Nothing */
  215. #endif // QX_USED
  216. #ifdef QT_NO_OPENSSL
  217. #ifndef QT_NO_SSL
  218. #define QT_NO_SSL /* Nothing */
  219. #endif // QT_NO_SSL
  220. #endif // QT_NO_OPENSSL
  221. #endif // _QX_MACRO_H_