69 namespace json_details {
70#if defined( DAW_ATTRIB_ENABLE_IF )
71#if defined( DAW_HAS_CPP26_DELETED_REASON )
72 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
73 handle_error(
bool b, json_exception &&jex )
74 DAW_ATTRIB_ENABLE_IF( __builtin_constant_p( b ) and b,
75 "daw_json_ensure check failed" ) =
76 delete(
"daw_json_ensure check failed" );
78 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
79 handle_error(
bool b, json_exception &&jex )
80 DAW_ATTRIB_ENABLE_IF( __builtin_constant_p( b ) and not b,
81 "daw_json_ensure check failed" ) {
87 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
88 handle_error(
bool b, json_exception &&jex )
89 DAW_ATTRIB_ENABLE_IF( not __builtin_constant_p( b ),
" " ) {
95 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
96 handle_error(
bool, json_exception &&jex ) {
104 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
106 json_details::handle_error( b, json_exception( reason ) );
109 template<
typename ParseState>
110 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
112 if( location.first ) {
113 json_details::handle_error( b,
114 json_exception( reason, location.first ) );
116 if( location.class_first ) {
117 json_details::handle_error(
118 b, json_exception( reason, location.class_first ) );
120 json_details::handle_error( b, json_exception( reason ) );
123 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
125 json_details::handle_error( b, json_exception( reason ) );
128 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
130 json_details::handle_error( b, json_exception( reason ) );
133 template<
typename ParseState>
134 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
136 ParseState
const &location ) {
137 if( location.class_first and location.first ) {
138 static constexpr std::size_t max_len = 150;
139 std::size_t
const len = [&]( ) -> std::size_t {
140 if( location.first ==
nullptr or location.class_first ==
nullptr ) {
141 if( location.class_first ==
nullptr or
142 location.class_last ==
nullptr ) {
145 auto const dist =
static_cast<std::size_t
>( location.class_last -
146 location.class_first );
147 if( dist < max_len ) {
152 auto const dist =
static_cast<std::size_t
>( location.class_first -
153 location.first + 1 );
154 if( dist < max_len ) {
159 json_details::handle_error(
161 json_exception( reason,
162 std::string_view( location.class_first, len ) ) );
164 json_details::handle_error( b, json_exception( reason ) );
167 template<
typename ParseState>
168 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
170 ParseState
const &location ) {
171 if( location.first ) {
172 json_details::handle_error( b,
173 json_exception( reason, location.first ) );
175 if( location.class_first ) {
176 json_details::handle_error(
177 b, json_exception( reason, location.class_first ) );
179 json_details::handle_error( b, json_exception( reason ) );