summaryrefslogtreecommitdiffstats
path: root/3rdparty/clucene/src/CLucene/debug/condition.cpp
blob: 855419451cd0c4acca64f319f4ec99b47b864db3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*------------------------------------------------------------------------------
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
* 
* Distributable under the terms of either the Apache License (Version 2.0) or 
* the GNU Lesser General Public License, as specified in the COPYING file.
------------------------------------------------------------------------------*/
#include "CLucene/StdHeader.h"
#include "condition.h"
#include "CLucene/util/Misc.h"
#ifdef _CL__CND_DEBUG

#define __CND_STR_PRECONDITION    "PRECONDITION"
#define __CND_STR_CONDITION       "CONDITION"
#define __CND_STR_WARNING         "WARNING"
#define __CND_STR_MESSAGE         "MESSAGE"
#define __CND_STR_DEBUGMESSAGE    "DEBUG MESSAGE"
#define __CND_STR_EXIT            "EXIT"

#ifndef _CND_DEBUG_DONTIMPLEMENT_OUTDEBUG
void _Cnd_OutDebug( const char* FormattedMsg, const char* StrTitle, const char* File, int32_t Line, int32_t Title, const char* Mes2, int32_t fatal ){
	#ifdef __WINDOWS_H
			/*Display a standard messagebox*/
 			MessageBox(NULL, FormattedMsg, StrTitle, (fatal==1 ? MB_ICONSTOP:MB_ICONEXCLAMATION) | MB_OK | MB_TASKMODAL);
	#else
			printf("%s\n",FormattedMsg);
	#endif

	#if defined(_CND_DEBUG_WARN_DEBUGGER) /*attempt to signal windows debugger*/
			OutputDebugString(FormattedMsg);
			DebugBreak(); /*Position debugger just before exit program*/
	#endif

	if ( fatal )
		debugFatalExit(1);
}
#endif

void __cnd_FormatDebug( const char* File, int32_t Line, int32_t Title, const char* Mes2, int32_t fatal ) {
	char M[512];
    char* StrTitle = NULL;

	if( Mes2 )
		_snprintf(M,512,"file:%s line:%d\n%s",File,Line,Mes2);
	else
		_snprintf(M,512,"file:%s line:%d",File,Line);

    /*Determine which title to use*/
    switch( Title ) {
        case CND_STR_PRECONDITION: {
            StrTitle = __CND_STR_PRECONDITION;
            break;
            }
        case CND_STR_CONDITION: {
            StrTitle = __CND_STR_CONDITION;
            break;
            }
        case CND_STR_WARNING: {
            StrTitle = __CND_STR_WARNING;
            break;
            }
        case CND_STR_MESSAGE: {
	        StrTitle = __CND_STR_MESSAGE;
            break;
            }
        case CND_STR_DEBUGMESSAGE: {
            StrTitle = __CND_STR_DEBUGMESSAGE;
            break;
            }
        case CND_STR_EXIT: {
            StrTitle = __CND_STR_EXIT;
            break;
            }
        default:
            break;
        }/*switch*/

	_Cnd_OutDebug(M, StrTitle, File, Line, Title, Mes2, fatal);
}
#endif