Devin Jeanpierre | 59e4d35 | 2017-07-21 03:44:36 -0700 | [diff] [blame] | 1 | // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 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 Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 6 | #ifndef JSON_CONFIG_H_INCLUDED |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 7 | #define JSON_CONFIG_H_INCLUDED |
Hans Johnson | e50bfef | 2018-12-12 13:34:37 -0600 | [diff] [blame] | 8 | #include <cstddef> |
| 9 | #include <cstdint> //typedef int64_t, uint64_t |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 10 | #include <string> //typedef String |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 11 | |
| 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 Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 17 | /// If defined, indicates that cpptl vector based map should be used instead of |
| 18 | /// std::map |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 19 | /// as Value container. |
| 20 | //# define JSON_USE_CPPTL_SMALLMAP 1 |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 21 | |
Aaron Jacobs | 7c507d7 | 2011-09-14 08:41:37 +0000 | [diff] [blame] | 22 | // If non-zero, the library uses exceptions to report bad input instead of C |
| 23 | // assertion macros. The default is to use exceptions. |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 24 | #ifndef JSON_USE_EXCEPTION |
| 25 | #define JSON_USE_EXCEPTION 1 |
| 26 | #endif |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 27 | |
Josh Soref | e6a588a | 2017-12-03 11:54:29 -0500 | [diff] [blame] | 28 | /// If defined, indicates that the source file is amalgamated |
Baptiste Lepilleur | 64e40aa | 2011-05-01 20:13:40 +0000 | [diff] [blame] | 29 | /// to prevent private header inclusion. |
Josh Soref | e6a588a | 2017-12-03 11:54:29 -0500 | [diff] [blame] | 30 | /// Remarks: it is automatically defined in the generated amalgamated header. |
Baptiste Lepilleur | eadc478 | 2011-05-02 21:09:30 +0000 | [diff] [blame] | 31 | // #define JSON_IS_AMALGAMATION |
Baptiste Lepilleur | 64e40aa | 2011-05-01 20:13:40 +0000 | [diff] [blame] | 32 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 33 | #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 Lepilleur | 64e40aa | 2011-05-01 20:13:40 +0000 | [diff] [blame] | 39 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 40 | #ifdef JSON_IN_CPPTL |
| 41 | #define JSON_API CPPTL_API |
| 42 | #elif defined(JSON_DLL_BUILD) |
Gaurav | 8aabf93 | 2016-03-08 17:34:22 +0530 | [diff] [blame] | 43 | #if defined(_MSC_VER) || defined(__MINGW32__) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 44 | #define JSON_API __declspec(dllexport) |
| 45 | #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING |
| 46 | #endif // if defined(_MSC_VER) |
| 47 | #elif defined(JSON_DLL) |
Gaurav | 8aabf93 | 2016-03-08 17:34:22 +0530 | [diff] [blame] | 48 | #if defined(_MSC_VER) || defined(__MINGW32__) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 49 | #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 Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 56 | |
Hans Johnson | 31d6571 | 2019-01-11 14:13:08 -0600 | [diff] [blame] | 57 | #if defined(_MSC_VER) && _MSC_VER < 1800 |
| 58 | #error "ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities" |
| 59 | #endif |
| 60 | |
Hans Johnson | 5c8e539 | 2018-12-12 13:31:55 -0600 | [diff] [blame] | 61 | #if defined(_MSC_VER) && _MSC_VER < 1900 |
| 62 | // As recommended at https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 |
| 63 | extern JSON_API int msvc_pre1900_c99_snprintf(char *outBuf, size_t size, const char *format, ...); |
| 64 | # define jsoncpp_snprintf msvc_pre1900_c99_snprintf |
| 65 | #else |
| 66 | # define jsoncpp_snprintf std::snprintf |
| 67 | #endif |
| 68 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 69 | // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for |
| 70 | // integer |
Baptiste Lepilleur | 842e9ac | 2010-12-27 17:45:23 +0000 | [diff] [blame] | 71 | // Storages, and 64 bits integer support is disabled. |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 72 | // #define JSON_NO_INT64 1 |
| 73 | |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 74 | #if defined(_MSC_VER) // MSVC |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 75 | #define JSONCPP_DEPRECATED(message) __declspec(deprecated(message)) |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 76 | #endif // defined(_MSC_VER) |
| 77 | |
Josh Soref | e6a588a | 2017-12-03 11:54:29 -0500 | [diff] [blame] | 78 | // In c++11 the override keyword allows you to explicitly define that a function |
Jean-Christophe Fillion-Robin | ba6fa48 | 2016-04-25 17:35:12 -0400 | [diff] [blame] | 79 | // is intended to override the base-class version. This makes the code more |
luzpaz | 5b45aa5 | 2018-02-08 20:05:50 -0500 | [diff] [blame] | 80 | // manageable and fixes a set of common hard-to-find bugs. |
Hans Johnson | 2853b1c | 2019-01-11 13:58:53 -0600 | [diff] [blame] | 81 | #define JSONCPP_OVERRIDE override // Define maintained for backwards compatibility of external tools. C++11 should be used directly in JSONCPP |
Christopher Dunn | e0f9aab | 2016-06-26 17:52:19 -0500 | [diff] [blame] | 82 | #if __cplusplus >= 201103L |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 83 | #define JSONCPP_NOEXCEPT noexcept |
| 84 | #define JSONCPP_OP_EXPLICIT explicit |
Hans Johnson | 31d6571 | 2019-01-11 14:13:08 -0600 | [diff] [blame] | 85 | #elif defined(_MSC_VER) && _MSC_VER < 1900 |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 86 | #define JSONCPP_NOEXCEPT throw() |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 87 | #define JSONCPP_OP_EXPLICIT explicit |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 88 | #elif defined(_MSC_VER) && _MSC_VER >= 1900 |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 89 | #define JSONCPP_NOEXCEPT noexcept |
| 90 | #define JSONCPP_OP_EXPLICIT explicit |
| 91 | #else |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 92 | #define JSONCPP_NOEXCEPT throw() |
| 93 | #define JSONCPP_OP_EXPLICIT |
Jean-Christophe Fillion-Robin | ba6fa48 | 2016-04-25 17:35:12 -0400 | [diff] [blame] | 94 | #endif |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 95 | |
| 96 | #ifndef JSON_HAS_RVALUE_REFERENCES |
| 97 | |
Hans Johnson | 31d6571 | 2019-01-11 14:13:08 -0600 | [diff] [blame] | 98 | #if defined(_MSC_VER) |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 99 | #define JSON_HAS_RVALUE_REFERENCES 1 |
Hans Johnson | 31d6571 | 2019-01-11 14:13:08 -0600 | [diff] [blame] | 100 | #endif // MSVC >= 2013 |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 101 | |
| 102 | #ifdef __clang__ |
| 103 | #if __has_feature(cxx_rvalue_references) |
| 104 | #define JSON_HAS_RVALUE_REFERENCES 1 |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 105 | #endif // has_feature |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 106 | |
| 107 | #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc) |
| 108 | #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L) |
| 109 | #define JSON_HAS_RVALUE_REFERENCES 1 |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 110 | #endif // GXX_EXPERIMENTAL |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 111 | |
| 112 | #endif // __clang__ || __GNUC__ |
| 113 | |
| 114 | #endif // not defined JSON_HAS_RVALUE_REFERENCES |
| 115 | |
| 116 | #ifndef JSON_HAS_RVALUE_REFERENCES |
| 117 | #define JSON_HAS_RVALUE_REFERENCES 0 |
Dani-Hub | 5003983 | 2015-03-08 18:48:24 +0100 | [diff] [blame] | 118 | #endif |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 119 | |
| 120 | #ifdef __clang__ |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 121 | #if __has_extension(attribute_deprecated_with_message) |
| 122 | #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message))) |
| 123 | #endif |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 124 | #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc) |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 125 | #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) |
| 126 | #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message))) |
| 127 | #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) |
| 128 | #define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__)) |
| 129 | #endif // GNUC version |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 130 | #endif // __clang__ || __GNUC__ |
Baptiste Lepilleur | b2e8ccc | 2011-05-01 16:27:55 +0000 | [diff] [blame] | 131 | |
| 132 | #if !defined(JSONCPP_DEPRECATED) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 133 | #define JSONCPP_DEPRECATED(message) |
Baptiste Lepilleur | b2e8ccc | 2011-05-01 16:27:55 +0000 | [diff] [blame] | 134 | #endif // if !defined(JSONCPP_DEPRECATED) |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 135 | |
Christopher Dunn | 95f120f | 2016-02-07 11:09:41 -0600 | [diff] [blame] | 136 | #if __GNUC__ >= 6 |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 137 | #define JSON_USE_INT64_DOUBLE_CONVERSION 1 |
Christopher Dunn | 95f120f | 2016-02-07 11:09:41 -0600 | [diff] [blame] | 138 | #endif |
| 139 | |
Christopher Dunn | 12c67e8 | 2016-03-21 20:33:15 -0500 | [diff] [blame] | 140 | #if !defined(JSON_IS_AMALGAMATION) |
dawesc | f8674c6 | 2016-03-06 11:42:11 -0600 | [diff] [blame] | 141 | |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 142 | #include "version.h" |
Christopher Dunn | 12c67e8 | 2016-03-21 20:33:15 -0500 | [diff] [blame] | 143 | |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 144 | #if JSONCPP_USING_SECURE_MEMORY |
| 145 | #include "allocator.h" //typedef Allocator |
| 146 | #endif |
Christopher Dunn | 12c67e8 | 2016-03-21 20:33:15 -0500 | [diff] [blame] | 147 | |
| 148 | #endif // if !defined(JSON_IS_AMALGAMATION) |
dawesc | f8674c6 | 2016-03-06 11:42:11 -0600 | [diff] [blame] | 149 | |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 150 | namespace Json { |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 151 | typedef int Int; |
| 152 | typedef unsigned int UInt; |
| 153 | #if defined(JSON_NO_INT64) |
| 154 | typedef int LargestInt; |
| 155 | typedef unsigned int LargestUInt; |
| 156 | #undef JSON_HAS_INT64 |
| 157 | #else // if defined(JSON_NO_INT64) |
| 158 | // For Microsoft Visual use specific types as long long is not supported |
| 159 | #if defined(_MSC_VER) // Microsoft Visual Studio |
| 160 | typedef __int64 Int64; |
| 161 | typedef unsigned __int64 UInt64; |
| 162 | #else // if defined(_MSC_VER) // Other platforms, use long long |
Christopher Dunn | b9afdf1 | 2016-08-21 19:58:43 -0500 | [diff] [blame] | 163 | typedef int64_t Int64; |
| 164 | typedef uint64_t UInt64; |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 165 | #endif // if defined(_MSC_VER) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 166 | typedef Int64 LargestInt; |
| 167 | typedef UInt64 LargestUInt; |
| 168 | #define JSON_HAS_INT64 |
| 169 | #endif // if defined(JSON_NO_INT64) |
dawesc | ae56465 | 2016-03-14 19:11:02 -0500 | [diff] [blame] | 170 | #if JSONCPP_USING_SECURE_MEMORY |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 171 | #define JSONCPP_STRING \ |
| 172 | std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> > |
| 173 | #define JSONCPP_OSTRINGSTREAM \ |
| 174 | std::basic_ostringstream<char, std::char_traits<char>, \ |
| 175 | Json::SecureAllocator<char> > |
| 176 | #define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char> > |
| 177 | #define JSONCPP_ISTRINGSTREAM \ |
| 178 | std::basic_istringstream<char, std::char_traits<char>, \ |
| 179 | Json::SecureAllocator<char> > |
| 180 | #define JSONCPP_ISTREAM std::istream |
dawesc | f8674c6 | 2016-03-06 11:42:11 -0600 | [diff] [blame] | 181 | #else |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 182 | #define JSONCPP_STRING std::string |
Christopher Dunn | de5b792 | 2016-03-06 11:19:46 -0600 | [diff] [blame] | 183 | #define JSONCPP_OSTRINGSTREAM std::ostringstream |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 184 | #define JSONCPP_OSTREAM std::ostream |
Christopher Dunn | de5b792 | 2016-03-06 11:19:46 -0600 | [diff] [blame] | 185 | #define JSONCPP_ISTRINGSTREAM std::istringstream |
Billy Donahue | b5e1fe8 | 2018-05-20 16:55:27 -0400 | [diff] [blame] | 186 | #define JSONCPP_ISTREAM std::istream |
dawesc | ae56465 | 2016-03-14 19:11:02 -0500 | [diff] [blame] | 187 | #endif // if JSONCPP_USING_SECURE_MEMORY |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 188 | } // end namespace Json |
| 189 | |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 190 | #endif // JSON_CONFIG_H_INCLUDED |