libpqxx
stream_base.hxx
1 
13 #ifndef PQXX_H_STREAM_BASE
14 #define PQXX_H_STREAM_BASE
15 
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/compiler-internal-pre.hxx"
18 #include "pqxx/transaction_base.hxx"
19 #include "pqxx/util.hxx"
20 
21 #include <string>
22 
23 
24 namespace pqxx
25 {
26 
27 class PQXX_LIBEXPORT PQXX_NOVTABLE stream_base :
29 {
30 public:
31  explicit stream_base(transaction_base &);
32  // TODO: Can we get rid of the vtable?
33  virtual ~stream_base() noexcept =default;
34  virtual void complete() = 0;
35  operator bool() const noexcept;
36  bool operator!() const noexcept;
37 protected:
38  bool m_finished;
39  virtual void close();
40  template<typename C> static std::string columnlist(const C &);
41  template<typename I> static std::string columnlist(I begin, I end);
42 private:
43  stream_base();
44  stream_base(const stream_base&);
45  stream_base & operator=(const stream_base &);
46 };
47 
48 template<typename C> std::string stream_base::columnlist(const C &c)
49 {
50  return columnlist(std::begin(c), std::end(c));
51 }
52 
53 template<typename I> std::string stream_base::columnlist(I begin, I end)
54 {
55  return separated_list(",", begin, end);
56 }
57 
58 } // namespace pqxx
59 
60 
61 #include "pqxx/compiler-internal-post.hxx"
62 #endif
Definition: transaction_base.hxx:43
Definition: stream_base.hxx:27
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:136
static std::string columnlist(const C &)
Definition: stream_base.hxx:48
std::string separated_list(const std::string &sep, ITER begin, ITER end, ACCESS access)
Represent sequence of values as a string, joined by a given separator.
Definition: util.hxx:95
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
bool m_finished
Definition: stream_base.hxx:38