IOSS 2.0

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