json-forwards.h 15 KB

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