Version: 0.6.0
json_defs.h
1 // Name: json_defs.h
3 // Purpose: shared build defines
4 // Author: Luciano Cattani
5 // Created: 2007/10/20
6 // RCS-ID: $Id: json_defs.h,v 1.6 2008/03/12 10:48:19 luccat Exp $
7 // Copyright: (c) 2007 Luciano Cattani
8 // Licence: wxWidgets licence
10 
11 
12 #ifndef _WX_JSON_DEFS_H_
13 #define _WX_JSON_DEFS_H_
14 
15 // Defines for component version.
16 // The following symbols should be updated for each new component release
17 // since some kind of tests, like those of AM_WXCODE_CHECKFOR_COMPONENT_VERSION()
18 // for "configure" scripts under unix, use them.
19 #define wxJSON_MAJOR 1
20 #define wxJSON_MINOR 2
21 #define wxJSON_RELEASE 1
22 
23 // For non-Unix systems (i.e. when building without a configure script),
24 // users of this component can use the following macro to check if the
25 // current version is at least major.minor.release
26 #define wxCHECK_JSON_VERSION(major,minor,release) \
27  (wxJSON_MAJOR > (major) || \
28  (wxJSON_MAJOR == (major) && wxJSON_MINOR > (minor)) || \
29  (wxJSON_MAJOR == (major) && wxJSON_MINOR == (minor) && wxJSON_RELEASE >= (release)))
30 
31 
32 // Defines for shared builds.
33 // Simple reference for using these macros and for writin components
34 // which support shared builds:
35 //
36 // 1) use the WXDLLIMPEXP_MYCOMP in each class declaration:
37 // class WXDLLIMPEXP_MYCOMP myCompClass { [...] };
38 //
39 // 2) use the WXDLLIMPEXP_MYCOMP in the declaration of each global function:
40 // WXDLLIMPEXP_MYCOMP int myGlobalFunc();
41 //
42 // 3) use the WXDLLIMPEXP_DATA_MYCOMP() in the declaration of each global
43 // variable:
44 // WXDLLIMPEXP_DATA_MYCOMP(int) myGlobalIntVar;
45 //
46 #ifdef WXMAKINGDLL_JSON
47  #define WXDLLIMPEXP_JSON WXEXPORT
48  #define WXDLLIMPEXP_DATA_JSON(type) WXEXPORT type
49 #elif defined(WXUSINGDLL)
50  #define WXDLLIMPEXP_JSON WXIMPORT
51  #define WXDLLIMPEXP_DATA_JSON(type) WXIMPORT type
52 #else // not making nor using DLL
53  #define WXDLLIMPEXP_JSON
54  #define WXDLLIMPEXP_DATA_JSON(type) type
55 #endif
56 
57 // the __PRETTY_FUNCTION__ macro expands to the full class's
58 // member name in the GNU GCC.
59 // For other compilers we use the standard __wxFUNCTION__ macro
60 #if !defined( __GNUC__ )
61  #define __PRETTY_FUNCTION__ __WXFUNCTION__
62 #endif
63 
64 
65 
66 // define wxJSON_USE_UNICODE if wxWidgets was built with
67 // unicode support
68 #if defined( wxJSON_USE_UNICODE )
69  #undef wxJSON_USE_UNICODE
70 #endif
71 // do not modify the following lines
72 #if wxUSE_UNICODE == 1
73  #define wxJSON_USE_UNICODE
74 #endif
75 
76 // the following macro, if defined, cause the wxJSONValue to store
77 // pointers to C-strings as pointers to statically allocated
78 // C-strings. By default this macro is not defined
79 // #define wxJSON_USE_CSTRING
80 
81 
82 // the following macro, if defined, cause the wxJSONvalue and its
83 // referenced data structure to store and increment a static
84 // progressive counter in the ctor.
85 // this is only usefull for debugging purposes
86 // #define WXJSON_USE_VALUE_COUNTER
87 
88 
89 // the following macro is used by wxJSON internally and you should not
90 // modify it. If the platform seems to support 64-bits integers,
91 // the following lines define the 'wxJSON_64BIT_INT' macro
92 #if defined( wxLongLong_t )
93 #define wxJSON_64BIT_INT
94 #endif
95 
96 
97 //
98 // the following macro, if defined, cause the wxJSON library to
99 // always use 32-bits integers also when the platform seems to
100 // have native 64-bits support: by default the macro if not defined
101 //
102 // #define wxJSON_NO_64BIT_INT
103 //
104 #if defined( wxJSON_NO_64BIT_INT ) && defined( wxJSON_64BIT_INT )
105 #undef wxJSON_64BIT_INT
106 #endif
107 
108 //
109 // it seems that some compilers do not define 'long long int' limits
110 // constants. For example, this is the output of the Borland BCC 5.5
111 // compiler when I tried to compile wxJSON with 64-bits integer support:
112 // Error E2451 ..\src\jsonreader.cpp 1737: Undefined symbol 'LLONG_MAX'
113 // in function wxJSONReader::Strtoll(const wxString &,__int64 *)
114 // *** 1 errors in Compile ***
115 // so, if the constants are not defined, I define them by myself
116 #if !defined( LLONG_MAX )
117  #define LLONG_MAX 9223372036854775807
118 #endif
119 
120 #if !defined( ULLONG_MAX )
121  #define ULLONG_MAX 18446744073709551615
122 #endif
123 
124 #if !defined( LLONG_MIN )
125  #define LLONG_MIN -9223372036854775808
126 #endif
127 
128 
129 
130 // the same applies for all other integer constants
131 #if !defined( INT_MIN )
132  #define INT_MIN -32768
133 #endif
134 #if !defined( INT_MAX )
135  #define INT_MAX 32767
136 #endif
137 #if !defined( UINT_MAX )
138  #define UINT_MAX 65535
139 #endif
140 #if !defined( LONG_MIN )
141  #define LONG_MIN -2147483648
142 #endif
143 #if !defined( LONG_MAX )
144  #define LONG_MAX 2147483647
145 #endif
146 #if !defined( ULONG_MAX )
147  #define ULONG_MAX 4294967295
148 #endif
149 #if !defined( SHORT_MAX )
150  #define SHORT_MAX 32767
151 #endif
152 #if !defined( SHORT_MIN )
153  #define SHORT_MIN -32768
154 #endif
155 #if !defined( USHORT_MAX )
156  #define USHORT_MAX 65535
157 #endif
158 
159 
160 
161 //
162 // define the wxJSON_ASSERT() macro to expand to wxASSERT()
163 // unless the wxJSON_NOABORT_ASSERT is defined
164  #define wxJSON_NOABORT_ASSERT
165 #if defined( wxJSON_NOABORT_ASSERT )
166  #define wxJSON_ASSERT( cond )
167 #else
168  #define wxJSON_ASSERT( cond ) wxASSERT( cond );
169 #endif
170 
171 
172 //
173 // the following macros are used by the wxJSONWriter::WriteStringValues()
174 // when the wxJSONWRITER_SPLIT_STRING flag is set
175 #define wxJSONWRITER_LAST_COL 50
176 #define wxJSONWRITER_SPLIT_COL 75
177 #define wxJSONWRITER_MIN_LENGTH 15
178 #define wxJSONWRITER_TAB_LENGTH 4
179 
180 
181 //
182 // some compilers (i.e. MSVC++) defines their own 'snprintf' function
183 // so if it is not defined, define it in the following lines
184 // please note that we cannot use the wxWidget's counterpart 'wxSnprintf'
185 // because the latter uses 'wxChar' but wxJSON only use 'char'
186 #if !defined(snprintf) && defined(_MSC_VER)
187 #define snprintf _snprintf
188 #endif
189 
190 
191 //
192 // check if wxWidgets is compiled using --enable-stl in which case
193 // we have to use different aproaches when declaring the array and
194 // key/value containers (see the docs: wxJSON internals: array and hash_map
195 #undef wxJSON_USE_STL
196 #if defined( wxUSE_STL ) && wxUSE_STL == 1
197 #define wxJSON_USE_STL
198 #endif
199 
200 #endif // _WX_JSON_DEFS_H_
201 
202