The R Project SVN R-packages

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7747 ripley 1
#ifndef LIBJSON_GUARD_DEBUG_H
2
#define LIBJSON_GUARD_DEBUG_H
3
 
4
#include "JSONDefs.h"
5
#include "JSONStats.h"
6
 
7
#ifdef JSON_DEBUG
8
    #ifdef JSON_SAFE
9
	   #define JSON_ASSERT_SAFE(condition, msg, code)\
10
		  {\
11
			 if (json_unlikely(!(condition))){\
12
				JSON_FAIL(msg);\
13
				code\
14
			 }\
15
		  }
16
	   #define JSON_FAIL_SAFE(msg, code)\
17
		  {\
18
			 JSON_FAIL(msg);\
19
			 code\
20
		  }
21
    #else
22
	   #define JSON_ASSERT_SAFE(condition, msg, code) JSON_ASSERT(condition, msg)
23
	   #define JSON_FAIL_SAFE(msg, code) JSON_FAIL(msg)
24
    #endif
25
 
26
    #define JSON_FAIL(msg) JSONDebug::_JSON_FAIL(msg)
27
    #define JSON_ASSERT(bo, msg) JSONDebug::_JSON_ASSERT(bo, msg)
28
 
29
    class JSONDebug {
30
    public:
31
	   #ifndef JSON_STDERROR
32
		  static json_error_callback_t register_callback(json_error_callback_t callback) json_nothrow json_cold;
33
	   #endif
34
	   static void _JSON_FAIL(const json_string & msg) json_nothrow json_cold;
35
	   static void _JSON_ASSERT(bool condition, const json_string & msg) json_nothrow json_cold;
36
    };
37
#else
38
    #ifdef JSON_SAFE
39
	   #define JSON_ASSERT_SAFE(condition, msg, code)\
40
		  {\
41
			 if (json_unlikely(!(condition))){\
42
				code\
43
			 }\
44
		  }
45
	   #define JSON_FAIL_SAFE(msg, code)\
46
		  {\
47
			 code\
48
		  }
49
    #else
50
	   #define JSON_ASSERT_SAFE(condition, msg, code)
51
	   #define JSON_FAIL_SAFE(msg, code)
52
    #endif
53
 
54
    #define JSON_ASSERT(condition, msg)
55
    #define JSON_FAIL(msg)
56
#endif
57
 
58
#endif
59