1b2a28edaSopenharmony_ci/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).
2b2a28edaSopenharmony_ci/// It is intended to be used with #include "json/json.h"
3b2a28edaSopenharmony_ci
4b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
5b2a28edaSopenharmony_ci// Beginning of content of file: LICENSE
6b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
7b2a28edaSopenharmony_ci
8b2a28edaSopenharmony_ci/*
9b2a28edaSopenharmony_ciThe JsonCpp library's source code, including accompanying documentation,
10b2a28edaSopenharmony_citests and demonstration applications, are licensed under the following
11b2a28edaSopenharmony_ciconditions...
12b2a28edaSopenharmony_ci
13b2a28edaSopenharmony_ciThe author (Baptiste Lepilleur) explicitly disclaims copyright in all
14b2a28edaSopenharmony_cijurisdictions which recognize such a disclaimer. In such jurisdictions,
15b2a28edaSopenharmony_cithis software is released into the Public Domain.
16b2a28edaSopenharmony_ci
17b2a28edaSopenharmony_ciIn jurisdictions which do not recognize Public Domain property (e.g. Germany as of
18b2a28edaSopenharmony_ci2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
19b2a28edaSopenharmony_cireleased under the terms of the MIT License (see below).
20b2a28edaSopenharmony_ci
21b2a28edaSopenharmony_ciIn jurisdictions which recognize Public Domain property, the user of this
22b2a28edaSopenharmony_cisoftware may choose to accept it either as 1) Public Domain, 2) under the
23b2a28edaSopenharmony_ciconditions of the MIT License (see below), or 3) under the terms of dual
24b2a28edaSopenharmony_ciPublic Domain/MIT License conditions described here, as they choose.
25b2a28edaSopenharmony_ci
26b2a28edaSopenharmony_ciThe MIT License is about as close to Public Domain as a license can get, and is
27b2a28edaSopenharmony_cidescribed in clear, concise terms at:
28b2a28edaSopenharmony_ci
29b2a28edaSopenharmony_ci   http://en.wikipedia.org/wiki/MIT_License
30b2a28edaSopenharmony_ci
31b2a28edaSopenharmony_ciThe full text of the MIT License follows:
32b2a28edaSopenharmony_ci
33b2a28edaSopenharmony_ci========================================================================
34b2a28edaSopenharmony_ciCopyright (c) 2007-2010 Baptiste Lepilleur
35b2a28edaSopenharmony_ci
36b2a28edaSopenharmony_ciPermission is hereby granted, free of charge, to any person
37b2a28edaSopenharmony_ciobtaining a copy of this software and associated documentation
38b2a28edaSopenharmony_cifiles (the "Software"), to deal in the Software without
39b2a28edaSopenharmony_cirestriction, including without limitation the rights to use, copy,
40b2a28edaSopenharmony_cimodify, merge, publish, distribute, sublicense, and/or sell copies
41b2a28edaSopenharmony_ciof the Software, and to permit persons to whom the Software is
42b2a28edaSopenharmony_cifurnished to do so, subject to the following conditions:
43b2a28edaSopenharmony_ci
44b2a28edaSopenharmony_ciThe above copyright notice and this permission notice shall be
45b2a28edaSopenharmony_ciincluded in all copies or substantial portions of the Software.
46b2a28edaSopenharmony_ci
47b2a28edaSopenharmony_ciTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
48b2a28edaSopenharmony_ciEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49b2a28edaSopenharmony_ciMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
50b2a28edaSopenharmony_ciNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
51b2a28edaSopenharmony_ciBE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
52b2a28edaSopenharmony_ciACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
53b2a28edaSopenharmony_ciCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54b2a28edaSopenharmony_ciSOFTWARE.
55b2a28edaSopenharmony_ci========================================================================
56b2a28edaSopenharmony_ci(END LICENSE TEXT)
57b2a28edaSopenharmony_ci
58b2a28edaSopenharmony_ciThe MIT license is compatible with both the GPL and commercial
59b2a28edaSopenharmony_cisoftware, affording one all of the rights of Public Domain with the
60b2a28edaSopenharmony_ciminor nuisance of being required to keep the above copyright notice
61b2a28edaSopenharmony_ciand license text in the source code. Note also that by accepting the
62b2a28edaSopenharmony_ciPublic Domain "license" you can re-license your copy using whatever
63b2a28edaSopenharmony_cilicense you like.
64b2a28edaSopenharmony_ci
65b2a28edaSopenharmony_ci*/
66b2a28edaSopenharmony_ci
67b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
68b2a28edaSopenharmony_ci// End of content of file: LICENSE
69b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
70b2a28edaSopenharmony_ci
71b2a28edaSopenharmony_ci
72b2a28edaSopenharmony_ci
73b2a28edaSopenharmony_ci
74b2a28edaSopenharmony_ci
75b2a28edaSopenharmony_ci#ifndef JSON_AMALGATED_H_INCLUDED
76b2a28edaSopenharmony_ci# define JSON_AMALGATED_H_INCLUDED
77b2a28edaSopenharmony_ci/// If defined, indicates that the source file is amalgated
78b2a28edaSopenharmony_ci/// to prevent private header inclusion.
79b2a28edaSopenharmony_ci#define JSON_IS_AMALGAMATION
80b2a28edaSopenharmony_ci
81b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
82b2a28edaSopenharmony_ci// Beginning of content of file: include/json/version.h
83b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
84b2a28edaSopenharmony_ci
85b2a28edaSopenharmony_ci// DO NOT EDIT. This file is generated by CMake from  "version"
86b2a28edaSopenharmony_ci// and "version.h.in" files.
87b2a28edaSopenharmony_ci// Run CMake configure step to update it.
88b2a28edaSopenharmony_ci#ifndef JSON_VERSION_H_INCLUDED
89b2a28edaSopenharmony_ci# define JSON_VERSION_H_INCLUDED
90b2a28edaSopenharmony_ci
91b2a28edaSopenharmony_ci# define JSONCPP_VERSION_STRING "1.6.2"
92b2a28edaSopenharmony_ci# define JSONCPP_VERSION_MAJOR 1
93b2a28edaSopenharmony_ci# define JSONCPP_VERSION_MINOR 6
94b2a28edaSopenharmony_ci# define JSONCPP_VERSION_PATCH 2
95b2a28edaSopenharmony_ci# define JSONCPP_VERSION_QUALIFIER
96b2a28edaSopenharmony_ci# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
97b2a28edaSopenharmony_ci
98b2a28edaSopenharmony_ci#endif // JSON_VERSION_H_INCLUDED
99b2a28edaSopenharmony_ci
100b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
101b2a28edaSopenharmony_ci// End of content of file: include/json/version.h
102b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
103b2a28edaSopenharmony_ci
104b2a28edaSopenharmony_ci
105b2a28edaSopenharmony_ci
106b2a28edaSopenharmony_ci
107b2a28edaSopenharmony_ci
108b2a28edaSopenharmony_ci
109b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
110b2a28edaSopenharmony_ci// Beginning of content of file: include/json/config.h
111b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
112b2a28edaSopenharmony_ci
113b2a28edaSopenharmony_ci// Copyright 2007-2010 Baptiste Lepilleur
114b2a28edaSopenharmony_ci// Distributed under MIT license, or public domain if desired and
115b2a28edaSopenharmony_ci// recognized in your jurisdiction.
116b2a28edaSopenharmony_ci// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
117b2a28edaSopenharmony_ci
118b2a28edaSopenharmony_ci#ifndef JSON_CONFIG_H_INCLUDED
119b2a28edaSopenharmony_ci#define JSON_CONFIG_H_INCLUDED
120b2a28edaSopenharmony_ci
121b2a28edaSopenharmony_ci/// If defined, indicates that json library is embedded in CppTL library.
122b2a28edaSopenharmony_ci//# define JSON_IN_CPPTL 1
123b2a28edaSopenharmony_ci
124b2a28edaSopenharmony_ci/// If defined, indicates that json may leverage CppTL library
125b2a28edaSopenharmony_ci//#  define JSON_USE_CPPTL 1
126b2a28edaSopenharmony_ci/// If defined, indicates that cpptl vector based map should be used instead of
127b2a28edaSopenharmony_ci/// std::map
128b2a28edaSopenharmony_ci/// as Value container.
129b2a28edaSopenharmony_ci//#  define JSON_USE_CPPTL_SMALLMAP 1
130b2a28edaSopenharmony_ci
131b2a28edaSopenharmony_ci// If non-zero, the library uses exceptions to report bad input instead of C
132b2a28edaSopenharmony_ci// assertion macros. The default is to use exceptions.
133b2a28edaSopenharmony_ci#ifndef JSON_USE_EXCEPTION
134b2a28edaSopenharmony_ci#define JSON_USE_EXCEPTION 1
135b2a28edaSopenharmony_ci#endif
136b2a28edaSopenharmony_ci
137b2a28edaSopenharmony_ci/// If defined, indicates that the source file is amalgated
138b2a28edaSopenharmony_ci/// to prevent private header inclusion.
139b2a28edaSopenharmony_ci/// Remarks: it is automatically defined in the generated amalgated header.
140b2a28edaSopenharmony_ci// #define JSON_IS_AMALGAMATION
141b2a28edaSopenharmony_ci
142b2a28edaSopenharmony_ci#ifdef JSON_IN_CPPTL
143b2a28edaSopenharmony_ci#include <cpptl/config.h>
144b2a28edaSopenharmony_ci#ifndef JSON_USE_CPPTL
145b2a28edaSopenharmony_ci#define JSON_USE_CPPTL 1
146b2a28edaSopenharmony_ci#endif
147b2a28edaSopenharmony_ci#endif
148b2a28edaSopenharmony_ci
149b2a28edaSopenharmony_ci#ifdef JSON_IN_CPPTL
150b2a28edaSopenharmony_ci#define JSON_API CPPTL_API
151b2a28edaSopenharmony_ci#elif defined(JSON_DLL_BUILD)
152b2a28edaSopenharmony_ci#if defined(_MSC_VER)
153b2a28edaSopenharmony_ci#define JSON_API __declspec(dllexport)
154b2a28edaSopenharmony_ci#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
155b2a28edaSopenharmony_ci#endif // if defined(_MSC_VER)
156b2a28edaSopenharmony_ci#elif defined(JSON_DLL)
157b2a28edaSopenharmony_ci#if defined(_MSC_VER)
158b2a28edaSopenharmony_ci#define JSON_API __declspec(dllimport)
159b2a28edaSopenharmony_ci#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
160b2a28edaSopenharmony_ci#endif // if defined(_MSC_VER)
161b2a28edaSopenharmony_ci#endif // ifdef JSON_IN_CPPTL
162b2a28edaSopenharmony_ci#if !defined(JSON_API)
163b2a28edaSopenharmony_ci#define JSON_API
164b2a28edaSopenharmony_ci#endif
165b2a28edaSopenharmony_ci
166b2a28edaSopenharmony_ci// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
167b2a28edaSopenharmony_ci// integer
168b2a28edaSopenharmony_ci// Storages, and 64 bits integer support is disabled.
169b2a28edaSopenharmony_ci// #define JSON_NO_INT64 1
170b2a28edaSopenharmony_ci
171b2a28edaSopenharmony_ci#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
172b2a28edaSopenharmony_ci// Microsoft Visual Studio 6 only support conversion from __int64 to double
173b2a28edaSopenharmony_ci// (no conversion from unsigned __int64).
174b2a28edaSopenharmony_ci#define JSON_USE_INT64_DOUBLE_CONVERSION 1
175b2a28edaSopenharmony_ci// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
176b2a28edaSopenharmony_ci// characters in the debug information)
177b2a28edaSopenharmony_ci// All projects I've ever seen with VS6 were using this globally (not bothering
178b2a28edaSopenharmony_ci// with pragma push/pop).
179b2a28edaSopenharmony_ci#pragma warning(disable : 4786)
180b2a28edaSopenharmony_ci#endif // if defined(_MSC_VER)  &&  _MSC_VER < 1200 // MSVC 6
181b2a28edaSopenharmony_ci
182b2a28edaSopenharmony_ci#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
183b2a28edaSopenharmony_ci/// Indicates that the following function is deprecated.
184b2a28edaSopenharmony_ci#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
185b2a28edaSopenharmony_ci#elif defined(__clang__) && defined(__has_feature)
186b2a28edaSopenharmony_ci#if __has_feature(attribute_deprecated_with_message)
187b2a28edaSopenharmony_ci#define JSONCPP_DEPRECATED(message)  __attribute__ ((deprecated(message)))
188b2a28edaSopenharmony_ci#endif
189b2a28edaSopenharmony_ci#elif defined(__GNUC__) &&  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
190b2a28edaSopenharmony_ci#define JSONCPP_DEPRECATED(message)  __attribute__ ((deprecated(message)))
191b2a28edaSopenharmony_ci#elif defined(__GNUC__) &&  (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
192b2a28edaSopenharmony_ci#define JSONCPP_DEPRECATED(message)  __attribute__((__deprecated__))
193b2a28edaSopenharmony_ci#endif
194b2a28edaSopenharmony_ci
195b2a28edaSopenharmony_ci#if !defined(JSONCPP_DEPRECATED)
196b2a28edaSopenharmony_ci#define JSONCPP_DEPRECATED(message)
197b2a28edaSopenharmony_ci#endif // if !defined(JSONCPP_DEPRECATED)
198b2a28edaSopenharmony_ci
199b2a28edaSopenharmony_cinamespace Json {
200b2a28edaSopenharmony_citypedef int Int;
201b2a28edaSopenharmony_citypedef unsigned int UInt;
202b2a28edaSopenharmony_ci#if defined(JSON_NO_INT64)
203b2a28edaSopenharmony_citypedef int LargestInt;
204b2a28edaSopenharmony_citypedef unsigned int LargestUInt;
205b2a28edaSopenharmony_ci#undef JSON_HAS_INT64
206b2a28edaSopenharmony_ci#else                 // if defined(JSON_NO_INT64)
207b2a28edaSopenharmony_ci// For Microsoft Visual use specific types as long long is not supported
208b2a28edaSopenharmony_ci#if defined(_MSC_VER) // Microsoft Visual Studio
209b2a28edaSopenharmony_citypedef __int64 Int64;
210b2a28edaSopenharmony_citypedef unsigned __int64 UInt64;
211b2a28edaSopenharmony_ci#else                 // if defined(_MSC_VER) // Other platforms, use long long
212b2a28edaSopenharmony_citypedef long long int Int64;
213b2a28edaSopenharmony_citypedef unsigned long long int UInt64;
214b2a28edaSopenharmony_ci#endif // if defined(_MSC_VER)
215b2a28edaSopenharmony_citypedef Int64 LargestInt;
216b2a28edaSopenharmony_citypedef UInt64 LargestUInt;
217b2a28edaSopenharmony_ci#define JSON_HAS_INT64
218b2a28edaSopenharmony_ci#endif // if defined(JSON_NO_INT64)
219b2a28edaSopenharmony_ci} // end namespace Json
220b2a28edaSopenharmony_ci
221b2a28edaSopenharmony_ci#endif // JSON_CONFIG_H_INCLUDED
222b2a28edaSopenharmony_ci
223b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
224b2a28edaSopenharmony_ci// End of content of file: include/json/config.h
225b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
226b2a28edaSopenharmony_ci
227b2a28edaSopenharmony_ci
228b2a28edaSopenharmony_ci
229b2a28edaSopenharmony_ci
230b2a28edaSopenharmony_ci
231b2a28edaSopenharmony_ci
232b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
233b2a28edaSopenharmony_ci// Beginning of content of file: include/json/forwards.h
234b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
235b2a28edaSopenharmony_ci
236b2a28edaSopenharmony_ci// Copyright 2007-2010 Baptiste Lepilleur
237b2a28edaSopenharmony_ci// Distributed under MIT license, or public domain if desired and
238b2a28edaSopenharmony_ci// recognized in your jurisdiction.
239b2a28edaSopenharmony_ci// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
240b2a28edaSopenharmony_ci
241b2a28edaSopenharmony_ci#ifndef JSON_FORWARDS_H_INCLUDED
242b2a28edaSopenharmony_ci#define JSON_FORWARDS_H_INCLUDED
243b2a28edaSopenharmony_ci
244b2a28edaSopenharmony_ci#if !defined(JSON_IS_AMALGAMATION)
245b2a28edaSopenharmony_ci#include "config.h"
246b2a28edaSopenharmony_ci#endif // if !defined(JSON_IS_AMALGAMATION)
247b2a28edaSopenharmony_ci
248b2a28edaSopenharmony_cinamespace Json {
249b2a28edaSopenharmony_ci
250b2a28edaSopenharmony_ci// writer.h
251b2a28edaSopenharmony_ciclass FastWriter;
252b2a28edaSopenharmony_ciclass StyledWriter;
253b2a28edaSopenharmony_ci
254b2a28edaSopenharmony_ci// reader.h
255b2a28edaSopenharmony_ciclass Reader;
256b2a28edaSopenharmony_ci
257b2a28edaSopenharmony_ci// features.h
258b2a28edaSopenharmony_ciclass Features;
259b2a28edaSopenharmony_ci
260b2a28edaSopenharmony_ci// value.h
261b2a28edaSopenharmony_citypedef unsigned int ArrayIndex;
262b2a28edaSopenharmony_ciclass StaticString;
263b2a28edaSopenharmony_ciclass Path;
264b2a28edaSopenharmony_ciclass PathArgument;
265b2a28edaSopenharmony_ciclass Value;
266b2a28edaSopenharmony_ciclass ValueIteratorBase;
267b2a28edaSopenharmony_ciclass ValueIterator;
268b2a28edaSopenharmony_ciclass ValueConstIterator;
269b2a28edaSopenharmony_ci
270b2a28edaSopenharmony_ci} // namespace Json
271b2a28edaSopenharmony_ci
272b2a28edaSopenharmony_ci#endif // JSON_FORWARDS_H_INCLUDED
273b2a28edaSopenharmony_ci
274b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
275b2a28edaSopenharmony_ci// End of content of file: include/json/forwards.h
276b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
277b2a28edaSopenharmony_ci
278b2a28edaSopenharmony_ci
279b2a28edaSopenharmony_ci
280b2a28edaSopenharmony_ci
281b2a28edaSopenharmony_ci
282b2a28edaSopenharmony_ci
283b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
284b2a28edaSopenharmony_ci// Beginning of content of file: include/json/features.h
285b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
286b2a28edaSopenharmony_ci
287b2a28edaSopenharmony_ci// Copyright 2007-2010 Baptiste Lepilleur
288b2a28edaSopenharmony_ci// Distributed under MIT license, or public domain if desired and
289b2a28edaSopenharmony_ci// recognized in your jurisdiction.
290b2a28edaSopenharmony_ci// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
291b2a28edaSopenharmony_ci
292b2a28edaSopenharmony_ci#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
293b2a28edaSopenharmony_ci#define CPPTL_JSON_FEATURES_H_INCLUDED
294b2a28edaSopenharmony_ci
295b2a28edaSopenharmony_ci#if !defined(JSON_IS_AMALGAMATION)
296b2a28edaSopenharmony_ci#include "forwards.h"
297b2a28edaSopenharmony_ci#endif // if !defined(JSON_IS_AMALGAMATION)
298b2a28edaSopenharmony_ci
299b2a28edaSopenharmony_cinamespace Json {
300b2a28edaSopenharmony_ci
301b2a28edaSopenharmony_ci/** \brief Configuration passed to reader and writer.
302b2a28edaSopenharmony_ci * This configuration object can be used to force the Reader or Writer
303b2a28edaSopenharmony_ci * to behave in a standard conforming way.
304b2a28edaSopenharmony_ci */
305b2a28edaSopenharmony_ciclass JSON_API Features {
306b2a28edaSopenharmony_cipublic:
307b2a28edaSopenharmony_ci  /** \brief A configuration that allows all features and assumes all strings
308b2a28edaSopenharmony_ci   * are UTF-8.
309b2a28edaSopenharmony_ci   * - C & C++ comments are allowed
310b2a28edaSopenharmony_ci   * - Root object can be any JSON value
311b2a28edaSopenharmony_ci   * - Assumes Value strings are encoded in UTF-8
312b2a28edaSopenharmony_ci   */
313b2a28edaSopenharmony_ci  static Features all();
314b2a28edaSopenharmony_ci
315b2a28edaSopenharmony_ci  /** \brief A configuration that is strictly compatible with the JSON
316b2a28edaSopenharmony_ci   * specification.
317b2a28edaSopenharmony_ci   * - Comments are forbidden.
318b2a28edaSopenharmony_ci   * - Root object must be either an array or an object value.
319b2a28edaSopenharmony_ci   * - Assumes Value strings are encoded in UTF-8
320b2a28edaSopenharmony_ci   */
321b2a28edaSopenharmony_ci  static Features strictMode();
322b2a28edaSopenharmony_ci
323b2a28edaSopenharmony_ci  /** \brief Initialize the configuration like JsonConfig::allFeatures;
324b2a28edaSopenharmony_ci   */
325b2a28edaSopenharmony_ci  Features();
326b2a28edaSopenharmony_ci
327b2a28edaSopenharmony_ci  /// \c true if comments are allowed. Default: \c true.
328b2a28edaSopenharmony_ci  bool allowComments_;
329b2a28edaSopenharmony_ci
330b2a28edaSopenharmony_ci  /// \c true if root must be either an array or an object value. Default: \c
331b2a28edaSopenharmony_ci  /// false.
332b2a28edaSopenharmony_ci  bool strictRoot_;
333b2a28edaSopenharmony_ci
334b2a28edaSopenharmony_ci  /// \c true if dropped null placeholders are allowed. Default: \c false.
335b2a28edaSopenharmony_ci  bool allowDroppedNullPlaceholders_;
336b2a28edaSopenharmony_ci
337b2a28edaSopenharmony_ci  /// \c true if numeric object key are allowed. Default: \c false.
338b2a28edaSopenharmony_ci  bool allowNumericKeys_;
339b2a28edaSopenharmony_ci};
340b2a28edaSopenharmony_ci
341b2a28edaSopenharmony_ci} // namespace Json
342b2a28edaSopenharmony_ci
343b2a28edaSopenharmony_ci#endif // CPPTL_JSON_FEATURES_H_INCLUDED
344b2a28edaSopenharmony_ci
345b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
346b2a28edaSopenharmony_ci// End of content of file: include/json/features.h
347b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
348b2a28edaSopenharmony_ci
349b2a28edaSopenharmony_ci
350b2a28edaSopenharmony_ci
351b2a28edaSopenharmony_ci
352b2a28edaSopenharmony_ci
353b2a28edaSopenharmony_ci
354b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
355b2a28edaSopenharmony_ci// Beginning of content of file: include/json/value.h
356b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
357b2a28edaSopenharmony_ci
358b2a28edaSopenharmony_ci// Copyright 2007-2010 Baptiste Lepilleur
359b2a28edaSopenharmony_ci// Distributed under MIT license, or public domain if desired and
360b2a28edaSopenharmony_ci// recognized in your jurisdiction.
361b2a28edaSopenharmony_ci// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
362b2a28edaSopenharmony_ci
363b2a28edaSopenharmony_ci#ifndef CPPTL_JSON_H_INCLUDED
364b2a28edaSopenharmony_ci#define CPPTL_JSON_H_INCLUDED
365b2a28edaSopenharmony_ci
366b2a28edaSopenharmony_ci#if !defined(JSON_IS_AMALGAMATION)
367b2a28edaSopenharmony_ci#include "forwards.h"
368b2a28edaSopenharmony_ci#endif // if !defined(JSON_IS_AMALGAMATION)
369b2a28edaSopenharmony_ci#include <string>
370b2a28edaSopenharmony_ci#include <vector>
371b2a28edaSopenharmony_ci#include <exception>
372b2a28edaSopenharmony_ci
373b2a28edaSopenharmony_ci#ifndef JSON_USE_CPPTL_SMALLMAP
374b2a28edaSopenharmony_ci#include <map>
375b2a28edaSopenharmony_ci#else
376b2a28edaSopenharmony_ci#include <cpptl/smallmap.h>
377b2a28edaSopenharmony_ci#endif
378b2a28edaSopenharmony_ci#ifdef JSON_USE_CPPTL
379b2a28edaSopenharmony_ci#include <cpptl/forwards.h>
380b2a28edaSopenharmony_ci#endif
381b2a28edaSopenharmony_ci
382b2a28edaSopenharmony_ci// Disable warning C4251: <data member>: <type> needs to have dll-interface to
383b2a28edaSopenharmony_ci// be used by...
384b2a28edaSopenharmony_ci#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
385b2a28edaSopenharmony_ci#pragma warning(push)
386b2a28edaSopenharmony_ci#pragma warning(disable : 4251)
387b2a28edaSopenharmony_ci#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
388b2a28edaSopenharmony_ci
389b2a28edaSopenharmony_ci/** \brief JSON (JavaScript Object Notation).
390b2a28edaSopenharmony_ci */
391b2a28edaSopenharmony_cinamespace Json {
392b2a28edaSopenharmony_ci
393b2a28edaSopenharmony_ci/** Base class for all exceptions we throw.
394b2a28edaSopenharmony_ci *
395b2a28edaSopenharmony_ci * We use nothing but these internally. Of course, STL can throw others.
396b2a28edaSopenharmony_ci */
397b2a28edaSopenharmony_ciclass JSON_API Exception;
398b2a28edaSopenharmony_ci/** Exceptions which the user cannot easily avoid.
399b2a28edaSopenharmony_ci *
400b2a28edaSopenharmony_ci * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
401b2a28edaSopenharmony_ci *
402b2a28edaSopenharmony_ci * \remark derived from Json::Exception
403b2a28edaSopenharmony_ci */
404b2a28edaSopenharmony_ciclass JSON_API RuntimeError;
405b2a28edaSopenharmony_ci/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
406b2a28edaSopenharmony_ci *
407b2a28edaSopenharmony_ci * These are precondition-violations (user bugs) and internal errors (our bugs).
408b2a28edaSopenharmony_ci *
409b2a28edaSopenharmony_ci * \remark derived from Json::Exception
410b2a28edaSopenharmony_ci */
411b2a28edaSopenharmony_ciclass JSON_API LogicError;
412b2a28edaSopenharmony_ci
413b2a28edaSopenharmony_ci/// used internally
414b2a28edaSopenharmony_civoid throwRuntimeError(std::string const& msg);
415b2a28edaSopenharmony_ci/// used internally
416b2a28edaSopenharmony_civoid throwLogicError(std::string const& msg);
417b2a28edaSopenharmony_ci
418b2a28edaSopenharmony_ci/** \brief Type of the value held by a Value object.
419b2a28edaSopenharmony_ci */
420b2a28edaSopenharmony_cienum ValueType {
421b2a28edaSopenharmony_ci  nullValue = 0, ///< 'null' value
422b2a28edaSopenharmony_ci  intValue,      ///< signed integer value
423b2a28edaSopenharmony_ci  uintValue,     ///< unsigned integer value
424b2a28edaSopenharmony_ci  realValue,     ///< double value
425b2a28edaSopenharmony_ci  stringValue,   ///< UTF-8 string value
426b2a28edaSopenharmony_ci  booleanValue,  ///< bool value
427b2a28edaSopenharmony_ci  arrayValue,    ///< array value (ordered list)
428b2a28edaSopenharmony_ci  objectValue    ///< object value (collection of name/value pairs).
429b2a28edaSopenharmony_ci};
430b2a28edaSopenharmony_ci
431b2a28edaSopenharmony_cienum CommentPlacement {
432b2a28edaSopenharmony_ci  commentBefore = 0,      ///< a comment placed on the line before a value
433b2a28edaSopenharmony_ci  commentAfterOnSameLine, ///< a comment just after a value on the same line
434b2a28edaSopenharmony_ci  commentAfter, ///< a comment on the line after a value (only make sense for
435b2a28edaSopenharmony_ci  /// root value)
436b2a28edaSopenharmony_ci  numberOfCommentPlacement
437b2a28edaSopenharmony_ci};
438b2a28edaSopenharmony_ci
439b2a28edaSopenharmony_ci//# ifdef JSON_USE_CPPTL
440b2a28edaSopenharmony_ci//   typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
441b2a28edaSopenharmony_ci//   typedef CppTL::AnyEnumerator<const Value &> EnumValues;
442b2a28edaSopenharmony_ci//# endif
443b2a28edaSopenharmony_ci
444b2a28edaSopenharmony_ci/** \brief Lightweight wrapper to tag static string.
445b2a28edaSopenharmony_ci *
446b2a28edaSopenharmony_ci * Value constructor and objectValue member assignement takes advantage of the
447b2a28edaSopenharmony_ci * StaticString and avoid the cost of string duplication when storing the
448b2a28edaSopenharmony_ci * string or the member name.
449b2a28edaSopenharmony_ci *
450b2a28edaSopenharmony_ci * Example of usage:
451b2a28edaSopenharmony_ci * \code
452b2a28edaSopenharmony_ci * Json::Value aValue( StaticString("some text") );
453b2a28edaSopenharmony_ci * Json::Value object;
454b2a28edaSopenharmony_ci * static const StaticString code("code");
455b2a28edaSopenharmony_ci * object[code] = 1234;
456b2a28edaSopenharmony_ci * \endcode
457b2a28edaSopenharmony_ci */
458b2a28edaSopenharmony_ciclass JSON_API StaticString {
459b2a28edaSopenharmony_cipublic:
460b2a28edaSopenharmony_ci  explicit StaticString(const char* czstring) : c_str_(czstring) {}
461b2a28edaSopenharmony_ci
462b2a28edaSopenharmony_ci  operator const char*() const { return c_str_; }
463b2a28edaSopenharmony_ci
464b2a28edaSopenharmony_ci  const char* c_str() const { return c_str_; }
465b2a28edaSopenharmony_ci
466b2a28edaSopenharmony_ciprivate:
467b2a28edaSopenharmony_ci  const char* c_str_;
468b2a28edaSopenharmony_ci};
469b2a28edaSopenharmony_ci
470b2a28edaSopenharmony_ci/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
471b2a28edaSopenharmony_ci *
472b2a28edaSopenharmony_ci * This class is a discriminated union wrapper that can represents a:
473b2a28edaSopenharmony_ci * - signed integer [range: Value::minInt - Value::maxInt]
474b2a28edaSopenharmony_ci * - unsigned integer (range: 0 - Value::maxUInt)
475b2a28edaSopenharmony_ci * - double
476b2a28edaSopenharmony_ci * - UTF-8 string
477b2a28edaSopenharmony_ci * - boolean
478b2a28edaSopenharmony_ci * - 'null'
479b2a28edaSopenharmony_ci * - an ordered list of Value
480b2a28edaSopenharmony_ci * - collection of name/value pairs (javascript object)
481b2a28edaSopenharmony_ci *
482b2a28edaSopenharmony_ci * The type of the held value is represented by a #ValueType and
483b2a28edaSopenharmony_ci * can be obtained using type().
484b2a28edaSopenharmony_ci *
485b2a28edaSopenharmony_ci * Values of an #objectValue or #arrayValue can be accessed using operator[]()
486b2a28edaSopenharmony_ci * methods.
487b2a28edaSopenharmony_ci * Non-const methods will automatically create the a #nullValue element
488b2a28edaSopenharmony_ci * if it does not exist.
489b2a28edaSopenharmony_ci * The sequence of an #arrayValue will be automatically resized and initialized
490b2a28edaSopenharmony_ci * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
491b2a28edaSopenharmony_ci *
492b2a28edaSopenharmony_ci * The get() methods can be used to obtain default value in the case the
493b2a28edaSopenharmony_ci * required element does not exist.
494b2a28edaSopenharmony_ci *
495b2a28edaSopenharmony_ci * It is possible to iterate over the list of a #objectValue values using
496b2a28edaSopenharmony_ci * the getMemberNames() method.
497b2a28edaSopenharmony_ci *
498b2a28edaSopenharmony_ci * \note #Value string-length fit in size_t, but keys must be < 2^30.
499b2a28edaSopenharmony_ci * (The reason is an implementation detail.) A #CharReader will raise an
500b2a28edaSopenharmony_ci * exception if a bound is exceeded to avoid security holes in your app,
501b2a28edaSopenharmony_ci * but the Value API does *not* check bounds. That is the responsibility
502b2a28edaSopenharmony_ci * of the caller.
503b2a28edaSopenharmony_ci */
504b2a28edaSopenharmony_ciclass JSON_API Value {
505b2a28edaSopenharmony_ci  friend class ValueIteratorBase;
506b2a28edaSopenharmony_cipublic:
507b2a28edaSopenharmony_ci  typedef std::vector<std::string> Members;
508b2a28edaSopenharmony_ci  typedef ValueIterator iterator;
509b2a28edaSopenharmony_ci  typedef ValueConstIterator const_iterator;
510b2a28edaSopenharmony_ci  typedef Json::UInt UInt;
511b2a28edaSopenharmony_ci  typedef Json::Int Int;
512b2a28edaSopenharmony_ci#if defined(JSON_HAS_INT64)
513b2a28edaSopenharmony_ci  typedef Json::UInt64 UInt64;
514b2a28edaSopenharmony_ci  typedef Json::Int64 Int64;
515b2a28edaSopenharmony_ci#endif // defined(JSON_HAS_INT64)
516b2a28edaSopenharmony_ci  typedef Json::LargestInt LargestInt;
517b2a28edaSopenharmony_ci  typedef Json::LargestUInt LargestUInt;
518b2a28edaSopenharmony_ci  typedef Json::ArrayIndex ArrayIndex;
519b2a28edaSopenharmony_ci
520b2a28edaSopenharmony_ci  static const Value& null;  ///< We regret this reference to a global instance; prefer the simpler Value().
521b2a28edaSopenharmony_ci  static const Value& nullRef;  ///< just a kludge for binary-compatibility; same as null
522b2a28edaSopenharmony_ci  /// Minimum signed integer value that can be stored in a Json::Value.
523b2a28edaSopenharmony_ci  static const LargestInt minLargestInt;
524b2a28edaSopenharmony_ci  /// Maximum signed integer value that can be stored in a Json::Value.
525b2a28edaSopenharmony_ci  static const LargestInt maxLargestInt;
526b2a28edaSopenharmony_ci  /// Maximum unsigned integer value that can be stored in a Json::Value.
527b2a28edaSopenharmony_ci  static const LargestUInt maxLargestUInt;
528b2a28edaSopenharmony_ci
529b2a28edaSopenharmony_ci  /// Minimum signed int value that can be stored in a Json::Value.
530b2a28edaSopenharmony_ci  static const Int minInt;
531b2a28edaSopenharmony_ci  /// Maximum signed int value that can be stored in a Json::Value.
532b2a28edaSopenharmony_ci  static const Int maxInt;
533b2a28edaSopenharmony_ci  /// Maximum unsigned int value that can be stored in a Json::Value.
534b2a28edaSopenharmony_ci  static const UInt maxUInt;
535b2a28edaSopenharmony_ci
536b2a28edaSopenharmony_ci#if defined(JSON_HAS_INT64)
537b2a28edaSopenharmony_ci  /// Minimum signed 64 bits int value that can be stored in a Json::Value.
538b2a28edaSopenharmony_ci  static const Int64 minInt64;
539b2a28edaSopenharmony_ci  /// Maximum signed 64 bits int value that can be stored in a Json::Value.
540b2a28edaSopenharmony_ci  static const Int64 maxInt64;
541b2a28edaSopenharmony_ci  /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
542b2a28edaSopenharmony_ci  static const UInt64 maxUInt64;
543b2a28edaSopenharmony_ci#endif // defined(JSON_HAS_INT64)
544b2a28edaSopenharmony_ci
545b2a28edaSopenharmony_ciprivate:
546b2a28edaSopenharmony_ci#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
547b2a28edaSopenharmony_ci  class CZString {
548b2a28edaSopenharmony_ci  public:
549b2a28edaSopenharmony_ci    enum DuplicationPolicy {
550b2a28edaSopenharmony_ci      noDuplication = 0,
551b2a28edaSopenharmony_ci      duplicate,
552b2a28edaSopenharmony_ci      duplicateOnCopy
553b2a28edaSopenharmony_ci    };
554b2a28edaSopenharmony_ci    CZString(ArrayIndex index);
555b2a28edaSopenharmony_ci    CZString(char const* str, unsigned length, DuplicationPolicy allocate);
556b2a28edaSopenharmony_ci    CZString(CZString const& other);
557b2a28edaSopenharmony_ci    ~CZString();
558b2a28edaSopenharmony_ci    CZString& operator=(CZString other);
559b2a28edaSopenharmony_ci    bool operator<(CZString const& other) const;
560b2a28edaSopenharmony_ci    bool operator==(CZString const& other) const;
561b2a28edaSopenharmony_ci    ArrayIndex index() const;
562b2a28edaSopenharmony_ci    //const char* c_str() const; ///< \deprecated
563b2a28edaSopenharmony_ci    char const* data() const;
564b2a28edaSopenharmony_ci    unsigned length() const;
565b2a28edaSopenharmony_ci    bool isStaticString() const;
566b2a28edaSopenharmony_ci
567b2a28edaSopenharmony_ci  private:
568b2a28edaSopenharmony_ci    void swap(CZString& other);
569b2a28edaSopenharmony_ci
570b2a28edaSopenharmony_ci    struct StringStorage {
571b2a28edaSopenharmony_ci      unsigned policy_: 2;
572b2a28edaSopenharmony_ci      unsigned length_: 30; // 1GB max
573b2a28edaSopenharmony_ci    };
574b2a28edaSopenharmony_ci
575b2a28edaSopenharmony_ci    char const* cstr_;  // actually, a prefixed string, unless policy is noDup
576b2a28edaSopenharmony_ci    union {
577b2a28edaSopenharmony_ci      ArrayIndex index_;
578b2a28edaSopenharmony_ci      StringStorage storage_;
579b2a28edaSopenharmony_ci    };
580b2a28edaSopenharmony_ci  };
581b2a28edaSopenharmony_ci
582b2a28edaSopenharmony_cipublic:
583b2a28edaSopenharmony_ci#ifndef JSON_USE_CPPTL_SMALLMAP
584b2a28edaSopenharmony_ci  typedef std::map<CZString, Value> ObjectValues;
585b2a28edaSopenharmony_ci#else
586b2a28edaSopenharmony_ci  typedef CppTL::SmallMap<CZString, Value> ObjectValues;
587b2a28edaSopenharmony_ci#endif // ifndef JSON_USE_CPPTL_SMALLMAP
588b2a28edaSopenharmony_ci#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
589b2a28edaSopenharmony_ci
590b2a28edaSopenharmony_cipublic:
591b2a28edaSopenharmony_ci  /** \brief Create a default Value of the given type.
592b2a28edaSopenharmony_ci
593b2a28edaSopenharmony_ci    This is a very useful constructor.
594b2a28edaSopenharmony_ci    To create an empty array, pass arrayValue.
595b2a28edaSopenharmony_ci    To create an empty object, pass objectValue.
596b2a28edaSopenharmony_ci    Another Value can then be set to this one by assignment.
597b2a28edaSopenharmony_ciThis is useful since clear() and resize() will not alter types.
598b2a28edaSopenharmony_ci
599b2a28edaSopenharmony_ci    Examples:
600b2a28edaSopenharmony_ci\code
601b2a28edaSopenharmony_ciJson::Value null_value; // null
602b2a28edaSopenharmony_ciJson::Value arr_value(Json::arrayValue); // []
603b2a28edaSopenharmony_ciJson::Value obj_value(Json::objectValue); // {}
604b2a28edaSopenharmony_ci\endcode
605b2a28edaSopenharmony_ci  */
606b2a28edaSopenharmony_ci  Value(ValueType type = nullValue);
607b2a28edaSopenharmony_ci  Value(Int value);
608b2a28edaSopenharmony_ci  Value(UInt value);
609b2a28edaSopenharmony_ci#if defined(JSON_HAS_INT64)
610b2a28edaSopenharmony_ci  Value(Int64 value);
611b2a28edaSopenharmony_ci  Value(UInt64 value);
612b2a28edaSopenharmony_ci#endif // if defined(JSON_HAS_INT64)
613b2a28edaSopenharmony_ci  Value(double value);
614b2a28edaSopenharmony_ci  Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
615b2a28edaSopenharmony_ci  Value(const char* beginValue, const char* endValue); ///< Copy all, incl zeroes.
616b2a28edaSopenharmony_ci  /** \brief Constructs a value from a static string.
617b2a28edaSopenharmony_ci
618b2a28edaSopenharmony_ci   * Like other value string constructor but do not duplicate the string for
619b2a28edaSopenharmony_ci   * internal storage. The given string must remain alive after the call to this
620b2a28edaSopenharmony_ci   * constructor.
621b2a28edaSopenharmony_ci   * \note This works only for null-terminated strings. (We cannot change the
622b2a28edaSopenharmony_ci   *   size of this class, so we have nowhere to store the length,
623b2a28edaSopenharmony_ci   *   which might be computed later for various operations.)
624b2a28edaSopenharmony_ci   *
625b2a28edaSopenharmony_ci   * Example of usage:
626b2a28edaSopenharmony_ci   * \code
627b2a28edaSopenharmony_ci   * static StaticString foo("some text");
628b2a28edaSopenharmony_ci   * Json::Value aValue(foo);
629b2a28edaSopenharmony_ci   * \endcode
630b2a28edaSopenharmony_ci   */
631b2a28edaSopenharmony_ci  Value(const StaticString& value);
632b2a28edaSopenharmony_ci  Value(const std::string& value); ///< Copy data() til size(). Embedded zeroes too.
633b2a28edaSopenharmony_ci#ifdef JSON_USE_CPPTL
634b2a28edaSopenharmony_ci  Value(const CppTL::ConstString& value);
635b2a28edaSopenharmony_ci#endif
636b2a28edaSopenharmony_ci  Value(bool value);
637b2a28edaSopenharmony_ci  /// Deep copy.
638b2a28edaSopenharmony_ci  Value(const Value& other);
639b2a28edaSopenharmony_ci  ~Value();
640b2a28edaSopenharmony_ci
641b2a28edaSopenharmony_ci  /// Deep copy, then swap(other).
642b2a28edaSopenharmony_ci  /// \note Over-write existing comments. To preserve comments, use #swapPayload().
643b2a28edaSopenharmony_ci  Value& operator=(Value other);
644b2a28edaSopenharmony_ci  /// Swap everything.
645b2a28edaSopenharmony_ci  void swap(Value& other);
646b2a28edaSopenharmony_ci  /// Swap values but leave comments and source offsets in place.
647b2a28edaSopenharmony_ci  void swapPayload(Value& other);
648b2a28edaSopenharmony_ci
649b2a28edaSopenharmony_ci  ValueType type() const;
650b2a28edaSopenharmony_ci
651b2a28edaSopenharmony_ci  /// Compare payload only, not comments etc.
652b2a28edaSopenharmony_ci  bool operator<(const Value& other) const;
653b2a28edaSopenharmony_ci  bool operator<=(const Value& other) const;
654b2a28edaSopenharmony_ci  bool operator>=(const Value& other) const;
655b2a28edaSopenharmony_ci  bool operator>(const Value& other) const;
656b2a28edaSopenharmony_ci  bool operator==(const Value& other) const;
657b2a28edaSopenharmony_ci  bool operator!=(const Value& other) const;
658b2a28edaSopenharmony_ci  int compare(const Value& other) const;
659b2a28edaSopenharmony_ci
660b2a28edaSopenharmony_ci  const char* asCString() const; ///< Embedded zeroes could cause you trouble!
661b2a28edaSopenharmony_ci  std::string asString() const; ///< Embedded zeroes are possible.
662b2a28edaSopenharmony_ci  /** Get raw char* of string-value.
663b2a28edaSopenharmony_ci   *  \return false if !string. (Seg-fault if str or end are NULL.)
664b2a28edaSopenharmony_ci   */
665b2a28edaSopenharmony_ci  bool getString(
666b2a28edaSopenharmony_ci      char const** str, char const** end) const;
667b2a28edaSopenharmony_ci#ifdef JSON_USE_CPPTL
668b2a28edaSopenharmony_ci  CppTL::ConstString asConstString() const;
669b2a28edaSopenharmony_ci#endif
670b2a28edaSopenharmony_ci  Int asInt() const;
671b2a28edaSopenharmony_ci  UInt asUInt() const;
672b2a28edaSopenharmony_ci#if defined(JSON_HAS_INT64)
673b2a28edaSopenharmony_ci  Int64 asInt64() const;
674b2a28edaSopenharmony_ci  UInt64 asUInt64() const;
675b2a28edaSopenharmony_ci#endif // if defined(JSON_HAS_INT64)
676b2a28edaSopenharmony_ci  LargestInt asLargestInt() const;
677b2a28edaSopenharmony_ci  LargestUInt asLargestUInt() const;
678b2a28edaSopenharmony_ci  float asFloat() const;
679b2a28edaSopenharmony_ci  double asDouble() const;
680b2a28edaSopenharmony_ci  bool asBool() const;
681b2a28edaSopenharmony_ci
682b2a28edaSopenharmony_ci  bool isNull() const;
683b2a28edaSopenharmony_ci  bool isBool() const;
684b2a28edaSopenharmony_ci  bool isInt() const;
685b2a28edaSopenharmony_ci  bool isInt64() const;
686b2a28edaSopenharmony_ci  bool isUInt() const;
687b2a28edaSopenharmony_ci  bool isUInt64() const;
688b2a28edaSopenharmony_ci  bool isIntegral() const;
689b2a28edaSopenharmony_ci  bool isDouble() const;
690b2a28edaSopenharmony_ci  bool isNumeric() const;
691b2a28edaSopenharmony_ci  bool isString() const;
692b2a28edaSopenharmony_ci  bool isArray() const;
693b2a28edaSopenharmony_ci  bool isObject() const;
694b2a28edaSopenharmony_ci
695b2a28edaSopenharmony_ci  bool isConvertibleTo(ValueType other) const;
696b2a28edaSopenharmony_ci
697b2a28edaSopenharmony_ci  /// Number of values in array or object
698b2a28edaSopenharmony_ci  ArrayIndex size() const;
699b2a28edaSopenharmony_ci
700b2a28edaSopenharmony_ci  /// \brief Return true if empty array, empty object, or null;
701b2a28edaSopenharmony_ci  /// otherwise, false.
702b2a28edaSopenharmony_ci  bool empty() const;
703b2a28edaSopenharmony_ci
704b2a28edaSopenharmony_ci  /// Return isNull()
705b2a28edaSopenharmony_ci  bool operator!() const;
706b2a28edaSopenharmony_ci
707b2a28edaSopenharmony_ci  /// Remove all object members and array elements.
708b2a28edaSopenharmony_ci  /// \pre type() is arrayValue, objectValue, or nullValue
709b2a28edaSopenharmony_ci  /// \post type() is unchanged
710b2a28edaSopenharmony_ci  void clear();
711b2a28edaSopenharmony_ci
712b2a28edaSopenharmony_ci  /// Resize the array to size elements.
713b2a28edaSopenharmony_ci  /// New elements are initialized to null.
714b2a28edaSopenharmony_ci  /// May only be called on nullValue or arrayValue.
715b2a28edaSopenharmony_ci  /// \pre type() is arrayValue or nullValue
716b2a28edaSopenharmony_ci  /// \post type() is arrayValue
717b2a28edaSopenharmony_ci  void resize(ArrayIndex size);
718b2a28edaSopenharmony_ci
719b2a28edaSopenharmony_ci  /// Access an array element (zero based index ).
720b2a28edaSopenharmony_ci  /// If the array contains less than index element, then null value are
721b2a28edaSopenharmony_ci  /// inserted
722b2a28edaSopenharmony_ci  /// in the array so that its size is index+1.
723b2a28edaSopenharmony_ci  /// (You may need to say 'value[0u]' to get your compiler to distinguish
724b2a28edaSopenharmony_ci  ///  this from the operator[] which takes a string.)
725b2a28edaSopenharmony_ci  Value& operator[](ArrayIndex index);
726b2a28edaSopenharmony_ci
727b2a28edaSopenharmony_ci  /// Access an array element (zero based index ).
728b2a28edaSopenharmony_ci  /// If the array contains less than index element, then null value are
729b2a28edaSopenharmony_ci  /// inserted
730b2a28edaSopenharmony_ci  /// in the array so that its size is index+1.
731b2a28edaSopenharmony_ci  /// (You may need to say 'value[0u]' to get your compiler to distinguish
732b2a28edaSopenharmony_ci  ///  this from the operator[] which takes a string.)
733b2a28edaSopenharmony_ci  Value& operator[](int index);
734b2a28edaSopenharmony_ci
735b2a28edaSopenharmony_ci  /// Access an array element (zero based index )
736b2a28edaSopenharmony_ci  /// (You may need to say 'value[0u]' to get your compiler to distinguish
737b2a28edaSopenharmony_ci  ///  this from the operator[] which takes a string.)
738b2a28edaSopenharmony_ci  const Value& operator[](ArrayIndex index) const;
739b2a28edaSopenharmony_ci
740b2a28edaSopenharmony_ci  /// Access an array element (zero based index )
741b2a28edaSopenharmony_ci  /// (You may need to say 'value[0u]' to get your compiler to distinguish
742b2a28edaSopenharmony_ci  ///  this from the operator[] which takes a string.)
743b2a28edaSopenharmony_ci  const Value& operator[](int index) const;
744b2a28edaSopenharmony_ci
745b2a28edaSopenharmony_ci  /// If the array contains at least index+1 elements, returns the element
746b2a28edaSopenharmony_ci  /// value,
747b2a28edaSopenharmony_ci  /// otherwise returns defaultValue.
748b2a28edaSopenharmony_ci  Value get(ArrayIndex index, const Value& defaultValue) const;
749b2a28edaSopenharmony_ci  /// Return true if index < size().
750b2a28edaSopenharmony_ci  bool isValidIndex(ArrayIndex index) const;
751b2a28edaSopenharmony_ci  /// \brief Append value to array at the end.
752b2a28edaSopenharmony_ci  ///
753b2a28edaSopenharmony_ci  /// Equivalent to jsonvalue[jsonvalue.size()] = value;
754b2a28edaSopenharmony_ci  Value& append(const Value& value);
755b2a28edaSopenharmony_ci
756b2a28edaSopenharmony_ci  /// Access an object value by name, create a null member if it does not exist.
757b2a28edaSopenharmony_ci  /// \note Because of our implementation, keys are limited to 2^30 -1 chars.
758b2a28edaSopenharmony_ci  ///  Exceeding that will cause an exception.
759b2a28edaSopenharmony_ci  Value& operator[](const char* key);
760b2a28edaSopenharmony_ci  /// Access an object value by name, returns null if there is no member with
761b2a28edaSopenharmony_ci  /// that name.
762b2a28edaSopenharmony_ci  const Value& operator[](const char* key) const;
763b2a28edaSopenharmony_ci  /// Access an object value by name, create a null member if it does not exist.
764b2a28edaSopenharmony_ci  /// \param key may contain embedded nulls.
765b2a28edaSopenharmony_ci  Value& operator[](const std::string& key);
766b2a28edaSopenharmony_ci  /// Access an object value by name, returns null if there is no member with
767b2a28edaSopenharmony_ci  /// that name.
768b2a28edaSopenharmony_ci  /// \param key may contain embedded nulls.
769b2a28edaSopenharmony_ci  const Value& operator[](const std::string& key) const;
770b2a28edaSopenharmony_ci  /** \brief Access an object value by name, create a null member if it does not
771b2a28edaSopenharmony_ci   exist.
772b2a28edaSopenharmony_ci
773b2a28edaSopenharmony_ci   * If the object has no entry for that name, then the member name used to store
774b2a28edaSopenharmony_ci   * the new entry is not duplicated.
775b2a28edaSopenharmony_ci   * Example of use:
776b2a28edaSopenharmony_ci   * \code
777b2a28edaSopenharmony_ci   * Json::Value object;
778b2a28edaSopenharmony_ci   * static const StaticString code("code");
779b2a28edaSopenharmony_ci   * object[code] = 1234;
780b2a28edaSopenharmony_ci   * \endcode
781b2a28edaSopenharmony_ci   */
782b2a28edaSopenharmony_ci  Value& operator[](const StaticString& key);
783b2a28edaSopenharmony_ci#ifdef JSON_USE_CPPTL
784b2a28edaSopenharmony_ci  /// Access an object value by name, create a null member if it does not exist.
785b2a28edaSopenharmony_ci  Value& operator[](const CppTL::ConstString& key);
786b2a28edaSopenharmony_ci  /// Access an object value by name, returns null if there is no member with
787b2a28edaSopenharmony_ci  /// that name.
788b2a28edaSopenharmony_ci  const Value& operator[](const CppTL::ConstString& key) const;
789b2a28edaSopenharmony_ci#endif
790b2a28edaSopenharmony_ci  /// Return the member named key if it exist, defaultValue otherwise.
791b2a28edaSopenharmony_ci  /// \note deep copy
792b2a28edaSopenharmony_ci  Value get(const char* key, const Value& defaultValue) const;
793b2a28edaSopenharmony_ci  /// Return the member named key if it exist, defaultValue otherwise.
794b2a28edaSopenharmony_ci  /// \note deep copy
795b2a28edaSopenharmony_ci  /// \param key may contain embedded nulls.
796b2a28edaSopenharmony_ci  Value get(const char* key, const char* end, const Value& defaultValue) const;
797b2a28edaSopenharmony_ci  /// Return the member named key if it exist, defaultValue otherwise.
798b2a28edaSopenharmony_ci  /// \note deep copy
799b2a28edaSopenharmony_ci  /// \param key may contain embedded nulls.
800b2a28edaSopenharmony_ci  Value get(const std::string& key, const Value& defaultValue) const;
801b2a28edaSopenharmony_ci#ifdef JSON_USE_CPPTL
802b2a28edaSopenharmony_ci  /// Return the member named key if it exist, defaultValue otherwise.
803b2a28edaSopenharmony_ci  /// \note deep copy
804b2a28edaSopenharmony_ci  Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
805b2a28edaSopenharmony_ci#endif
806b2a28edaSopenharmony_ci  /// Most general and efficient version of isMember()const, get()const,
807b2a28edaSopenharmony_ci  /// and operator[]const
808b2a28edaSopenharmony_ci  /// \note As stated elsewhere, behavior is undefined if (end-key) >= 2^30
809b2a28edaSopenharmony_ci  Value const* find(char const* key, char const* end) const;
810b2a28edaSopenharmony_ci  /// Most general and efficient version of object-mutators.
811b2a28edaSopenharmony_ci  /// \note As stated elsewhere, behavior is undefined if (end-key) >= 2^30
812b2a28edaSopenharmony_ci  /// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
813b2a28edaSopenharmony_ci  Value const* demand(char const* key, char const* end);
814b2a28edaSopenharmony_ci  /// \brief Remove and return the named member.
815b2a28edaSopenharmony_ci  ///
816b2a28edaSopenharmony_ci  /// Do nothing if it did not exist.
817b2a28edaSopenharmony_ci  /// \return the removed Value, or null.
818b2a28edaSopenharmony_ci  /// \pre type() is objectValue or nullValue
819b2a28edaSopenharmony_ci  /// \post type() is unchanged
820b2a28edaSopenharmony_ci  /// \deprecated
821b2a28edaSopenharmony_ci  Value removeMember(const char* key);
822b2a28edaSopenharmony_ci  /// Same as removeMember(const char*)
823b2a28edaSopenharmony_ci  /// \param key may contain embedded nulls.
824b2a28edaSopenharmony_ci  /// \deprecated
825b2a28edaSopenharmony_ci  Value removeMember(const std::string& key);
826b2a28edaSopenharmony_ci  /// Same as removeMember(const char* key, const char* end, Value* removed),
827b2a28edaSopenharmony_ci  /// but 'key' is null-terminated.
828b2a28edaSopenharmony_ci  bool removeMember(const char* key, Value* removed);
829b2a28edaSopenharmony_ci  /** \brief Remove the named map member.
830b2a28edaSopenharmony_ci
831b2a28edaSopenharmony_ci      Update 'removed' iff removed.
832b2a28edaSopenharmony_ci      \param key may contain embedded nulls.
833b2a28edaSopenharmony_ci      \return true iff removed (no exceptions)
834b2a28edaSopenharmony_ci  */
835b2a28edaSopenharmony_ci  bool removeMember(std::string const& key, Value* removed);
836b2a28edaSopenharmony_ci  /// Same as removeMember(std::string const& key, Value* removed)
837b2a28edaSopenharmony_ci  bool removeMember(const char* key, const char* end, Value* removed);
838b2a28edaSopenharmony_ci  /** \brief Remove the indexed array element.
839b2a28edaSopenharmony_ci
840b2a28edaSopenharmony_ci      O(n) expensive operations.
841b2a28edaSopenharmony_ci      Update 'removed' iff removed.
842b2a28edaSopenharmony_ci      \return true iff removed (no exceptions)
843b2a28edaSopenharmony_ci  */
844b2a28edaSopenharmony_ci  bool removeIndex(ArrayIndex i, Value* removed);
845b2a28edaSopenharmony_ci
846b2a28edaSopenharmony_ci  /// Return true if the object has a member named key.
847b2a28edaSopenharmony_ci  /// \note 'key' must be null-terminated.
848b2a28edaSopenharmony_ci  bool isMember(const char* key) const;
849b2a28edaSopenharmony_ci  /// Return true if the object has a member named key.
850b2a28edaSopenharmony_ci  /// \param key may contain embedded nulls.
851b2a28edaSopenharmony_ci  bool isMember(const std::string& key) const;
852b2a28edaSopenharmony_ci  /// Same as isMember(std::string const& key)const
853b2a28edaSopenharmony_ci  bool isMember(const char* key, const char* end) const;
854b2a28edaSopenharmony_ci#ifdef JSON_USE_CPPTL
855b2a28edaSopenharmony_ci  /// Return true if the object has a member named key.
856b2a28edaSopenharmony_ci  bool isMember(const CppTL::ConstString& key) const;
857b2a28edaSopenharmony_ci#endif
858b2a28edaSopenharmony_ci
859b2a28edaSopenharmony_ci  /// \brief Return a list of the member names.
860b2a28edaSopenharmony_ci  ///
861b2a28edaSopenharmony_ci  /// If null, return an empty list.
862b2a28edaSopenharmony_ci  /// \pre type() is objectValue or nullValue
863b2a28edaSopenharmony_ci  /// \post if type() was nullValue, it remains nullValue
864b2a28edaSopenharmony_ci  Members getMemberNames() const;
865b2a28edaSopenharmony_ci
866b2a28edaSopenharmony_ci  //# ifdef JSON_USE_CPPTL
867b2a28edaSopenharmony_ci  //      EnumMemberNames enumMemberNames() const;
868b2a28edaSopenharmony_ci  //      EnumValues enumValues() const;
869b2a28edaSopenharmony_ci  //# endif
870b2a28edaSopenharmony_ci
871b2a28edaSopenharmony_ci  /// \deprecated Always pass len.
872b2a28edaSopenharmony_ci  JSONCPP_DEPRECATED("Use setComment(std::string const&) instead.")
873b2a28edaSopenharmony_ci  void setComment(const char* comment, CommentPlacement placement);
874b2a28edaSopenharmony_ci  /// Comments must be //... or /* ... */
875b2a28edaSopenharmony_ci  void setComment(const char* comment, size_t len, CommentPlacement placement);
876b2a28edaSopenharmony_ci  /// Comments must be //... or /* ... */
877b2a28edaSopenharmony_ci  void setComment(const std::string& comment, CommentPlacement placement);
878b2a28edaSopenharmony_ci  bool hasComment(CommentPlacement placement) const;
879b2a28edaSopenharmony_ci  /// Include delimiters and embedded newlines.
880b2a28edaSopenharmony_ci  std::string getComment(CommentPlacement placement) const;
881b2a28edaSopenharmony_ci
882b2a28edaSopenharmony_ci  std::string toStyledString() const;
883b2a28edaSopenharmony_ci
884b2a28edaSopenharmony_ci  const_iterator begin() const;
885b2a28edaSopenharmony_ci  const_iterator end() const;
886b2a28edaSopenharmony_ci
887b2a28edaSopenharmony_ci  iterator begin();
888b2a28edaSopenharmony_ci  iterator end();
889b2a28edaSopenharmony_ci
890b2a28edaSopenharmony_ci  // Accessors for the [start, limit) range of bytes within the JSON text from
891b2a28edaSopenharmony_ci  // which this value was parsed, if any.
892b2a28edaSopenharmony_ci  void setOffsetStart(size_t start);
893b2a28edaSopenharmony_ci  void setOffsetLimit(size_t limit);
894b2a28edaSopenharmony_ci  size_t getOffsetStart() const;
895b2a28edaSopenharmony_ci  size_t getOffsetLimit() const;
896b2a28edaSopenharmony_ci
897b2a28edaSopenharmony_ciprivate:
898b2a28edaSopenharmony_ci  void initBasic(ValueType type, bool allocated = false);
899b2a28edaSopenharmony_ci
900b2a28edaSopenharmony_ci  Value& resolveReference(const char* key);
901b2a28edaSopenharmony_ci  Value& resolveReference(const char* key, const char* end);
902b2a28edaSopenharmony_ci
903b2a28edaSopenharmony_ci  struct CommentInfo {
904b2a28edaSopenharmony_ci    CommentInfo();
905b2a28edaSopenharmony_ci    ~CommentInfo();
906b2a28edaSopenharmony_ci
907b2a28edaSopenharmony_ci    void setComment(const char* text, size_t len);
908b2a28edaSopenharmony_ci
909b2a28edaSopenharmony_ci    char* comment_;
910b2a28edaSopenharmony_ci  };
911b2a28edaSopenharmony_ci
912b2a28edaSopenharmony_ci  // struct MemberNamesTransform
913b2a28edaSopenharmony_ci  //{
914b2a28edaSopenharmony_ci  //   typedef const char *result_type;
915b2a28edaSopenharmony_ci  //   const char *operator()( const CZString &name ) const
916b2a28edaSopenharmony_ci  //   {
917b2a28edaSopenharmony_ci  //      return name.c_str();
918b2a28edaSopenharmony_ci  //   }
919b2a28edaSopenharmony_ci  //};
920b2a28edaSopenharmony_ci
921b2a28edaSopenharmony_ci  union ValueHolder {
922b2a28edaSopenharmony_ci    LargestInt int_;
923b2a28edaSopenharmony_ci    LargestUInt uint_;
924b2a28edaSopenharmony_ci    double real_;
925b2a28edaSopenharmony_ci    bool bool_;
926b2a28edaSopenharmony_ci    char* string_;  // actually ptr to unsigned, followed by str, unless !allocated_
927b2a28edaSopenharmony_ci    ObjectValues* map_;
928b2a28edaSopenharmony_ci  } value_;
929b2a28edaSopenharmony_ci  ValueType type_ : 8;
930b2a28edaSopenharmony_ci  unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
931b2a28edaSopenharmony_ci                               // If not allocated_, string_ must be null-terminated.
932b2a28edaSopenharmony_ci  CommentInfo* comments_;
933b2a28edaSopenharmony_ci
934b2a28edaSopenharmony_ci  // [start, limit) byte offsets in the source JSON text from which this Value
935b2a28edaSopenharmony_ci  // was extracted.
936b2a28edaSopenharmony_ci  size_t start_;
937b2a28edaSopenharmony_ci  size_t limit_;
938b2a28edaSopenharmony_ci};
939b2a28edaSopenharmony_ci
940b2a28edaSopenharmony_ci/** \brief Experimental and untested: represents an element of the "path" to
941b2a28edaSopenharmony_ci * access a node.
942b2a28edaSopenharmony_ci */
943b2a28edaSopenharmony_ciclass JSON_API PathArgument {
944b2a28edaSopenharmony_cipublic:
945b2a28edaSopenharmony_ci  friend class Path;
946b2a28edaSopenharmony_ci
947b2a28edaSopenharmony_ci  PathArgument();
948b2a28edaSopenharmony_ci  PathArgument(ArrayIndex index);
949b2a28edaSopenharmony_ci  PathArgument(const char* key);
950b2a28edaSopenharmony_ci  PathArgument(const std::string& key);
951b2a28edaSopenharmony_ci
952b2a28edaSopenharmony_ciprivate:
953b2a28edaSopenharmony_ci  enum Kind {
954b2a28edaSopenharmony_ci    kindNone = 0,
955b2a28edaSopenharmony_ci    kindIndex,
956b2a28edaSopenharmony_ci    kindKey
957b2a28edaSopenharmony_ci  };
958b2a28edaSopenharmony_ci  std::string key_;
959b2a28edaSopenharmony_ci  ArrayIndex index_;
960b2a28edaSopenharmony_ci  Kind kind_;
961b2a28edaSopenharmony_ci};
962b2a28edaSopenharmony_ci
963b2a28edaSopenharmony_ci/** \brief Experimental and untested: represents a "path" to access a node.
964b2a28edaSopenharmony_ci *
965b2a28edaSopenharmony_ci * Syntax:
966b2a28edaSopenharmony_ci * - "." => root node
967b2a28edaSopenharmony_ci * - ".[n]" => elements at index 'n' of root node (an array value)
968b2a28edaSopenharmony_ci * - ".name" => member named 'name' of root node (an object value)
969b2a28edaSopenharmony_ci * - ".name1.name2.name3"
970b2a28edaSopenharmony_ci * - ".[0][1][2].name1[3]"
971b2a28edaSopenharmony_ci * - ".%" => member name is provided as parameter
972b2a28edaSopenharmony_ci * - ".[%]" => index is provied as parameter
973b2a28edaSopenharmony_ci */
974b2a28edaSopenharmony_ciclass JSON_API Path {
975b2a28edaSopenharmony_cipublic:
976b2a28edaSopenharmony_ci  Path(const std::string& path,
977b2a28edaSopenharmony_ci       const PathArgument& a1 = PathArgument(),
978b2a28edaSopenharmony_ci       const PathArgument& a2 = PathArgument(),
979b2a28edaSopenharmony_ci       const PathArgument& a3 = PathArgument(),
980b2a28edaSopenharmony_ci       const PathArgument& a4 = PathArgument(),
981b2a28edaSopenharmony_ci       const PathArgument& a5 = PathArgument());
982b2a28edaSopenharmony_ci
983b2a28edaSopenharmony_ci  const Value& resolve(const Value& root) const;
984b2a28edaSopenharmony_ci  Value resolve(const Value& root, const Value& defaultValue) const;
985b2a28edaSopenharmony_ci  /// Creates the "path" to access the specified node and returns a reference on
986b2a28edaSopenharmony_ci  /// the node.
987b2a28edaSopenharmony_ci  Value& make(Value& root) const;
988b2a28edaSopenharmony_ci
989b2a28edaSopenharmony_ciprivate:
990b2a28edaSopenharmony_ci  typedef std::vector<const PathArgument*> InArgs;
991b2a28edaSopenharmony_ci  typedef std::vector<PathArgument> Args;
992b2a28edaSopenharmony_ci
993b2a28edaSopenharmony_ci  void makePath(const std::string& path, const InArgs& in);
994b2a28edaSopenharmony_ci  void addPathInArg(const std::string& path,
995b2a28edaSopenharmony_ci                    const InArgs& in,
996b2a28edaSopenharmony_ci                    InArgs::const_iterator& itInArg,
997b2a28edaSopenharmony_ci                    PathArgument::Kind kind);
998b2a28edaSopenharmony_ci  void invalidPath(const std::string& path, int location);
999b2a28edaSopenharmony_ci
1000b2a28edaSopenharmony_ci  Args args_;
1001b2a28edaSopenharmony_ci};
1002b2a28edaSopenharmony_ci
1003b2a28edaSopenharmony_ci/** \brief base class for Value iterators.
1004b2a28edaSopenharmony_ci *
1005b2a28edaSopenharmony_ci */
1006b2a28edaSopenharmony_ciclass JSON_API ValueIteratorBase {
1007b2a28edaSopenharmony_cipublic:
1008b2a28edaSopenharmony_ci  typedef std::bidirectional_iterator_tag iterator_category;
1009b2a28edaSopenharmony_ci  typedef unsigned int size_t;
1010b2a28edaSopenharmony_ci  typedef int difference_type;
1011b2a28edaSopenharmony_ci  typedef ValueIteratorBase SelfType;
1012b2a28edaSopenharmony_ci
1013b2a28edaSopenharmony_ci  bool operator==(const SelfType& other) const { return isEqual(other); }
1014b2a28edaSopenharmony_ci
1015b2a28edaSopenharmony_ci  bool operator!=(const SelfType& other) const { return !isEqual(other); }
1016b2a28edaSopenharmony_ci
1017b2a28edaSopenharmony_ci  difference_type operator-(const SelfType& other) const {
1018b2a28edaSopenharmony_ci    return other.computeDistance(*this);
1019b2a28edaSopenharmony_ci  }
1020b2a28edaSopenharmony_ci
1021b2a28edaSopenharmony_ci  /// Return either the index or the member name of the referenced value as a
1022b2a28edaSopenharmony_ci  /// Value.
1023b2a28edaSopenharmony_ci  Value key() const;
1024b2a28edaSopenharmony_ci
1025b2a28edaSopenharmony_ci  /// Return the index of the referenced Value, or -1 if it is not an arrayValue.
1026b2a28edaSopenharmony_ci  UInt index() const;
1027b2a28edaSopenharmony_ci
1028b2a28edaSopenharmony_ci  /// Return the member name of the referenced Value, or "" if it is not an
1029b2a28edaSopenharmony_ci  /// objectValue.
1030b2a28edaSopenharmony_ci  /// \note Avoid `c_str()` on result, as embedded zeroes are possible.
1031b2a28edaSopenharmony_ci  std::string name() const;
1032b2a28edaSopenharmony_ci
1033b2a28edaSopenharmony_ci  /// Return the member name of the referenced Value. "" if it is not an
1034b2a28edaSopenharmony_ci  /// objectValue.
1035b2a28edaSopenharmony_ci  /// \deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls.
1036b2a28edaSopenharmony_ci  JSONCPP_DEPRECATED("Use `key = name();` instead.")
1037b2a28edaSopenharmony_ci  char const* memberName() const;
1038b2a28edaSopenharmony_ci  /// Return the member name of the referenced Value, or NULL if it is not an
1039b2a28edaSopenharmony_ci  /// objectValue.
1040b2a28edaSopenharmony_ci  /// \note Better version than memberName(). Allows embedded nulls.
1041b2a28edaSopenharmony_ci  char const* memberName(char const** end) const;
1042b2a28edaSopenharmony_ci
1043b2a28edaSopenharmony_ciprotected:
1044b2a28edaSopenharmony_ci  Value& deref() const;
1045b2a28edaSopenharmony_ci
1046b2a28edaSopenharmony_ci  void increment();
1047b2a28edaSopenharmony_ci
1048b2a28edaSopenharmony_ci  void decrement();
1049b2a28edaSopenharmony_ci
1050b2a28edaSopenharmony_ci  difference_type computeDistance(const SelfType& other) const;
1051b2a28edaSopenharmony_ci
1052b2a28edaSopenharmony_ci  bool isEqual(const SelfType& other) const;
1053b2a28edaSopenharmony_ci
1054b2a28edaSopenharmony_ci  void copy(const SelfType& other);
1055b2a28edaSopenharmony_ci
1056b2a28edaSopenharmony_ciprivate:
1057b2a28edaSopenharmony_ci  Value::ObjectValues::iterator current_;
1058b2a28edaSopenharmony_ci  // Indicates that iterator is for a null value.
1059b2a28edaSopenharmony_ci  bool isNull_;
1060b2a28edaSopenharmony_ci
1061b2a28edaSopenharmony_cipublic:
1062b2a28edaSopenharmony_ci  // For some reason, BORLAND needs these at the end, rather
1063b2a28edaSopenharmony_ci  // than earlier. No idea why.
1064b2a28edaSopenharmony_ci  ValueIteratorBase();
1065b2a28edaSopenharmony_ci  explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
1066b2a28edaSopenharmony_ci};
1067b2a28edaSopenharmony_ci
1068b2a28edaSopenharmony_ci/** \brief const iterator for object and array value.
1069b2a28edaSopenharmony_ci *
1070b2a28edaSopenharmony_ci */
1071b2a28edaSopenharmony_ciclass JSON_API ValueConstIterator : public ValueIteratorBase {
1072b2a28edaSopenharmony_ci  friend class Value;
1073b2a28edaSopenharmony_ci
1074b2a28edaSopenharmony_cipublic:
1075b2a28edaSopenharmony_ci  typedef const Value value_type;
1076b2a28edaSopenharmony_ci  //typedef unsigned int size_t;
1077b2a28edaSopenharmony_ci  //typedef int difference_type;
1078b2a28edaSopenharmony_ci  typedef const Value& reference;
1079b2a28edaSopenharmony_ci  typedef const Value* pointer;
1080b2a28edaSopenharmony_ci  typedef ValueConstIterator SelfType;
1081b2a28edaSopenharmony_ci
1082b2a28edaSopenharmony_ci  ValueConstIterator();
1083b2a28edaSopenharmony_ci
1084b2a28edaSopenharmony_ciprivate:
1085b2a28edaSopenharmony_ci/*! \internal Use by Value to create an iterator.
1086b2a28edaSopenharmony_ci */
1087b2a28edaSopenharmony_ci  explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
1088b2a28edaSopenharmony_cipublic:
1089b2a28edaSopenharmony_ci  SelfType& operator=(const ValueIteratorBase& other);
1090b2a28edaSopenharmony_ci
1091b2a28edaSopenharmony_ci  SelfType operator++(int) {
1092b2a28edaSopenharmony_ci    SelfType temp(*this);
1093b2a28edaSopenharmony_ci    ++*this;
1094b2a28edaSopenharmony_ci    return temp;
1095b2a28edaSopenharmony_ci  }
1096b2a28edaSopenharmony_ci
1097b2a28edaSopenharmony_ci  SelfType operator--(int) {
1098b2a28edaSopenharmony_ci    SelfType temp(*this);
1099b2a28edaSopenharmony_ci    --*this;
1100b2a28edaSopenharmony_ci    return temp;
1101b2a28edaSopenharmony_ci  }
1102b2a28edaSopenharmony_ci
1103b2a28edaSopenharmony_ci  SelfType& operator--() {
1104b2a28edaSopenharmony_ci    decrement();
1105b2a28edaSopenharmony_ci    return *this;
1106b2a28edaSopenharmony_ci  }
1107b2a28edaSopenharmony_ci
1108b2a28edaSopenharmony_ci  SelfType& operator++() {
1109b2a28edaSopenharmony_ci    increment();
1110b2a28edaSopenharmony_ci    return *this;
1111b2a28edaSopenharmony_ci  }
1112b2a28edaSopenharmony_ci
1113b2a28edaSopenharmony_ci  reference operator*() const { return deref(); }
1114b2a28edaSopenharmony_ci
1115b2a28edaSopenharmony_ci  pointer operator->() const { return &deref(); }
1116b2a28edaSopenharmony_ci};
1117b2a28edaSopenharmony_ci
1118b2a28edaSopenharmony_ci/** \brief Iterator for object and array value.
1119b2a28edaSopenharmony_ci */
1120b2a28edaSopenharmony_ciclass JSON_API ValueIterator : public ValueIteratorBase {
1121b2a28edaSopenharmony_ci  friend class Value;
1122b2a28edaSopenharmony_ci
1123b2a28edaSopenharmony_cipublic:
1124b2a28edaSopenharmony_ci  typedef Value value_type;
1125b2a28edaSopenharmony_ci  typedef unsigned int size_t;
1126b2a28edaSopenharmony_ci  typedef int difference_type;
1127b2a28edaSopenharmony_ci  typedef Value& reference;
1128b2a28edaSopenharmony_ci  typedef Value* pointer;
1129b2a28edaSopenharmony_ci  typedef ValueIterator SelfType;
1130b2a28edaSopenharmony_ci
1131b2a28edaSopenharmony_ci  ValueIterator();
1132b2a28edaSopenharmony_ci  ValueIterator(const ValueConstIterator& other);
1133b2a28edaSopenharmony_ci  ValueIterator(const ValueIterator& other);
1134b2a28edaSopenharmony_ci
1135b2a28edaSopenharmony_ciprivate:
1136b2a28edaSopenharmony_ci/*! \internal Use by Value to create an iterator.
1137b2a28edaSopenharmony_ci */
1138b2a28edaSopenharmony_ci  explicit ValueIterator(const Value::ObjectValues::iterator& current);
1139b2a28edaSopenharmony_cipublic:
1140b2a28edaSopenharmony_ci  SelfType& operator=(const SelfType& other);
1141b2a28edaSopenharmony_ci
1142b2a28edaSopenharmony_ci  SelfType operator++(int) {
1143b2a28edaSopenharmony_ci    SelfType temp(*this);
1144b2a28edaSopenharmony_ci    ++*this;
1145b2a28edaSopenharmony_ci    return temp;
1146b2a28edaSopenharmony_ci  }
1147b2a28edaSopenharmony_ci
1148b2a28edaSopenharmony_ci  SelfType operator--(int) {
1149b2a28edaSopenharmony_ci    SelfType temp(*this);
1150b2a28edaSopenharmony_ci    --*this;
1151b2a28edaSopenharmony_ci    return temp;
1152b2a28edaSopenharmony_ci  }
1153b2a28edaSopenharmony_ci
1154b2a28edaSopenharmony_ci  SelfType& operator--() {
1155b2a28edaSopenharmony_ci    decrement();
1156b2a28edaSopenharmony_ci    return *this;
1157b2a28edaSopenharmony_ci  }
1158b2a28edaSopenharmony_ci
1159b2a28edaSopenharmony_ci  SelfType& operator++() {
1160b2a28edaSopenharmony_ci    increment();
1161b2a28edaSopenharmony_ci    return *this;
1162b2a28edaSopenharmony_ci  }
1163b2a28edaSopenharmony_ci
1164b2a28edaSopenharmony_ci  reference operator*() const { return deref(); }
1165b2a28edaSopenharmony_ci
1166b2a28edaSopenharmony_ci  pointer operator->() const { return &deref(); }
1167b2a28edaSopenharmony_ci};
1168b2a28edaSopenharmony_ci
1169b2a28edaSopenharmony_ci} // namespace Json
1170b2a28edaSopenharmony_ci
1171b2a28edaSopenharmony_ci
1172b2a28edaSopenharmony_cinamespace std {
1173b2a28edaSopenharmony_ci/// Specialize std::swap() for Json::Value.
1174b2a28edaSopenharmony_citemplate<>
1175b2a28edaSopenharmony_ciinline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
1176b2a28edaSopenharmony_ci}
1177b2a28edaSopenharmony_ci
1178b2a28edaSopenharmony_ci
1179b2a28edaSopenharmony_ci#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1180b2a28edaSopenharmony_ci#pragma warning(pop)
1181b2a28edaSopenharmony_ci#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1182b2a28edaSopenharmony_ci
1183b2a28edaSopenharmony_ci#endif // CPPTL_JSON_H_INCLUDED
1184b2a28edaSopenharmony_ci
1185b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1186b2a28edaSopenharmony_ci// End of content of file: include/json/value.h
1187b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1188b2a28edaSopenharmony_ci
1189b2a28edaSopenharmony_ci
1190b2a28edaSopenharmony_ci
1191b2a28edaSopenharmony_ci
1192b2a28edaSopenharmony_ci
1193b2a28edaSopenharmony_ci
1194b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1195b2a28edaSopenharmony_ci// Beginning of content of file: include/json/reader.h
1196b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1197b2a28edaSopenharmony_ci
1198b2a28edaSopenharmony_ci// Copyright 2007-2010 Baptiste Lepilleur
1199b2a28edaSopenharmony_ci// Distributed under MIT license, or public domain if desired and
1200b2a28edaSopenharmony_ci// recognized in your jurisdiction.
1201b2a28edaSopenharmony_ci// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
1202b2a28edaSopenharmony_ci
1203b2a28edaSopenharmony_ci#ifndef CPPTL_JSON_READER_H_INCLUDED
1204b2a28edaSopenharmony_ci#define CPPTL_JSON_READER_H_INCLUDED
1205b2a28edaSopenharmony_ci
1206b2a28edaSopenharmony_ci#if !defined(JSON_IS_AMALGAMATION)
1207b2a28edaSopenharmony_ci#include "features.h"
1208b2a28edaSopenharmony_ci#include "value.h"
1209b2a28edaSopenharmony_ci#endif // if !defined(JSON_IS_AMALGAMATION)
1210b2a28edaSopenharmony_ci#include <deque>
1211b2a28edaSopenharmony_ci#include <iosfwd>
1212b2a28edaSopenharmony_ci#include <stack>
1213b2a28edaSopenharmony_ci#include <string>
1214b2a28edaSopenharmony_ci#include <istream>
1215b2a28edaSopenharmony_ci
1216b2a28edaSopenharmony_ci// Disable warning C4251: <data member>: <type> needs to have dll-interface to
1217b2a28edaSopenharmony_ci// be used by...
1218b2a28edaSopenharmony_ci#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1219b2a28edaSopenharmony_ci#pragma warning(push)
1220b2a28edaSopenharmony_ci#pragma warning(disable : 4251)
1221b2a28edaSopenharmony_ci#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1222b2a28edaSopenharmony_ci
1223b2a28edaSopenharmony_cinamespace Json {
1224b2a28edaSopenharmony_ci
1225b2a28edaSopenharmony_ci/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
1226b2a28edaSopenharmony_ci *Value.
1227b2a28edaSopenharmony_ci *
1228b2a28edaSopenharmony_ci * \deprecated Use CharReader and CharReaderBuilder.
1229b2a28edaSopenharmony_ci */
1230b2a28edaSopenharmony_ciclass JSON_API Reader {
1231b2a28edaSopenharmony_cipublic:
1232b2a28edaSopenharmony_ci  typedef char Char;
1233b2a28edaSopenharmony_ci  typedef const Char* Location;
1234b2a28edaSopenharmony_ci
1235b2a28edaSopenharmony_ci  /** \brief An error tagged with where in the JSON text it was encountered.
1236b2a28edaSopenharmony_ci   *
1237b2a28edaSopenharmony_ci   * The offsets give the [start, limit) range of bytes within the text. Note
1238b2a28edaSopenharmony_ci   * that this is bytes, not codepoints.
1239b2a28edaSopenharmony_ci   *
1240b2a28edaSopenharmony_ci   */
1241b2a28edaSopenharmony_ci  struct StructuredError {
1242b2a28edaSopenharmony_ci    size_t offset_start;
1243b2a28edaSopenharmony_ci    size_t offset_limit;
1244b2a28edaSopenharmony_ci    std::string message;
1245b2a28edaSopenharmony_ci  };
1246b2a28edaSopenharmony_ci
1247b2a28edaSopenharmony_ci  /** \brief Constructs a Reader allowing all features
1248b2a28edaSopenharmony_ci   * for parsing.
1249b2a28edaSopenharmony_ci   */
1250b2a28edaSopenharmony_ci  Reader();
1251b2a28edaSopenharmony_ci
1252b2a28edaSopenharmony_ci  /** \brief Constructs a Reader allowing the specified feature set
1253b2a28edaSopenharmony_ci   * for parsing.
1254b2a28edaSopenharmony_ci   */
1255b2a28edaSopenharmony_ci  Reader(const Features& features);
1256b2a28edaSopenharmony_ci
1257b2a28edaSopenharmony_ci  /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
1258b2a28edaSopenharmony_ci   * document.
1259b2a28edaSopenharmony_ci   * \param document UTF-8 encoded string containing the document to read.
1260b2a28edaSopenharmony_ci   * \param root [out] Contains the root value of the document if it was
1261b2a28edaSopenharmony_ci   *             successfully parsed.
1262b2a28edaSopenharmony_ci   * \param collectComments \c true to collect comment and allow writing them
1263b2a28edaSopenharmony_ci   * back during
1264b2a28edaSopenharmony_ci   *                        serialization, \c false to discard comments.
1265b2a28edaSopenharmony_ci   *                        This parameter is ignored if
1266b2a28edaSopenharmony_ci   * Features::allowComments_
1267b2a28edaSopenharmony_ci   *                        is \c false.
1268b2a28edaSopenharmony_ci   * \return \c true if the document was successfully parsed, \c false if an
1269b2a28edaSopenharmony_ci   * error occurred.
1270b2a28edaSopenharmony_ci   */
1271b2a28edaSopenharmony_ci  bool
1272b2a28edaSopenharmony_ci  parse(const std::string& document, Value& root, bool collectComments = true);
1273b2a28edaSopenharmony_ci
1274b2a28edaSopenharmony_ci  /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
1275b2a28edaSopenharmony_ci   document.
1276b2a28edaSopenharmony_ci   * \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
1277b2a28edaSopenharmony_ci   document to read.
1278b2a28edaSopenharmony_ci   * \param endDoc Pointer on the end of the UTF-8 encoded string of the
1279b2a28edaSopenharmony_ci   document to read.
1280b2a28edaSopenharmony_ci   *               Must be >= beginDoc.
1281b2a28edaSopenharmony_ci   * \param root [out] Contains the root value of the document if it was
1282b2a28edaSopenharmony_ci   *             successfully parsed.
1283b2a28edaSopenharmony_ci   * \param collectComments \c true to collect comment and allow writing them
1284b2a28edaSopenharmony_ci   back during
1285b2a28edaSopenharmony_ci   *                        serialization, \c false to discard comments.
1286b2a28edaSopenharmony_ci   *                        This parameter is ignored if
1287b2a28edaSopenharmony_ci   Features::allowComments_
1288b2a28edaSopenharmony_ci   *                        is \c false.
1289b2a28edaSopenharmony_ci   * \return \c true if the document was successfully parsed, \c false if an
1290b2a28edaSopenharmony_ci   error occurred.
1291b2a28edaSopenharmony_ci   */
1292b2a28edaSopenharmony_ci  bool parse(const char* beginDoc,
1293b2a28edaSopenharmony_ci             const char* endDoc,
1294b2a28edaSopenharmony_ci             Value& root,
1295b2a28edaSopenharmony_ci             bool collectComments = true);
1296b2a28edaSopenharmony_ci
1297b2a28edaSopenharmony_ci  /// \brief Parse from input stream.
1298b2a28edaSopenharmony_ci  /// \see Json::operator>>(std::istream&, Json::Value&).
1299b2a28edaSopenharmony_ci  bool parse(std::istream& is, Value& root, bool collectComments = true);
1300b2a28edaSopenharmony_ci
1301b2a28edaSopenharmony_ci  /** \brief Returns a user friendly string that list errors in the parsed
1302b2a28edaSopenharmony_ci   * document.
1303b2a28edaSopenharmony_ci   * \return Formatted error message with the list of errors with their location
1304b2a28edaSopenharmony_ci   * in
1305b2a28edaSopenharmony_ci   *         the parsed document. An empty string is returned if no error
1306b2a28edaSopenharmony_ci   * occurred
1307b2a28edaSopenharmony_ci   *         during parsing.
1308b2a28edaSopenharmony_ci   * \deprecated Use getFormattedErrorMessages() instead (typo fix).
1309b2a28edaSopenharmony_ci   */
1310b2a28edaSopenharmony_ci  JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
1311b2a28edaSopenharmony_ci  std::string getFormatedErrorMessages() const;
1312b2a28edaSopenharmony_ci
1313b2a28edaSopenharmony_ci  /** \brief Returns a user friendly string that list errors in the parsed
1314b2a28edaSopenharmony_ci   * document.
1315b2a28edaSopenharmony_ci   * \return Formatted error message with the list of errors with their location
1316b2a28edaSopenharmony_ci   * in
1317b2a28edaSopenharmony_ci   *         the parsed document. An empty string is returned if no error
1318b2a28edaSopenharmony_ci   * occurred
1319b2a28edaSopenharmony_ci   *         during parsing.
1320b2a28edaSopenharmony_ci   */
1321b2a28edaSopenharmony_ci  std::string getFormattedErrorMessages() const;
1322b2a28edaSopenharmony_ci
1323b2a28edaSopenharmony_ci  /** \brief Returns a vector of structured erros encounted while parsing.
1324b2a28edaSopenharmony_ci   * \return A (possibly empty) vector of StructuredError objects. Currently
1325b2a28edaSopenharmony_ci   *         only one error can be returned, but the caller should tolerate
1326b2a28edaSopenharmony_ci   * multiple
1327b2a28edaSopenharmony_ci   *         errors.  This can occur if the parser recovers from a non-fatal
1328b2a28edaSopenharmony_ci   *         parse error and then encounters additional errors.
1329b2a28edaSopenharmony_ci   */
1330b2a28edaSopenharmony_ci  std::vector<StructuredError> getStructuredErrors() const;
1331b2a28edaSopenharmony_ci
1332b2a28edaSopenharmony_ci  /** \brief Add a semantic error message.
1333b2a28edaSopenharmony_ci   * \param value JSON Value location associated with the error
1334b2a28edaSopenharmony_ci   * \param message The error message.
1335b2a28edaSopenharmony_ci   * \return \c true if the error was successfully added, \c false if the
1336b2a28edaSopenharmony_ci   * Value offset exceeds the document size.
1337b2a28edaSopenharmony_ci   */
1338b2a28edaSopenharmony_ci  bool pushError(const Value& value, const std::string& message);
1339b2a28edaSopenharmony_ci
1340b2a28edaSopenharmony_ci  /** \brief Add a semantic error message with extra context.
1341b2a28edaSopenharmony_ci   * \param value JSON Value location associated with the error
1342b2a28edaSopenharmony_ci   * \param message The error message.
1343b2a28edaSopenharmony_ci   * \param extra Additional JSON Value location to contextualize the error
1344b2a28edaSopenharmony_ci   * \return \c true if the error was successfully added, \c false if either
1345b2a28edaSopenharmony_ci   * Value offset exceeds the document size.
1346b2a28edaSopenharmony_ci   */
1347b2a28edaSopenharmony_ci  bool pushError(const Value& value, const std::string& message, const Value& extra);
1348b2a28edaSopenharmony_ci
1349b2a28edaSopenharmony_ci  /** \brief Return whether there are any errors.
1350b2a28edaSopenharmony_ci   * \return \c true if there are no errors to report \c false if
1351b2a28edaSopenharmony_ci   * errors have occurred.
1352b2a28edaSopenharmony_ci   */
1353b2a28edaSopenharmony_ci  bool good() const;
1354b2a28edaSopenharmony_ci
1355b2a28edaSopenharmony_ciprivate:
1356b2a28edaSopenharmony_ci  enum TokenType {
1357b2a28edaSopenharmony_ci    tokenEndOfStream = 0,
1358b2a28edaSopenharmony_ci    tokenObjectBegin,
1359b2a28edaSopenharmony_ci    tokenObjectEnd,
1360b2a28edaSopenharmony_ci    tokenArrayBegin,
1361b2a28edaSopenharmony_ci    tokenArrayEnd,
1362b2a28edaSopenharmony_ci    tokenString,
1363b2a28edaSopenharmony_ci    tokenNumber,
1364b2a28edaSopenharmony_ci    tokenTrue,
1365b2a28edaSopenharmony_ci    tokenFalse,
1366b2a28edaSopenharmony_ci    tokenNull,
1367b2a28edaSopenharmony_ci    tokenArraySeparator,
1368b2a28edaSopenharmony_ci    tokenMemberSeparator,
1369b2a28edaSopenharmony_ci    tokenComment,
1370b2a28edaSopenharmony_ci    tokenError
1371b2a28edaSopenharmony_ci  };
1372b2a28edaSopenharmony_ci
1373b2a28edaSopenharmony_ci  class Token {
1374b2a28edaSopenharmony_ci  public:
1375b2a28edaSopenharmony_ci    TokenType type_;
1376b2a28edaSopenharmony_ci    Location start_;
1377b2a28edaSopenharmony_ci    Location end_;
1378b2a28edaSopenharmony_ci  };
1379b2a28edaSopenharmony_ci
1380b2a28edaSopenharmony_ci  class ErrorInfo {
1381b2a28edaSopenharmony_ci  public:
1382b2a28edaSopenharmony_ci    Token token_;
1383b2a28edaSopenharmony_ci    std::string message_;
1384b2a28edaSopenharmony_ci    Location extra_;
1385b2a28edaSopenharmony_ci  };
1386b2a28edaSopenharmony_ci
1387b2a28edaSopenharmony_ci  typedef std::deque<ErrorInfo> Errors;
1388b2a28edaSopenharmony_ci
1389b2a28edaSopenharmony_ci  bool readToken(Token& token);
1390b2a28edaSopenharmony_ci  void skipSpaces();
1391b2a28edaSopenharmony_ci  bool match(Location pattern, int patternLength);
1392b2a28edaSopenharmony_ci  bool readComment();
1393b2a28edaSopenharmony_ci  bool readCStyleComment();
1394b2a28edaSopenharmony_ci  bool readCppStyleComment();
1395b2a28edaSopenharmony_ci  bool readString();
1396b2a28edaSopenharmony_ci  void readNumber();
1397b2a28edaSopenharmony_ci  bool readValue();
1398b2a28edaSopenharmony_ci  bool readObject(Token& token);
1399b2a28edaSopenharmony_ci  bool readArray(Token& token);
1400b2a28edaSopenharmony_ci  bool decodeNumber(Token& token);
1401b2a28edaSopenharmony_ci  bool decodeNumber(Token& token, Value& decoded);
1402b2a28edaSopenharmony_ci  bool decodeString(Token& token);
1403b2a28edaSopenharmony_ci  bool decodeString(Token& token, std::string& decoded);
1404b2a28edaSopenharmony_ci  bool decodeDouble(Token& token);
1405b2a28edaSopenharmony_ci  bool decodeDouble(Token& token, Value& decoded);
1406b2a28edaSopenharmony_ci  bool decodeUnicodeCodePoint(Token& token,
1407b2a28edaSopenharmony_ci                              Location& current,
1408b2a28edaSopenharmony_ci                              Location end,
1409b2a28edaSopenharmony_ci                              unsigned int& unicode);
1410b2a28edaSopenharmony_ci  bool decodeUnicodeEscapeSequence(Token& token,
1411b2a28edaSopenharmony_ci                                   Location& current,
1412b2a28edaSopenharmony_ci                                   Location end,
1413b2a28edaSopenharmony_ci                                   unsigned int& unicode);
1414b2a28edaSopenharmony_ci  bool addError(const std::string& message, Token& token, Location extra = 0);
1415b2a28edaSopenharmony_ci  bool recoverFromError(TokenType skipUntilToken);
1416b2a28edaSopenharmony_ci  bool addErrorAndRecover(const std::string& message,
1417b2a28edaSopenharmony_ci                          Token& token,
1418b2a28edaSopenharmony_ci                          TokenType skipUntilToken);
1419b2a28edaSopenharmony_ci  void skipUntilSpace();
1420b2a28edaSopenharmony_ci  Value& currentValue();
1421b2a28edaSopenharmony_ci  Char getNextChar();
1422b2a28edaSopenharmony_ci  void
1423b2a28edaSopenharmony_ci  getLocationLineAndColumn(Location location, int& line, int& column) const;
1424b2a28edaSopenharmony_ci  std::string getLocationLineAndColumn(Location location) const;
1425b2a28edaSopenharmony_ci  void addComment(Location begin, Location end, CommentPlacement placement);
1426b2a28edaSopenharmony_ci  void skipCommentTokens(Token& token);
1427b2a28edaSopenharmony_ci
1428b2a28edaSopenharmony_ci  typedef std::stack<Value*> Nodes;
1429b2a28edaSopenharmony_ci  Nodes nodes_;
1430b2a28edaSopenharmony_ci  Errors errors_;
1431b2a28edaSopenharmony_ci  std::string document_;
1432b2a28edaSopenharmony_ci  Location begin_;
1433b2a28edaSopenharmony_ci  Location end_;
1434b2a28edaSopenharmony_ci  Location current_;
1435b2a28edaSopenharmony_ci  Location lastValueEnd_;
1436b2a28edaSopenharmony_ci  Value* lastValue_;
1437b2a28edaSopenharmony_ci  std::string commentsBefore_;
1438b2a28edaSopenharmony_ci  Features features_;
1439b2a28edaSopenharmony_ci  bool collectComments_;
1440b2a28edaSopenharmony_ci};  // Reader
1441b2a28edaSopenharmony_ci
1442b2a28edaSopenharmony_ci/** Interface for reading JSON from a char array.
1443b2a28edaSopenharmony_ci */
1444b2a28edaSopenharmony_ciclass JSON_API CharReader {
1445b2a28edaSopenharmony_cipublic:
1446b2a28edaSopenharmony_ci  virtual ~CharReader() {}
1447b2a28edaSopenharmony_ci  /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
1448b2a28edaSopenharmony_ci   document.
1449b2a28edaSopenharmony_ci   * The document must be a UTF-8 encoded string containing the document to read.
1450b2a28edaSopenharmony_ci   *
1451b2a28edaSopenharmony_ci   * \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
1452b2a28edaSopenharmony_ci   document to read.
1453b2a28edaSopenharmony_ci   * \param endDoc Pointer on the end of the UTF-8 encoded string of the
1454b2a28edaSopenharmony_ci   document to read.
1455b2a28edaSopenharmony_ci   *        Must be >= beginDoc.
1456b2a28edaSopenharmony_ci   * \param root [out] Contains the root value of the document if it was
1457b2a28edaSopenharmony_ci   *             successfully parsed.
1458b2a28edaSopenharmony_ci   * \param errs [out] Formatted error messages (if not NULL)
1459b2a28edaSopenharmony_ci   *        a user friendly string that lists errors in the parsed
1460b2a28edaSopenharmony_ci   * document.
1461b2a28edaSopenharmony_ci   * \return \c true if the document was successfully parsed, \c false if an
1462b2a28edaSopenharmony_ci   error occurred.
1463b2a28edaSopenharmony_ci   */
1464b2a28edaSopenharmony_ci  virtual bool parse(
1465b2a28edaSopenharmony_ci      char const* beginDoc, char const* endDoc,
1466b2a28edaSopenharmony_ci      Value* root, std::string* errs) = 0;
1467b2a28edaSopenharmony_ci
1468b2a28edaSopenharmony_ci  class Factory {
1469b2a28edaSopenharmony_ci  public:
1470b2a28edaSopenharmony_ci    virtual ~Factory() {}
1471b2a28edaSopenharmony_ci    /** \brief Allocate a CharReader via operator new().
1472b2a28edaSopenharmony_ci     * \throw std::exception if something goes wrong (e.g. invalid settings)
1473b2a28edaSopenharmony_ci     */
1474b2a28edaSopenharmony_ci    virtual CharReader* newCharReader() const = 0;
1475b2a28edaSopenharmony_ci  };  // Factory
1476b2a28edaSopenharmony_ci};  // CharReader
1477b2a28edaSopenharmony_ci
1478b2a28edaSopenharmony_ci/** \brief Build a CharReader implementation.
1479b2a28edaSopenharmony_ci
1480b2a28edaSopenharmony_ciUsage:
1481b2a28edaSopenharmony_ci\code
1482b2a28edaSopenharmony_ci  using namespace Json;
1483b2a28edaSopenharmony_ci  CharReaderBuilder builder;
1484b2a28edaSopenharmony_ci  builder["collectComments"] = false;
1485b2a28edaSopenharmony_ci  Value value;
1486b2a28edaSopenharmony_ci  std::string errs;
1487b2a28edaSopenharmony_ci  bool ok = parseFromStream(builder, std::cin, &value, &errs);
1488b2a28edaSopenharmony_ci\endcode
1489b2a28edaSopenharmony_ci*/
1490b2a28edaSopenharmony_ciclass JSON_API CharReaderBuilder : public CharReader::Factory {
1491b2a28edaSopenharmony_cipublic:
1492b2a28edaSopenharmony_ci  // Note: We use a Json::Value so that we can add data-members to this class
1493b2a28edaSopenharmony_ci  // without a major version bump.
1494b2a28edaSopenharmony_ci  /** Configuration of this builder.
1495b2a28edaSopenharmony_ci    These are case-sensitive.
1496b2a28edaSopenharmony_ci    Available settings (case-sensitive):
1497b2a28edaSopenharmony_ci    - `"collectComments": false or true`
1498b2a28edaSopenharmony_ci      - true to collect comment and allow writing them
1499b2a28edaSopenharmony_ci        back during serialization, false to discard comments.
1500b2a28edaSopenharmony_ci        This parameter is ignored if allowComments is false.
1501b2a28edaSopenharmony_ci    - `"allowComments": false or true`
1502b2a28edaSopenharmony_ci      - true if comments are allowed.
1503b2a28edaSopenharmony_ci    - `"strictRoot": false or true`
1504b2a28edaSopenharmony_ci      - true if root must be either an array or an object value
1505b2a28edaSopenharmony_ci    - `"allowDroppedNullPlaceholders": false or true`
1506b2a28edaSopenharmony_ci      - true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
1507b2a28edaSopenharmony_ci    - `"allowNumericKeys": false or true`
1508b2a28edaSopenharmony_ci      - true if numeric object keys are allowed.
1509b2a28edaSopenharmony_ci    - `"allowSingleQuotes": false or true`
1510b2a28edaSopenharmony_ci      - true if '' are allowed for strings (both keys and values)
1511b2a28edaSopenharmony_ci    - `"stackLimit": integer`
1512b2a28edaSopenharmony_ci      - Exceeding stackLimit (recursive depth of `readValue()`) will
1513b2a28edaSopenharmony_ci        cause an exception.
1514b2a28edaSopenharmony_ci      - This is a security issue (seg-faults caused by deeply nested JSON),
1515b2a28edaSopenharmony_ci        so the default is low.
1516b2a28edaSopenharmony_ci    - `"failIfExtra": false or true`
1517b2a28edaSopenharmony_ci      - If true, `parse()` returns false when extra non-whitespace trails
1518b2a28edaSopenharmony_ci        the JSON value in the input string.
1519b2a28edaSopenharmony_ci    - `"rejectDupKeys": false or true`
1520b2a28edaSopenharmony_ci      - If true, `parse()` returns false when a key is duplicated within an object.
1521b2a28edaSopenharmony_ci
1522b2a28edaSopenharmony_ci    You can examine 'settings_` yourself
1523b2a28edaSopenharmony_ci    to see the defaults. You can also write and read them just like any
1524b2a28edaSopenharmony_ci    JSON Value.
1525b2a28edaSopenharmony_ci    \sa setDefaults()
1526b2a28edaSopenharmony_ci    */
1527b2a28edaSopenharmony_ci  Json::Value settings_;
1528b2a28edaSopenharmony_ci
1529b2a28edaSopenharmony_ci  CharReaderBuilder();
1530b2a28edaSopenharmony_ci  virtual ~CharReaderBuilder();
1531b2a28edaSopenharmony_ci
1532b2a28edaSopenharmony_ci  virtual CharReader* newCharReader() const;
1533b2a28edaSopenharmony_ci
1534b2a28edaSopenharmony_ci  /** \return true if 'settings' are legal and consistent;
1535b2a28edaSopenharmony_ci   *   otherwise, indicate bad settings via 'invalid'.
1536b2a28edaSopenharmony_ci   */
1537b2a28edaSopenharmony_ci  bool validate(Json::Value* invalid) const;
1538b2a28edaSopenharmony_ci
1539b2a28edaSopenharmony_ci  /** A simple way to update a specific setting.
1540b2a28edaSopenharmony_ci   */
1541b2a28edaSopenharmony_ci  Value& operator[](std::string key);
1542b2a28edaSopenharmony_ci
1543b2a28edaSopenharmony_ci  /** Called by ctor, but you can use this to reset settings_.
1544b2a28edaSopenharmony_ci   * \pre 'settings' != NULL (but Json::null is fine)
1545b2a28edaSopenharmony_ci   * \remark Defaults:
1546b2a28edaSopenharmony_ci   * \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
1547b2a28edaSopenharmony_ci   */
1548b2a28edaSopenharmony_ci  static void setDefaults(Json::Value* settings);
1549b2a28edaSopenharmony_ci  /** Same as old Features::strictMode().
1550b2a28edaSopenharmony_ci   * \pre 'settings' != NULL (but Json::null is fine)
1551b2a28edaSopenharmony_ci   * \remark Defaults:
1552b2a28edaSopenharmony_ci   * \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
1553b2a28edaSopenharmony_ci   */
1554b2a28edaSopenharmony_ci  static void strictMode(Json::Value* settings);
1555b2a28edaSopenharmony_ci};
1556b2a28edaSopenharmony_ci
1557b2a28edaSopenharmony_ci/** Consume entire stream and use its begin/end.
1558b2a28edaSopenharmony_ci  * Someday we might have a real StreamReader, but for now this
1559b2a28edaSopenharmony_ci  * is convenient.
1560b2a28edaSopenharmony_ci  */
1561b2a28edaSopenharmony_cibool JSON_API parseFromStream(
1562b2a28edaSopenharmony_ci    CharReader::Factory const&,
1563b2a28edaSopenharmony_ci    std::istream&,
1564b2a28edaSopenharmony_ci    Value* root, std::string* errs);
1565b2a28edaSopenharmony_ci
1566b2a28edaSopenharmony_ci/** \brief Read from 'sin' into 'root'.
1567b2a28edaSopenharmony_ci
1568b2a28edaSopenharmony_ci Always keep comments from the input JSON.
1569b2a28edaSopenharmony_ci
1570b2a28edaSopenharmony_ci This can be used to read a file into a particular sub-object.
1571b2a28edaSopenharmony_ci For example:
1572b2a28edaSopenharmony_ci \code
1573b2a28edaSopenharmony_ci Json::Value root;
1574b2a28edaSopenharmony_ci cin >> root["dir"]["file"];
1575b2a28edaSopenharmony_ci cout << root;
1576b2a28edaSopenharmony_ci \endcode
1577b2a28edaSopenharmony_ci Result:
1578b2a28edaSopenharmony_ci \verbatim
1579b2a28edaSopenharmony_ci {
1580b2a28edaSopenharmony_ci "dir": {
1581b2a28edaSopenharmony_ci     "file": {
1582b2a28edaSopenharmony_ci     // The input stream JSON would be nested here.
1583b2a28edaSopenharmony_ci     }
1584b2a28edaSopenharmony_ci }
1585b2a28edaSopenharmony_ci }
1586b2a28edaSopenharmony_ci \endverbatim
1587b2a28edaSopenharmony_ci \throw std::exception on parse error.
1588b2a28edaSopenharmony_ci \see Json::operator<<()
1589b2a28edaSopenharmony_ci*/
1590b2a28edaSopenharmony_ciJSON_API std::istream& operator>>(std::istream&, Value&);
1591b2a28edaSopenharmony_ci
1592b2a28edaSopenharmony_ci} // namespace Json
1593b2a28edaSopenharmony_ci
1594b2a28edaSopenharmony_ci#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1595b2a28edaSopenharmony_ci#pragma warning(pop)
1596b2a28edaSopenharmony_ci#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1597b2a28edaSopenharmony_ci
1598b2a28edaSopenharmony_ci#endif // CPPTL_JSON_READER_H_INCLUDED
1599b2a28edaSopenharmony_ci
1600b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1601b2a28edaSopenharmony_ci// End of content of file: include/json/reader.h
1602b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1603b2a28edaSopenharmony_ci
1604b2a28edaSopenharmony_ci
1605b2a28edaSopenharmony_ci
1606b2a28edaSopenharmony_ci
1607b2a28edaSopenharmony_ci
1608b2a28edaSopenharmony_ci
1609b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1610b2a28edaSopenharmony_ci// Beginning of content of file: include/json/writer.h
1611b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1612b2a28edaSopenharmony_ci
1613b2a28edaSopenharmony_ci// Copyright 2007-2010 Baptiste Lepilleur
1614b2a28edaSopenharmony_ci// Distributed under MIT license, or public domain if desired and
1615b2a28edaSopenharmony_ci// recognized in your jurisdiction.
1616b2a28edaSopenharmony_ci// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
1617b2a28edaSopenharmony_ci
1618b2a28edaSopenharmony_ci#ifndef JSON_WRITER_H_INCLUDED
1619b2a28edaSopenharmony_ci#define JSON_WRITER_H_INCLUDED
1620b2a28edaSopenharmony_ci
1621b2a28edaSopenharmony_ci#if !defined(JSON_IS_AMALGAMATION)
1622b2a28edaSopenharmony_ci#include "value.h"
1623b2a28edaSopenharmony_ci#endif // if !defined(JSON_IS_AMALGAMATION)
1624b2a28edaSopenharmony_ci#include <vector>
1625b2a28edaSopenharmony_ci#include <string>
1626b2a28edaSopenharmony_ci#include <ostream>
1627b2a28edaSopenharmony_ci
1628b2a28edaSopenharmony_ci// Disable warning C4251: <data member>: <type> needs to have dll-interface to
1629b2a28edaSopenharmony_ci// be used by...
1630b2a28edaSopenharmony_ci#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1631b2a28edaSopenharmony_ci#pragma warning(push)
1632b2a28edaSopenharmony_ci#pragma warning(disable : 4251)
1633b2a28edaSopenharmony_ci#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1634b2a28edaSopenharmony_ci
1635b2a28edaSopenharmony_cinamespace Json {
1636b2a28edaSopenharmony_ci
1637b2a28edaSopenharmony_ciclass Value;
1638b2a28edaSopenharmony_ci
1639b2a28edaSopenharmony_ci/**
1640b2a28edaSopenharmony_ci
1641b2a28edaSopenharmony_ciUsage:
1642b2a28edaSopenharmony_ci\code
1643b2a28edaSopenharmony_ci  using namespace Json;
1644b2a28edaSopenharmony_ci  void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {
1645b2a28edaSopenharmony_ci    std::unique_ptr<StreamWriter> const writer(
1646b2a28edaSopenharmony_ci      factory.newStreamWriter());
1647b2a28edaSopenharmony_ci    writer->write(value, &std::cout);
1648b2a28edaSopenharmony_ci    std::cout << std::endl;  // add lf and flush
1649b2a28edaSopenharmony_ci  }
1650b2a28edaSopenharmony_ci\endcode
1651b2a28edaSopenharmony_ci*/
1652b2a28edaSopenharmony_ciclass JSON_API StreamWriter {
1653b2a28edaSopenharmony_ciprotected:
1654b2a28edaSopenharmony_ci  std::ostream* sout_;  // not owned; will not delete
1655b2a28edaSopenharmony_cipublic:
1656b2a28edaSopenharmony_ci  StreamWriter();
1657b2a28edaSopenharmony_ci  virtual ~StreamWriter();
1658b2a28edaSopenharmony_ci  /** Write Value into document as configured in sub-class.
1659b2a28edaSopenharmony_ci      Do not take ownership of sout, but maintain a reference during function.
1660b2a28edaSopenharmony_ci      \pre sout != NULL
1661b2a28edaSopenharmony_ci      \return zero on success (For now, we always return zero, so check the stream instead.)
1662b2a28edaSopenharmony_ci      \throw std::exception possibly, depending on configuration
1663b2a28edaSopenharmony_ci   */
1664b2a28edaSopenharmony_ci  virtual int write(Value const& root, std::ostream* sout) = 0;
1665b2a28edaSopenharmony_ci
1666b2a28edaSopenharmony_ci  /** \brief A simple abstract factory.
1667b2a28edaSopenharmony_ci   */
1668b2a28edaSopenharmony_ci  class JSON_API Factory {
1669b2a28edaSopenharmony_ci  public:
1670b2a28edaSopenharmony_ci    virtual ~Factory();
1671b2a28edaSopenharmony_ci    /** \brief Allocate a CharReader via operator new().
1672b2a28edaSopenharmony_ci     * \throw std::exception if something goes wrong (e.g. invalid settings)
1673b2a28edaSopenharmony_ci     */
1674b2a28edaSopenharmony_ci    virtual StreamWriter* newStreamWriter() const = 0;
1675b2a28edaSopenharmony_ci  };  // Factory
1676b2a28edaSopenharmony_ci};  // StreamWriter
1677b2a28edaSopenharmony_ci
1678b2a28edaSopenharmony_ci/** \brief Write into stringstream, then return string, for convenience.
1679b2a28edaSopenharmony_ci * A StreamWriter will be created from the factory, used, and then deleted.
1680b2a28edaSopenharmony_ci */
1681b2a28edaSopenharmony_cistd::string JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
1682b2a28edaSopenharmony_ci
1683b2a28edaSopenharmony_ci
1684b2a28edaSopenharmony_ci/** \brief Build a StreamWriter implementation.
1685b2a28edaSopenharmony_ci
1686b2a28edaSopenharmony_ciUsage:
1687b2a28edaSopenharmony_ci\code
1688b2a28edaSopenharmony_ci  using namespace Json;
1689b2a28edaSopenharmony_ci  Value value = ...;
1690b2a28edaSopenharmony_ci  StreamWriterBuilder builder;
1691b2a28edaSopenharmony_ci  builder["commentStyle"] = "None";
1692b2a28edaSopenharmony_ci  builder["indentation"] = "   ";  // or whatever you like
1693b2a28edaSopenharmony_ci  std::unique_ptr<Json::StreamWriter> writer(
1694b2a28edaSopenharmony_ci      builder.newStreamWriter());
1695b2a28edaSopenharmony_ci  writer->write(value, &std::cout);
1696b2a28edaSopenharmony_ci  std::cout << std::endl;  // add lf and flush
1697b2a28edaSopenharmony_ci\endcode
1698b2a28edaSopenharmony_ci*/
1699b2a28edaSopenharmony_ciclass JSON_API StreamWriterBuilder : public StreamWriter::Factory {
1700b2a28edaSopenharmony_cipublic:
1701b2a28edaSopenharmony_ci  // Note: We use a Json::Value so that we can add data-members to this class
1702b2a28edaSopenharmony_ci  // without a major version bump.
1703b2a28edaSopenharmony_ci  /** Configuration of this builder.
1704b2a28edaSopenharmony_ci    Available settings (case-sensitive):
1705b2a28edaSopenharmony_ci    - "commentStyle": "None" or "All"
1706b2a28edaSopenharmony_ci    - "indentation":  "<anything>"
1707b2a28edaSopenharmony_ci    - "enableYAMLCompatibility": false or true
1708b2a28edaSopenharmony_ci      - slightly change the whitespace around colons
1709b2a28edaSopenharmony_ci    - "dropNullPlaceholders": false or true
1710b2a28edaSopenharmony_ci      - Drop the "null" string from the writer's output for nullValues.
1711b2a28edaSopenharmony_ci        Strictly speaking, this is not valid JSON. But when the output is being
1712b2a28edaSopenharmony_ci        fed to a browser's Javascript, it makes for smaller output and the
1713b2a28edaSopenharmony_ci        browser can handle the output just fine.
1714b2a28edaSopenharmony_ci
1715b2a28edaSopenharmony_ci    You can examine 'settings_` yourself
1716b2a28edaSopenharmony_ci    to see the defaults. You can also write and read them just like any
1717b2a28edaSopenharmony_ci    JSON Value.
1718b2a28edaSopenharmony_ci    \sa setDefaults()
1719b2a28edaSopenharmony_ci    */
1720b2a28edaSopenharmony_ci  Json::Value settings_;
1721b2a28edaSopenharmony_ci
1722b2a28edaSopenharmony_ci  StreamWriterBuilder();
1723b2a28edaSopenharmony_ci  virtual ~StreamWriterBuilder();
1724b2a28edaSopenharmony_ci
1725b2a28edaSopenharmony_ci  /**
1726b2a28edaSopenharmony_ci   * \throw std::exception if something goes wrong (e.g. invalid settings)
1727b2a28edaSopenharmony_ci   */
1728b2a28edaSopenharmony_ci  virtual StreamWriter* newStreamWriter() const;
1729b2a28edaSopenharmony_ci
1730b2a28edaSopenharmony_ci  /** \return true if 'settings' are legal and consistent;
1731b2a28edaSopenharmony_ci   *   otherwise, indicate bad settings via 'invalid'.
1732b2a28edaSopenharmony_ci   */
1733b2a28edaSopenharmony_ci  bool validate(Json::Value* invalid) const;
1734b2a28edaSopenharmony_ci  /** A simple way to update a specific setting.
1735b2a28edaSopenharmony_ci   */
1736b2a28edaSopenharmony_ci  Value& operator[](std::string key);
1737b2a28edaSopenharmony_ci
1738b2a28edaSopenharmony_ci  /** Called by ctor, but you can use this to reset settings_.
1739b2a28edaSopenharmony_ci   * \pre 'settings' != NULL (but Json::null is fine)
1740b2a28edaSopenharmony_ci   * \remark Defaults:
1741b2a28edaSopenharmony_ci   * \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
1742b2a28edaSopenharmony_ci   */
1743b2a28edaSopenharmony_ci  static void setDefaults(Json::Value* settings);
1744b2a28edaSopenharmony_ci};
1745b2a28edaSopenharmony_ci
1746b2a28edaSopenharmony_ci/** \brief Abstract class for writers.
1747b2a28edaSopenharmony_ci * \deprecated Use StreamWriter. (And really, this is an implementation detail.)
1748b2a28edaSopenharmony_ci */
1749b2a28edaSopenharmony_ciclass JSON_API Writer {
1750b2a28edaSopenharmony_cipublic:
1751b2a28edaSopenharmony_ci  virtual ~Writer();
1752b2a28edaSopenharmony_ci
1753b2a28edaSopenharmony_ci  virtual std::string write(const Value& root) = 0;
1754b2a28edaSopenharmony_ci};
1755b2a28edaSopenharmony_ci
1756b2a28edaSopenharmony_ci/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
1757b2a28edaSopenharmony_ci *without formatting (not human friendly).
1758b2a28edaSopenharmony_ci *
1759b2a28edaSopenharmony_ci * The JSON document is written in a single line. It is not intended for 'human'
1760b2a28edaSopenharmony_ci *consumption,
1761b2a28edaSopenharmony_ci * but may be usefull to support feature such as RPC where bandwith is limited.
1762b2a28edaSopenharmony_ci * \sa Reader, Value
1763b2a28edaSopenharmony_ci * \deprecated Use StreamWriterBuilder.
1764b2a28edaSopenharmony_ci */
1765b2a28edaSopenharmony_ciclass JSON_API FastWriter : public Writer {
1766b2a28edaSopenharmony_ci
1767b2a28edaSopenharmony_cipublic:
1768b2a28edaSopenharmony_ci  FastWriter();
1769b2a28edaSopenharmony_ci  virtual ~FastWriter() {}
1770b2a28edaSopenharmony_ci
1771b2a28edaSopenharmony_ci  void enableYAMLCompatibility();
1772b2a28edaSopenharmony_ci
1773b2a28edaSopenharmony_ci  /** \brief Drop the "null" string from the writer's output for nullValues.
1774b2a28edaSopenharmony_ci   * Strictly speaking, this is not valid JSON. But when the output is being
1775b2a28edaSopenharmony_ci   * fed to a browser's Javascript, it makes for smaller output and the
1776b2a28edaSopenharmony_ci   * browser can handle the output just fine.
1777b2a28edaSopenharmony_ci   */
1778b2a28edaSopenharmony_ci  void dropNullPlaceholders();
1779b2a28edaSopenharmony_ci
1780b2a28edaSopenharmony_ci  void omitEndingLineFeed();
1781b2a28edaSopenharmony_ci
1782b2a28edaSopenharmony_cipublic: // overridden from Writer
1783b2a28edaSopenharmony_ci  virtual std::string write(const Value& root);
1784b2a28edaSopenharmony_ci
1785b2a28edaSopenharmony_ciprivate:
1786b2a28edaSopenharmony_ci  void writeValue(const Value& value);
1787b2a28edaSopenharmony_ci
1788b2a28edaSopenharmony_ci  std::string document_;
1789b2a28edaSopenharmony_ci  bool yamlCompatiblityEnabled_;
1790b2a28edaSopenharmony_ci  bool dropNullPlaceholders_;
1791b2a28edaSopenharmony_ci  bool omitEndingLineFeed_;
1792b2a28edaSopenharmony_ci};
1793b2a28edaSopenharmony_ci
1794b2a28edaSopenharmony_ci/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
1795b2a28edaSopenharmony_ci *human friendly way.
1796b2a28edaSopenharmony_ci *
1797b2a28edaSopenharmony_ci * The rules for line break and indent are as follow:
1798b2a28edaSopenharmony_ci * - Object value:
1799b2a28edaSopenharmony_ci *     - if empty then print {} without indent and line break
1800b2a28edaSopenharmony_ci *     - if not empty the print '{', line break & indent, print one value per
1801b2a28edaSopenharmony_ci *line
1802b2a28edaSopenharmony_ci *       and then unindent and line break and print '}'.
1803b2a28edaSopenharmony_ci * - Array value:
1804b2a28edaSopenharmony_ci *     - if empty then print [] without indent and line break
1805b2a28edaSopenharmony_ci *     - if the array contains no object value, empty array or some other value
1806b2a28edaSopenharmony_ci *types,
1807b2a28edaSopenharmony_ci *       and all the values fit on one lines, then print the array on a single
1808b2a28edaSopenharmony_ci *line.
1809b2a28edaSopenharmony_ci *     - otherwise, it the values do not fit on one line, or the array contains
1810b2a28edaSopenharmony_ci *       object or non empty array, then print one value per line.
1811b2a28edaSopenharmony_ci *
1812b2a28edaSopenharmony_ci * If the Value have comments then they are outputed according to their
1813b2a28edaSopenharmony_ci *#CommentPlacement.
1814b2a28edaSopenharmony_ci *
1815b2a28edaSopenharmony_ci * \sa Reader, Value, Value::setComment()
1816b2a28edaSopenharmony_ci * \deprecated Use StreamWriterBuilder.
1817b2a28edaSopenharmony_ci */
1818b2a28edaSopenharmony_ciclass JSON_API StyledWriter : public Writer {
1819b2a28edaSopenharmony_cipublic:
1820b2a28edaSopenharmony_ci  StyledWriter();
1821b2a28edaSopenharmony_ci  virtual ~StyledWriter() {}
1822b2a28edaSopenharmony_ci
1823b2a28edaSopenharmony_cipublic: // overridden from Writer
1824b2a28edaSopenharmony_ci  /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
1825b2a28edaSopenharmony_ci   * \param root Value to serialize.
1826b2a28edaSopenharmony_ci   * \return String containing the JSON document that represents the root value.
1827b2a28edaSopenharmony_ci   */
1828b2a28edaSopenharmony_ci  virtual std::string write(const Value& root);
1829b2a28edaSopenharmony_ci
1830b2a28edaSopenharmony_ciprivate:
1831b2a28edaSopenharmony_ci  void writeValue(const Value& value);
1832b2a28edaSopenharmony_ci  void writeArrayValue(const Value& value);
1833b2a28edaSopenharmony_ci  bool isMultineArray(const Value& value);
1834b2a28edaSopenharmony_ci  void pushValue(const std::string& value);
1835b2a28edaSopenharmony_ci  void writeIndent();
1836b2a28edaSopenharmony_ci  void writeWithIndent(const std::string& value);
1837b2a28edaSopenharmony_ci  void indent();
1838b2a28edaSopenharmony_ci  void unindent();
1839b2a28edaSopenharmony_ci  void writeCommentBeforeValue(const Value& root);
1840b2a28edaSopenharmony_ci  void writeCommentAfterValueOnSameLine(const Value& root);
1841b2a28edaSopenharmony_ci  bool hasCommentForValue(const Value& value);
1842b2a28edaSopenharmony_ci  static std::string normalizeEOL(const std::string& text);
1843b2a28edaSopenharmony_ci
1844b2a28edaSopenharmony_ci  typedef std::vector<std::string> ChildValues;
1845b2a28edaSopenharmony_ci
1846b2a28edaSopenharmony_ci  ChildValues childValues_;
1847b2a28edaSopenharmony_ci  std::string document_;
1848b2a28edaSopenharmony_ci  std::string indentString_;
1849b2a28edaSopenharmony_ci  int rightMargin_;
1850b2a28edaSopenharmony_ci  int indentSize_;
1851b2a28edaSopenharmony_ci  bool addChildValues_;
1852b2a28edaSopenharmony_ci};
1853b2a28edaSopenharmony_ci
1854b2a28edaSopenharmony_ci/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
1855b2a28edaSopenharmony_ci human friendly way,
1856b2a28edaSopenharmony_ci     to a stream rather than to a string.
1857b2a28edaSopenharmony_ci *
1858b2a28edaSopenharmony_ci * The rules for line break and indent are as follow:
1859b2a28edaSopenharmony_ci * - Object value:
1860b2a28edaSopenharmony_ci *     - if empty then print {} without indent and line break
1861b2a28edaSopenharmony_ci *     - if not empty the print '{', line break & indent, print one value per
1862b2a28edaSopenharmony_ci line
1863b2a28edaSopenharmony_ci *       and then unindent and line break and print '}'.
1864b2a28edaSopenharmony_ci * - Array value:
1865b2a28edaSopenharmony_ci *     - if empty then print [] without indent and line break
1866b2a28edaSopenharmony_ci *     - if the array contains no object value, empty array or some other value
1867b2a28edaSopenharmony_ci types,
1868b2a28edaSopenharmony_ci *       and all the values fit on one lines, then print the array on a single
1869b2a28edaSopenharmony_ci line.
1870b2a28edaSopenharmony_ci *     - otherwise, it the values do not fit on one line, or the array contains
1871b2a28edaSopenharmony_ci *       object or non empty array, then print one value per line.
1872b2a28edaSopenharmony_ci *
1873b2a28edaSopenharmony_ci * If the Value have comments then they are outputed according to their
1874b2a28edaSopenharmony_ci #CommentPlacement.
1875b2a28edaSopenharmony_ci *
1876b2a28edaSopenharmony_ci * \param indentation Each level will be indented by this amount extra.
1877b2a28edaSopenharmony_ci * \sa Reader, Value, Value::setComment()
1878b2a28edaSopenharmony_ci * \deprecated Use StreamWriterBuilder.
1879b2a28edaSopenharmony_ci */
1880b2a28edaSopenharmony_ciclass JSON_API StyledStreamWriter {
1881b2a28edaSopenharmony_cipublic:
1882b2a28edaSopenharmony_ci  StyledStreamWriter(std::string indentation = "\t");
1883b2a28edaSopenharmony_ci  ~StyledStreamWriter() {}
1884b2a28edaSopenharmony_ci
1885b2a28edaSopenharmony_cipublic:
1886b2a28edaSopenharmony_ci  /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
1887b2a28edaSopenharmony_ci   * \param out Stream to write to. (Can be ostringstream, e.g.)
1888b2a28edaSopenharmony_ci   * \param root Value to serialize.
1889b2a28edaSopenharmony_ci   * \note There is no point in deriving from Writer, since write() should not
1890b2a28edaSopenharmony_ci   * return a value.
1891b2a28edaSopenharmony_ci   */
1892b2a28edaSopenharmony_ci  void write(std::ostream& out, const Value& root);
1893b2a28edaSopenharmony_ci
1894b2a28edaSopenharmony_ciprivate:
1895b2a28edaSopenharmony_ci  void writeValue(const Value& value);
1896b2a28edaSopenharmony_ci  void writeArrayValue(const Value& value);
1897b2a28edaSopenharmony_ci  bool isMultineArray(const Value& value);
1898b2a28edaSopenharmony_ci  void pushValue(const std::string& value);
1899b2a28edaSopenharmony_ci  void writeIndent();
1900b2a28edaSopenharmony_ci  void writeWithIndent(const std::string& value);
1901b2a28edaSopenharmony_ci  void indent();
1902b2a28edaSopenharmony_ci  void unindent();
1903b2a28edaSopenharmony_ci  void writeCommentBeforeValue(const Value& root);
1904b2a28edaSopenharmony_ci  void writeCommentAfterValueOnSameLine(const Value& root);
1905b2a28edaSopenharmony_ci  bool hasCommentForValue(const Value& value);
1906b2a28edaSopenharmony_ci  static std::string normalizeEOL(const std::string& text);
1907b2a28edaSopenharmony_ci
1908b2a28edaSopenharmony_ci  typedef std::vector<std::string> ChildValues;
1909b2a28edaSopenharmony_ci
1910b2a28edaSopenharmony_ci  ChildValues childValues_;
1911b2a28edaSopenharmony_ci  std::ostream* document_;
1912b2a28edaSopenharmony_ci  std::string indentString_;
1913b2a28edaSopenharmony_ci  int rightMargin_;
1914b2a28edaSopenharmony_ci  std::string indentation_;
1915b2a28edaSopenharmony_ci  bool addChildValues_ : 1;
1916b2a28edaSopenharmony_ci  bool indented_ : 1;
1917b2a28edaSopenharmony_ci};
1918b2a28edaSopenharmony_ci
1919b2a28edaSopenharmony_ci#if defined(JSON_HAS_INT64)
1920b2a28edaSopenharmony_cistd::string JSON_API valueToString(Int value);
1921b2a28edaSopenharmony_cistd::string JSON_API valueToString(UInt value);
1922b2a28edaSopenharmony_ci#endif // if defined(JSON_HAS_INT64)
1923b2a28edaSopenharmony_cistd::string JSON_API valueToString(LargestInt value);
1924b2a28edaSopenharmony_cistd::string JSON_API valueToString(LargestUInt value);
1925b2a28edaSopenharmony_cistd::string JSON_API valueToString(double value);
1926b2a28edaSopenharmony_cistd::string JSON_API valueToString(bool value);
1927b2a28edaSopenharmony_cistd::string JSON_API valueToQuotedString(const char* value);
1928b2a28edaSopenharmony_ci
1929b2a28edaSopenharmony_ci/// \brief Output using the StyledStreamWriter.
1930b2a28edaSopenharmony_ci/// \see Json::operator>>()
1931b2a28edaSopenharmony_ciJSON_API std::ostream& operator<<(std::ostream&, const Value& root);
1932b2a28edaSopenharmony_ci
1933b2a28edaSopenharmony_ci} // namespace Json
1934b2a28edaSopenharmony_ci
1935b2a28edaSopenharmony_ci#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1936b2a28edaSopenharmony_ci#pragma warning(pop)
1937b2a28edaSopenharmony_ci#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1938b2a28edaSopenharmony_ci
1939b2a28edaSopenharmony_ci#endif // JSON_WRITER_H_INCLUDED
1940b2a28edaSopenharmony_ci
1941b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1942b2a28edaSopenharmony_ci// End of content of file: include/json/writer.h
1943b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1944b2a28edaSopenharmony_ci
1945b2a28edaSopenharmony_ci
1946b2a28edaSopenharmony_ci
1947b2a28edaSopenharmony_ci
1948b2a28edaSopenharmony_ci
1949b2a28edaSopenharmony_ci
1950b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1951b2a28edaSopenharmony_ci// Beginning of content of file: include/json/assertions.h
1952b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
1953b2a28edaSopenharmony_ci
1954b2a28edaSopenharmony_ci// Copyright 2007-2010 Baptiste Lepilleur
1955b2a28edaSopenharmony_ci// Distributed under MIT license, or public domain if desired and
1956b2a28edaSopenharmony_ci// recognized in your jurisdiction.
1957b2a28edaSopenharmony_ci// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
1958b2a28edaSopenharmony_ci
1959b2a28edaSopenharmony_ci#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
1960b2a28edaSopenharmony_ci#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
1961b2a28edaSopenharmony_ci
1962b2a28edaSopenharmony_ci#include <stdlib.h>
1963b2a28edaSopenharmony_ci#include <sstream>
1964b2a28edaSopenharmony_ci
1965b2a28edaSopenharmony_ci#if !defined(JSON_IS_AMALGAMATION)
1966b2a28edaSopenharmony_ci#include "config.h"
1967b2a28edaSopenharmony_ci#endif // if !defined(JSON_IS_AMALGAMATION)
1968b2a28edaSopenharmony_ci
1969b2a28edaSopenharmony_ci/** It should not be possible for a maliciously designed file to
1970b2a28edaSopenharmony_ci *  cause an abort() or seg-fault, so these macros are used only
1971b2a28edaSopenharmony_ci *  for pre-condition violations and internal logic errors.
1972b2a28edaSopenharmony_ci */
1973b2a28edaSopenharmony_ci#if JSON_USE_EXCEPTION
1974b2a28edaSopenharmony_ci
1975b2a28edaSopenharmony_ci// @todo <= add detail about condition in exception
1976b2a28edaSopenharmony_ci# define JSON_ASSERT(condition)                                                \
1977b2a28edaSopenharmony_ci  {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
1978b2a28edaSopenharmony_ci
1979b2a28edaSopenharmony_ci# define JSON_FAIL_MESSAGE(message)                                            \
1980b2a28edaSopenharmony_ci  {                                                                            \
1981b2a28edaSopenharmony_ci    std::ostringstream oss; oss << message;                                    \
1982b2a28edaSopenharmony_ci    Json::throwLogicError(oss.str());                                          \
1983b2a28edaSopenharmony_ci    abort();                                                                   \
1984b2a28edaSopenharmony_ci  }
1985b2a28edaSopenharmony_ci
1986b2a28edaSopenharmony_ci#else // JSON_USE_EXCEPTION
1987b2a28edaSopenharmony_ci
1988b2a28edaSopenharmony_ci# define JSON_ASSERT(condition) assert(condition)
1989b2a28edaSopenharmony_ci
1990b2a28edaSopenharmony_ci// The call to assert() will show the failure message in debug builds. In
1991b2a28edaSopenharmony_ci// release builds we abort, for a core-dump or debugger.
1992b2a28edaSopenharmony_ci# define JSON_FAIL_MESSAGE(message)                                            \
1993b2a28edaSopenharmony_ci  {                                                                            \
1994b2a28edaSopenharmony_ci    std::ostringstream oss; oss << message;                                    \
1995b2a28edaSopenharmony_ci    assert(false && oss.str().c_str());                                        \
1996b2a28edaSopenharmony_ci    abort();                                                                   \
1997b2a28edaSopenharmony_ci  }
1998b2a28edaSopenharmony_ci
1999b2a28edaSopenharmony_ci
2000b2a28edaSopenharmony_ci#endif
2001b2a28edaSopenharmony_ci
2002b2a28edaSopenharmony_ci#define JSON_ASSERT_MESSAGE(condition, message)                                \
2003b2a28edaSopenharmony_ci  if (!(condition)) {                                                          \
2004b2a28edaSopenharmony_ci    JSON_FAIL_MESSAGE(message);                                                \
2005b2a28edaSopenharmony_ci  }
2006b2a28edaSopenharmony_ci
2007b2a28edaSopenharmony_ci#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
2008b2a28edaSopenharmony_ci
2009b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
2010b2a28edaSopenharmony_ci// End of content of file: include/json/assertions.h
2011b2a28edaSopenharmony_ci// //////////////////////////////////////////////////////////////////////
2012b2a28edaSopenharmony_ci
2013b2a28edaSopenharmony_ci
2014b2a28edaSopenharmony_ci
2015b2a28edaSopenharmony_ci
2016b2a28edaSopenharmony_ci
2017b2a28edaSopenharmony_ci#endif //ifndef JSON_AMALGATED_H_INCLUDED
2018