| 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_DETAIL_PARSE_INTO_HPP
|
11 |
|
#ifndef BOOST_JSON_DETAIL_PARSE_INTO_HPP
|
| 12 |
|
#define BOOST_JSON_DETAIL_PARSE_INTO_HPP
|
12 |
|
#define BOOST_JSON_DETAIL_PARSE_INTO_HPP
|
| 13 |
|
|
13 |
|
|
| 14 |
|
#include <boost/json/detail/config.hpp>
|
14 |
|
#include <boost/json/detail/config.hpp>
|
| 15 |
|
|
15 |
|
|
| 16 |
|
#include <boost/json/error.hpp>
|
16 |
|
#include <boost/json/error.hpp>
|
| 17 |
|
#include <boost/json/conversion.hpp>
|
17 |
|
#include <boost/json/conversion.hpp>
|
| 18 |
|
#include <boost/describe/enum_from_string.hpp>
|
18 |
|
#include <boost/describe/enum_from_string.hpp>
|
| 19 |
|
|
19 |
|
|
| 20 |
|
|
20 |
|
|
| 21 |
|
|
21 |
|
|
| 22 |
|
|
22 |
|
|
| 23 |
|
* This file contains the majority of parse_into functionality, specifically
|
23 |
|
* This file contains the majority of parse_into functionality, specifically
|
| 24 |
|
* the implementation of dedicated handlers for different generic categories of
|
24 |
|
* the implementation of dedicated handlers for different generic categories of
|
| 25 |
|
|
25 |
|
|
| 26 |
|
|
26 |
|
|
| 27 |
|
* At the core of parse_into is the specialisation basic_parser<
|
27 |
|
* At the core of parse_into is the specialisation basic_parser<
|
| 28 |
|
* detail::into_handler<T> >. detail::into_handler<T> is a handler for
|
28 |
|
* detail::into_handler<T> >. detail::into_handler<T> is a handler for
|
| 29 |
|
* basic_parser. It directly handles events on_comment_part and on_comment (by
|
29 |
|
* basic_parser. It directly handles events on_comment_part and on_comment (by
|
| 30 |
|
* ignoring them), on_document_begin (by enabling the nested dedicated
|
30 |
|
* ignoring them), on_document_begin (by enabling the nested dedicated
|
| 31 |
|
* handler), and on_document_end (by disabling the nested handler).
|
31 |
|
* handler), and on_document_end (by disabling the nested handler).
|
| 32 |
|
|
32 |
|
|
| 33 |
|
* Every other event is handled by the nested handler, which has the type
|
33 |
|
* Every other event is handled by the nested handler, which has the type
|
| 34 |
|
* get_handler< T, into_handler<T> >. The second parameter is the parent
|
34 |
|
* get_handler< T, into_handler<T> >. The second parameter is the parent
|
| 35 |
|
* handler (in this case, it's the top handler, into_handler<T>). The type is
|
35 |
|
* handler (in this case, it's the top handler, into_handler<T>). The type is
|
| 36 |
|
* actually an alias to class template converting_handler, which has a separate
|
36 |
|
* actually an alias to class template converting_handler, which has a separate
|
| 37 |
|
* specialisation for every conversion category from the list of generic
|
37 |
|
* specialisation for every conversion category from the list of generic
|
| 38 |
|
* conversion categories (e.g. sequence_conversion_tag, tuple_conversion_tag,
|
38 |
|
* conversion categories (e.g. sequence_conversion_tag, tuple_conversion_tag,
|
| 39 |
|
* etc.) Instantiations of the template store a pointer to the parent handler
|
39 |
|
* etc.) Instantiations of the template store a pointer to the parent handler
|
| 40 |
|
* and a pointer to the value T.
|
40 |
|
* and a pointer to the value T.
|
| 41 |
|
|
41 |
|
|
| 42 |
|
* The nested handler handles specific parser events by setting error_code to
|
42 |
|
* The nested handler handles specific parser events by setting error_code to
|
| 43 |
|
* an appropriate value, if it receives an event it isn't supposed to handle
|
43 |
|
* an appropriate value, if it receives an event it isn't supposed to handle
|
| 44 |
|
* (e.g. a number handler getting an on_string event), and also updates the
|
44 |
|
* (e.g. a number handler getting an on_string event), and also updates the
|
| 45 |
|
* value when appropriate. Note that they never need to handle on_comment_part,
|
45 |
|
* value when appropriate. Note that they never need to handle on_comment_part,
|
| 46 |
|
* on_comment, on_document_begin, and on_document_end events, as those are
|
46 |
|
* on_comment, on_document_begin, and on_document_end events, as those are
|
| 47 |
|
* always handled by the top handler into_handler<T>.
|
47 |
|
* always handled by the top handler into_handler<T>.
|
| 48 |
|
|
48 |
|
|
| 49 |
|
* When the nested handler receives an event that completes the current value,
|
49 |
|
* When the nested handler receives an event that completes the current value,
|
| 50 |
|
* it is supposed to call its parent's signal_value member function. This is
|
50 |
|
* it is supposed to call its parent's signal_value member function. This is
|
| 51 |
|
* necessary for correct handling of composite types (e.g. sequences).
|
51 |
|
* necessary for correct handling of composite types (e.g. sequences).
|
| 52 |
|
|
52 |
|
|
| 53 |
|
* Finally, nested handlers should always call parent's signal_end member
|
53 |
|
* Finally, nested handlers should always call parent's signal_end member
|
| 54 |
|
* function if they don't handle on_array_end themselves. This is necessary
|
54 |
|
* function if they don't handle on_array_end themselves. This is necessary
|
| 55 |
|
* to correctly handle nested composites (e.g. sequences inside sequences).
|
55 |
|
* to correctly handle nested composites (e.g. sequences inside sequences).
|
| 56 |
|
* signal_end can return false and set error state when the containing parser
|
56 |
|
* signal_end can return false and set error state when the containing parser
|
| 57 |
|
* requires more elements.
|
57 |
|
* requires more elements.
|
| 58 |
|
|
58 |
|
|
| 59 |
|
* converting_handler instantiations for composite categories of types have
|
59 |
|
* converting_handler instantiations for composite categories of types have
|
| 60 |
|
* their own nested handlers, to which they themselves delegate events. For
|
60 |
|
* their own nested handlers, to which they themselves delegate events. For
|
| 61 |
|
* complex types you will get a tree of handlers with into_handler<T> as the
|
61 |
|
* complex types you will get a tree of handlers with into_handler<T> as the
|
| 62 |
|
* root and handlers for scalars as leaves.
|
62 |
|
* root and handlers for scalars as leaves.
|
| 63 |
|
|
63 |
|
|
| 64 |
|
* To reiterate, only into_handler has to handle on_comment_part, on_comment,
|
64 |
|
* To reiterate, only into_handler has to handle on_comment_part, on_comment,
|
| 65 |
|
* on_document_begin, and on_document_end; only handlers for composites and
|
65 |
|
* on_document_begin, and on_document_end; only handlers for composites and
|
| 66 |
|
* into_handler has to provide signal_value and signal_end; all handlers
|
66 |
|
* into_handler has to provide signal_value and signal_end; all handlers
|
| 67 |
|
* except for into_handler have to call their parent's signal_end from
|
67 |
|
* except for into_handler have to call their parent's signal_end from
|
| 68 |
|
* their on_array_begin, if they don't handle it themselves; once a handler
|
68 |
|
* their on_array_begin, if they don't handle it themselves; once a handler
|
| 69 |
|
* receives an event that finishes its current value, it should call its
|
69 |
|
* receives an event that finishes its current value, it should call its
|
| 70 |
|
|
70 |
|
|
| 71 |
|
|
71 |
|
|
| 72 |
|
|
72 |
|
|
| 73 |
|
|
73 |
|
|
| 74 |
|
|
74 |
|
|
| 75 |
|
|
75 |
|
|
| 76 |
|
|
76 |
|
|
| 77 |
|
template< class Impl, class T, class Parent >
|
77 |
|
template< class Impl, class T, class Parent >
|
| 78 |
|
class converting_handler;
|
78 |
|
class converting_handler;
|
| 79 |
|
|
79 |
|
|
| 80 |
|
|
80 |
|
|
| 81 |
|
template< class V, class P >
|
81 |
|
template< class V, class P >
|
| 82 |
|
using get_handler = converting_handler< generic_conversion_category<V>, V, P >;
|
82 |
|
using get_handler = converting_handler< generic_conversion_category<V>, V, P >;
|
| 83 |
|
|
83 |
|
|
| 84 |
|
template<error E> class handler_error_base
|
84 |
|
template<error E> class handler_error_base
|
| 85 |
|
|
85 |
|
|
| 86 |
|
|
86 |
|
|
| 87 |
|
|
87 |
|
|
| 88 |
|
handler_error_base() = default;
|
88 |
|
handler_error_base() = default;
|
| 89 |
|
|
89 |
|
|
| 90 |
|
handler_error_base( handler_error_base const& ) = delete;
|
90 |
|
handler_error_base( handler_error_base const& ) = delete;
|
| 91 |
|
handler_error_base& operator=( handler_error_base const& ) = delete;
|
91 |
|
handler_error_base& operator=( handler_error_base const& ) = delete;
|
| 92 |
|
|
92 |
|
|
| 93 |
|
|
93 |
|
|
| 94 |
|
|
94 |
|
|
| 95 |
|
bool on_object_begin( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
95 |
|
bool on_object_begin( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 96 |
|
bool on_array_begin( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
96 |
|
bool on_array_begin( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 97 |
|
bool on_array_end( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
97 |
|
bool on_array_end( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 98 |
|
bool on_string_part( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
98 |
|
bool on_string_part( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 99 |
|
bool on_string( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
99 |
|
bool on_string( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 100 |
|
bool on_number_part( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
100 |
|
bool on_number_part( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 101 |
|
bool on_int64( system::error_code& ec, std::int64_t ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
101 |
|
bool on_int64( system::error_code& ec, std::int64_t ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 102 |
|
bool on_uint64( system::error_code& ec, std::uint64_t ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
102 |
|
bool on_uint64( system::error_code& ec, std::uint64_t ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 103 |
|
bool on_double( system::error_code& ec, double ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
103 |
|
bool on_double( system::error_code& ec, double ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 104 |
|
bool on_bool( system::error_code& ec, bool ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
104 |
|
bool on_bool( system::error_code& ec, bool ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 105 |
|
bool on_null( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
105 |
|
bool on_null( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 106 |
|
|
106 |
|
|
| 107 |
|
|
107 |
|
|
| 108 |
|
// parses that can't handle this would fail at on_object_begin
|
108 |
|
// parses that can't handle this would fail at on_object_begin
|
| 109 |
|
bool on_object_end( system::error_code& ) { BOOST_ASSERT( false ); return false; }
|
109 |
|
bool on_object_end( system::error_code& ) { BOOST_ASSERT( false ); return false; }
|
| 110 |
|
bool on_key_part( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
110 |
|
bool on_key_part( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 111 |
|
bool on_key( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
111 |
|
bool on_key( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
| 112 |
|
|
112 |
|
|
| 113 |
|
|
113 |
|
|
| 114 |
|
|
114 |
|
|
| 115 |
|
template< class P, error E >
|
115 |
|
template< class P, error E >
|
| 116 |
|
|
116 |
|
|
| 117 |
|
: public handler_error_base<E>
|
117 |
|
: public handler_error_base<E>
|
| 118 |
|
|
118 |
|
|
| 119 |
|
|
119 |
|
|
| 120 |
|
|
120 |
|
|
| 121 |
|
|
121 |
|
|
| 122 |
|
|
122 |
|
|
| 123 |
|
scalar_handler(scalar_handler const&) = delete;
|
123 |
|
scalar_handler(scalar_handler const&) = delete;
|
| 124 |
|
scalar_handler& operator=(scalar_handler const&) = delete;
|
124 |
|
scalar_handler& operator=(scalar_handler const&) = delete;
|
| 125 |
|
|
125 |
|
|
| 126 |
|
scalar_handler(P* p): parent_( p )
|
126 |
|
scalar_handler(P* p): parent_( p )
|
| 127 |
|
|
127 |
|
|
| 128 |
|
|
128 |
|
|
| 129 |
|
bool on_array_end( system::error_code& ec )
|
129 |
|
bool on_array_end( system::error_code& ec )
|
| 130 |
|
|
130 |
|
|
| 131 |
|
return parent_->signal_end(ec);
|
131 |
|
return parent_->signal_end(ec);
|
| 132 |
|
|
132 |
|
|
| 133 |
|
|
133 |
|
|
| 134 |
|
|
134 |
|
|
| 135 |
|
template< class D, class V, class P, error E >
|
135 |
|
template< class D, class V, class P, error E >
|
| 136 |
|
|
136 |
|
|
| 137 |
|
|
137 |
|
|
| 138 |
|
|
138 |
|
|
| 139 |
|
using inner_handler_type = get_handler<V, D>;
|
139 |
|
using inner_handler_type = get_handler<V, D>;
|
| 140 |
|
|
140 |
|
|
| 141 |
|
|
141 |
|
|
| 142 |
|
#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
|
142 |
|
#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
|
| 143 |
|
# pragma GCC diagnostic push
|
143 |
|
# pragma GCC diagnostic push
|
| 144 |
|
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
144 |
|
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
| 145 |
|
|
145 |
|
|
| 146 |
|
|
146 |
|
|
| 147 |
|
inner_handler_type inner_;
|
147 |
|
inner_handler_type inner_;
|
| 148 |
|
bool inner_active_ = false;
|
148 |
|
bool inner_active_ = false;
|
| 149 |
|
|
149 |
|
|
| 150 |
|
|
150 |
|
|
| 151 |
|
composite_handler( composite_handler const& ) = delete;
|
151 |
|
composite_handler( composite_handler const& ) = delete;
|
| 152 |
|
composite_handler& operator=( composite_handler const& ) = delete;
|
152 |
|
composite_handler& operator=( composite_handler const& ) = delete;
|
| 153 |
|
|
153 |
|
|
| 154 |
|
composite_handler( P* p )
|
154 |
|
composite_handler( P* p )
|
| 155 |
|
: parent_(p), inner_( &next_value_, static_cast<D*>(this) )
|
155 |
|
: parent_(p), inner_( &next_value_, static_cast<D*>(this) )
|
| 156 |
|
|
156 |
|
|
| 157 |
|
#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
|
157 |
|
#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
|
| 158 |
|
# pragma GCC diagnostic pop
|
158 |
|
# pragma GCC diagnostic pop
|
| 159 |
|
|
159 |
|
|
| 160 |
|
|
160 |
|
|
| 161 |
|
bool signal_end(system::error_code& ec)
|
161 |
|
bool signal_end(system::error_code& ec)
|
| 162 |
|
|
162 |
|
|
| 163 |
|
|
163 |
|
|
| 164 |
|
return parent_->signal_value(ec);
|
164 |
|
return parent_->signal_value(ec);
|
| 165 |
|
|
165 |
|
|
| 166 |
|
|
166 |
|
|
| 167 |
|
#define BOOST_JSON_INVOKE_INNER(f) \
|
167 |
|
#define BOOST_JSON_INVOKE_INNER(f) \
|
| 168 |
|
|
168 |
|
|
| 169 |
|
BOOST_JSON_FAIL(ec, E); \
|
169 |
|
BOOST_JSON_FAIL(ec, E); \
|
| 170 |
|
|
170 |
|
|
| 171 |
|
|
171 |
|
|
| 172 |
|
|
172 |
|
|
| 173 |
|
|
173 |
|
|
| 174 |
|
|
174 |
|
|
| 175 |
|
bool on_object_begin( system::error_code& ec )
|
175 |
|
bool on_object_begin( system::error_code& ec )
|
| 176 |
|
|
176 |
|
|
| 177 |
|
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
177 |
|
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
| 178 |
|
|
178 |
|
|
| 179 |
|
|
179 |
|
|
| 180 |
|
bool on_object_end( system::error_code& ec )
|
180 |
|
bool on_object_end( system::error_code& ec )
|
| 181 |
|
|
181 |
|
|
| 182 |
|
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
182 |
|
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
| 183 |
|
|
183 |
|
|
| 184 |
|
|
184 |
|
|
| 185 |
|
bool on_array_begin( system::error_code& ec )
|
185 |
|
bool on_array_begin( system::error_code& ec )
|
| 186 |
|
|
186 |
|
|
| 187 |
|
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
187 |
|
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
| 188 |
|
|
188 |
|
|
| 189 |
|
|
189 |
|
|
| 190 |
|
bool on_array_end( system::error_code& ec )
|
190 |
|
bool on_array_end( system::error_code& ec )
|
| 191 |
|
|
191 |
|
|
| 192 |
|
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
192 |
|
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
| 193 |
|
|
193 |
|
|
| 194 |
|
|
194 |
|
|
| 195 |
|
bool on_key_part( system::error_code& ec, string_view sv )
|
195 |
|
bool on_key_part( system::error_code& ec, string_view sv )
|
| 196 |
|
|
196 |
|
|
| 197 |
|
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
197 |
|
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
| 198 |
|
|
198 |
|
|
| 199 |
|
|
199 |
|
|
| 200 |
|
bool on_key( system::error_code& ec, string_view sv )
|
200 |
|
bool on_key( system::error_code& ec, string_view sv )
|
| 201 |
|
|
201 |
|
|
| 202 |
|
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
202 |
|
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
| 203 |
|
|
203 |
|
|
| 204 |
|
|
204 |
|
|
| 205 |
|
bool on_string_part( system::error_code& ec, string_view sv )
|
205 |
|
bool on_string_part( system::error_code& ec, string_view sv )
|
| 206 |
|
|
206 |
|
|
| 207 |
|
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
207 |
|
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
| 208 |
|
|
208 |
|
|
| 209 |
|
|
209 |
|
|
| 210 |
|
bool on_string( system::error_code& ec, string_view sv )
|
210 |
|
bool on_string( system::error_code& ec, string_view sv )
|
| 211 |
|
|
211 |
|
|
| 212 |
|
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
212 |
|
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
| 213 |
|
|
213 |
|
|
| 214 |
|
|
214 |
|
|
| 215 |
|
bool on_number_part( system::error_code& ec )
|
215 |
|
bool on_number_part( system::error_code& ec )
|
| 216 |
|
|
216 |
|
|
| 217 |
|
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
217 |
|
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
| 218 |
|
|
218 |
|
|
| 219 |
|
|
219 |
|
|
| 220 |
|
bool on_int64( system::error_code& ec, std::int64_t v )
|
220 |
|
bool on_int64( system::error_code& ec, std::int64_t v )
|
| 221 |
|
|
221 |
|
|
| 222 |
|
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
222 |
|
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
| 223 |
|
|
223 |
|
|
| 224 |
|
|
224 |
|
|
| 225 |
|
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
225 |
|
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
| 226 |
|
|
226 |
|
|
| 227 |
|
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
227 |
|
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
| 228 |
|
|
228 |
|
|
| 229 |
|
|
229 |
|
|
| 230 |
|
bool on_double( system::error_code& ec, double v )
|
230 |
|
bool on_double( system::error_code& ec, double v )
|
| 231 |
|
|
231 |
|
|
| 232 |
|
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
232 |
|
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
| 233 |
|
|
233 |
|
|
| 234 |
|
|
234 |
|
|
| 235 |
|
bool on_bool( system::error_code& ec, bool v )
|
235 |
|
bool on_bool( system::error_code& ec, bool v )
|
| 236 |
|
|
236 |
|
|
| 237 |
|
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
237 |
|
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
| 238 |
|
|
238 |
|
|
| 239 |
|
|
239 |
|
|
| 240 |
|
bool on_null( system::error_code& ec )
|
240 |
|
bool on_null( system::error_code& ec )
|
| 241 |
|
|
241 |
|
|
| 242 |
|
BOOST_JSON_INVOKE_INNER( on_null(ec) );
|
242 |
|
BOOST_JSON_INVOKE_INNER( on_null(ec) );
|
| 243 |
|
|
243 |
|
|
| 244 |
|
|
244 |
|
|
| 245 |
|
#undef BOOST_JSON_INVOKE_INNER
|
245 |
|
#undef BOOST_JSON_INVOKE_INNER
|
| 246 |
|
|
246 |
|
|
| 247 |
|
|
247 |
|
|
| 248 |
|
|
248 |
|
|
| 249 |
|
|
249 |
|
|
| 250 |
|
typename std::enable_if<std::is_signed<V>::value, int>::type = 0>
|
250 |
|
typename std::enable_if<std::is_signed<V>::value, int>::type = 0>
|
| 251 |
|
bool integral_in_range( std::int64_t v )
|
251 |
|
bool integral_in_range( std::int64_t v )
|
| 252 |
|
|
252 |
|
|
| 253 |
|
return v >= (std::numeric_limits<V>::min)() && v <= (std::numeric_limits<V>::max)();
|
253 |
|
return v >= (std::numeric_limits<V>::min)() && v <= (std::numeric_limits<V>::max)();
|
| 254 |
|
|
254 |
|
|
| 255 |
|
|
255 |
|
|
| 256 |
|
|
256 |
|
|
| 257 |
|
typename std::enable_if<!std::is_signed<V>::value, int>::type = 0>
|
257 |
|
typename std::enable_if<!std::is_signed<V>::value, int>::type = 0>
|
| 258 |
|
bool integral_in_range( std::int64_t v )
|
258 |
|
bool integral_in_range( std::int64_t v )
|
| 259 |
|
|
259 |
|
|
| 260 |
|
return v >= 0 && static_cast<std::uint64_t>( v ) <= (std::numeric_limits<V>::max)();
|
260 |
|
return v >= 0 && static_cast<std::uint64_t>( v ) <= (std::numeric_limits<V>::max)();
|
| 261 |
|
|
261 |
|
|
| 262 |
|
|
262 |
|
|
| 263 |
|
|
263 |
|
|
| 264 |
|
bool integral_in_range( std::uint64_t v )
|
264 |
|
bool integral_in_range( std::uint64_t v )
|
| 265 |
|
|
265 |
|
|
| 266 |
|
return v <= static_cast<typename std::make_unsigned<V>::type>( (std::numeric_limits<V>::max)() );
|
266 |
|
return v <= static_cast<typename std::make_unsigned<V>::type>( (std::numeric_limits<V>::max)() );
|
| 267 |
|
|
267 |
|
|
| 268 |
|
|
268 |
|
|
| 269 |
|
template< class V, class P >
|
269 |
|
template< class V, class P >
|
| 270 |
|
class converting_handler<integral_conversion_tag, V, P>
|
270 |
|
class converting_handler<integral_conversion_tag, V, P>
|
| 271 |
|
: public scalar_handler<P, error::not_integer>
|
271 |
|
: public scalar_handler<P, error::not_integer>
|
| 272 |
|
|
272 |
|
|
| 273 |
|
|
273 |
|
|
| 274 |
|
|
274 |
|
|
| 275 |
|
|
275 |
|
|
| 276 |
|
|
276 |
|
|
| 277 |
|
converting_handler( V* v, P* p )
|
277 |
|
converting_handler( V* v, P* p )
|
| 278 |
|
: converting_handler::scalar_handler(p)
|
278 |
|
: converting_handler::scalar_handler(p)
|
| 279 |
|
|
279 |
|
|
| 280 |
|
|
280 |
|
|
| 281 |
|
|
281 |
|
|
| 282 |
|
bool on_number_part( system::error_code& )
|
282 |
|
bool on_number_part( system::error_code& )
|
| 283 |
|
|
283 |
|
|
| 284 |
|
|
284 |
|
|
| 285 |
|
|
285 |
|
|
| 286 |
|
|
286 |
|
|
| 287 |
|
bool on_int64(system::error_code& ec, std::int64_t v)
|
287 |
|
bool on_int64(system::error_code& ec, std::int64_t v)
|
| 288 |
|
|
288 |
|
|
| 289 |
|
if( !integral_in_range<V>( v ) )
|
289 |
|
if( !integral_in_range<V>( v ) )
|
| 290 |
|
|
290 |
|
|
| 291 |
|
BOOST_JSON_FAIL( ec, error::not_exact );
|
291 |
|
BOOST_JSON_FAIL( ec, error::not_exact );
|
| 292 |
|
|
292 |
|
|
| 293 |
|
|
293 |
|
|
| 294 |
|
|
294 |
|
|
| 295 |
|
*value_ = static_cast<V>( v );
|
295 |
|
*value_ = static_cast<V>( v );
|
| 296 |
|
return this->parent_->signal_value(ec);
|
296 |
|
return this->parent_->signal_value(ec);
|
| 297 |
|
|
297 |
|
|
| 298 |
|
|
298 |
|
|
| 299 |
|
bool on_uint64(system::error_code& ec, std::uint64_t v)
|
299 |
|
bool on_uint64(system::error_code& ec, std::uint64_t v)
|
| 300 |
|
|
300 |
|
|
| 301 |
|
if( !integral_in_range<V>(v) )
|
301 |
|
if( !integral_in_range<V>(v) )
|
| 302 |
|
|
302 |
|
|
| 303 |
|
BOOST_JSON_FAIL( ec, error::not_exact );
|
303 |
|
BOOST_JSON_FAIL( ec, error::not_exact );
|
| 304 |
|
|
304 |
|
|
| 305 |
|
|
305 |
|
|
| 306 |
|
|
306 |
|
|
| 307 |
|
*value_ = static_cast<V>(v);
|
307 |
|
*value_ = static_cast<V>(v);
|
| 308 |
|
return this->parent_->signal_value(ec);
|
308 |
|
return this->parent_->signal_value(ec);
|
| 309 |
|
|
309 |
|
|
| 310 |
|
|
310 |
|
|
| 311 |
|
|
311 |
|
|
| 312 |
|
// floating point handler
|
312 |
|
// floating point handler
|
| 313 |
|
template< class V, class P>
|
313 |
|
template< class V, class P>
|
| 314 |
|
class converting_handler<floating_point_conversion_tag, V, P>
|
314 |
|
class converting_handler<floating_point_conversion_tag, V, P>
|
| 315 |
|
: public scalar_handler<P, error::not_double>
|
315 |
|
: public scalar_handler<P, error::not_double>
|
| 316 |
|
|
316 |
|
|
| 317 |
|
|
317 |
|
|
| 318 |
|
|
318 |
|
|
| 319 |
|
|
319 |
|
|
| 320 |
|
|
320 |
|
|
| 321 |
|
converting_handler( V* v, P* p )
|
321 |
|
converting_handler( V* v, P* p )
|
| 322 |
|
: converting_handler::scalar_handler(p)
|
322 |
|
: converting_handler::scalar_handler(p)
|
| 323 |
|
|
323 |
|
|
| 324 |
|
|
324 |
|
|
| 325 |
|
|
325 |
|
|
| 326 |
|
bool on_number_part( system::error_code& )
|
326 |
|
bool on_number_part( system::error_code& )
|
| 327 |
|
|
327 |
|
|
| 328 |
|
|
328 |
|
|
| 329 |
|
|
329 |
|
|
| 330 |
|
|
330 |
|
|
| 331 |
|
bool on_int64(system::error_code& ec, std::int64_t v)
|
331 |
|
bool on_int64(system::error_code& ec, std::int64_t v)
|
| 332 |
|
|
332 |
|
|
| 333 |
|
*value_ = static_cast<V>(v);
|
333 |
|
*value_ = static_cast<V>(v);
|
| 334 |
|
return this->parent_->signal_value(ec);
|
334 |
|
return this->parent_->signal_value(ec);
|
| 335 |
|
|
335 |
|
|
| 336 |
|
|
336 |
|
|
| 337 |
|
bool on_uint64(system::error_code& ec, std::uint64_t v)
|
337 |
|
bool on_uint64(system::error_code& ec, std::uint64_t v)
|
| 338 |
|
|
338 |
|
|
| 339 |
|
*value_ = static_cast<V>(v);
|
339 |
|
*value_ = static_cast<V>(v);
|
| 340 |
|
return this->parent_->signal_value(ec);
|
340 |
|
return this->parent_->signal_value(ec);
|
| 341 |
|
|
341 |
|
|
| 342 |
|
|
342 |
|
|
| 343 |
|
bool on_double(system::error_code& ec, double v)
|
343 |
|
bool on_double(system::error_code& ec, double v)
|
| 344 |
|
|
344 |
|
|
| 345 |
|
*value_ = static_cast<V>(v);
|
345 |
|
*value_ = static_cast<V>(v);
|
| 346 |
|
return this->parent_->signal_value(ec);
|
346 |
|
return this->parent_->signal_value(ec);
|
| 347 |
|
|
347 |
|
|
| 348 |
|
|
348 |
|
|
| 349 |
|
|
349 |
|
|
| 350 |
|
|
350 |
|
|
| 351 |
|
template< class V, class P >
|
351 |
|
template< class V, class P >
|
| 352 |
|
class converting_handler<string_like_conversion_tag, V, P>
|
352 |
|
class converting_handler<string_like_conversion_tag, V, P>
|
| 353 |
|
: public scalar_handler<P, error::not_string>
|
353 |
|
: public scalar_handler<P, error::not_string>
|
| 354 |
|
|
354 |
|
|
| 355 |
|
|
355 |
|
|
| 356 |
|
|
356 |
|
|
| 357 |
|
|
357 |
|
|
| 358 |
|
|
358 |
|
|
| 359 |
|
|
359 |
|
|
| 360 |
|
converting_handler( V* v, P* p )
|
360 |
|
converting_handler( V* v, P* p )
|
| 361 |
|
: converting_handler::scalar_handler(p)
|
361 |
|
: converting_handler::scalar_handler(p)
|
| 362 |
|
|
362 |
|
|
| 363 |
|
|
363 |
|
|
| 364 |
|
|
364 |
|
|
| 365 |
|
bool on_string_part( system::error_code&, string_view sv )
|
365 |
|
bool on_string_part( system::error_code&, string_view sv )
|
| 366 |
|
|
366 |
|
|
| 367 |
|
|
367 |
|
|
| 368 |
|
|
368 |
|
|
| 369 |
|
|
369 |
|
|
| 370 |
|
|
370 |
|
|
| 371 |
|
|
371 |
|
|
| 372 |
|
|
372 |
|
|
| 373 |
|
value_->append( sv.begin(), sv.end() );
|
373 |
|
value_->append( sv.begin(), sv.end() );
|
| 374 |
|
|
374 |
|
|
| 375 |
|
|
375 |
|
|
| 376 |
|
|
376 |
|
|
| 377 |
|
bool on_string(system::error_code& ec, string_view sv)
|
377 |
|
bool on_string(system::error_code& ec, string_view sv)
|
| 378 |
|
|
378 |
|
|
| 379 |
|
|
379 |
|
|
| 380 |
|
|
380 |
|
|
| 381 |
|
|
381 |
|
|
| 382 |
|
|
382 |
|
|
| 383 |
|
|
383 |
|
|
| 384 |
|
value_->append( sv.begin(), sv.end() );
|
384 |
|
value_->append( sv.begin(), sv.end() );
|
| 385 |
|
return this->parent_->signal_value(ec);
|
385 |
|
return this->parent_->signal_value(ec);
|
| 386 |
|
|
386 |
|
|
| 387 |
|
|
387 |
|
|
| 388 |
|
|
388 |
|
|
| 389 |
|
|
389 |
|
|
| 390 |
|
template< class V, class P >
|
390 |
|
template< class V, class P >
|
| 391 |
|
class converting_handler<bool_conversion_tag, V, P>
|
391 |
|
class converting_handler<bool_conversion_tag, V, P>
|
| 392 |
|
: public scalar_handler<P, error::not_bool>
|
392 |
|
: public scalar_handler<P, error::not_bool>
|
| 393 |
|
|
393 |
|
|
| 394 |
|
|
394 |
|
|
| 395 |
|
|
395 |
|
|
| 396 |
|
|
396 |
|
|
| 397 |
|
|
397 |
|
|
| 398 |
|
converting_handler( V* v, P* p )
|
398 |
|
converting_handler( V* v, P* p )
|
| 399 |
|
: converting_handler::scalar_handler(p)
|
399 |
|
: converting_handler::scalar_handler(p)
|
| 400 |
|
|
400 |
|
|
| 401 |
|
|
401 |
|
|
| 402 |
|
|
402 |
|
|
| 403 |
|
bool on_bool(system::error_code& ec, bool v)
|
403 |
|
bool on_bool(system::error_code& ec, bool v)
|
| 404 |
|
|
404 |
|
|
| 405 |
|
|
405 |
|
|
| 406 |
|
return this->parent_->signal_value(ec);
|
406 |
|
return this->parent_->signal_value(ec);
|
| 407 |
|
|
407 |
|
|
| 408 |
|
|
408 |
|
|
| 409 |
|
|
409 |
|
|
| 410 |
|
|
410 |
|
|
| 411 |
|
template< class V, class P >
|
411 |
|
template< class V, class P >
|
| 412 |
|
class converting_handler<null_like_conversion_tag, V, P>
|
412 |
|
class converting_handler<null_like_conversion_tag, V, P>
|
| 413 |
|
: public scalar_handler<P, error::not_null>
|
413 |
|
: public scalar_handler<P, error::not_null>
|
| 414 |
|
|
414 |
|
|
| 415 |
|
|
415 |
|
|
| 416 |
|
|
416 |
|
|
| 417 |
|
|
417 |
|
|
| 418 |
|
|
418 |
|
|
| 419 |
|
converting_handler( V* v, P* p )
|
419 |
|
converting_handler( V* v, P* p )
|
| 420 |
|
: converting_handler::scalar_handler(p)
|
420 |
|
: converting_handler::scalar_handler(p)
|
| 421 |
|
|
421 |
|
|
| 422 |
|
|
422 |
|
|
| 423 |
|
|
423 |
|
|
| 424 |
|
bool on_null(system::error_code& ec)
|
424 |
|
bool on_null(system::error_code& ec)
|
| 425 |
|
|
425 |
|
|
| 426 |
|
|
426 |
|
|
| 427 |
|
return this->parent_->signal_value(ec);
|
427 |
|
return this->parent_->signal_value(ec);
|
| 428 |
|
|
428 |
|
|
| 429 |
|
|
429 |
|
|
| 430 |
|
|
430 |
|
|
| 431 |
|
// described enum handler
|
431 |
|
// described enum handler
|
| 432 |
|
template< class V, class P >
|
432 |
|
template< class V, class P >
|
| 433 |
|
class converting_handler<described_enum_conversion_tag, V, P>
|
433 |
|
class converting_handler<described_enum_conversion_tag, V, P>
|
| 434 |
|
: public scalar_handler<P, error::not_string>
|
434 |
|
: public scalar_handler<P, error::not_string>
|
| 435 |
|
|
435 |
|
|
| 436 |
|
#ifndef BOOST_DESCRIBE_CXX14
|
436 |
|
#ifndef BOOST_DESCRIBE_CXX14
|
| 437 |
|
|
437 |
|
|
| 438 |
|
|
438 |
|
|
| 439 |
|
sizeof(V) == 0, "Enum support for parse_into requires C++14" );
|
439 |
|
sizeof(V) == 0, "Enum support for parse_into requires C++14" );
|
| 440 |
|
|
440 |
|
|
| 441 |
|
|
441 |
|
|
| 442 |
|
|
442 |
|
|
| 443 |
|
|
443 |
|
|
| 444 |
|
|
444 |
|
|
| 445 |
|
|
445 |
|
|
| 446 |
|
|
446 |
|
|
| 447 |
|
|
447 |
|
|
| 448 |
|
converting_handler( V* v, P* p )
|
448 |
|
converting_handler( V* v, P* p )
|
| 449 |
|
: converting_handler::scalar_handler(p)
|
449 |
|
: converting_handler::scalar_handler(p)
|
| 450 |
|
|
450 |
|
|
| 451 |
|
|
451 |
|
|
| 452 |
|
|
452 |
|
|
| 453 |
|
bool on_string_part( system::error_code&, string_view sv )
|
453 |
|
bool on_string_part( system::error_code&, string_view sv )
|
| 454 |
|
|
454 |
|
|
| 455 |
|
name_.append( sv.begin(), sv.end() );
|
455 |
|
name_.append( sv.begin(), sv.end() );
|
| 456 |
|
|
456 |
|
|
| 457 |
|
|
457 |
|
|
| 458 |
|
|
458 |
|
|
| 459 |
|
bool on_string(system::error_code& ec, string_view sv)
|
459 |
|
bool on_string(system::error_code& ec, string_view sv)
|
| 460 |
|
|
460 |
|
|
| 461 |
|
|
461 |
|
|
| 462 |
|
|
462 |
|
|
| 463 |
|
|
463 |
|
|
| 464 |
|
name_.append( sv.begin(), sv.end() );
|
464 |
|
name_.append( sv.begin(), sv.end() );
|
| 465 |
|
|
465 |
|
|
| 466 |
|
|
466 |
|
|
| 467 |
|
|
467 |
|
|
| 468 |
|
if( !describe::enum_from_string(name, *value_) )
|
468 |
|
if( !describe::enum_from_string(name, *value_) )
|
| 469 |
|
|
469 |
|
|
| 470 |
|
BOOST_JSON_FAIL(ec, error::unknown_name);
|
470 |
|
BOOST_JSON_FAIL(ec, error::unknown_name);
|
| 471 |
|
|
471 |
|
|
| 472 |
|
|
472 |
|
|
| 473 |
|
|
473 |
|
|
| 474 |
|
return this->parent_->signal_value(ec);
|
474 |
|
return this->parent_->signal_value(ec);
|
| 475 |
|
|
475 |
|
|
| 476 |
|
|
476 |
|
|
| 477 |
|
#endif // BOOST_DESCRIBE_CXX14
|
477 |
|
#endif // BOOST_DESCRIBE_CXX14
|
| 478 |
|
|
478 |
|
|
| 479 |
|
|
479 |
|
|
| 480 |
|
template< class V, class P >
|
480 |
|
template< class V, class P >
|
| 481 |
|
class converting_handler<no_conversion_tag, V, P>
|
481 |
|
class converting_handler<no_conversion_tag, V, P>
|
| 482 |
|
|
482 |
|
|
| 483 |
|
static_assert( sizeof(V) == 0, "This type is not supported" );
|
483 |
|
static_assert( sizeof(V) == 0, "This type is not supported" );
|
| 484 |
|
|
484 |
|
|
| 485 |
|
|
485 |
|
|
| 486 |
|
|
486 |
|
|
| 487 |
|
|
487 |
|
|
| 488 |
|
bool cannot_insert(It i, It e)
|
488 |
|
bool cannot_insert(It i, It e)
|
| 489 |
|
|
489 |
|
|
| 490 |
|
|
490 |
|
|
| 491 |
|
|
491 |
|
|
| 492 |
|
|
492 |
|
|
| 493 |
|
template< class It1, class It2 >
|
493 |
|
template< class It1, class It2 >
|
| 494 |
|
std::false_type cannot_insert(It1, It2)
|
494 |
|
std::false_type cannot_insert(It1, It2)
|
| 495 |
|
|
495 |
|
|
| 496 |
|
|
496 |
|
|
| 497 |
|
|
497 |
|
|
| 498 |
|
|
498 |
|
|
| 499 |
|
|
499 |
|
|
| 500 |
|
bool needs_more_elements(It i, It e)
|
500 |
|
bool needs_more_elements(It i, It e)
|
| 501 |
|
|
501 |
|
|
| 502 |
|
|
502 |
|
|
| 503 |
|
|
503 |
|
|
| 504 |
|
|
504 |
|
|
| 505 |
|
template< class It1, class It2 >
|
505 |
|
template< class It1, class It2 >
|
| 506 |
|
std::false_type needs_more_elements(It1, It2)
|
506 |
|
std::false_type needs_more_elements(It1, It2)
|
| 507 |
|
|
507 |
|
|
| 508 |
|
|
508 |
|
|
| 509 |
|
|
509 |
|
|
| 510 |
|
|
510 |
|
|
| 511 |
|
|
511 |
|
|
| 512 |
|
|
512 |
|
|
| 513 |
|
|
513 |
|
|
| 514 |
|
|
514 |
|
|
| 515 |
|
|
515 |
|
|
| 516 |
|
|
516 |
|
|
| 517 |
|
|
517 |
|
|
| 518 |
|
|
518 |
|
|
| 519 |
|
|
519 |
|
|
| 520 |
|
|
520 |
|
|
| 521 |
|
|
521 |
|
|
| 522 |
|
|
522 |
|
|
| 523 |
|
|
523 |
|
|
| 524 |
|
|
524 |
|
|
| 525 |
|
|
525 |
|
|
| 526 |
|
|
526 |
|
|
| 527 |
|
|
527 |
|
|
| 528 |
|
|
528 |
|
|
| 529 |
|
|
529 |
|
|
| 530 |
|
|
530 |
|
|
| 531 |
|
|
531 |
|
|
| 532 |
|
|
532 |
|
|
| 533 |
|
|
533 |
|
|
| 534 |
|
|
534 |
|
|
| 535 |
|
|
535 |
|
|
| 536 |
|
|
536 |
|
|
| 537 |
|
template< class V, class P >
|
537 |
|
template< class V, class P >
|
| 538 |
|
class converting_handler<sequence_conversion_tag, V, P>
|
538 |
|
class converting_handler<sequence_conversion_tag, V, P>
|
| 539 |
|
: public composite_handler<
|
539 |
|
: public composite_handler<
|
| 540 |
|
converting_handler<sequence_conversion_tag, V, P>,
|
540 |
|
converting_handler<sequence_conversion_tag, V, P>,
|
| 541 |
|
|
541 |
|
|
| 542 |
|
|
542 |
|
|
| 543 |
|
|
543 |
|
|
| 544 |
|
|
544 |
|
|
| 545 |
|
|
545 |
|
|
| 546 |
|
|
546 |
|
|
| 547 |
|
|
547 |
|
|
| 548 |
|
using Inserter = decltype(
|
548 |
|
using Inserter = decltype(
|
| 549 |
|
detail::inserter(*value_, inserter_implementation<V>()) );
|
549 |
|
detail::inserter(*value_, inserter_implementation<V>()) );
|
| 550 |
|
|
550 |
|
|
| 551 |
|
|
551 |
|
|
| 552 |
|
|
552 |
|
|
| 553 |
|
converting_handler( V* v, P* p )
|
553 |
|
converting_handler( V* v, P* p )
|
| 554 |
|
: converting_handler::composite_handler(p)
|
554 |
|
: converting_handler::composite_handler(p)
|
| 555 |
|
|
555 |
|
|
| 556 |
|
, inserter( detail::inserter(*value_, inserter_implementation<V>()) )
|
556 |
|
, inserter( detail::inserter(*value_, inserter_implementation<V>()) )
|
| 557 |
|
|
557 |
|
|
| 558 |
|
|
558 |
|
|
| 559 |
|
bool signal_value(system::error_code& ec)
|
559 |
|
bool signal_value(system::error_code& ec)
|
| 560 |
|
|
560 |
|
|
| 561 |
|
if(cannot_insert( inserter, value_->end() ))
|
561 |
|
if(cannot_insert( inserter, value_->end() ))
|
| 562 |
|
|
562 |
|
|
| 563 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch );
|
563 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch );
|
| 564 |
|
|
564 |
|
|
| 565 |
|
|
565 |
|
|
| 566 |
|
|
566 |
|
|
| 567 |
|
*inserter++ = std::move(this->next_value_);
|
567 |
|
*inserter++ = std::move(this->next_value_);
|
| 568 |
|
#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
|
568 |
|
#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
|
| 569 |
|
# pragma GCC diagnostic push
|
569 |
|
# pragma GCC diagnostic push
|
| 570 |
|
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
570 |
|
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
| 571 |
|
|
571 |
|
|
| 572 |
|
|
572 |
|
|
| 573 |
|
#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
|
573 |
|
#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
|
| 574 |
|
# pragma GCC diagnostic pop
|
574 |
|
# pragma GCC diagnostic pop
|
| 575 |
|
|
575 |
|
|
| 576 |
|
|
576 |
|
|
| 577 |
|
|
577 |
|
|
| 578 |
|
|
578 |
|
|
| 579 |
|
bool signal_end(system::error_code& ec)
|
579 |
|
bool signal_end(system::error_code& ec)
|
| 580 |
|
|
580 |
|
|
| 581 |
|
if(needs_more_elements( inserter, value_->end() ))
|
581 |
|
if(needs_more_elements( inserter, value_->end() ))
|
| 582 |
|
|
582 |
|
|
| 583 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch );
|
583 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch );
|
| 584 |
|
|
584 |
|
|
| 585 |
|
|
585 |
|
|
| 586 |
|
|
586 |
|
|
| 587 |
|
inserter = detail::inserter(*value_, inserter_implementation<V>());
|
587 |
|
inserter = detail::inserter(*value_, inserter_implementation<V>());
|
| 588 |
|
|
588 |
|
|
| 589 |
|
return converting_handler::composite_handler::signal_end(ec);
|
589 |
|
return converting_handler::composite_handler::signal_end(ec);
|
| 590 |
|
|
590 |
|
|
| 591 |
|
|
591 |
|
|
| 592 |
|
bool on_array_begin( system::error_code& ec )
|
592 |
|
bool on_array_begin( system::error_code& ec )
|
| 593 |
|
|
593 |
|
|
| 594 |
|
if( this->inner_active_ )
|
594 |
|
if( this->inner_active_ )
|
| 595 |
|
return this->inner_.on_array_begin( ec );
|
595 |
|
return this->inner_.on_array_begin( ec );
|
| 596 |
|
|
596 |
|
|
| 597 |
|
this->inner_active_ = true;
|
597 |
|
this->inner_active_ = true;
|
| 598 |
|
clear_container( *value_, inserter_implementation<V>() );
|
598 |
|
clear_container( *value_, inserter_implementation<V>() );
|
| 599 |
|
|
599 |
|
|
| 600 |
|
|
600 |
|
|
| 601 |
|
|
601 |
|
|
| 602 |
|
bool on_array_end( system::error_code& ec )
|
602 |
|
bool on_array_end( system::error_code& ec )
|
| 603 |
|
|
603 |
|
|
| 604 |
|
if( this->inner_active_ )
|
604 |
|
if( this->inner_active_ )
|
| 605 |
|
return this->inner_.on_array_end( ec );
|
605 |
|
return this->inner_.on_array_end( ec );
|
| 606 |
|
|
606 |
|
|
| 607 |
|
return this->parent_->signal_end(ec);
|
607 |
|
return this->parent_->signal_end(ec);
|
| 608 |
|
|
608 |
|
|
| 609 |
|
|
609 |
|
|
| 610 |
|
|
610 |
|
|
| 611 |
|
|
611 |
|
|
| 612 |
|
template< class V, class P >
|
612 |
|
template< class V, class P >
|
| 613 |
|
class converting_handler<map_like_conversion_tag, V, P>
|
613 |
|
class converting_handler<map_like_conversion_tag, V, P>
|
| 614 |
|
: public composite_handler<
|
614 |
|
: public composite_handler<
|
| 615 |
|
converting_handler<map_like_conversion_tag, V, P>,
|
615 |
|
converting_handler<map_like_conversion_tag, V, P>,
|
| 616 |
|
|
616 |
|
|
| 617 |
|
|
617 |
|
|
| 618 |
|
|
618 |
|
|
| 619 |
|
|
619 |
|
|
| 620 |
|
|
620 |
|
|
| 621 |
|
|
621 |
|
|
| 622 |
|
|
622 |
|
|
| 623 |
|
|
623 |
|
|
| 624 |
|
|
624 |
|
|
| 625 |
|
converting_handler( V* v, P* p )
|
625 |
|
converting_handler( V* v, P* p )
|
| 626 |
|
: converting_handler::composite_handler(p), value_(v)
|
626 |
|
: converting_handler::composite_handler(p), value_(v)
|
| 627 |
|
|
627 |
|
|
| 628 |
|
|
628 |
|
|
| 629 |
|
bool signal_value(system::error_code&)
|
629 |
|
bool signal_value(system::error_code&)
|
| 630 |
|
|
630 |
|
|
| 631 |
|
value_->emplace( std::move(key_), std::move(this->next_value_) );
|
631 |
|
value_->emplace( std::move(key_), std::move(this->next_value_) );
|
| 632 |
|
|
632 |
|
|
| 633 |
|
|
633 |
|
|
| 634 |
|
|
634 |
|
|
| 635 |
|
|
635 |
|
|
| 636 |
|
this->inner_active_ = false;
|
636 |
|
this->inner_active_ = false;
|
| 637 |
|
|
637 |
|
|
| 638 |
|
|
638 |
|
|
| 639 |
|
|
639 |
|
|
| 640 |
|
|
640 |
|
|
| 641 |
|
bool on_object_begin( system::error_code& ec )
|
641 |
|
bool on_object_begin( system::error_code& ec )
|
| 642 |
|
|
642 |
|
|
| 643 |
|
if( this->inner_active_ )
|
643 |
|
if( this->inner_active_ )
|
| 644 |
|
return this->inner_.on_object_begin(ec);
|
644 |
|
return this->inner_.on_object_begin(ec);
|
| 645 |
|
|
645 |
|
|
| 646 |
|
clear_container( *value_, inserter_implementation<V>() );
|
646 |
|
clear_container( *value_, inserter_implementation<V>() );
|
| 647 |
|
|
647 |
|
|
| 648 |
|
|
648 |
|
|
| 649 |
|
|
649 |
|
|
| 650 |
|
bool on_object_end(system::error_code& ec)
|
650 |
|
bool on_object_end(system::error_code& ec)
|
| 651 |
|
|
651 |
|
|
| 652 |
|
if( this->inner_active_ )
|
652 |
|
if( this->inner_active_ )
|
| 653 |
|
return this->inner_.on_object_end(ec);
|
653 |
|
return this->inner_.on_object_end(ec);
|
| 654 |
|
|
654 |
|
|
| 655 |
|
return this->parent_->signal_value(ec);
|
655 |
|
return this->parent_->signal_value(ec);
|
| 656 |
|
|
656 |
|
|
| 657 |
|
|
657 |
|
|
| 658 |
|
bool on_array_end( system::error_code& ec )
|
658 |
|
bool on_array_end( system::error_code& ec )
|
| 659 |
|
|
659 |
|
|
| 660 |
|
if( this->inner_active_ )
|
660 |
|
if( this->inner_active_ )
|
| 661 |
|
return this->inner_.on_array_end(ec);
|
661 |
|
return this->inner_.on_array_end(ec);
|
| 662 |
|
|
662 |
|
|
| 663 |
|
return this->parent_->signal_end(ec);
|
663 |
|
return this->parent_->signal_end(ec);
|
| 664 |
|
|
664 |
|
|
| 665 |
|
|
665 |
|
|
| 666 |
|
bool on_key_part( system::error_code& ec, string_view sv )
|
666 |
|
bool on_key_part( system::error_code& ec, string_view sv )
|
| 667 |
|
|
667 |
|
|
| 668 |
|
if( this->inner_active_ )
|
668 |
|
if( this->inner_active_ )
|
| 669 |
|
return this->inner_.on_key_part(ec, sv);
|
669 |
|
return this->inner_.on_key_part(ec, sv);
|
| 670 |
|
|
670 |
|
|
| 671 |
|
key_.append( sv.data(), sv.size() );
|
671 |
|
key_.append( sv.data(), sv.size() );
|
| 672 |
|
|
672 |
|
|
| 673 |
|
|
673 |
|
|
| 674 |
|
|
674 |
|
|
| 675 |
|
bool on_key( system::error_code& ec, string_view sv )
|
675 |
|
bool on_key( system::error_code& ec, string_view sv )
|
| 676 |
|
|
676 |
|
|
| 677 |
|
if( this->inner_active_ )
|
677 |
|
if( this->inner_active_ )
|
| 678 |
|
return this->inner_.on_key(ec, sv);
|
678 |
|
return this->inner_.on_key(ec, sv);
|
| 679 |
|
|
679 |
|
|
| 680 |
|
key_.append( sv.data(), sv.size() );
|
680 |
|
key_.append( sv.data(), sv.size() );
|
| 681 |
|
|
681 |
|
|
| 682 |
|
this->inner_active_ = true;
|
682 |
|
this->inner_active_ = true;
|
| 683 |
|
|
683 |
|
|
| 684 |
|
|
684 |
|
|
| 685 |
|
|
685 |
|
|
| 686 |
|
|
686 |
|
|
| 687 |
|
|
687 |
|
|
| 688 |
|
template<std::size_t I, class T>
|
688 |
|
template<std::size_t I, class T>
|
| 689 |
|
struct handler_tuple_element
|
689 |
|
struct handler_tuple_element
|
| 690 |
|
|
690 |
|
|
| 691 |
|
template< class... Args >
|
691 |
|
template< class... Args >
|
| 692 |
|
handler_tuple_element( Args&& ... args )
|
692 |
|
handler_tuple_element( Args&& ... args )
|
| 693 |
|
: t_( static_cast<Args&&>(args)... )
|
693 |
|
: t_( static_cast<Args&&>(args)... )
|
| 694 |
|
|
694 |
|
|
| 695 |
|
|
695 |
|
|
| 696 |
|
|
696 |
|
|
| 697 |
|
|
697 |
|
|
| 698 |
|
|
698 |
|
|
| 699 |
|
template<std::size_t I, class T>
|
699 |
|
template<std::size_t I, class T>
|
| 700 |
|
|
700 |
|
|
| 701 |
|
get( handler_tuple_element<I, T>& e )
|
701 |
|
get( handler_tuple_element<I, T>& e )
|
| 702 |
|
|
702 |
|
|
| 703 |
|
|
703 |
|
|
| 704 |
|
|
704 |
|
|
| 705 |
|
|
705 |
|
|
| 706 |
|
|
706 |
|
|
| 707 |
|
|
707 |
|
|
| 708 |
|
|
708 |
|
|
| 709 |
|
class S = mp11::make_index_sequence<mp11::mp_size<LV>::value> >
|
709 |
|
class S = mp11::make_index_sequence<mp11::mp_size<LV>::value> >
|
| 710 |
|
|
710 |
|
|
| 711 |
|
|
711 |
|
|
| 712 |
|
template< class P, template<class...> class L, class... V, std::size_t... I >
|
712 |
|
template< class P, template<class...> class L, class... V, std::size_t... I >
|
| 713 |
|
struct handler_tuple< P, L<V...>, mp11::index_sequence<I...> >
|
713 |
|
struct handler_tuple< P, L<V...>, mp11::index_sequence<I...> >
|
| 714 |
|
: handler_tuple_element<I, V>
|
714 |
|
: handler_tuple_element<I, V>
|
| 715 |
|
|
715 |
|
|
| 716 |
|
|
716 |
|
|
| 717 |
|
handler_tuple( handler_tuple const& ) = delete;
|
717 |
|
handler_tuple( handler_tuple const& ) = delete;
|
| 718 |
|
handler_tuple& operator=( handler_tuple const& ) = delete;
|
718 |
|
handler_tuple& operator=( handler_tuple const& ) = delete;
|
| 719 |
|
|
719 |
|
|
| 720 |
|
template< class Access, class T >
|
720 |
|
template< class Access, class T >
|
| 721 |
|
handler_tuple( Access access, T* pv, P* pp )
|
721 |
|
handler_tuple( Access access, T* pv, P* pp )
|
| 722 |
|
: handler_tuple_element<I, V>(
|
722 |
|
: handler_tuple_element<I, V>(
|
| 723 |
|
access( pv, mp11::mp_size_t<I>() ),
|
723 |
|
access( pv, mp11::mp_size_t<I>() ),
|
| 724 |
|
|
724 |
|
|
| 725 |
|
|
725 |
|
|
| 726 |
|
|
726 |
|
|
| 727 |
|
|
727 |
|
|
| 728 |
|
|
728 |
|
|
| 729 |
|
#if defined(BOOST_MSVC) && BOOST_MSVC < 1910
|
729 |
|
#if defined(BOOST_MSVC) && BOOST_MSVC < 1910
|
| 730 |
|
|
730 |
|
|
| 731 |
|
|
731 |
|
|
| 732 |
|
struct tuple_element_list_impl
|
732 |
|
struct tuple_element_list_impl
|
| 733 |
|
|
733 |
|
|
| 734 |
|
|
734 |
|
|
| 735 |
|
using tuple_element_helper = tuple_element_t<I::value, T>;
|
735 |
|
using tuple_element_helper = tuple_element_t<I::value, T>;
|
| 736 |
|
|
736 |
|
|
| 737 |
|
using type = mp11::mp_transform<
|
737 |
|
using type = mp11::mp_transform<
|
| 738 |
|
|
738 |
|
|
| 739 |
|
mp11::mp_iota< std::tuple_size<T> > >;
|
739 |
|
mp11::mp_iota< std::tuple_size<T> > >;
|
| 740 |
|
|
740 |
|
|
| 741 |
|
|
741 |
|
|
| 742 |
|
using tuple_element_list = typename tuple_element_list_impl<T>::type;
|
742 |
|
using tuple_element_list = typename tuple_element_list_impl<T>::type;
|
| 743 |
|
|
743 |
|
|
| 744 |
|
|
744 |
|
|
| 745 |
|
|
745 |
|
|
| 746 |
|
template< class I, class T >
|
746 |
|
template< class I, class T >
|
| 747 |
|
using tuple_element_helper = tuple_element_t<I::value, T>;
|
747 |
|
using tuple_element_helper = tuple_element_t<I::value, T>;
|
| 748 |
|
|
748 |
|
|
| 749 |
|
using tuple_element_list = mp11::mp_transform_q<
|
749 |
|
using tuple_element_list = mp11::mp_transform_q<
|
| 750 |
|
mp11::mp_bind_back< tuple_element_helper, T>,
|
750 |
|
mp11::mp_bind_back< tuple_element_helper, T>,
|
| 751 |
|
mp11::mp_iota< std::tuple_size<T> > >;
|
751 |
|
mp11::mp_iota< std::tuple_size<T> > >;
|
| 752 |
|
|
752 |
|
|
| 753 |
|
|
753 |
|
|
| 754 |
|
|
754 |
|
|
| 755 |
|
template< class Op, class... Args>
|
755 |
|
template< class Op, class... Args>
|
| 756 |
|
struct handler_op_invoker
|
756 |
|
struct handler_op_invoker
|
| 757 |
|
|
757 |
|
|
| 758 |
|
|
758 |
|
|
| 759 |
|
std::tuple<Args&...> args;
|
759 |
|
std::tuple<Args&...> args;
|
| 760 |
|
|
760 |
|
|
| 761 |
|
template< class Handler >
|
761 |
|
template< class Handler >
|
| 762 |
|
|
762 |
|
|
| 763 |
|
operator()( Handler& handler ) const
|
763 |
|
operator()( Handler& handler ) const
|
| 764 |
|
|
764 |
|
|
| 765 |
|
return (*this)( handler, mp11::index_sequence_for<Args...>() );
|
765 |
|
return (*this)( handler, mp11::index_sequence_for<Args...>() );
|
| 766 |
|
|
766 |
|
|
| 767 |
|
|
767 |
|
|
| 768 |
|
|
768 |
|
|
| 769 |
|
template< class Handler, std::size_t... I >
|
769 |
|
template< class Handler, std::size_t... I >
|
| 770 |
|
|
770 |
|
|
| 771 |
|
operator()( Handler& handler, mp11::index_sequence<I...> ) const
|
771 |
|
operator()( Handler& handler, mp11::index_sequence<I...> ) const
|
| 772 |
|
|
772 |
|
|
| 773 |
|
return Op()( handler, std::get<I>(args)... );
|
773 |
|
return Op()( handler, std::get<I>(args)... );
|
| 774 |
|
|
774 |
|
|
| 775 |
|
|
775 |
|
|
| 776 |
|
|
776 |
|
|
| 777 |
|
template< class Handlers, class F >
|
777 |
|
template< class Handlers, class F >
|
| 778 |
|
struct tuple_handler_op_invoker
|
778 |
|
struct tuple_handler_op_invoker
|
| 779 |
|
|
779 |
|
|
| 780 |
|
|
780 |
|
|
| 781 |
|
|
781 |
|
|
| 782 |
|
|
782 |
|
|
| 783 |
|
|
783 |
|
|
| 784 |
|
|
784 |
|
|
| 785 |
|
|
785 |
|
|
| 786 |
|
|
786 |
|
|
| 787 |
|
return fn( get<I::value>(handlers) );
|
787 |
|
return fn( get<I::value>(handlers) );
|
| 788 |
|
|
788 |
|
|
| 789 |
|
|
789 |
|
|
| 790 |
|
|
790 |
|
|
| 791 |
|
|
791 |
|
|
| 792 |
|
|
792 |
|
|
| 793 |
|
template< class T, class I >
|
793 |
|
template< class T, class I >
|
| 794 |
|
auto operator()( T* t, I ) const -> tuple_element_t<I::value, T>*
|
794 |
|
auto operator()( T* t, I ) const -> tuple_element_t<I::value, T>*
|
| 795 |
|
|
795 |
|
|
| 796 |
|
|
796 |
|
|
| 797 |
|
return &get<I::value>(*t);
|
797 |
|
return &get<I::value>(*t);
|
| 798 |
|
|
798 |
|
|
| 799 |
|
|
799 |
|
|
| 800 |
|
|
800 |
|
|
| 801 |
|
template< class T, class P >
|
801 |
|
template< class T, class P >
|
| 802 |
|
class converting_handler<tuple_conversion_tag, T, P>
|
802 |
|
class converting_handler<tuple_conversion_tag, T, P>
|
| 803 |
|
|
803 |
|
|
| 804 |
|
|
804 |
|
|
| 805 |
|
|
805 |
|
|
| 806 |
|
using ElementTypes = tuple_element_list<T>;
|
806 |
|
using ElementTypes = tuple_element_list<T>;
|
| 807 |
|
|
807 |
|
|
| 808 |
|
|
808 |
|
|
| 809 |
|
using ElementHandler = get_handler<V, converting_handler>;
|
809 |
|
using ElementHandler = get_handler<V, converting_handler>;
|
| 810 |
|
using InnerHandlers = mp11::mp_transform<ElementHandler, ElementTypes>;
|
810 |
|
using InnerHandlers = mp11::mp_transform<ElementHandler, ElementTypes>;
|
| 811 |
|
using HandlerTuple = handler_tuple<converting_handler, InnerHandlers>;
|
811 |
|
using HandlerTuple = handler_tuple<converting_handler, InnerHandlers>;
|
| 812 |
|
|
812 |
|
|
| 813 |
|
|
813 |
|
|
| 814 |
|
|
814 |
|
|
| 815 |
|
|
815 |
|
|
| 816 |
|
|
816 |
|
|
| 817 |
|
|
817 |
|
|
| 818 |
|
|
818 |
|
|
| 819 |
|
|
819 |
|
|
| 820 |
|
converting_handler( converting_handler const& ) = delete;
|
820 |
|
converting_handler( converting_handler const& ) = delete;
|
| 821 |
|
converting_handler& operator=( converting_handler const& ) = delete;
|
821 |
|
converting_handler& operator=( converting_handler const& ) = delete;
|
| 822 |
|
|
822 |
|
|
| 823 |
|
converting_handler( T* v, P* p )
|
823 |
|
converting_handler( T* v, P* p )
|
| 824 |
|
: value_(v) , parent_(p) , handlers_(tuple_accessor(), v, this)
|
824 |
|
: value_(v) , parent_(p) , handlers_(tuple_accessor(), v, this)
|
| 825 |
|
|
825 |
|
|
| 826 |
|
|
826 |
|
|
| 827 |
|
bool signal_value(system::error_code&)
|
827 |
|
bool signal_value(system::error_code&)
|
| 828 |
|
|
828 |
|
|
| 829 |
|
|
829 |
|
|
| 830 |
|
|
830 |
|
|
| 831 |
|
|
831 |
|
|
| 832 |
|
|
832 |
|
|
| 833 |
|
bool signal_end(system::error_code& ec)
|
833 |
|
bool signal_end(system::error_code& ec)
|
| 834 |
|
|
834 |
|
|
| 835 |
|
constexpr int N = std::tuple_size<T>::value;
|
835 |
|
constexpr int N = std::tuple_size<T>::value;
|
| 836 |
|
|
836 |
|
|
| 837 |
|
|
837 |
|
|
| 838 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch );
|
838 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch );
|
| 839 |
|
|
839 |
|
|
| 840 |
|
|
840 |
|
|
| 841 |
|
|
841 |
|
|
| 842 |
|
|
842 |
|
|
| 843 |
|
return parent_->signal_value(ec);
|
843 |
|
return parent_->signal_value(ec);
|
| 844 |
|
|
844 |
|
|
| 845 |
|
|
845 |
|
|
| 846 |
|
#define BOOST_JSON_HANDLE_EVENT(fn) \
|
846 |
|
#define BOOST_JSON_HANDLE_EVENT(fn) \
|
| 847 |
|
|
847 |
|
|
| 848 |
|
|
848 |
|
|
| 849 |
|
template< class H, class... Args > \
|
849 |
|
template< class H, class... Args > \
|
| 850 |
|
bool operator()( H& h, Args& ... args ) const \
|
850 |
|
bool operator()( H& h, Args& ... args ) const \
|
| 851 |
|
|
851 |
|
|
| 852 |
|
return h. fn (args...); \
|
852 |
|
return h. fn (args...); \
|
| 853 |
|
|
853 |
|
|
| 854 |
|
|
854 |
|
|
| 855 |
|
|
855 |
|
|
| 856 |
|
template< class... Args > \
|
856 |
|
template< class... Args > \
|
| 857 |
|
bool fn( system::error_code& ec, Args&& ... args ) \
|
857 |
|
bool fn( system::error_code& ec, Args&& ... args ) \
|
| 858 |
|
|
858 |
|
|
| 859 |
|
if( inner_active_ < 0 ) \
|
859 |
|
if( inner_active_ < 0 ) \
|
| 860 |
|
|
860 |
|
|
| 861 |
|
BOOST_JSON_FAIL( ec, error::not_array ); \
|
861 |
|
BOOST_JSON_FAIL( ec, error::not_array ); \
|
| 862 |
|
|
862 |
|
|
| 863 |
|
|
863 |
|
|
| 864 |
|
constexpr int N = std::tuple_size<T>::value; \
|
864 |
|
constexpr int N = std::tuple_size<T>::value; \
|
| 865 |
|
if( inner_active_ >= N ) \
|
865 |
|
if( inner_active_ >= N ) \
|
| 866 |
|
|
866 |
|
|
| 867 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch ); \
|
867 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch ); \
|
| 868 |
|
|
868 |
|
|
| 869 |
|
|
869 |
|
|
| 870 |
|
using F = handler_op_invoker< do_ ## fn, system::error_code, Args...>; \
|
870 |
|
using F = handler_op_invoker< do_ ## fn, system::error_code, Args...>; \
|
| 871 |
|
using H = decltype(handlers_); \
|
871 |
|
using H = decltype(handlers_); \
|
| 872 |
|
return mp11::mp_with_index<N>( \
|
872 |
|
return mp11::mp_with_index<N>( \
|
| 873 |
|
|
873 |
|
|
| 874 |
|
tuple_handler_op_invoker<H, F>{ \
|
874 |
|
tuple_handler_op_invoker<H, F>{ \
|
| 875 |
|
|
875 |
|
|
| 876 |
|
F{ std::forward_as_tuple(ec, args...) } } ); \
|
876 |
|
F{ std::forward_as_tuple(ec, args...) } } ); \
|
| 877 |
|
|
877 |
|
|
| 878 |
|
|
878 |
|
|
| 879 |
|
BOOST_JSON_HANDLE_EVENT( on_object_begin )
|
879 |
|
BOOST_JSON_HANDLE_EVENT( on_object_begin )
|
| 880 |
|
BOOST_JSON_HANDLE_EVENT( on_object_end )
|
880 |
|
BOOST_JSON_HANDLE_EVENT( on_object_end )
|
| 881 |
|
|
881 |
|
|
| 882 |
|
|
882 |
|
|
| 883 |
|
|
883 |
|
|
| 884 |
|
|
884 |
|
|
| 885 |
|
|
885 |
|
|
| 886 |
|
|
886 |
|
|
| 887 |
|
|
887 |
|
|
| 888 |
|
bool operator()( I ) const
|
888 |
|
bool operator()( I ) const
|
| 889 |
|
|
889 |
|
|
| 890 |
|
return get<I::value>(handlers).on_array_begin(ec);
|
890 |
|
return get<I::value>(handlers).on_array_begin(ec);
|
| 891 |
|
|
891 |
|
|
| 892 |
|
|
892 |
|
|
| 893 |
|
bool on_array_begin( system::error_code& ec )
|
893 |
|
bool on_array_begin( system::error_code& ec )
|
| 894 |
|
|
894 |
|
|
| 895 |
|
|
895 |
|
|
| 896 |
|
|
896 |
|
|
| 897 |
|
|
897 |
|
|
| 898 |
|
|
898 |
|
|
| 899 |
|
|
899 |
|
|
| 900 |
|
|
900 |
|
|
| 901 |
|
constexpr int N = std::tuple_size<T>::value;
|
901 |
|
constexpr int N = std::tuple_size<T>::value;
|
| 902 |
|
|
902 |
|
|
| 903 |
|
|
903 |
|
|
| 904 |
|
|
904 |
|
|
| 905 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch );
|
905 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch );
|
| 906 |
|
|
906 |
|
|
| 907 |
|
|
907 |
|
|
| 908 |
|
|
908 |
|
|
| 909 |
|
return mp11::mp_with_index<N>(
|
909 |
|
return mp11::mp_with_index<N>(
|
| 910 |
|
inner_active_, do_on_array_begin{handlers_, ec} );
|
910 |
|
inner_active_, do_on_array_begin{handlers_, ec} );
|
| 911 |
|
|
911 |
|
|
| 912 |
|
|
912 |
|
|
| 913 |
|
|
913 |
|
|
| 914 |
|
|
914 |
|
|
| 915 |
|
|
915 |
|
|
| 916 |
|
|
916 |
|
|
| 917 |
|
|
917 |
|
|
| 918 |
|
|
918 |
|
|
| 919 |
|
bool operator()( I ) const
|
919 |
|
bool operator()( I ) const
|
| 920 |
|
|
920 |
|
|
| 921 |
|
return get<I::value>(handlers).on_array_end(ec);
|
921 |
|
return get<I::value>(handlers).on_array_end(ec);
|
| 922 |
|
|
922 |
|
|
| 923 |
|
|
923 |
|
|
| 924 |
|
bool on_array_end( system::error_code& ec )
|
924 |
|
bool on_array_end( system::error_code& ec )
|
| 925 |
|
|
925 |
|
|
| 926 |
|
|
926 |
|
|
| 927 |
|
return parent_->signal_end(ec);
|
927 |
|
return parent_->signal_end(ec);
|
| 928 |
|
|
928 |
|
|
| 929 |
|
constexpr int N = std::tuple_size<T>::value;
|
929 |
|
constexpr int N = std::tuple_size<T>::value;
|
| 930 |
|
|
930 |
|
|
| 931 |
|
|
931 |
|
|
| 932 |
|
|
932 |
|
|
| 933 |
|
|
933 |
|
|
| 934 |
|
return mp11::mp_with_index<N>(
|
934 |
|
return mp11::mp_with_index<N>(
|
| 935 |
|
inner_active_, do_on_array_end{handlers_, ec} );
|
935 |
|
inner_active_, do_on_array_end{handlers_, ec} );
|
| 936 |
|
|
936 |
|
|
| 937 |
|
|
937 |
|
|
| 938 |
|
BOOST_JSON_HANDLE_EVENT( on_key_part )
|
938 |
|
BOOST_JSON_HANDLE_EVENT( on_key_part )
|
| 939 |
|
BOOST_JSON_HANDLE_EVENT( on_key )
|
939 |
|
BOOST_JSON_HANDLE_EVENT( on_key )
|
| 940 |
|
BOOST_JSON_HANDLE_EVENT( on_string_part )
|
940 |
|
BOOST_JSON_HANDLE_EVENT( on_string_part )
|
| 941 |
|
BOOST_JSON_HANDLE_EVENT( on_string )
|
941 |
|
BOOST_JSON_HANDLE_EVENT( on_string )
|
| 942 |
|
BOOST_JSON_HANDLE_EVENT( on_number_part )
|
942 |
|
BOOST_JSON_HANDLE_EVENT( on_number_part )
|
| 943 |
|
BOOST_JSON_HANDLE_EVENT( on_int64 )
|
943 |
|
BOOST_JSON_HANDLE_EVENT( on_int64 )
|
| 944 |
|
BOOST_JSON_HANDLE_EVENT( on_uint64 )
|
944 |
|
BOOST_JSON_HANDLE_EVENT( on_uint64 )
|
| 945 |
|
BOOST_JSON_HANDLE_EVENT( on_double )
|
945 |
|
BOOST_JSON_HANDLE_EVENT( on_double )
|
| 946 |
|
BOOST_JSON_HANDLE_EVENT( on_bool )
|
946 |
|
BOOST_JSON_HANDLE_EVENT( on_bool )
|
| 947 |
|
BOOST_JSON_HANDLE_EVENT( on_null )
|
947 |
|
BOOST_JSON_HANDLE_EVENT( on_null )
|
| 948 |
|
|
948 |
|
|
| 949 |
|
#undef BOOST_JSON_HANDLE_EVENT
|
949 |
|
#undef BOOST_JSON_HANDLE_EVENT
|
| 950 |
|
|
950 |
|
|
| 951 |
|
|
951 |
|
|
| 952 |
|
// described struct handler
|
952 |
|
// described struct handler
|
| 953 |
|
#if defined(BOOST_MSVC) && BOOST_MSVC < 1910
|
953 |
|
#if defined(BOOST_MSVC) && BOOST_MSVC < 1910
|
| 954 |
|
|
954 |
|
|
| 955 |
|
|
955 |
|
|
| 956 |
|
struct struct_element_list_impl
|
956 |
|
struct struct_element_list_impl
|
| 957 |
|
|
957 |
|
|
| 958 |
|
|
958 |
|
|
| 959 |
|
using helper = described_member_t<T, D>;
|
959 |
|
using helper = described_member_t<T, D>;
|
| 960 |
|
|
960 |
|
|
| 961 |
|
using type = mp11::mp_transform< helper, described_members<T> >;
|
961 |
|
using type = mp11::mp_transform< helper, described_members<T> >;
|
| 962 |
|
|
962 |
|
|
| 963 |
|
|
963 |
|
|
| 964 |
|
using struct_element_list = typename struct_element_list_impl<T>::type;
|
964 |
|
using struct_element_list = typename struct_element_list_impl<T>::type;
|
| 965 |
|
|
965 |
|
|
| 966 |
|
|
966 |
|
|
| 967 |
|
|
967 |
|
|
| 968 |
|
|
968 |
|
|
| 969 |
|
using struct_element_list = mp11::mp_transform_q<
|
969 |
|
using struct_element_list = mp11::mp_transform_q<
|
| 970 |
|
mp11::mp_bind_front< described_member_t, T >, described_members<T> >;
|
970 |
|
mp11::mp_bind_front< described_member_t, T >, described_members<T> >;
|
| 971 |
|
|
971 |
|
|
| 972 |
|
|
972 |
|
|
| 973 |
|
|
973 |
|
|
| 974 |
|
|
974 |
|
|
| 975 |
|
|
975 |
|
|
| 976 |
|
|
976 |
|
|
| 977 |
|
auto operator()( T*, mp11::mp_size< described_members<T> > ) const
|
977 |
|
auto operator()( T*, mp11::mp_size< described_members<T> > ) const
|
| 978 |
|
|
978 |
|
|
| 979 |
|
|
979 |
|
|
| 980 |
|
|
980 |
|
|
| 981 |
|
|
981 |
|
|
| 982 |
|
|
982 |
|
|
| 983 |
|
template< class T, class I >
|
983 |
|
template< class T, class I >
|
| 984 |
|
auto operator()( T* t, I ) const
|
984 |
|
auto operator()( T* t, I ) const
|
| 985 |
|
-> described_member_t<T, mp11::mp_at< described_members<T>, I> >*
|
985 |
|
-> described_member_t<T, mp11::mp_at< described_members<T>, I> >*
|
| 986 |
|
|
986 |
|
|
| 987 |
|
using Ds = described_members<T>;
|
987 |
|
using Ds = described_members<T>;
|
| 988 |
|
using D = mp11::mp_at<Ds, I>;
|
988 |
|
using D = mp11::mp_at<Ds, I>;
|
| 989 |
|
return &(t->*D::pointer);
|
989 |
|
return &(t->*D::pointer);
|
| 990 |
|
|
990 |
|
|
| 991 |
|
|
991 |
|
|
| 992 |
|
|
992 |
|
|
| 993 |
|
struct struct_key_searcher
|
993 |
|
struct struct_key_searcher
|
| 994 |
|
|
994 |
|
|
| 995 |
|
|
995 |
|
|
| 996 |
|
|
996 |
|
|
| 997 |
|
|
997 |
|
|
| 998 |
|
|
998 |
|
|
| 999 |
|
struct_key_searcher(string_view key, int& found) noexcept
|
999 |
|
struct_key_searcher(string_view key, int& found) noexcept
|
| 1000 |
|
|
1000 |
|
|
| 1001 |
|
|
1001 |
|
|
| 1002 |
|
|
1002 |
|
|
| 1003 |
|
|
1003 |
|
|
| 1004 |
|
|
1004 |
|
|
| 1005 |
|
|
1005 |
|
|
| 1006 |
|
|
1006 |
|
|
| 1007 |
|
|
1007 |
|
|
| 1008 |
|
|
1008 |
|
|
| 1009 |
|
|
1009 |
|
|
| 1010 |
|
|
1010 |
|
|
| 1011 |
|
|
1011 |
|
|
| 1012 |
|
|
1012 |
|
|
| 1013 |
|
|
1013 |
|
|
| 1014 |
|
|
1014 |
|
|
| 1015 |
|
|
1015 |
|
|
| 1016 |
|
|
1016 |
|
|
| 1017 |
|
std::size_t array_depth_ = 0;
|
1017 |
|
std::size_t array_depth_ = 0;
|
| 1018 |
|
std::size_t object_depth_ = 0;
|
1018 |
|
std::size_t object_depth_ = 0;
|
| 1019 |
|
|
1019 |
|
|
| 1020 |
|
ignoring_handler(ignoring_handler const&) = delete;
|
1020 |
|
ignoring_handler(ignoring_handler const&) = delete;
|
| 1021 |
|
ignoring_handler& operator=(ignoring_handler const&) = delete;
|
1021 |
|
ignoring_handler& operator=(ignoring_handler const&) = delete;
|
| 1022 |
|
|
1022 |
|
|
| 1023 |
|
ignoring_handler(void*, P* p) noexcept
|
1023 |
|
ignoring_handler(void*, P* p) noexcept
|
| 1024 |
|
|
1024 |
|
|
| 1025 |
|
|
1025 |
|
|
| 1026 |
|
|
1026 |
|
|
| 1027 |
|
bool on_object_begin(system::error_code&)
|
1027 |
|
bool on_object_begin(system::error_code&)
|
| 1028 |
|
|
1028 |
|
|
| 1029 |
|
|
1029 |
|
|
| 1030 |
|
|
1030 |
|
|
| 1031 |
|
|
1031 |
|
|
| 1032 |
|
|
1032 |
|
|
| 1033 |
|
bool on_object_end(system::error_code& ec)
|
1033 |
|
bool on_object_end(system::error_code& ec)
|
| 1034 |
|
|
1034 |
|
|
| 1035 |
|
BOOST_ASSERT( object_depth_ > 0 );
|
1035 |
|
BOOST_ASSERT( object_depth_ > 0 );
|
| 1036 |
|
|
1036 |
|
|
| 1037 |
|
|
1037 |
|
|
| 1038 |
|
if( (array_depth_ + object_depth_) == 0 )
|
1038 |
|
if( (array_depth_ + object_depth_) == 0 )
|
| 1039 |
|
return parent_->signal_value(ec);
|
1039 |
|
return parent_->signal_value(ec);
|
| 1040 |
|
|
1040 |
|
|
| 1041 |
|
|
1041 |
|
|
| 1042 |
|
|
1042 |
|
|
| 1043 |
|
bool on_array_begin(system::error_code&)
|
1043 |
|
bool on_array_begin(system::error_code&)
|
| 1044 |
|
|
1044 |
|
|
| 1045 |
|
|
1045 |
|
|
| 1046 |
|
|
1046 |
|
|
| 1047 |
|
|
1047 |
|
|
| 1048 |
|
|
1048 |
|
|
| 1049 |
|
bool on_array_end(system::error_code& ec)
|
1049 |
|
bool on_array_end(system::error_code& ec)
|
| 1050 |
|
|
1050 |
|
|
| 1051 |
|
BOOST_ASSERT( array_depth_ > 0 );
|
1051 |
|
BOOST_ASSERT( array_depth_ > 0 );
|
| 1052 |
|
|
1052 |
|
|
| 1053 |
|
|
1053 |
|
|
| 1054 |
|
if( (array_depth_ + object_depth_) == 0 )
|
1054 |
|
if( (array_depth_ + object_depth_) == 0 )
|
| 1055 |
|
return parent_->signal_value(ec);
|
1055 |
|
return parent_->signal_value(ec);
|
| 1056 |
|
|
1056 |
|
|
| 1057 |
|
|
1057 |
|
|
| 1058 |
|
|
1058 |
|
|
| 1059 |
|
bool on_key_part(system::error_code&, string_view)
|
1059 |
|
bool on_key_part(system::error_code&, string_view)
|
| 1060 |
|
|
1060 |
|
|
| 1061 |
|
|
1061 |
|
|
| 1062 |
|
|
1062 |
|
|
| 1063 |
|
|
1063 |
|
|
| 1064 |
|
bool on_key(system::error_code&, string_view)
|
1064 |
|
bool on_key(system::error_code&, string_view)
|
| 1065 |
|
|
1065 |
|
|
| 1066 |
|
|
1066 |
|
|
| 1067 |
|
|
1067 |
|
|
| 1068 |
|
|
1068 |
|
|
| 1069 |
|
bool on_string_part(system::error_code&, string_view)
|
1069 |
|
bool on_string_part(system::error_code&, string_view)
|
| 1070 |
|
|
1070 |
|
|
| 1071 |
|
|
1071 |
|
|
| 1072 |
|
|
1072 |
|
|
| 1073 |
|
|
1073 |
|
|
| 1074 |
|
bool on_string(system::error_code& ec, string_view)
|
1074 |
|
bool on_string(system::error_code& ec, string_view)
|
| 1075 |
|
|
1075 |
|
|
| 1076 |
|
if( (array_depth_ + object_depth_) == 0 )
|
1076 |
|
if( (array_depth_ + object_depth_) == 0 )
|
| 1077 |
|
return parent_->signal_value(ec);
|
1077 |
|
return parent_->signal_value(ec);
|
| 1078 |
|
|
1078 |
|
|
| 1079 |
|
|
1079 |
|
|
| 1080 |
|
|
1080 |
|
|
| 1081 |
|
bool on_number_part(system::error_code&)
|
1081 |
|
bool on_number_part(system::error_code&)
|
| 1082 |
|
|
1082 |
|
|
| 1083 |
|
|
1083 |
|
|
| 1084 |
|
|
1084 |
|
|
| 1085 |
|
|
1085 |
|
|
| 1086 |
|
bool on_int64(system::error_code& ec, std::int64_t)
|
1086 |
|
bool on_int64(system::error_code& ec, std::int64_t)
|
| 1087 |
|
|
1087 |
|
|
| 1088 |
|
if( (array_depth_ + object_depth_) == 0 )
|
1088 |
|
if( (array_depth_ + object_depth_) == 0 )
|
| 1089 |
|
return parent_->signal_value(ec);
|
1089 |
|
return parent_->signal_value(ec);
|
| 1090 |
|
|
1090 |
|
|
| 1091 |
|
|
1091 |
|
|
| 1092 |
|
|
1092 |
|
|
| 1093 |
|
bool on_uint64(system::error_code& ec, std::uint64_t)
|
1093 |
|
bool on_uint64(system::error_code& ec, std::uint64_t)
|
| 1094 |
|
|
1094 |
|
|
| 1095 |
|
if( (array_depth_ + object_depth_) == 0 )
|
1095 |
|
if( (array_depth_ + object_depth_) == 0 )
|
| 1096 |
|
return parent_->signal_value(ec);
|
1096 |
|
return parent_->signal_value(ec);
|
| 1097 |
|
|
1097 |
|
|
| 1098 |
|
|
1098 |
|
|
| 1099 |
|
|
1099 |
|
|
| 1100 |
|
bool on_double(system::error_code& ec, double)
|
1100 |
|
bool on_double(system::error_code& ec, double)
|
| 1101 |
|
|
1101 |
|
|
| 1102 |
|
if( (array_depth_ + object_depth_) == 0 )
|
1102 |
|
if( (array_depth_ + object_depth_) == 0 )
|
| 1103 |
|
return parent_->signal_value(ec);
|
1103 |
|
return parent_->signal_value(ec);
|
| 1104 |
|
|
1104 |
|
|
| 1105 |
|
|
1105 |
|
|
| 1106 |
|
|
1106 |
|
|
| 1107 |
|
bool on_bool(system::error_code& ec, bool)
|
1107 |
|
bool on_bool(system::error_code& ec, bool)
|
| 1108 |
|
|
1108 |
|
|
| 1109 |
|
if( (array_depth_ + object_depth_) == 0 )
|
1109 |
|
if( (array_depth_ + object_depth_) == 0 )
|
| 1110 |
|
return parent_->signal_value(ec);
|
1110 |
|
return parent_->signal_value(ec);
|
| 1111 |
|
|
1111 |
|
|
| 1112 |
|
|
1112 |
|
|
| 1113 |
|
|
1113 |
|
|
| 1114 |
|
bool on_null(system::error_code& ec)
|
1114 |
|
bool on_null(system::error_code& ec)
|
| 1115 |
|
|
1115 |
|
|
| 1116 |
|
if( (array_depth_ + object_depth_) == 0 )
|
1116 |
|
if( (array_depth_ + object_depth_) == 0 )
|
| 1117 |
|
return parent_->signal_value(ec);
|
1117 |
|
return parent_->signal_value(ec);
|
| 1118 |
|
|
1118 |
|
|
| 1119 |
|
|
1119 |
|
|
| 1120 |
|
|
1120 |
|
|
| 1121 |
|
|
1121 |
|
|
| 1122 |
|
template<class V, class P>
|
1122 |
|
template<class V, class P>
|
| 1123 |
|
class converting_handler<described_class_conversion_tag, V, P>
|
1123 |
|
class converting_handler<described_class_conversion_tag, V, P>
|
| 1124 |
|
|
1124 |
|
|
| 1125 |
|
#if !defined(BOOST_DESCRIBE_CXX14)
|
1125 |
|
#if !defined(BOOST_DESCRIBE_CXX14)
|
| 1126 |
|
|
1126 |
|
|
| 1127 |
|
|
1127 |
|
|
| 1128 |
|
sizeof(V) == 0, "Struct support for parse_into requires C++14" );
|
1128 |
|
sizeof(V) == 0, "Struct support for parse_into requires C++14" );
|
| 1129 |
|
|
1129 |
|
|
| 1130 |
|
|
1130 |
|
|
| 1131 |
|
|
1131 |
|
|
| 1132 |
|
|
1132 |
|
|
| 1133 |
|
|
1133 |
|
|
| 1134 |
|
uniquely_named_members<V>::value,
|
1134 |
|
uniquely_named_members<V>::value,
|
| 1135 |
|
"The type has several described members with the same name.");
|
1135 |
|
"The type has several described members with the same name.");
|
| 1136 |
|
|
1136 |
|
|
| 1137 |
|
using Dm = described_members<V>;
|
1137 |
|
using Dm = described_members<V>;
|
| 1138 |
|
using Dt = struct_element_list<V>;
|
1138 |
|
using Dt = struct_element_list<V>;
|
| 1139 |
|
|
1139 |
|
|
| 1140 |
|
|
1140 |
|
|
| 1141 |
|
using MemberHandler = get_handler<T, converting_handler>;
|
1141 |
|
using MemberHandler = get_handler<T, converting_handler>;
|
| 1142 |
|
using InnerHandlers = mp11::mp_push_back<
|
1142 |
|
using InnerHandlers = mp11::mp_push_back<
|
| 1143 |
|
mp11::mp_transform<MemberHandler, Dt>,
|
1143 |
|
mp11::mp_transform<MemberHandler, Dt>,
|
| 1144 |
|
ignoring_handler<converting_handler> >;
|
1144 |
|
ignoring_handler<converting_handler> >;
|
| 1145 |
|
using InnerCount = mp11::mp_size<InnerHandlers>;
|
1145 |
|
using InnerCount = mp11::mp_size<InnerHandlers>;
|
| 1146 |
|
|
1146 |
|
|
| 1147 |
|
|
1147 |
|
|
| 1148 |
|
|
1148 |
|
|
| 1149 |
|
|
1149 |
|
|
| 1150 |
|
|
1150 |
|
|
| 1151 |
|
|
1151 |
|
|
| 1152 |
|
handler_tuple<converting_handler, InnerHandlers> handlers_;
|
1152 |
|
handler_tuple<converting_handler, InnerHandlers> handlers_;
|
| 1153 |
|
|
1153 |
|
|
| 1154 |
|
std::size_t activated_ = 0;
|
1154 |
|
std::size_t activated_ = 0;
|
| 1155 |
|
|
1155 |
|
|
| 1156 |
|
|
1156 |
|
|
| 1157 |
|
converting_handler( converting_handler const& ) = delete;
|
1157 |
|
converting_handler( converting_handler const& ) = delete;
|
| 1158 |
|
converting_handler& operator=( converting_handler const& ) = delete;
|
1158 |
|
converting_handler& operator=( converting_handler const& ) = delete;
|
| 1159 |
|
|
1159 |
|
|
| 1160 |
|
converting_handler( V* v, P* p )
|
1160 |
|
converting_handler( V* v, P* p )
|
| 1161 |
|
: value_(v), parent_(p), handlers_(struct_accessor(), v, this)
|
1161 |
|
: value_(v), parent_(p), handlers_(struct_accessor(), v, this)
|
| 1162 |
|
|
1162 |
|
|
| 1163 |
|
|
1163 |
|
|
| 1164 |
|
struct is_required_checker
|
1164 |
|
struct is_required_checker
|
| 1165 |
|
|
1165 |
|
|
| 1166 |
|
bool operator()( mp11::mp_size<Dt> ) const noexcept
|
1166 |
|
bool operator()( mp11::mp_size<Dt> ) const noexcept
|
| 1167 |
|
|
1167 |
|
|
| 1168 |
|
|
1168 |
|
|
| 1169 |
|
|
1169 |
|
|
| 1170 |
|
|
1170 |
|
|
| 1171 |
|
|
1171 |
|
|
| 1172 |
|
auto operator()( I ) const noexcept
|
1172 |
|
auto operator()( I ) const noexcept
|
| 1173 |
|
|
1173 |
|
|
| 1174 |
|
using T = mp11::mp_at<Dt, I>;
|
1174 |
|
using T = mp11::mp_at<Dt, I>;
|
| 1175 |
|
return !is_optional_like<T>::value;
|
1175 |
|
return !is_optional_like<T>::value;
|
| 1176 |
|
|
1176 |
|
|
| 1177 |
|
|
1177 |
|
|
| 1178 |
|
|
1178 |
|
|
| 1179 |
|
bool signal_value(system::error_code&)
|
1179 |
|
bool signal_value(system::error_code&)
|
| 1180 |
|
|
1180 |
|
|
| 1181 |
|
BOOST_ASSERT( inner_active_ >= 0 );
|
1181 |
|
BOOST_ASSERT( inner_active_ >= 0 );
|
| 1182 |
|
bool required_member = mp11::mp_with_index<InnerCount>(
|
1182 |
|
bool required_member = mp11::mp_with_index<InnerCount>(
|
| 1183 |
|
|
1183 |
|
|
| 1184 |
|
|
1184 |
|
|
| 1185 |
|
|
1185 |
|
|
| 1186 |
|
|
1186 |
|
|
| 1187 |
|
|
1187 |
|
|
| 1188 |
|
|
1188 |
|
|
| 1189 |
|
|
1189 |
|
|
| 1190 |
|
|
1190 |
|
|
| 1191 |
|
|
1191 |
|
|
| 1192 |
|
|
1192 |
|
|
| 1193 |
|
bool signal_end(system::error_code& ec)
|
1193 |
|
bool signal_end(system::error_code& ec)
|
| 1194 |
|
|
1194 |
|
|
| 1195 |
|
|
1195 |
|
|
| 1196 |
|
|
1196 |
|
|
| 1197 |
|
return parent_->signal_value(ec);
|
1197 |
|
return parent_->signal_value(ec);
|
| 1198 |
|
|
1198 |
|
|
| 1199 |
|
|
1199 |
|
|
| 1200 |
|
#define BOOST_JSON_INVOKE_INNER(fn) \
|
1200 |
|
#define BOOST_JSON_INVOKE_INNER(fn) \
|
| 1201 |
|
if( inner_active_ < 0 ) \
|
1201 |
|
if( inner_active_ < 0 ) \
|
| 1202 |
|
|
1202 |
|
|
| 1203 |
|
BOOST_JSON_FAIL( ec, error::not_object ); \
|
1203 |
|
BOOST_JSON_FAIL( ec, error::not_object ); \
|
| 1204 |
|
|
1204 |
|
|
| 1205 |
|
|
1205 |
|
|
| 1206 |
|
auto f = [&](auto& handler) { return handler.fn ; }; \
|
1206 |
|
auto f = [&](auto& handler) { return handler.fn ; }; \
|
| 1207 |
|
|
1207 |
|
|
| 1208 |
|
using H = decltype(handlers_); \
|
1208 |
|
using H = decltype(handlers_); \
|
| 1209 |
|
return mp11::mp_with_index<InnerCount>( \
|
1209 |
|
return mp11::mp_with_index<InnerCount>( \
|
| 1210 |
|
|
1210 |
|
|
| 1211 |
|
tuple_handler_op_invoker<H, F>{handlers_, f} );
|
1211 |
|
tuple_handler_op_invoker<H, F>{handlers_, f} );
|
| 1212 |
|
|
1212 |
|
|
| 1213 |
|
bool on_object_begin( system::error_code& ec )
|
1213 |
|
bool on_object_begin( system::error_code& ec )
|
| 1214 |
|
|
1214 |
|
|
| 1215 |
|
|
1215 |
|
|
| 1216 |
|
|
1216 |
|
|
| 1217 |
|
|
1217 |
|
|
| 1218 |
|
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
1218 |
|
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
| 1219 |
|
|
1219 |
|
|
| 1220 |
|
|
1220 |
|
|
| 1221 |
|
bool on_object_end( system::error_code& ec )
|
1221 |
|
bool on_object_end( system::error_code& ec )
|
| 1222 |
|
|
1222 |
|
|
| 1223 |
|
|
1223 |
|
|
| 1224 |
|
|
1224 |
|
|
| 1225 |
|
using C = mp11::mp_count_if<Dt, is_optional_like>;
|
1225 |
|
using C = mp11::mp_count_if<Dt, is_optional_like>;
|
| 1226 |
|
constexpr int N = mp11::mp_size<Dt>::value - C::value;
|
1226 |
|
constexpr int N = mp11::mp_size<Dt>::value - C::value;
|
| 1227 |
|
|
1227 |
|
|
| 1228 |
|
|
1228 |
|
|
| 1229 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch );
|
1229 |
|
BOOST_JSON_FAIL( ec, error::size_mismatch );
|
| 1230 |
|
|
1230 |
|
|
| 1231 |
|
|
1231 |
|
|
| 1232 |
|
|
1232 |
|
|
| 1233 |
|
return parent_->signal_value(ec);
|
1233 |
|
return parent_->signal_value(ec);
|
| 1234 |
|
|
1234 |
|
|
| 1235 |
|
|
1235 |
|
|
| 1236 |
|
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
1236 |
|
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
| 1237 |
|
|
1237 |
|
|
| 1238 |
|
|
1238 |
|
|
| 1239 |
|
bool on_array_begin( system::error_code& ec )
|
1239 |
|
bool on_array_begin( system::error_code& ec )
|
| 1240 |
|
|
1240 |
|
|
| 1241 |
|
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
1241 |
|
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
| 1242 |
|
|
1242 |
|
|
| 1243 |
|
|
1243 |
|
|
| 1244 |
|
bool on_array_end( system::error_code& ec )
|
1244 |
|
bool on_array_end( system::error_code& ec )
|
| 1245 |
|
|
1245 |
|
|
| 1246 |
|
|
1246 |
|
|
| 1247 |
|
return parent_->signal_end(ec);
|
1247 |
|
return parent_->signal_end(ec);
|
| 1248 |
|
|
1248 |
|
|
| 1249 |
|
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
1249 |
|
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
| 1250 |
|
|
1250 |
|
|
| 1251 |
|
|
1251 |
|
|
| 1252 |
|
bool on_key_part( system::error_code& ec, string_view sv )
|
1252 |
|
bool on_key_part( system::error_code& ec, string_view sv )
|
| 1253 |
|
|
1253 |
|
|
| 1254 |
|
|
1254 |
|
|
| 1255 |
|
|
1255 |
|
|
| 1256 |
|
key_.append( sv.data(), sv.size() );
|
1256 |
|
key_.append( sv.data(), sv.size() );
|
| 1257 |
|
|
1257 |
|
|
| 1258 |
|
|
1258 |
|
|
| 1259 |
|
|
1259 |
|
|
| 1260 |
|
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
1260 |
|
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
| 1261 |
|
|
1261 |
|
|
| 1262 |
|
|
1262 |
|
|
| 1263 |
|
bool on_key( system::error_code& ec, string_view sv )
|
1263 |
|
bool on_key( system::error_code& ec, string_view sv )
|
| 1264 |
|
|
1264 |
|
|
| 1265 |
|
|
1265 |
|
|
| 1266 |
|
|
1266 |
|
|
| 1267 |
|
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
1267 |
|
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
| 1268 |
|
|
1268 |
|
|
| 1269 |
|
|
1269 |
|
|
| 1270 |
|
|
1270 |
|
|
| 1271 |
|
|
1271 |
|
|
| 1272 |
|
|
1272 |
|
|
| 1273 |
|
key_.append( sv.data(), sv.size() );
|
1273 |
|
key_.append( sv.data(), sv.size() );
|
| 1274 |
|
|
1274 |
|
|
| 1275 |
|
|
1275 |
|
|
| 1276 |
|
|
1276 |
|
|
| 1277 |
|
inner_active_ = InnerCount::value - 1;
|
1277 |
|
inner_active_ = InnerCount::value - 1;
|
| 1278 |
|
mp11::mp_for_each<Dm>( struct_key_searcher(key, inner_active_) );
|
1278 |
|
mp11::mp_for_each<Dm>( struct_key_searcher(key, inner_active_) );
|
| 1279 |
|
|
1279 |
|
|
| 1280 |
|
|
1280 |
|
|
| 1281 |
|
|
1281 |
|
|
| 1282 |
|
bool on_string_part( system::error_code& ec, string_view sv )
|
1282 |
|
bool on_string_part( system::error_code& ec, string_view sv )
|
| 1283 |
|
|
1283 |
|
|
| 1284 |
|
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
1284 |
|
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
| 1285 |
|
|
1285 |
|
|
| 1286 |
|
|
1286 |
|
|
| 1287 |
|
bool on_string( system::error_code& ec, string_view sv )
|
1287 |
|
bool on_string( system::error_code& ec, string_view sv )
|
| 1288 |
|
|
1288 |
|
|
| 1289 |
|
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
1289 |
|
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
| 1290 |
|
|
1290 |
|
|
| 1291 |
|
|
1291 |
|
|
| 1292 |
|
bool on_number_part( system::error_code& ec )
|
1292 |
|
bool on_number_part( system::error_code& ec )
|
| 1293 |
|
|
1293 |
|
|
| 1294 |
|
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
1294 |
|
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
| 1295 |
|
|
1295 |
|
|
| 1296 |
|
|
1296 |
|
|
| 1297 |
|
bool on_int64( system::error_code& ec, std::int64_t v )
|
1297 |
|
bool on_int64( system::error_code& ec, std::int64_t v )
|
| 1298 |
|
|
1298 |
|
|
| 1299 |
|
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
1299 |
|
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
| 1300 |
|
|
1300 |
|
|
| 1301 |
|
|
1301 |
|
|
| 1302 |
|
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
1302 |
|
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
| 1303 |
|
|
1303 |
|
|
| 1304 |
|
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
1304 |
|
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
| 1305 |
|
|
1305 |
|
|
| 1306 |
|
|
1306 |
|
|
| 1307 |
|
bool on_double( system::error_code& ec, double v )
|
1307 |
|
bool on_double( system::error_code& ec, double v )
|
| 1308 |
|
|
1308 |
|
|
| 1309 |
|
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
1309 |
|
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
| 1310 |
|
|
1310 |
|
|
| 1311 |
|
|
1311 |
|
|
| 1312 |
|
bool on_bool( system::error_code& ec, bool v )
|
1312 |
|
bool on_bool( system::error_code& ec, bool v )
|
| 1313 |
|
|
1313 |
|
|
| 1314 |
|
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
1314 |
|
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
| 1315 |
|
|
1315 |
|
|
| 1316 |
|
|
1316 |
|
|
| 1317 |
|
bool on_null( system::error_code& ec )
|
1317 |
|
bool on_null( system::error_code& ec )
|
| 1318 |
|
|
1318 |
|
|
| 1319 |
|
BOOST_JSON_INVOKE_INNER( on_null(ec) );
|
1319 |
|
BOOST_JSON_INVOKE_INNER( on_null(ec) );
|
| 1320 |
|
|
1320 |
|
|
| 1321 |
|
|
1321 |
|
|
| 1322 |
|
#undef BOOST_JSON_INVOKE_INNER
|
1322 |
|
#undef BOOST_JSON_INVOKE_INNER
|
| 1323 |
|
|
1323 |
|
|
| 1324 |
|
|
1324 |
|
|
| 1325 |
|
|
1325 |
|
|
| 1326 |
|
|
1326 |
|
|
| 1327 |
|
|
1327 |
|
|
| 1328 |
|
struct object_begin_handler_event
|
1328 |
|
struct object_begin_handler_event
|
| 1329 |
|
|
1329 |
|
|
| 1330 |
|
|
1330 |
|
|
| 1331 |
|
struct object_end_handler_event
|
1331 |
|
struct object_end_handler_event
|
| 1332 |
|
|
1332 |
|
|
| 1333 |
|
|
1333 |
|
|
| 1334 |
|
struct array_begin_handler_event
|
1334 |
|
struct array_begin_handler_event
|
| 1335 |
|
|
1335 |
|
|
| 1336 |
|
|
1336 |
|
|
| 1337 |
|
struct array_end_handler_event
|
1337 |
|
struct array_end_handler_event
|
| 1338 |
|
|
1338 |
|
|
| 1339 |
|
|
1339 |
|
|
| 1340 |
|
|
1340 |
|
|
| 1341 |
|
|
1341 |
|
|
| 1342 |
|
|
1342 |
|
|
| 1343 |
|
|
1343 |
|
|
| 1344 |
|
|
1344 |
|
|
| 1345 |
|
struct string_handler_event
|
1345 |
|
struct string_handler_event
|
| 1346 |
|
|
1346 |
|
|
| 1347 |
|
|
1347 |
|
|
| 1348 |
|
|
1348 |
|
|
| 1349 |
|
|
1349 |
|
|
| 1350 |
|
struct int64_handler_event
|
1350 |
|
struct int64_handler_event
|
| 1351 |
|
|
1351 |
|
|
| 1352 |
|
|
1352 |
|
|
| 1353 |
|
|
1353 |
|
|
| 1354 |
|
|
1354 |
|
|
| 1355 |
|
struct uint64_handler_event
|
1355 |
|
struct uint64_handler_event
|
| 1356 |
|
|
1356 |
|
|
| 1357 |
|
|
1357 |
|
|
| 1358 |
|
|
1358 |
|
|
| 1359 |
|
|
1359 |
|
|
| 1360 |
|
struct double_handler_event
|
1360 |
|
struct double_handler_event
|
| 1361 |
|
|
1361 |
|
|
| 1362 |
|
|
1362 |
|
|
| 1363 |
|
|
1363 |
|
|
| 1364 |
|
|
1364 |
|
|
| 1365 |
|
struct bool_handler_event
|
1365 |
|
struct bool_handler_event
|
| 1366 |
|
|
1366 |
|
|
| 1367 |
|
|
1367 |
|
|
| 1368 |
|
|
1368 |
|
|
| 1369 |
|
|
1369 |
|
|
| 1370 |
|
struct null_handler_event
|
1370 |
|
struct null_handler_event
|
| 1371 |
|
|
1371 |
|
|
| 1372 |
|
|
1372 |
|
|
| 1373 |
|
using parse_event = variant2::variant<
|
1373 |
|
using parse_event = variant2::variant<
|
| 1374 |
|
object_begin_handler_event,
|
1374 |
|
object_begin_handler_event,
|
| 1375 |
|
object_end_handler_event,
|
1375 |
|
object_end_handler_event,
|
| 1376 |
|
array_begin_handler_event,
|
1376 |
|
array_begin_handler_event,
|
| 1377 |
|
|
1377 |
|
|
| 1378 |
|
|
1378 |
|
|
| 1379 |
|
|
1379 |
|
|
| 1380 |
|
|
1380 |
|
|
| 1381 |
|
|
1381 |
|
|
| 1382 |
|
|
1382 |
|
|
| 1383 |
|
|
1383 |
|
|
| 1384 |
|
|
1384 |
|
|
| 1385 |
|
|
1385 |
|
|
| 1386 |
|
|
1386 |
|
|
| 1387 |
|
|
1387 |
|
|
| 1388 |
|
|
1388 |
|
|
| 1389 |
|
|
1389 |
|
|
| 1390 |
|
|
1390 |
|
|
| 1391 |
|
|
1391 |
|
|
| 1392 |
|
|
1392 |
|
|
| 1393 |
|
operator()(object_begin_handler_event&) const
|
1393 |
|
operator()(object_begin_handler_event&) const
|
| 1394 |
|
|
1394 |
|
|
| 1395 |
|
return handler.on_object_begin(ec);
|
1395 |
|
return handler.on_object_begin(ec);
|
| 1396 |
|
|
1396 |
|
|
| 1397 |
|
|
1397 |
|
|
| 1398 |
|
|
1398 |
|
|
| 1399 |
|
operator()(object_end_handler_event&) const
|
1399 |
|
operator()(object_end_handler_event&) const
|
| 1400 |
|
|
1400 |
|
|
| 1401 |
|
return handler.on_object_end(ec);
|
1401 |
|
return handler.on_object_end(ec);
|
| 1402 |
|
|
1402 |
|
|
| 1403 |
|
|
1403 |
|
|
| 1404 |
|
|
1404 |
|
|
| 1405 |
|
operator()(array_begin_handler_event&) const
|
1405 |
|
operator()(array_begin_handler_event&) const
|
| 1406 |
|
|
1406 |
|
|
| 1407 |
|
return handler.on_array_begin(ec);
|
1407 |
|
return handler.on_array_begin(ec);
|
| 1408 |
|
|
1408 |
|
|
| 1409 |
|
|
1409 |
|
|
| 1410 |
|
|
1410 |
|
|
| 1411 |
|
operator()(array_end_handler_event&) const
|
1411 |
|
operator()(array_end_handler_event&) const
|
| 1412 |
|
|
1412 |
|
|
| 1413 |
|
return handler.on_array_end(ec);
|
1413 |
|
return handler.on_array_end(ec);
|
| 1414 |
|
|
1414 |
|
|
| 1415 |
|
|
1415 |
|
|
| 1416 |
|
|
1416 |
|
|
| 1417 |
|
operator()(key_handler_event& ev) const
|
1417 |
|
operator()(key_handler_event& ev) const
|
| 1418 |
|
|
1418 |
|
|
| 1419 |
|
return handler.on_key(ec, ev.value);
|
1419 |
|
return handler.on_key(ec, ev.value);
|
| 1420 |
|
|
1420 |
|
|
| 1421 |
|
|
1421 |
|
|
| 1422 |
|
|
1422 |
|
|
| 1423 |
|
operator()(string_handler_event& ev) const
|
1423 |
|
operator()(string_handler_event& ev) const
|
| 1424 |
|
|
1424 |
|
|
| 1425 |
|
return handler.on_string(ec, ev.value);
|
1425 |
|
return handler.on_string(ec, ev.value);
|
| 1426 |
|
|
1426 |
|
|
| 1427 |
|
|
1427 |
|
|
| 1428 |
|
|
1428 |
|
|
| 1429 |
|
operator()(int64_handler_event& ev) const
|
1429 |
|
operator()(int64_handler_event& ev) const
|
| 1430 |
|
|
1430 |
|
|
| 1431 |
|
return handler.on_int64(ec, ev.value);
|
1431 |
|
return handler.on_int64(ec, ev.value);
|
| 1432 |
|
|
1432 |
|
|
| 1433 |
|
|
1433 |
|
|
| 1434 |
|
|
1434 |
|
|
| 1435 |
|
operator()(uint64_handler_event& ev) const
|
1435 |
|
operator()(uint64_handler_event& ev) const
|
| 1436 |
|
|
1436 |
|
|
| 1437 |
|
return handler.on_uint64(ec, ev.value);
|
1437 |
|
return handler.on_uint64(ec, ev.value);
|
| 1438 |
|
|
1438 |
|
|
| 1439 |
|
|
1439 |
|
|
| 1440 |
|
|
1440 |
|
|
| 1441 |
|
operator()(double_handler_event& ev) const
|
1441 |
|
operator()(double_handler_event& ev) const
|
| 1442 |
|
|
1442 |
|
|
| 1443 |
|
return handler.on_double(ec, ev.value);
|
1443 |
|
return handler.on_double(ec, ev.value);
|
| 1444 |
|
|
1444 |
|
|
| 1445 |
|
|
1445 |
|
|
| 1446 |
|
|
1446 |
|
|
| 1447 |
|
operator()(bool_handler_event& ev) const
|
1447 |
|
operator()(bool_handler_event& ev) const
|
| 1448 |
|
|
1448 |
|
|
| 1449 |
|
return handler.on_bool(ec, ev.value);
|
1449 |
|
return handler.on_bool(ec, ev.value);
|
| 1450 |
|
|
1450 |
|
|
| 1451 |
|
|
1451 |
|
|
| 1452 |
|
|
1452 |
|
|
| 1453 |
|
operator()(null_handler_event&) const
|
1453 |
|
operator()(null_handler_event&) const
|
| 1454 |
|
|
1454 |
|
|
| 1455 |
|
return handler.on_null(ec);
|
1455 |
|
return handler.on_null(ec);
|
| 1456 |
|
|
1456 |
|
|
| 1457 |
|
|
1457 |
|
|
| 1458 |
|
|
1458 |
|
|
| 1459 |
|
// L<T...> -> variant< monostate, get_handler<T, P>... >
|
1459 |
|
// L<T...> -> variant< monostate, get_handler<T, P>... >
|
| 1460 |
|
template< class P, class L >
|
1460 |
|
template< class P, class L >
|
| 1461 |
|
using inner_handler_variant = mp11::mp_push_front<
|
1461 |
|
using inner_handler_variant = mp11::mp_push_front<
|
| 1462 |
|
|
1462 |
|
|
| 1463 |
|
mp11::mp_bind_back<get_handler, P>,
|
1463 |
|
mp11::mp_bind_back<get_handler, P>,
|
| 1464 |
|
mp11::mp_apply<variant2::variant, L>>,
|
1464 |
|
mp11::mp_apply<variant2::variant, L>>,
|
| 1465 |
|
|
1465 |
|
|
| 1466 |
|
|
1466 |
|
|
| 1467 |
|
template< class T, class P >
|
1467 |
|
template< class T, class P >
|
| 1468 |
|
class converting_handler<variant_conversion_tag, T, P>
|
1468 |
|
class converting_handler<variant_conversion_tag, T, P>
|
| 1469 |
|
|
1469 |
|
|
| 1470 |
|
|
1470 |
|
|
| 1471 |
|
using variant_size = mp11::mp_size<T>;
|
1471 |
|
using variant_size = mp11::mp_size<T>;
|
| 1472 |
|
|
1472 |
|
|
| 1473 |
|
|
1473 |
|
|
| 1474 |
|
|
1474 |
|
|
| 1475 |
|
|
1475 |
|
|
| 1476 |
|
|
1476 |
|
|
| 1477 |
|
std::vector< parse_event > events_;
|
1477 |
|
std::vector< parse_event > events_;
|
| 1478 |
|
inner_handler_variant<converting_handler, T> inner_;
|
1478 |
|
inner_handler_variant<converting_handler, T> inner_;
|
| 1479 |
|
|
1479 |
|
|
| 1480 |
|
|
1480 |
|
|
| 1481 |
|
|
1481 |
|
|
| 1482 |
|
converting_handler( converting_handler const& ) = delete;
|
1482 |
|
converting_handler( converting_handler const& ) = delete;
|
| 1483 |
|
converting_handler& operator=( converting_handler const& ) = delete;
|
1483 |
|
converting_handler& operator=( converting_handler const& ) = delete;
|
| 1484 |
|
|
1484 |
|
|
| 1485 |
|
converting_handler( T* v, P* p )
|
1485 |
|
converting_handler( T* v, P* p )
|
| 1486 |
|
|
1486 |
|
|
| 1487 |
|
|
1487 |
|
|
| 1488 |
|
|
1488 |
|
|
| 1489 |
|
|
1489 |
|
|
| 1490 |
|
bool signal_value(system::error_code& ec)
|
1490 |
|
bool signal_value(system::error_code& ec)
|
| 1491 |
|
|
1491 |
|
|
| 1492 |
|
inner_.template emplace<0>();
|
1492 |
|
inner_.template emplace<0>();
|
| 1493 |
|
|
1493 |
|
|
| 1494 |
|
|
1494 |
|
|
| 1495 |
|
return parent_->signal_value(ec);
|
1495 |
|
return parent_->signal_value(ec);
|
| 1496 |
|
|
1496 |
|
|
| 1497 |
|
|
1497 |
|
|
| 1498 |
|
bool signal_end(system::error_code& ec)
|
1498 |
|
bool signal_end(system::error_code& ec)
|
| 1499 |
|
|
1499 |
|
|
| 1500 |
|
return parent_->signal_end(ec);
|
1500 |
|
return parent_->signal_end(ec);
|
| 1501 |
|
|
1501 |
|
|
| 1502 |
|
|
1502 |
|
|
| 1503 |
|
struct alternative_selector
|
1503 |
|
struct alternative_selector
|
| 1504 |
|
|
1504 |
|
|
| 1505 |
|
converting_handler* self;
|
1505 |
|
converting_handler* self;
|
| 1506 |
|
|
1506 |
|
|
| 1507 |
|
|
1507 |
|
|
| 1508 |
|
|
1508 |
|
|
| 1509 |
|
|
1509 |
|
|
| 1510 |
|
|
1510 |
|
|
| 1511 |
|
using V = mp11::mp_at<T, I>;
|
1511 |
|
using V = mp11::mp_at<T, I>;
|
| 1512 |
|
auto& v = self->value_->template emplace<I::value>( V{} );
|
1512 |
|
auto& v = self->value_->template emplace<I::value>( V{} );
|
| 1513 |
|
self->inner_.template emplace<I::value + 1>(&v, self);
|
1513 |
|
self->inner_.template emplace<I::value + 1>(&v, self);
|
| 1514 |
|
|
1514 |
|
|
| 1515 |
|
|
1515 |
|
|
| 1516 |
|
|
1516 |
|
|
| 1517 |
|
|
1517 |
|
|
| 1518 |
|
|
1518 |
|
|
| 1519 |
|
if( ++inner_active_ >= static_cast<int>(variant_size::value) )
|
1519 |
|
if( ++inner_active_ >= static_cast<int>(variant_size::value) )
|
| 1520 |
|
|
1520 |
|
|
| 1521 |
|
|
1521 |
|
|
| 1522 |
|
mp11::mp_with_index< variant_size::value >(
|
1522 |
|
mp11::mp_with_index< variant_size::value >(
|
| 1523 |
|
inner_active_, alternative_selector{this} );
|
1523 |
|
inner_active_, alternative_selector{this} );
|
| 1524 |
|
|
1524 |
|
|
| 1525 |
|
|
1525 |
|
|
| 1526 |
|
|
1526 |
|
|
| 1527 |
|
|
1527 |
|
|
| 1528 |
|
converting_handler* self;
|
1528 |
|
converting_handler* self;
|
| 1529 |
|
|
1529 |
|
|
| 1530 |
|
|
1530 |
|
|
| 1531 |
|
|
1531 |
|
|
| 1532 |
|
|
1532 |
|
|
| 1533 |
|
bool operator()( I ) const
|
1533 |
|
bool operator()( I ) const
|
| 1534 |
|
|
1534 |
|
|
| 1535 |
|
auto& handler = variant2::get<I::value + 1>(self->inner_);
|
1535 |
|
auto& handler = variant2::get<I::value + 1>(self->inner_);
|
| 1536 |
|
using Handler = remove_cvref<decltype(handler)>;
|
1536 |
|
using Handler = remove_cvref<decltype(handler)>;
|
| 1537 |
|
|
1537 |
|
|
| 1538 |
|
event_visitor<Handler>{handler, ec}, event );
|
1538 |
|
event_visitor<Handler>{handler, ec}, event );
|
| 1539 |
|
|
1539 |
|
|
| 1540 |
|
|
1540 |
|
|
| 1541 |
|
bool process_events(system::error_code& ec)
|
1541 |
|
bool process_events(system::error_code& ec)
|
| 1542 |
|
|
1542 |
|
|
| 1543 |
|
constexpr std::size_t N = variant_size::value;
|
1543 |
|
constexpr std::size_t N = variant_size::value;
|
| 1544 |
|
|
1544 |
|
|
| 1545 |
|
// should be pointers not iterators, otherwise MSVC crashes
|
1545 |
|
// should be pointers not iterators, otherwise MSVC crashes
|
| 1546 |
|
auto const last = events_.data() + events_.size();
|
1546 |
|
auto const last = events_.data() + events_.size();
|
| 1547 |
|
|
1547 |
|
|
| 1548 |
|
|
1548 |
|
|
| 1549 |
|
|
1549 |
|
|
| 1550 |
|
|
1550 |
|
|
| 1551 |
|
|
1551 |
|
|
| 1552 |
|
|
1552 |
|
|
| 1553 |
|
|
1553 |
|
|
| 1554 |
|
if( static_cast<std::size_t>(inner_active_) >= N )
|
1554 |
|
if( static_cast<std::size_t>(inner_active_) >= N )
|
| 1555 |
|
|
1555 |
|
|
| 1556 |
|
BOOST_JSON_FAIL( ec, error::exhausted_variants );
|
1556 |
|
BOOST_JSON_FAIL( ec, error::exhausted_variants );
|
| 1557 |
|
|
1557 |
|
|
| 1558 |
|
|
1558 |
|
|
| 1559 |
|
|
1559 |
|
|
| 1560 |
|
for ( ; first != last; ++first )
|
1560 |
|
for ( ; first != last; ++first )
|
| 1561 |
|
|
1561 |
|
|
| 1562 |
|
ok = mp11::mp_with_index< N >(
|
1562 |
|
ok = mp11::mp_with_index< N >(
|
| 1563 |
|
inner_active_, event_processor{this, ec, *first} );
|
1563 |
|
inner_active_, event_processor{this, ec, *first} );
|
| 1564 |
|
|
1564 |
|
|
| 1565 |
|
|
1565 |
|
|
| 1566 |
|
|
1566 |
|
|
| 1567 |
|
|
1567 |
|
|
| 1568 |
|
|
1568 |
|
|
| 1569 |
|
|
1569 |
|
|
| 1570 |
|
|
1570 |
|
|
| 1571 |
|
|
1571 |
|
|
| 1572 |
|
|
1572 |
|
|
| 1573 |
|
|
1573 |
|
|
| 1574 |
|
|
1574 |
|
|
| 1575 |
|
|
1575 |
|
|
| 1576 |
|
|
1576 |
|
|
| 1577 |
|
|
1577 |
|
|
| 1578 |
|
#define BOOST_JSON_INVOKE_INNER(ev, ec) \
|
1578 |
|
#define BOOST_JSON_INVOKE_INNER(ev, ec) \
|
| 1579 |
|
events_.emplace_back( ev ); \
|
1579 |
|
events_.emplace_back( ev ); \
|
| 1580 |
|
return process_events(ec);
|
1580 |
|
return process_events(ec);
|
| 1581 |
|
|
1581 |
|
|
| 1582 |
|
bool on_object_begin( system::error_code& ec )
|
1582 |
|
bool on_object_begin( system::error_code& ec )
|
| 1583 |
|
|
1583 |
|
|
| 1584 |
|
BOOST_JSON_INVOKE_INNER( object_begin_handler_event{}, ec );
|
1584 |
|
BOOST_JSON_INVOKE_INNER( object_begin_handler_event{}, ec );
|
| 1585 |
|
|
1585 |
|
|
| 1586 |
|
|
1586 |
|
|
| 1587 |
|
bool on_object_end( system::error_code& ec )
|
1587 |
|
bool on_object_end( system::error_code& ec )
|
| 1588 |
|
|
1588 |
|
|
| 1589 |
|
BOOST_JSON_INVOKE_INNER( object_end_handler_event{}, ec );
|
1589 |
|
BOOST_JSON_INVOKE_INNER( object_end_handler_event{}, ec );
|
| 1590 |
|
|
1590 |
|
|
| 1591 |
|
|
1591 |
|
|
| 1592 |
|
bool on_array_begin( system::error_code& ec )
|
1592 |
|
bool on_array_begin( system::error_code& ec )
|
| 1593 |
|
|
1593 |
|
|
| 1594 |
|
BOOST_JSON_INVOKE_INNER( array_begin_handler_event{}, ec );
|
1594 |
|
BOOST_JSON_INVOKE_INNER( array_begin_handler_event{}, ec );
|
| 1595 |
|
|
1595 |
|
|
| 1596 |
|
|
1596 |
|
|
| 1597 |
|
bool on_array_end( system::error_code& ec )
|
1597 |
|
bool on_array_end( system::error_code& ec )
|
| 1598 |
|
|
1598 |
|
|
| 1599 |
|
|
1599 |
|
|
| 1600 |
|
|
1600 |
|
|
| 1601 |
|
|
1601 |
|
|
| 1602 |
|
BOOST_JSON_INVOKE_INNER( array_end_handler_event{}, ec );
|
1602 |
|
BOOST_JSON_INVOKE_INNER( array_end_handler_event{}, ec );
|
| 1603 |
|
|
1603 |
|
|
| 1604 |
|
|
1604 |
|
|
| 1605 |
|
bool on_key_part( system::error_code&, string_view sv )
|
1605 |
|
bool on_key_part( system::error_code&, string_view sv )
|
| 1606 |
|
|
1606 |
|
|
| 1607 |
|
|
1607 |
|
|
| 1608 |
|
|
1608 |
|
|
| 1609 |
|
|
1609 |
|
|
| 1610 |
|
|
1610 |
|
|
| 1611 |
|
bool on_key( system::error_code& ec, string_view sv )
|
1611 |
|
bool on_key( system::error_code& ec, string_view sv )
|
| 1612 |
|
|
1612 |
|
|
| 1613 |
|
|
1613 |
|
|
| 1614 |
|
BOOST_JSON_INVOKE_INNER( key_handler_event{ std::move(string_) }, ec );
|
1614 |
|
BOOST_JSON_INVOKE_INNER( key_handler_event{ std::move(string_) }, ec );
|
| 1615 |
|
|
1615 |
|
|
| 1616 |
|
|
1616 |
|
|
| 1617 |
|
bool on_string_part( system::error_code&, string_view sv )
|
1617 |
|
bool on_string_part( system::error_code&, string_view sv )
|
| 1618 |
|
|
1618 |
|
|
| 1619 |
|
|
1619 |
|
|
| 1620 |
|
|
1620 |
|
|
| 1621 |
|
|
1621 |
|
|
| 1622 |
|
|
1622 |
|
|
| 1623 |
|
bool on_string( system::error_code& ec, string_view sv )
|
1623 |
|
bool on_string( system::error_code& ec, string_view sv )
|
| 1624 |
|
|
1624 |
|
|
| 1625 |
|
|
1625 |
|
|
| 1626 |
|
|
1626 |
|
|
| 1627 |
|
string_handler_event{ std::move(string_) }, ec );
|
1627 |
|
string_handler_event{ std::move(string_) }, ec );
|
| 1628 |
|
|
1628 |
|
|
| 1629 |
|
|
1629 |
|
|
| 1630 |
|
bool on_number_part( system::error_code& )
|
1630 |
|
bool on_number_part( system::error_code& )
|
| 1631 |
|
|
1631 |
|
|
| 1632 |
|
|
1632 |
|
|
| 1633 |
|
|
1633 |
|
|
| 1634 |
|
|
1634 |
|
|
| 1635 |
|
bool on_int64( system::error_code& ec, std::int64_t v )
|
1635 |
|
bool on_int64( system::error_code& ec, std::int64_t v )
|
| 1636 |
|
|
1636 |
|
|
| 1637 |
|
BOOST_JSON_INVOKE_INNER( int64_handler_event{v}, ec );
|
1637 |
|
BOOST_JSON_INVOKE_INNER( int64_handler_event{v}, ec );
|
| 1638 |
|
|
1638 |
|
|
| 1639 |
|
|
1639 |
|
|
| 1640 |
|
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
1640 |
|
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
| 1641 |
|
|
1641 |
|
|
| 1642 |
|
BOOST_JSON_INVOKE_INNER( uint64_handler_event{v}, ec );
|
1642 |
|
BOOST_JSON_INVOKE_INNER( uint64_handler_event{v}, ec );
|
| 1643 |
|
|
1643 |
|
|
| 1644 |
|
|
1644 |
|
|
| 1645 |
|
bool on_double( system::error_code& ec, double v )
|
1645 |
|
bool on_double( system::error_code& ec, double v )
|
| 1646 |
|
|
1646 |
|
|
| 1647 |
|
BOOST_JSON_INVOKE_INNER( double_handler_event{v}, ec );
|
1647 |
|
BOOST_JSON_INVOKE_INNER( double_handler_event{v}, ec );
|
| 1648 |
|
|
1648 |
|
|
| 1649 |
|
|
1649 |
|
|
| 1650 |
|
bool on_bool( system::error_code& ec, bool v )
|
1650 |
|
bool on_bool( system::error_code& ec, bool v )
|
| 1651 |
|
|
1651 |
|
|
| 1652 |
|
BOOST_JSON_INVOKE_INNER( bool_handler_event{v}, ec );
|
1652 |
|
BOOST_JSON_INVOKE_INNER( bool_handler_event{v}, ec );
|
| 1653 |
|
|
1653 |
|
|
| 1654 |
|
|
1654 |
|
|
| 1655 |
|
bool on_null( system::error_code& ec )
|
1655 |
|
bool on_null( system::error_code& ec )
|
| 1656 |
|
|
1656 |
|
|
| 1657 |
|
BOOST_JSON_INVOKE_INNER( null_handler_event{}, ec );
|
1657 |
|
BOOST_JSON_INVOKE_INNER( null_handler_event{}, ec );
|
| 1658 |
|
|
1658 |
|
|
| 1659 |
|
|
1659 |
|
|
| 1660 |
|
#undef BOOST_JSON_INVOKE_INNER
|
1660 |
|
#undef BOOST_JSON_INVOKE_INNER
|
| 1661 |
|
|
1661 |
|
|
| 1662 |
|
|
1662 |
|
|
| 1663 |
|
|
1663 |
|
|
| 1664 |
|
template<class V, class P>
|
1664 |
|
template<class V, class P>
|
| 1665 |
|
class converting_handler<optional_conversion_tag, V, P>
|
1665 |
|
class converting_handler<optional_conversion_tag, V, P>
|
| 1666 |
|
|
1666 |
|
|
| 1667 |
|
|
1667 |
|
|
| 1668 |
|
using inner_type = value_result_type<V>;
|
1668 |
|
using inner_type = value_result_type<V>;
|
| 1669 |
|
using inner_handler_type = get_handler<inner_type, converting_handler>;
|
1669 |
|
using inner_handler_type = get_handler<inner_type, converting_handler>;
|
| 1670 |
|
|
1670 |
|
|
| 1671 |
|
|
1671 |
|
|
| 1672 |
|
|
1672 |
|
|
| 1673 |
|
|
1673 |
|
|
| 1674 |
|
inner_type inner_value_ = {};
|
1674 |
|
inner_type inner_value_ = {};
|
| 1675 |
|
inner_handler_type inner_;
|
1675 |
|
inner_handler_type inner_;
|
| 1676 |
|
bool inner_active_ = false;
|
1676 |
|
bool inner_active_ = false;
|
| 1677 |
|
|
1677 |
|
|
| 1678 |
|
|
1678 |
|
|
| 1679 |
|
converting_handler( converting_handler const& ) = delete;
|
1679 |
|
converting_handler( converting_handler const& ) = delete;
|
| 1680 |
|
converting_handler& operator=( converting_handler const& ) = delete;
|
1680 |
|
converting_handler& operator=( converting_handler const& ) = delete;
|
| 1681 |
|
|
1681 |
|
|
| 1682 |
|
converting_handler( V* v, P* p )
|
1682 |
|
converting_handler( V* v, P* p )
|
| 1683 |
|
: value_(v), parent_(p), inner_(&inner_value_, this)
|
1683 |
|
: value_(v), parent_(p), inner_(&inner_value_, this)
|
| 1684 |
|
|
1684 |
|
|
| 1685 |
|
|
1685 |
|
|
| 1686 |
|
bool signal_value(system::error_code& ec)
|
1686 |
|
bool signal_value(system::error_code& ec)
|
| 1687 |
|
|
1687 |
|
|
| 1688 |
|
*value_ = std::move(inner_value_);
|
1688 |
|
*value_ = std::move(inner_value_);
|
| 1689 |
|
|
1689 |
|
|
| 1690 |
|
|
1690 |
|
|
| 1691 |
|
return parent_->signal_value(ec);
|
1691 |
|
return parent_->signal_value(ec);
|
| 1692 |
|
|
1692 |
|
|
| 1693 |
|
|
1693 |
|
|
| 1694 |
|
bool signal_end(system::error_code& ec)
|
1694 |
|
bool signal_end(system::error_code& ec)
|
| 1695 |
|
|
1695 |
|
|
| 1696 |
|
return parent_->signal_end(ec);
|
1696 |
|
return parent_->signal_end(ec);
|
| 1697 |
|
|
1697 |
|
|
| 1698 |
|
|
1698 |
|
|
| 1699 |
|
#define BOOST_JSON_INVOKE_INNER(fn) \
|
1699 |
|
#define BOOST_JSON_INVOKE_INNER(fn) \
|
| 1700 |
|
|
1700 |
|
|
| 1701 |
|
|
1701 |
|
|
| 1702 |
|
|
1702 |
|
|
| 1703 |
|
|
1703 |
|
|
| 1704 |
|
bool on_object_begin( system::error_code& ec )
|
1704 |
|
bool on_object_begin( system::error_code& ec )
|
| 1705 |
|
|
1705 |
|
|
| 1706 |
|
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
1706 |
|
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
| 1707 |
|
|
1707 |
|
|
| 1708 |
|
|
1708 |
|
|
| 1709 |
|
bool on_object_end( system::error_code& ec )
|
1709 |
|
bool on_object_end( system::error_code& ec )
|
| 1710 |
|
|
1710 |
|
|
| 1711 |
|
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
1711 |
|
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
| 1712 |
|
|
1712 |
|
|
| 1713 |
|
|
1713 |
|
|
| 1714 |
|
bool on_array_begin( system::error_code& ec )
|
1714 |
|
bool on_array_begin( system::error_code& ec )
|
| 1715 |
|
|
1715 |
|
|
| 1716 |
|
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
1716 |
|
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
| 1717 |
|
|
1717 |
|
|
| 1718 |
|
|
1718 |
|
|
| 1719 |
|
bool on_array_end( system::error_code& ec )
|
1719 |
|
bool on_array_end( system::error_code& ec )
|
| 1720 |
|
|
1720 |
|
|
| 1721 |
|
|
1721 |
|
|
| 1722 |
|
|
1722 |
|
|
| 1723 |
|
|
1723 |
|
|
| 1724 |
|
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
1724 |
|
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
| 1725 |
|
|
1725 |
|
|
| 1726 |
|
|
1726 |
|
|
| 1727 |
|
bool on_key_part( system::error_code& ec, string_view sv )
|
1727 |
|
bool on_key_part( system::error_code& ec, string_view sv )
|
| 1728 |
|
|
1728 |
|
|
| 1729 |
|
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
1729 |
|
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
| 1730 |
|
|
1730 |
|
|
| 1731 |
|
|
1731 |
|
|
| 1732 |
|
bool on_key( system::error_code& ec, string_view sv )
|
1732 |
|
bool on_key( system::error_code& ec, string_view sv )
|
| 1733 |
|
|
1733 |
|
|
| 1734 |
|
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
1734 |
|
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
| 1735 |
|
|
1735 |
|
|
| 1736 |
|
|
1736 |
|
|
| 1737 |
|
bool on_string_part( system::error_code& ec, string_view sv )
|
1737 |
|
bool on_string_part( system::error_code& ec, string_view sv )
|
| 1738 |
|
|
1738 |
|
|
| 1739 |
|
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
1739 |
|
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
| 1740 |
|
|
1740 |
|
|
| 1741 |
|
|
1741 |
|
|
| 1742 |
|
bool on_string( system::error_code& ec, string_view sv )
|
1742 |
|
bool on_string( system::error_code& ec, string_view sv )
|
| 1743 |
|
|
1743 |
|
|
| 1744 |
|
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
1744 |
|
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
| 1745 |
|
|
1745 |
|
|
| 1746 |
|
|
1746 |
|
|
| 1747 |
|
bool on_number_part( system::error_code& ec )
|
1747 |
|
bool on_number_part( system::error_code& ec )
|
| 1748 |
|
|
1748 |
|
|
| 1749 |
|
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
1749 |
|
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
| 1750 |
|
|
1750 |
|
|
| 1751 |
|
|
1751 |
|
|
| 1752 |
|
bool on_int64( system::error_code& ec, std::int64_t v )
|
1752 |
|
bool on_int64( system::error_code& ec, std::int64_t v )
|
| 1753 |
|
|
1753 |
|
|
| 1754 |
|
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
1754 |
|
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
| 1755 |
|
|
1755 |
|
|
| 1756 |
|
|
1756 |
|
|
| 1757 |
|
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
1757 |
|
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
| 1758 |
|
|
1758 |
|
|
| 1759 |
|
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
1759 |
|
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
| 1760 |
|
|
1760 |
|
|
| 1761 |
|
|
1761 |
|
|
| 1762 |
|
bool on_double( system::error_code& ec, double v )
|
1762 |
|
bool on_double( system::error_code& ec, double v )
|
| 1763 |
|
|
1763 |
|
|
| 1764 |
|
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
1764 |
|
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
| 1765 |
|
|
1765 |
|
|
| 1766 |
|
|
1766 |
|
|
| 1767 |
|
bool on_bool( system::error_code& ec, bool v )
|
1767 |
|
bool on_bool( system::error_code& ec, bool v )
|
| 1768 |
|
|
1768 |
|
|
| 1769 |
|
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
1769 |
|
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
| 1770 |
|
|
1770 |
|
|
| 1771 |
|
|
1771 |
|
|
| 1772 |
|
bool on_null(system::error_code& ec)
|
1772 |
|
bool on_null(system::error_code& ec)
|
| 1773 |
|
|
1773 |
|
|
| 1774 |
|
|
1774 |
|
|
| 1775 |
|
|
1775 |
|
|
| 1776 |
|
|
1776 |
|
|
| 1777 |
|
return this->parent_->signal_value(ec);
|
1777 |
|
return this->parent_->signal_value(ec);
|
| 1778 |
|
|
1778 |
|
|
| 1779 |
|
|
1779 |
|
|
| 1780 |
|
|
1780 |
|
|
| 1781 |
|
return inner_.on_null(ec);
|
1781 |
|
return inner_.on_null(ec);
|
| 1782 |
|
|
1782 |
|
|
| 1783 |
|
|
1783 |
|
|
| 1784 |
|
|
1784 |
|
|
| 1785 |
|
#undef BOOST_JSON_INVOKE_INNER
|
1785 |
|
#undef BOOST_JSON_INVOKE_INNER
|
| 1786 |
|
|
1786 |
|
|
| 1787 |
|
|
1787 |
|
|
| 1788 |
|
|
1788 |
|
|
| 1789 |
|
template< class V, class P >
|
1789 |
|
template< class V, class P >
|
| 1790 |
|
class converting_handler<path_conversion_tag, V, P>
|
1790 |
|
class converting_handler<path_conversion_tag, V, P>
|
| 1791 |
|
: public scalar_handler<P, error::not_string>
|
1791 |
|
: public scalar_handler<P, error::not_string>
|
| 1792 |
|
|
1792 |
|
|
| 1793 |
|
|
1793 |
|
|
| 1794 |
|
|
1794 |
|
|
| 1795 |
|
|
1795 |
|
|
| 1796 |
|
|
1796 |
|
|
| 1797 |
|
|
1797 |
|
|
| 1798 |
|
converting_handler( V* v, P* p )
|
1798 |
|
converting_handler( V* v, P* p )
|
| 1799 |
|
: converting_handler::scalar_handler(p)
|
1799 |
|
: converting_handler::scalar_handler(p)
|
| 1800 |
|
|
1800 |
|
|
| 1801 |
|
|
1801 |
|
|
| 1802 |
|
|
1802 |
|
|
| 1803 |
|
bool on_string_part( system::error_code&, string_view sv )
|
1803 |
|
bool on_string_part( system::error_code&, string_view sv )
|
| 1804 |
|
|
1804 |
|
|
| 1805 |
|
|
1805 |
|
|
| 1806 |
|
|
1806 |
|
|
| 1807 |
|
|
1807 |
|
|
| 1808 |
|
|
1808 |
|
|
| 1809 |
|
|
1809 |
|
|
| 1810 |
|
|
1810 |
|
|
| 1811 |
|
value_->concat( sv.begin(), sv.end() );
|
1811 |
|
value_->concat( sv.begin(), sv.end() );
|
| 1812 |
|
|
1812 |
|
|
| 1813 |
|
|
1813 |
|
|
| 1814 |
|
|
1814 |
|
|
| 1815 |
|
bool on_string(system::error_code& ec, string_view sv)
|
1815 |
|
bool on_string(system::error_code& ec, string_view sv)
|
| 1816 |
|
|
1816 |
|
|
| 1817 |
|
|
1817 |
|
|
| 1818 |
|
|
1818 |
|
|
| 1819 |
|
|
1819 |
|
|
| 1820 |
|
|
1820 |
|
|
| 1821 |
|
|
1821 |
|
|
| 1822 |
|
value_->concat( sv.begin(), sv.end() );
|
1822 |
|
value_->concat( sv.begin(), sv.end() );
|
| 1823 |
|
|
1823 |
|
|
| 1824 |
|
return this->parent_->signal_value(ec);
|
1824 |
|
return this->parent_->signal_value(ec);
|
| 1825 |
|
|
1825 |
|
|
| 1826 |
|
|
1826 |
|
|
| 1827 |
|
|
1827 |
|
|
| 1828 |
|
|
1828 |
|
|
| 1829 |
|
|
1829 |
|
|
| 1830 |
|
|
1830 |
|
|
| 1831 |
|
|
1831 |
|
|
| 1832 |
|
|
1832 |
|
|
| 1833 |
|
|
1833 |
|
|
| 1834 |
|
using inner_handler_type = get_handler<V, into_handler>;
|
1834 |
|
using inner_handler_type = get_handler<V, into_handler>;
|
| 1835 |
|
|
1835 |
|
|
| 1836 |
|
inner_handler_type inner_;
|
1836 |
|
inner_handler_type inner_;
|
| 1837 |
|
bool inner_active_ = true;
|
1837 |
|
bool inner_active_ = true;
|
| 1838 |
|
|
1838 |
|
|
| 1839 |
|
|
1839 |
|
|
| 1840 |
|
|
1840 |
|
|
| 1841 |
|
into_handler( into_handler const& ) = delete;
|
1841 |
|
into_handler( into_handler const& ) = delete;
|
| 1842 |
|
into_handler& operator=( into_handler const& ) = delete;
|
1842 |
|
into_handler& operator=( into_handler const& ) = delete;
|
| 1843 |
|
|
1843 |
|
|
| 1844 |
|
|
1844 |
|
|
| 1845 |
|
|
1845 |
|
|
| 1846 |
|
static constexpr std::size_t max_object_size = object::max_size();
|
1846 |
|
static constexpr std::size_t max_object_size = object::max_size();
|
| 1847 |
|
static constexpr std::size_t max_array_size = array::max_size();
|
1847 |
|
static constexpr std::size_t max_array_size = array::max_size();
|
| 1848 |
|
static constexpr std::size_t max_key_size = string::max_size();
|
1848 |
|
static constexpr std::size_t max_key_size = string::max_size();
|
| 1849 |
|
static constexpr std::size_t max_string_size = string::max_size();
|
1849 |
|
static constexpr std::size_t max_string_size = string::max_size();
|
| 1850 |
|
|
1850 |
|
|
| 1851 |
|
|
1851 |
|
|
| 1852 |
|
|
1852 |
|
|
| 1853 |
|
explicit into_handler( V* v ): inner_( v, this )
|
1853 |
|
explicit into_handler( V* v ): inner_( v, this )
|
| 1854 |
|
|
1854 |
|
|
| 1855 |
|
|
1855 |
|
|
| 1856 |
|
|
1856 |
|
|
| 1857 |
|
bool signal_value(system::error_code&)
|
1857 |
|
bool signal_value(system::error_code&)
|
| 1858 |
|
|
1858 |
|
|
| 1859 |
|
|
1859 |
|
|
| 1860 |
|
|
1860 |
|
|
| 1861 |
|
|
1861 |
|
|
| 1862 |
|
bool signal_end(system::error_code&)
|
1862 |
|
bool signal_end(system::error_code&)
|
| 1863 |
|
|
1863 |
|
|
| 1864 |
|
|
1864 |
|
|
| 1865 |
|
|
1865 |
|
|
| 1866 |
|
|
1866 |
|
|
| 1867 |
|
bool on_document_begin( system::error_code& )
|
1867 |
|
bool on_document_begin( system::error_code& )
|
| 1868 |
|
|
1868 |
|
|
| 1869 |
|
|
1869 |
|
|
| 1870 |
|
|
1870 |
|
|
| 1871 |
|
|
1871 |
|
|
| 1872 |
|
bool on_document_end( system::error_code& )
|
1872 |
|
bool on_document_end( system::error_code& )
|
| 1873 |
|
|
1873 |
|
|
| 1874 |
|
|
1874 |
|
|
| 1875 |
|
|
1875 |
|
|
| 1876 |
|
|
1876 |
|
|
| 1877 |
|
|
1877 |
|
|
| 1878 |
|
#define BOOST_JSON_INVOKE_INNER(f) \
|
1878 |
|
#define BOOST_JSON_INVOKE_INNER(f) \
|
| 1879 |
|
|
1879 |
|
|
| 1880 |
|
|
1880 |
|
|
| 1881 |
|
BOOST_JSON_FAIL( ec, error::extra_data ); \
|
1881 |
|
BOOST_JSON_FAIL( ec, error::extra_data ); \
|
| 1882 |
|
|
1882 |
|
|
| 1883 |
|
|
1883 |
|
|
| 1884 |
|
|
1884 |
|
|
| 1885 |
|
|
1885 |
|
|
| 1886 |
|
|
1886 |
|
|
| 1887 |
|
bool on_object_begin( system::error_code& ec )
|
1887 |
|
bool on_object_begin( system::error_code& ec )
|
| 1888 |
|
|
1888 |
|
|
| 1889 |
|
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
1889 |
|
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
| 1890 |
|
|
1890 |
|
|
| 1891 |
|
|
1891 |
|
|
| 1892 |
|
bool on_object_end( std::size_t, system::error_code& ec )
|
1892 |
|
bool on_object_end( std::size_t, system::error_code& ec )
|
| 1893 |
|
|
1893 |
|
|
| 1894 |
|
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
1894 |
|
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
| 1895 |
|
|
1895 |
|
|
| 1896 |
|
|
1896 |
|
|
| 1897 |
|
bool on_array_begin( system::error_code& ec )
|
1897 |
|
bool on_array_begin( system::error_code& ec )
|
| 1898 |
|
|
1898 |
|
|
| 1899 |
|
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
1899 |
|
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
| 1900 |
|
|
1900 |
|
|
| 1901 |
|
|
1901 |
|
|
| 1902 |
|
bool on_array_end( std::size_t, system::error_code& ec )
|
1902 |
|
bool on_array_end( std::size_t, system::error_code& ec )
|
| 1903 |
|
|
1903 |
|
|
| 1904 |
|
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
1904 |
|
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
| 1905 |
|
|
1905 |
|
|
| 1906 |
|
|
1906 |
|
|
| 1907 |
|
bool on_key_part( string_view sv, std::size_t, system::error_code& ec )
|
1907 |
|
bool on_key_part( string_view sv, std::size_t, system::error_code& ec )
|
| 1908 |
|
|
1908 |
|
|
| 1909 |
|
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
1909 |
|
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
| 1910 |
|
|
1910 |
|
|
| 1911 |
|
|
1911 |
|
|
| 1912 |
|
bool on_key( string_view sv, std::size_t, system::error_code& ec )
|
1912 |
|
bool on_key( string_view sv, std::size_t, system::error_code& ec )
|
| 1913 |
|
|
1913 |
|
|
| 1914 |
|
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
1914 |
|
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
| 1915 |
|
|
1915 |
|
|
| 1916 |
|
|
1916 |
|
|
| 1917 |
|
bool on_string_part( string_view sv, std::size_t, system::error_code& ec )
|
1917 |
|
bool on_string_part( string_view sv, std::size_t, system::error_code& ec )
|
| 1918 |
|
|
1918 |
|
|
| 1919 |
|
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
1919 |
|
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
| 1920 |
|
|
1920 |
|
|
| 1921 |
|
|
1921 |
|
|
| 1922 |
|
bool on_string( string_view sv, std::size_t, system::error_code& ec )
|
1922 |
|
bool on_string( string_view sv, std::size_t, system::error_code& ec )
|
| 1923 |
|
|
1923 |
|
|
| 1924 |
|
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
1924 |
|
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
| 1925 |
|
|
1925 |
|
|
| 1926 |
|
|
1926 |
|
|
| 1927 |
|
bool on_number_part( string_view, system::error_code& ec )
|
1927 |
|
bool on_number_part( string_view, system::error_code& ec )
|
| 1928 |
|
|
1928 |
|
|
| 1929 |
|
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
1929 |
|
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
| 1930 |
|
|
1930 |
|
|
| 1931 |
|
|
1931 |
|
|
| 1932 |
|
bool on_int64( std::int64_t v, string_view, system::error_code& ec )
|
1932 |
|
bool on_int64( std::int64_t v, string_view, system::error_code& ec )
|
| 1933 |
|
|
1933 |
|
|
| 1934 |
|
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
1934 |
|
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
| 1935 |
|
|
1935 |
|
|
| 1936 |
|
|
1936 |
|
|
| 1937 |
|
bool on_uint64( std::uint64_t v, string_view, system::error_code& ec )
|
1937 |
|
bool on_uint64( std::uint64_t v, string_view, system::error_code& ec )
|
| 1938 |
|
|
1938 |
|
|
| 1939 |
|
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
1939 |
|
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
| 1940 |
|
|
1940 |
|
|
| 1941 |
|
|
1941 |
|
|
| 1942 |
|
bool on_double( double v, string_view, system::error_code& ec )
|
1942 |
|
bool on_double( double v, string_view, system::error_code& ec )
|
| 1943 |
|
|
1943 |
|
|
| 1944 |
|
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
1944 |
|
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
| 1945 |
|
|
1945 |
|
|
| 1946 |
|
|
1946 |
|
|
| 1947 |
|
bool on_bool( bool v, system::error_code& ec )
|
1947 |
|
bool on_bool( bool v, system::error_code& ec )
|
| 1948 |
|
|
1948 |
|
|
| 1949 |
|
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
1949 |
|
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
| 1950 |
|
|
1950 |
|
|
| 1951 |
|
|
1951 |
|
|
| 1952 |
|
bool on_null( system::error_code& ec )
|
1952 |
|
bool on_null( system::error_code& ec )
|
| 1953 |
|
|
1953 |
|
|
| 1954 |
|
BOOST_JSON_INVOKE_INNER( on_null(ec) );
|
1954 |
|
BOOST_JSON_INVOKE_INNER( on_null(ec) );
|
| 1955 |
|
|
1955 |
|
|
| 1956 |
|
|
1956 |
|
|
| 1957 |
|
bool on_comment_part(string_view, system::error_code&)
|
1957 |
|
bool on_comment_part(string_view, system::error_code&)
|
| 1958 |
|
|
1958 |
|
|
| 1959 |
|
|
1959 |
|
|
| 1960 |
|
|
1960 |
|
|
| 1961 |
|
|
1961 |
|
|
| 1962 |
|
bool on_comment(string_view, system::error_code&)
|
1962 |
|
bool on_comment(string_view, system::error_code&)
|
| 1963 |
|
|
1963 |
|
|
| 1964 |
|
|
1964 |
|
|
| 1965 |
|
|
1965 |
|
|
| 1966 |
|
|
1966 |
|
|
| 1967 |
|
#undef BOOST_JSON_INVOKE_INNER
|
1967 |
|
#undef BOOST_JSON_INVOKE_INNER
|
| 1968 |
|
|
1968 |
|
|
| 1969 |
|
|
1969 |
|
|
| 1970 |
|
|
1970 |
|
|
| 1971 |
|
|
1971 |
|
|
| 1972 |
|
|
1972 |
|
|
| 1973 |
|
|
1973 |
|
|
| 1974 |
|
|
1974 |
|
|