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.

168 lines
5.7 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
7 years ago
​
7 years ago
​
​
7 years ago
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
7 years ago
​
​
​
​
​
7 years ago
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
7 years ago
​
7 years ago
​
7 years ago
​
​
​
​
7 years ago
​
​
​
​
7 years ago
7 years ago
​
​
7 years ago
​
​
7 years ago
​
7 years ago
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
7 years ago
​
​
7 years ago
​
​
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 <stdint.h>
  14. #include <string>
  15. #include <type_traits>
  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 "ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
  59. #endif
  60. #if defined(_MSC_VER) && _MSC_VER < 1900
  61. // As recommended at
  62. // 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. // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
  69. // integer
  70. // Storages, and 64 bits integer support is disabled.
  71. // #define JSON_NO_INT64 1
  72. // JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
  73. // C++11 should be used directly in JSONCPP.
  74. #define JSONCPP_OVERRIDE override
  75. #if __cplusplus >= 201103L
  76. #define JSONCPP_NOEXCEPT noexcept
  77. #define JSONCPP_OP_EXPLICIT explicit
  78. #elif defined(_MSC_VER) && _MSC_VER < 1900
  79. #define JSONCPP_NOEXCEPT throw()
  80. #define JSONCPP_OP_EXPLICIT explicit
  81. #elif defined(_MSC_VER) && _MSC_VER >= 1900
  82. #define JSONCPP_NOEXCEPT noexcept
  83. #define JSONCPP_OP_EXPLICIT explicit
  84. #else
  85. #define JSONCPP_NOEXCEPT throw()
  86. #define JSONCPP_OP_EXPLICIT
  87. #endif
  88. #ifdef __clang__
  89. #if __has_extension(attribute_deprecated_with_message)
  90. #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
  91. #endif
  92. #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
  93. #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
  94. #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
  95. #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
  96. #define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
  97. #endif // GNUC version
  98. #elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates MSVC)
  99. #define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
  100. #endif // __clang__ || __GNUC__ || _MSC_VER
  101. #if ! defined(JSONCPP_DEPRECATED)
  102. #define JSONCPP_DEPRECATED(message)
  103. #endif // if !defined(JSONCPP_DEPRECATED)
  104. #if __GNUC__ >= 6
  105. #define JSON_USE_INT64_DOUBLE_CONVERSION 1
  106. #endif
  107. #if ! defined(JSON_IS_AMALGAMATION)
  108. #include "allocator.h"
  109. #include "version.h"
  110. #endif // if !defined(JSON_IS_AMALGAMATION)
  111. namespace Json
  112. {
  113. typedef int Int;
  114. typedef unsigned int UInt;
  115. #if defined(JSON_NO_INT64)
  116. typedef int LargestInt;
  117. typedef unsigned int LargestUInt;
  118. #undef JSON_HAS_INT64
  119. #else // if defined(JSON_NO_INT64)
  120. // For Microsoft Visual use specific types as long long is not supported
  121. #if defined(_MSC_VER) // Microsoft Visual Studio
  122. typedef __int64 Int64;
  123. typedef unsigned __int64 UInt64;
  124. #else // if defined(_MSC_VER) // Other platforms, use long long
  125. typedef int64_t Int64;
  126. typedef uint64_t UInt64;
  127. #endif // if defined(_MSC_VER)
  128. typedef Int64 LargestInt;
  129. typedef UInt64 LargestUInt;
  130. #define JSON_HAS_INT64
  131. #endif // if defined(JSON_NO_INT64)
  132. template <typename T> using Allocator = typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>, std::allocator<T>>::type;
  133. using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
  134. using IStringStream = std::basic_istringstream<String::value_type, String::traits_type, String::allocator_type>;
  135. using OStringStream = std::basic_ostringstream<String::value_type, String::traits_type, String::allocator_type>;
  136. using IStream = std::istream;
  137. using OStream = std::ostream;
  138. } // namespace Json
  139. // Legacy names (formerly macros).
  140. using JSONCPP_STRING = Json::String;
  141. using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
  142. using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
  143. using JSONCPP_ISTREAM = Json::IStream;
  144. using JSONCPP_OSTREAM = Json::OStream;
  145. #endif // JSON_CONFIG_H_INCLUDED