15#include <daw/daw_is_constant_evaluated.h>
16#include <daw/daw_likely.h>
17#include <daw/daw_traits.h>
21#if defined( __GNUC__ )
22#define DAW_CAN_CONSTANT_EVAL( ... ) \
23 ( __builtin_constant_p( __VA_ARGS__ ) == 1 )
25#define DAW_CAN_CONSTANT_EVAL( ... ) true
30 namespace json_details {
40 template<
char c,
typename ExecTag,
bool expect_
long,
typename CharT>
41 DAW_ATTRIB_FLATINLINE
inline constexpr CharT *
43#if DAW_HAS_BUILTIN( __builtin_char_memchr )
44 if constexpr( expect_long ) {
45 return __builtin_char_memchr(
46 first,
'"',
static_cast<std::size_t
>( last - first ) );
49#if defined( DAW_IS_CONSTANT_EVALUATED )
55 if constexpr( expect_long ) {
56 if( ( not is_cxeval ) |
57 daw::traits::not_same_v<ExecTag, constexpr_exec_tag> ) {
58 return static_cast<CharT *
>(
59 std::memchr(
static_cast<void const *
>( first ),
'"',
60 static_cast<std::size_t
>( last - first ) ) );
63 while( *first != c ) {
71 while( *first != c ) {
87 template<
char c,
typename ExecTag,
bool expect_
long,
typename CharT>
88 DAW_ATTRIB_FLATINLINE
inline constexpr CharT *
90#if DAW_HAS_BUILTIN( __builtin_char_memchr )
91 if constexpr( expect_long ) {
92 return __builtin_char_memchr(
93 first,
'"',
static_cast<std::size_t
>( last - first ) );
96#if defined( DAW_IS_CONSTANT_EVALUATED )
102 if constexpr( expect_long ) {
103 if( ( not is_cxeval ) |
104 daw::traits::not_same_v<ExecTag, constexpr_exec_tag> ) {
105 return static_cast<CharT *
>(
106 std::memchr(
static_cast<void const *
>( first ),
'"',
107 static_cast<std::size_t
>( last - first ) ) );
109 while( DAW_LIKELY( first < last ) and *first != c ) {
116 while( DAW_LIKELY( first < last ) and *first != c ) {
123 template<
typename ExecTag,
bool expect_long,
char... chars,
125 DAW_ATTRIB_FLATINLINE
inline constexpr CharT *
127#if DAW_HAS_BUILTIN( __builtin_strpbrk )
128 if constexpr( expect_long ) {
129 constexpr char const needles[]{ chars...,
'\0' };
130 CharT *res = __builtin_strpbrk( first, needles );
131#if not defined( NDEBUG )
137#if defined( DAW_IS_CONSTANT_EVALUATED )
143 if constexpr( expect_long ) {
144 if( ( not is_cxeval ) |
145 daw::traits::not_same_v<ExecTag, constexpr_exec_tag> ) {
146 constexpr char const needles[]{ chars...,
'\0' };
147 CharT *res = std::strpbrk( first, needles );
148#if not defined( NDEBUG )
153 while( not parse_policy_details::in<chars...>( *first ) ) {
160 while( not parse_policy_details::in<chars...>( *first ) ) {
167 template<
typename ExecTag,
bool expect_long,
char... chars,
169 DAW_ATTRIB_FLATINLINE
inline constexpr CharT *
171 if constexpr( expect_long ) {
172#if defined( DAW_IS_CONSTANT_EVALUATED )
178 if( ( not is_cxeval ) |
179 daw::traits::not_same_v<ExecTag, constexpr_exec_tag> ) {
183 while( DAW_LIKELY( first < last ) and
189 while( DAW_LIKELY( first < last ) and
197 template<
bool is_unchecked_input,
typename ExecTag,
bool expect_long,
198 char... chars,
typename CharT>
199 DAW_ATTRIB_FLATINLINE
inline constexpr CharT *
mempbrk( CharT *first,
202 if constexpr( is_unchecked_input ) {
#define daw_json_assert(Bool,...)
Definition: daw_json_assert.h:179
#define DAW_CAN_CONSTANT_EVAL(...)
Definition: daw_json_string_util.h:25
DAW_ATTRIB_INLINE CharT * mem_move_to_next_of(runtime_exec_tag, CharT *first, CharT *last)
Definition: daw_not_const_ex_functions.h:353
constexpr DAW_ATTRIB_FLATINLINE CharT * memchr_checked(CharT *first, CharT *last)
Search for a character in a string.
Definition: daw_json_string_util.h:89
constexpr DAW_ATTRIB_FLATINLINE CharT * mempbrk(CharT *first, CharT *last)
Definition: daw_json_string_util.h:199
constexpr DAW_ATTRIB_FLATINLINE CharT * mempbrk_unchecked(CharT *first, CharT *)
Definition: daw_json_string_util.h:126
constexpr DAW_ATTRIB_FLATINLINE CharT * memchr_unchecked(CharT *first, CharT *last)
Search for a character in a string.
Definition: daw_json_string_util.h:42
constexpr DAW_ATTRIB_FLATINLINE CharT * mempbrk_checked(CharT *first, CharT *last)
Definition: daw_json_string_util.h:170
constexpr DAW_ATTRIB_FLATINLINE bool in(char c)
Definition: daw_json_parse_policy_policy_details.h:19
Definition: daw_from_json.h:22
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.
Definition: version.h:16