15 #include <daw/daw_attributes.h>
19 namespace parse_policy_details {
20 template<
char... keys>
21 [[nodiscard]] DAW_ATTRIB_FLATINLINE
static inline constexpr
bool
23 auto const eq = [c](
char k ) {
26 return nsc_or( eq( keys )... );
29 [[nodiscard]] DAW_ATTRIB_FLATINLINE
static inline constexpr
bool
30 at_end_of_item(
char c ) {
31 return static_cast<bool>(
static_cast<unsigned>( c ==
',' ) |
32 static_cast<unsigned>( c ==
'}' ) |
33 static_cast<unsigned>( c ==
']' ) |
34 static_cast<unsigned>( c ==
':' ) |
35 static_cast<unsigned>( c <= 0x20 ) );
38 [[nodiscard]] DAW_ATTRIB_FLATINLINE
static inline constexpr
bool
40 return static_cast<unsigned>(
static_cast<unsigned char>( c ) -
41 static_cast<unsigned char>(
'0' ) ) < 10U;
44 template<
typename ParseState>
45 DAW_ATTRIB_FLATINLINE
static inline constexpr
void
46 validate_unsigned_first( ParseState
const &parse_state ) {
47 if constexpr( not ParseState::is_unchecked_input ) {
48 switch( parse_state.front( ) ) {
60 if( parse_state.size( ) > 1 ) {
62 ErrorReason::InvalidNumberStart, parse_state );
76 template<
typename ParseState>
77 [[nodiscard]] DAW_ATTRIB_FLATINLINE
static inline constexpr
int
78 validate_signed_first( ParseState &parse_state ) {
80 ErrorReason::UnexpectedEndOfData, parse_state );
81 auto const c = parse_state.front( );
83 parse_state.remove_prefix( );
86 if constexpr( ParseState::is_unchecked_input ) {
87 if( DAW_LIKELY( c >=
'0' ) and DAW_LIKELY( c <=
'9' ) ) {
91 if( c >=
'1' and c <=
'9' ) {
94 if( DAW_LIKELY( c ==
'0' ) ) {
95 if( parse_state.size( ) > 1 ) {
96 auto const next_dig =
static_cast<unsigned>(
97 static_cast<unsigned char>( *( parse_state.first + 1 ) ) );
98 auto const tst = next_dig -
static_cast<unsigned char>(
'0' );
109 [[nodiscard]] DAW_ATTRIB_FLATINLINE
static inline constexpr
bool
110 is_number_start(
char c ) {
#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.
DAW_ATTRIB_NOINLINE void daw_json_error(ErrorReason reason)
Customization point traits.
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.