annotate Resources/CodeGeneration/testWasmIntegrated/jsoncpp-1.8.4/json/json.h @ 703:d4d6c5b502b5

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