20 namespace json_details {
23 template<
typename Char>
24 [[nodiscard]]
constexpr Char *input_pointer( Char *origin,
char const *position ) {
25 if constexpr( std::is_const_v<Char> ) {
28 return position ? origin + ( position - origin ) :
nullptr;
32 enum class SkipBracketedType { Array, Class };
35 namespace parse_policy_details {
36 template<
char... keys>
37 [[nodiscard]] DAW_ATTRIB_FLATINLINE
static constexpr bool in(
char c ) {
38 auto const eq = [c](
char k ) {
41 return nsc_or( eq( keys )... );
44 [[nodiscard]] DAW_ATTRIB_FLATINLINE
static constexpr bool
45 at_end_of_item(
char c ) {
46 return static_cast<bool>(
static_cast<unsigned>( c ==
',' ) |
47 static_cast<unsigned>( c ==
'}' ) |
48 static_cast<unsigned>( c ==
']' ) |
49 static_cast<unsigned>( c ==
':' ) |
50 static_cast<unsigned>( c <= 0x20 ) );
53 [[nodiscard]] DAW_ATTRIB_FLATINLINE
static inline constexpr bool
55 return static_cast<unsigned>(
static_cast<unsigned char>( c ) -
56 static_cast<unsigned char>(
'0' ) ) < 10U;
59 template<
typename ParseState>
60 DAW_ATTRIB_FLATINLINE
static inline constexpr void
61 validate_unsigned_first( ParseState
const &parse_state ) {
62 if constexpr( not ParseState::is_unchecked_input ) {
63 switch( parse_state.front( ) ) {
75 if( parse_state.size( ) > 1 ) {
77 ErrorReason::InvalidNumberStart,
82 daw_json_error(
true, ErrorReason::InvalidNumberStart, parse_state );
92 template<
typename ParseState>
93 [[nodiscard]] DAW_ATTRIB_FLATINLINE
static constexpr int
94 validate_signed_first( ParseState &parse_state ) {
96 ErrorReason::UnexpectedEndOfData,
98 auto const c = parse_state.front( );
100 parse_state.remove_prefix( );
103 if constexpr( ParseState::is_unchecked_input ) {
104 if( DAW_LIKELY( c >=
'0' ) and DAW_LIKELY( c <=
'9' ) ) {
108 if( c >=
'1' and c <=
'9' ) {
111 if( DAW_LIKELY( c ==
'0' ) ) {
112 if( parse_state.size( ) > 1 ) {
113 auto const next_dig =
static_cast<unsigned>(
114 static_cast<unsigned char>( *( parse_state.first + 1 ) ) );
115 auto const tst = next_dig -
static_cast<unsigned char>(
'0' );
118 tst >= 10U, ErrorReason::InvalidNumberStart, parse_state );
123 daw_json_error(
true, ErrorReason::InvalidNumberStart, parse_state );
126 [[nodiscard]] DAW_ATTRIB_FLATINLINE
static constexpr bool
127 is_number_start(
char c ) {