config.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. #ifndef JSON_CONFIG_H_INCLUDED
  6. #define JSON_CONFIG_H_INCLUDED
  7. #include <stddef.h>
  8. #include <string.h> //typedef String
  9. #ifdef _WIN32
  10. #else
  11. #include <stdint.h> //typedef int64_t, uint64_t
  12. #endif
  13. /// If defined, indicates that json library is embedded in CppTL library.
  14. //# define JSON_IN_CPPTL 1
  15. /// If defined, indicates that json may leverage CppTL library
  16. //# define JSON_USE_CPPTL 1
  17. /// If defined, indicates that cpptl vector based map should be used instead of
  18. /// std::map
  19. /// as Value container.
  20. //# define JSON_USE_CPPTL_SMALLMAP 1
  21. // If non-zero, the library uses exceptions to report bad input instead of C
  22. // assertion macros. The default is to use exceptions.
  23. #ifndef JSON_USE_EXCEPTION
  24. #define JSON_USE_EXCEPTION 1
  25. #endif
  26. /// If defined, indicates that the source file is amalgated
  27. /// to prevent private header inclusion.
  28. /// Remarks: it is automatically defined in the generated amalgated header.
  29. // #define JSON_IS_AMALGAMATION
  30. #ifdef JSON_IN_CPPTL
  31. #include <cpptl/config.h>
  32. #ifndef JSON_USE_CPPTL
  33. #define JSON_USE_CPPTL 1
  34. #endif
  35. #endif
  36. #ifdef JSON_IN_CPPTL
  37. #define JSON_API CPPTL_API
  38. #elif defined(JSON_DLL_BUILD)
  39. #if defined(_MSC_VER) || defined(__MINGW32__)
  40. #define JSON_API __declspec(dllexport)
  41. #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
  42. #endif // if defined(_MSC_VER)
  43. #elif defined(JSON_DLL)
  44. #if defined(_MSC_VER) || defined(__MINGW32__)
  45. #define JSON_API __declspec(dllimport)
  46. #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
  47. #endif // if defined(_MSC_VER)
  48. #endif // ifdef JSON_IN_CPPTL
  49. #if !defined(JSON_API)
  50. #define JSON_API
  51. #endif
  52. // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
  53. // integer
  54. // Storages, and 64 bits integer support is disabled.
  55. // #define JSON_NO_INT64 1
  56. #if defined(_MSC_VER) // MSVC
  57. # if _MSC_VER <= 1200 // MSVC 6
  58. // Microsoft Visual Studio 6 only support conversion from __int64 to double
  59. // (no conversion from unsigned __int64).
  60. # define JSON_USE_INT64_DOUBLE_CONVERSION 1
  61. // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
  62. // characters in the debug information)
  63. // All projects I've ever seen with VS6 were using this globally (not bothering
  64. // with pragma push/pop).
  65. # pragma warning(disable : 4786)
  66. # endif // MSVC 6
  67. # if _MSC_VER >= 1500 // MSVC 2008
  68. /// Indicates that the following function is deprecated.
  69. # define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
  70. # endif
  71. #endif // defined(_MSC_VER)
  72. // In c++11 the override keyword allows you to explicity define that a function
  73. // is intended to override the base-class version. This makes the code more
  74. // managable and fixes a set of common hard-to-find bugs.
  75. #if __cplusplus >= 201103L
  76. # define JSONCPP_OVERRIDE override
  77. # define JSONCPP_NOEXCEPT noexcept
  78. #elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
  79. # define JSONCPP_OVERRIDE override
  80. # define JSONCPP_NOEXCEPT throw()
  81. #elif defined(_MSC_VER) && _MSC_VER >= 1900
  82. # define JSONCPP_OVERRIDE override
  83. # define JSONCPP_NOEXCEPT noexcept
  84. #else
  85. # define JSONCPP_OVERRIDE
  86. # define JSONCPP_NOEXCEPT throw()
  87. #endif
  88. #ifndef JSON_HAS_RVALUE_REFERENCES
  89. #if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
  90. #define JSON_HAS_RVALUE_REFERENCES 1
  91. #endif // MSVC >= 2010
  92. #ifdef __clang__
  93. #if __has_feature(cxx_rvalue_references)
  94. #define JSON_HAS_RVALUE_REFERENCES 1
  95. #endif // has_feature
  96. #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
  97. #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
  98. #define JSON_HAS_RVALUE_REFERENCES 1
  99. #endif // GXX_EXPERIMENTAL
  100. #endif // __clang__ || __GNUC__
  101. #endif // not defined JSON_HAS_RVALUE_REFERENCES
  102. #ifndef JSON_HAS_RVALUE_REFERENCES
  103. #define JSON_HAS_RVALUE_REFERENCES 0
  104. #endif
  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__
  113. #if !defined(JSONCPP_DEPRECATED)
  114. #define JSONCPP_DEPRECATED(message)
  115. #endif // if !defined(JSONCPP_DEPRECATED)
  116. #if __GNUC__ >= 6
  117. # define JSON_USE_INT64_DOUBLE_CONVERSION 1
  118. #endif
  119. #if !defined(JSON_IS_AMALGAMATION)
  120. # include "version.h"
  121. # if JSONCPP_USING_SECURE_MEMORY
  122. # include "allocator.h" //typedef Allocator
  123. # endif
  124. #endif // if !defined(JSON_IS_AMALGAMATION)
  125. // 使用vector替代map,不对标签进行排序
  126. #define JSONCPP_NON_SORT_BY_VECTOR
  127. namespace Json {
  128. typedef int Int;
  129. typedef unsigned int UInt;
  130. #if defined(JSON_NO_INT64)
  131. typedef int LargestInt;
  132. typedef unsigned int LargestUInt;
  133. #undef JSON_HAS_INT64
  134. #else // if defined(JSON_NO_INT64)
  135. // For Microsoft Visual use specific types as long long is not supported
  136. #if defined(_MSC_VER) // Microsoft Visual Studio
  137. typedef __int64 Int64;
  138. typedef unsigned __int64 UInt64;
  139. #else // if defined(_MSC_VER) // Other platforms, use long long
  140. typedef int64_t Int64;
  141. typedef uint64_t UInt64;
  142. #endif // if defined(_MSC_VER)
  143. typedef Int64 LargestInt;
  144. typedef UInt64 LargestUInt;
  145. #define JSON_HAS_INT64
  146. #endif // if defined(JSON_NO_INT64)
  147. #if JSONCPP_USING_SECURE_MEMORY
  148. #define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
  149. #define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
  150. #define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
  151. #define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
  152. #define JSONCPP_ISTREAM std::istream
  153. #else
  154. #define JSONCPP_STRING std::string
  155. #define JSONCPP_OSTRINGSTREAM std::ostringstream
  156. #define JSONCPP_OSTREAM std::ostream
  157. #define JSONCPP_ISTRINGSTREAM std::istringstream
  158. #define JSONCPP_ISTREAM std::istream
  159. #endif // if JSONCPP_USING_SECURE_MEMORY
  160. } // end namespace Json
  161. #endif // JSON_CONFIG_H_INCLUDED