Skip to content

Commit 220ea73

Browse files
author
Roy Bellingan
committed
initial test for intrusive debug
1 parent c02d872 commit 220ea73

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

include/boost/json/detail/value_to.hpp

+32-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@
1212
#ifndef BOOST_JSON_DETAIL_VALUE_TO_HPP
1313
#define BOOST_JSON_DETAIL_VALUE_TO_HPP
1414

15+
#ifndef BOOST_JSON_INTRUSIVE_INDEX_INC
16+
#define BOOST_JSON_INTRUSIVE_INDEX_INC ((void)0);
17+
#endif
18+
19+
#ifndef BOOST_JSON_INTRUSIVE_PATH_PUSH
20+
#define BOOST_JSON_INTRUSIVE_PATH_PUSH(x) ((void)0);
21+
#endif
22+
23+
#ifndef BOOST_JSON_INTRUSIVE_PATH_POP
24+
#define BOOST_JSON_INTRUSIVE_PATH_POP ((void)0);
25+
#endif
26+
27+
#ifndef BOOST_JSON_INTRUSIVE_MESSAGE
28+
#define BOOST_JSON_INTRUSIVE_MESSAGE(x) ((void)0);
29+
#endif
30+
31+
1532
#include <boost/json/value.hpp>
1633
#include <boost/json/conversion.hpp>
1734
#include <boost/json/result_for.hpp>
@@ -270,13 +287,21 @@ value_to_impl(
270287
}
271288

272289
auto ins = detail::inserter(result, inserter_implementation<T>());
290+
291+
BOOST_JSON_INTRUSIVE_PATH_PUSH(-1)
292+
273293
for( value const& val: *arr )
274294
{
295+
BOOST_JSON_INTRUSIVE_INDEX_INC
296+
275297
auto elem_res = try_value_to<value_type<T>>( val, ctx );
276298
if( elem_res.has_error() )
277299
return {boost::system::in_place_error, elem_res.error()};
278300
*ins++ = std::move(*elem_res);
279301
}
302+
303+
BOOST_JSON_INTRUSIVE_PATH_POP
304+
280305
return result;
281306
}
282307

@@ -373,10 +398,14 @@ struct to_described_member
373398
system::error_code ec;
374399
BOOST_JSON_FAIL(ec, error::size_mismatch);
375400
res = {boost::system::in_place_error, ec};
401+
402+
BOOST_JSON_INTRUSIVE_MESSAGE(std::format("the key >> {} << is non optional and missing in path {}", D::name, BOOST_JSON_INTRUSIVE::composePath()));
376403
}
377404
return;
378405
}
379406

407+
BOOST_JSON_INTRUSIVE_PATH_PUSH(D::name)
408+
380409
#if defined(__GNUC__) && BOOST_GCC_VERSION >= 80000 && BOOST_GCC_VERSION < 11000
381410
# pragma GCC diagnostic push
382411
# pragma GCC diagnostic ignored "-Wunused"
@@ -386,8 +415,10 @@ struct to_described_member
386415
#if defined(__GNUC__) && BOOST_GCC_VERSION >= 80000 && BOOST_GCC_VERSION < 11000
387416
# pragma GCC diagnostic pop
388417
#endif
389-
if( member_res )
418+
if( member_res ){
390419
(*res).* D::pointer = std::move(*member_res);
420+
BOOST_JSON_INTRUSIVE_PATH_POP
421+
}
391422
else
392423
res = {boost::system::in_place_error, member_res.error()};
393424
}

0 commit comments

Comments
 (0)