libpqxx
prepared_statement.hxx
1 
11 #ifndef PQXX_H_PREPARED_STATEMENT
12 #define PQXX_H_PREPARED_STATEMENT
13 
14 #include "pqxx/compiler-public.hxx"
15 #include "pqxx/compiler-internal-pre.hxx"
16 
17 #include "pqxx/internal/statement_parameters.hxx"
18 
19 #include "pqxx/types.hxx"
20 
21 
22 namespace pqxx
23 {
25 namespace prepare
26 {
28 
30 class PQXX_LIBEXPORT invocation : internal::statement_parameters
31 {
32 public:
33  invocation(transaction_base &, const std::string &statement);
34  invocation &operator=(const invocation &) =delete;
35 
37  result exec() const;
38 
40  bool exists() const;
41 
43  invocation &operator()() { add_param(); return *this; }
44 
46 
49  template<typename T> invocation &operator()(const T &v)
50  { add_param(v, true); return *this; }
51 
53 
57  { add_binary_param(v, true); return *this; }
58 
60 
64  template<typename T> invocation &operator()(const T &v, bool nonnull)
65  { add_param(v, nonnull); return *this; }
66 
68 
72  invocation &operator()(const binarystring &v, bool nonnull)
73  { add_binary_param(v, nonnull); return *this; }
74 
76 
83  template<typename T> invocation &operator()(T *v, bool nonnull=true)
84  { add_param(v, nonnull); return *this; }
85 
87 
91  invocation &operator()(const char *v, bool nonnull=true)
92  { add_param(v, nonnull); return *this; }
93 
94 private:
95  transaction_base &m_home;
96  const std::string m_statement;
97 
98  invocation &setparam(const std::string &, bool nonnull);
99 };
100 
101 
102 namespace internal
103 {
105 struct PQXX_LIBEXPORT prepared_def
106 {
108  std::string definition;
110  bool registered = false;
111 
112  prepared_def() =default;
113  explicit prepared_def(const std::string &);
114 };
115 
116 } // namespace pqxx::prepare::internal
117 } // namespace pqxx::prepare
118 } // namespace pqxx
119 
120 #include "pqxx/compiler-internal-post.hxx"
121 #endif
Binary data corresponding to PostgreSQL&#39;s "BYTEA" binary-string type.
Definition: binarystring.hxx:53
std::string definition
Text of prepared query.
Definition: prepared_statement.hxx:108
invocation & operator()(const T &v)
Pass parameter value.
Definition: prepared_statement.hxx:49
Helper class for passing parameters to, and executing, prepared statements.
Definition: prepared_statement.hxx:30
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:22
invocation & operator()(const char *v, bool nonnull=true)
Pass C-style string parameter, or null if pointer is null.
Definition: prepared_statement.hxx:91
invocation & operator()(const binarystring &v, bool nonnull)
Pass binary parameter value for a BYTEA field.
Definition: prepared_statement.hxx:72
invocation & operator()(const binarystring &v)
Pass binary parameter value for a BYTEA field.
Definition: prepared_statement.hxx:56
Result set containing data returned by a query or command.
Definition: result.hxx:67
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:130
invocation & operator()(const T &v, bool nonnull)
Pass parameter value.
Definition: prepared_statement.hxx:64
Internal representation of a prepared statement definition.
Definition: prepared_statement.hxx:105
invocation & operator()()
Pass null parameter.
Definition: prepared_statement.hxx:43
invocation & operator()(T *v, bool nonnull=true)
Pass C-style parameter string, or null if pointer is null.
Definition: prepared_statement.hxx:83