| 1 |
|
|
1 |
|
|
| 2 |
|
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
2 |
|
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
| 3 |
|
// Copyright (c) 2020 Krystian Stasiowski (sdkrystian@gmail.com)
|
3 |
|
// Copyright (c) 2020 Krystian Stasiowski (sdkrystian@gmail.com)
|
| 4 |
|
|
4 |
|
|
| 5 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
5 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
| 6 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
6 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 7 |
|
|
7 |
|
|
| 8 |
|
// Official repository: https://github.com/boostorg/json
|
8 |
|
// Official repository: https://github.com/boostorg/json
|
| 9 |
|
|
9 |
|
|
| 10 |
|
|
10 |
|
|
| 11 |
|
#ifndef BOOST_JSON_BASIC_PARSER_HPP
|
11 |
|
#ifndef BOOST_JSON_BASIC_PARSER_HPP
|
| 12 |
|
#define BOOST_JSON_BASIC_PARSER_HPP
|
12 |
|
#define BOOST_JSON_BASIC_PARSER_HPP
|
| 13 |
|
|
13 |
|
|
| 14 |
|
#include <boost/json/detail/config.hpp>
|
14 |
|
#include <boost/json/detail/config.hpp>
|
| 15 |
|
#include <boost/json/detail/except.hpp>
|
15 |
|
#include <boost/json/detail/except.hpp>
|
| 16 |
|
#include <boost/json/error.hpp>
|
16 |
|
#include <boost/json/error.hpp>
|
| 17 |
|
#include <boost/json/kind.hpp>
|
17 |
|
#include <boost/json/kind.hpp>
|
| 18 |
|
#include <boost/json/parse_options.hpp>
|
18 |
|
#include <boost/json/parse_options.hpp>
|
| 19 |
|
#include <boost/json/detail/stack.hpp>
|
19 |
|
#include <boost/json/detail/stack.hpp>
|
| 20 |
|
#include <boost/json/detail/stream.hpp>
|
20 |
|
#include <boost/json/detail/stream.hpp>
|
| 21 |
|
#include <boost/json/detail/utf8.hpp>
|
21 |
|
#include <boost/json/detail/utf8.hpp>
|
| 22 |
|
#include <boost/json/detail/sbo_buffer.hpp>
|
22 |
|
#include <boost/json/detail/sbo_buffer.hpp>
|
| 23 |
|
|
23 |
|
|
| 24 |
|
|
24 |
|
|
| 25 |
|
|
25 |
|
|
| 26 |
|
|
26 |
|
|
| 27 |
|
/** An incremental SAX parser for serialized JSON.
|
27 |
|
/** An incremental SAX parser for serialized JSON.
|
| 28 |
|
|
28 |
|
|
| 29 |
- |
This implements a SAX-style parser, invoking a caller-supplied handler with
|
29 |
+ |
This implements a SAX-style parser, invoking a
|
| 30 |
- |
each parsing event. To use, first declare a variable of type
|
30 |
+ |
caller-supplied handler with each parsing event.
|
| 31 |
- |
`basic_parser<T>` where `T` meets the handler requirements specified below.
|
31 |
+ |
To use, first declare a variable of type
|
| 32 |
- |
Then call @ref write_some one or more times with the input, setting
|
32 |
+ |
`basic_parser<T>` where `T` meets the handler
|
| 33 |
- |
`more = false` on the final buffer. The parsing events are realized through
|
33 |
+ |
requirements specified below. Then call
|
| 34 |
- |
member function calls on the handler, which exists as a data member of the
|
34 |
+ |
@ref write_some one or more times with the input,
|
| 35 |
- |
|
35 |
+ |
setting `more = false` on the final buffer.
|
| 36 |
- |
|
36 |
+ |
The parsing events are realized through member
|
| 37 |
- |
The parser may dynamically allocate intermediate storage as needed to
|
37 |
+ |
function calls on the handler, which exists
|
| 38 |
- |
accommodate the nesting level of the input JSON. On subsequent invocations,
|
38 |
+ |
as a data member of the parser.
|
| 39 |
- |
the parser can cheaply re-use this memory, improving performance. This
|
39 |
+ |
|
| 40 |
- |
storage is freed when the parser is destroyed
|
40 |
+ |
The parser may dynamically allocate intermediate
|
|
|
|
41 |
+ |
storage as needed to accommodate the nesting level
|
|
|
|
42 |
+ |
of the input JSON. On subsequent invocations, the
|
|
|
|
43 |
+ |
parser can cheaply re-use this memory, improving
|
|
|
|
44 |
+ |
performance. This storage is freed when the
|
|
|
|
45 |
+ |
|
| 41 |
|
|
46 |
|
|
| 42 |
|
|
47 |
|
|
| 43 |
- |
To get the declaration and function definitions for this class it is
|
48 |
+ |
|
| 44 |
- |
necessary to include this file instead:
|
49 |
+ |
To get the declaration and function definitions
|
|
|
|
50 |
+ |
for this class it is necessary to include this
|
|
|
|
51 |
+ |
|
| 45 |
|
|
52 |
|
|
| 46 |
|
#include <boost/json/basic_parser_impl.hpp>
|
53 |
|
#include <boost/json/basic_parser_impl.hpp>
|
| 47 |
|
|
54 |
|
|
| 48 |
|
|
55 |
|
|
| 49 |
- |
Users who wish to parse JSON into the DOM container @ref value will not use
|
56 |
+ |
Users who wish to parse JSON into the DOM container
|
| 50 |
- |
this class directly; instead they will create an instance of @ref parser or
|
57 |
+ |
@ref value will not use this class directly; instead
|
| 51 |
- |
@ref stream_parser and use that instead. Alternatively, they may call the
|
58 |
+ |
they will create an instance of @ref parser or
|
| 52 |
- |
function @ref parse. This class is designed for users who wish to perform
|
59 |
+ |
@ref stream_parser and use that instead. Alternatively,
|
| 53 |
- |
custom actions instead of building a @ref value. For example, to produce a
|
60 |
+ |
they may call the function @ref parse. This class is
|
| 54 |
- |
DOM from an external library.
|
61 |
+ |
designed for users who wish to perform custom actions
|
| 55 |
- |
|
62 |
+ |
instead of building a @ref value. For example, to
|
|
|
|
63 |
+ |
produce a DOM from an external library.
|
|
|
|
64 |
+ |
|
| 56 |
|
|
65 |
|
|
| 57 |
- |
By default, only conforming JSON using UTF-8 encoding is accepted. However,
|
66 |
+ |
|
| 58 |
- |
select non-compliant syntax can be allowed by construction using a
|
67 |
+ |
By default, only conforming JSON using UTF-8
|
|
|
|
68 |
+ |
encoding is accepted. However, select non-compliant
|
|
|
|
69 |
+ |
syntax can be allowed by construction using a
|
| 59 |
|
@ref parse_options set to desired values.
|
70 |
|
@ref parse_options set to desired values.
|
| 60 |
|
|
71 |
|
|
| 61 |
- |
The handler provided must be implemented as an object of class type which
|
|
|
|
| 62 |
- |
defines each of the required event member functions below. The event
|
|
|
|
| 63 |
- |
functions return a `bool` where `true` indicates success, and `false`
|
|
|
|
| 64 |
- |
indicates failure. If the member function returns `false`, it must set the
|
|
|
|
| 65 |
- |
error code to a suitable value. This error code will be returned by the
|
|
|
|
| 66 |
- |
write function to the caller.
|
|
|
|
| 67 |
|
|
72 |
|
|
| 68 |
|
|
73 |
|
|
| 69 |
- |
Handlers are required to declare the maximum limits on various elements. If
|
74 |
+ |
The handler provided must be implemented as an
|
| 70 |
- |
these limits are exceeded during parsing, then parsing fails with an error.
|
75 |
+ |
object of class type which defines each of the
|
| 71 |
- |
|
76 |
+ |
required event member functions below. The event
|
| 72 |
- |
The following declaration meets the parser's handler requirements:
|
77 |
+ |
functions return a `bool` where `true` indicates
|
|
|
|
78 |
+ |
success, and `false` indicates failure. If the
|
|
|
|
79 |
+ |
member function returns `false`, it must set
|
|
|
|
80 |
+ |
the error code to a suitable value. This error
|
|
|
|
81 |
+ |
code will be returned by the write function to
|
|
|
|
82 |
+ |
|
|
|
|
83 |
+ |
|
|
|
|
84 |
+ |
Handlers are required to declare the maximum
|
|
|
|
85 |
+ |
limits on various elements. If these limits
|
|
|
|
86 |
+ |
are exceeded during parsing, then parsing
|
|
|
|
87 |
+ |
|
|
|
|
88 |
+ |
|
|
|
|
89 |
+ |
The following declaration meets the parser's
|
|
|
|
90 |
+ |
|
| 73 |
|
|
91 |
|
|
| 74 |
|
|
92 |
|
|
| 75 |
|
|
93 |
|
|
| 76 |
|
|
94 |
|
|
| 77 |
|
/// The maximum number of elements allowed in an array
|
95 |
|
/// The maximum number of elements allowed in an array
|
| 78 |
|
static constexpr std::size_t max_array_size = -1;
|
96 |
|
static constexpr std::size_t max_array_size = -1;
|
| 79 |
|
|
97 |
|
|
| 80 |
|
/// The maximum number of elements allowed in an object
|
98 |
|
/// The maximum number of elements allowed in an object
|
| 81 |
|
static constexpr std::size_t max_object_size = -1;
|
99 |
|
static constexpr std::size_t max_object_size = -1;
|
| 82 |
|
|
100 |
|
|
| 83 |
|
/// The maximum number of characters allowed in a string
|
101 |
|
/// The maximum number of characters allowed in a string
|
| 84 |
|
static constexpr std::size_t max_string_size = -1;
|
102 |
|
static constexpr std::size_t max_string_size = -1;
|
| 85 |
|
|
103 |
|
|
| 86 |
|
/// The maximum number of characters allowed in a key
|
104 |
|
/// The maximum number of characters allowed in a key
|
| 87 |
|
static constexpr std::size_t max_key_size = -1;
|
105 |
|
static constexpr std::size_t max_key_size = -1;
|
| 88 |
|
|
106 |
|
|
| 89 |
|
/// Called once when the JSON parsing begins.
|
107 |
|
/// Called once when the JSON parsing begins.
|
| 90 |
|
|
108 |
|
|
| 91 |
|
/// @return `true` on success.
|
109 |
|
/// @return `true` on success.
|
| 92 |
|
/// @param ec Set to the error, if any occurred.
|
110 |
|
/// @param ec Set to the error, if any occurred.
|
| 93 |
|
|
111 |
|
|
| 94 |
|
bool on_document_begin( error_code& ec );
|
112 |
|
bool on_document_begin( error_code& ec );
|
| 95 |
|
|
113 |
|
|
| 96 |
|
/// Called when the JSON parsing is done.
|
114 |
|
/// Called when the JSON parsing is done.
|
| 97 |
|
|
115 |
|
|
| 98 |
|
/// @return `true` on success.
|
116 |
|
/// @return `true` on success.
|
| 99 |
|
/// @param ec Set to the error, if any occurred.
|
117 |
|
/// @param ec Set to the error, if any occurred.
|
| 100 |
|
|
118 |
|
|
| 101 |
|
bool on_document_end( error_code& ec );
|
119 |
|
bool on_document_end( error_code& ec );
|
| 102 |
|
|
120 |
|
|
| 103 |
|
/// Called when the beginning of an array is encountered.
|
121 |
|
/// Called when the beginning of an array is encountered.
|
| 104 |
|
|
122 |
|
|
| 105 |
|
/// @return `true` on success.
|
123 |
|
/// @return `true` on success.
|
| 106 |
|
/// @param ec Set to the error, if any occurred.
|
124 |
|
/// @param ec Set to the error, if any occurred.
|
| 107 |
|
|
125 |
|
|
| 108 |
|
bool on_array_begin( error_code& ec );
|
126 |
|
bool on_array_begin( error_code& ec );
|
| 109 |
|
|
127 |
|
|
| 110 |
|
/// Called when the end of the current array is encountered.
|
128 |
|
/// Called when the end of the current array is encountered.
|
| 111 |
|
|
129 |
|
|
| 112 |
|
/// @return `true` on success.
|
130 |
|
/// @return `true` on success.
|
| 113 |
|
/// @param n The number of elements in the array.
|
131 |
|
/// @param n The number of elements in the array.
|
| 114 |
|
/// @param ec Set to the error, if any occurred.
|
132 |
|
/// @param ec Set to the error, if any occurred.
|
| 115 |
|
|
133 |
|
|
| 116 |
|
bool on_array_end( std::size_t n, error_code& ec );
|
134 |
|
bool on_array_end( std::size_t n, error_code& ec );
|
| 117 |
|
|
135 |
|
|
| 118 |
|
/// Called when the beginning of an object is encountered.
|
136 |
|
/// Called when the beginning of an object is encountered.
|
| 119 |
|
|
137 |
|
|
| 120 |
|
/// @return `true` on success.
|
138 |
|
/// @return `true` on success.
|
| 121 |
|
/// @param ec Set to the error, if any occurred.
|
139 |
|
/// @param ec Set to the error, if any occurred.
|
| 122 |
|
|
140 |
|
|
| 123 |
|
bool on_object_begin( error_code& ec );
|
141 |
|
bool on_object_begin( error_code& ec );
|
| 124 |
|
|
142 |
|
|
| 125 |
|
/// Called when the end of the current object is encountered.
|
143 |
|
/// Called when the end of the current object is encountered.
|
| 126 |
|
|
144 |
|
|
| 127 |
|
/// @return `true` on success.
|
145 |
|
/// @return `true` on success.
|
| 128 |
|
/// @param n The number of elements in the object.
|
146 |
|
/// @param n The number of elements in the object.
|
| 129 |
|
/// @param ec Set to the error, if any occurred.
|
147 |
|
/// @param ec Set to the error, if any occurred.
|
| 130 |
|
|
148 |
|
|
| 131 |
|
bool on_object_end( std::size_t n, error_code& ec );
|
149 |
|
bool on_object_end( std::size_t n, error_code& ec );
|
| 132 |
|
|
150 |
|
|
| 133 |
|
/// Called with characters corresponding to part of the current string.
|
151 |
|
/// Called with characters corresponding to part of the current string.
|
| 134 |
|
|
152 |
|
|
| 135 |
|
/// @return `true` on success.
|
153 |
|
/// @return `true` on success.
|
| 136 |
|
/// @param s The partial characters
|
154 |
|
/// @param s The partial characters
|
| 137 |
|
/// @param n The total size of the string thus far
|
155 |
|
/// @param n The total size of the string thus far
|
| 138 |
|
/// @param ec Set to the error, if any occurred.
|
156 |
|
/// @param ec Set to the error, if any occurred.
|
| 139 |
|
|
157 |
|
|
| 140 |
|
bool on_string_part( string_view s, std::size_t n, error_code& ec );
|
158 |
|
bool on_string_part( string_view s, std::size_t n, error_code& ec );
|
| 141 |
|
|
159 |
|
|
| 142 |
|
/// Called with the last characters corresponding to the current string.
|
160 |
|
/// Called with the last characters corresponding to the current string.
|
| 143 |
|
|
161 |
|
|
| 144 |
|
/// @return `true` on success.
|
162 |
|
/// @return `true` on success.
|
| 145 |
|
/// @param s The remaining characters
|
163 |
|
/// @param s The remaining characters
|
| 146 |
|
/// @param n The total size of the string
|
164 |
|
/// @param n The total size of the string
|
| 147 |
|
/// @param ec Set to the error, if any occurred.
|
165 |
|
/// @param ec Set to the error, if any occurred.
|
| 148 |
|
|
166 |
|
|
| 149 |
|
bool on_string( string_view s, std::size_t n, error_code& ec );
|
167 |
|
bool on_string( string_view s, std::size_t n, error_code& ec );
|
| 150 |
|
|
168 |
|
|
| 151 |
|
/// Called with characters corresponding to part of the current key.
|
169 |
|
/// Called with characters corresponding to part of the current key.
|
| 152 |
|
|
170 |
|
|
| 153 |
|
/// @return `true` on success.
|
171 |
|
/// @return `true` on success.
|
| 154 |
|
/// @param s The partial characters
|
172 |
|
/// @param s The partial characters
|
| 155 |
|
/// @param n The total size of the key thus far
|
173 |
|
/// @param n The total size of the key thus far
|
| 156 |
|
/// @param ec Set to the error, if any occurred.
|
174 |
|
/// @param ec Set to the error, if any occurred.
|
| 157 |
|
|
175 |
|
|
| 158 |
|
bool on_key_part( string_view s, std::size_t n, error_code& ec );
|
176 |
|
bool on_key_part( string_view s, std::size_t n, error_code& ec );
|
| 159 |
|
|
177 |
|
|
| 160 |
|
/// Called with the last characters corresponding to the current key.
|
178 |
|
/// Called with the last characters corresponding to the current key.
|
| 161 |
|
|
179 |
|
|
| 162 |
|
/// @return `true` on success.
|
180 |
|
/// @return `true` on success.
|
| 163 |
|
/// @param s The remaining characters
|
181 |
|
/// @param s The remaining characters
|
| 164 |
|
/// @param n The total size of the key
|
182 |
|
/// @param n The total size of the key
|
| 165 |
|
/// @param ec Set to the error, if any occurred.
|
183 |
|
/// @param ec Set to the error, if any occurred.
|
| 166 |
|
|
184 |
|
|
| 167 |
|
bool on_key( string_view s, std::size_t n, error_code& ec );
|
185 |
|
bool on_key( string_view s, std::size_t n, error_code& ec );
|
| 168 |
|
|
186 |
|
|
| 169 |
|
/// Called with the characters corresponding to part of the current number.
|
187 |
|
/// Called with the characters corresponding to part of the current number.
|
| 170 |
|
|
188 |
|
|
| 171 |
|
/// @return `true` on success.
|
189 |
|
/// @return `true` on success.
|
| 172 |
|
/// @param s The partial characters
|
190 |
|
/// @param s The partial characters
|
| 173 |
|
/// @param ec Set to the error, if any occurred.
|
191 |
|
/// @param ec Set to the error, if any occurred.
|
| 174 |
|
|
192 |
|
|
| 175 |
|
bool on_number_part( string_view s, error_code& ec );
|
193 |
|
bool on_number_part( string_view s, error_code& ec );
|
| 176 |
|
|
194 |
|
|
| 177 |
|
/// Called when a signed integer is parsed.
|
195 |
|
/// Called when a signed integer is parsed.
|
| 178 |
|
|
196 |
|
|
| 179 |
|
/// @return `true` on success.
|
197 |
|
/// @return `true` on success.
|
| 180 |
|
|
198 |
|
|
| 181 |
|
/// @param s The remaining characters
|
199 |
|
/// @param s The remaining characters
|
| 182 |
|
/// @param ec Set to the error, if any occurred.
|
200 |
|
/// @param ec Set to the error, if any occurred.
|
| 183 |
|
|
201 |
|
|
| 184 |
|
bool on_int64( int64_t i, string_view s, error_code& ec );
|
202 |
|
bool on_int64( int64_t i, string_view s, error_code& ec );
|
| 185 |
|
|
203 |
|
|
| 186 |
|
/// Called when an unsigend integer is parsed.
|
204 |
|
/// Called when an unsigend integer is parsed.
|
| 187 |
|
|
205 |
|
|
| 188 |
|
/// @return `true` on success.
|
206 |
|
/// @return `true` on success.
|
| 189 |
|
|
207 |
|
|
| 190 |
|
/// @param s The remaining characters
|
208 |
|
/// @param s The remaining characters
|
| 191 |
|
/// @param ec Set to the error, if any occurred.
|
209 |
|
/// @param ec Set to the error, if any occurred.
|
| 192 |
|
|
210 |
|
|
| 193 |
|
bool on_uint64( uint64_t u, string_view s, error_code& ec );
|
211 |
|
bool on_uint64( uint64_t u, string_view s, error_code& ec );
|
| 194 |
|
|
212 |
|
|
| 195 |
|
/// Called when a double is parsed.
|
213 |
|
/// Called when a double is parsed.
|
| 196 |
|
|
214 |
|
|
| 197 |
|
/// @return `true` on success.
|
215 |
|
/// @return `true` on success.
|
| 198 |
|
|
216 |
|
|
| 199 |
|
/// @param s The remaining characters
|
217 |
|
/// @param s The remaining characters
|
| 200 |
|
/// @param ec Set to the error, if any occurred.
|
218 |
|
/// @param ec Set to the error, if any occurred.
|
| 201 |
|
|
219 |
|
|
| 202 |
|
bool on_double( double d, string_view s, error_code& ec );
|
220 |
|
bool on_double( double d, string_view s, error_code& ec );
|
| 203 |
|
|
221 |
|
|
| 204 |
|
/// Called when a boolean is parsed.
|
222 |
|
/// Called when a boolean is parsed.
|
| 205 |
|
|
223 |
|
|
| 206 |
|
/// @return `true` on success.
|
224 |
|
/// @return `true` on success.
|
| 207 |
|
|
225 |
|
|
| 208 |
|
/// @param s The remaining characters
|
226 |
|
/// @param s The remaining characters
|
| 209 |
|
/// @param ec Set to the error, if any occurred.
|
227 |
|
/// @param ec Set to the error, if any occurred.
|
| 210 |
|
|
228 |
|
|
| 211 |
|
bool on_bool( bool b, error_code& ec );
|
229 |
|
bool on_bool( bool b, error_code& ec );
|
| 212 |
|
|
230 |
|
|
| 213 |
|
/// Called when a null is parsed.
|
231 |
|
/// Called when a null is parsed.
|
| 214 |
|
|
232 |
|
|
| 215 |
|
/// @return `true` on success.
|
233 |
|
/// @return `true` on success.
|
| 216 |
|
/// @param ec Set to the error, if any occurred.
|
234 |
|
/// @param ec Set to the error, if any occurred.
|
| 217 |
|
|
235 |
|
|
| 218 |
|
bool on_null( error_code& ec );
|
236 |
|
bool on_null( error_code& ec );
|
| 219 |
|
|
237 |
|
|
| 220 |
|
/// Called with characters corresponding to part of the current comment.
|
238 |
|
/// Called with characters corresponding to part of the current comment.
|
| 221 |
|
|
239 |
|
|
| 222 |
|
/// @return `true` on success.
|
240 |
|
/// @return `true` on success.
|
| 223 |
|
/// @param s The partial characters.
|
241 |
|
/// @param s The partial characters.
|
| 224 |
|
/// @param ec Set to the error, if any occurred.
|
242 |
|
/// @param ec Set to the error, if any occurred.
|
| 225 |
|
|
243 |
|
|
| 226 |
|
bool on_comment_part( string_view s, error_code& ec );
|
244 |
|
bool on_comment_part( string_view s, error_code& ec );
|
| 227 |
|
|
245 |
|
|
| 228 |
|
/// Called with the last characters corresponding to the current comment.
|
246 |
|
/// Called with the last characters corresponding to the current comment.
|
| 229 |
|
|
247 |
|
|
| 230 |
|
/// @return `true` on success.
|
248 |
|
/// @return `true` on success.
|
| 231 |
|
/// @param s The remaining characters
|
249 |
|
/// @param s The remaining characters
|
| 232 |
|
/// @param ec Set to the error, if any occurred.
|
250 |
|
/// @param ec Set to the error, if any occurred.
|
| 233 |
|
|
251 |
|
|
| 234 |
|
bool on_comment( string_view s, error_code& ec );
|
252 |
|
bool on_comment( string_view s, error_code& ec );
|
| 235 |
|
|
253 |
|
|
| 236 |
|
|
254 |
|
|
| 237 |
|
|
255 |
|
|
| 238 |
|
|
256 |
|
|
| 239 |
|
|
257 |
|
|
| 240 |
|
|
258 |
|
|
| 241 |
- |
\<\<examples_validate, validating parser example\>\>.
|
259 |
+ |
[Validating parser example](../../doc/html/json/examples.html#json.examples.validate).
|
|
|
|
260 |
+ |
|
|
|
|
261 |
+ |
@headerfile <boost/json/basic_parser.hpp>
|
| 242 |
|
|
262 |
|
|
| 243 |
|
|
263 |
|
|
| 244 |
|
|
264 |
|
|
| 245 |
|
|
265 |
|
|
| 246 |
|
|
266 |
|
|
| 247 |
|
|
267 |
|
|
| 248 |
|
|
268 |
|
|
| 249 |
|
|
269 |
|
|
| 250 |
|
|
270 |
|
|
| 251 |
|
|
271 |
|
|
| 252 |
|
|
272 |
|
|
| 253 |
|
|
273 |
|
|
| 254 |
|
|
274 |
|
|
| 255 |
|
|
275 |
|
|
| 256 |
|
|
276 |
|
|
| 257 |
|
|
277 |
|
|
| 258 |
|
|
278 |
|
|
| 259 |
|
|
279 |
|
|
| 260 |
|
|
280 |
|
|
| 261 |
|
|
281 |
|
|
| 262 |
|
|
282 |
|
|
| 263 |
|
|
283 |
|
|
| 264 |
|
|
284 |
|
|
| 265 |
|
|
285 |
|
|
| 266 |
|
|
286 |
|
|
| 267 |
|
|
287 |
|
|
| 268 |
|
|
288 |
|
|
| 269 |
|
|
289 |
|
|
| 270 |
|
|
290 |
|
|
| 271 |
|
|
291 |
|
|
| 272 |
|
|
292 |
|
|
| 273 |
|
|
293 |
|
|
| 274 |
|
|
294 |
|
|
| 275 |
|
template< bool StackEmpty_, char First_ >
|
295 |
|
template< bool StackEmpty_, char First_ >
|
| 276 |
|
struct parse_number_helper;
|
296 |
|
struct parse_number_helper;
|
| 277 |
|
|
297 |
|
|
| 278 |
|
// optimization: must come first
|
298 |
|
// optimization: must come first
|
| 279 |
|
|
299 |
|
|
| 280 |
|
|
300 |
|
|
| 281 |
|
|
301 |
|
|
| 282 |
|
|
302 |
|
|
| 283 |
|
|
303 |
|
|
| 284 |
|
detail::utf8_sequence seq_;
|
304 |
|
detail::utf8_sequence seq_;
|
| 285 |
|
|
305 |
|
|
| 286 |
|
|
306 |
|
|
| 287 |
|
bool more_; // false for final buffer
|
307 |
|
bool more_; // false for final buffer
|
| 288 |
|
bool done_ = false; // true on complete parse
|
308 |
|
bool done_ = false; // true on complete parse
|
| 289 |
|
bool clean_ = true; // write_some exited cleanly
|
309 |
|
bool clean_ = true; // write_some exited cleanly
|
| 290 |
|
|
310 |
|
|
| 291 |
|
detail::sbo_buffer<16 + 16 + 1 + 1> num_buf_;
|
311 |
|
detail::sbo_buffer<16 + 16 + 1 + 1> num_buf_;
|
| 292 |
|
|
312 |
|
|
| 293 |
|
// how many levels deeper the parser can go
|
313 |
|
// how many levels deeper the parser can go
|
| 294 |
|
std::size_t depth_ = opt_.max_depth;
|
314 |
|
std::size_t depth_ = opt_.max_depth;
|
| 295 |
|
unsigned char cur_lit_ = 0;
|
315 |
|
unsigned char cur_lit_ = 0;
|
| 296 |
|
unsigned char lit_offset_ = 0;
|
316 |
|
unsigned char lit_offset_ = 0;
|
| 297 |
|
|
317 |
|
|
| 298 |
|
|
318 |
|
|
| 299 |
|
inline const char* sentinel();
|
319 |
|
inline const char* sentinel();
|
| 300 |
|
|
320 |
|
|
| 301 |
|
const detail::const_stream_wrapper& cs);
|
321 |
|
const detail::const_stream_wrapper& cs);
|
| 302 |
|
|
322 |
|
|
| 303 |
|
|
323 |
|
|
| 304 |
|
|
324 |
|
|
| 305 |
|
#pragma warning disable 2196
|
325 |
|
#pragma warning disable 2196
|
| 306 |
|
|
326 |
|
|
| 307 |
|
|
327 |
|
|
| 308 |
|
|
328 |
|
|
| 309 |
|
|
329 |
|
|
| 310 |
|
|
330 |
|
|
| 311 |
|
suspend_or_fail(state st);
|
331 |
|
suspend_or_fail(state st);
|
| 312 |
|
|
332 |
|
|
| 313 |
|
|
333 |
|
|
| 314 |
|
|
334 |
|
|
| 315 |
|
|
335 |
|
|
| 316 |
|
|
336 |
|
|
| 317 |
|
|
337 |
|
|
| 318 |
|
|
338 |
|
|
| 319 |
|
|
339 |
|
|
| 320 |
|
|
340 |
|
|
| 321 |
|
|
341 |
|
|
| 322 |
|
|
342 |
|
|
| 323 |
|
fail(const char* p) noexcept;
|
343 |
|
fail(const char* p) noexcept;
|
| 324 |
|
|
344 |
|
|
| 325 |
|
|
345 |
|
|
| 326 |
|
|
346 |
|
|
| 327 |
|
|
347 |
|
|
| 328 |
|
|
348 |
|
|
| 329 |
|
|
349 |
|
|
| 330 |
|
|
350 |
|
|
| 331 |
|
source_location const* loc) noexcept;
|
351 |
|
source_location const* loc) noexcept;
|
| 332 |
|
|
352 |
|
|
| 333 |
|
|
353 |
|
|
| 334 |
|
|
354 |
|
|
| 335 |
|
|
355 |
|
|
| 336 |
|
|
356 |
|
|
| 337 |
|
|
357 |
|
|
| 338 |
|
|
358 |
|
|
| 339 |
|
|
359 |
|
|
| 340 |
|
|
360 |
|
|
| 341 |
|
|
361 |
|
|
| 342 |
|
|
362 |
|
|
| 343 |
|
|
363 |
|
|
| 344 |
|
|
364 |
|
|
| 345 |
|
|
365 |
|
|
| 346 |
|
|
366 |
|
|
| 347 |
|
|
367 |
|
|
| 348 |
|
|
368 |
|
|
| 349 |
|
|
369 |
|
|
| 350 |
|
|
370 |
|
|
| 351 |
|
|
371 |
|
|
| 352 |
|
|
372 |
|
|
| 353 |
|
|
373 |
|
|
| 354 |
|
|
374 |
|
|
| 355 |
|
|
375 |
|
|
| 356 |
|
|
376 |
|
|
| 357 |
|
|
377 |
|
|
| 358 |
|
|
378 |
|
|
| 359 |
|
|
379 |
|
|
| 360 |
|
|
380 |
|
|
| 361 |
|
|
381 |
|
|
| 362 |
|
|
382 |
|
|
| 363 |
|
|
383 |
|
|
| 364 |
|
|
384 |
|
|
| 365 |
|
|
385 |
|
|
| 366 |
|
|
386 |
|
|
| 367 |
|
|
387 |
|
|
| 368 |
|
|
388 |
|
|
| 369 |
|
|
389 |
|
|
| 370 |
|
|
390 |
|
|
| 371 |
|
|
391 |
|
|
| 372 |
|
|
392 |
|
|
| 373 |
|
|
393 |
|
|
| 374 |
|
|
394 |
|
|
| 375 |
|
template<bool StackEmpty_/*, bool Terminal_*/>
|
395 |
|
template<bool StackEmpty_/*, bool Terminal_*/>
|
| 376 |
|
const char* parse_comment(const char* p,
|
396 |
|
const char* parse_comment(const char* p,
|
| 377 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
397 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
| 378 |
|
/*std::integral_constant<bool, Terminal_>*/ bool terminal);
|
398 |
|
/*std::integral_constant<bool, Terminal_>*/ bool terminal);
|
| 379 |
|
|
399 |
|
|
| 380 |
|
template<bool StackEmpty_>
|
400 |
|
template<bool StackEmpty_>
|
| 381 |
|
const char* parse_document(const char* p,
|
401 |
|
const char* parse_document(const char* p,
|
| 382 |
|
std::integral_constant<bool, StackEmpty_> stack_empty);
|
402 |
|
std::integral_constant<bool, StackEmpty_> stack_empty);
|
| 383 |
|
|
403 |
|
|
| 384 |
|
template<bool StackEmpty_, bool AllowComments_/*,
|
404 |
|
template<bool StackEmpty_, bool AllowComments_/*,
|
| 385 |
|
bool AllowTrailing_, bool AllowBadUTF8_*/>
|
405 |
|
bool AllowTrailing_, bool AllowBadUTF8_*/>
|
| 386 |
|
const char* parse_value(const char* p,
|
406 |
|
const char* parse_value(const char* p,
|
| 387 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
407 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
| 388 |
|
std::integral_constant<bool, AllowComments_> allow_comments,
|
408 |
|
std::integral_constant<bool, AllowComments_> allow_comments,
|
| 389 |
|
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
|
409 |
|
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
|
| 390 |
|
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
|
410 |
|
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
|
| 391 |
|
|
411 |
|
|
| 392 |
|
|
412 |
|
|
| 393 |
|
template<bool AllowComments_/*,
|
413 |
|
template<bool AllowComments_/*,
|
| 394 |
|
bool AllowTrailing_, bool AllowBadUTF8_*/>
|
414 |
|
bool AllowTrailing_, bool AllowBadUTF8_*/>
|
| 395 |
|
const char* resume_value(const char* p,
|
415 |
|
const char* resume_value(const char* p,
|
| 396 |
|
std::integral_constant<bool, AllowComments_> allow_comments,
|
416 |
|
std::integral_constant<bool, AllowComments_> allow_comments,
|
| 397 |
|
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
|
417 |
|
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
|
| 398 |
|
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
|
418 |
|
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
|
| 399 |
|
|
419 |
|
|
| 400 |
|
|
420 |
|
|
| 401 |
|
template<bool StackEmpty_, bool AllowComments_/*,
|
421 |
|
template<bool StackEmpty_, bool AllowComments_/*,
|
| 402 |
|
bool AllowTrailing_, bool AllowBadUTF8_*/>
|
422 |
|
bool AllowTrailing_, bool AllowBadUTF8_*/>
|
| 403 |
|
const char* parse_object(const char* p,
|
423 |
|
const char* parse_object(const char* p,
|
| 404 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
424 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
| 405 |
|
std::integral_constant<bool, AllowComments_> allow_comments,
|
425 |
|
std::integral_constant<bool, AllowComments_> allow_comments,
|
| 406 |
|
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
|
426 |
|
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
|
| 407 |
|
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
|
427 |
|
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
|
| 408 |
|
|
428 |
|
|
| 409 |
|
|
429 |
|
|
| 410 |
|
template<bool StackEmpty_, bool AllowComments_/*,
|
430 |
|
template<bool StackEmpty_, bool AllowComments_/*,
|
| 411 |
|
bool AllowTrailing_, bool AllowBadUTF8_*/>
|
431 |
|
bool AllowTrailing_, bool AllowBadUTF8_*/>
|
| 412 |
|
const char* parse_array(const char* p,
|
432 |
|
const char* parse_array(const char* p,
|
| 413 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
433 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
| 414 |
|
std::integral_constant<bool, AllowComments_> allow_comments,
|
434 |
|
std::integral_constant<bool, AllowComments_> allow_comments,
|
| 415 |
|
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
|
435 |
|
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
|
| 416 |
|
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
|
436 |
|
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
|
| 417 |
|
|
437 |
|
|
| 418 |
|
|
438 |
|
|
| 419 |
|
|
439 |
|
|
| 420 |
|
const char* parse_literal(const char* p, Literal literal);
|
440 |
|
const char* parse_literal(const char* p, Literal literal);
|
| 421 |
|
|
441 |
|
|
| 422 |
|
template<bool StackEmpty_, bool IsKey_>
|
442 |
|
template<bool StackEmpty_, bool IsKey_>
|
| 423 |
|
const char* parse_string(const char* p,
|
443 |
|
const char* parse_string(const char* p,
|
| 424 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
444 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
| 425 |
|
std::integral_constant<bool, IsKey_> is_key,
|
445 |
|
std::integral_constant<bool, IsKey_> is_key,
|
| 426 |
|
|
446 |
|
|
| 427 |
|
|
447 |
|
|
| 428 |
|
|
448 |
|
|
| 429 |
|
template<bool StackEmpty_>
|
449 |
|
template<bool StackEmpty_>
|
| 430 |
|
const char* parse_escaped(
|
450 |
|
const char* parse_escaped(
|
| 431 |
|
|
451 |
|
|
| 432 |
|
|
452 |
|
|
| 433 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
453 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
| 434 |
|
|
454 |
|
|
| 435 |
|
|
455 |
|
|
| 436 |
|
|
456 |
|
|
| 437 |
|
template<bool StackEmpty_, char First_, number_precision Numbers_>
|
457 |
|
template<bool StackEmpty_, char First_, number_precision Numbers_>
|
| 438 |
|
const char* parse_number(const char* p,
|
458 |
|
const char* parse_number(const char* p,
|
| 439 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
459 |
|
std::integral_constant<bool, StackEmpty_> stack_empty,
|
| 440 |
|
std::integral_constant<char, First_> first,
|
460 |
|
std::integral_constant<char, First_> first,
|
| 441 |
|
std::integral_constant<number_precision, Numbers_> numbers);
|
461 |
|
std::integral_constant<number_precision, Numbers_> numbers);
|
| 442 |
|
|
462 |
|
|
| 443 |
|
|
463 |
|
|
| 444 |
|
|
464 |
|
|
| 445 |
|
|
465 |
|
|
| 446 |
|
|
466 |
|
|
| 447 |
|
return opt_.max_depth - depth_;
|
467 |
|
return opt_.max_depth - depth_;
|
| 448 |
|
|
468 |
|
|
| 449 |
|
|
469 |
|
|
| 450 |
|
|
470 |
|
|
|
|
|
471 |
+ |
/// Copy constructor (deleted)
|
|
|
|
472 |
+ |
|
|
|
|
473 |
+ |
basic_parser const&) = delete;
|
|
|
|
474 |
+ |
|
|
|
|
475 |
+ |
/// Copy assignment (deleted)
|
|
|
|
476 |
+ |
|
|
|
|
477 |
+ |
basic_parser const&) = delete;
|
|
|
|
478 |
+ |
|
| 451 |
|
|
479 |
|
|
| 452 |
|
|
480 |
|
|
| 453 |
|
All dynamically allocated internal memory is freed.
|
481 |
|
All dynamically allocated internal memory is freed.
|
| 454 |
|
|
482 |
|
|
| 455 |
|
|
483 |
|
|
| 456 |
|
|
484 |
|
|
| 457 |
- |
|
485 |
+ |
this->handler().~Handler()
|
| 458 |
|
|
486 |
|
|
| 459 |
|
|
487 |
|
|
| 460 |
|
|
488 |
|
|
| 461 |
|
|
489 |
|
|
| 462 |
|
|
490 |
|
|
| 463 |
|
|
491 |
|
|
| 464 |
|
|
492 |
|
|
| 465 |
|
|
493 |
|
|
| 466 |
|
~basic_parser() = default;
|
494 |
|
~basic_parser() = default;
|
| 467 |
|
|
495 |
|
|
| 468 |
- |
|
496 |
+ |
|
| 469 |
- |
|
|
|
|
| 470 |
- |
Overload **(1)** constructs the parser with the specified options, with
|
|
|
|
| 471 |
- |
any additional arguments forwarded to the handler's constructor.
|
|
|
|
| 472 |
|
|
497 |
|
|
| 473 |
- |
`basic_parser` is not copyable or movable, so the copy constructor is
|
498 |
+ |
This function constructs the parser with
|
| 474 |
- |
|
499 |
+ |
the specified options, with any additional
|
|
|
|
500 |
+ |
arguments forwarded to the handler's constructor.
|
| 475 |
|
|
501 |
|
|
| 476 |
|
|
502 |
|
|
| 477 |
|
Same as `Handler( std::forward< Args >( args )... )`.
|
503 |
|
Same as `Handler( std::forward< Args >( args )... )`.
|
| 478 |
|
|
504 |
|
|
| 479 |
|
|
505 |
|
|
| 480 |
|
Same as `Handler( std::forward< Args >( args )... )`.
|
506 |
|
Same as `Handler( std::forward< Args >( args )... )`.
|
| 481 |
|
|
507 |
|
|
| 482 |
- |
@param opt Configuration settings for the parser. If this structure is
|
508 |
+ |
@param opt Configuration settings for the parser.
|
| 483 |
- |
default constructed, the parser will accept only standard JSON.
|
509 |
+ |
If this structure is default constructed, the
|
| 484 |
- |
@param args Optional additional arguments forwarded to the handler's
|
510 |
+ |
parser will accept only standard JSON.
|
| 485 |
- |
|
|
|
|
| 486 |
|
|
511 |
|
|
| 487 |
- |
|
512 |
+ |
@param args Optional additional arguments
|
|
|
|
513 |
+ |
forwarded to the handler's constructor.
|
| 488 |
|
|
514 |
|
|
| 489 |
|
|
515 |
|
|
| 490 |
|
|
516 |
|
|
| 491 |
|
|
517 |
|
|
| 492 |
|
parse_options const& opt,
|
518 |
|
parse_options const& opt,
|
| 493 |
|
|
519 |
|
|
| 494 |
- |
|
|
|
|
| 495 |
- |
|
|
|
|
| 496 |
- |
basic_parser const&) = delete;
|
|
|
|
| 497 |
- |
|
|
|
|
| 498 |
- |
|
|
|
|
| 499 |
- |
|
|
|
|
| 500 |
- |
|
|
|
|
| 501 |
- |
This type cannot be copied or moved. The copy assignment is deleted.
|
|
|
|
| 502 |
- |
|
|
|
|
| 503 |
- |
|
|
|
|
| 504 |
- |
basic_parser const&) = delete;
|
|
|
|
| 505 |
- |
|
|
|
|
| 506 |
|
|
520 |
|
|
| 507 |
|
/** Return a reference to the handler.
|
521 |
|
/** Return a reference to the handler.
|
| 508 |
|
|
522 |
|
|
| 509 |
|
This function provides access to the constructed
|
523 |
|
This function provides access to the constructed
|
| 510 |
|
instance of the handler owned by the parser.
|
524 |
|
instance of the handler owned by the parser.
|
| 511 |
|
|
525 |
|
|
| 512 |
|
|
526 |
|
|
| 513 |
|
|
527 |
|
|
| 514 |
|
|
528 |
|
|
| 515 |
|
|
529 |
|
|
| 516 |
- |
|
|
|
|
| 517 |
- |
|
|
|
|
| 518 |
|
|
530 |
|
|
| 519 |
|
|
531 |
|
|
| 520 |
|
|
532 |
|
|
| 521 |
|
|
533 |
|
|
| 522 |
|
|
534 |
|
|
| 523 |
|
|
535 |
|
|
| 524 |
|
|
536 |
|
|
| 525 |
|
|
537 |
|
|
|
|
|
538 |
+ |
/** Return a reference to the handler.
|
|
|
|
539 |
+ |
|
|
|
|
540 |
+ |
This function provides access to the constructed
|
|
|
|
541 |
+ |
instance of the handler owned by the parser.
|
|
|
|
542 |
+ |
|
|
|
|
543 |
+ |
|
|
|
|
544 |
+ |
|
|
|
|
545 |
+ |
|
|
|
|
546 |
+ |
|
|
|
|
547 |
+ |
|
|
|
|
548 |
+ |
|
| 526 |
|
|
549 |
|
|
| 527 |
|
|
550 |
|
|
| 528 |
|
|
551 |
|
|
| 529 |
|
|
552 |
|
|
| 530 |
- |
|
|
|
|
| 531 |
|
|
553 |
|
|
| 532 |
|
|
554 |
|
|
| 533 |
|
/** Return the last error.
|
555 |
|
/** Return the last error.
|
| 534 |
|
|
556 |
|
|
| 535 |
|
This returns the last error code which
|
557 |
|
This returns the last error code which
|
| 536 |
|
was generated in the most recent call
|
558 |
|
was generated in the most recent call
|
| 537 |
|
|
559 |
|
|
| 538 |
|
|
560 |
|
|
| 539 |
|
|
561 |
|
|
| 540 |
|
|
562 |
|
|
| 541 |
|
|
563 |
|
|
| 542 |
|
|
564 |
|
|
| 543 |
|
|
565 |
|
|
| 544 |
|
|
566 |
|
|
| 545 |
|
|
567 |
|
|
| 546 |
|
last_error() const noexcept
|
568 |
|
last_error() const noexcept
|
| 547 |
|
|
569 |
|
|
| 548 |
|
|
570 |
|
|
| 549 |
|
|
571 |
|
|
| 550 |
|
|
572 |
|
|
| 551 |
- |
/** Check if a complete JSON text has been parsed.
|
573 |
+ |
/** Return true if a complete JSON has been parsed.
|
| 552 |
|
|
574 |
|
|
| 553 |
- |
This function returns `true` when all of these conditions are met:
|
575 |
+ |
This function returns `true` when all of these
|
|
|
|
576 |
+ |
|
| 554 |
|
|
577 |
|
|
| 555 |
- |
@li A complete serialized JSON text has been presented to the parser,
|
578 |
+ |
@li A complete serialized JSON has been
|
| 556 |
- |
|
579 |
+ |
presented to the parser, and
|
| 557 |
- |
@li No error or exception has occurred since the parser was
|
580 |
+ |
|
| 558 |
- |
constructed, or since the last call to @ref reset.
|
581 |
+ |
@li No error or exception has occurred since the
|
|
|
|
582 |
+ |
parser was constructed, or since the last call
|
|
|
|
583 |
+ |
|
| 559 |
|
|
584 |
|
|
| 560 |
|
|
585 |
|
|
| 561 |
|
|
586 |
|
|
| 562 |
|
|
587 |
|
|
| 563 |
|
|
588 |
|
|
| 564 |
|
|
589 |
|
|
| 565 |
|
|
590 |
|
|
| 566 |
|
|
591 |
|
|
| 567 |
|
|
592 |
|
|
| 568 |
|
|
593 |
|
|
| 569 |
|
|
594 |
|
|
| 570 |
|
|
595 |
|
|
| 571 |
|
|
596 |
|
|
| 572 |
|
/** Reset the state, to parse a new document.
|
597 |
|
/** Reset the state, to parse a new document.
|
| 573 |
|
|
598 |
|
|
| 574 |
|
This function discards the current parsing
|
599 |
|
This function discards the current parsing
|
| 575 |
|
state, to prepare for parsing a new document.
|
600 |
|
state, to prepare for parsing a new document.
|
| 576 |
|
Dynamically allocated temporary memory used
|
601 |
|
Dynamically allocated temporary memory used
|
| 577 |
|
by the implementation is not deallocated.
|
602 |
|
by the implementation is not deallocated.
|
| 578 |
|
|
603 |
|
|
| 579 |
|
|
604 |
|
|
| 580 |
|
|
605 |
|
|
| 581 |
|
|
606 |
|
|
| 582 |
|
|
607 |
|
|
| 583 |
|
|
608 |
|
|
| 584 |
|
|
609 |
|
|
| 585 |
|
|
610 |
|
|
| 586 |
|
|
611 |
|
|
| 587 |
|
|
612 |
|
|
| 588 |
|
/** Indicate a parsing failure.
|
613 |
|
/** Indicate a parsing failure.
|
| 589 |
|
|
614 |
|
|
| 590 |
- |
This changes the state of the parser to indicate that the parse has
|
615 |
+ |
This changes the state of the parser to indicate
|
| 591 |
- |
failed. A parser implementation can use this to fail the parser if
|
616 |
+ |
that the parse has failed. A parser implementation
|
| 592 |
- |
needed due to external inputs.
|
617 |
+ |
can use this to fail the parser if needed due to
|
|
|
|
618 |
+ |
|
| 593 |
|
|
619 |
|
|
| 594 |
- |
|
620 |
+ |
|
| 595 |
- |
If `! ec.failed()`, an implementation-defined error code that indicates
|
621 |
+ |
|
| 596 |
- |
failure will be stored instead.
|
622 |
+ |
If `!ec`, the stored error code is unspecified.
|
| 597 |
|
|
623 |
|
|
| 598 |
|
|
624 |
|
|
| 599 |
|
|
625 |
|
|
| 600 |
|
|
626 |
|
|
| 601 |
|
|
627 |
|
|
| 602 |
|
|
628 |
|
|
| 603 |
|
|
629 |
|
|
| 604 |
- |
@param ec The error code to set.
|
630 |
+ |
@param ec The error code to set. If the code does
|
|
|
|
631 |
+ |
not indicate failure, an implementation-defined
|
|
|
|
632 |
+ |
error code that indicates failure will be stored
|
|
|
|
633 |
+ |
|
| 605 |
|
|
634 |
|
|
| 606 |
|
|
635 |
|
|
| 607 |
|
fail(system::error_code ec) noexcept;
|
636 |
|
fail(system::error_code ec) noexcept;
|
| 608 |
|
|
637 |
|
|
| 609 |
- |
/** Parse some of input characters as JSON, incrementally.
|
638 |
+ |
/** Parse some of an input string as JSON, incrementally.
|
| 610 |
|
|
639 |
|
|
| 611 |
- |
This function parses the JSON text in the specified buffer, calling the
|
640 |
+ |
This function parses the JSON in the specified
|
| 612 |
- |
handler to emit each SAX parsing event. The parse proceeds from the
|
641 |
+ |
buffer, calling the handler to emit each SAX
|
| 613 |
- |
current state, which is at the beginning of a new JSON or in the middle
|
642 |
+ |
parsing event. The parse proceeds from the
|
| 614 |
- |
of the current JSON if any characters were already parsed.
|
643 |
+ |
current state, which is at the beginning of a
|
|
|
|
644 |
+ |
new JSON or in the middle of the current JSON
|
|
|
|
645 |
+ |
if any characters were already parsed.
|
|
|
|
646 |
+ |
|
|
|
|
647 |
+ |
The characters in the buffer are processed
|
|
|
|
648 |
+ |
starting from the beginning, until one of the
|
|
|
|
649 |
+ |
following conditions is met:
|
| 615 |
|
|
650 |
|
|
| 616 |
- |
The characters in the buffer are processed starting from the beginning,
|
651 |
+ |
@li All of the characters in the buffer
|
| 617 |
- |
until one of the following conditions is met:
|
652 |
+ |
|
|
|
|
653 |
+ |
|
|
|
|
654 |
+ |
@li Some of the characters in the buffer
|
|
|
|
655 |
+ |
have been parsed and the JSON is complete, or
|
| 618 |
- |
@li All of the characters in the buffer have been parsed, or
|
|
|
|
| 619 |
- |
@li Some of the characters in the buffer have been parsed and the JSON
|
|
|
|
| 620 |
- |
|
|
|
|
| 621 |
|
|
656 |
|
|
| 622 |
|
@li A parsing error occurs.
|
657 |
|
@li A parsing error occurs.
|
| 623 |
|
|
658 |
|
|
| 624 |
- |
The supplied buffer does not need to contain the entire JSON.
|
659 |
+ |
The supplied buffer does not need to contain the
|
| 625 |
- |
Subsequent calls can provide more serialized data, allowing JSON to be
|
660 |
+ |
entire JSON. Subsequent calls can provide more
|
| 626 |
- |
processed incrementally. The end of the serialized JSON can be
|
661 |
+ |
serialized data, allowing JSON to be processed
|
| 627 |
- |
indicated by passing `more = false`.
|
662 |
+ |
incrementally. The end of the serialized JSON
|
|
|
|
663 |
+ |
can be indicated by passing `more = false`.
|
| 628 |
|
|
664 |
|
|
| 629 |
|
|
665 |
|
|
| 630 |
|
|
666 |
|
|
| 631 |
|
|
667 |
|
|
| 632 |
|
|
668 |
|
|
| 633 |
- |
Basic guarantee. Calls to the handler may throw.
|
669 |
+ |
|
| 634 |
- |
|
670 |
+ |
Calls to the handler may throw.
|
| 635 |
- |
Upon error or exception, subsequent calls will fail until @ref reset
|
671 |
+ |
Upon error or exception, subsequent calls will
|
| 636 |
- |
is called to parse a new JSON.
|
672 |
+ |
fail until @ref reset is called to parse a new JSON.
|
| 637 |
|
|
673 |
|
|
| 638 |
|
@return The number of characters successfully
|
674 |
|
@return The number of characters successfully
|
| 639 |
|
parsed, which may be smaller than `size`.
|
675 |
|
parsed, which may be smaller than `size`.
|
| 640 |
|
|
676 |
|
|
| 641 |
- |
@param more `true` if there are possibly more buffers in the current
|
677 |
+ |
@param more `true` if there are possibly more
|
| 642 |
- |
|
678 |
+ |
buffers in the current JSON, otherwise `false`.
|
| 643 |
|
|
679 |
|
|
| 644 |
- |
@param data A pointer to a buffer of `size` characters to parse.
|
680 |
+ |
@param data A pointer to a buffer of `size`
|
|
|
|
681 |
+ |
|
| 645 |
|
|
682 |
|
|
| 646 |
- |
@param size The number of characters pointed to by `data`.
|
683 |
+ |
@param size The number of characters pointed to
|
|
|
|
684 |
+ |
|
| 647 |
|
|
685 |
|
|
| 648 |
- |
|
|
|
|
| 649 |
- |
|
|
|
|
| 650 |
|
@param ec Set to the error, if any occurred.
|
686 |
|
@param ec Set to the error, if any occurred.
|
| 651 |
|
|
687 |
|
|
|
|
|
688 |
+ |
|
| 652 |
|
|
689 |
|
|
| 653 |
|
|
690 |
|
|
| 654 |
|
|
691 |
|
|
| 655 |
|
|
692 |
|
|
| 656 |
|
|
693 |
|
|
| 657 |
|
|
694 |
|
|
| 658 |
|
|
695 |
|
|
| 659 |
|
|
696 |
|
|
| 660 |
|
|
697 |
|
|
| 661 |
|
|
698 |
|
|
| 662 |
|
|
699 |
|
|
| 663 |
|
|
700 |
|
|
| 664 |
|
|
701 |
|
|
| 665 |
- |
|
702 |
+ |
|
| 666 |
|
|
703 |
|
|
| 667 |
|
|
704 |
|
|
| 668 |
|
|
705 |
|
|
| 669 |
|
|
706 |
|
|
| 670 |
|
|
707 |
|
|
| 671 |
|
|
708 |
|
|