soci-sqlite3.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton, David Courtney
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_SQLITE3_H_INCLUDED
9 #define SOCI_SQLITE3_H_INCLUDED
10 
11 #ifdef _WIN32
12 # ifdef SOCI_DLL
13 # ifdef SOCI_SQLITE3_SOURCE
14 # define SOCI_SQLITE3_DECL __declspec(dllexport)
15 # else
16 # define SOCI_SQLITE3_DECL __declspec(dllimport)
17 # endif // SOCI_SQLITE3_SOURCE
18 # endif // SOCI_DLL
19 #endif // _WIN32
20 //
21 // If SOCI_SQLITE3_DECL isn't defined yet define it now
22 #ifndef SOCI_SQLITE3_DECL
23 # define SOCI_SQLITE3_DECL
24 #endif
25 
26 #include <cstdarg>
27 #include <vector>
28 #include "soci-backend.h"
29 
30 // Disable flood of nonsense warnings generated for SQLite
31 #ifdef _MSC_VER
32 #pragma warning(push)
33 #pragma warning(disable:4510 4512 4610)
34 #endif
35 
36 namespace sqlite_api
37 {
38 
39 #if SQLITE_VERSION_NUMBER < 3003010
40 // The sqlite3_destructor_type typedef introduced in 3.3.10
41 // http://www.sqlite.org/cvstrac/tktview?tn=2191
42 typedef void (*sqlite3_destructor_type)(void*);
43 #endif
44 
45 #include <sqlite3.h>
46 
47 } // namespace sqlite_api
48 
49 #undef SQLITE_STATIC
50 #define SQLITE_STATIC ((sqlite_api::sqlite3_destructor_type)0)
51 
52 #ifdef _MSC_VER
53 #pragma warning(pop)
54 #endif
55 
56 namespace soci
57 {
58 
60 {
61 public:
62  sqlite3_soci_error(std::string const & msg, int result);
63 
64  int result() const;
65 
66 private:
67  int result_;
68 };
69 
72 {
74  : statement_(st) {}
75 
76  virtual void define_by_pos(int &position,
77  void *data, details::exchange_type type);
78 
79  virtual void pre_fetch();
80  virtual void post_fetch(bool gotData, bool calledFromFetch,
81  indicator *ind);
82 
83  virtual void clean_up();
84 
86 
87  void *data_;
89  int position_;
90 };
91 
93 {
95  : statement_(st) {}
96 
97  void define_by_pos(int& position, void* data, details::exchange_type type);
98 
99  void pre_fetch();
100  void post_fetch(bool gotData, indicator* ind);
101 
102  void resize(std::size_t sz);
103  std::size_t size();
104 
105  virtual void clean_up();
106 
108 
109  void *data_;
112 };
113 
115 {
117  : statement_(st), buf_(0) {}
118 
119  virtual void bind_by_pos(int &position,
120  void *data, details::exchange_type type, bool readOnly);
121  virtual void bind_by_name(std::string const &name,
122  void *data, details::exchange_type type, bool readOnly);
123 
124  virtual void pre_use(indicator const *ind);
125  virtual void post_use(bool gotData, indicator *ind);
126 
127  virtual void clean_up();
128 
130 
131  void *data_;
134  std::string name_;
135  char *buf_;
136 };
137 
139 {
141  : statement_(st) {}
142 
143  virtual void bind_by_pos(int &position,
144  void *data, details::exchange_type type);
145  virtual void bind_by_name(std::string const &name,
146  void *data, details::exchange_type type);
147 
148  virtual void pre_use(indicator const *ind);
149 
150  virtual std::size_t size();
151 
152  virtual void clean_up();
153 
155 
156  void *data_;
159  std::string name_;
160 };
161 
163 {
164  std::string data_;
165  bool isNull_;
166  char * blobBuf_;
167  std::size_t blobSize_;
168 };
169 
170 typedef std::vector<sqlite3_column> sqlite3_row;
171 typedef std::vector<sqlite3_row> sqlite3_recordset;
172 
175 {
177 
178  virtual void alloc();
179  virtual void clean_up();
180  virtual void prepare(std::string const &query,
182  void reset_if_needed();
183 
184  virtual exec_fetch_result execute(int number);
185  virtual exec_fetch_result fetch(int number);
186 
187  virtual long long get_affected_rows();
188  virtual int get_number_of_rows();
189 
190  virtual std::string rewrite_for_procedure_call(std::string const &query);
191 
192  virtual int prepare_for_describe();
193  virtual void describe_column(int colNum, data_type &dtype,
194  std::string &columnName);
195 
196  virtual sqlite3_standard_into_type_backend * make_into_type_backend();
197  virtual sqlite3_standard_use_type_backend * make_use_type_backend();
198  virtual sqlite3_vector_into_type_backend * make_vector_into_type_backend();
199  virtual sqlite3_vector_use_type_backend * make_vector_use_type_backend();
200 
202  sqlite_api::sqlite3_stmt *stmt_;
203  sqlite3_recordset dataCache_;
204  sqlite3_recordset useData_;
208 
209  long long rowsAffectedBulk_; // number of rows affected by the last bulk operation
210 
211 private:
212  exec_fetch_result load_rowset(int totalRows);
213  exec_fetch_result load_one();
214  exec_fetch_result bind_and_execute(int number);
215 };
216 
218 {
220 
222 
223  unsigned long value_;
224 };
225 
227 {
229 
231 
232  virtual std::size_t get_len();
233  virtual std::size_t read(std::size_t offset, char *buf,
234  std::size_t toRead);
235  virtual std::size_t write(std::size_t offset, char const *buf,
236  std::size_t toWrite);
237  virtual std::size_t append(char const *buf, std::size_t toWrite);
238  virtual void trim(std::size_t newLen);
239 
241 
242  std::size_t set_data(char const *buf, std::size_t toWrite);
243 
244 private:
245  char *buf_;
246  size_t len_;
247 };
248 
250 {
252 
254 
255  virtual void begin();
256  virtual void commit();
257  virtual void rollback();
258 
259  virtual std::string get_backend_name() const { return "sqlite3"; }
260 
261  void clean_up();
262 
263  virtual sqlite3_statement_backend * make_statement_backend();
264  virtual sqlite3_rowid_backend * make_rowid_backend();
265  virtual sqlite3_blob_backend * make_blob_backend();
266 
268 };
269 
271 {
273  virtual sqlite3_session_backend * make_session(
274  connection_parameters const & parameters) const;
275 };
276 
278 
279 extern "C"
280 {
281 
282 // for dynamic backend loading
285 
286 } // extern "C"
287 
288 } // namespace soci
289 
290 #endif // SOCI_SQLITE3_H_INCLUDED
sqlite3_session_backend & session_
Definition: soci-sqlite3.h:240
SOCI_SQLITE3_DECL void register_factory_sqlite3()
sqlite3_standard_into_type_backend(sqlite3_statement_backend &st)
Definition: soci-sqlite3.h:73
void(* sqlite3_destructor_type)(void *)
Definition: soci-sqlite3.h:42
sqlite3_statement_backend & statement_
Definition: soci-sqlite3.h:85
sqlite3_statement_backend & statement_
Definition: soci-sqlite3.h:154
SOCI_SQLITE3_DECL sqlite3_backend_factory const sqlite3
std::size_t blobSize_
Definition: soci-sqlite3.h:167
SOCI_SQLITE3_DECL backend_factory const * factory_sqlite3()
sqlite3_standard_use_type_backend(sqlite3_statement_backend &st)
Definition: soci-sqlite3.h:116
sqlite3_vector_use_type_backend(sqlite3_statement_backend &st)
Definition: soci-sqlite3.h:140
sqlite3_statement_backend & statement_
Definition: soci-sqlite3.h:129
std::vector< sqlite3_column > sqlite3_row
Definition: soci-sqlite3.h:170
#define SOCI_SQLITE3_DECL
Definition: soci-sqlite3.h:23
virtual std::string get_backend_name() const
Definition: soci-sqlite3.h:259
sqlite3_vector_into_type_backend(sqlite3_statement_backend &st)
Definition: soci-sqlite3.h:94
sqlite_api::sqlite3_stmt * stmt_
Definition: soci-sqlite3.h:202
sqlite3_session_backend & session_
Definition: soci-sqlite3.h:201
sqlite_api::sqlite3 * conn_
Definition: soci-sqlite3.h:267
std::vector< ISM::CombinatorialTrainerParameters > parameters
std::vector< sqlite3_row > sqlite3_recordset
Definition: soci-sqlite3.h:171
sqlite3_statement_backend & statement_
Definition: soci-sqlite3.h:107


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