55
66#ifndef JSON_CONFIG_H_INCLUDED
77#define JSON_CONFIG_H_INCLUDED
8- #include < cstddef>
9- #include < cstdint>
8+
109#include < istream>
1110#include < memory>
1211#include < ostream>
1312#include < sstream>
1413#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
1622
1723// If non-zero, the library uses exceptions to report bad input instead of C
1824// assertion macros. The default is to use exceptions.
5056#define JSON_API
5157#endif
5258
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-
5859#if defined(_MSC_VER) && _MSC_VER < 1900
5960// As recommended at
6061// 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,
7071// Storages, and 64 bits integer support is disabled.
7172// #define JSON_NO_INT64 1
7273
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
7595#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
76105
106+ // Define *deprecated* attribute
107+ // [[deprecated]] is in C++14 or in Visual Studio 2015 and later
108+ // For compatibility, [[deprecated]] is not used
77109#ifdef __clang__
78110#if __has_extension(attribute_deprecated_with_message)
79111#define JSONCPP_DEPRECATED (message ) __attribute__((deprecated(message)))
@@ -98,33 +130,36 @@ extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
98130#endif
99131
100132#if !defined(JSON_IS_AMALGAMATION)
101-
133+ # if JSONCPP_CXX_STD_11
102134#include " allocator.h"
135+ #endif
103136#include " version.h"
104137
105138#endif // if !defined(JSON_IS_AMALGAMATION)
106139
107140namespace Json {
108- using Int = int ;
109- using UInt = unsigned int ;
141+
142+ typedef int Int;
143+ typedef unsigned int UInt;
110144#if defined(JSON_NO_INT64)
111- using LargestInt = int ;
112- using LargestUInt = unsigned int ;
145+ typedef int LargestInt ;
146+ typedef unsigned int LargestUInt ;
113147#undef JSON_HAS_INT64
114148#else // if defined(JSON_NO_INT64)
115149// For Microsoft Visual use specific types as long long is not supported
116150#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 ;
119153#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 ;
122156#endif // if defined(_MSC_VER)
123- using LargestInt = Int64;
124- using LargestUInt = UInt64;
157+ typedef Int64 LargestInt ;
158+ typedef UInt64 LargestUInt ;
125159#define JSON_HAS_INT64
126160#endif // if defined(JSON_NO_INT64)
127161
162+ #if JSONCPP_CXX_STD_11
128163template <typename T>
129164using Allocator =
130165 typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
@@ -138,13 +173,20 @@ using OStringStream =
138173 String::allocator_type>;
139174using IStream = std::istream;
140175using 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
141183} // namespace Json
142184
143185// 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 ;
149191
150192#endif // JSON_CONFIG_H_INCLUDED
0 commit comments