config.h 6.5 KB

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