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 static DAW_CONSTEVAL T
const *data( ) {
71 static DAW_CONSTEVAL std::size_t size( ) {
89 template<
typename... JsonMembers,
typename OutputIterator,
91 typename Tuple,
typename Value>
93 OutputIterator, SerializationOptions>
96 Tuple
const &args, Value
const &value, std::index_sequence<Is...> ) {
102 daw::constant<
sizeof...( JsonMembers ) +
103 (
static_cast<std::size_t
>(
104 has_dependent_member_v<JsonMembers> ) +
106 auto visited_members =
107 basic_array_t<daw::string_view, visit_size::value>{ };
113 bool is_first =
true;
116 (void)visited_members;
119 using Names = daw::fwd_pack<JsonMembers...>;
120 daw::empty_t
const expander[]{
121 ( dependent_member_to_json_str<
123 daw::traits::nth_element<Is, JsonMembers...>,
124 Names>( is_first, it, args, value, visited_members ),
125 daw::empty_t{ } )...,
132 daw::empty_t
const expander[]{
133 ( to_json_str<Is, daw::traits::nth_element<Is, JsonMembers...>>(
134 is_first, it, args, value, visited_members ),
135 daw::empty_t{ } )...,
140 if constexpr(
sizeof...( Is ) > 0 ) {
142 options::OutputTrailingComma::Yes ) {
151 template<
typename... JsonMembers,
typename OutputIterator,
155 OutputIterator, SerializerOptions>
156 serialize_ordered_json_class(
158 Tuple
const &args, Value
const &value, std::index_sequence<Is...> ) {
163 std::size_t array_idx = 0;
167 daw::empty_t
const expander[]{
168 ( to_json_ordered_str<Is,
169 daw::traits::nth_element<Is, JsonMembers...>>(
170 array_idx,
sizeof...( Is ), it, args ),
171 daw::empty_t{ } )...,
176 if constexpr(
sizeof...( Is ) != 0 ) {
178 options::OutputTrailingComma::Yes ) {