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