blob: 5049c7321206335ecb1d64bc0ceae052b625c6e9 [file] [log] [blame]
Devin Jeanpierre59e4d352017-07-21 03:44:36 -07001// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +00002// 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
Christopher Dunn6d135cb2007-06-13 15:51:04 +00006#ifndef JSON_CONFIG_H_INCLUDED
Aaron Jacobs9fa4e842014-07-01 08:48:54 +10007#define JSON_CONFIG_H_INCLUDED
Hans Johnsone50bfef2018-12-12 13:34:37 -06008#include <cstddef>
9#include <cstdint> //typedef int64_t, uint64_t
Billy Donahueb5e1fe82018-05-20 16:55:27 -040010#include <string> //typedef String
Christopher Dunn6d135cb2007-06-13 15:51:04 +000011
12/// If defined, indicates that json library is embedded in CppTL library.
13//# define JSON_IN_CPPTL 1
14
15/// If defined, indicates that json may leverage CppTL library
16//# define JSON_USE_CPPTL 1
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100017/// If defined, indicates that cpptl vector based map should be used instead of
18/// std::map
Christopher Dunn6d135cb2007-06-13 15:51:04 +000019/// as Value container.
20//# define JSON_USE_CPPTL_SMALLMAP 1
Christopher Dunn6d135cb2007-06-13 15:51:04 +000021
Aaron Jacobs7c507d72011-09-14 08:41:37 +000022// If non-zero, the library uses exceptions to report bad input instead of C
23// assertion macros. The default is to use exceptions.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100024#ifndef JSON_USE_EXCEPTION
25#define JSON_USE_EXCEPTION 1
26#endif
Christopher Dunn6d135cb2007-06-13 15:51:04 +000027
Josh Sorefe6a588a2017-12-03 11:54:29 -050028/// If defined, indicates that the source file is amalgamated
Baptiste Lepilleur64e40aa2011-05-01 20:13:40 +000029/// to prevent private header inclusion.
Josh Sorefe6a588a2017-12-03 11:54:29 -050030/// Remarks: it is automatically defined in the generated amalgamated header.
Baptiste Lepilleureadc4782011-05-02 21:09:30 +000031// #define JSON_IS_AMALGAMATION
Baptiste Lepilleur64e40aa2011-05-01 20:13:40 +000032
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100033#ifdef JSON_IN_CPPTL
34#include <cpptl/config.h>
35#ifndef JSON_USE_CPPTL
36#define JSON_USE_CPPTL 1
37#endif
38#endif
Baptiste Lepilleur64e40aa2011-05-01 20:13:40 +000039
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100040#ifdef JSON_IN_CPPTL
41#define JSON_API CPPTL_API
42#elif defined(JSON_DLL_BUILD)
Gaurav8aabf932016-03-08 17:34:22 +053043#if defined(_MSC_VER) || defined(__MINGW32__)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100044#define JSON_API __declspec(dllexport)
45#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
46#endif // if defined(_MSC_VER)
47#elif defined(JSON_DLL)
Gaurav8aabf932016-03-08 17:34:22 +053048#if defined(_MSC_VER) || defined(__MINGW32__)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100049#define JSON_API __declspec(dllimport)
50#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
51#endif // if defined(_MSC_VER)
52#endif // ifdef JSON_IN_CPPTL
53#if !defined(JSON_API)
54#define JSON_API
55#endif
Christopher Dunn6d135cb2007-06-13 15:51:04 +000056
Hans Johnson5c8e5392018-12-12 13:31:55 -060057#if defined(_MSC_VER) && _MSC_VER < 1900
58// As recommended at https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
59 extern JSON_API int msvc_pre1900_c99_snprintf(char *outBuf, size_t size, const char *format, ...);
60# define jsoncpp_snprintf msvc_pre1900_c99_snprintf
61#else
62# define jsoncpp_snprintf std::snprintf
63#endif
64
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100065// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
66// integer
Baptiste Lepilleur842e9ac2010-12-27 17:45:23 +000067// Storages, and 64 bits integer support is disabled.
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +000068// #define JSON_NO_INT64 1
69
Motti2b008912015-04-20 17:44:47 +030070#if defined(_MSC_VER) // MSVC
Billy Donahueb5e1fe82018-05-20 16:55:27 -040071#if _MSC_VER <= 1200 // MSVC 6
72// Microsoft Visual Studio 6 only support conversion from __int64 to double
73// (no conversion from unsigned __int64).
74#define JSON_USE_INT64_DOUBLE_CONVERSION 1
75// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
76// characters in the debug information)
77// All projects I've ever seen with VS6 were using this globally (not bothering
78// with pragma push/pop).
79#pragma warning(disable : 4786)
80#endif // MSVC 6
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +000081
Billy Donahueb5e1fe82018-05-20 16:55:27 -040082#if _MSC_VER >= 1500 // MSVC 2008
83 /// Indicates that the following function is deprecated.
84#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
85#endif
Motti2b008912015-04-20 17:44:47 +030086
87#endif // defined(_MSC_VER)
88
Josh Sorefe6a588a2017-12-03 11:54:29 -050089// In c++11 the override keyword allows you to explicitly define that a function
Jean-Christophe Fillion-Robinba6fa482016-04-25 17:35:12 -040090// is intended to override the base-class version. This makes the code more
luzpaz5b45aa52018-02-08 20:05:50 -050091// manageable and fixes a set of common hard-to-find bugs.
Hans Johnson2853b1c2019-01-11 13:58:53 -060092#define JSONCPP_OVERRIDE override // Define maintained for backwards compatibility of external tools. C++11 should be used directly in JSONCPP
Christopher Dunne0f9aab2016-06-26 17:52:19 -050093#if __cplusplus >= 201103L
Billy Donahueb5e1fe82018-05-20 16:55:27 -040094#define JSONCPP_NOEXCEPT noexcept
95#define JSONCPP_OP_EXPLICIT explicit
Omkar Wagh91c1d232016-11-07 13:57:00 -050096#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
Billy Donahueb5e1fe82018-05-20 16:55:27 -040097#define JSONCPP_NOEXCEPT throw()
98#if _MSC_VER >= 1800 // MSVC 2013
99#define JSONCPP_OP_EXPLICIT explicit
Jean-Christophe Fillion-Robinba6fa482016-04-25 17:35:12 -0400100#else
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400101#define JSONCPP_OP_EXPLICIT
102#endif
103#elif defined(_MSC_VER) && _MSC_VER >= 1900
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400104#define JSONCPP_NOEXCEPT noexcept
105#define JSONCPP_OP_EXPLICIT explicit
106#else
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400107#define JSONCPP_NOEXCEPT throw()
108#define JSONCPP_OP_EXPLICIT
Jean-Christophe Fillion-Robinba6fa482016-04-25 17:35:12 -0400109#endif
Motti2b008912015-04-20 17:44:47 +0300110
111#ifndef JSON_HAS_RVALUE_REFERENCES
112
113#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
114#define JSON_HAS_RVALUE_REFERENCES 1
115#endif // MSVC >= 2010
116
117#ifdef __clang__
118#if __has_feature(cxx_rvalue_references)
119#define JSON_HAS_RVALUE_REFERENCES 1
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400120#endif // has_feature
Motti2b008912015-04-20 17:44:47 +0300121
122#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
123#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
124#define JSON_HAS_RVALUE_REFERENCES 1
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400125#endif // GXX_EXPERIMENTAL
Motti2b008912015-04-20 17:44:47 +0300126
127#endif // __clang__ || __GNUC__
128
129#endif // not defined JSON_HAS_RVALUE_REFERENCES
130
131#ifndef JSON_HAS_RVALUE_REFERENCES
132#define JSON_HAS_RVALUE_REFERENCES 0
Dani-Hub50039832015-03-08 18:48:24 +0100133#endif
Motti2b008912015-04-20 17:44:47 +0300134
135#ifdef __clang__
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400136#if __has_extension(attribute_deprecated_with_message)
137#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
138#endif
Motti2b008912015-04-20 17:44:47 +0300139#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400140#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
141#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
142#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
143#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
144#endif // GNUC version
Motti2b008912015-04-20 17:44:47 +0300145#endif // __clang__ || __GNUC__
Baptiste Lepilleurb2e8ccc2011-05-01 16:27:55 +0000146
147#if !defined(JSONCPP_DEPRECATED)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000148#define JSONCPP_DEPRECATED(message)
Baptiste Lepilleurb2e8ccc2011-05-01 16:27:55 +0000149#endif // if !defined(JSONCPP_DEPRECATED)
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +0000150
Christopher Dunn95f120f2016-02-07 11:09:41 -0600151#if __GNUC__ >= 6
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400152#define JSON_USE_INT64_DOUBLE_CONVERSION 1
Christopher Dunn95f120f2016-02-07 11:09:41 -0600153#endif
154
Christopher Dunn12c67e82016-03-21 20:33:15 -0500155#if !defined(JSON_IS_AMALGAMATION)
dawescf8674c62016-03-06 11:42:11 -0600156
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400157#include "version.h"
Christopher Dunn12c67e82016-03-21 20:33:15 -0500158
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400159#if JSONCPP_USING_SECURE_MEMORY
160#include "allocator.h" //typedef Allocator
161#endif
Christopher Dunn12c67e82016-03-21 20:33:15 -0500162
163#endif // if !defined(JSON_IS_AMALGAMATION)
dawescf8674c62016-03-06 11:42:11 -0600164
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +0000165namespace Json {
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000166typedef int Int;
167typedef unsigned int UInt;
168#if defined(JSON_NO_INT64)
169typedef int LargestInt;
170typedef unsigned int LargestUInt;
171#undef JSON_HAS_INT64
172#else // if defined(JSON_NO_INT64)
173// For Microsoft Visual use specific types as long long is not supported
174#if defined(_MSC_VER) // Microsoft Visual Studio
175typedef __int64 Int64;
176typedef unsigned __int64 UInt64;
177#else // if defined(_MSC_VER) // Other platforms, use long long
Christopher Dunnb9afdf12016-08-21 19:58:43 -0500178typedef int64_t Int64;
179typedef uint64_t UInt64;
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400180#endif // if defined(_MSC_VER)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000181typedef Int64 LargestInt;
182typedef UInt64 LargestUInt;
183#define JSON_HAS_INT64
184#endif // if defined(JSON_NO_INT64)
dawescae564652016-03-14 19:11:02 -0500185#if JSONCPP_USING_SECURE_MEMORY
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400186#define JSONCPP_STRING \
187 std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
188#define JSONCPP_OSTRINGSTREAM \
189 std::basic_ostringstream<char, std::char_traits<char>, \
190 Json::SecureAllocator<char> >
191#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char> >
192#define JSONCPP_ISTRINGSTREAM \
193 std::basic_istringstream<char, std::char_traits<char>, \
194 Json::SecureAllocator<char> >
195#define JSONCPP_ISTREAM std::istream
dawescf8674c62016-03-06 11:42:11 -0600196#else
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400197#define JSONCPP_STRING std::string
Christopher Dunnde5b7922016-03-06 11:19:46 -0600198#define JSONCPP_OSTRINGSTREAM std::ostringstream
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400199#define JSONCPP_OSTREAM std::ostream
Christopher Dunnde5b7922016-03-06 11:19:46 -0600200#define JSONCPP_ISTRINGSTREAM std::istringstream
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400201#define JSONCPP_ISTREAM std::istream
dawescae564652016-03-14 19:11:02 -0500202#endif // if JSONCPP_USING_SECURE_MEMORY
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +0000203} // end namespace Json
204
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000205#endif // JSON_CONFIG_H_INCLUDED