CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef __CONDITION_H 00008 #define __CONDITION_H 00009 00010 #if defined(_LUCENE_PRAGMA_ONCE) 00011 # pragma once 00012 #endif 00013 00014 /* 00015 To enable condition debugging uncomment _CND_DEBUG in CLConfig.h 00016 */ 00017 00018 #ifdef _CL__CND_DEBUG /* Don't include the debug code */ 00019 #ifndef CND_STR_DEFINES 00020 #define CND_STR_DEFINES 00021 #define CND_STR_PRECONDITION 1 00022 #define CND_STR_CONDITION 2 00023 #define CND_STR_WARNING 3 00024 #define CND_STR_MESSAGE 4 00025 #define CND_STR_DEBUGMESSAGE 5 00026 #define CND_STR_EXIT 6 00027 #endif 00028 00029 /* _CL__CND_DEBUG defined, include debug code */ 00030 00031 #ifdef _CND_NODEBUGTEXT 00032 #define CND_PRECONDITION(cond,usermessage) CND__EXITCONDITION(cond,__FILE__,__LINE__,CND_STR_PRECONDITION,NULL) 00033 #define CND_CONDITION(cond,usermessage) CND__EXITCONDITION(cond,__FILE__,__LINE__,CND_STR_CONDITION,NULL) 00034 #define CND_WARNING(cond,usermessage) CND__CONDITION(cond,__FILE__,__LINE__,CND_STR_WARNING,NULL) 00035 #define CND_MESSAGE(cond,usermessage) CND__CONDITION(cond,__FILE__,__LINE__,CND_STR_MESSAGE,NULL) 00036 #define CND_DEBUGMESSAGE(usermessage) CND__MESSAGE(__FILE__,__LINE__,CND_STR_DEBUGMESSAGE,NULL) 00037 #else 00038 #define CND_PRECONDITION(cond,usermessage) CND__EXITCONDITION(cond,__FILE__,__LINE__,CND_STR_PRECONDITION,usermessage) 00039 #define CND_CONDITION(cond,usermessage) CND__EXITCONDITION(cond,__FILE__,__LINE__,CND_STR_CONDITION,usermessage) 00040 #define CND_WARNING(cond,usermessage) CND__CONDITION(cond,__FILE__,__LINE__,CND_STR_WARNING,usermessage) 00041 #define CND_MESSAGE(cond,usermessage) CND__CONDITION(cond,__FILE__,__LINE__,CND_STR_MESSAGE,usermessage) 00042 #define CND_DEBUGMESSAGE(usermessage) CND__MESSAGE(__FILE__,__LINE__,CND_STR_DEBUGMESSAGE,usermessage) 00043 #endif 00044 00045 //if _CND_DEBUG_DONTIMPLEMENT_OUTDEBUG is defined, then you must implement 00046 //this routine in the client application. The debug callback can then 00047 //be better customised to the host application. 00048 //Here is the default implementation: 00049 void _Cnd_OutDebug( const char* FormattedMsg, const char* StrTitle, const char* File, int32_t Line, int32_t Title, const char* Mes2, int32_t fatal ); 00050 00051 void __cnd_FormatDebug( const char* File, int32_t Line, int32_t Title, const char* Mes2, int32_t fatal ); 00052 #define CND__EXIT(file,line,title,mes2) {__cnd_FormatDebug(file,line,title,mes2,1);} 00053 #define CND__EXITCONDITION(cond,file,line,title,mes2) {if(!(cond)){__cnd_FormatDebug(file,line,title,mes2,1);}} 00054 #define CND__CONDITION(cond,file,line,title,mes2) {if(!(cond)){__cnd_FormatDebug(file,line,title,mes2,0);}} 00055 #define CND__MESSAGE(file,line,title,mes2) {__cnd_FormatDebug(file,line,title,mes2,0);} 00056 #else 00057 #define CND_PRECONDITION(cond, usermessage) 00058 #define CND_CONDITION(cond, usermessage) 00059 #define CND_WARNING(cond,usermessage) 00060 #define CND_MESSAGE(cond,usermessage) 00061 #define CND_DEBUGMESSAGE(usermessage) 00062 #endif 00063 00064 #endif