27 namespace json_details {
29 template<
typename T, std::
size_t Capacity>
30 struct basic_array_t {
31 static constexpr std::size_t capacity = Capacity;
34 std::size_t position{ };
35 daw::string_view array[capacity]{ };
38 basic_array_t( ) =
default;
40 DAW_ATTRIB_RET_NONNULL
41 constexpr T
const *data( )
const {
45 DAW_ATTRIB_RET_NONNULL
46 constexpr T *data( ) {
50 constexpr std::size_t size( )
const {
54 constexpr void push_back( T
const &v ) {
55 assert( position < capacity );
62 struct basic_array_t<T, 0> {
63 static constexpr std::size_t capacity = 0;
65 basic_array_t( ) =
default;
67 DAW_CONSTEVAL T
const *data( )
const {
71 DAW_CONSTEVAL T *data( ) {
75 DAW_CONSTEVAL std::size_t size( )
const {
93 template<
typename... JsonMembers,
typename OutputIterator,
95 typename Tuple,
typename Value>
97 OutputIterator, SerializationOptions>
100 Tuple
const &args, Value
const &value, std::index_sequence<Is...> ) {
106 daw::constant<
sizeof...( JsonMembers ) +
107 (
static_cast<std::size_t
>(
108 has_dependent_member_v<JsonMembers> ) +
110 auto visited_members =
111 basic_array_t<daw::string_view, visit_size::value>{ };
117 bool is_first =
true;
120 (void)visited_members;
123 using Names = daw::fwd_pack<JsonMembers...>;
124 daw::empty_t
const expander[]{
125 ( dependent_member_to_json_str<
127 daw::traits::nth_element<Is, JsonMembers...>,
128 Names>( is_first, it, args, value, visited_members ),
129 daw::empty_t{ } )...,
136 daw::empty_t
const expander[]{
137 ( to_json_str<Is, daw::traits::nth_element<Is, JsonMembers...>>(
138 is_first, it, args, value, visited_members ),
139 daw::empty_t{ } )...,
144 if constexpr(
sizeof...( Is ) > 0 ) {
146 options::OutputTrailingComma::Yes ) {
155 template<
typename... JsonMembers,
typename OutputIterator,
159 OutputIterator, SerializerOptions>
160 serialize_ordered_json_class(
162 Tuple
const &args, Value
const &value, std::index_sequence<Is...> ) {
167 std::size_t array_idx = 0;
171 daw::empty_t
const expander[]{
172 ( to_json_ordered_str<Is,
173 daw::traits::nth_element<Is, JsonMembers...>>(
174 array_idx,
sizeof...( Is ), it, args ),
175 daw::empty_t{ } )...,
180 if constexpr(
sizeof...( Is ) != 0 ) {
182 options::OutputTrailingComma::Yes ) {