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