You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
5.9 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
  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. #ifndef JSON_CONFIG_H_INCLUDED
  6. #define JSON_CONFIG_H_INCLUDED
  7. #include <cstddef>
  8. #include <cstdint>
  9. #include <istream>
  10. #include <memory>
  11. #include <ostream>
  12. #include <sstream>
  13. #include <string>
  14. #include <type_traits>
  15. #include <stdint.h>
  16. /// If defined, indicates that json library is embedded in CppTL library.
  17. //# define JSON_IN_CPPTL 1
  18. /// If defined, indicates that json may leverage CppTL library
  19. //# define JSON_USE_CPPTL 1
  20. /// If defined, indicates that cpptl vector based map should be used instead of
  21. /// std::map
  22. /// as Value container.
  23. //# define JSON_USE_CPPTL_SMALLMAP 1
  24. // If non-zero, the library uses exceptions to report bad input instead of C
  25. // assertion macros. The default is to use exceptions.
  26. #ifndef JSON_USE_EXCEPTION
  27. #define JSON_USE_EXCEPTION 1
  28. #endif
  29. /// If defined, indicates that the source file is amalgamated
  30. /// to prevent private header inclusion.
  31. /// Remarks: it is automatically defined in the generated amalgamated header.
  32. // #define JSON_IS_AMALGAMATION
  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
  39. #ifdef JSON_IN_CPPTL
  40. #define JSON_API CPPTL_API
  41. #elif defined(JSON_DLL_BUILD)
  42. #if defined(_MSC_VER) || defined(__MINGW32__)
  43. #define JSON_API __declspec(dllexport)
  44. #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
  45. #elif defined(__GNUC__) || defined(__clang__)
  46. #define JSON_API __attribute__((visibility("default")))
  47. #endif // if defined(_MSC_VER)
  48. #elif defined(JSON_DLL)
  49. #if defined(_MSC_VER) || defined(__MINGW32__)
  50. #define JSON_API __declspec(dllimport)
  51. #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
  52. #endif // if defined(_MSC_VER)
  53. #endif // ifdef JSON_IN_CPPTL
  54. #if !defined(JSON_API)
  55. #define JSON_API
  56. #endif
  57. #if defined(_MSC_VER) && _MSC_VER < 1800
  58. #error \
  59. "ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
  60. #endif
  61. #if defined(_MSC_VER) && _MSC_VER < 1900
  62. // As recommended at
  63. // https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
  64. extern JSON_API int
  65. msvc_pre1900_c99_snprintf(char* outBuf, size_t size, const char* format, ...);
  66. #define jsoncpp_snprintf msvc_pre1900_c99_snprintf
  67. #else
  68. #define jsoncpp_snprintf std::snprintf
  69. #endif
  70. // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
  71. // integer
  72. // Storages, and 64 bits integer support is disabled.
  73. // #define JSON_NO_INT64 1
  74. // JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
  75. // C++11 should be used directly in JSONCPP.
  76. #define JSONCPP_OVERRIDE override
  77. #if __cplusplus >= 201103L
  78. #define JSONCPP_NOEXCEPT noexcept
  79. #define JSONCPP_OP_EXPLICIT explicit
  80. #elif defined(_MSC_VER) && _MSC_VER < 1900
  81. #define JSONCPP_NOEXCEPT throw()
  82. #define JSONCPP_OP_EXPLICIT explicit
  83. #elif defined(_MSC_VER) && _MSC_VER >= 1900
  84. #define JSONCPP_NOEXCEPT noexcept
  85. #define JSONCPP_OP_EXPLICIT explicit
  86. #else
  87. #define JSONCPP_NOEXCEPT throw()
  88. #define JSONCPP_OP_EXPLICIT
  89. #endif
  90. #ifdef __clang__
  91. #if __has_extension(attribute_deprecated_with_message)
  92. #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
  93. #endif
  94. #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
  95. #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
  96. #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
  97. #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
  98. #define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
  99. #endif // GNUC version
  100. #elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates MSVC)
  101. #define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
  102. #endif // __clang__ || __GNUC__ || _MSC_VER
  103. #if !defined(JSONCPP_DEPRECATED)
  104. #define JSONCPP_DEPRECATED(message)
  105. #endif // if !defined(JSONCPP_DEPRECATED)
  106. #if __GNUC__ >= 6
  107. #define JSON_USE_INT64_DOUBLE_CONVERSION 1
  108. #endif
  109. #if !defined(JSON_IS_AMALGAMATION)
  110. #include "allocator.h"
  111. #include "version.h"
  112. #endif // if !defined(JSON_IS_AMALGAMATION)
  113. namespace Json {
  114. typedef int Int;
  115. typedef unsigned int UInt;
  116. #if defined(JSON_NO_INT64)
  117. typedef int LargestInt;
  118. typedef unsigned int LargestUInt;
  119. #undef JSON_HAS_INT64
  120. #else // if defined(JSON_NO_INT64)
  121. // For Microsoft Visual use specific types as long long is not supported
  122. #if defined(_MSC_VER) // Microsoft Visual Studio
  123. typedef __int64 Int64;
  124. typedef unsigned __int64 UInt64;
  125. #else // if defined(_MSC_VER) // Other platforms, use long long
  126. typedef int64_t Int64;
  127. typedef uint64_t UInt64;
  128. #endif // if defined(_MSC_VER)
  129. typedef Int64 LargestInt;
  130. typedef UInt64 LargestUInt;
  131. #define JSON_HAS_INT64
  132. #endif // if defined(JSON_NO_INT64)
  133. template <typename T>
  134. using Allocator = typename std::conditional<JSONCPP_USING_SECURE_MEMORY,
  135. SecureAllocator<T>,
  136. std::allocator<T>>::type;
  137. using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
  138. using IStringStream = std::basic_istringstream<String::value_type,
  139. String::traits_type,
  140. String::allocator_type>;
  141. using OStringStream = std::basic_ostringstream<String::value_type,
  142. String::traits_type,
  143. String::allocator_type>;
  144. using IStream = std::istream;
  145. using OStream = std::ostream;
  146. } // namespace Json
  147. // Legacy names (formerly macros).
  148. using JSONCPP_STRING = Json::String;
  149. using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
  150. using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
  151. using JSONCPP_ISTREAM = Json::IStream;
  152. using JSONCPP_OSTREAM = Json::OStream;
  153. #endif // JSON_CONFIG_H_INCLUDED