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 ) ) {
86 result.counter =
static_cast<bool>( true );
90 template<
typename ParseState>
93 if constexpr( ( ParseState::is_zero_terminated_string or
94 ParseState::is_unchecked_input ) ) {
107 result.counter =
static_cast<bool>( false );
111 template<
typename ParseState>
113 if constexpr( ( ParseState::is_zero_terminated_string or
114 ParseState::is_unchecked_input ) ) {
129 result.first =
nullptr;
130 result.last =
nullptr;
134 template<
bool skip_end_check,
typename CharT>
135 DAW_ATTRIB_FLATINLINE [[nodiscard]]
inline constexpr CharT *
141 if constexpr( not skip_end_check ) {
142 if( DAW_UNLIKELY( first >= last ) ) {
156#if false and defined( DAW_CX_BIT_CAST )
157 template<
typename ParseState,
158 std::enable_if_t<( ParseState::is_unchecked_input or
159 ParseState::is_zero_terminated_string ),
160 std::nullptr_t> =
nullptr>
161 [[nodiscard]]
constexpr ParseState
163 using CharT =
typename ParseState::CharT;
169 if( *first ==
'-' ) {
175 CharT *decimal =
nullptr;
176 if( *first ==
'.' ) {
181 CharT *exp =
nullptr;
182 char const maybe_e = *first;
183 if( ( maybe_e ==
'e' ) | ( maybe_e ==
'E' ) ) {
185 char const maybe_sign = *first;
186 if( ( maybe_sign ==
'+' ) | ( maybe_sign ==
'-' ) ) {
196 result.class_first = decimal;
197 result.class_last = exp;
201 template<
typename ParseState,
202 std::enable_if_t<not( ParseState::is_unchecked_input or
203 ParseState::is_zero_terminated_string ),
204 std::nullptr_t> =
nullptr>
206 template<
typename ParseState>
208 [[nodiscard]]
constexpr ParseState
210 using CharT =
typename ParseState::CharT;
217 if constexpr( ParseState::allow_leading_zero_plus ) {
218 if( *first ==
'-' ) {
229 if( last - first > 1 ) {
238 if( DAW_LIKELY( first < last ) ) {
240 skip_digits<( ParseState::is_zero_terminated_string or
241 ParseState::is_unchecked_input )>( first, last );
244 CharT *decimal =
nullptr;
245 if( ( ( ParseState::is_zero_terminated_string or
246 ParseState::is_unchecked_input ) or
248 ( *first ==
'.' ) ) {
251 if( DAW_LIKELY( first < last ) ) {
253 skip_digits<( ParseState::is_zero_terminated_string or
254 ParseState::is_unchecked_input )>( first, last );
257 CharT *exp =
nullptr;
258 if constexpr( not( ParseState::is_zero_terminated_string or
259 ParseState::is_unchecked_input ) ) {
280 ErrorReason::InvalidNumber );
282 if( DAW_LIKELY( first < last ) ) {
284 skip_digits<( ParseState::is_zero_terminated_string or
285 ParseState::is_unchecked_input )>( first, last );
291 result.class_first = decimal;
292 result.class_last = exp;
302 template<
typename ParseState>
303 [[nodiscard]]
inline constexpr ParseState
338 if constexpr( ParseState::is_unchecked_input ) {
349 template<
typename JsonMember,
typename ParseState>
350 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr ParseState
356 JsonMember::expected_type ==
364 }
else if constexpr( JsonMember::expected_type ==
366 JsonMember::expected_type ==
368 JsonMember::expected_type ==
370 JsonMember::expected_type ==
372 JsonMember::expected_type ==
376 }
else if constexpr( JsonMember::expected_type ==
381 }
else if constexpr( JsonMember::expected_type ==
391 template<
typename ParseState>
392 [[nodiscard]]
inline constexpr ParseState
421 if constexpr( ParseState::is_unchecked_input ) {
#define daw_json_assert_weak(Bool,...)
Definition: daw_json_assert.h:190
#define daw_json_assert(Bool,...)
Definition: daw_json_assert.h:179
ParseState & parse_state
Definition: daw_json_parse_class.h:182
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:91
constexpr DAW_ATTRIB_FLATTEN CharT * count_digits(CharT *first, CharT *last)
Definition: daw_count_digits.h:63
constexpr ParseState skip_value(ParseState &parse_state)
Definition: daw_json_skip.h:304
constexpr DAW_ATTRIB_FLATINLINE CharT * skip_digits(CharT *first, CharT *const last)
Definition: daw_json_skip.h:136
constexpr ParseState skip_literal(ParseState &parse_state)
Definition: daw_json_skip.h:393
constexpr ParseState skip_number(ParseState &parse_state)
Definition: daw_json_skip.h:209
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:112
constexpr DAW_ATTRIB_FLATINLINE ParseState skip_string_nq(ParseState &parse_state)
Definition: daw_json_skip.h:39
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:351
constexpr DAW_ATTRIB_FLATINLINE bool is_number(char c)
Definition: daw_json_parse_policy_policy_details.h:34
@ Array
A class type with named members.
@ Date
String - Fully processed string.
@ Signed
Number - Floating Point.
@ Custom
Array - Each element has a key and a value submember.
@ Class
ISO 8601 Timestamp.
@ Unsigned
Number - Signed Integer.
@ Null
An array with a fixed size. This allows for size_t/ptr like combinations.
@ StringEscaped
String - A raw string as is. Escapes are left in.
@ Bool
Number - Unsigned Integer.
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
The version string used in namespace definitions. Must be a valid namespace name.
Definition: version.h:16