13 #ifndef PQXX_H_STREAM_FROM
14 #define PQXX_H_STREAM_FROM
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/compiler-internal-pre.hxx"
18 #include "pqxx/transaction_base.hxx"
19 #include "pqxx/stream_base.hxx"
20 #include "pqxx/internal/type_utils.hxx"
34 const std::string &table_name
38 const std::string &table_name,
39 const Columns& columns
43 const std::string &table_name,
50 void complete()
override;
52 bool get_raw_line(std::string &);
53 template<
typename Tuple>
stream_from & operator>>(Tuple &);
56 internal::encoding_group m_copy_encoding;
57 std::string m_current_line;
63 const std::string &table_name,
64 const std::string &columns
67 void close()
override;
71 std::string::size_type &,
75 template<
typename Tuple, std::
size_t I>
auto tokenize_ith(
78 std::string::size_type,
80 )
const ->
typename std::enable_if<(
81 std::tuple_size<Tuple>::value > I
83 template<
typename Tuple, std::
size_t I>
auto tokenize_ith(
86 std::string::size_type,
88 )
const ->
typename std::enable_if<(
89 std::tuple_size<Tuple>::value <= I
92 template<
typename T>
void extract_value(
93 const std::string &line,
95 std::string::size_type &here,
96 std::string &workspace
103 const std::string &table_name,
104 const Columns& columns
115 const std::string &table_name,
119 namedclass{
"stream_from", table_name},
125 columnlist(columns_begin, columns_end)
136 std::string workspace;
139 tokenize_ith<Tuple, 0>(m_current_line, t, 0, workspace);
140 m_retry_line =
false;
152 template<
typename Tuple, std::
size_t I>
auto stream_from::tokenize_ith(
153 const std::string &line,
155 std::string::size_type here,
156 std::string &workspace
157 )
const ->
typename std::enable_if<(
158 std::tuple_size<Tuple>::value > I
161 if (here >= line.size())
162 throw usage_error{
"Too few fields to extract from stream_from line."};
164 extract_value(line, std::get<I>(t), here, workspace);
165 tokenize_ith<Tuple, I+1>(line, t, here, workspace);
169 template<
typename Tuple, std::
size_t I>
auto stream_from::tokenize_ith(
170 const std::string &line,
172 std::string::size_type here,
174 )
const ->
typename std::enable_if<(
175 std::tuple_size<Tuple>::value <= I
180 here < line.size() and
181 not (here == line.size() - 1 and line[here] ==
'\n'))
182 throw usage_error{
"Not all fields extracted from stream_from line"};
186 template<
typename T>
void stream_from::extract_value(
187 const std::string &line,
189 std::string::size_type &here,
190 std::string &workspace
193 if (extract_field(line, here, workspace))
194 from_string<T>(workspace, t);
196 t = internal::null_value<T>();
199 template<>
void stream_from::extract_value<std::nullptr_t>(
200 const std::string &line,
202 std::string::size_type &here,
203 std::string &workspace
209 #include "pqxx/compiler-internal-post.hxx"