13#include <daw/daw_enable_requires.h>
14#include <daw/daw_traits.h>
16#if not __has_include( <boost/describe.hpp> ) and __has_include( <boost/mp11.hpp> )
18 "In order to use daw_json_link_describe.h Boost.Describe and Boost.Mp11 must be available"
21#include <boost/describe.hpp>
22#include <boost/mp11.hpp>
32 template<
typename,
typename =
void>
35 namespace describe_impl {
36 template<
typename,
typename>
37 struct describe_member_impl;
41 template<
typename T, std::size_t... Is>
42 struct describe_member_impl<T,
std::index_sequence<Is...>> {
43 static constexpr char const name[
sizeof...( Is )]{ T::name[Is]... };
46 daw::traits::member_type_of_t<DAW_TYPEOF( T::pointer )>>;
50 using describe_member =
51 describe_member_impl<T, std::make_index_sequence<
52 std::char_traits<char>::length( T::name ) + 1>>;
57 template<
template<
typename...>
typename List,
typename... Ts>
58 struct member_list<List<Ts...>> {
60 using desc_t =
typename describe_member<U>::type;
68 and use_boost_describe_v<T> )
72 boost::describe::describe_members<T, boost::describe::mod_public>;
74 boost::describe::describe_members<T, boost::describe::mod_private>;
76 boost::describe::describe_members<T, boost::describe::mod_protected>;
77 static_assert( boost::mp11::mp_empty<pri_desc_t>::value,
78 "Classes with private member variables are not supported. "
79 "Must use a manual mapping." );
80 static_assert( boost::mp11::mp_empty<pro_desc_t>::value,
81 "Classes with protected member variables are not supported. "
82 "Must use a manual mapping." );
85 using desc_t =
typename describe_impl::describe_member<U>::type;
87 template<
template<
typename...>
typename List,
typename... Ts>
88 static constexpr auto to_json_data_impl( T
const &value,
89 List<Ts...>
const & )
noexcept {
90 return std::forward_as_tuple( value.*Ts::pointer... );
94 using type =
typename describe_impl::member_list<pub_desc_t>::type;
96 static constexpr auto to_json_data( T
const &value )
noexcept {
97 return to_json_data_impl( value, pub_desc_t{ } );
typename json_details::ensure_mapped_t< json_details::json_deduced_type< T > >::template with_name< Name > json_link
Deduce the json type mapping based on common types and types already mapped.
string_writer grows its string with resize_and_overwrite, leaving the new bytes uninitialized,...
DAW_REQUIRES(boost::describe::has_describe_members< T >::value and use_boost_describe_v< T >) struct json_data_contract< T >
constexpr bool use_boost_describe_v
Types that use Boost.Describe need to specialize use_boost_describe_v for their type with a bool valu...
Mapping class for JSON data structures to C++. It must be specialized in order to parse to a user cla...