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