QxOrm  1.4.5
C++ Object Relational Mapping library
QxMacro.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** https://www.qxorm.com/
00004 ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
00005 **
00006 ** This file is part of the QxOrm library
00007 **
00008 ** This software is provided 'as-is', without any express or implied
00009 ** warranty. In no event will the authors be held liable for any
00010 ** damages arising from the use of this software
00011 **
00012 ** Commercial Usage
00013 ** Licensees holding valid commercial QxOrm licenses may use this file in
00014 ** accordance with the commercial license agreement provided with the
00015 ** Software or, alternatively, in accordance with the terms contained in
00016 ** a written agreement between you and Lionel Marty
00017 **
00018 ** GNU General Public License Usage
00019 ** Alternatively, this file may be used under the terms of the GNU
00020 ** General Public License version 3.0 as published by the Free Software
00021 ** Foundation and appearing in the file 'license.gpl3.txt' included in the
00022 ** packaging of this file. Please review the following information to
00023 ** ensure the GNU General Public License version 3.0 requirements will be
00024 ** met : http://www.gnu.org/copyleft/gpl.html
00025 **
00026 ** If you are unsure which license is appropriate for your use, or
00027 ** if you have questions regarding the use of this file, please contact :
00028 ** contact@qxorm.com
00029 **
00030 ****************************************************************************/
00031 
00032 #ifndef _QX_MACRO_H_
00033 #define _QX_MACRO_H_
00034 
00035 #ifdef _MSC_VER
00036 #pragma once
00037 #endif
00038 
00046 #include <QxCommon/QxConfig.h>
00047 
00048 #ifndef qAssert
00049 #if _QX_USE_ASSERT
00050 #define qAssert Q_ASSERT
00051 #else // _QX_USE_ASSERT
00052 #define qAssert(x) /* Nothing */
00053 #endif // _QX_USE_ASSERT
00054 #endif // qAssert
00055 
00056 #ifndef qAssertMsg
00057 #if _QX_USE_ASSERT
00058 #define qAssertMsg(test, where, what) Q_ASSERT_X(test, where, what)
00059 #else // _QX_USE_ASSERT
00060 #define qAssertMsg(test, where, what) /* Nothing */
00061 #endif // _QX_USE_ASSERT
00062 #endif // qAssertMsg
00063 
00064 #ifndef QX_PRAGMA
00065 #ifdef __GNUC__
00066 #define QX_PRAGMA(x) _Pragma( #x )
00067 #endif // __GNUC__
00068 #ifdef _MSC_VER
00069 #define QX_PRAGMA(x) __pragma( x )
00070 #endif // _MSC_VER
00071 #ifndef QX_PRAGMA
00072 #define QX_PRAGMA(x) /* Nothing */
00073 #endif // QX_PRAGMA
00074 #endif // QX_PRAGMA
00075 
00076 #ifndef QX_DLL_EXPORT_HELPER
00077 #ifdef Q_OS_WIN
00078 #define QX_DLL_EXPORT_HELPER __declspec(dllexport)
00079 #elif (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
00080 #define QX_DLL_EXPORT_HELPER __attribute__ ((visibility("default")))
00081 #else
00082 #define QX_DLL_EXPORT_HELPER /* Nothing */
00083 #endif // Q_OS_WIN
00084 #endif // QX_DLL_EXPORT_HELPER
00085 
00086 #ifndef QX_DLL_IMPORT_HELPER
00087 #ifdef Q_OS_WIN
00088 #define QX_DLL_IMPORT_HELPER __declspec(dllimport)
00089 #elif (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
00090 #define QX_DLL_IMPORT_HELPER __attribute__ ((visibility("default")))
00091 #else
00092 #define QX_DLL_IMPORT_HELPER /* Nothing */
00093 #endif // Q_OS_WIN
00094 #endif // QX_DLL_IMPORT_HELPER
00095 
00096 #ifdef __GNUC__
00097 #if _QX_USE_GCC_EXPORT_ALL_SYMBOLS
00098 #undef QX_DLL_EXPORT_HELPER
00099 #undef QX_DLL_IMPORT_HELPER
00100 #define QX_DLL_EXPORT_HELPER /* Nothing */
00101 #define QX_DLL_IMPORT_HELPER /* Nothing */
00102 #endif // _QX_USE_GCC_EXPORT_ALL_SYMBOLS
00103 #endif // __GNUC__
00104 
00105 #ifdef _QX_STATIC_BUILD
00106 #undef QX_DLL_EXPORT_HELPER
00107 #undef QX_DLL_IMPORT_HELPER
00108 #define QX_DLL_EXPORT_HELPER /* Nothing */
00109 #define QX_DLL_IMPORT_HELPER /* Nothing */
00110 #endif // _QX_STATIC_BUILD
00111 
00112 #ifndef QX_DLL_INTERNAL_HELPER
00113 #if (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
00114 #define QX_DLL_INTERNAL_HELPER __attribute__ ((visibility("hidden")))
00115 #else
00116 #define QX_DLL_INTERNAL_HELPER /* Nothing */
00117 #endif // (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
00118 #endif // QX_DLL_INTERNAL_HELPER
00119 
00120 #ifndef QX_DLL_EXPORT_TEMPLATE_HELPER
00121 #ifdef _MSC_VER
00122 #define QX_DLL_EXPORT_TEMPLATE_HELPER QX_DLL_EXPORT_HELPER
00123 #else // _MSC_VER
00124 #define QX_DLL_EXPORT_TEMPLATE_HELPER /* Nothing */
00125 #endif // _MSC_VER
00126 #endif // QX_DLL_EXPORT_TEMPLATE_HELPER
00127 
00128 #ifndef QX_DLL_IMPORT_TEMPLATE_HELPER
00129 #ifdef _MSC_VER
00130 #define QX_DLL_IMPORT_TEMPLATE_HELPER QX_DLL_IMPORT_HELPER
00131 #else // _MSC_VER
00132 #define QX_DLL_IMPORT_TEMPLATE_HELPER /* Nothing */
00133 #endif // _MSC_VER
00134 #endif // QX_DLL_IMPORT_TEMPLATE_HELPER
00135 
00136 #ifndef QX_PRAGMA_VISIBILITY_BEGIN
00137 #ifndef Q_OS_WIN
00138 #if (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
00139 #define QX_PRAGMA_VISIBILITY_BEGIN QX_PRAGMA(GCC visibility push( default ))
00140 #endif // (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
00141 #endif // Q_OS_WIN
00142 #ifndef QX_PRAGMA_VISIBILITY_BEGIN
00143 #define QX_PRAGMA_VISIBILITY_BEGIN /* Nothing */
00144 #endif // QX_PRAGMA_VISIBILITY_BEGIN
00145 #endif // QX_PRAGMA_VISIBILITY_BEGIN
00146 
00147 #ifndef QX_PRAGMA_VISIBILITY_END
00148 #ifndef Q_OS_WIN
00149 #if (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
00150 #define QX_PRAGMA_VISIBILITY_END QX_PRAGMA(GCC visibility pop)
00151 #endif // (_QX_USE_GCC_VISIBILITY && (__GNUC__ >= 4))
00152 #endif // Q_OS_WIN
00153 #ifndef QX_PRAGMA_VISIBILITY_END
00154 #define QX_PRAGMA_VISIBILITY_END /* Nothing */
00155 #endif // QX_PRAGMA_VISIBILITY_END
00156 #endif // QX_PRAGMA_VISIBILITY_END
00157 
00158 #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
00159 #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
00160 #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
00161 #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
00162 #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
00163 
00164 #define QX_DLL_EXPORT_TEMPLATE_CPP(CL, T) QX_PRAGMA_VISIBILITY_BEGIN template CL QX_DLL_EXPORT_TEMPLATE_HELPER T; QX_PRAGMA_VISIBILITY_END
00165 #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
00166 #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
00167 #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
00168 #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
00169 
00170 #define QX_TEMPLATE_T(T) T<>
00171 #define QX_TEMPLATE_T_P1(T, P1) T< P1 >
00172 #define QX_TEMPLATE_T_P1_P2(T, P1, P2) T< P1, P2 >
00173 #define QX_TEMPLATE_T_P1_P2_P3(T, P1, P2, P3) T< P1, P2, P3 >
00174 #define QX_TEMPLATE_T_U_P1(T, U, P1) T< U< P1 > >
00175 #define QX_TEMPLATE_T_U_P1_P2(T, U, P1, P2) T< U< P1, P2 > >
00176 #define QX_TEMPLATE_T_U_P1_P2_P3(T, U, P1, P2, P3) T< U< P1, P2, P3 > >
00177 
00178 #ifndef QX_DLL_EXPORT
00179 #ifdef _QX_BUILDING_QX_ORM
00180 #define QX_DLL_EXPORT QX_DLL_EXPORT_HELPER
00181 #else // _QX_BUILDING_QX_ORM
00182 #define QX_DLL_EXPORT QX_DLL_IMPORT_HELPER
00183 #endif // _QX_BUILDING_QX_ORM
00184 #endif // QX_DLL_EXPORT
00185 
00186 #ifndef QX_DLL_EXPORT_QX_SINGLETON_HPP
00187 #ifdef _QX_BUILDING_QX_ORM
00188 #define QX_DLL_EXPORT_QX_SINGLETON_HPP(x) /* Nothing */
00189 #else // _QX_BUILDING_QX_ORM
00190 #define QX_DLL_EXPORT_QX_SINGLETON_HPP(x) QX_DLL_EXPORT_TEMPLATE_HPP(class, qx::QxSingleton< x >)
00191 #endif // _QX_BUILDING_QX_ORM
00192 #endif // QX_DLL_EXPORT_QX_SINGLETON_HPP
00193 
00194 #ifndef QX_DLL_EXPORT_QX_SINGLETON_CPP
00195 #ifdef _QX_BUILDING_QX_ORM
00196 #define QX_DLL_EXPORT_QX_SINGLETON_CPP(x) QX_DLL_EXPORT_TEMPLATE_CPP(class, qx::QxSingleton< x >)
00197 #else // _QX_BUILDING_QX_ORM
00198 #define QX_DLL_EXPORT_QX_SINGLETON_CPP(x) /* Nothing */
00199 #endif // _QX_BUILDING_QX_ORM
00200 #endif // QX_DLL_EXPORT_QX_SINGLETON_CPP
00201 
00202 #ifndef QX_DLL_EXPORT_INLINE_FCT
00203 #ifdef _MSC_VER
00204 #define QX_DLL_EXPORT_INLINE_FCT QX_DLL_EXPORT
00205 #else // _MSC_VER
00206 #define QX_DLL_EXPORT_INLINE_FCT /* Nothing */
00207 #endif // _MSC_VER
00208 #endif // QX_DLL_EXPORT_INLINE_FCT
00209 
00210 #ifdef __GNUC__
00211 #define QX_GCC_WORKAROUND_TEMPLATE_SPEC_INLINE inline
00212 #else
00213 #define QX_GCC_WORKAROUND_TEMPLATE_SPEC_INLINE /* Nothing */
00214 #endif // __GNUC__
00215 
00216 #ifdef _MSC_VER
00217 #define QX_STRNCPY strncpy_s
00218 #define QX_VSPRINTF vsprintf_s
00219 #else // _MSC_VER
00220 #define QX_STRNCPY strncpy
00221 #define QX_VSPRINTF vsprintf
00222 #endif // _MSC_VER
00223 
00224 #ifdef _QX_MODE_RELEASE
00225 #ifndef NDEBUG
00226 #define NDEBUG
00227 #endif // NDEBUG
00228 #endif // _QX_MODE_RELEASE
00229 
00230 // From file <boost/serialization/force_include.hpp> (written by Robert Ramey)
00231 #if ! defined(_WIN32) && ! defined(_WIN64)
00232 #   if defined(__GNUC__) && (__GNUC__ >= 3)
00233 #       define QX_USED __attribute__ ((__used__))
00234 #   elif defined(__IBMCPP__) && (__IBMCPP__ >= 1110)
00235 #       define QX_USED __attribute__ ((__used__))
00236 #   elif defined(__INTEL_COMPILER)
00237 #       define QX_USED __attribute__ ((__used__))
00238 #   endif
00239 #endif // ! defined(_WIN32) && ! defined(_WIN64)
00240 
00241 #ifndef QX_USED
00242 #define QX_USED /* Nothing */
00243 #endif // QX_USED
00244 
00245 #endif // _QX_MACRO_H_