libpqxx: prepared_statement.hxx Source File

libpqxx 4.0.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

prepared_statement.hxx
1 /*-------------------------------------------------------------------------
2 *
3 * FILE
4 * pqxx/prepared_statement.hxx
5 *
6 * DESCRIPTION
7 * Helper classes for defining and executing prepared statements
8 * See the connection_base hierarchy for more about prepared statements
9 *
10 * Copyright (c) 2006-2011, Jeroen T. Vermeulen <jtv@xs4all.nl>
11 *
12 * See COPYING for copyright license. If you did not receive a file called
13 * COPYING with this source code, please notify the distributor of this mistake,
14 * or contact the author.
15 *
16 *-------------------------------------------------------------------------
17 */
18 #ifndef PQXX_H_PREPARED_STATEMENT
19 #define PQXX_H_PREPARED_STATEMENT
20
21 #include "pqxx/compiler-public.hxx"
22 #include "pqxx/compiler-internal-pre.hxx"
23
24 #include "pqxx/internal/statement_parameters.hxx"
25
26
27 namespace pqxx
28 {
29 class binarystring;
30 class connection_base;
31 class transaction_base;
32 class result;
33
34
36 namespace prepare
37 {
123
124 class PQXX_LIBEXPORT invocation : internal::statement_parameters
125 {
126 public:
127 invocation(transaction_base &, const PGSTD::string &statement);
128
130 result exec() const;
131
133 bool exists() const;
134
136 invocation &operator()() { add_param(); return *this; }
137
139
142 template<typename T> invocation &operator()(const T &v)
143 { add_param(v, true); return *this; }
144
146
149 invocation &operator()(const binarystring &v)
150 { add_binary_param(v, true); return *this; }
151
153
157 template<typename T> invocation &operator()(const T &v, bool nonnull)
158 { add_param(v, nonnull); return *this; }
159
161
165 invocation &operator()(const binarystring &v, bool nonnull)
166 { add_binary_param(v, nonnull); return *this; }
167
169
187 template<typename T> invocation &operator()(T *v, bool nonnull=true)
188 { add_param(v, nonnull); return *this; }
189
191
195 invocation &operator()(const char *v, bool nonnull=true)
196 { add_param(v, nonnull); return *this; }
197
198 private:
200 invocation &operator=(const invocation &);
201
202 transaction_base &m_home;
203 const PGSTD::string m_statement;
204 PGSTD::vector<PGSTD::string> m_values;
205 PGSTD::vector<bool> m_nonnull;
206
207 invocation &setparam(const PGSTD::string &, bool nonnull);
208 };
209
210
211 namespace internal
212 {
214 struct PQXX_LIBEXPORT prepared_def
215 {
217 PGSTD::string definition;
219 bool registered;
220
221 prepared_def();
222 explicit prepared_def(const PGSTD::string &);
223 };
224
225 } // namespace pqxx::prepare::internal
226 } // namespace pqxx::prepare
227 } // namespace pqxx
228
229 #include "pqxx/compiler-internal-post.hxx"
230
231 #endif
232