Skip to content

Commit f53396b

Browse files
ZughyZughy
and
Zughy
authoredOct 21, 2020
Update jsoncpp to 1.9.4 (#10477)
Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
1 parent 4d9c918 commit f53396b

File tree

4 files changed

+2473
-2283
lines changed

4 files changed

+2473
-2283
lines changed
 

‎lib/jsoncpp/json/UPDATING

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
cd ..
3-
git clone https://github.com/open-source-parsers/jsoncpp -b 1.8.3 --depth 1
3+
git clone https://github.com/open-source-parsers/jsoncpp -b 1.9.4 --depth 1
44
cd jsoncpp
55
python amalgamate.py
66
cp -R dist/json ../json

‎lib/jsoncpp/json/json-forwards.h

+240-126
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,151 @@ license you like.
7979
/// to prevent private header inclusion.
8080
#define JSON_IS_AMALGAMATION
8181

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+
82227
// //////////////////////////////////////////////////////////////////////
83228
// Beginning of content of file: include/json/config.h
84229
// //////////////////////////////////////////////////////////////////////
@@ -90,184 +235,147 @@ license you like.
90235

91236
#ifndef JSON_CONFIG_H_INCLUDED
92237
#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>
106246

107247
// If non-zero, the library uses exceptions to report bad input instead of C
108248
// assertion macros. The default is to use exceptions.
109249
#ifndef JSON_USE_EXCEPTION
110250
#define JSON_USE_EXCEPTION 1
111251
#endif
112252

253+
// Temporary, tracked for removal with issue #982.
254+
#ifndef JSON_USE_NULLREF
255+
#define JSON_USE_NULLREF 1
256+
#endif
257+
113258
/// If defined, indicates that the source file is amalgamated
114259
/// to prevent private header inclusion.
115260
/// Remarks: it is automatically defined in the generated amalgamated header.
116261
// #define JSON_IS_AMALGAMATION
117262

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)
128265
#if defined(_MSC_VER) || defined(__MINGW32__)
129266
#define JSON_API __declspec(dllexport)
130267
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
268+
#elif defined(__GNUC__) || defined(__clang__)
269+
#define JSON_API __attribute__((visibility("default")))
131270
#endif // if defined(_MSC_VER)
271+
132272
#elif defined(JSON_DLL)
133273
#if defined(_MSC_VER) || defined(__MINGW32__)
134274
#define JSON_API __declspec(dllimport)
135275
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
136276
#endif // if defined(_MSC_VER)
137-
#endif // ifdef JSON_IN_CPPTL
277+
#endif // ifdef JSON_DLL_BUILD
278+
138279
#if !defined(JSON_API)
139280
#define JSON_API
140281
#endif
141282

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
146287

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
178294
#else
179-
# define JSONCPP_OVERRIDE
180-
# define JSONCPP_NOEXCEPT throw()
295+
#define jsoncpp_snprintf std::snprintf
181296
#endif
182297

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
184302

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
188306

189307
#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)))
205310
#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
218321

219322
#if !defined(JSONCPP_DEPRECATED)
220323
#define JSONCPP_DEPRECATED(message)
221324
#endif // if !defined(JSONCPP_DEPRECATED)
222325

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
225328
#endif
226329

227330
#if !defined(JSON_IS_AMALGAMATION)
228331

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"
234334

235335
#endif // if !defined(JSON_IS_AMALGAMATION)
236336

237337
namespace Json {
238-
typedef int Int;
239-
typedef unsigned int UInt;
338+
using Int = int;
339+
using UInt = unsigned int;
240340
#if defined(JSON_NO_INT64)
241-
typedef int LargestInt;
242-
typedef unsigned int LargestUInt;
341+
using LargestInt = int;
342+
using LargestUInt = unsigned int;
243343
#undef JSON_HAS_INT64
244344
#else // if defined(JSON_NO_INT64)
245345
// For Microsoft Visual use specific types as long long is not supported
246346
#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;
249349
#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;
255355
#define JSON_HAS_INT64
256356
#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;
271379

272380
#endif // JSON_CONFIG_H_INCLUDED
273381

@@ -299,17 +407,23 @@ typedef UInt64 LargestUInt;
299407
namespace Json {
300408

301409
// writer.h
410+
class StreamWriter;
411+
class StreamWriterBuilder;
412+
class Writer;
302413
class FastWriter;
303414
class StyledWriter;
415+
class StyledStreamWriter;
304416

305417
// reader.h
306418
class Reader;
419+
class CharReader;
420+
class CharReaderBuilder;
307421

308-
// features.h
422+
// json_features.h
309423
class Features;
310424

311425
// value.h
312-
typedef unsigned int ArrayIndex;
426+
using ArrayIndex = unsigned int;
313427
class StaticString;
314428
class Path;
315429
class PathArgument;

‎lib/jsoncpp/json/json.h

+881-745
Large diffs are not rendered by default.

‎lib/jsoncpp/jsoncpp.cpp

+1,351-1,411
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.