soci-backend.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 
8 #ifndef SOCI_BACKEND_H_INCLUDED
9 #define SOCI_BACKEND_H_INCLUDED
10 
11 #include "soci-config.h"
12 #include "error.h"
13 // std
14 #include <cstddef>
15 #include <map>
16 #include <string>
17 
18 namespace soci
19 {
20 
21 // data types, as seen by the user
23 {
25 };
26 
27 // the enum type for indicator variables
29 
30 class session;
31 
32 namespace details
33 {
34 
35 // data types, as used to describe exchange format
37 {
49 };
50 
51 // type of statement (used for optimizing statement preparation)
53 {
56 };
57 
58 // polymorphic into type backend
59 
61 {
62 public:
65 
66  virtual void define_by_pos(int& position, void* data, exchange_type type) = 0;
67 
68  virtual void pre_fetch() = 0;
69  virtual void post_fetch(bool gotData, bool calledFromFetch, indicator* ind) = 0;
70 
71  virtual void clean_up() = 0;
72 
73 private:
74  // noncopyable
77 };
78 
80 {
81 public:
82 
85 
86  virtual void define_by_pos(int& position, void* data, exchange_type type) = 0;
87 
88  virtual void pre_fetch() = 0;
89  virtual void post_fetch(bool gotData, indicator* ind) = 0;
90 
91  virtual void resize(std::size_t sz) = 0;
92  virtual std::size_t size() = 0;
93 
94  virtual void clean_up() = 0;
95 
96 private:
97  // noncopyable
100 };
101 
102 // polymorphic use type backend
103 
105 {
106 public:
109 
110  virtual void bind_by_pos(int& position, void* data,
111  exchange_type type, bool readOnly) = 0;
112  virtual void bind_by_name(std::string const& name,
113  void* data, exchange_type type, bool readOnly) = 0;
114 
115  virtual void pre_use(indicator const* ind) = 0;
116  virtual void post_use(bool gotData, indicator * ind) = 0;
117 
118  virtual void clean_up() = 0;
119 
120 private:
121  // noncopyable
124 };
125 
127 {
128 public:
131 
132  virtual void bind_by_pos(int& position, void* data, exchange_type type) = 0;
133  virtual void bind_by_name(std::string const& name,
134  void* data, exchange_type type) = 0;
135 
136  virtual void pre_use(indicator const* ind) = 0;
137 
138  virtual std::size_t size() = 0;
139 
140  virtual void clean_up() = 0;
141 
142 private:
143  // noncopyable
146 };
147 
148 // polymorphic statement backend
149 
151 {
152 public:
154  virtual ~statement_backend() {}
155 
156  virtual void alloc() = 0;
157  virtual void clean_up() = 0;
158 
159  virtual void prepare(std::string const& query, statement_type eType) = 0;
160 
162  {
164  ef_no_data
165  };
166 
167  virtual exec_fetch_result execute(int number) = 0;
168  virtual exec_fetch_result fetch(int number) = 0;
169 
170  virtual long long get_affected_rows() = 0;
171  virtual int get_number_of_rows() = 0;
172 
173  virtual std::string rewrite_for_procedure_call(std::string const& query) = 0;
174 
175  virtual int prepare_for_describe() = 0;
176  virtual void describe_column(int colNum, data_type& dtype,
177  std::string& column_name) = 0;
178 
179  virtual standard_into_type_backend* make_into_type_backend() = 0;
180  virtual standard_use_type_backend* make_use_type_backend() = 0;
181  virtual vector_into_type_backend* make_vector_into_type_backend() = 0;
182  virtual vector_use_type_backend* make_vector_use_type_backend() = 0;
183 
184 private:
185  // noncopyable
188 };
189 
190 // polymorphic RowID backend
191 
193 {
194 public:
195  virtual ~rowid_backend() {}
196 };
197 
198 // polymorphic blob backend
199 
201 {
202 public:
204  virtual ~blob_backend() {}
205 
206  virtual std::size_t get_len() = 0;
207  virtual std::size_t read(std::size_t offset, char* buf,
208  std::size_t toRead) = 0;
209  virtual std::size_t write(std::size_t offset, char const* buf,
210  std::size_t toWrite) = 0;
211  virtual std::size_t append(char const* buf, std::size_t toWrite) = 0;
212  virtual void trim(std::size_t newLen) = 0;
213 
214 private:
215  // noncopyable
216  blob_backend(blob_backend const&);
218 };
219 
220 // polymorphic session backend
221 
223 {
224 public:
226  virtual ~session_backend() {}
227 
228  virtual void begin() = 0;
229  virtual void commit() = 0;
230  virtual void rollback() = 0;
231 
232  // At least one of these functions is usually not implemented for any given
233  // backend as RDBMS support either sequences or auto-generated values, so
234  // we don't declare them as pure virtuals to avoid having to define trivial
235  // versions of them in the derived classes. However every backend should
236  // define at least one of them to allow the code using auto-generated values
237  // to work.
238  virtual bool get_next_sequence_value(session&, std::string const&, long&)
239  {
240  return false;
241  }
242  virtual bool get_last_insert_id(session&, std::string const&, long&)
243  {
244  return false;
245  }
246 
247  virtual std::string get_backend_name() const = 0;
248 
249  virtual statement_backend* make_statement_backend() = 0;
250  virtual rowid_backend* make_rowid_backend() = 0;
251  virtual blob_backend* make_blob_backend() = 0;
252 
253 private:
254  // noncopyable
257 };
258 
259 } // namespace details
260 
261 // simple base class for the session back-end factory
262 
264 
266 {
267 public:
269  virtual ~backend_factory() {}
270 
271  virtual details::session_backend* make_session(
272  connection_parameters const& parameters) const = 0;
273 };
274 
275 } // namespace soci
276 
277 #endif // SOCI_BACKEND_H_INCLUDED
virtual bool get_last_insert_id(session &, std::string const &, long &)
Definition: soci-backend.h:242
virtual void post_fetch(bool gotData, bool calledFromFetch, indicator *ind)=0
#define SOCI_DECL
Definition: soci-config.h:31
standard_into_type_backend & operator=(standard_into_type_backend const &)
std::vector< ISM::CombinatorialTrainerParameters > parameters
virtual bool get_next_sequence_value(session &, std::string const &, long &)
Definition: soci-backend.h:238
virtual ~backend_factory()
Definition: soci-backend.h:269
virtual void define_by_pos(int &position, void *data, exchange_type type)=0


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:41