libpqxx
basic_connection.hxx
1 
13 #ifndef PQXX_H_BASIC_CONNECTION
14 #define PQXX_H_BASIC_CONNECTION
15 
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/compiler-internal-pre.hxx"
18 
19 #include <cstddef>
20 #include <memory>
21 #include <string>
22 
23 #include "pqxx/connection_base.hxx"
24 
25 
26 namespace pqxx
27 {
28 
30 
41 template<typename CONNECTPOLICY> class basic_connection :
42  public connection_base
43 {
44 public:
46  connection_base(m_policy),
47  m_options(std::string()),
48  m_policy(m_options)
49  { init(); }
50 
53  explicit basic_connection(const std::string &opt) :
54  connection_base(m_policy),
55  m_options(opt),
56  m_policy(m_options)
57  {init();}
58 
60  explicit basic_connection(const char opt[]) :
61  basic_connection(opt ? std::string(opt) : std::string()) {}
62 
63  explicit basic_connection(std::nullptr_t) : basic_connection() {}
64 
65  ~basic_connection() noexcept
66  { close(); }
67 
68  const std::string &options() const noexcept //[t01]
69  {return m_policy.options();}
70 
71 private:
73  std::string m_options;
75  CONNECTPOLICY m_policy;
76 };
77 
78 } // namespace
79 
80 #include "pqxx/compiler-internal-post.hxx"
81 
82 #endif
void init()
Definition: connection_base.cxx:93
basic_connection(const std::string &opt)
Definition: basic_connection.hxx:53
basic_connection(const char opt[])
See: basic_connection(const std::string &opt)
Definition: basic_connection.hxx:60
~basic_connection() noexcept
Definition: basic_connection.hxx:65
basic_connection()
Definition: basic_connection.hxx:45
Base-class template for all libpqxx connection types.
Definition: basic_connection.hxx:41
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:22
const std::string & options() const noexcept
Definition: basic_connection.hxx:68
connection_base abstract base class; represents a connection to a database.
Definition: connection_base.hxx:139
basic_connection(std::nullptr_t)
Definition: basic_connection.hxx:63
STL namespace.
void close() noexcept
Definition: connection_base.cxx:839