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 ) {