json-forwards.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. /// Json-cpp amalgamated forward header (https://github.com/open-source-parsers/jsoncpp/).
  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.7"
  74. #define JSONCPP_VERSION_MAJOR 1
  75. #define JSONCPP_VERSION_MINOR 9
  76. #define JSONCPP_VERSION_PATCH 7
  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. #if !defined(JSONCPP_USE_SECURE_MEMORY)
  82. #define JSONCPP_USE_SECURE_MEMORY 0
  83. #endif
  84. // If non-zero, the library zeroes any memory that it has allocated before
  85. // it frees its memory.
  86. #endif // JSON_VERSION_H_INCLUDED
  87. // //////////////////////////////////////////////////////////////////////
  88. // End of content of file: include/json/version.h
  89. // //////////////////////////////////////////////////////////////////////
  90. // //////////////////////////////////////////////////////////////////////
  91. // Beginning of content of file: include/json/allocator.h
  92. // //////////////////////////////////////////////////////////////////////
  93. // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
  94. // Distributed under MIT license, or public domain if desired and
  95. // recognized in your jurisdiction.
  96. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
  97. #ifndef JSON_ALLOCATOR_H_INCLUDED
  98. #define JSON_ALLOCATOR_H_INCLUDED
  99. #include <algorithm>
  100. #include <cstring>
  101. #include <memory>
  102. #pragma pack(push)
  103. #pragma pack()
  104. namespace Json {
  105. template <typename T> class SecureAllocator {
  106. public:
  107. // Type definitions
  108. using value_type = T;
  109. using pointer = T*;
  110. using const_pointer = const T*;
  111. using reference = T&;
  112. using const_reference = const T&;
  113. using size_type = std::size_t;
  114. using difference_type = std::ptrdiff_t;
  115. /**
  116. * Allocate memory for N items using the standard allocator.
  117. */
  118. pointer allocate(size_type n) {
  119. // allocate using "global operator new"
  120. return static_cast<pointer>(::operator new(n * sizeof(T)));
  121. }
  122. /**
  123. * Release memory which was allocated for N items at pointer P.
  124. *
  125. * The memory block is filled with zeroes before being released.
  126. */
  127. void deallocate(pointer p, size_type n) {
  128. // These constructs will not be removed by the compiler during optimization,
  129. // unlike memset.
  130. #if defined(HAVE_MEMSET_S)
  131. memset_s(p, n * sizeof(T), 0, n * sizeof(T));
  132. #elif defined(_WIN32)
  133. RtlSecureZeroMemory(p, n * sizeof(T));
  134. #else
  135. std::fill_n(reinterpret_cast<volatile unsigned char*>(p), n, 0);
  136. #endif
  137. // free using "global operator delete"
  138. ::operator delete(p);
  139. }
  140. /**
  141. * Construct an item in-place at pointer P.
  142. */
  143. template <typename... Args> void construct(pointer p, Args&&... args) {
  144. // construct using "placement new" and "perfect forwarding"
  145. ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
  146. }
  147. size_type max_size() const { return size_t(-1) / sizeof(T); }
  148. pointer address(reference x) const { return std::addressof(x); }
  149. const_pointer address(const_reference x) const { return std::addressof(x); }
  150. /**
  151. * Destroy an item in-place at pointer P.
  152. */
  153. void destroy(pointer p) {
  154. // destroy using "explicit destructor"
  155. p->~T();
  156. }
  157. // Boilerplate
  158. SecureAllocator() {}
  159. template <typename U> SecureAllocator(const SecureAllocator<U>&) {}
  160. template <typename U> struct rebind {
  161. using other = SecureAllocator<U>;
  162. };
  163. };
  164. template <typename T, typename U>
  165. bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
  166. return true;
  167. }
  168. template <typename T, typename U>
  169. bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
  170. return false;
  171. }
  172. } // namespace Json
  173. #pragma pack(pop)
  174. #endif // JSON_ALLOCATOR_H_INCLUDED
  175. // //////////////////////////////////////////////////////////////////////
  176. // End of content of file: include/json/allocator.h
  177. // //////////////////////////////////////////////////////////////////////
  178. // //////////////////////////////////////////////////////////////////////
  179. // Beginning of content of file: include/json/config.h
  180. // //////////////////////////////////////////////////////////////////////
  181. // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
  182. // Distributed under MIT license, or public domain if desired and
  183. // recognized in your jurisdiction.
  184. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
  185. #ifndef JSON_CONFIG_H_INCLUDED
  186. #define JSON_CONFIG_H_INCLUDED
  187. #include <cstddef>
  188. #include <cstdint>
  189. #include <istream>
  190. #include <memory>
  191. #include <ostream>
  192. #include <sstream>
  193. #include <string>
  194. #include <type_traits>
  195. // If non-zero, the library uses exceptions to report bad input instead of C
  196. // assertion macros. The default is to use exceptions.
  197. #ifndef JSON_USE_EXCEPTION
  198. #define JSON_USE_EXCEPTION 1
  199. #endif
  200. // Temporary, tracked for removal with issue #982.
  201. #ifndef JSON_USE_NULLREF
  202. #define JSON_USE_NULLREF 1
  203. #endif
  204. /// If defined, indicates that the source file is amalgamated
  205. /// to prevent private header inclusion.
  206. /// Remarks: it is automatically defined in the generated amalgamated header.
  207. // #define JSON_IS_AMALGAMATION
  208. // Export macros for DLL visibility
  209. #if defined(JSON_DLL_BUILD)
  210. #if defined(_MSC_VER) || defined(__MINGW32__)
  211. #define JSON_API __declspec(dllexport)
  212. #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
  213. #elif defined(__GNUC__) || defined(__clang__)
  214. #define JSON_API __attribute__((visibility("default")))
  215. #endif // if defined(_MSC_VER)
  216. #elif defined(JSON_DLL)
  217. #if defined(_MSC_VER) || defined(__MINGW32__)
  218. #define JSON_API __declspec(dllimport)
  219. #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
  220. #endif // if defined(_MSC_VER)
  221. #endif // ifdef JSON_DLL_BUILD
  222. #if !defined(JSON_API)
  223. #define JSON_API
  224. #endif
  225. #if defined(_MSC_VER) && _MSC_VER < 1800
  226. #error \
  227. "ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
  228. #endif
  229. #if defined(_MSC_VER) && _MSC_VER < 1900
  230. // As recommended at
  231. // https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
  232. extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
  233. const char* format, ...);
  234. #define jsoncpp_snprintf msvc_pre1900_c99_snprintf
  235. #else
  236. #define jsoncpp_snprintf std::snprintf
  237. #endif
  238. // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
  239. // integer
  240. // Storages, and 64 bits integer support is disabled.
  241. // #define JSON_NO_INT64 1
  242. // JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
  243. // C++11 should be used directly in JSONCPP.
  244. #define JSONCPP_OVERRIDE override
  245. #ifdef __clang__
  246. #if __has_extension(attribute_deprecated_with_message)
  247. #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
  248. #endif
  249. #elif defined(__GNUC__) // not clang (gcc comes later since clang emulates gcc)
  250. #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
  251. #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
  252. #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
  253. #define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
  254. #endif // GNUC version
  255. #elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
  256. // MSVC)
  257. #define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
  258. #endif // __clang__ || __GNUC__ || _MSC_VER
  259. #if !defined(JSONCPP_DEPRECATED)
  260. #define JSONCPP_DEPRECATED(message)
  261. #endif // if !defined(JSONCPP_DEPRECATED)
  262. #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
  263. #define JSON_USE_INT64_DOUBLE_CONVERSION 1
  264. #endif
  265. #if !defined(JSON_IS_AMALGAMATION)
  266. #include "allocator.h"
  267. #include "version.h"
  268. #endif // if !defined(JSON_IS_AMALGAMATION)
  269. namespace Json {
  270. using Int = int;
  271. using UInt = unsigned int;
  272. #if defined(JSON_NO_INT64)
  273. using LargestInt = int;
  274. using LargestUInt = unsigned int;
  275. #undef JSON_HAS_INT64
  276. #else // if defined(JSON_NO_INT64)
  277. // For Microsoft Visual use specific types as long long is not supported
  278. #if defined(_MSC_VER) // Microsoft Visual Studio
  279. using Int64 = __int64;
  280. using UInt64 = unsigned __int64;
  281. #else // if defined(_MSC_VER) // Other platforms, use long long
  282. using Int64 = int64_t;
  283. using UInt64 = uint64_t;
  284. #endif // if defined(_MSC_VER)
  285. using LargestInt = Int64;
  286. using LargestUInt = UInt64;
  287. #define JSON_HAS_INT64
  288. #endif // if defined(JSON_NO_INT64)
  289. template <typename T>
  290. using Allocator =
  291. typename std::conditional<JSONCPP_USE_SECURE_MEMORY, SecureAllocator<T>,
  292. std::allocator<T>>::type;
  293. using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
  294. using IStringStream =
  295. std::basic_istringstream<String::value_type, String::traits_type,
  296. String::allocator_type>;
  297. using OStringStream =
  298. std::basic_ostringstream<String::value_type, String::traits_type,
  299. String::allocator_type>;
  300. using IStream = std::istream;
  301. using OStream = std::ostream;
  302. } // namespace Json
  303. // Legacy names (formerly macros).
  304. using JSONCPP_STRING = Json::String;
  305. using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
  306. using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
  307. using JSONCPP_ISTREAM = Json::IStream;
  308. using JSONCPP_OSTREAM = Json::OStream;
  309. #endif // JSON_CONFIG_H_INCLUDED
  310. // //////////////////////////////////////////////////////////////////////
  311. // End of content of file: include/json/config.h
  312. // //////////////////////////////////////////////////////////////////////
  313. // //////////////////////////////////////////////////////////////////////
  314. // Beginning of content of file: include/json/forwards.h
  315. // //////////////////////////////////////////////////////////////////////
  316. // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
  317. // Distributed under MIT license, or public domain if desired and
  318. // recognized in your jurisdiction.
  319. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
  320. #ifndef JSON_FORWARDS_H_INCLUDED
  321. #define JSON_FORWARDS_H_INCLUDED
  322. #if !defined(JSON_IS_AMALGAMATION)
  323. #include "config.h"
  324. #endif // if !defined(JSON_IS_AMALGAMATION)
  325. namespace Json {
  326. // writer.h
  327. class StreamWriter;
  328. class StreamWriterBuilder;
  329. class Writer;
  330. class FastWriter;
  331. class StyledWriter;
  332. class StyledStreamWriter;
  333. // reader.h
  334. class Reader;
  335. class CharReader;
  336. class CharReaderBuilder;
  337. // json_features.h
  338. class Features;
  339. // value.h
  340. using ArrayIndex = unsigned int;
  341. class StaticString;
  342. class Path;
  343. class PathArgument;
  344. class Value;
  345. class ValueIteratorBase;
  346. class ValueIterator;
  347. class ValueConstIterator;
  348. } // namespace Json
  349. #endif // JSON_FORWARDS_H_INCLUDED
  350. // //////////////////////////////////////////////////////////////////////
  351. // End of content of file: include/json/forwards.h
  352. // //////////////////////////////////////////////////////////////////////
  353. #endif //ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED