DAW JSON Link
daw_json_traits.h
Go to the documentation of this file.
1// Copyright (c) Darrell Wright
2//
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
5//
6// Official repository: https://github.com/beached/daw_json_link
7//
8
9#pragma once
10
11#include "version.h"
12
13#include "daw_json_enums.h"
14
15#include <daw/cpp_17.h>
16#include <daw/daw_fwd_pack_apply.h>
17#include <daw/daw_move.h>
18#include <daw/daw_scope_guard.h>
19#include <daw/daw_traits.h>
20
21#include <array>
22#include <memory>
23#include <optional>
24#include <string>
25#include <unordered_map>
26#include <utility>
27
28/***
29 * Customization point traits
30 *
31 */
32namespace daw::json {
33 inline namespace DAW_JSON_VER {
34 namespace json_details {
35 template<typename T>
37 decltype( static_cast<bool>( std::declval<T>( ) ) );
38
39 template<typename T>
40 inline constexpr bool has_op_bool_v =
41 daw::is_detected_v<has_op_bool_test, T>;
42
43 template<typename T>
44 using has_op_star_test = decltype( *std::declval<T>( ) );
45
46 template<typename T>
47 inline constexpr bool has_op_star_v =
48 daw::is_detected_v<has_op_star_test, T>;
49
50 template<typename T>
51 using has_empty_member_test = decltype( std::declval<T>( ).empty( ) );
52
53 template<typename T>
54 inline constexpr bool has_empty_member_v =
55 daw::is_detected_v<has_empty_member_test, T>;
56
57 template<typename T>
58 inline constexpr bool is_readable_v =
59 has_op_bool_v<T> or has_empty_member_v<T>;
60
61 template<typename T>
62 inline constexpr auto has_value( T const &v )
63 -> std::enable_if_t<is_readable_v<T>, bool> {
64
65 if constexpr( has_op_bool_v<T> ) {
66 return static_cast<bool>( v );
67 } else if constexpr( has_empty_member_v<T> ) {
68 return not v.empty( );
69 }
70 DAW_UNREACHABLE( );
71 }
72
73 template<typename Constructor, typename... Args>
75
76 template<typename Constructor, typename... Args>
78
79 // clang-format off
80 template<bool Nullable, typename Constructor, typename... Args>
82 std::conditional_t<
84 std::conditional_t<
85 std::is_invocable_v<Constructor, Args...>,
86 std::conditional_t<
87 std::is_invocable_v<Constructor>,
88 std::invoke_result<Constructor>,
89 traits::identity<nullable_constructor_cannot_be_invoked<Constructor>>
90 >,
91 traits::identity<nullable_constructor_cannot_be_invoked<Constructor, Args...>>
92 >,
93 std::conditional_t<
94 std::is_invocable_v<Constructor, Args...>,
95 std::invoke_result<Constructor, Args...>,
96 traits::identity<constructor_cannot_be_invoked<Constructor, Args...>>
97 >
98 >;
99 // clang-format on
100 } // namespace json_details
101
102 namespace json_details {
103 template<typename JsonMember>
105
106 template<typename JsonMember, JSONNAMETYPE NewName, bool Cond>
107 using copy_name_when = std::conditional_t<
108 Cond, typename JsonMember::template with_name<NewName>, JsonMember>;
109
110 template<typename JsonMember, JSONNAMETYPE NewName>
113 } // namespace json_details
114 /***
115 * This class is used as a way to indicate that a json_data_contract
116 * specialization has not been done for a user class.
117 */
118 template<typename>
120
121 /***
122 * Mapping class for JSON data structures to C++. It must be specialized in
123 * order to parse to a user class
124 * @tparam T Class to map
125 */
126 template<typename T, typename = void>
129 };
130
131 /***
132 * This trait gets us the mapping type from the contract.
133 */
134 template<typename T>
136
137 template<typename T>
140
141 namespace json_details {
142 template<typename T>
145
146 template<typename T>
147 inline constexpr bool is_json_map_alias_v =
148 daw::is_detected_v<json_map_alias_test, T>;
149
150 template<typename T>
153
154 template<typename T>
157
158 template<typename JsonMember>
159 using switcher_t = typename JsonMember::switcher;
160
161 template<typename JsonMember>
162 inline constexpr bool has_switcher_v =
163 daw::is_detected_v<switcher_t, JsonMember>;
164 } // namespace json_details
165 /***
166 * This trait can be specialized such that when class being returned has
167 * non-move/copyable members the construction can be done with { } instead
168 * of a callable. This is a blunt object and probably should not be used
169 * add a type alias named force_aggregate_construction to your
170 * json_data_contract specialization
171 * @tparam T type to specialize
172 */
173 template<typename T>
174 using force_aggregate_construction = std::bool_constant<std::disjunction_v<
175 daw::is_detected<json_details::force_aggregate_construction_test, T>,
176 daw::is_detected<json_details::force_aggregate_construction_test2, T>>>;
177
178 template<typename T>
179 inline constexpr bool force_aggregate_construction_v =
181
182 namespace json_details {
183 template<typename T>
185 }
186
187 template<typename... Ts>
188 using is_empty_pack = std::bool_constant<( sizeof...( Ts ) == 0 )>;
189
190 template<typename... Ts>
191 inline constexpr bool is_empty_pack_v = is_empty_pack<Ts...>::value;
192
193 /***
194 * Default Constructor for a type. It accounts for aggregate types and uses
195 * brace construction for them
196 * @tparam T type to construct
197 */
198 template<typename T>
200 [[nodiscard]] DAW_ATTRIB_INLINE inline constexpr T operator( )( ) const {
201 return T{ };
202 }
203
204 template<
205 typename... Args,
206 std::enable_if_t<std::conjunction_v<std::is_constructible<T, Args...>,
207 not_trait<is_empty_pack<Args...>>>,
208 std::nullptr_t> = nullptr>
209 [[nodiscard]] DAW_ATTRIB_INLINE inline constexpr T
210 operator( )( Args &&...args ) const {
211
212 return T( DAW_FWD2( Args, args )... );
213 }
214
215 template<
216 typename... Args,
217 typename std::enable_if_t<
218 std::conjunction_v<daw::not_trait<std::is_constructible<T, Args...>>,
219 daw::not_trait<is_empty_pack<Args...>>,
220 daw::traits::is_list_constructible<T, Args...>>,
221 std::nullptr_t> = nullptr>
222 [[nodiscard]] DAW_ATTRIB_INLINE inline constexpr T
223 operator( )( Args &&...args ) const
224 noexcept( noexcept( T{ DAW_FWD2( Args, args )... } ) ) {
225
226 return T{ DAW_FWD2( Args, args )... };
227 }
228 };
229
230 template<typename, typename = void>
231 struct is_default_constructor : std::false_type {};
232
233 template<typename T>
235
236 template<typename T>
237 inline constexpr bool is_default_constructor_v =
239
240 namespace json_details {
241 template<typename>
242 struct is_std_allocator : std::false_type {};
243
244 template<typename... Ts>
245 struct is_std_allocator<std::allocator<Ts...>> : std::true_type {};
246 } // namespace json_details
247
248 inline namespace {
249 template<typename Iterator>
250 struct construct_array_cleanup {
251 Iterator &it;
252
253 DAW_ATTRIB_INLINE
254 DAW_SG_CXDTOR inline ~construct_array_cleanup( ) noexcept( false ) {
255#if defined( DAW_HAS_CONSTEXPR_SCOPE_GUARD )
256 if( DAW_IS_CONSTANT_EVALUATED( ) ) {
257 ++it;
258 } else {
259#endif
260 if( std::uncaught_exceptions( ) == 0 ) {
261 ++it;
262 }
263#if defined( DAW_HAS_CONSTEXPR_SCOPE_GUARD )
264 }
265#endif
266 }
267 };
268 } // namespace
269
270 template<typename T, std::size_t Sz>
271 struct default_constructor<std::array<T, Sz>> {
272 DAW_ATTRIB_INLINE constexpr std::array<T, Sz> operator( )( ) const
273 noexcept( noexcept( std::array<T, Sz>{ } ) ) {
274 return { };
275 }
276
277 DAW_ATTRIB_INLINE constexpr std::array<T, Sz> &&
278 operator( )( std::array<T, Sz> &&v ) const noexcept {
279 return DAW_MOVE( v );
280 }
281
282 template<typename Iterator, std::size_t... Is>
283 DAW_ATTRIB_INLINE static constexpr std::array<T, Sz>
284 construct_array( Iterator first, Iterator last,
285 std::index_sequence<Is...> ) {
286 auto const get_result = [&]( std::size_t ) {
287 if( first != last ) {
288 if constexpr( std::is_move_constructible_v<T> ) {
289 auto result = *first;
290 ++first;
291 return result;
292 } else {
293 auto const run_after_parse = construct_array_cleanup{ first };
294 (void)run_after_parse;
295 return *first;
296 }
297 }
298 return T{ };
299 };
300 return std::array<T, Sz>{ get_result( Is )... };
301 }
302
303 template<typename Iterator>
304 DAW_ATTRIB_INLINE constexpr std::array<T, Sz>
305 operator( )( Iterator first, Iterator last ) const {
306 return construct_array( first, last, std::make_index_sequence<Sz>{ } );
307 }
308 };
309
310 template<typename T, typename Alloc>
311 struct default_constructor<std::vector<T, Alloc>> {
312 // DAW
313 DAW_ATTRIB_INLINE inline std::vector<T, Alloc> operator( )( ) const
314 noexcept( noexcept( std::vector<T, Alloc>( ) ) ) {
315 return { };
316 }
317
318 DAW_ATTRIB_INLINE inline std::vector<T, Alloc> &&
319 operator( )( std::vector<T, Alloc> &&v ) const
320 noexcept( noexcept( std::vector<T, Alloc>( v ) ) ) {
321 return DAW_MOVE( v );
322 }
323
324 template<typename Iterator>
325 DAW_ATTRIB_INLINE inline std::vector<T, Alloc>
326 operator( )( Iterator first, Iterator last,
327 Alloc const &alloc = Alloc{ } ) const {
328 if constexpr( std::is_same_v<std::random_access_iterator_tag,
329 typename std::iterator_traits<
330 Iterator>::iterator_category> or
331 not json_details::is_std_allocator<Alloc>::value ) {
332 return std::vector<T, Alloc>( first, last, alloc );
333 } else {
334 constexpr auto reserve_amount = 4096U / ( sizeof( T ) * 8U );
335 auto result = std::vector<T, Alloc>( alloc );
336 // Lets use a WAG and go for a 4k page size
337 result.reserve( reserve_amount );
338 result.assign( first, last );
339 return result;
340 }
341 }
342 };
343
344 /***
345 * Auto generated constructor for nullable types.
346 * Specializations must accept accept an operator( )( ) that signifies a
347 * JSON null. Any other arguments only need to be valid to construct the
348 * type.
349 */
350 template<typename T>
352
353 template<typename T>
354 struct nullable_constructor<std::optional<T>> {
355 using value_type = T;
356
357 [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::optional<T>
358 operator( )( ) const noexcept {
359 return std::optional<T>( );
360 }
361
362 template<typename... Args>
363 [[nodiscard]] DAW_ATTRIB_INLINE inline constexpr auto
364 operator( )( Args &&...args ) const
365 noexcept( std::is_nothrow_constructible<
366 std::optional<T>, std::in_place_t, Args...>::value )
367 -> std::enable_if_t<
368 ( ( sizeof...( Args ) > 0 ) and
369 std::is_constructible<T, std::in_place_t, Args...>::value ),
370 std::optional<T>> {
371
372 return std::optional<T>( std::in_place, DAW_FWD2( Args, args )... );
373 }
374
375 template<typename... Args>
376 [[nodiscard]] DAW_ATTRIB_INLINE inline constexpr auto
377 operator( )( Args &&...args ) const noexcept(
378 std::conjunction<traits::is_nothrow_list_constructible<T, Args...>,
379 std::is_nothrow_move_constructible<T>>::value )
380 -> std::enable_if_t<
381 ( ( sizeof...( Args ) > 0 ) and
382 not std::is_constructible<T, std::in_place_t, Args...>::value and
383 traits::is_list_constructible<T, Args...>::value ),
384 std::optional<T>> {
385
386 return std::optional<T>( T{ DAW_FWD2( Args, args )... } );
387 }
388 };
389
390 template<typename T, typename Deleter>
391 struct nullable_constructor<std::unique_ptr<T, Deleter>> {
392 using value_type = T;
393
394 DAW_ATTRIB_INLINE inline constexpr std::unique_ptr<T, Deleter>
395 operator( )( ) const noexcept {
396 return std::unique_ptr<T, Deleter>{ };
397 }
398
399 template<typename... Args>
400 [[nodiscard]] DAW_ATTRIB_INLINE inline auto
401 operator( )( Args &&...args ) const
402 noexcept( std::is_nothrow_constructible<T, Args...>::value )
403 -> std::enable_if_t<( sizeof...( Args ) > 0 and
404 std::is_constructible<T, Args...>::value ),
405 std::unique_ptr<T, Deleter>> {
406
407 return std::unique_ptr<T, Deleter>(
408 new T( DAW_FWD2( Args, args )... ) );
409 }
410
411 template<typename... Args>
412 [[nodiscard]] DAW_ATTRIB_INLINE inline auto
413 operator( )( Args &&...args ) const
414 noexcept( traits::is_nothrow_list_constructible<T, Args...>::value )
415 -> std::enable_if_t<
416 ( ( sizeof...( Args ) > 0 ) and
417 not std::is_constructible<T, Args...>::value and
418 traits::is_list_constructible<T, Args...>::value ),
419 std::unique_ptr<T, Deleter>> {
420
421 return std::unique_ptr<T, Deleter>(
422 new T{ DAW_FWD2( Args, args )... } );
423 }
424 };
425
426 /***
427 * Can use the fast, pseudo random string iterators. They are
428 * InputIterators with an operator- that allows for O(1) distance
429 * calculations as we often know the length but cannot provide random
430 * access. For types that only use InputIterator operations and last -
431 * first for distance calc
432 */
433 template<typename>
434 struct can_single_allocation_string : std::false_type {};
435
436 template<typename Char, typename CharTrait, typename Allocator>
438 std::basic_string<Char, CharTrait, Allocator>> : std::true_type {};
439
440 namespace json_details {
441 template<typename T>
442 using json_type_t = typename T::i_am_a_json_type;
443
444 template<typename T>
446 std::bool_constant<daw::is_detected_v<json_type_t, T>>;
447
448 template<typename T>
450
451 template<typename T>
452 struct ensure_json_type : std::true_type {
453 static_assert( is_a_json_type_v<T> );
454 };
455
456 template<typename T>
457 using ordered_member_t = typename T::i_am_an_ordered_member;
458
459 template<typename T>
460 using is_an_ordered_member = daw::is_detected<ordered_member_t, T>;
461
462 template<typename T>
463 inline constexpr bool is_an_ordered_member_v =
465
466 template<typename T>
468 typename T::i_am_a_json_tagged_variant;
469
470 template<typename T>
472 daw::is_detected<is_a_json_tagged_variant_test, T>;
473
474 template<typename T>
475 inline constexpr bool is_a_json_tagged_variant_v =
477
478 template<typename T, bool, bool>
481 };
482
483 template<typename T>
485 decltype( decltype( std::declval<
486 json_data_contract_trait_t<T>> )::constructor );
487
488 template<typename T>
491 };
492
493 template<typename T>
496 T, daw::is_detected<json_data_contract_trait_t, T>::value,
497 daw::is_detected<has_json_data_constract_constructor_test, T>::value>;
498
499 template<typename T>
502
503 // DAW 20210801
504 /*template<typename T, typename Default>
505 using json_class_constructor_t = typename std::conditional_t<
506 daw::is_detected<json_data_contract_constructor_t, T>::value,
507 json_data_contract_constructor<T>,
508 daw::traits::identity<Default>>::type;*/
509
510 template<typename T>
513
514 template<typename T, typename Default>
516 daw::detected_or_t<Default, json_class_constructor_t_impl, T>;
517
518 namespace is_string_like_impl {
519 template<typename T>
520 using has_data_test = decltype( std::data( std::declval<T>( ) ) );
521
522 template<typename T>
523 using has_size_test = decltype( std::size( std::declval<T>( ) ) );
524 } // namespace is_string_like_impl
525 template<typename T>
526 using is_string_view_like = std::conjunction<
527 daw::is_detected<is_string_like_impl::has_data_test, T>,
528 daw::is_detected<is_string_like_impl::has_size_test, T>>;
529
530 template<typename T>
531 inline constexpr bool is_string_view_like_v =
533
534 static_assert( is_string_view_like_v<std::string_view> );
535
536 } // namespace json_details
537
538 /***
539 * Trait for passively exploiting the zero termination when the type
540 * guarantees it.
541 */
542 template<typename>
543 struct is_zero_terminated_string : std::false_type {};
544
545 template<typename CharT, typename Traits, typename Alloc>
546 struct is_zero_terminated_string<std::basic_string<CharT, Traits, Alloc>>
547 : std::true_type {};
548
549 template<typename T>
550 inline constexpr bool is_zero_terminated_string_v =
552
553 namespace json_details {
554 template<typename ParsePolicy, auto Option>
556 typename ParsePolicy::template SetPolicyOptions<Option>;
557
558 template<typename ParsePolicy, typename String, auto Option>
559 using apply_zstring_policy_option_t = std::conditional_t<
560 is_zero_terminated_string_v<daw::remove_cvref_t<String>>,
562
563 template<typename String>
564 inline constexpr bool is_mutable_string_v =
565 not std::is_const_v<std::remove_pointer_t<std::remove_reference_t<
566 decltype( std::data( std::declval<String &&>( ) ) )>>>;
567
568 template<typename String>
569 constexpr bool is_mutable_string =
570 json_details::is_mutable_string_v<String>;
571
572 template<typename String>
573 constexpr bool is_rvalue_string = std::is_rvalue_reference_v<String>;
574
575 template<typename String>
576 constexpr bool is_ref_string =
577 not is_rvalue_string<String> and
578 std::is_const_v<std::remove_reference_t<String>>;
579
580 template<typename ParsePolicy, typename String, auto OptionMutable,
581 auto OptionImmutable>
582 using apply_mutable_policy = std::conditional_t<
583 ParsePolicy::allow_temporarily_mutating_buffer,
584 std::conditional_t<is_mutable_string_v<String>,
587 std::conditional_t<
588 (is_rvalue_string<String> and is_mutable_string_v<String>),
591 } // namespace json_details
592
593 /***
594 * A trait to specify that this class, when parsed, will describe all
595 * members of the JSON object. Anything not mapped is an error.
596 * Either specialize the class daw::json::is_exact_class_mapping, the
597 * variable is_exact_class_mapping_v, or have a type in your
598 * json_data_contract named exact_class_mapping for your type
599 */
600 template<typename>
601 struct is_exact_class_mapping : std::false_type {};
602
603 /***
604 * Ignore unknown members trait allows the parser to skip unknown members
605 * when the default is exact
606 */
607 template<typename>
608 struct ignore_unknown_members : std::false_type {};
609
610 namespace json_details {
611 template<typename T>
614
615 template<typename T>
618 } // namespace json_details
619
620 template<typename T>
621 inline constexpr bool ignore_unknown_members_v = std::disjunction<
623 daw::is_detected<
625
626 /***
627 * A trait to specify that this class, when parsed, will describe all
628 * members of the JSON object. Anything not mapped is an error.
629 * Either specialize the class daw::json::is_exact_class_mapping, the
630 * variable is_exact_class_mapping_v, or have a type in your
631 * json_data_contract named exact_class_mapping for your type
632 */
633 template<typename T>
634 inline constexpr bool is_exact_class_mapping_v = std::disjunction<
637 T>>::value;
638
639 namespace json_details {
640 template<typename T, typename ParseState>
641 inline constexpr bool all_json_members_must_exist_v =
642 not ignore_unknown_members_v<T> and
643 ( is_exact_class_mapping_v<T> or
644 ParseState::use_exact_mappings_by_default );
645
646 template<JsonNullable ClassNullability, JsonNullable DependentNullability>
647 inline constexpr bool is_nullability_compatable_v =
648 ( DependentNullability == JsonNullable::MustExist ) or
649 ( ClassNullability == JsonNullable::Nullable or
650 ClassNullability == JsonNullable::NullVisible );
651
652 template<typename T>
653 using element_type_t = typename T::element_type;
654
655 template<typename T>
656 using has_element_type = daw::is_detected<element_type_t, T>;
657 } // namespace json_details
658
659 /***
660 * is_pointer_like is used in json_array to ensure that to_json_data returns
661 * a Container/View of the data with the size encoded with it.
662 * The std
663 */
664 template<typename T>
666 : std::disjunction<std::is_pointer<T>,
667 json_details::has_element_type<T>> {};
668
671 template<typename Tuple>
673
674 template<typename... Ts>
675 struct tuple_elements_pack<std::tuple<Ts...>> {
676 using type = std::tuple<Ts...>;
677
678 static constexpr std::size_t size = sizeof...( Ts );
679
680 template<std::size_t Idx>
681 using element_t = std::tuple_element_t<Idx, type>;
682
683 template<std::size_t Idx, typename Tuple>
684 static constexpr decltype( auto ) get( Tuple &&tp ) {
685 return std::get<Idx>( DAW_FWD( tp ) );
686 }
687 };
688
689 template<typename... Ts>
690 struct tuple_elements_pack<daw::fwd_pack<Ts...>> {
691 using type = daw::fwd_pack<Ts...>;
692
693 static constexpr std::size_t size = sizeof...( Ts );
694
695 template<std::size_t Idx>
696 using element_t = typename daw::tuple_element<Idx, type>::type;
697
698 template<std::size_t Idx, typename Tuple>
699 static constexpr decltype( auto ) get( Tuple &&tp ) {
700 return DAW_FWD( tp ).template get<Idx>( );
701 }
702 };
703
704 namespace json_details {
705 template<typename T>
707
710 template<typename T>
711 using is_tuple = daw::is_detected<json_details::tuple_test, T>;
712
713 template<typename T>
714 inline constexpr bool is_tuple_v = is_tuple<T>::value;
715
716 namespace deref_t_impl {
717 template<typename>
719
720 template<typename T>
721 using deref_type_detect = DAW_TYPEOF( *std::declval<T>( ) );
722
723 template<typename T>
725 using type =
726 daw::detected_or_t<unable_to_dereference<T>, deref_type_detect, T>;
727 };
728
729 template<typename T>
730 struct deref_type_impl<T *> {
731 using type = std::remove_cv_t<T>;
732 };
733
734 template<typename T>
735 struct deref_type_impl<std::unique_ptr<T>> {
736 using type = std::remove_cv_t<T>;
737 };
738
739 template<typename T>
740 struct deref_type_impl<std::optional<T>> {
741 using type = std::remove_cv_t<T>;
742 };
743 } // namespace deref_t_impl
744 template<typename T>
746
747 template<typename T>
749 daw::not_trait<std::is_same<dereferenced_t<T>,
751
752 template<typename T>
754
755 namespace unwrapped_impl {
756 template<typename T>
758 std::conditional_t<is_dereferenceable_v<T>, dereferenced_t<T>, T>;
759 }
760
761 template<typename T, JsonNullable Nullable>
763 typename std::conditional_t<is_nullable_json_value_v<Nullable>,
765 } // namespace json_details
766 } // namespace DAW_JSON_VER
767} // namespace daw::json
Iterator & it
Definition: daw_json_traits.h:251
DAW_TYPEOF(*std::declval< T >()) deref_type_detect
Definition: daw_json_traits.h:721
void unable_to_dereference
Definition: daw_json_traits.h:718
decltype(std::data(std::declval< T >())) has_data_test
Definition: daw_json_traits.h:520
decltype(std::size(std::declval< T >())) has_size_test
Definition: daw_json_traits.h:523
std::conditional_t< is_dereferenceable_v< T >, dereferenced_t< T >, T > unwrapped_t_impl
Definition: daw_json_traits.h:758
daw::is_detected< element_type_t, T > has_element_type
Definition: daw_json_traits.h:656
std::conditional_t< Nullable, std::conditional_t< std::is_invocable_v< Constructor, Args... >, std::conditional_t< std::is_invocable_v< Constructor >, std::invoke_result< Constructor >, traits::identity< nullable_constructor_cannot_be_invoked< Constructor > > >, traits::identity< nullable_constructor_cannot_be_invoked< Constructor, Args... > > >, std::conditional_t< std::is_invocable_v< Constructor, Args... >, std::invoke_result< Constructor, Args... >, traits::identity< constructor_cannot_be_invoked< Constructor, Args... > > > > construction_result
Definition: daw_json_traits.h:98
constexpr bool is_mutable_string
Definition: daw_json_traits.h:569
constexpr bool is_a_json_tagged_variant_v
Definition: daw_json_traits.h:475
constexpr bool is_dereferenceable_v
Definition: daw_json_traits.h:753
decltype(static_cast< bool >(std::declval< T >())) has_op_bool_test
Definition: daw_json_traits.h:37
copy_name_when< JsonMember, NewName, is_no_name_v< JsonMember > > copy_name_when_noname
Definition: daw_json_traits.h:112
typename json_data_contract< T >::exact_class_mapping has_exact_mapping_trait_in_class_map
Definition: daw_json_traits.h:613
std::conditional_t< ParsePolicy::allow_temporarily_mutating_buffer, std::conditional_t< is_mutable_string_v< String >, apply_policy_option_t< ParsePolicy, OptionMutable >, apply_policy_option_t< ParsePolicy, OptionImmutable > >, std::conditional_t<(is_rvalue_string< String > and is_mutable_string_v< String >), apply_policy_option_t< ParsePolicy, OptionMutable >, apply_policy_option_t< ParsePolicy, OptionImmutable > > > apply_mutable_policy
Definition: daw_json_traits.h:590
typename deref_t_impl::deref_type_impl< T >::type dereferenced_t
Definition: daw_json_traits.h:745
std::conjunction< daw::is_detected< is_string_like_impl::has_data_test, T >, daw::is_detected< is_string_like_impl::has_size_test, T > > is_string_view_like
Definition: daw_json_traits.h:528
typename JsonMember::without_name without_name
Definition: daw_json_traits.h:104
daw::is_detected< is_a_json_tagged_variant_test, T > is_a_json_tagged_variant
Definition: daw_json_traits.h:472
typename tuple_elements_pack< T >::type tuple_test
Definition: daw_json_traits.h:706
typename T::i_am_an_ordered_member ordered_member_t
Definition: daw_json_traits.h:457
constexpr bool is_mutable_string_v
Definition: daw_json_traits.h:564
constexpr bool is_json_map_alias_v
Definition: daw_json_traits.h:147
typename json_data_contract< T >::force_aggregate_construction force_aggregate_construction_test
Definition: daw_json_traits.h:152
std::bool_constant< daw::is_detected_v< json_type_t, T > > is_a_json_type
Definition: daw_json_traits.h:446
constexpr bool is_tuple_v
Definition: daw_json_traits.h:714
constexpr auto has_value(T const &v) -> std::enable_if_t< is_readable_v< T >, bool >
Definition: daw_json_traits.h:62
constexpr bool all_json_members_must_exist_v
Definition: daw_json_traits.h:641
typename T::i_am_a_json_type json_type_t
Definition: daw_json_traits.h:442
constexpr bool has_op_star_v
Definition: daw_json_traits.h:47
constexpr bool has_empty_member_v
Definition: daw_json_traits.h:54
constexpr bool is_an_ordered_member_v
Definition: daw_json_traits.h:463
decltype(T::force_aggregate_construction) force_aggregate_construction_test2
Definition: daw_json_traits.h:156
daw::not_trait< std::is_same< dereferenced_t< T >, deref_t_impl::unable_to_dereference< T > > > is_dereferenceable
Definition: daw_json_traits.h:750
constexpr bool is_ref_string
Definition: daw_json_traits.h:576
constexpr bool has_op_bool_v
Definition: daw_json_traits.h:40
typename ParsePolicy::template SetPolicyOptions< Option > apply_policy_option_t
Definition: daw_json_traits.h:556
constexpr bool has_switcher_v
Definition: daw_json_traits.h:162
typename JsonMember::switcher switcher_t
Definition: daw_json_traits.h:159
typename T::element_type element_type_t
Definition: daw_json_traits.h:653
daw::is_detected< ordered_member_t, T > is_an_ordered_member
Definition: daw_json_traits.h:460
constexpr bool is_readable_v
Definition: daw_json_traits.h:58
daw::is_detected< json_details::tuple_test, T > is_tuple
Detect if T follows the tuple protocol.
Definition: daw_json_traits.h:711
typename json_data_contract< T >::constructor json_class_constructor_t_impl
Definition: daw_json_traits.h:512
decltype(decltype(std::declval< json_data_contract_trait_t< T > >)::constructor) has_json_data_constract_constructor_test
Definition: daw_json_traits.h:486
std::conditional_t< Cond, typename JsonMember::template with_name< NewName >, JsonMember > copy_name_when
Definition: daw_json_traits.h:108
decltype(*std::declval< T >()) has_op_star_test
Definition: daw_json_traits.h:44
std::conditional_t< is_zero_terminated_string_v< daw::remove_cvref_t< String > >, apply_policy_option_t< ParsePolicy, Option >, ParsePolicy > apply_zstring_policy_option_t
Definition: daw_json_traits.h:561
decltype(std::declval< T >().empty()) has_empty_member_test
Definition: daw_json_traits.h:51
typename std::conditional_t< is_nullable_json_value_v< Nullable >, unwrapped_impl::unwrapped_t_impl< T >, T > unwrapped_t
Definition: daw_json_traits.h:764
typename json_data_contract_trait_t< T >::i_am_a_json_map_alias json_map_alias_test
Definition: daw_json_traits.h:144
typename json_data_contract_constructor< T >::type json_data_contract_constructor_t
Definition: daw_json_traits.h:501
constexpr bool is_a_json_type_v
Definition: daw_json_traits.h:449
typename T::i_am_a_json_tagged_variant is_a_json_tagged_variant_test
Definition: daw_json_traits.h:468
constexpr bool is_string_view_like_v
Definition: daw_json_traits.h:531
typename json_data_contract< T >::ignore_unknown_members has_ignore_unknown_members_trait_in_class_map
Definition: daw_json_traits.h:617
daw::detected_or_t< Default, json_class_constructor_t_impl, T > json_class_constructor_t
Definition: daw_json_traits.h:516
constexpr bool is_rvalue_string
Definition: daw_json_traits.h:573
constexpr bool is_nullability_compatable_v
Definition: daw_json_traits.h:647
constexpr bool is_empty_pack_v
Definition: daw_json_traits.h:191
typename json_data_contract_trait_t< T >::i_am_a_json_member_list test_valid_json_data_contract_trait_t
Definition: daw_json_traits.h:139
constexpr decltype(auto) get(basic_json_pair< ParseState > const &parse_state)
Definition: daw_json_value.h:49
typename json_data_contract< T >::type json_data_contract_trait_t
Definition: daw_json_traits.h:135
constexpr bool ignore_unknown_members_v
Definition: daw_json_traits.h:621
constexpr bool is_exact_class_mapping_v
Definition: daw_json_traits.h:634
constexpr bool is_zero_terminated_string_v
Definition: daw_json_traits.h:550
std::bool_constant<(sizeof...(Ts)==0)> is_empty_pack
Definition: daw_json_traits.h:188
std::bool_constant< std::disjunction_v< daw::is_detected< json_details::force_aggregate_construction_test, T >, daw::is_detected< json_details::force_aggregate_construction_test2, T > > > force_aggregate_construction
Definition: daw_json_traits.h:176
constexpr bool is_default_constructor_v
Definition: daw_json_traits.h:237
constexpr bool force_aggregate_construction_v
Definition: daw_json_traits.h:179
Definition: daw_from_json.h:22
Definition: daw_from_json.h:22
Definition: daw_json_traits.h:434
Definition: daw_json_traits.h:199
Definition: daw_json_traits.h:608
Definition: daw_json_traits.h:231
Definition: daw_json_traits.h:601
Definition: daw_json_traits.h:667
Definition: daw_json_traits.h:127
std::remove_cv_t< T > type
Definition: daw_json_traits.h:731
daw::detected_or_t< unable_to_dereference< T >, deref_type_detect, T > type
Definition: daw_json_traits.h:726
typename json_data_contract_trait_t< T >::constructor type
Definition: daw_json_traits.h:490
Definition: daw_json_traits.h:351
daw::fwd_pack< Ts... > type
Definition: daw_json_traits.h:691
static constexpr decltype(auto) get(Tuple &&tp)
Definition: daw_json_traits.h:699
typename daw::tuple_element< Idx, type >::type element_t
Definition: daw_json_traits.h:696
Allow tuple like types to be used in json_tuple.
Definition: daw_json_traits.h:672
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.
Definition: version.h:16