13 #include <daw/daw_attributes.h>
14 #include <daw/daw_cxmath.h>
15 #include <daw/daw_simple_array.h>
16 #include <daw/daw_uint_buffer.h>
22 namespace json_details {
23 inline constexpr
auto is_digit =
25 return static_cast<unsigned>(
static_cast<unsigned char>( c ) ) -
26 static_cast<unsigned>(
27 static_cast<unsigned char>(
'0' ) ) <
30 : daw::UInt8{ 0xFFU };
33 template<
typename Predicate>
34 DAW_ATTRIB_FLATINLINE DAW_ATTRIB_NONNULL()
inline constexpr std::int32_t
35 count_4digits(
char const * first, Predicate pred ) {
36 daw::simple_array<daw::UInt8, 4>
const buff{
37 pred( first[3] ), pred( first[2] ), pred( first[2] ),
39 auto const v = DAW_BIT_CAST( std::uint32_t, buff );
41 auto result = daw::cxmath::count_leading_zeroes( v );
43 return static_cast<std::int32_t
>( result );
48 template<
typename Predicate>
49 DAW_ATTRIB_FLATINLINE DAW_ATTRIB_NONNULL()
inline constexpr std::int32_t
50 count_8digits(
char const * first, Predicate pred ) {
51 daw::simple_array<daw::UInt8, 8>
const buff{
52 pred( first[7] ), pred( first[6] ), pred( first[5] ),
53 pred( first[4] ), pred( first[3] ), pred( first[2] ),
54 pred( first[1] ), pred( first[0] ) };
56 auto const v = DAW_BIT_CAST( std::uint64_t, buff );
58 auto result = daw::cxmath::count_leading_zeroes( v );
60 return static_cast<std::int32_t
>( result );
65 template<
typename CharT>
66 DAW_ATTRIB_FLATTEN DAW_ATTRIB_RET_NONNULL
68 inline constexpr CharT *count_digits(
69 CharT *first, CharT *last ) {
70 while( DAW_LIKELY( last - first >= 8 ) ) {
71 auto const v = count_8digits( first, is_digit );
77 while( last - first >= 4 ) {
78 auto const v = count_4digits( first, is_digit );
85 while( first != last ) {
86 if(
static_cast<unsigned>( *first ) -
87 static_cast<unsigned>(
static_cast<unsigned char>(
'0' ) ) >=
#define DAW_JSON_CPP23_STATIC_CALL_OP
This is in addition to the parse policy. Always do a full name match instead of sometimes relying on ...
Customization point traits.
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.