stream_base.hxx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /** Definition of the pqxx::stream_base class.
  2. *
  3. * pqxx::stream_base provides optimized batch access to a database table.
  4. *
  5. * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/stream_base instead.
  6. *
  7. * Copyright (c) 2000-2019, Jeroen T. Vermeulen.
  8. *
  9. * See COPYING for copyright license. If you did not receive a file called
  10. * COPYING with this source code, please notify the distributor of this mistake,
  11. * or contact the author.
  12. */
  13. #ifndef PQXX_H_STREAM_BASE
  14. #define PQXX_H_STREAM_BASE
  15. #include "pqxx/compiler-public.hxx"
  16. #include "pqxx/compiler-internal-pre.hxx"
  17. #include "pqxx/transaction_base.hxx"
  18. #include "pqxx/util.hxx"
  19. #include <string>
  20. namespace pqxx
  21. {
  22. class PQXX_LIBEXPORT PQXX_NOVTABLE stream_base :
  23. public internal::transactionfocus
  24. {
  25. public:
  26. explicit stream_base(transaction_base &);
  27. // TODO: Can we get rid of the vtable?
  28. virtual ~stream_base() noexcept =default;
  29. virtual void complete() = 0;
  30. operator bool() const noexcept;
  31. bool operator!() const noexcept;
  32. protected:
  33. bool m_finished;
  34. virtual void close();
  35. template<typename C> static std::string columnlist(const C &);
  36. template<typename I> static std::string columnlist(I begin, I end);
  37. private:
  38. stream_base();
  39. stream_base(const stream_base&);
  40. stream_base & operator=(const stream_base &);
  41. };
  42. template<typename C> std::string stream_base::columnlist(const C &c)
  43. {
  44. return columnlist(std::begin(c), std::end(c));
  45. }
  46. template<typename I> std::string stream_base::columnlist(I begin, I end)
  47. {
  48. return separated_list(",", begin, end);
  49. }
  50. } // namespace pqxx
  51. #include "pqxx/compiler-internal-post.hxx"
  52. #endif