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