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// 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#ifndef _WX_JSON_DEFS_H_
12#define _WX_JSON_DEFS_H_
13
14// Defines for component version.
15// The following symbols should be updated for each new component release
16// since some kind of tests, like those of
17// AM_WXCODE_CHECKFOR_COMPONENT_VERSION() for "configure" scripts under unix,
18// 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) && \
30 wxJSON_RELEASE >= (release)))
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// define wxJSON_USE_UNICODE if wxWidgets was built with
65// unicode support
66#if defined(wxJSON_USE_UNICODE)
67#undef wxJSON_USE_UNICODE
68#endif
69// do not modify the following lines
70#if wxUSE_UNICODE == 1
71#define wxJSON_USE_UNICODE
72#endif
73
74// the following macro, if defined, cause the wxJSONValue to store
75// pointers to C-strings as pointers to statically allocated
76// C-strings. By default this macro is not defined
77// #define wxJSON_USE_CSTRING
78
79// the following macro, if defined, cause the wxJSONvalue and its
80// referenced data structure to store and increment a static
81// progressive counter in the ctor.
82// this is only usefull for debugging purposes
83// #define WXJSON_USE_VALUE_COUNTER
84
85// the following macro is used by wxJSON internally and you should not
86// modify it. If the platform seems to support 64-bits integers,
87// the following lines define the 'wxJSON_64BIT_INT' macro
88#if defined(wxLongLong_t)
89#define wxJSON_64BIT_INT
90#endif
91
92//
93// the following macro, if defined, cause the wxJSON library to
94// always use 32-bits integers also when the platform seems to
95// have native 64-bits support: by default the macro if not defined
96//
97// #define wxJSON_NO_64BIT_INT
98//
99#if defined(wxJSON_NO_64BIT_INT) && defined(wxJSON_64BIT_INT)
100#undef wxJSON_64BIT_INT
101#endif
102
103//
104// it seems that some compilers do not define 'long long int' limits
105// constants. For example, this is the output of the Borland BCC 5.5
106// compiler when I tried to compile wxJSON with 64-bits integer support:
107// Error E2451 ..\src\jsonreader.cpp 1737: Undefined symbol 'LLONG_MAX'
108// in function wxJSONReader::Strtoll(const wxString &,__int64 *)
109// *** 1 errors in Compile ***
110// so, if the constants are not defined, I define them by myself
111#if !defined(LLONG_MAX)
112#define LLONG_MAX 9223372036854775807
113#endif
114
115#if !defined(ULLONG_MAX)
116#define ULLONG_MAX 18446744073709551615
117#endif
118
119#if !defined(LLONG_MIN)
120#define LLONG_MIN -9223372036854775808
121#endif
122
123// the same applies for all other integer constants
124#if !defined(INT_MIN)
125#define INT_MIN -32768
126#endif
127#if !defined(INT_MAX)
128#define INT_MAX 32767
129#endif
130#if !defined(UINT_MAX)
131#define UINT_MAX 65535
132#endif
133#if !defined(LONG_MIN)
134#define LONG_MIN -2147483648
135#endif
136#if !defined(LONG_MAX)
137#define LONG_MAX 2147483647
138#endif
139#if !defined(ULONG_MAX)
140#define ULONG_MAX 4294967295
141#endif
142#if !defined(SHORT_MAX)
143#define SHORT_MAX 32767
144#endif
145#if !defined(SHORT_MIN)
146#define SHORT_MIN -32768
147#endif
148#if !defined(USHORT_MAX)
149#define USHORT_MAX 65535
150#endif
151
152//
153// define the wxJSON_ASSERT() macro to expand to wxASSERT()
154// unless the wxJSON_NOABORT_ASSERT is defined
155// #define wxJSON_NOABORT_ASSERT
156#if defined(wxJSON_NOABORT_ASSERT)
157#define wxJSON_ASSERT(cond)
158#else
159#define wxJSON_ASSERT(cond) wxASSERT(cond);
160#endif
161
162//
163// the following macros are used by the wxJSONWriter::WriteStringValues()
164// when the wxJSONWRITER_SPLIT_STRING flag is set
165#define wxJSONWRITER_LAST_COL 50
166#define wxJSONWRITER_SPLIT_COL 75
167#define wxJSONWRITER_MIN_LENGTH 15
168#define wxJSONWRITER_TAB_LENGTH 4
169
170//
171// some compilers (i.e. MSVC++) defines their own 'snprintf' function
172// so if it is not defined, define it in the following lines
173// please note that we cannot use the wxWidget's counterpart 'wxSnprintf'
174// because the latter uses 'wxChar' but wxJSON only use 'char'
175#if !defined(snprintf) && defined(_MSC_VER)
176#define snprintf _snprintf
177#endif
178
179//
180// check if wxWidgets is compiled using --enable-stl in which case
181// we have to use different aproaches when declaring the array and
182// key/value containers (see the docs: wxJSON internals: array and hash_map
183#undef wxJSON_USE_STL
184#if defined(wxUSE_STL) && wxUSE_STL == 1
185#define wxJSON_USE_STL
186#endif
187
188//
189// defines the MIN and MAX macro for numeric arguments
190// note that the safest way to define such functions is using templates
191#ifndef MIN
192#define MIN(a, b) a < b ? a : b
193#endif
194#ifndef MAX
195#define MAX(a, b) a > b ? a : b
196#endif
197
198#endif // _WX_JSON_DEFS_H_