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