config.h 6.3 KB

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