Jamoma API  0.6.0.a19
JSONDefs.h
1 #ifndef JSONDEFS_H
2 #define JSONDEFS_H
3 
4 /*
5  Defines all of the types of functions and various other definitions
6  that are used in C applications, this is very useful if dynamically loading
7  the library instead of linking.
8 */
9 
10 #include "../../JSONOptions.h"
11 #include "JSONDefs/Unknown_C.h"
12 #include "JSONDefs/GNU_C.h"
13 #include "JSONDefs/Visual_C.h"
14 #include "JSONDefs/Strings_Defs.h"
15 
16 #define __LIBJSON_MAJOR__ 7
17 #define __LIBJSON_MINOR__ 6
18 #define __LIBJSON_PATCH__ 1
19 #define __LIBJSON_VERSION__ (__LIBJSON_MAJOR__ * 10000 + __LIBJSON_MINOR__ * 100 + __LIBJSON_PATCH__)
20 
21 #define JSON_NULL '\0'
22 #define JSON_STRING '\1'
23 #define JSON_NUMBER '\2'
24 #define JSON_BOOL '\3'
25 #define JSON_ARRAY '\4'
26 #define JSON_NODE '\5'
27 
28 #ifdef __cplusplus
29  #if defined(JSON_MEMORY_CALLBACKS) || defined(JSON_MEMORY_POOL)
30  #include "JSONAllocator.h"
31  #else
32  #define json_allocator std::allocator
33  #endif
34 
35  #ifdef JSON_STRING_HEADER
36  #include JSON_STRING_HEADER
37  #else
38  typedef std::basic_string<json_char, std::char_traits<json_char>, json_allocator<json_char> > json_string;
39  #endif
40 #endif
41 #define JSON_MAP(x, y) std::map<x, y, std::less<x>, json_allocator<std::pair<const x, y> > >
42 
43 #ifdef JSON_NO_EXCEPTIONS
44  #define json_throw(x)
45  #define json_try
46  #define json_catch(exception, code)
47 #else
48  #define json_throw(x) throw(x)
49  #define json_try try
50  #define json_catch(exception, code) catch(exception){ code }
51 #endif
52 
53 #ifdef JSON_STRICT
54  #ifndef JSON_UNICODE
55  #error, JSON_UNICODE is required for JSON_STRICT
56  #endif
57  #ifdef JSON_COMMENTS
58  #error, JSON_COMMENTS is required to be off for JSON_STRICT
59  #endif
60 #endif
61 
62 #ifdef JSON_ISO_STRICT
63  #ifdef JSON_UNICODE
64  #error, You can not use unicode under ANSI Strict C++
65  #endif
66 #else
67  #ifdef __GNUC__
68  #ifdef __STRICT_ANSI__
69  #warning, Using -ansi GCC option, but JSON_ISO_STRICT not on, turning it on for you
70  #define JSON_ISO_STRICT
71  #endif
72  #endif
73 #endif
74 
75 
76 #ifdef JSON_NUMBER_TYPE
77  typedef JSON_NUMBER_TYPE json_number;
78  #define JSON_FLOAT_THRESHHOLD 0.00001
79 #else
80  #ifdef JSON_LESS_MEMORY
81  typedef float json_number;
82  #define JSON_FLOAT_THRESHHOLD 0.00001f
83  #else
84  typedef double json_number;
85  #define JSON_FLOAT_THRESHHOLD 0.00001
86  #endif
87 #endif
88 
89 
90 #ifdef JSON_LESS_MEMORY
91  /* PACKED and BITS stored in compiler specific headers */
92  #define START_MEM_SCOPE {
93  #define END_MEM_SCOPE }
94 #else
95  #define PACKED(x)
96  #define BITS(x)
97  #define START_MEM_SCOPE
98  #define END_MEM_SCOPE
99 #endif
100 
101 #if defined JSON_DEBUG || defined JSON_SAFE
102  #ifdef JSON_LIBRARY
103  typedef void (*json_error_callback_t)(const json_char *);
104  #else
105  typedef void (*json_error_callback_t)(const json_string &);
106  #endif
107 #endif
108 
109 #ifdef JSON_INDEX_TYPE
110  typedef JSON_INDEX_TYPE json_index_t;
111 #else
112  typedef unsigned int json_index_t;
113 #endif
114 
115 #ifdef JSON_BOOL_TYPE
116  typedef JSON_BOOL_TYPE json_bool_t;
117 #else
118  typedef int json_bool_t;
119 #endif
120 
121 #ifdef JSON_INT_TYPE
122  typedef JSON_INT_TYPE json_int_t;
123 #else
124  typedef long json_int_t;
125 #endif
126 
127 #define JSONSTREAM_SELF (void*)-1
128 typedef void (*json_stream_e_callback_t)(void * identifier);
129 
130 typedef void (*json_mutex_callback_t)(void *);
131 typedef void (*json_free_t)(void *);
132 #ifndef JSON_LIBRARY
133  typedef void * (*json_malloc_t)(size_t);
134  typedef void * (*json_realloc_t)(void *, size_t);
135 #else
136  #define JSONNODE void /* so that JSONNODE* is void* */
137  typedef JSONNODE** JSONNODE_ITERATOR;
138  #ifdef JSON_STREAM
139  #define JSONSTREAM void
140  typedef void (*json_stream_callback_t)(JSONNODE *, void * identifier);
141  #endif
142  typedef void * (*json_malloc_t)(unsigned long);
143  typedef void * (*json_realloc_t)(void *, unsigned long);
144 #endif
145 
146 #ifdef JSON_DEBUG
147  #ifdef NDEBUG
148  #ifdef __GNUC__
149  #warning, Have JSON_DEBUG on in a release build
150  #else
151  #error, Have JSON_DEBUG on in a release build
152  #endif
153  #endif
154 #else
155  #ifndef NDEBUG
156  #ifdef __GNUC__
157  #warning, Release build of libjson, but NDEBUG is not on
158  #else
159  #error, Release build of libjson, but NDEBUG is not on
160  #endif
161  #endif
162 #endif
163 
164 #ifdef JSON_UNIT_TEST
165  #define JSON_PRIVATE public:
166  #define JSON_PROTECTED public:
167 #else
168  #define JSON_PRIVATE private:
169  #define JSON_PROTECTED protected:
170 #endif
171 #ifdef JSON_STREAM
172  #ifndef JSON_READ_PRIORITY
173  #error, JSON_STREAM also requires JSON_READ_PRIORITY
174  #endif
175 #endif
176 #ifdef JSON_VALIDATE
177  #ifndef JSON_READ_PRIORITY
178  #error, JSON_VALIDATE also requires JSON_READ_PRIORITY
179  #endif
180 #endif
181 
182 #define JSON_TEMP_COMMENT_IDENTIFIER JSON_TEXT('#')
183 
184 #endif