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