blob: 606cc85f2a6079ba3efc446ba447a0ddf59e126f [file] [log] [blame]
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +00001// Copyright 2007-2010 Baptiste Lepilleur
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
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>
Christopher Dunnde5b7922016-03-06 11:19:46 -06009#include <string> //typdef String
Christopher Dunn6d135cb2007-06-13 15:51:04 +000010
11/// If defined, indicates that json library is embedded in CppTL library.
12//# define JSON_IN_CPPTL 1
13
14/// If defined, indicates that json may leverage CppTL library
15//# define JSON_USE_CPPTL 1
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100016/// If defined, indicates that cpptl vector based map should be used instead of
17/// std::map
Christopher Dunn6d135cb2007-06-13 15:51:04 +000018/// as Value container.
19//# define JSON_USE_CPPTL_SMALLMAP 1
Christopher Dunn6d135cb2007-06-13 15:51:04 +000020
Aaron Jacobs7c507d72011-09-14 08:41:37 +000021// If non-zero, the library uses exceptions to report bad input instead of C
22// assertion macros. The default is to use exceptions.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100023#ifndef JSON_USE_EXCEPTION
24#define JSON_USE_EXCEPTION 1
25#endif
Christopher Dunn6d135cb2007-06-13 15:51:04 +000026
Baptiste Lepilleur64e40aa2011-05-01 20:13:40 +000027/// If defined, indicates that the source file is amalgated
28/// to prevent private header inclusion.
29/// Remarks: it is automatically defined in the generated amalgated header.
Baptiste Lepilleureadc4782011-05-02 21:09:30 +000030// #define JSON_IS_AMALGAMATION
Baptiste Lepilleur64e40aa2011-05-01 20:13:40 +000031
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100032#ifdef JSON_IN_CPPTL
33#include <cpptl/config.h>
34#ifndef JSON_USE_CPPTL
35#define JSON_USE_CPPTL 1
36#endif
37#endif
Baptiste Lepilleur64e40aa2011-05-01 20:13:40 +000038
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100039#ifdef JSON_IN_CPPTL
40#define JSON_API CPPTL_API
41#elif defined(JSON_DLL_BUILD)
Gaurav8aabf932016-03-08 17:34:22 +053042#if defined(_MSC_VER) || defined(__MINGW32__)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100043#define JSON_API __declspec(dllexport)
44#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
45#endif // if defined(_MSC_VER)
46#elif defined(JSON_DLL)
Gaurav8aabf932016-03-08 17:34:22 +053047#if defined(_MSC_VER) || defined(__MINGW32__)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100048#define JSON_API __declspec(dllimport)
49#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
50#endif // if defined(_MSC_VER)
51#endif // ifdef JSON_IN_CPPTL
52#if !defined(JSON_API)
53#define JSON_API
54#endif
Christopher Dunn6d135cb2007-06-13 15:51:04 +000055
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100056// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
57// integer
Baptiste Lepilleur842e9ac2010-12-27 17:45:23 +000058// Storages, and 64 bits integer support is disabled.
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +000059// #define JSON_NO_INT64 1
60
Motti2b008912015-04-20 17:44:47 +030061#if defined(_MSC_VER) // MSVC
62# if _MSC_VER <= 1200 // MSVC 6
Christopher Dunna4ce2822015-10-19 23:40:47 -050063 // Microsoft Visual Studio 6 only support conversion from __int64 to double
64 // (no conversion from unsigned __int64).
Motti2b008912015-04-20 17:44:47 +030065# define JSON_USE_INT64_DOUBLE_CONVERSION 1
Christopher Dunna4ce2822015-10-19 23:40:47 -050066 // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
67 // characters in the debug information)
68 // All projects I've ever seen with VS6 were using this globally (not bothering
69 // with pragma push/pop).
70# pragma warning(disable : 4786)
Motti2b008912015-04-20 17:44:47 +030071# endif // MSVC 6
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +000072
Motti2b008912015-04-20 17:44:47 +030073# if _MSC_VER >= 1500 // MSVC 2008
Christopher Dunna4ce2822015-10-19 23:40:47 -050074 /// Indicates that the following function is deprecated.
Motti2b008912015-04-20 17:44:47 +030075# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
76# endif
77
78#endif // defined(_MSC_VER)
79
Jean-Christophe Fillion-Robinba6fa482016-04-25 17:35:12 -040080// In c++11 the override keyword allows you to explicity define that a function
81// is intended to override the base-class version. This makes the code more
82// managable and fixes a set of common hard-to-find bugs.
Steven Hahn55176b22016-05-25 18:28:22 -040083#if __cplusplus >= 201103L
84# define JSONCPP_OVERRIDE override
85#elif defined(_MSC_VER) && _MSC_VER > 1600
Christopher Dunn98e981d2016-03-21 21:00:24 -050086# define JSONCPP_OVERRIDE override
Jean-Christophe Fillion-Robinba6fa482016-04-25 17:35:12 -040087#else
88# define JSONCPP_OVERRIDE
89#endif
Motti2b008912015-04-20 17:44:47 +030090
91#ifndef JSON_HAS_RVALUE_REFERENCES
92
93#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
94#define JSON_HAS_RVALUE_REFERENCES 1
95#endif // MSVC >= 2010
96
97#ifdef __clang__
98#if __has_feature(cxx_rvalue_references)
99#define JSON_HAS_RVALUE_REFERENCES 1
100#endif // has_feature
101
102#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
103#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
104#define JSON_HAS_RVALUE_REFERENCES 1
105#endif // GXX_EXPERIMENTAL
106
107#endif // __clang__ || __GNUC__
108
109#endif // not defined JSON_HAS_RVALUE_REFERENCES
110
111#ifndef JSON_HAS_RVALUE_REFERENCES
112#define JSON_HAS_RVALUE_REFERENCES 0
Dani-Hub50039832015-03-08 18:48:24 +0100113#endif
Motti2b008912015-04-20 17:44:47 +0300114
115#ifdef __clang__
116#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
117# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
118# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
119# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
120# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
121# endif // GNUC version
122#endif // __clang__ || __GNUC__
Baptiste Lepilleurb2e8ccc2011-05-01 16:27:55 +0000123
124#if !defined(JSONCPP_DEPRECATED)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000125#define JSONCPP_DEPRECATED(message)
Baptiste Lepilleurb2e8ccc2011-05-01 16:27:55 +0000126#endif // if !defined(JSONCPP_DEPRECATED)
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +0000127
Christopher Dunn95f120f2016-02-07 11:09:41 -0600128#if __GNUC__ >= 6
129# define JSON_USE_INT64_DOUBLE_CONVERSION 1
130#endif
131
Christopher Dunn12c67e82016-03-21 20:33:15 -0500132#if !defined(JSON_IS_AMALGAMATION)
dawescf8674c62016-03-06 11:42:11 -0600133
Christopher Dunn12c67e82016-03-21 20:33:15 -0500134# include "version.h"
135
136# if JSONCPP_USING_SECURE_MEMORY
137# include "allocator.h" //typedef Allocator
138# endif
139
140#endif // if !defined(JSON_IS_AMALGAMATION)
dawescf8674c62016-03-06 11:42:11 -0600141
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +0000142namespace Json {
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000143typedef int Int;
144typedef unsigned int UInt;
145#if defined(JSON_NO_INT64)
146typedef int LargestInt;
147typedef unsigned int LargestUInt;
148#undef JSON_HAS_INT64
149#else // if defined(JSON_NO_INT64)
150// For Microsoft Visual use specific types as long long is not supported
151#if defined(_MSC_VER) // Microsoft Visual Studio
152typedef __int64 Int64;
153typedef unsigned __int64 UInt64;
154#else // if defined(_MSC_VER) // Other platforms, use long long
155typedef long long int Int64;
156typedef unsigned long long int UInt64;
Aaron Jacobs3a0c4fc2014-07-01 09:20:48 +1000157#endif // if defined(_MSC_VER)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000158typedef Int64 LargestInt;
159typedef UInt64 LargestUInt;
160#define JSON_HAS_INT64
161#endif // if defined(JSON_NO_INT64)
dawescae564652016-03-14 19:11:02 -0500162#if JSONCPP_USING_SECURE_MEMORY
163#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
164#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
dawescf8674c62016-03-06 11:42:11 -0600165#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
dawescae564652016-03-14 19:11:02 -0500166#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
dawescf8674c62016-03-06 11:42:11 -0600167#define JSONCPP_ISTREAM std::istream
168#else
Christopher Dunnde5b7922016-03-06 11:19:46 -0600169#define JSONCPP_STRING std::string
170#define JSONCPP_OSTRINGSTREAM std::ostringstream
171#define JSONCPP_OSTREAM std::ostream
172#define JSONCPP_ISTRINGSTREAM std::istringstream
173#define JSONCPP_ISTREAM std::istream
dawescae564652016-03-14 19:11:02 -0500174#endif // if JSONCPP_USING_SECURE_MEMORY
Baptiste Lepilleur201fb2c2010-04-19 07:37:41 +0000175} // end namespace Json
176
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000177#endif // JSON_CONFIG_H_INCLUDED