Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion include/boost/json/detail/value_to.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <boost/json/value.hpp>
#include <boost/json/conversion.hpp>
#include <boost/json/result_for.hpp>
Expand Down Expand Up @@ -270,13 +287,21 @@ value_to_impl(
}

auto ins = detail::inserter(result, inserter_implementation<T>());

BOOST_JSON_INTRUSIVE_PATH_PUSH(-1)

for( value const& val: *arr )
{
BOOST_JSON_INTRUSIVE_INDEX_INC

auto elem_res = try_value_to<value_type<T>>( 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;
}

Expand Down Expand Up @@ -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"
Expand All @@ -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()};
}
Expand Down