Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 1 | // 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 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 |
Christopher Dunn | 779d8a3 | 2016-02-06 09:49:29 -0600 | [diff] [blame] | 8 | #include <stddef.h> |
Christopher Dunn | de5b792 | 2016-03-06 11:19:46 -0600 | [diff] [blame] | 9 | #include <string> //typdef String |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 10 | |
| 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 Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 16 | /// If defined, indicates that cpptl vector based map should be used instead of |
| 17 | /// std::map |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 18 | /// as Value container. |
| 19 | //# define JSON_USE_CPPTL_SMALLMAP 1 |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 20 | |
Aaron Jacobs | 7c507d7 | 2011-09-14 08:41:37 +0000 | [diff] [blame] | 21 | // If non-zero, the library uses exceptions to report bad input instead of C |
| 22 | // assertion macros. The default is to use exceptions. |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 23 | #ifndef JSON_USE_EXCEPTION |
| 24 | #define JSON_USE_EXCEPTION 1 |
| 25 | #endif |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 26 | |
Baptiste Lepilleur | 64e40aa | 2011-05-01 20:13:40 +0000 | [diff] [blame] | 27 | /// 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 Lepilleur | eadc478 | 2011-05-02 21:09:30 +0000 | [diff] [blame] | 30 | // #define JSON_IS_AMALGAMATION |
Baptiste Lepilleur | 64e40aa | 2011-05-01 20:13:40 +0000 | [diff] [blame] | 31 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 32 | #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 Lepilleur | 64e40aa | 2011-05-01 20:13:40 +0000 | [diff] [blame] | 38 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 39 | #ifdef JSON_IN_CPPTL |
| 40 | #define JSON_API CPPTL_API |
| 41 | #elif defined(JSON_DLL_BUILD) |
Gaurav | 8aabf93 | 2016-03-08 17:34:22 +0530 | [diff] [blame^] | 42 | #if defined(_MSC_VER) || defined(__MINGW32__) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 43 | #define JSON_API __declspec(dllexport) |
| 44 | #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING |
| 45 | #endif // if defined(_MSC_VER) |
| 46 | #elif defined(JSON_DLL) |
Gaurav | 8aabf93 | 2016-03-08 17:34:22 +0530 | [diff] [blame^] | 47 | #if defined(_MSC_VER) || defined(__MINGW32__) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 48 | #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 Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 55 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 56 | // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for |
| 57 | // integer |
Baptiste Lepilleur | 842e9ac | 2010-12-27 17:45:23 +0000 | [diff] [blame] | 58 | // Storages, and 64 bits integer support is disabled. |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 59 | // #define JSON_NO_INT64 1 |
| 60 | |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 61 | #if defined(_MSC_VER) // MSVC |
| 62 | # if _MSC_VER <= 1200 // MSVC 6 |
Christopher Dunn | a4ce282 | 2015-10-19 23:40:47 -0500 | [diff] [blame] | 63 | // Microsoft Visual Studio 6 only support conversion from __int64 to double |
| 64 | // (no conversion from unsigned __int64). |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 65 | # define JSON_USE_INT64_DOUBLE_CONVERSION 1 |
Christopher Dunn | a4ce282 | 2015-10-19 23:40:47 -0500 | [diff] [blame] | 66 | // 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) |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 71 | # endif // MSVC 6 |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 72 | |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 73 | # if _MSC_VER >= 1500 // MSVC 2008 |
Christopher Dunn | a4ce282 | 2015-10-19 23:40:47 -0500 | [diff] [blame] | 74 | /// Indicates that the following function is deprecated. |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 75 | # define JSONCPP_DEPRECATED(message) __declspec(deprecated(message)) |
| 76 | # endif |
| 77 | |
| 78 | #endif // defined(_MSC_VER) |
| 79 | |
| 80 | |
| 81 | #ifndef JSON_HAS_RVALUE_REFERENCES |
| 82 | |
| 83 | #if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010 |
| 84 | #define JSON_HAS_RVALUE_REFERENCES 1 |
| 85 | #endif // MSVC >= 2010 |
| 86 | |
| 87 | #ifdef __clang__ |
| 88 | #if __has_feature(cxx_rvalue_references) |
| 89 | #define JSON_HAS_RVALUE_REFERENCES 1 |
| 90 | #endif // has_feature |
| 91 | |
| 92 | #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc) |
| 93 | #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L) |
| 94 | #define JSON_HAS_RVALUE_REFERENCES 1 |
| 95 | #endif // GXX_EXPERIMENTAL |
| 96 | |
| 97 | #endif // __clang__ || __GNUC__ |
| 98 | |
| 99 | #endif // not defined JSON_HAS_RVALUE_REFERENCES |
| 100 | |
| 101 | #ifndef JSON_HAS_RVALUE_REFERENCES |
| 102 | #define JSON_HAS_RVALUE_REFERENCES 0 |
Dani-Hub | 5003983 | 2015-03-08 18:48:24 +0100 | [diff] [blame] | 103 | #endif |
Motti | 2b00891 | 2015-04-20 17:44:47 +0300 | [diff] [blame] | 104 | |
| 105 | #ifdef __clang__ |
| 106 | #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc) |
| 107 | # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) |
| 108 | # define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) |
| 109 | # elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) |
| 110 | # define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__)) |
| 111 | # endif // GNUC version |
| 112 | #endif // __clang__ || __GNUC__ |
Baptiste Lepilleur | b2e8ccc | 2011-05-01 16:27:55 +0000 | [diff] [blame] | 113 | |
| 114 | #if !defined(JSONCPP_DEPRECATED) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 115 | #define JSONCPP_DEPRECATED(message) |
Baptiste Lepilleur | b2e8ccc | 2011-05-01 16:27:55 +0000 | [diff] [blame] | 116 | #endif // if !defined(JSONCPP_DEPRECATED) |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 117 | |
Christopher Dunn | 95f120f | 2016-02-07 11:09:41 -0600 | [diff] [blame] | 118 | #if __GNUC__ >= 6 |
| 119 | # define JSON_USE_INT64_DOUBLE_CONVERSION 1 |
| 120 | #endif |
| 121 | |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 122 | namespace Json { |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 123 | typedef int Int; |
| 124 | typedef unsigned int UInt; |
| 125 | #if defined(JSON_NO_INT64) |
| 126 | typedef int LargestInt; |
| 127 | typedef unsigned int LargestUInt; |
| 128 | #undef JSON_HAS_INT64 |
| 129 | #else // if defined(JSON_NO_INT64) |
| 130 | // For Microsoft Visual use specific types as long long is not supported |
| 131 | #if defined(_MSC_VER) // Microsoft Visual Studio |
| 132 | typedef __int64 Int64; |
| 133 | typedef unsigned __int64 UInt64; |
| 134 | #else // if defined(_MSC_VER) // Other platforms, use long long |
| 135 | typedef long long int Int64; |
| 136 | typedef unsigned long long int UInt64; |
Aaron Jacobs | 3a0c4fc | 2014-07-01 09:20:48 +1000 | [diff] [blame] | 137 | #endif // if defined(_MSC_VER) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 138 | typedef Int64 LargestInt; |
| 139 | typedef UInt64 LargestUInt; |
| 140 | #define JSON_HAS_INT64 |
| 141 | #endif // if defined(JSON_NO_INT64) |
Christopher Dunn | de5b792 | 2016-03-06 11:19:46 -0600 | [diff] [blame] | 142 | #define JSONCPP_STRING std::string |
| 143 | #define JSONCPP_OSTRINGSTREAM std::ostringstream |
| 144 | #define JSONCPP_OSTREAM std::ostream |
| 145 | #define JSONCPP_ISTRINGSTREAM std::istringstream |
| 146 | #define JSONCPP_ISTREAM std::istream |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 147 | } // end namespace Json |
| 148 | |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 149 | #endif // JSON_CONFIG_H_INCLUDED |