1 | /*------------------------------------------------------------------------------ |
2 | * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team |
3 | * |
4 | * Distributable under the terms of either the Apache License (Version 2.0) or |
5 | * the GNU Lesser General Public License, as specified in the COPYING file. |
6 | ------------------------------------------------------------------------------*/ |
7 | #ifndef __CONDITION_H |
8 | #define __CONDITION_H |
9 | |
10 | #if defined(_LUCENE_PRAGMA_ONCE) |
11 | # pragma once |
12 | #endif |
13 | |
14 | /* |
15 | To enable condition debugging uncomment _CND_DEBUG in CLConfig.h |
16 | */ |
17 | |
18 | #ifdef _CL__CND_DEBUG /* Don't include the debug code */ |
19 | #ifndef CND_STR_DEFINES |
20 | #define CND_STR_DEFINES |
21 | #define CND_STR_PRECONDITION 1 |
22 | #define CND_STR_CONDITION 2 |
23 | #define CND_STR_WARNING 3 |
24 | #define CND_STR_MESSAGE 4 |
25 | #define CND_STR_DEBUGMESSAGE 5 |
26 | #define CND_STR_EXIT 6 |
27 | #endif |
28 | |
29 | /* _CL__CND_DEBUG defined, include debug code */ |
30 | |
31 | #ifdef _CND_NODEBUGTEXT |
32 | #define CND_PRECONDITION(cond,usermessage) CND__EXITCONDITION(cond,__FILE__,__LINE__,CND_STR_PRECONDITION,NULL) |
33 | #define CND_CONDITION(cond,usermessage) CND__EXITCONDITION(cond,__FILE__,__LINE__,CND_STR_CONDITION,NULL) |
34 | #define CND_WARNING(cond,usermessage) CND__CONDITION(cond,__FILE__,__LINE__,CND_STR_WARNING,NULL) |
35 | #define CND_MESSAGE(cond,usermessage) CND__CONDITION(cond,__FILE__,__LINE__,CND_STR_MESSAGE,NULL) |
36 | #define CND_DEBUGMESSAGE(usermessage) CND__MESSAGE(__FILE__,__LINE__,CND_STR_DEBUGMESSAGE,NULL) |
37 | #else |
38 | #define CND_PRECONDITION(cond,usermessage) CND__EXITCONDITION(cond,__FILE__,__LINE__,CND_STR_PRECONDITION,usermessage) |
39 | #define CND_CONDITION(cond,usermessage) CND__EXITCONDITION(cond,__FILE__,__LINE__,CND_STR_CONDITION,usermessage) |
40 | #define CND_WARNING(cond,usermessage) CND__CONDITION(cond,__FILE__,__LINE__,CND_STR_WARNING,usermessage) |
41 | #define CND_MESSAGE(cond,usermessage) CND__CONDITION(cond,__FILE__,__LINE__,CND_STR_MESSAGE,usermessage) |
42 | #define CND_DEBUGMESSAGE(usermessage) CND__MESSAGE(__FILE__,__LINE__,CND_STR_DEBUGMESSAGE,usermessage) |
43 | #endif |
44 | |
45 | //if _CND_DEBUG_DONTIMPLEMENT_OUTDEBUG is defined, then you must implement |
46 | //this routine in the client application. The debug callback can then |
47 | //be better customised to the host application. |
48 | //Here is the default implementation: |
49 | void _Cnd_OutDebug( const char* FormattedMsg, const char* StrTitle, const char* File, int32_t Line, int32_t Title, const char* Mes2, int32_t fatal ); |
50 | |
51 | void __cnd_FormatDebug( const char* File, int32_t Line, int32_t Title, const char* Mes2, int32_t fatal ); |
52 | #define CND__EXIT(file,line,title,mes2) {__cnd_FormatDebug(file,line,title,mes2,1);} |
53 | #define CND__EXITCONDITION(cond,file,line,title,mes2) {if(!(cond)){__cnd_FormatDebug(file,line,title,mes2,1);}} |
54 | #define CND__CONDITION(cond,file,line,title,mes2) {if(!(cond)){__cnd_FormatDebug(file,line,title,mes2,0);}} |
55 | #define CND__MESSAGE(file,line,title,mes2) {__cnd_FormatDebug(file,line,title,mes2,0);} |
56 | #else |
57 | #define CND_PRECONDITION(cond, usermessage) |
58 | #define CND_CONDITION(cond, usermessage) |
59 | #define CND_WARNING(cond,usermessage) |
60 | #define CND_MESSAGE(cond,usermessage) |
61 | #define CND_DEBUGMESSAGE(usermessage) |
62 | #endif |
63 | |
64 | #endif |
65 | |