16 #include <daw/daw_function_table.h>
17 #include <daw/daw_hide.h>
22 #include <type_traits>
25 template<
bool DocumentIsMinified>
31 template<
typename Range>
32 DAW_ATTRIBUTE_FLATTEN
static constexpr
void
36 char const *first = rng.first;
37 char const *
const last = rng.last;
39 static_cast<unsigned char>( *first ) <= 0x20U ) {
46 template<
typename Range>
47 DAW_ATTRIBUTE_FLATTEN
static constexpr
void
50 char const *first = rng.first;
51 while(
static_cast<unsigned char>( *first ) <= 0x20 ) {
58 template<
char... keys,
typename Range>
60 static_assert(
sizeof...( keys ) <= 16 );
62 if constexpr( not std::is_same_v<
typename Range::exec_tag_t,
65 json_details::mem_move_to_next_of<Range::is_unchecked_input, keys...>(
66 Range::exec_tag, rng.first, rng.last );
68 char const *first = rng.first;
69 char const *
const last = rng.last;
72 while( not parse_policy_details::in<keys...>( *first ) ) {
82 return c ==
'\0' or c ==
',' or c ==
']' or c ==
'}';
85 template<
char PrimLeft,
char PrimRight,
char SecLeft,
char SecRight,
87 DAW_ATTRIBUTE_FLATTEN
static constexpr Range
92 std::uint32_t prime_bracket_count = 1;
93 std::uint32_t second_bracket_count = 0;
94 char const *ptr_first = rng.first;
95 char const *
const ptr_last = rng.last;
100 if( *ptr_first == PrimLeft ) {
104 switch( *ptr_first ) {
110 if constexpr( not std::is_same_v<
typename Range::exec_tag_t,
112 ptr_first = json_details::mem_skip_until_end_of_string<
113 Range::is_unchecked_input>( Range::exec_tag, ptr_first,
117 *ptr_first !=
'"' ) {
118 if( *ptr_first ==
'\\' ) {
119 if( ptr_first + 1 < ptr_last ) {
123 ptr_first = ptr_last;
131 ErrorReason::UnexpectedEndOfData, rng );
135 ( second_bracket_count == 0 ) ) ) {
140 ++prime_bracket_count;
143 --prime_bracket_count;
144 if( prime_bracket_count == 0 ) {
147 ErrorReason::InvalidBracketing, rng );
148 result.last = ptr_first;
149 result.counter = cnt;
150 rng.first = ptr_first;
155 ++second_bracket_count;
158 --second_bracket_count;
164 ( second_bracket_count == 0 ),
165 ErrorReason::InvalidBracketing, rng );
168 result.last = ptr_first;
169 result.counter = cnt;
170 rng.first = ptr_first;
174 template<
char PrimLeft,
char PrimRight,
char SecLeft,
char SecRight,
176 DAW_ATTRIBUTE_FLATTEN
static constexpr Range
181 std::uint32_t prime_bracket_count = 1;
182 std::uint32_t second_bracket_count = 0;
183 char const *ptr_first = rng.first;
185 if( *ptr_first == PrimLeft ) {
189 switch( *ptr_first ) {
195 if constexpr( not std::is_same_v<
typename Range::exec_tag_t,
197 ptr_first = json_details::mem_skip_until_end_of_string<
198 Range::is_unchecked_input>( Range::exec_tag, ptr_first,
201 while( *ptr_first !=
'"' ) {
202 if( *ptr_first ==
'\\' ) {
211 ( second_bracket_count == 0 ) ) ) {
216 ++prime_bracket_count;
219 --prime_bracket_count;
220 if( prime_bracket_count == 0 ) {
224 result.last = ptr_first;
225 result.counter = cnt;
226 rng.first = ptr_first;
231 ++second_bracket_count;
234 --second_bracket_count;