json-forwards.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. /// Json-cpp amalgamated forward header (http://jsoncpp.sourceforge.net/).
  2. /// It is intended to be used with #include "json/json-forwards.h"
  3. /// This header provides forward declaration for all JsonCpp types.
  4. // //////////////////////////////////////////////////////////////////////
  5. // Beginning of content of file: LICENSE
  6. // //////////////////////////////////////////////////////////////////////
  7. /*
  8. The JsonCpp library's source code, including accompanying documentation,
  9. tests and demonstration applications, are licensed under the following
  10. conditions...
  11. Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
  12. jurisdictions which recognize such a disclaimer. In such jurisdictions,
  13. this software is released into the Public Domain.
  14. In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
  15. 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
  16. The JsonCpp Authors, and is released under the terms of the MIT License (see below).
  17. In jurisdictions which recognize Public Domain property, the user of this
  18. software may choose to accept it either as 1) Public Domain, 2) under the
  19. conditions of the MIT License (see below), or 3) under the terms of dual
  20. Public Domain/MIT License conditions described here, as they choose.
  21. The MIT License is about as close to Public Domain as a license can get, and is
  22. described in clear, concise terms at:
  23. http://en.wikipedia.org/wiki/MIT_License
  24. The full text of the MIT License follows:
  25. ========================================================================
  26. Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
  27. Permission is hereby granted, free of charge, to any person
  28. obtaining a copy of this software and associated documentation
  29. files (the "Software"), to deal in the Software without
  30. restriction, including without limitation the rights to use, copy,
  31. modify, merge, publish, distribute, sublicense, and/or sell copies
  32. of the Software, and to permit persons to whom the Software is
  33. furnished to do so, subject to the following conditions:
  34. The above copyright notice and this permission notice shall be
  35. included in all copies or substantial portions of the Software.
  36. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  37. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  38. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  39. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  40. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  41. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  42. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  43. SOFTWARE.
  44. ========================================================================
  45. (END LICENSE TEXT)
  46. The MIT license is compatible with both the GPL and commercial
  47. software, affording one all of the rights of Public Domain with the
  48. minor nuisance of being required to keep the above copyright notice
  49. and license text in the source code. Note also that by accepting the
  50. Public Domain "license" you can re-license your copy using whatever
  51. license you like.
  52. */
  53. // //////////////////////////////////////////////////////////////////////
  54. // End of content of file: LICENSE
  55. // //////////////////////////////////////////////////////////////////////
  56. #ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED
  57. # define JSON_FORWARD_AMALGAMATED_H_INCLUDED
  58. /// If defined, indicates that the source file is amalgamated
  59. /// to prevent private header inclusion.
  60. #define JSON_IS_AMALGAMATION
  61. // //////////////////////////////////////////////////////////////////////
  62. // Beginning of content of file: include/json/version.h
  63. // //////////////////////////////////////////////////////////////////////
  64. #ifndef JSON_VERSION_H_INCLUDED
  65. #define JSON_VERSION_H_INCLUDED
  66. // Note: version must be updated in three places when doing a release. This
  67. // annoying process ensures that amalgamate, CMake, and meson all report the
  68. // correct version.
  69. // 1. /meson.build
  70. // 2. /include/json/version.h
  71. // 3. /CMakeLists.txt
  72. // IMPORTANT: also update the SOVERSION!!
  73. #define JSONCPP_VERSION_STRING "1.9.5"
  74. #define JSONCPP_VERSION_MAJOR 1
  75. #define JSONCPP_VERSION_MINOR 9
  76. #define JSONCPP_VERSION_PATCH 5
  77. #define JSONCPP_VERSION_QUALIFIER
  78. #define JSONCPP_VERSION_HEXA \
  79. ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
  80. (JSONCPP_VERSION_PATCH << 8))
  81. #ifdef JSONCPP_USING_SECURE_MEMORY
  82. #undef JSONCPP_USING_SECURE_MEMORY
  83. #endif
  84. #define JSONCPP_USING_SECURE_MEMORY 0
  85. // If non-zero, the library zeroes any memory that it has allocated before
  86. // it frees its memory.
  87. #endif // JSON_VERSION_H_INCLUDED
  88. // //////////////////////////////////////////////////////////////////////
  89. // End of content of file: include/json/version.h
  90. // //////////////////////////////////////////////////////////////////////
  91. // //////////////////////////////////////////////////////////////////////
  92. // Beginning of content of file: include/json/allocator.h
  93. // //////////////////////////////////////////////////////////////////////
  94. // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
  95. // Distributed under MIT license, or public domain if desired and
  96. // recognized in your jurisdiction.
  97. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
  98. #ifndef JSON_ALLOCATOR_H_INCLUDED
  99. #define JSON_ALLOCATOR_H_INCLUDED
  100. #include <cstring>
  101. #include <memory>
  102. #pragma pack(push, 8)
  103. namespace Json {
  104. template <typename T> class SecureAllocator {
  105. public:
  106. // Type definitions
  107. using value_type = T;
  108. using pointer = T*;
  109. using const_pointer = const T*;
  110. using reference = T&;
  111. using const_reference = const T&;
  112. using size_type = std::size_t;
  113. using difference_type = std::ptrdiff_t;
  114. /**
  115. * Allocate memory for N items using the standard allocator.
  116. */
  117. pointer allocate(size_type n) {
  118. // allocate using "global operator new"
  119. return static_cast<pointer>(::operator new(n * sizeof(T)));
  120. }
  121. /**
  122. * Release memory which was allocated for N items at pointer P.
  123. *
  124. * The memory block is filled with zeroes before being released.
  125. */
  126. void deallocate(pointer p, size_type n) {
  127. // memset_s is used because memset may be optimized away by the compiler
  128. memset_s(p, n * sizeof(T), 0, n * sizeof(T));
  129. // free using "global operator delete"
  130. ::operator delete(p);
  131. }
  132. /**
  133. * Construct an item in-place at pointer P.
  134. */
  135. template <typename... Args> void construct(pointer p, Args&&... args) {
  136. // construct using "placement new" and "perfect forwarding"
  137. ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
  138. }
  139. size_type max_size() const { return size_t(-1) / sizeof(T); }
  140. pointer address(reference x) const { return std::addressof(x); }
  141. const_pointer address(const_reference x) const { return std::addressof(x); }
  142. /**
  143. * Destroy an item in-place at pointer P.
  144. */
  145. void destroy(pointer p) {
  146. // destroy using "explicit destructor"
  147. p->~T();
  148. }
  149. // Boilerplate
  150. SecureAllocator() {}
  151. template <typename U> SecureAllocator(const SecureAllocator<U>&) {}
  152. template <typename U> struct rebind { using other = SecureAllocator<U>; };
  153. };
  154. template <typename T, typename U>
  155. bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
  156. return true;
  157. }
  158. template <typename T, typename U>
  159. bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
  160. return false;
  161. }
  162. } // namespace Json
  163. #pragma pack(pop)
  164. #endif // JSON_ALLOCATOR_H_INCLUDED
  165. // //////////////////////////////////////////////////////////////////////
  166. // End of content of file: include/json/allocator.h
  167. // //////////////////////////////////////////////////////////////////////
  168. // //////////////////////////////////////////////////////////////////////
  169. // Beginning of content of file: include/json/config.h
  170. // //////////////////////////////////////////////////////////////////////
  171. // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
  172. // Distributed under MIT license, or public domain if desired and
  173. // recognized in your jurisdiction.
  174. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
  175. #ifndef JSON_CONFIG_H_INCLUDED
  176. #define JSON_CONFIG_H_INCLUDED
  177. #include <cstddef>
  178. #include <cstdint>
  179. #include <istream>
  180. #include <memory>
  181. #include <ostream>
  182. #include <sstream>
  183. #include <string>
  184. #include <type_traits>
  185. // If non-zero, the library uses exceptions to report bad input instead of C
  186. // assertion macros. The default is to use exceptions.
  187. #ifndef JSON_USE_EXCEPTION
  188. #define JSON_USE_EXCEPTION 1
  189. #endif
  190. // Temporary, tracked for removal with issue #982.
  191. #ifndef JSON_USE_NULLREF
  192. #define JSON_USE_NULLREF 1
  193. #endif
  194. /// If defined, indicates that the source file is amalgamated
  195. /// to prevent private header inclusion.
  196. /// Remarks: it is automatically defined in the generated amalgamated header.
  197. // #define JSON_IS_AMALGAMATION
  198. // Export macros for DLL visibility
  199. #if defined(JSON_DLL_BUILD)
  200. #if defined(_MSC_VER) || defined(__MINGW32__)
  201. #define JSON_API __declspec(dllexport)
  202. #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
  203. #elif defined(__GNUC__) || defined(__clang__)
  204. #define JSON_API __attribute__((visibility("default")))
  205. #endif // if defined(_MSC_VER)
  206. #elif defined(JSON_DLL)
  207. #if defined(_MSC_VER) || defined(__MINGW32__)
  208. #define JSON_API __declspec(dllimport)
  209. #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
  210. #endif // if defined(_MSC_VER)
  211. #endif // ifdef JSON_DLL_BUILD
  212. #if !defined(JSON_API)
  213. #define JSON_API
  214. #endif
  215. #if defined(_MSC_VER) && _MSC_VER < 1800
  216. #error \
  217. "ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
  218. #endif
  219. #if defined(_MSC_VER) && _MSC_VER < 1900
  220. // As recommended at
  221. // https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
  222. extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
  223. const char* format, ...);
  224. #define jsoncpp_snprintf msvc_pre1900_c99_snprintf
  225. #else
  226. #define jsoncpp_snprintf std::snprintf
  227. #endif
  228. // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
  229. // integer
  230. // Storages, and 64 bits integer support is disabled.
  231. // #define JSON_NO_INT64 1
  232. // JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
  233. // C++11 should be used directly in JSONCPP.
  234. #define JSONCPP_OVERRIDE override
  235. #ifdef __clang__
  236. #if __has_extension(attribute_deprecated_with_message)
  237. #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
  238. #endif
  239. #elif defined(__GNUC__) // not clang (gcc comes later since clang emulates gcc)
  240. #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
  241. #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
  242. #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
  243. #define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
  244. #endif // GNUC version
  245. #elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
  246. // MSVC)
  247. #define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
  248. #endif // __clang__ || __GNUC__ || _MSC_VER
  249. #if !defined(JSONCPP_DEPRECATED)
  250. #define JSONCPP_DEPRECATED(message)
  251. #endif // if !defined(JSONCPP_DEPRECATED)
  252. #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
  253. #define JSON_USE_INT64_DOUBLE_CONVERSION 1
  254. #endif
  255. #if !defined(JSON_IS_AMALGAMATION)
  256. #include "allocator.h"
  257. #include "version.h"
  258. #endif // if !defined(JSON_IS_AMALGAMATION)
  259. namespace Json {
  260. using Int = int;
  261. using UInt = unsigned int;
  262. #if defined(JSON_NO_INT64)
  263. using LargestInt = int;
  264. using LargestUInt = unsigned int;
  265. #undef JSON_HAS_INT64
  266. #else // if defined(JSON_NO_INT64)
  267. // For Microsoft Visual use specific types as long long is not supported
  268. #if defined(_MSC_VER) // Microsoft Visual Studio
  269. using Int64 = __int64;
  270. using UInt64 = unsigned __int64;
  271. #else // if defined(_MSC_VER) // Other platforms, use long long
  272. using Int64 = int64_t;
  273. using UInt64 = uint64_t;
  274. #endif // if defined(_MSC_VER)
  275. using LargestInt = Int64;
  276. using LargestUInt = UInt64;
  277. #define JSON_HAS_INT64
  278. #endif // if defined(JSON_NO_INT64)
  279. template <typename T>
  280. using Allocator =
  281. typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
  282. std::allocator<T>>::type;
  283. using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
  284. using IStringStream =
  285. std::basic_istringstream<String::value_type, String::traits_type,
  286. String::allocator_type>;
  287. using OStringStream =
  288. std::basic_ostringstream<String::value_type, String::traits_type,
  289. String::allocator_type>;
  290. using IStream = std::istream;
  291. using OStream = std::ostream;
  292. } // namespace Json
  293. // Legacy names (formerly macros).
  294. using JSONCPP_STRING = Json::String;
  295. using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
  296. using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
  297. using JSONCPP_ISTREAM = Json::IStream;
  298. using JSONCPP_OSTREAM = Json::OStream;
  299. #endif // JSON_CONFIG_H_INCLUDED
  300. // //////////////////////////////////////////////////////////////////////
  301. // End of content of file: include/json/config.h
  302. // //////////////////////////////////////////////////////////////////////
  303. // //////////////////////////////////////////////////////////////////////
  304. // Beginning of content of file: include/json/forwards.h
  305. // //////////////////////////////////////////////////////////////////////
  306. // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
  307. // Distributed under MIT license, or public domain if desired and
  308. // recognized in your jurisdiction.
  309. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
  310. #ifndef JSON_FORWARDS_H_INCLUDED
  311. #define JSON_FORWARDS_H_INCLUDED
  312. #if !defined(JSON_IS_AMALGAMATION)
  313. #include "config.h"
  314. #endif // if !defined(JSON_IS_AMALGAMATION)
  315. namespace Json {
  316. // writer.h
  317. class StreamWriter;
  318. class StreamWriterBuilder;
  319. class Writer;
  320. class FastWriter;
  321. class StyledWriter;
  322. class StyledStreamWriter;
  323. // reader.h
  324. class Reader;
  325. class CharReader;
  326. class CharReaderBuilder;
  327. // json_features.h
  328. class Features;
  329. // value.h
  330. using ArrayIndex = unsigned int;
  331. class StaticString;
  332. class Path;
  333. class PathArgument;
  334. class Value;
  335. class ValueIteratorBase;
  336. class ValueIterator;
  337. class ValueConstIterator;
  338. } // namespace Json
  339. #endif // JSON_FORWARDS_H_INCLUDED
  340. // //////////////////////////////////////////////////////////////////////
  341. // End of content of file: include/json/forwards.h
  342. // //////////////////////////////////////////////////////////////////////
  343. #endif //ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED