18 #include <daw/daw_algorithm.h>
19 #include <daw/daw_character_traits.h>
20 #include <daw/daw_string_view.h>
30 writeable_output_details::is_char_sized_character_v<T> or
31 writeable_output_details::is_byte_type_v<T> )
32 struct writable_output_trait<
34 writeable_output_details::is_char_sized_character_v<T> or
35 writeable_output_details::is_byte_type_v<T> )> : std::true_type {
37 template<
typename... StringViews>
38 static constexpr
void write( T *&ptr, StringViews
const &...svs ) {
39 static_assert(
sizeof...( StringViews ) > 0 );
41 constexpr
auto writer = []( T *&p,
46 p = writeable_output_details::copy_to_buffer( p, sv );
49 ( (void)writer( ptr, svs ), ... );
52 static constexpr
void put( T *&ptr,
char c ) {
54 *ptr =
static_cast<T
>( c );
62 T,
typename T::value_type> )
63 struct writable_output_trait<
65 T, typename T::value_type> )> : std::true_type {
66 using CharT =
typename T::value_type;
68 template<
typename... StringViews>
69 static constexpr
void write( T &out, StringViews
const &...svs ) {
70 static_assert(
sizeof...( StringViews ) > 0 );
72 daw::json::ErrorReason::OutputError );
73 constexpr
auto writer = []( T &s,
78 (void)writeable_output_details::copy_to_buffer( s.data( ), sv );
79 s = s.subspan( sv.size( ) );
82 ( (void)writer( out, svs ), ... );
85 static constexpr
void put( T &out,
char c ) {
87 daw::json::ErrorReason::OutputError );
88 *out.data( ) =
static_cast<CharT
>( c );
89 out.remove_prefix( 1 );
94 template<
typename Container>
96 writeable_output_details::is_string_like_writable_output_v<
97 Container,
typename Container::value_type> )
99 writeable_output_details::is_string_like_writable_output_v<
100 Container, typename Container::value_type> )> : std::true_type {
101 using CharT =
typename Container::value_type;
103 template<
typename... StringViews>
104 static inline void write( Container &out, StringViews
const &...svs ) {
105 static_assert(
sizeof...( StringViews ) > 0 );
106 auto const start_pos = out.size( );
107 auto const total_size = ( std::size( svs ) + ... );
108 out.resize( start_pos + total_size );
110 constexpr
auto writer = []( CharT *&p,
115 p = writeable_output_details::copy_to_buffer( p, sv );
118 auto *ptr = out.data( ) + start_pos;
119 ( (void)writer( ptr, svs ), ... );
122 static inline void put( Container &out,
char c ) {
123 out.push_back(
static_cast<CharT
>( c ) );
130 writeable_output_details::is_writable_output_iterator_v<T> )
132 writeable_output_details::is_writable_output_iterator_v<T> )>
135 template<
typename... StringViews>
136 static constexpr
void write( T &it, StringViews
const &...svs ) {
137 static_assert(
sizeof...( StringViews ) > 0 );
139 constexpr
auto writer = []( T &i,
auto sv )
141 for(
char c : daw::string_view( sv ) ) {
147 ( (void)writer( it, svs ), ... );
150 static constexpr
void put( T &it,
char c ) {
#define daw_json_ensure(Bool,...)
Ensure that Bool is true. If false pass rest of args to daw_json_error.
#define DAW_JSON_ENABLEIF_S(...)
#define DAW_JSON_CPP23_STATIC_CALL_OP
This is in addition to the parse policy. Always do a full name match instead of sometimes relying on ...
Customization point traits.
DAW_JSON_REQUIRES(boost::describe::has_describe_members< T >::value and use_boost_describe_v< T >) struct json_data_contract< T >
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.