68 namespace json_details {
69#if defined( DAW_ATTRIB_ENABLE_IF )
70#if defined( DAW_HAS_CPP26_DELETED_REASON )
71 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
72 handle_error(
bool b, json_exception &&jex )
73 DAW_ATTRIB_ENABLE_IF( __builtin_constant_p( b ) and b,
74 "daw_json_ensure check failed" ) =
75 delete(
"daw_json_ensure check failed" );
77 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
78 handle_error(
bool b, json_exception &&jex )
79 DAW_ATTRIB_ENABLE_IF( __builtin_constant_p( b ) and not b,
80 "daw_json_ensure check failed" ) {
86 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
87 handle_error(
bool b, json_exception &&jex )
88 DAW_ATTRIB_ENABLE_IF( not __builtin_constant_p( b ),
" " ) {
94 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
95 handle_error(
bool, json_exception &&jex ) {
103 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
105 json_details::handle_error( b, json_exception( reason ) );
108 template<
typename ParseState>
109 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
111 if( location.first ) {
112 json_details::handle_error( b,
113 json_exception( reason, location.first ) );
115 if( location.class_first ) {
116 json_details::handle_error(
117 b, json_exception( reason, location.class_first ) );
119 json_details::handle_error( b, json_exception( reason ) );
122 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
124 json_details::handle_error( b, json_exception( reason ) );
127 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
129 json_details::handle_error( b, json_exception( reason ) );
132 template<
typename ParseState>
133 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
135 ParseState
const &location ) {
136 if( location.class_first and location.first ) {
137 static constexpr std::size_t max_len = 150;
138 std::size_t
const len = [&]( ) -> std::size_t {
139 if( location.first ==
nullptr or location.class_first ==
nullptr ) {
140 if( location.class_first ==
nullptr or
141 location.class_last ==
nullptr ) {
144 auto const dist =
static_cast<std::size_t
>( location.class_last -
145 location.class_first );
146 if( dist < max_len ) {
151 auto const dist =
static_cast<std::size_t
>( location.class_first -
152 location.first + 1 );
153 if( dist < max_len ) {
158 json_details::handle_error(
160 json_exception( reason,
161 std::string_view( location.class_first, len ) ) );
163 json_details::handle_error( b, json_exception( reason ) );
166 template<
typename ParseState>
167 [[noreturn]] DAW_ATTRIB_NOINLINE
inline void
169 ParseState
const &location ) {
170 if( location.first ) {
171 json_details::handle_error( b,
172 json_exception( reason, location.first ) );
174 if( location.class_first ) {
175 json_details::handle_error(
176 b, json_exception( reason, location.class_first ) );
178 json_details::handle_error( b, json_exception( reason ) );