blob: c83e78a3f21515abeb02351653e66f2fd17ce461 [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
Christopher Dunn779d8a32016-02-06 09:49:29 -06008#include <stddef.h>
yiqiju4a431bc2016-09-27 17:47:51 -07009#include <string> //typedef String
Vicente Olivert Rieraab0f1e22016-09-26 11:16:38 +010010#include <stdint.h> //typedef int64_t, uint64_t
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
Baptiste Lepilleur64e40aa2011-05-01 20:13:40 +000028/// If defined, indicates that the source file is amalgated
29/// to prevent private header inclusion.
30/// Remarks: it is automatically defined in the generated amalgated 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
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100057// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
58// integer
Baptiste Lepilleur842e9ac2010-12-27 17:45:23 +000059// Storages, and 64 bits integer support is disabled.
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +000060// #define JSON_NO_INT64 1
61
Motti2b008912015-04-20 17:44:47 +030062#if defined(_MSC_VER) // MSVC
63# if _MSC_VER <= 1200 // MSVC 6
Christopher Dunna4ce2822015-10-19 23:40:47 -050064 // Microsoft Visual Studio 6 only support conversion from __int64 to double
65 // (no conversion from unsigned __int64).
Motti2b008912015-04-20 17:44:47 +030066# define JSON_USE_INT64_DOUBLE_CONVERSION 1
Christopher Dunna4ce2822015-10-19 23:40:47 -050067 // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
68 // characters in the debug information)
69 // All projects I've ever seen with VS6 were using this globally (not bothering
70 // with pragma push/pop).
71# pragma warning(disable : 4786)
Motti2b008912015-04-20 17:44:47 +030072# endif // MSVC 6
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +000073
Motti2b008912015-04-20 17:44:47 +030074# if _MSC_VER >= 1500 // MSVC 2008
Christopher Dunna4ce2822015-10-19 23:40:47 -050075 /// Indicates that the following function is deprecated.
Motti2b008912015-04-20 17:44:47 +030076# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
77# endif
78
79#endif // defined(_MSC_VER)
80
Jean-Christophe Fillion-Robinba6fa482016-04-25 17:35:12 -040081// In c++11 the override keyword allows you to explicity define that a function
82// is intended to override the base-class version. This makes the code more
83// managable and fixes a set of common hard-to-find bugs.
Christopher Dunne0f9aab2016-06-26 17:52:19 -050084#if __cplusplus >= 201103L
Steven Hahn55176b22016-05-25 18:28:22 -040085# define JSONCPP_OVERRIDE override
Omkar Wagh91c1d232016-11-07 13:57:00 -050086# define JSONCPP_NOEXCEPT noexcept
87#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
Christopher Dunn98e981d2016-03-21 21:00:24 -050088# define JSONCPP_OVERRIDE override
Omkar Wagh91c1d232016-11-07 13:57:00 -050089# define JSONCPP_NOEXCEPT throw()
90#elif defined(_MSC_VER) && _MSC_VER >= 1900
91# define JSONCPP_OVERRIDE override
92# define JSONCPP_NOEXCEPT noexcept
Jean-Christophe Fillion-Robinba6fa482016-04-25 17:35:12 -040093#else
94# define JSONCPP_OVERRIDE
Omkar Wagh91c1d232016-11-07 13:57:00 -050095# define JSONCPP_NOEXCEPT throw()
Jean-Christophe Fillion-Robinba6fa482016-04-25 17:35:12 -040096#endif
Motti2b008912015-04-20 17:44:47 +030097
98#ifndef JSON_HAS_RVALUE_REFERENCES
99
100#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
101#define JSON_HAS_RVALUE_REFERENCES 1
102#endif // MSVC >= 2010
103
104#ifdef __clang__
105#if __has_feature(cxx_rvalue_references)
106#define JSON_HAS_RVALUE_REFERENCES 1
107#endif // has_feature
108
109#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
110#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
111#define JSON_HAS_RVALUE_REFERENCES 1
112#endif // GXX_EXPERIMENTAL
113
114#endif // __clang__ || __GNUC__
115
116#endif // not defined JSON_HAS_RVALUE_REFERENCES
117
118#ifndef JSON_HAS_RVALUE_REFERENCES
119#define JSON_HAS_RVALUE_REFERENCES 0
Dani-Hub50039832015-03-08 18:48:24 +0100120#endif
Motti2b008912015-04-20 17:44:47 +0300121
122#ifdef __clang__
damiramef16a352017-08-02 22:44:42 -0700123# if __has_extension(attribute_deprecated_with_message)
124# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
125# endif
Motti2b008912015-04-20 17:44:47 +0300126#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
127# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
128# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
129# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
130# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
131# endif // GNUC version
132#endif // __clang__ || __GNUC__
Baptiste Lepilleurb2e8ccc2011-05-01 16:27:55 +0000133
134#if !defined(JSONCPP_DEPRECATED)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000135#define JSONCPP_DEPRECATED(message)
Baptiste Lepilleurb2e8ccc2011-05-01 16:27:55 +0000136#endif // if !defined(JSONCPP_DEPRECATED)
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +0000137
Christopher Dunn95f120f2016-02-07 11:09:41 -0600138#if __GNUC__ >= 6
139# define JSON_USE_INT64_DOUBLE_CONVERSION 1
140#endif
141
Christopher Dunn12c67e82016-03-21 20:33:15 -0500142#if !defined(JSON_IS_AMALGAMATION)
dawescf8674c62016-03-06 11:42:11 -0600143
Christopher Dunn12c67e82016-03-21 20:33:15 -0500144# include "version.h"
145
146# if JSONCPP_USING_SECURE_MEMORY
147# include "allocator.h" //typedef Allocator
148# endif
149
150#endif // if !defined(JSON_IS_AMALGAMATION)
dawescf8674c62016-03-06 11:42:11 -0600151
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +0000152namespace Json {
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000153typedef int Int;
154typedef unsigned int UInt;
155#if defined(JSON_NO_INT64)
156typedef int LargestInt;
157typedef unsigned int LargestUInt;
158#undef JSON_HAS_INT64
159#else // if defined(JSON_NO_INT64)
160// For Microsoft Visual use specific types as long long is not supported
161#if defined(_MSC_VER) // Microsoft Visual Studio
162typedef __int64 Int64;
163typedef unsigned __int64 UInt64;
164#else // if defined(_MSC_VER) // Other platforms, use long long
Christopher Dunnb9afdf12016-08-21 19:58:43 -0500165typedef int64_t Int64;
166typedef uint64_t UInt64;
Aaron Jacobs3a0c4fc2014-07-01 09:20:48 +1000167#endif // if defined(_MSC_VER)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000168typedef Int64 LargestInt;
169typedef UInt64 LargestUInt;
170#define JSON_HAS_INT64
171#endif // if defined(JSON_NO_INT64)
dawescae564652016-03-14 19:11:02 -0500172#if JSONCPP_USING_SECURE_MEMORY
173#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
174#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
dawescf8674c62016-03-06 11:42:11 -0600175#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
dawescae564652016-03-14 19:11:02 -0500176#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
dawescf8674c62016-03-06 11:42:11 -0600177#define JSONCPP_ISTREAM std::istream
178#else
Christopher Dunnde5b7922016-03-06 11:19:46 -0600179#define JSONCPP_STRING std::string
180#define JSONCPP_OSTRINGSTREAM std::ostringstream
181#define JSONCPP_OSTREAM std::ostream
182#define JSONCPP_ISTRINGSTREAM std::istringstream
183#define JSONCPP_ISTREAM std::istream
dawescae564652016-03-14 19:11:02 -0500184#endif // if JSONCPP_USING_SECURE_MEMORY
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +0000185} // end namespace Json
186
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000187#endif // JSON_CONFIG_H_INCLUDED