17 #include <daw/daw_attributes.h>
18 #include <daw/daw_function_table.h>
19 #include <daw/daw_likely.h>
20 #include <daw/daw_traits.h>
25 #include <type_traits>
30 template<
typename ParseState>
31 DAW_ATTRIB_FLATINLINE
static constexpr
void
33 if constexpr( ParseState::minified_document ) {
36 using CharT =
typename ParseState::CharT;
44 if constexpr( ParseState::is_zero_terminated_string ) {
47 (
static_cast<unsigned>(
static_cast<unsigned char>( *first ) ) -
54 DAW_LIKELY( first < last ) and
55 (
static_cast<unsigned>(
static_cast<unsigned char>( *first ) ) -
64 template<
typename ParseState>
65 DAW_ATTRIB_FLATINLINE
static constexpr
void
67 if constexpr( ParseState::minified_document ) {
70 using CharT =
typename ParseState::CharT;
73 (
static_cast<unsigned>(
static_cast<unsigned char>( *first ) ) -
82 template<
typename ParseState>
83 DAW_ATTRIB_FLATINLINE
static constexpr
void
85 using CharT =
typename ParseState::CharT;
87 while( *first !=
'"' ) {
93 template<
char... keys,
typename ParseState>
94 DAW_ATTRIB_FLATINLINE
static constexpr
void
96 static_assert(
sizeof...( keys ) > 0 );
97 static_assert(
sizeof...( keys ) <= 16 );
99 using CharT =
typename ParseState::CharT;
101 if constexpr( traits::not_same<
typename ParseState::exec_tag_t,
115 if( ParseState::is_zero_terminated_string ) {
117 ErrorReason::UnexpectedEndOfData,
119 while( not parse_policy_details::in<keys...>( *first ) ) {
126 first < last, ErrorReason::UnexpectedEndOfData,
parse_state );
127 while( not parse_policy_details::in<keys...>( *first ) ) {
130 first < last, ErrorReason::UnexpectedEndOfData,
parse_state );
138 return ( c ==
'\0' ) | ( c ==
',' ) | ( c ==
']' ) | ( c ==
'}' );
141 template<
char PrimLeft,
char PrimRight,
char SecLeft,
char SecRight,
143 DAW_ATTRIB_FLATTEN
static constexpr ParseState
145 using CharT =
typename ParseState::CharT;
149 std::uint32_t prime_bracket_count = 1;
150 std::uint32_t second_bracket_count = 0;
154 if( DAW_UNLIKELY( ptr_first >= ptr_last ) ) {
157 if( *ptr_first == PrimLeft ) {
160 if constexpr( ParseState::is_zero_terminated_string ) {
163 while( *ptr_first != 0 ) {
164 switch( *ptr_first ) {
170 if constexpr( traits::not_same<
typename ParseState::exec_tag_t,
173 ParseState::is_unchecked_input>(
174 ParseState::exec_tag, ptr_first,
parse_state.last );
177 while( ( c !=
'\0' ) & ( c !=
'"' ) ) {
179 if( ptr_first + 1 < ptr_last ) {
184 ptr_first = ptr_last;
196 if( DAW_UNLIKELY( ( prime_bracket_count == 1 ) &
197 ( second_bracket_count == 0 ) ) ) {
202 ++prime_bracket_count;
205 --prime_bracket_count;
206 if( prime_bracket_count == 0 ) {
210 result.last = ptr_first;
211 result.counter = cnt;
217 ++second_bracket_count;
220 --second_bracket_count;
226 while( DAW_LIKELY( ptr_first < ptr_last ) ) {
227 switch( *ptr_first ) {
233 if constexpr( traits::not_same<
typename ParseState::exec_tag_t,
236 ParseState::is_unchecked_input>(
237 ParseState::exec_tag, ptr_first,
parse_state.last );
239 while( DAW_LIKELY( ptr_first < ptr_last ) and
240 *ptr_first !=
'"' ) {
241 if( *ptr_first ==
'\\' ) {
242 if( ptr_first + 1 < ptr_last ) {
246 ptr_first = ptr_last;
257 if( DAW_UNLIKELY( ( prime_bracket_count == 1 ) &
258 ( second_bracket_count == 0 ) ) ) {
263 ++prime_bracket_count;
266 --prime_bracket_count;
267 if( prime_bracket_count == 0 ) {
271 result.last = ptr_first;
272 result.counter = cnt;
278 ++second_bracket_count;
281 --second_bracket_count;
288 ( second_bracket_count == 0 ),
292 result.last = ptr_first;
293 result.counter = cnt;
298 template<
char PrimLeft,
char PrimRight,
char SecLeft,
char SecRight,
300 DAW_ATTRIB_FLATTEN
static constexpr ParseState
303 using CharT =
typename ParseState::CharT;
306 std::uint32_t prime_bracket_count = 1;
307 std::uint32_t second_bracket_count = 0;
310 if( *ptr_first == PrimLeft ) {
314 switch( *ptr_first ) {
320 if constexpr( traits::not_same<
typename ParseState::exec_tag_t,
323 ParseState::is_unchecked_input>( ParseState::exec_tag,
326 while( *ptr_first !=
'"' ) {
327 if( *ptr_first ==
'\\' ) {
335 if( DAW_UNLIKELY( ( prime_bracket_count == 1 ) &
336 ( second_bracket_count == 0 ) ) ) {
341 ++prime_bracket_count;
344 --prime_bracket_count;
345 if( prime_bracket_count == 0 ) {
349 result.last = ptr_first;
350 result.counter = cnt;
356 ++second_bracket_count;
359 --second_bracket_count;
#define daw_json_assert_weak(Bool,...)
Definition: daw_json_assert.h:189
#define daw_json_assert(Bool,...)
Definition: daw_json_assert.h:178
ParseState & parse_state
Definition: daw_json_parse_class.h:201
DAW_ATTRIB_FLATINLINE CharT * mem_move_to_next_of(runtime_exec_tag, CharT *first, CharT *last)
Definition: daw_not_const_ex_functions.h:323
DAW_ATTRIB_FLATINLINE CharT * mem_skip_until_end_of_string(ExecTag const &tag, CharT *first, CharT *const last)
Definition: daw_not_const_ex_functions.h:360
Definition: daw_from_json.h:22
Definition: daw_json_exec_modes.h:19
#define DAW_JSON_VER
Definition: version.h:11