diff --git a/include/boost/json/detail/value_to.hpp b/include/boost/json/detail/value_to.hpp index 29ae444f9..3c012b564 100644 --- a/include/boost/json/detail/value_to.hpp +++ b/include/boost/json/detail/value_to.hpp @@ -12,6 +12,23 @@ #ifndef BOOST_JSON_DETAIL_VALUE_TO_HPP #define BOOST_JSON_DETAIL_VALUE_TO_HPP +#ifndef BOOST_JSON_INTRUSIVE_INDEX_INC +#define BOOST_JSON_INTRUSIVE_INDEX_INC ((void)0); +#endif + +#ifndef BOOST_JSON_INTRUSIVE_PATH_PUSH +#define BOOST_JSON_INTRUSIVE_PATH_PUSH(x) ((void)0); +#endif + +#ifndef BOOST_JSON_INTRUSIVE_PATH_POP +#define BOOST_JSON_INTRUSIVE_PATH_POP ((void)0); +#endif + +#ifndef BOOST_JSON_INTRUSIVE_MESSAGE +#define BOOST_JSON_INTRUSIVE_MESSAGE(x) ((void)0); +#endif + + #include #include #include @@ -270,13 +287,21 @@ value_to_impl( } auto ins = detail::inserter(result, inserter_implementation()); + + BOOST_JSON_INTRUSIVE_PATH_PUSH(-1) + for( value const& val: *arr ) { + BOOST_JSON_INTRUSIVE_INDEX_INC + auto elem_res = try_value_to>( val, ctx ); if( elem_res.has_error() ) return {boost::system::in_place_error, elem_res.error()}; *ins++ = std::move(*elem_res); } + + BOOST_JSON_INTRUSIVE_PATH_POP + return result; } @@ -373,10 +398,14 @@ struct to_described_member system::error_code ec; BOOST_JSON_FAIL(ec, error::size_mismatch); res = {boost::system::in_place_error, ec}; + + BOOST_JSON_INTRUSIVE_MESSAGE(std::format("the key >> {} << is non optional and missing in path {}", D::name, BOOST_JSON_INTRUSIVE::composePath())); } return; } + BOOST_JSON_INTRUSIVE_PATH_PUSH(D::name) + #if defined(__GNUC__) && BOOST_GCC_VERSION >= 80000 && BOOST_GCC_VERSION < 11000 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wunused" @@ -386,8 +415,10 @@ struct to_described_member #if defined(__GNUC__) && BOOST_GCC_VERSION >= 80000 && BOOST_GCC_VERSION < 11000 # pragma GCC diagnostic pop #endif - if( member_res ) + if( member_res ){ (*res).* D::pointer = std::move(*member_res); + BOOST_JSON_INTRUSIVE_PATH_POP + } else res = {boost::system::in_place_error, member_res.error()}; }