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