13 #ifndef PQXX_H_STREAM_TO
14 #define PQXX_H_STREAM_TO
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/internal/compiler-internal-pre.hxx"
19 #include "pqxx/separated_list.hxx"
20 #include "pqxx/transaction_base.hxx"
29 template<
typename T> std::string
operator()(T
const *t)
const
33 if constexpr (std::is_same_v<T, std::nullptr_t>)
36 return (t ==
nullptr or
is_null(*t)) ?
"\\N" :
89 template<
typename Columns>
94 template<
typename Iter>
101 [[nodiscard]]
operator bool() const noexcept {
return not m_finished; }
102 [[nodiscard]]
bool operator!() const noexcept {
return m_finished; }
131 bool m_finished =
false;
134 void write_raw_line(std::string_view);
139 std::string
const &columns);
143 template<
typename Columns>
145 transaction_base &tb, std::string_view table_name, Columns
const &columns) :
146 stream_to{tb, table_name, std::begin(columns), std::end(columns)}
150 template<
typename Iter>
154 namedclass{
"stream_to", table_name},
157 set_up(tb, table_name,
separated_list(
",", columns_begin, columns_end));
168 #include "pqxx/internal/compiler-internal-post.hxx"
void ignore_unused(T &&)
Suppress compiler warning about an unused item.
Definition: util.hxx:43
void complete()
Complete the operation, and check for errors.
Definition: stream_to.cxx:99
bool is_null(TYPE const &value)
Is value null?
Definition: strconv.hxx:286
std::string copy_string_escape(std::string_view)
Definition: stream_to.cxx:110
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
~stream_to() noexcept
Definition: stream_to.cxx:53
bool get_raw_line(std::string &)
Definition: stream_from.cxx:80
std::string to_string(field const &value)
Convert a field to a string.
Definition: result.cxx:478
Private namespace for libpqxx's internal use; do not access.
Definition: connection.hxx:59
stream_to(transaction_base &, std::string_view table_name)
Create a stream, without specifying columns.
Definition: stream_to.cxx:45
result exec0(std::string const &query, std::string const &desc=std::string{})
Execute query, which should zero rows of data.
Definition: transaction_base.hxx:246
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:97
bool operator!() const noexcept
Definition: stream_to.hxx:102
Efficiently pull data directly out of a table.
Definition: stream_from.hxx:30
std::string operator()(T const *t) const
Definition: stream_to.hxx:29
std::string separated_list(std::string_view sep, ITER begin, ITER end, ACCESS access)
Represent sequence of values as a string, joined by a given separator.
Definition: separated_list.hxx:40
stream_to & operator<<(Tuple const &)
Insert a row of data.
Definition: stream_to.hxx:161
std::basic_ostream< CHAR > & operator<<(std::basic_ostream< CHAR > &s, field const &value)
Write a result field to any type of stream.
Definition: field.hxx:347
Efficiently write data directly to a database table.
Definition: stream_to.hxx:75
Definition: transaction_base.hxx:42
Definition: stream_to.hxx:27