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