00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00069
00070 #ifndef FS_SYS_FSASSERT_H
00071 #define FS_SYS_FSASSERT_H
00072
00073 #if defined(FS_INCLUDE_USERDEFS) // inject user definition file on request
00074 # include <fs/fsUserDefs.h>
00075 #endif
00076
00077
00078
00079 #if !defined(FS_MMGR_USERDEFS) // define to overwrite default definitions
00080 # if !defined(NDEBUG)
00082
00084 # define FS_ASSERT_LABEL "FIPS' ASSERT WARNING"
00086
00090 # define FS_ASSERT_ENABLE_BOX
00092
00096 # define FS_ASSERT_ENABLE_BEEP
00097 # endif // NDEBUG
00098 #endif // FS_MMGR_USERDEFS
00099
00100
00101
00102 #if !defined(__FUNCTION__)
00103 # define __FUNCTION__ "???" // MSVC feature
00104 #endif
00105
00106 namespace fs { namespace sys { namespace asr {
00107
00108 #if defined(_WIN32) && defined(FS_ASSERT_ENABLE_BOX)
00110 bool BoxWin(const char *, const char *, const char *, const char *, int);
00111 #endif
00112
00113 #if defined(_WIN32) && defined(FS_ASSERT_ENABLE_BEEP)
00115 void BeepWin();
00116 #endif
00117
00118 #if defined(UNDER_CE) && defined(FS_ASSERT_ENABLE_BOX)
00120 void BreakWce();
00121 #endif
00122
00123 }}}
00124
00125 #if defined(FS_ASSERT_ENABLE_BOX)
00126 # if defined(UNDER_CE)
00127 # define FS_ASSERT_BREAK { fs::sys::asr::BreakWce(); }
00128 # elif defined(_WIN32)
00129 # define FS_ASSERT_BREAK __asm int 3
00130 # else
00131 # define FS_ASSERT_BREAK {}
00132 # endif
00133 #endif
00134
00135 #if defined(FS_ASSERT_ENABLE_BOX)
00136 # if defined(_WIN32)
00137 # define FS_ASSERT_MSG(exp, msg) \
00138 { \
00139 bool bExp = (exp) ? true : false; \
00140 if(!bExp && fs::sys::asr::BoxWin(#exp, msg, __FUNCTION__, \
00141 __FILE__, __LINE__)) FS_ASSERT_BREAK \
00142 }
00143 # else
00144 # define FS_ASSERT_MSG(exp, msg) assert(exp && msg)
00145 # endif
00146 #else
00147 # define FS_ASSERT_MSG(exp, msg) (void(0))
00148 #endif
00149
00150 #define FS_ASSERT(exp) FS_ASSERT_MSG(exp, 0)
00151
00152 #if defined(FS_ASSERT_ENABLE_BEEP)
00153 # if defined(_WIN32)
00154 # define FS_ASSERT_BEEP(exp) \
00155 { \
00156 bool bExp = (exp) ? true : false; \
00157 if(!bExp) fs::sys::asr::BeepWin(); \
00158 }
00159 # else
00160 # define FS_ASSERT_BEEP(exp) (void(0))
00161 # endif
00162 #else
00163 # define FS_ASSERT_BEEP(exp) (void(0))
00164 #endif
00165
00166 #if defined(FS_ASSERT_ENABLE_BOX)
00167 # define FS_VERIFY(exp) FS_ASSERT(exp)
00168 #else
00169 # define FS_VERIFY(exp) (void(exp))
00170 #endif
00171
00172 #if defined(FS_ASSERT_ENABLE_BOX)
00173 # define FS_VERIFY_MSG(exp, msg) FS_ASSERT_MSG(exp, msg)
00174 #else
00175 # define FS_VERIFY_MSG(exp, msg) (void(exp))
00176 #endif
00177
00178 #if defined(FS_ASSERT_ENABLE_BEEP)
00179 # define FS_VERIFY_BEEP(exp) FS_ASSERT_BEEP(exp)
00180 #else
00181 # define FS_VERIFY_BEEP(exp) (void(exp))
00182 #endif
00183
00184 template<bool> struct FS_STATIC_ASSERT___E_R_R_O_R___;
00186 template<> struct FS_STATIC_ASSERT___E_R_R_O_R___<true> {};
00187 #define FS_STATIC_ASSERT(exp) \
00188 ( (FS_STATIC_ASSERT___E_R_R_O_R___<(exp) != 0>()) )
00189
00190 #endif // FS_SYS_FSASSERT_H