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