JsonCpp project page Classes Namespace JsonCpp home page

config.h
Go to the documentation of this file.
1 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
2 // Distributed under MIT license, or public domain if desired and
3 // recognized in your jurisdiction.
4 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5 
6 #ifndef JSON_CONFIG_H_INCLUDED
7 #define JSON_CONFIG_H_INCLUDED
8 #include <cstddef>
9 #include <cstdint>
10 #include <istream>
11 #include <memory>
12 #include <ostream>
13 #include <sstream>
14 #include <string>
15 #include <type_traits>
16 
18 //# define JSON_IN_CPPTL 1
19 
21 //# define JSON_USE_CPPTL 1
25 //# define JSON_USE_CPPTL_SMALLMAP 1
26 
27 // If non-zero, the library uses exceptions to report bad input instead of C
28 // assertion macros. The default is to use exceptions.
29 #ifndef JSON_USE_EXCEPTION
30 #define JSON_USE_EXCEPTION 1
31 #endif
32 
36 // #define JSON_IS_AMALGAMATION
37 
38 #ifdef JSON_IN_CPPTL
39 #include <cpptl/config.h>
40 #ifndef JSON_USE_CPPTL
41 #define JSON_USE_CPPTL 1
42 #endif
43 #endif
44 
45 #ifdef JSON_IN_CPPTL
46 #define JSON_API CPPTL_API
47 #elif defined(JSON_DLL_BUILD)
48 #if defined(_MSC_VER) || defined(__MINGW32__)
49 #define JSON_API __declspec(dllexport)
50 #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
51 #elif defined(__GNUC__) || defined(__clang__)
52 #define JSON_API __attribute__((visibility("default")))
53 #endif // if defined(_MSC_VER)
54 #elif defined(JSON_DLL)
55 #if defined(_MSC_VER) || defined(__MINGW32__)
56 #define JSON_API __declspec(dllimport)
57 #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
58 #endif // if defined(_MSC_VER)
59 #endif // ifdef JSON_IN_CPPTL
60 #if !defined(JSON_API)
61 #define JSON_API
62 #endif
63 
64 #if defined(_MSC_VER) && _MSC_VER < 1800
65 #error \
66  "ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
67 #endif
68 
69 #if defined(_MSC_VER) && _MSC_VER < 1900
70 // As recommended at
71 // https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
72 extern JSON_API int
73 msvc_pre1900_c99_snprintf(char* outBuf, size_t size, const char* format, ...);
74 #define jsoncpp_snprintf msvc_pre1900_c99_snprintf
75 #else
76 #define jsoncpp_snprintf std::snprintf
77 #endif
78 
79 // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
80 // integer
81 // Storages, and 64 bits integer support is disabled.
82 // #define JSON_NO_INT64 1
83 
84 // JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
85 // C++11 should be used directly in JSONCPP.
86 #define JSONCPP_OVERRIDE override
87 
88 #if __cplusplus >= 201103L
89 #define JSONCPP_NOEXCEPT noexcept
90 #define JSONCPP_OP_EXPLICIT explicit
91 #elif defined(_MSC_VER) && _MSC_VER < 1900
92 #define JSONCPP_NOEXCEPT throw()
93 #define JSONCPP_OP_EXPLICIT explicit
94 #elif defined(_MSC_VER) && _MSC_VER >= 1900
95 #define JSONCPP_NOEXCEPT noexcept
96 #define JSONCPP_OP_EXPLICIT explicit
97 #else
98 #define JSONCPP_NOEXCEPT throw()
99 #define JSONCPP_OP_EXPLICIT
100 #endif
101 
102 #ifdef __clang__
103 #if __has_extension(attribute_deprecated_with_message)
104 #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
105 #endif
106 #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
107 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
108 #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
109 #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
110 #define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
111 #endif // GNUC version
112 #elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
113  // MSVC)
114 #define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
115 #endif // __clang__ || __GNUC__ || _MSC_VER
116 
117 #if !defined(JSONCPP_DEPRECATED)
118 #define JSONCPP_DEPRECATED(message)
119 #endif // if !defined(JSONCPP_DEPRECATED)
120 
121 #if __GNUC__ >= 6
122 #define JSON_USE_INT64_DOUBLE_CONVERSION 1
123 #endif
124 
125 #if !defined(JSON_IS_AMALGAMATION)
126 
127 #include "allocator.h"
128 #include "version.h"
129 
130 #endif // if !defined(JSON_IS_AMALGAMATION)
131 
132 namespace Json {
133 typedef int Int;
134 typedef unsigned int UInt;
135 #if defined(JSON_NO_INT64)
136 typedef int LargestInt;
137 typedef unsigned int LargestUInt;
138 #undef JSON_HAS_INT64
139 #else // if defined(JSON_NO_INT64)
140 // For Microsoft Visual use specific types as long long is not supported
141 #if defined(_MSC_VER) // Microsoft Visual Studio
142 typedef __int64 Int64;
143 typedef unsigned __int64 UInt64;
144 #else // if defined(_MSC_VER) // Other platforms, use long long
145 typedef int64_t Int64;
146 typedef uint64_t UInt64;
147 #endif // if defined(_MSC_VER)
150 #define JSON_HAS_INT64
151 #endif // if defined(JSON_NO_INT64)
152 
153 template <typename T>
154 using Allocator = typename std::conditional<JSONCPP_USING_SECURE_MEMORY,
155  SecureAllocator<T>,
156  std::allocator<T>>::type;
157 using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
158 using IStringStream = std::basic_istringstream<String::value_type,
159  String::traits_type,
160  String::allocator_type>;
161 using OStringStream = std::basic_ostringstream<String::value_type,
162  String::traits_type,
163  String::allocator_type>;
164 using IStream = std::istream;
165 using OStream = std::ostream;
166 } // namespace Json
167 
168 // Legacy names (formerly macros).
174 
175 #endif // JSON_CONFIG_H_INCLUDED
Int64 LargestInt
Definition: config.h:148
#define JSON_API
If defined, indicates that the source file is amalgamated to prevent private header inclusion...
Definition: config.h:61
Json::IStream JSONCPP_ISTREAM
Definition: config.h:172
unsigned __int64 UInt64
Definition: config.h:143
std::basic_istringstream< String::value_type, String::traits_type, String::allocator_type > IStringStream
Definition: config.h:160
Json::String JSONCPP_STRING
Definition: config.h:169
Json::OStringStream JSONCPP_OSTRINGSTREAM
Definition: config.h:171
std::basic_ostringstream< String::value_type, String::traits_type, String::allocator_type > OStringStream
Definition: config.h:163
UInt64 LargestUInt
Definition: config.h:149
JSON (JavaScript Object Notation).
Definition: allocator.h:14
int msvc_pre1900_c99_snprintf(char *outBuf, size_t size, const char *format,...)
Definition: json_value.cpp:37
Json::OStream JSONCPP_OSTREAM
Definition: config.h:173
unsigned int UInt
Definition: config.h:134
std::istream IStream
Definition: config.h:164
typename std::conditional< JSONCPP_USING_SECURE_MEMORY, SecureAllocator< T >, std::allocator< T > >::type Allocator
Definition: config.h:156
__int64 Int64
Definition: config.h:142
std::ostream OStream
Definition: config.h:165
Json::IStringStream JSONCPP_ISTRINGSTREAM
Definition: config.h:170
int Int
Definition: config.h:133
std::basic_string< char, std::char_traits< char >, Allocator< char > > String
Definition: config.h:157