18 #include <daw/daw_attributes.h>
19 #include <daw/daw_likely.h>
20 #include <daw/daw_traits.h>
24 #include <type_traits>
29 template<
typename ParseState>
30 DAW_ATTRIB_FLATINLINE
static constexpr
void
32 while( parse_state.front( ) ==
'#' ) {
33 parse_state.remove_prefix( );
34 parse_state.template move_to_next_of_unchecked<'\n'>( );
35 parse_state.remove_prefix( );
39 template<
typename ParseState>
40 DAW_ATTRIB_FLATINLINE
static constexpr
void
42 while( parse_state.has_more( ) and parse_state.front( ) ==
'#' ) {
43 parse_state.remove_prefix( );
44 parse_state.template move_to_next_of_checked<'\n'>( );
45 if( parse_state.front( ) ==
'\n' ) {
46 parse_state.remove_prefix( );
51 template<
typename ParseState>
52 DAW_ATTRIB_FLATINLINE
static constexpr
void
54 if constexpr( ParseState::is_unchecked_input ) {
55 skip_comments_unchecked( parse_state );
57 skip_comments_checked( parse_state );
62 template<
typename ParseState>
63 DAW_ATTRIB_FLATINLINE
static constexpr
void
65 skip_comments_checked( parse_state );
66 while( parse_state.has_more( ) and parse_state.is_space_unchecked( ) ) {
67 parse_state.remove_prefix( );
68 skip_comments_checked( parse_state );
72 template<
typename ParseState>
73 DAW_ATTRIB_FLATINLINE
static constexpr
void
75 skip_comments_unchecked( parse_state );
76 while( parse_state.is_space_unchecked( ) ) {
77 parse_state.remove_prefix( );
81 template<
typename ParseState>
82 DAW_ATTRIB_FLATINLINE
static constexpr
void
84 parse_state.move_next_member_or_end_unchecked( );
87 template<
char... keys,
typename ParseState>
88 DAW_ATTRIB_FLATINLINE
static constexpr
void
90 skip_comments( parse_state );
93 ErrorReason::UnexpectedEndOfData, parse_state );
94 while( not parse_policy_details::in<keys...>( parse_state.front( ) ) ) {
96 ErrorReason::UnexpectedEndOfData, parse_state );
97 parse_state.remove_prefix( );
98 skip_comments( parse_state );
102 DAW_ATTRIB_FLATINLINE
static constexpr
bool is_literal_end(
char c ) {
103 return c ==
'\0' or c ==
',' or c ==
']' or c ==
'}' or c ==
'#';
106 template<
char PrimLeft,
typename ParseState>
107 DAW_ATTRIB_FLATINLINE
static constexpr ParseState
109 constexpr
char PrimRight = PrimLeft ==
'{' ?
'}' :
']';
110 constexpr
char SecLeft = PrimLeft ==
'{' ?
'[' :
'{';
111 constexpr
char SecRight = SecLeft ==
'{' ?
'}' :
']';
112 using CharT =
typename ParseState::CharT;
114 auto result = parse_state;
116 std::uint32_t prime_bracket_count = 1;
117 std::uint32_t second_bracket_count = 0;
118 CharT *ptr_first = parse_state.first;
119 CharT *
const ptr_last = parse_state.last;
120 if( DAW_UNLIKELY( ptr_first >= ptr_last ) ) {
123 if( *ptr_first == PrimLeft ) {
126 while( DAW_LIKELY( ptr_first < ptr_last ) ) {
128 switch( *ptr_first ) {
134 ptr_first = json_details::mem_skip_until_end_of_string<
135 ParseState::is_unchecked_input>( ParseState::exec_tag, ptr_first,
138 ErrorReason::UnexpectedEndOfData, parse_state );
141 if( prime_bracket_count == 1 and second_bracket_count == 0 ) {
146 ++prime_bracket_count;
149 --prime_bracket_count;
150 if( prime_bracket_count == 0 ) {
152 ErrorReason::InvalidBracketing, parse_state );
156 result.last = ptr_first;
157 result.counter = cnt;
158 parse_state.first = ptr_first;
163 ++second_bracket_count;
166 --second_bracket_count;
170 while( ptr_first < ptr_last and *ptr_first !=
'\n' ) {
173 if( ptr_first < ptr_last ) {
181 ( second_bracket_count == 0 ),
182 ErrorReason::InvalidBracketing, parse_state );
185 result.last = ptr_first;
186 result.counter = cnt;
187 parse_state.first = ptr_first;
191 template<
char PrimLeft,
typename ParseState>
192 DAW_ATTRIB_FLATINLINE
static constexpr ParseState
195 constexpr
char PrimRight = PrimLeft ==
'{' ?
'}' :
']';
196 constexpr
char SecLeft = PrimLeft ==
'{' ?
'[' :
'{';
197 constexpr
char SecRight = SecLeft ==
'{' ?
'}' :
']';
198 using CharT =
typename ParseState::CharT;
199 auto result = parse_state;
201 std::uint32_t prime_bracket_count = 1;
202 std::uint32_t second_bracket_count = 0;
203 CharT *ptr_first = parse_state.first;
204 if( *ptr_first == PrimLeft ) {
208 switch( *ptr_first ) {
214 ptr_first = json_details::mem_skip_until_end_of_string<
215 ParseState::is_unchecked_input>( ParseState::exec_tag, ptr_first,
219 if( prime_bracket_count == 1 and second_bracket_count == 0 ) {
224 ++prime_bracket_count;
227 --prime_bracket_count;
228 if( prime_bracket_count == 0 ) {
232 result.last = ptr_first;
233 result.counter = cnt;
234 parse_state.first = ptr_first;
239 ++second_bracket_count;
242 --second_bracket_count;
246 while( *ptr_first !=
'\n' ) {
#define daw_json_assert_weak(Bool,...)
Assert that Bool is true when in Checked Input mode If false pass rest of args to daw_json_error.
#define daw_json_ensure(Bool,...)
Ensure that Bool is true. If false pass rest of args to daw_json_error.
Customization point traits.
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.