21 #include <daw/cpp_17.h>
22 #include <daw/daw_attributes.h>
23 #include <daw/daw_likely.h>
24 #include <daw/daw_traits.h>
30 #include <type_traits>
46 typename Allocator = json_details::NoAllocator>
53 json_details::get_bits_for<TemporarilyMutateBuffer>( PolicyFlags ) ==
57 std::conditional_t<allow_temporarily_mutating_buffer, char, char const>;
64 json_details::get_bits_for<CheckedParseMode>( PolicyFlags ) ==
71 switch_t<json_details::get_bits_for<ExecModeTypes, std::size_t>(
81 json_details::get_bits_for<AllowEscapedNames>( PolicyFlags ) ==
88 json_details::get_bits_for<ForceFullNameCheck>( PolicyFlags ) ==
95 json_details::get_bits_for<ZeroTerminatedString>( PolicyFlags ) ==
102 json_details::get_bits_for<IEEE754Precise>( PolicyFlags ) ==
109 json_details::get_bits_for<MinifiedDocument>( PolicyFlags ) ==
116 json_details::get_bits_for<ExcludeSpecialEscapes>( PolicyFlags ) ==
131 json_details::get_bits_for<UseExactMappingsByDefault>( PolicyFlags ) ==
135 json_details::get_bits_for<MustVerifyEndOfDataIsValid>( PolicyFlags ) ==
139 switch_t<json_details::get_bits_for<PolicyCommentTypes, std::size_t>(
151 template<
auto... PolicyOptions>
197 result.class_first = cf;
200 result.class_last = cl;
205 template<
typename Alloc>
208 template<
typename Alloc>
215 template<
typename Alloc>
216 [[nodiscard]] constexpr
auto
218 if constexpr( std::is_same<Alloc, json_details::NoAllocator>::value ) {
222 p.get_allocator( ) );
228 template<
typename Alloc>
229 [[nodiscard]]
inline constexpr with_allocator_type<Alloc>
256 template<
typename Alloc>
257 [[nodiscard]]
static inline constexpr with_allocator_type<Alloc>
259 return { f, l, f, l, alloc };
269 return { f, l, cf, cl };
272 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr
iterator
277 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr
iterator
282 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr
iterator
287 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr
iterator
292 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr
bool empty( )
const {
303 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr
bool
308 template<std::
size_t N>
309 inline constexpr
bool starts_with(
char const ( &rhs )[N] )
const {
310 if(
size( ) < ( N - 1 ) ) {
314 for( std::size_t n = 0; n < ( N - 1 ); ++n ) {
315 result = result & (
first[n] == rhs[n] );
325 first =
reinterpret_cast<CharT *
>( std::memchr(
328 while( *
first != c ) {
339 first =
reinterpret_cast<CharT *
>( std::memchr(
353 move_to_next_of_unchecked<c>( );
355 move_to_next_of_checked<c>( );
359 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr
char front( )
const {
363 [[nodiscard]]
inline constexpr std::size_t
size( )
const {
364 return static_cast<std::size_t
>(
last -
first );
367 [[nodiscard]]
inline constexpr
bool is_null( )
const {
368 return first ==
nullptr;
375 DAW_ATTRIB_FLATINLINE
inline constexpr
void
377 first +=
static_cast<std::ptrdiff_t
>( n );
386 return CommentPolicy::trim_left_checked( *
this );
390 return CommentPolicy::trim_left_unchecked( *
this );
397 while( (
static_cast<unsigned char>( *f ) > 0x20U ) &
398 not CommentPolicy::is_literal_end( *f ) ) {
402 while( ( f < l ) and ( (
static_cast<unsigned char>( *f ) > 0x20 ) &
403 not CommentPolicy::is_literal_end( *f ) ) ) {
411 return CommentPolicy::is_literal_end( *
first );
414 DAW_ATTRIB_FLATINLINE [[nodiscard]]
inline constexpr
bool
418 return (
static_cast<unsigned>(
static_cast<unsigned char>( *
first ) ) -
422 DAW_ATTRIB_FLATINLINE [[nodiscard]]
inline constexpr
bool
424 return (
static_cast<unsigned>(
static_cast<unsigned char>( *
first ) ) -
454 if( *
first ==
',' ) {
460 DAW_ATTRIB_FLATINLINE
inline constexpr
void
464 if( *
first ==
',' ) {
486 CommentPolicy::move_next_member_unchecked( *
this );
502 return parse_policy_details::in<',', ']'>( *
first );
506 return parse_policy_details::in<',', '}', ']'>( *
first );
509 template<
char PrimLeft,
char PrimRight,
char SecLeft,
char SecRight>
510 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr
ParseState
513 PrimLeft, PrimRight, SecLeft, SecRight>( *this );
516 template<
char PrimLeft,
char PrimRight,
char SecLeft,
char SecRight>
517 [[nodiscard]] DAW_ATTRIB_FLATINLINE
inline constexpr
ParseState
520 PrimLeft, PrimRight, SecLeft, SecRight>( *this );
552 namespace json_details {
572 template<
typename ExecMode>
577 template<
typename ExecTag,
typename Allocator = json_details::NoAllocator>
579 parse_options( json_details::exec_mode_from_tag<ExecTag> ), Allocator>;
584 template<
typename ExecTag,
typename Allocator = json_details::NoAllocator>
588 json_details::exec_mode_from_tag<ExecTag> ),
597 template<
typename ExecTag,
typename Allocator = json_details::NoAllocator>
601 json_details::exec_mode_from_tag<ExecTag> ),
604 template<
typename ExecTag,
typename Allocator = json_details::NoAllocator>
608 json_details::exec_mode_from_tag<ExecTag> ),
622 template<
typename ExecTag,
typename Allocator = json_details::NoAllocator>
626 json_details::exec_mode_from_tag<ExecTag> ),
633 template<
typename ExecTag,
typename Allocator = json_details::NoAllocator>
637 json_details::exec_mode_from_tag<ExecTag> ),
645 namespace json_details {
651 template<
typename ParsePolicy>
653 ParsePolicy::exec_tag_t::always_rvo;
#define daw_json_assert_weak(Bool,...)
Definition: daw_json_assert.h:189
#define daw_json_assert(Bool,...)
Definition: daw_json_assert.h:178
constexpr json_options_t set_bits(JsonOptionList< OptionList... >, json_options_t value, Option pol, Options... pols)
Definition: daw_json_option_bits.h:138
constexpr bool is_guaranteed_rvo_v
Definition: daw_json_parse_policy.h:652
std::uint32_t json_options_t
Definition: daw_json_option_bits.h:23
static constexpr json_options_t default_policy_flag
Definition: daw_json_parse_options.h:289
constexpr ExecModeTypes exec_mode_from_tag
Definition: daw_json_parse_policy.h:573
constexpr DAW_ATTRIB_FLATINLINE bool in(char c)
Definition: daw_json_parse_policy_policy_details.h:19
constexpr json_details::json_options_t parse_options(Policies... policies)
Definition: daw_json_parse_options.h:314
ExecModeTypes
Definition: daw_json_parse_options.h:33
Definition: daw_from_json.h:22
Definition: daw_json_parse_policy.h:47
constexpr BasicParsePolicy(iterator f, iterator l, Allocator &alloc)
Definition: daw_json_parse_policy.h:163
BasicParsePolicy ParseState
Definition: daw_json_parse_policy.h:149
constexpr DAW_ATTRIB_FLATINLINE iterator begin() const
Definition: daw_json_parse_policy.h:283
constexpr DAW_ATTRIB_FLATINLINE void move_next_member_or_end()
Definition: daw_json_parse_policy.h:476
constexpr bool is_literal_end() const
Definition: daw_json_parse_policy.h:410
static constexpr without_allocator_type without_allocator(iterator f, iterator l, iterator cf, iterator cl)
Definition: daw_json_parse_policy.h:268
static constexpr bool allow_leading_zero_plus
Definition: daw_json_parse_policy.h:119
static constexpr bool exclude_special_escapes
Definition: daw_json_parse_policy.h:115
static constexpr bool is_zero_terminated_string
Definition: daw_json_parse_policy.h:94
constexpr DAW_ATTRIB_FLATINLINE bool is_space_checked() const
Definition: daw_json_parse_policy.h:415
constexpr void move_to_next_class_member()
Definition: daw_json_parse_policy.h:493
constexpr void trim_left_unchecked()
Definition: daw_json_parse_policy.h:389
switch_t< json_details::get_bits_for< ExecModeTypes, std::size_t >(PolicyFlags), constexpr_exec_tag, runtime_exec_tag, simd_exec_tag > exec_tag_t
Definition: daw_json_parse_policy.h:73
constexpr DAW_ATTRIB_FLATINLINE iterator data() const
Definition: daw_json_parse_policy.h:273
constexpr bool is_at_next_array_element() const
Definition: daw_json_parse_policy.h:501
constexpr std::size_t size() const
Definition: daw_json_parse_policy.h:363
static constexpr bool force_name_equal_check
Definition: daw_json_parse_policy.h:87
constexpr with_allocator_type< Alloc > with_allocator(Alloc &alloc) const
Definition: daw_json_parse_policy.h:230
iterator first
Definition: daw_json_parse_policy.h:144
BasicParsePolicy< PolicyFlags, json_details::NoAllocator > without_allocator_type
Definition: daw_json_parse_policy.h:238
constexpr bool is_at_next_class_member() const
Definition: daw_json_parse_policy.h:497
static constexpr with_allocator_type< Alloc > with_allocator(iterator f, iterator l, Alloc &alloc)
Definition: daw_json_parse_policy.h:258
static constexpr bool is_unchecked_input
Definition: daw_json_parse_policy.h:63
constexpr void trim_left_checked()
Definition: daw_json_parse_policy.h:385
static constexpr exec_tag_t exec_tag
Definition: daw_json_parse_policy.h:75
iterator class_first
Definition: daw_json_parse_policy.h:146
constexpr bool is_at_token_after_value() const
Definition: daw_json_parse_policy.h:505
constexpr ParseState skip_array()
Definition: daw_json_parse_policy.h:531
static constexpr bool minified_document
Definition: daw_json_parse_policy.h:108
constexpr ParseState skip_class()
Definition: daw_json_parse_policy.h:523
constexpr bool starts_with(char const (&rhs)[N]) const
Definition: daw_json_parse_policy.h:309
static constexpr bool must_verify_end_of_data_is_valid
Definition: daw_json_parse_policy.h:134
constexpr DAW_ATTRIB_FLATINLINE ParseState skip_bracketed_item_unchecked()
Definition: daw_json_parse_policy.h:518
constexpr DAW_ATTRIB_FLATINLINE void move_next_member()
Definition: daw_json_parse_policy.h:484
constexpr DAW_ATTRIB_FLATINLINE void move_to_next_of()
Definition: daw_json_parse_policy.h:351
constexpr DAW_ATTRIB_FLATINLINE bool is_space_unchecked() const
Definition: daw_json_parse_policy.h:423
constexpr DAW_ATTRIB_FLATINLINE char front() const
Definition: daw_json_parse_policy.h:359
static constexpr bool precise_ieee754
Definition: daw_json_parse_policy.h:101
iterator last
Definition: daw_json_parse_policy.h:145
constexpr DAW_ATTRIB_FLATINLINE bool empty() const
Definition: daw_json_parse_policy.h:292
CharT * iterator
Definition: daw_json_parse_policy.h:58
constexpr DAW_ATTRIB_FLATINLINE void move_to_next_of_unchecked()
Definition: daw_json_parse_policy.h:321
constexpr bool is_opening_brace_checked() const
Definition: daw_json_parse_policy.h:432
constexpr auto with_allocator(BasicParsePolicy< PolicyFlags, Alloc > p) const
Definition: daw_json_parse_policy.h:217
iterator class_last
Definition: daw_json_parse_policy.h:147
constexpr void move_next_member_or_end_unchecked()
Definition: daw_json_parse_policy.h:452
constexpr DAW_ATTRIB_FLATINLINE ParseState skip_bracketed_item_checked()
Definition: daw_json_parse_policy.h:511
constexpr DAW_ATTRIB_FLATINLINE void move_to_next_of_checked()
Definition: daw_json_parse_policy.h:335
constexpr BasicParsePolicy(iterator f, iterator l, iterator cf, iterator cl, Allocator &alloc)
Definition: daw_json_parse_policy.h:178
std::size_t counter
Definition: daw_json_parse_policy.h:148
constexpr bool is_quotes_checked() const
Definition: daw_json_parse_policy.h:440
static constexpr without_allocator_type without_allocator(iterator f, iterator l)
Definition: daw_json_parse_policy.h:263
constexpr DAW_ATTRIB_FLATINLINE bool has_more() const
Definition: daw_json_parse_policy.h:304
static constexpr without_allocator_type without_allocator(BasicParsePolicy p)
Definition: daw_json_parse_policy.h:241
constexpr DAW_ATTRIB_FLATINLINE void remove_prefix(std::size_t n)
Definition: daw_json_parse_policy.h:376
constexpr DAW_ATTRIB_FLATINLINE void move_next_member_or_end_checked()
Definition: daw_json_parse_policy.h:461
switch_t< json_details::get_bits_for< PolicyCommentTypes, std::size_t >(PolicyFlags), NoCommentSkippingPolicy, CppCommentSkippingPolicy, HashCommentSkippingPolicy > CommentPolicy
Definition: daw_json_parse_policy.h:142
constexpr void set_class_position()
Definition: daw_json_parse_policy.h:380
static constexpr bool allow_temporarily_mutating_buffer
Definition: daw_json_parse_policy.h:52
constexpr BasicParsePolicy()=default
static constexpr bool allow_escaped_names
Definition: daw_json_parse_policy.h:80
constexpr BasicParsePolicy(iterator f, iterator l)
Definition: daw_json_parse_policy.h:157
std::conditional_t< allow_temporarily_mutating_buffer, char, char const > CharT
Definition: daw_json_parse_policy.h:57
constexpr bool is_null() const
Definition: daw_json_parse_policy.h:367
constexpr bool is_closing_brace_checked() const
Definition: daw_json_parse_policy.h:436
constexpr void move_to_end_of_literal()
Definition: daw_json_parse_policy.h:393
constexpr bool is_opening_bracket_checked() const
Definition: daw_json_parse_policy.h:428
constexpr DAW_ATTRIB_FLATINLINE iterator end() const
Definition: daw_json_parse_policy.h:288
constexpr BasicParsePolicy copy(iterator f=iterator{ }, iterator l=iterator{ }, iterator cf=iterator{ }, iterator cl=iterator{ }) const
Definition: daw_json_parse_policy.h:187
static constexpr bool use_exact_mappings_by_default
Definition: daw_json_parse_policy.h:130
constexpr BasicParsePolicy(iterator f, iterator l, iterator cf, iterator cl)
Definition: daw_json_parse_policy.h:171
constexpr DAW_ATTRIB_FLATINLINE void remove_prefix()
Definition: daw_json_parse_policy.h:371
static constexpr with_allocator_type< Alloc > with_allocator(iterator f, iterator l, iterator cf, iterator cl, Alloc &alloc)
Definition: daw_json_parse_policy.h:210
constexpr void trim_left()
Definition: daw_json_parse_policy.h:444
constexpr DAW_ATTRIB_FLATINLINE iterator data_end() const
Definition: daw_json_parse_policy.h:278
constexpr without_allocator_type without_allocator() const
Definition: daw_json_parse_policy.h:249
Definition: daw_json_exec_modes.h:19
AllocatorWrapper(allocator_type &alloc) noexcept
Definition: daw_json_allocator_wrapper.h:56
Definition: daw_json_parse_policy.h:554
Definition: daw_json_exec_modes.h:28
Definition: daw_json_exec_modes.h:41
#define DAW_JSON_VER
Definition: version.h:11