13 #include "../daw_json_exception.h"
19 #include <daw/daw_attributes.h>
20 #include <daw/daw_bit_cast.h>
21 #include <daw/daw_likely.h>
22 #include <daw/daw_unreachable.h>
24 #if defined( DAW_CX_BIT_CAST )
33 namespace json_details {
37 template<
typename ParseState>
38 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr ParseState
54 template<
typename ParseState>
55 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr ParseState
69 template<
typename ParseState>
72 if constexpr( ( ParseState::is_zero_terminated_string or
73 ParseState::is_unchecked_input ) ) {
85 result.counter =
static_cast<bool>( true );
89 template<
typename ParseState>
92 if constexpr( ( ParseState::is_zero_terminated_string or
93 ParseState::is_unchecked_input ) ) {
105 result.counter =
static_cast<bool>( false );
109 template<
typename ParseState>
111 if constexpr( ( ParseState::is_zero_terminated_string or
112 ParseState::is_unchecked_input ) ) {
126 result.first =
nullptr;
127 result.last =
nullptr;
131 template<
bool skip_end_check,
typename CharT>
132 DAW_ATTRIB_FLATINLINE [[nodiscard]]
inline constexpr CharT *
138 if constexpr( not skip_end_check ) {
139 if( DAW_UNLIKELY( first >= last ) ) {
152 #if false and defined( DAW_CX_BIT_CAST )
153 template<
typename ParseState,
154 std::enable_if_t<( ParseState::is_unchecked_input or
155 ParseState::is_zero_terminated_string ),
156 std::nullptr_t> =
nullptr>
157 [[nodiscard]] constexpr ParseState
159 using CharT =
typename ParseState::CharT;
165 if( *first ==
'-' ) {
171 CharT *decimal =
nullptr;
172 if( *first ==
'.' ) {
177 CharT *exp =
nullptr;
178 char const maybe_e = *first;
179 if( ( maybe_e ==
'e' ) | ( maybe_e ==
'E' ) ) {
181 char const maybe_sign = *first;
182 if( ( maybe_sign ==
'+' ) | ( maybe_sign ==
'-' ) ) {
192 result.class_first = decimal;
193 result.class_last = exp;
197 template<
typename ParseState,
198 std::enable_if_t<not( ParseState::is_unchecked_input or
199 ParseState::is_zero_terminated_string ),
200 std::nullptr_t> =
nullptr>
202 template<
typename ParseState>
204 [[nodiscard]] constexpr ParseState
206 using CharT =
typename ParseState::CharT;
213 if constexpr( ParseState::allow_leading_zero_plus ) {
214 if( *first ==
'-' ) {
225 if( last - first > 1 ) {
234 if( DAW_LIKELY( first < last ) ) {
236 skip_digits<( ParseState::is_zero_terminated_string or
237 ParseState::is_unchecked_input )>( first, last );
240 CharT *decimal =
nullptr;
241 if( ( ( ParseState::is_zero_terminated_string or
242 ParseState::is_unchecked_input ) or
244 ( *first ==
'.' ) ) {
247 if( DAW_LIKELY( first < last ) ) {
249 skip_digits<( ParseState::is_zero_terminated_string or
250 ParseState::is_unchecked_input )>( first, last );
253 CharT *exp =
nullptr;
255 if( ( ( ParseState::is_zero_terminated_string or
256 ParseState::is_unchecked_input ) or
274 ErrorReason::InvalidNumber );
276 if( DAW_LIKELY( first < last ) ) {
278 skip_digits<( ParseState::is_zero_terminated_string or
279 ParseState::is_unchecked_input )>( first, last );
285 result.class_first = decimal;
286 result.class_last = exp;
296 template<
typename ParseState>
297 [[nodiscard]]
inline constexpr ParseState
332 if constexpr( ParseState::is_unchecked_input ) {
343 template<
typename JsonMember,
typename ParseState>
344 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr ParseState
350 JsonMember::expected_type ==
358 }
else if constexpr( JsonMember::expected_type ==
360 JsonMember::expected_type ==
362 JsonMember::expected_type ==
364 JsonMember::expected_type ==
366 JsonMember::expected_type ==
370 }
else if constexpr( JsonMember::expected_type ==
375 }
else if constexpr( JsonMember::expected_type ==
385 template<
typename ParseState>
386 [[nodiscard]]
inline constexpr ParseState
415 if constexpr( ParseState::is_unchecked_input ) {
#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
static constexpr unsigned plus_char
Definition: daw_json_parse_digit.h:29
static constexpr unsigned e_char
Definition: daw_json_parse_digit.h:27
static constexpr unsigned minus_char
Definition: daw_json_parse_digit.h:30
static constexpr unsigned E_char
Definition: daw_json_parse_digit.h:28
constexpr ParseState skip_true(ParseState &parse_state)
Definition: daw_json_skip.h:70
constexpr ParseState skip_false(ParseState &parse_state)
Definition: daw_json_skip.h:90
constexpr ParseState skip_value(ParseState &parse_state)
Definition: daw_json_skip.h:298
constexpr DAW_ATTRIB_FLATTEN CharT * count_digits(CharT *first, CharT *last)
Definition: daw_count_digits.h:63
constexpr ParseState skip_literal(ParseState &parse_state)
Definition: daw_json_skip.h:387
constexpr ParseState skip_number(ParseState &parse_state)
Definition: daw_json_skip.h:205
constexpr DAW_ATTRIB_FLATINLINE ParseState skip_string(ParseState &parse_state)
Definition: daw_json_skip.h:56
constexpr ParseState skip_null(ParseState &parse_state)
Definition: daw_json_skip.h:110
constexpr DAW_ATTRIB_FLATINLINE ParseState skip_string_nq(ParseState &parse_state)
Definition: daw_json_skip.h:39
constexpr DAW_ATTRIB_FLATINLINE CharT * skip_digits(CharT *first, CharT *const last)
Definition: daw_json_skip.h:133
static constexpr DAW_ATTRIB_FLATINLINE unsigned parse_digit(char c)
Definition: daw_json_parse_digit.h:19
constexpr DAW_ATTRIB_FLATINLINE ParseState skip_known_value(ParseState &parse_state)
Definition: daw_json_skip.h:345
constexpr DAW_ATTRIB_FLATINLINE bool is_number(char c)
Definition: daw_json_parse_policy_policy_details.h:34
DAW_ATTRIB_NOINLINE void daw_json_error(ErrorReason reason)
Definition: daw_json_assert.h:39
Definition: daw_from_json.h:22
static constexpr auto parse_nq(ParseState &parse_state) -> std::enable_if_t< ParseState::is_unchecked_input, std::size_t >
Definition: daw_json_parse_string_quote.h:94
#define DAW_JSON_VER
Definition: version.h:11