5
5
6
6
#ifndef JSON_CONFIG_H_INCLUDED
7
7
#define JSON_CONFIG_H_INCLUDED
8
- #include < cstddef>
9
- #include < cstdint>
8
+
10
9
#include < istream>
11
10
#include < memory>
12
11
#include < ostream>
13
12
#include < sstream>
14
13
#include < string>
15
- #include < type_traits>
14
+
15
+ #if JSONCPP_CXX_STD_11
16
+ #include < cstddef> // typedef ptrdiff_t
17
+ #include < cstdint> // typedef int64_t, uint64_t
18
+ #else
19
+ #include < stddef.h>
20
+ #include < stdint.h>
21
+ #endif
16
22
17
23
// If non-zero, the library uses exceptions to report bad input instead of C
18
24
// assertion macros. The default is to use exceptions.
50
56
#define JSON_API
51
57
#endif
52
58
53
- #if defined(_MSC_VER) && _MSC_VER < 1800
54
- #error \
55
- " ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
56
- #endif
57
-
58
59
#if defined(_MSC_VER) && _MSC_VER < 1900
59
60
// As recommended at
60
61
// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
@@ -70,10 +71,41 @@ extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
70
71
// Storages, and 64 bits integer support is disabled.
71
72
// #define JSON_NO_INT64 1
72
73
73
- // JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
74
- // C++11 should be used directly in JSONCPP.
74
+ #if __cplusplus >= 201103L || defined(_MSC_VER)
75
+ #define JSONCPP_OP_EXPLICIT explicit
76
+ #else
77
+ #define JSONCPP_OP_EXPLICIT
78
+ #endif
79
+
80
+ // These Macros are maintained for backwards compatibility of external tools.
81
+ #if (defined(_MSC_VER) && _MSC_VER >= 1900) || \
82
+ (defined (__GNUC__) && __cplusplus >= 201103L ) || \
83
+ (defined (__clang__) && __clang_major__ == 3 && __clang_minor__ >= 3 )
84
+
85
+ #define JSONCPP_CXX_STD_11 1
86
+ #else
87
+ #define JSONCPP_CXX_STD_11 0
88
+ #endif
89
+
90
+ #if JSONCPP_CXX_STD_11
91
+ #define JSONCPP_NULL nullptr
92
+ #define JSONCPP_CONST constexpr
93
+ #define JSONCPP_CTOR_DELETE = delete
94
+ #define JSONCPP_NOEXCEPT noexcept
75
95
#define JSONCPP_OVERRIDE override
96
+ #define JSONCPP_MOVE (value ) std::move(value)
97
+ #else
98
+ #define JSONCPP_NULL NULL
99
+ #define JSONCPP_CONST const
100
+ #define JSONCPP_CTOR_DELETE
101
+ #define JSONCPP_NOEXCEPT throw ()
102
+ #define JSONCPP_OVERRIDE
103
+ #define JSONCPP_MOVE (value ) value
104
+ #endif
76
105
106
+ // Define *deprecated* attribute
107
+ // [[deprecated]] is in C++14 or in Visual Studio 2015 and later
108
+ // For compatibility, [[deprecated]] is not used
77
109
#ifdef __clang__
78
110
#if __has_extension(attribute_deprecated_with_message)
79
111
#define JSONCPP_DEPRECATED (message ) __attribute__((deprecated(message)))
@@ -98,33 +130,36 @@ extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
98
130
#endif
99
131
100
132
#if !defined(JSON_IS_AMALGAMATION)
101
-
133
+ # if JSONCPP_CXX_STD_11
102
134
#include " allocator.h"
135
+ #endif
103
136
#include " version.h"
104
137
105
138
#endif // if !defined(JSON_IS_AMALGAMATION)
106
139
107
140
namespace Json {
108
- using Int = int ;
109
- using UInt = unsigned int ;
141
+
142
+ typedef int Int;
143
+ typedef unsigned int UInt;
110
144
#if defined(JSON_NO_INT64)
111
- using LargestInt = int ;
112
- using LargestUInt = unsigned int ;
145
+ typedef int LargestInt ;
146
+ typedef unsigned int LargestUInt ;
113
147
#undef JSON_HAS_INT64
114
148
#else // if defined(JSON_NO_INT64)
115
149
// For Microsoft Visual use specific types as long long is not supported
116
150
#if defined(_MSC_VER) // Microsoft Visual Studio
117
- using Int64 = __int64;
118
- using UInt64 = unsigned __int64;
151
+ typedef __int64 Int64 ;
152
+ typedef unsigned __int64 UInt64 ;
119
153
#else // if defined(_MSC_VER) // Other platforms, use long long
120
- using Int64 = int64_t ;
121
- using UInt64 = uint64_t ;
154
+ typedef int64_t Int64 ;
155
+ typedef uint64_t UInt64 ;
122
156
#endif // if defined(_MSC_VER)
123
- using LargestInt = Int64;
124
- using LargestUInt = UInt64;
157
+ typedef Int64 LargestInt ;
158
+ typedef UInt64 LargestUInt ;
125
159
#define JSON_HAS_INT64
126
160
#endif // if defined(JSON_NO_INT64)
127
161
162
+ #if JSONCPP_CXX_STD_11
128
163
template <typename T>
129
164
using Allocator =
130
165
typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
@@ -138,13 +173,20 @@ using OStringStream =
138
173
String::allocator_type>;
139
174
using IStream = std::istream;
140
175
using OStream = std::ostream;
176
+ #else
177
+ typedef std::string String;
178
+ typedef std::istringstream IStringStream;
179
+ typedef std::ostringstream OStringStream;
180
+ typedef std::istream IStream;
181
+ typedef std::ostream OStream;
182
+ #endif // JSONCPP_CXX_STD_11
141
183
} // namespace Json
142
184
143
185
// Legacy names (formerly macros).
144
- using JSONCPP_STRING = Json::String;
145
- using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
146
- using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
147
- using JSONCPP_ISTREAM = Json::IStream;
148
- using JSONCPP_OSTREAM = Json::OStream;
186
+ typedef Json::String JSONCPP_STRING ;
187
+ typedef Json::IStringStream JSONCPP_ISTRINGSTREAM ;
188
+ typedef Json::OStringStream JSONCPP_OSTRINGSTREAM ;
189
+ typedef Json::IStream JSONCPP_ISTREAM ;
190
+ typedef Json::OStream JSONCPP_OSTREAM ;
149
191
150
192
#endif // JSON_CONFIG_H_INCLUDED
0 commit comments