@@ -79,6 +79,151 @@ license you like.
79
79
// / to prevent private header inclusion.
80
80
#define JSON_IS_AMALGAMATION
81
81
82
+ // //////////////////////////////////////////////////////////////////////
83
+ // Beginning of content of file: include/json/version.h
84
+ // //////////////////////////////////////////////////////////////////////
85
+
86
+ #ifndef JSON_VERSION_H_INCLUDED
87
+ #define JSON_VERSION_H_INCLUDED
88
+
89
+ // Note: version must be updated in three places when doing a release. This
90
+ // annoying process ensures that amalgamate, CMake, and meson all report the
91
+ // correct version.
92
+ // 1. /meson.build
93
+ // 2. /include/json/version.h
94
+ // 3. /CMakeLists.txt
95
+ // IMPORTANT: also update the SOVERSION!!
96
+
97
+ #define JSONCPP_VERSION_STRING " 1.9.4"
98
+ #define JSONCPP_VERSION_MAJOR 1
99
+ #define JSONCPP_VERSION_MINOR 9
100
+ #define JSONCPP_VERSION_PATCH 3
101
+ #define JSONCPP_VERSION_QUALIFIER
102
+ #define JSONCPP_VERSION_HEXA \
103
+ ((JSONCPP_VERSION_MAJOR << 24 ) | (JSONCPP_VERSION_MINOR << 16 ) | \
104
+ (JSONCPP_VERSION_PATCH << 8 ))
105
+
106
+ #ifdef JSONCPP_USING_SECURE_MEMORY
107
+ #undef JSONCPP_USING_SECURE_MEMORY
108
+ #endif
109
+ #define JSONCPP_USING_SECURE_MEMORY 0
110
+ // If non-zero, the library zeroes any memory that it has allocated before
111
+ // it frees its memory.
112
+
113
+ #endif // JSON_VERSION_H_INCLUDED
114
+
115
+ // //////////////////////////////////////////////////////////////////////
116
+ // End of content of file: include/json/version.h
117
+ // //////////////////////////////////////////////////////////////////////
118
+
119
+
120
+
121
+
122
+
123
+
124
+ // //////////////////////////////////////////////////////////////////////
125
+ // Beginning of content of file: include/json/allocator.h
126
+ // //////////////////////////////////////////////////////////////////////
127
+
128
+ // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
129
+ // Distributed under MIT license, or public domain if desired and
130
+ // recognized in your jurisdiction.
131
+ // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
132
+
133
+ #ifndef JSON_ALLOCATOR_H_INCLUDED
134
+ #define JSON_ALLOCATOR_H_INCLUDED
135
+
136
+ #include < cstring>
137
+ #include < memory>
138
+
139
+ #pragma pack(push, 8)
140
+
141
+ namespace Json {
142
+ template <typename T> class SecureAllocator {
143
+ public:
144
+ // Type definitions
145
+ using value_type = T;
146
+ using pointer = T*;
147
+ using const_pointer = const T*;
148
+ using reference = T&;
149
+ using const_reference = const T&;
150
+ using size_type = std::size_t ;
151
+ using difference_type = std::ptrdiff_t ;
152
+
153
+ /* *
154
+ * Allocate memory for N items using the standard allocator.
155
+ */
156
+ pointer allocate (size_type n) {
157
+ // allocate using "global operator new"
158
+ return static_cast <pointer>(::operator new (n * sizeof (T)));
159
+ }
160
+
161
+ /* *
162
+ * Release memory which was allocated for N items at pointer P.
163
+ *
164
+ * The memory block is filled with zeroes before being released.
165
+ * The pointer argument is tagged as "volatile" to prevent the
166
+ * compiler optimizing out this critical step.
167
+ */
168
+ void deallocate (volatile pointer p, size_type n) {
169
+ std::memset (p, 0 , n * sizeof (T));
170
+ // free using "global operator delete"
171
+ ::operator delete (p);
172
+ }
173
+
174
+ /* *
175
+ * Construct an item in-place at pointer P.
176
+ */
177
+ template <typename ... Args> void construct (pointer p, Args&&... args) {
178
+ // construct using "placement new" and "perfect forwarding"
179
+ ::new (static_cast <void *>(p)) T (std::forward<Args>(args)...);
180
+ }
181
+
182
+ size_type max_size () const { return size_t (-1 ) / sizeof (T); }
183
+
184
+ pointer address (reference x) const { return std::addressof (x); }
185
+
186
+ const_pointer address (const_reference x) const { return std::addressof (x); }
187
+
188
+ /* *
189
+ * Destroy an item in-place at pointer P.
190
+ */
191
+ void destroy (pointer p) {
192
+ // destroy using "explicit destructor"
193
+ p->~T ();
194
+ }
195
+
196
+ // Boilerplate
197
+ SecureAllocator () {}
198
+ template <typename U> SecureAllocator (const SecureAllocator<U>&) {}
199
+ template <typename U> struct rebind { using other = SecureAllocator<U>; };
200
+ };
201
+
202
+ template <typename T, typename U>
203
+ bool operator ==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
204
+ return true ;
205
+ }
206
+
207
+ template <typename T, typename U>
208
+ bool operator !=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
209
+ return false ;
210
+ }
211
+
212
+ } // namespace Json
213
+
214
+ #pragma pack(pop)
215
+
216
+ #endif // JSON_ALLOCATOR_H_INCLUDED
217
+
218
+ // //////////////////////////////////////////////////////////////////////
219
+ // End of content of file: include/json/allocator.h
220
+ // //////////////////////////////////////////////////////////////////////
221
+
222
+
223
+
224
+
225
+
226
+
82
227
// //////////////////////////////////////////////////////////////////////
83
228
// Beginning of content of file: include/json/config.h
84
229
// //////////////////////////////////////////////////////////////////////
@@ -90,184 +235,147 @@ license you like.
90
235
91
236
#ifndef JSON_CONFIG_H_INCLUDED
92
237
#define JSON_CONFIG_H_INCLUDED
93
- #include < stddef.h>
94
- #include < string> // typedef String
95
- #include < stdint.h> // typedef int64_t, uint64_t
96
-
97
- // / If defined, indicates that json library is embedded in CppTL library.
98
- // # define JSON_IN_CPPTL 1
99
-
100
- // / If defined, indicates that json may leverage CppTL library
101
- // # define JSON_USE_CPPTL 1
102
- // / If defined, indicates that cpptl vector based map should be used instead of
103
- // / std::map
104
- // / as Value container.
105
- // # define JSON_USE_CPPTL_SMALLMAP 1
238
+ #include < cstddef>
239
+ #include < cstdint>
240
+ #include < istream>
241
+ #include < memory>
242
+ #include < ostream>
243
+ #include < sstream>
244
+ #include < string>
245
+ #include < type_traits>
106
246
107
247
// If non-zero, the library uses exceptions to report bad input instead of C
108
248
// assertion macros. The default is to use exceptions.
109
249
#ifndef JSON_USE_EXCEPTION
110
250
#define JSON_USE_EXCEPTION 1
111
251
#endif
112
252
253
+ // Temporary, tracked for removal with issue #982.
254
+ #ifndef JSON_USE_NULLREF
255
+ #define JSON_USE_NULLREF 1
256
+ #endif
257
+
113
258
// / If defined, indicates that the source file is amalgamated
114
259
// / to prevent private header inclusion.
115
260
// / Remarks: it is automatically defined in the generated amalgamated header.
116
261
// #define JSON_IS_AMALGAMATION
117
262
118
- #ifdef JSON_IN_CPPTL
119
- #include < cpptl/config.h>
120
- #ifndef JSON_USE_CPPTL
121
- #define JSON_USE_CPPTL 1
122
- #endif
123
- #endif
124
-
125
- #ifdef JSON_IN_CPPTL
126
- #define JSON_API CPPTL_API
127
- #elif defined(JSON_DLL_BUILD)
263
+ // Export macros for DLL visibility
264
+ #if defined(JSON_DLL_BUILD)
128
265
#if defined(_MSC_VER) || defined(__MINGW32__)
129
266
#define JSON_API __declspec (dllexport)
130
267
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
268
+ #elif defined(__GNUC__) || defined(__clang__)
269
+ #define JSON_API __attribute__ ((visibility(" default" )))
131
270
#endif // if defined(_MSC_VER)
271
+
132
272
#elif defined(JSON_DLL)
133
273
#if defined(_MSC_VER) || defined(__MINGW32__)
134
274
#define JSON_API __declspec (dllimport)
135
275
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
136
276
#endif // if defined(_MSC_VER)
137
- #endif // ifdef JSON_IN_CPPTL
277
+ #endif // ifdef JSON_DLL_BUILD
278
+
138
279
#if !defined(JSON_API)
139
280
#define JSON_API
140
281
#endif
141
282
142
- // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
143
- // integer
144
- // Storages, and 64 bits integer support is disabled.
145
- // #define JSON_NO_INT64 1
283
+ # if defined(_MSC_VER) && _MSC_VER < 1800
284
+ # error \
285
+ " ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities "
286
+ # endif
146
287
147
- #if defined(_MSC_VER) // MSVC
148
- # if _MSC_VER <= 1200 // MSVC 6
149
- // Microsoft Visual Studio 6 only support conversion from __int64 to double
150
- // (no conversion from unsigned __int64).
151
- # define JSON_USE_INT64_DOUBLE_CONVERSION 1
152
- // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
153
- // characters in the debug information)
154
- // All projects I've ever seen with VS6 were using this globally (not bothering
155
- // with pragma push/pop).
156
- # pragma warning(disable : 4786)
157
- # endif // MSVC 6
158
-
159
- # if _MSC_VER >= 1500 // MSVC 2008
160
- // / Indicates that the following function is deprecated.
161
- # define JSONCPP_DEPRECATED (message ) __declspec(deprecated(message))
162
- # endif
163
-
164
- #endif // defined(_MSC_VER)
165
-
166
- // In c++11 the override keyword allows you to explicitly define that a function
167
- // is intended to override the base-class version. This makes the code more
168
- // managable and fixes a set of common hard-to-find bugs.
169
- #if __cplusplus >= 201103L
170
- # define JSONCPP_OVERRIDE override
171
- # define JSONCPP_NOEXCEPT noexcept
172
- #elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
173
- # define JSONCPP_OVERRIDE override
174
- # define JSONCPP_NOEXCEPT throw ()
175
- #elif defined(_MSC_VER) && _MSC_VER >= 1900
176
- # define JSONCPP_OVERRIDE override
177
- # define JSONCPP_NOEXCEPT noexcept
288
+ #if defined(_MSC_VER) && _MSC_VER < 1900
289
+ // As recommended at
290
+ // https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
291
+ extern JSON_API int msvc_pre1900_c99_snprintf (char * outBuf, size_t size,
292
+ const char * format, ...);
293
+ #define jsoncpp_snprintf msvc_pre1900_c99_snprintf
178
294
#else
179
- # define JSONCPP_OVERRIDE
180
- # define JSONCPP_NOEXCEPT throw ()
295
+ #define jsoncpp_snprintf std::snprintf
181
296
#endif
182
297
183
- #ifndef JSON_HAS_RVALUE_REFERENCES
298
+ // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
299
+ // integer
300
+ // Storages, and 64 bits integer support is disabled.
301
+ // #define JSON_NO_INT64 1
184
302
185
- # if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
186
- # define JSON_HAS_RVALUE_REFERENCES 1
187
- #endif // MSVC >= 2010
303
+ // JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
304
+ // C++11 should be used directly in JSONCPP.
305
+ #define JSONCPP_OVERRIDE override
188
306
189
307
#ifdef __clang__
190
- #if __has_feature(cxx_rvalue_references)
191
- #define JSON_HAS_RVALUE_REFERENCES 1
192
- #endif // has_feature
193
-
194
- #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
195
- #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
196
- #define JSON_HAS_RVALUE_REFERENCES 1
197
- #endif // GXX_EXPERIMENTAL
198
-
199
- #endif // __clang__ || __GNUC__
200
-
201
- #endif // not defined JSON_HAS_RVALUE_REFERENCES
202
-
203
- #ifndef JSON_HAS_RVALUE_REFERENCES
204
- #define JSON_HAS_RVALUE_REFERENCES 0
308
+ #if __has_extension(attribute_deprecated_with_message)
309
+ #define JSONCPP_DEPRECATED (message ) __attribute__((deprecated(message)))
205
310
#endif
206
-
207
- #ifdef __clang__
208
- # if __has_extension(attribute_deprecated_with_message)
209
- # define JSONCPP_DEPRECATED (message ) __attribute__ ((deprecated(message)))
210
- # endif
211
- #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
212
- # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
213
- # define JSONCPP_DEPRECATED (message ) __attribute__ ((deprecated(message)))
214
- # elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
215
- # define JSONCPP_DEPRECATED (message ) __attribute__((__deprecated__))
216
- # endif // GNUC version
217
- #endif // __clang__ || __GNUC__
311
+ #elif defined(__GNUC__) // not clang (gcc comes later since clang emulates gcc)
312
+ #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
313
+ #define JSONCPP_DEPRECATED (message ) __attribute__((deprecated(message)))
314
+ #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
315
+ #define JSONCPP_DEPRECATED (message ) __attribute__((__deprecated__))
316
+ #endif // GNUC version
317
+ #elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
318
+ // MSVC)
319
+ #define JSONCPP_DEPRECATED (message ) __declspec(deprecated(message))
320
+ #endif // __clang__ || __GNUC__ || _MSC_VER
218
321
219
322
#if !defined(JSONCPP_DEPRECATED)
220
323
#define JSONCPP_DEPRECATED (message )
221
324
#endif // if !defined(JSONCPP_DEPRECATED)
222
325
223
- #if __GNUC__ >= 6
224
- # define JSON_USE_INT64_DOUBLE_CONVERSION 1
326
+ #if defined(__clang__) || (defined( __GNUC__) && (__GNUC__ >= 6))
327
+ #define JSON_USE_INT64_DOUBLE_CONVERSION 1
225
328
#endif
226
329
227
330
#if !defined(JSON_IS_AMALGAMATION)
228
331
229
- # include " version.h"
230
-
231
- # if JSONCPP_USING_SECURE_MEMORY
232
- # include " allocator.h" // typedef Allocator
233
- # endif
332
+ #include " allocator.h"
333
+ #include " version.h"
234
334
235
335
#endif // if !defined(JSON_IS_AMALGAMATION)
236
336
237
337
namespace Json {
238
- typedef int Int;
239
- typedef unsigned int UInt ;
338
+ using Int = int ;
339
+ using UInt = unsigned int ;
240
340
#if defined(JSON_NO_INT64)
241
- typedef int LargestInt;
242
- typedef unsigned int LargestUInt ;
341
+ using LargestInt = int ;
342
+ using LargestUInt = unsigned int ;
243
343
#undef JSON_HAS_INT64
244
344
#else // if defined(JSON_NO_INT64)
245
345
// For Microsoft Visual use specific types as long long is not supported
246
346
#if defined(_MSC_VER) // Microsoft Visual Studio
247
- typedef __int64 Int64;
248
- typedef unsigned __int64 UInt64 ;
347
+ using Int64 = __int64 ;
348
+ using UInt64 = unsigned __int64;
249
349
#else // if defined(_MSC_VER) // Other platforms, use long long
250
- typedef int64_t Int64;
251
- typedef uint64_t UInt64 ;
252
- #endif // if defined(_MSC_VER)
253
- typedef Int64 LargestInt;
254
- typedef UInt64 LargestUInt;
350
+ using Int64 = int64_t ;
351
+ using UInt64 = uint64_t ;
352
+ #endif // if defined(_MSC_VER)
353
+ using LargestInt = Int64 ;
354
+ using LargestUInt = UInt64 ;
255
355
#define JSON_HAS_INT64
256
356
#endif // if defined(JSON_NO_INT64)
257
- #if JSONCPP_USING_SECURE_MEMORY
258
- #define JSONCPP_STRING std::basic_string<char , std::char_traits<char >, Json::SecureAllocator<char > >
259
- #define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char , std::char_traits<char >, Json::SecureAllocator<char > >
260
- #define JSONCPP_OSTREAM std::basic_ostream<char , std::char_traits<char >>
261
- #define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char , std::char_traits<char >, Json::SecureAllocator<char > >
262
- #define JSONCPP_ISTREAM std::istream
263
- #else
264
- #define JSONCPP_STRING std::string
265
- #define JSONCPP_OSTRINGSTREAM std::ostringstream
266
- #define JSONCPP_OSTREAM std::ostream
267
- #define JSONCPP_ISTRINGSTREAM std::istringstream
268
- #define JSONCPP_ISTREAM std::istream
269
- #endif // if JSONCPP_USING_SECURE_MEMORY
270
- } // end namespace Json
357
+
358
+ template <typename T>
359
+ using Allocator =
360
+ typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
361
+ std::allocator<T>>::type;
362
+ using String = std::basic_string<char , std::char_traits<char >, Allocator<char >>;
363
+ using IStringStream =
364
+ std::basic_istringstream<String::value_type, String::traits_type,
365
+ String::allocator_type>;
366
+ using OStringStream =
367
+ std::basic_ostringstream<String::value_type, String::traits_type,
368
+ String::allocator_type>;
369
+ using IStream = std::istream;
370
+ using OStream = std::ostream;
371
+ } // namespace Json
372
+
373
+ // Legacy names (formerly macros).
374
+ using JSONCPP_STRING = Json::String;
375
+ using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
376
+ using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
377
+ using JSONCPP_ISTREAM = Json::IStream;
378
+ using JSONCPP_OSTREAM = Json::OStream;
271
379
272
380
#endif // JSON_CONFIG_H_INCLUDED
273
381
@@ -299,17 +407,23 @@ typedef UInt64 LargestUInt;
299
407
namespace Json {
300
408
301
409
// writer.h
410
+ class StreamWriter ;
411
+ class StreamWriterBuilder ;
412
+ class Writer ;
302
413
class FastWriter ;
303
414
class StyledWriter ;
415
+ class StyledStreamWriter ;
304
416
305
417
// reader.h
306
418
class Reader ;
419
+ class CharReader ;
420
+ class CharReaderBuilder ;
307
421
308
- // features .h
422
+ // json_features .h
309
423
class Features ;
310
424
311
425
// value.h
312
- typedef unsigned int ArrayIndex ;
426
+ using ArrayIndex = unsigned int ;
313
427
class StaticString ;
314
428
class Path ;
315
429
class PathArgument ;
0 commit comments