14 #include <daw/daw_empty.h>
15 #include <daw/daw_fwd_pack_apply.h>
16 #include <daw/daw_string_view.h>
17 #include <daw/daw_undefined.h>
18 #include <daw/traits/daw_traits_nth_element.h>
22 #include <daw/stdinc/integer_sequence.h>
26 namespace json_details {
28 template<
typename T, std::
size_t Capacity>
29 struct basic_array_t {
30 static constexpr std::size_t capacity = Capacity;
33 std::size_t position{ };
34 daw::string_view array[capacity]{ };
37 basic_array_t( ) =
default;
39 DAW_ATTRIB_RET_NONNULL
40 constexpr T
const *data( )
const {
44 DAW_ATTRIB_RET_NONNULL
45 constexpr T *data( ) {
49 constexpr std::size_t size( )
const {
53 constexpr
void push_back( T
const &v ) {
54 assert( position < capacity );
61 struct basic_array_t<T, 0> {
62 static constexpr std::size_t capacity = 0;
64 basic_array_t( ) =
default;
66 DAW_CONSTEVAL T
const *data( )
const {
70 DAW_CONSTEVAL T *data( ) {
74 DAW_CONSTEVAL std::size_t size( )
const {
92 template<
typename... JsonMembers,
typename OutputIterator,
94 typename Tuple,
typename Value>
96 OutputIterator, SerializationOptions>
99 Tuple
const &args, Value
const &value, std::index_sequence<Is...> ) {
104 constexpr
auto visit_size =
105 sizeof...( JsonMembers ) +
106 (
static_cast<std::size_t
>( has_dependent_member_v<JsonMembers> ) +
108 auto visited_members = basic_array_t<daw::string_view, visit_size>{ };
114 bool is_first =
true;
117 (void)visited_members;
120 using Names = daw::fwd_pack<JsonMembers...>;
121 daw::empty_t
const expander[]{
122 ( dependent_member_to_json_str<
123 Is, daw::traits::nth_element<Is, JsonMembers...>, Names>(
124 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 ) {
std::uint32_t json_options_t
Customization point traits.
constexpr DAW_ATTRIB_INLINE void del_indent()
static constexpr options::OutputTrailingComma output_trailing_comma
constexpr DAW_ATTRIB_INLINE void add_indent()
constexpr DAW_ATTRIB_INLINE void next_member()
constexpr void put(char c)
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.