14 #include <daw/daw_likely.h>
15 #include <daw/daw_sort_n.h>
16 #include <daw/daw_string_view.h>
17 #include <daw/daw_uint_buffer.h>
22 #if defined( DAW_JSON_PARSER_DIAGNOSTICS )
29 namespace json_details {
30 template<
bool FullNameMatch,
typename CharT>
39 [[maybe_unused, nodiscard]]
inline constexpr
bool missing( )
const {
40 return first ==
nullptr;
43 template<
typename ParseState>
52 template<
typename ParseState>
53 constexpr
auto get_range( template_param<ParseState> )
const {
54 using range_t =
typename ParseState::without_allocator_type;
61 template<
typename CharT>
69 [[maybe_unused, nodiscard]]
inline constexpr
bool missing( )
const {
70 return first ==
nullptr;
73 template<
typename ParseState>
82 template<
typename ParseState>
83 constexpr
auto get_range( template_param<ParseState> )
const {
85 using range_t =
typename ParseState::without_allocator_type;
96 template<std::size_t MemberCount,
typename CharT,
97 bool DoFullNameMatch =
true>
116 static constexpr std::size_t
size( ) {
120 [[nodiscard]] constexpr std::size_t
121 find_name( std::size_t start_pos, daw::string_view key )
const {
123 #if defined( _MSC_VER ) and not defined( __clang__ )
127 for( std::size_t n = 0; n < MemberCount; ++n ) {
129 for( std::size_t n = start_pos; n < MemberCount; ++n ) {
133 if( DAW_UNLIKELY( key !=
names[n].name ) ) {
145 template<
typename... MemberNames>
147 daw::UInt32
hashes[
sizeof...( MemberNames )]{
150 daw::sort( std::data(
hashes ), daw::data_end(
hashes ) );
151 return daw::algorithm::adjacent_find( std::data(
hashes ),
153 []( UInt32 l, UInt32 r ) {
155 } ) != daw::data_end(
hashes );
159 template<
typename ParseState,
typename... JsonMembers>
161 using CharT =
typename ParseState::CharT;
162 #if defined( DAW_JSON_PARSER_DIAGNOSTICS ) or \
163 ( defined( __MSC_VER ) and not defined( __clang__ ) )
169 JsonMembers::name }... } };
173 ParseState::force_name_equal_check or
180 JsonMembers::name }... } };
200 bool from_start =
false, std::size_t N,
typename ParseState,
201 bool B,
typename CharT>
202 [[nodiscard]]
inline constexpr std::pair<ParseState, bool>
205 bool is_nullable, daw::string_view member_name ) {
220 bool known = not locations[pos].missing( );
221 while( locations[pos].missing( ) & (
parse_state.front( ) !=
'}' ) ) {
225 auto const name_pos =
226 locations.
find_name( from_start ? 0 : pos, name );
231 #if defined( DAW_JSON_PARSER_DIAGNOSTICS )
232 std::cerr <<
"DEBUG: Unknown member '" << name <<
'\n';
234 if( name_pos >= std::size( locations ) ) {
241 if( name_pos == pos ) {
245 #if defined( DAW_JSON_PARSER_DIAGNOSTICS )
246 std::cerr <<
"DEBUG: Out of order member '"
248 <<
"' found, looking for '" << locations.
names[pos].
name
250 << std::abs(
static_cast<long long>( pos ) -
251 static_cast<long long>( name_pos ) )
252 <<
" members ahead in constructor\n";
264 if constexpr( ParseState::is_unchecked_input ) {
265 if( name_pos + 1 < std::size( locations ) ) {
275 if( locations[pos].missing( ) ) {
278 if constexpr( ParseState::has_allocator ) {
279 return std::pair<ParseState, bool>{
281 .get_range( template_arg<ParseState> )
285 return std::pair<ParseState, bool>{
286 locations[pos].get_range( template_arg<ParseState> ), known };
#define daw_json_assert_weak(Bool,...)
Definition: daw_json_assert.h:189
#define daw_json_assert(Bool,...)
Definition: daw_json_assert.h:178
ParseState & parse_state
Definition: daw_json_parse_class.h:201
constexpr bool do_hashes_collide()
Definition: daw_json_location_info.h:146
constexpr DAW_ATTRIB_FLATINLINE auto make_locations_info()
Definition: daw_json_location_info.h:160
constexpr DAW_ATTRIB_FLATTEN daw::string_view parse_name(ParseState &parse_state)
Definition: daw_json_parse_name.h:128
constexpr std::pair< ParseState, bool > find_class_member(ParseState &parse_state, locations_info_t< N, CharT, B > &locations, bool is_nullable, daw::string_view member_name)
Definition: daw_json_location_info.h:203
constexpr ParseState skip_value(ParseState &parse_state)
Definition: daw_json_skip.h:298
AllMembersMustExist
Definition: daw_json_location_info.h:198
Definition: daw_from_json.h:22
constexpr UInt32 name_hash(StringView const &key, std::uint32_t seed=0)
Definition: daw_murmur3.h:45
constexpr bool missing() const
Definition: daw_json_location_info.h:69
constexpr void set_range(ParseState const &parse_state)
Definition: daw_json_location_info.h:74
constexpr auto get_range(template_param< ParseState >) const
Definition: daw_json_location_info.h:83
Definition: daw_json_location_info.h:31
constexpr auto get_range(template_param< ParseState >) const
Definition: daw_json_location_info.h:53
constexpr void set_range(ParseState const &parse_state)
Definition: daw_json_location_info.h:44
std::size_t counter
Definition: daw_json_location_info.h:37
constexpr bool missing() const
Definition: daw_json_location_info.h:39
CharT * class_last
Definition: daw_json_location_info.h:36
CharT * first
Definition: daw_json_location_info.h:33
CharT * class_first
Definition: daw_json_location_info.h:35
daw::string_view name
Definition: daw_json_location_info.h:32
CharT * last
Definition: daw_json_location_info.h:34
Definition: daw_json_location_info.h:98
value_type names[MemberCount]
Definition: daw_json_location_info.h:104
constexpr reference operator[](std::size_t idx)
Definition: daw_json_location_info.h:111
static constexpr std::size_t size()
Definition: daw_json_location_info.h:116
static constexpr bool do_full_name_match
Definition: daw_json_location_info.h:102
constexpr std::size_t find_name(std::size_t start_pos, daw::string_view key) const
Definition: daw_json_location_info.h:121
value_type const & const_reference
Definition: daw_json_location_info.h:101
daw::UInt32 hashes[MemberCount]
Definition: daw_json_location_info.h:103
constexpr const_reference operator[](std::size_t idx) const
Definition: daw_json_location_info.h:106
#define DAW_JSON_VER
Definition: version.h:11