soci-firebird.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton, Rafal Bobrowski
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 
9 #ifndef SOCI_FIREBIRD_H_INCLUDED
10 #define SOCI_FIREBIRD_H_INCLUDED
11 
12 #ifdef _WIN32
13 # ifdef SOCI_DLL
14 # ifdef SOCI_FIREBIRD_SOURCE
15 # define SOCI_FIREBIRD_DECL __declspec(dllexport)
16 # else
17 # define SOCI_FIREBIRD_DECL __declspec(dllimport)
18 # endif // SOCI_DLL
19 # endif // SOCI_FIREBIRD_SOURCE
20 #endif // _WIN32
21 
22 //
23 // If SOCI_FIREBIRD_DECL isn't defined yet define it now
24 #ifndef SOCI_FIREBIRD_DECL
25 # define SOCI_FIREBIRD_DECL
26 #endif
27 
28 #ifdef _WIN32
29 #include <ciso646> // To understand and/or/not on MSVC9
30 #endif
31 #include <soci-backend.h>
32 #include <ibase.h> // FireBird
33 #include <cstdlib>
34 #include <vector>
35 #include <string>
36 
37 namespace soci
38 {
39 
40 std::size_t const stat_size = 20;
41 
42 // size of buffer for error messages. All examples use this value.
43 // Anyone knows, where it is stated that 512 bytes is enough ?
44 std::size_t const SOCI_FIREBIRD_ERRMSG = 512;
45 
47 {
48 public:
49  firebird_soci_error(std::string const & msg,
50  ISC_STATUS const * status = 0);
51 
52  ~firebird_soci_error() throw() {};
53 
54  std::vector<ISC_STATUS> status_;
55 };
56 
58 {
60 };
61 
64 {
66  : statement_(st), buf_(NULL)
67  {}
68 
69  virtual void define_by_pos(int &position,
70  void *data, details::exchange_type type);
71 
72  virtual void pre_fetch();
73  virtual void post_fetch(bool gotData, bool calledFromFetch,
74  indicator *ind);
75 
76  virtual void clean_up();
77 
79  virtual void exchangeData();
80 
81  void *data_;
83  int position_;
84 
85  char *buf_;
87 };
88 
90 {
92  : statement_(st), buf_(NULL)
93  {}
94 
95  virtual void define_by_pos(int &position,
96  void *data, details::exchange_type type);
97 
98  virtual void pre_fetch();
99  virtual void post_fetch(bool gotData, indicator *ind);
100 
101  virtual void resize(std::size_t sz);
102  virtual std::size_t size();
103 
104  virtual void clean_up();
105 
107  virtual void exchangeData(std::size_t row);
108 
109  void *data_;
112 
113  char *buf_;
115 };
116 
118 {
120  : statement_(st), buf_(NULL), indISCHolder_(0)
121  {}
122 
123  virtual void bind_by_pos(int &position,
124  void *data, details::exchange_type type, bool readOnly);
125  virtual void bind_by_name(std::string const &name,
126  void *data, details::exchange_type type, bool readOnly);
127 
128  virtual void pre_use(indicator const *ind);
129  virtual void post_use(bool gotData, indicator *ind);
130 
131  virtual void clean_up();
132 
134  virtual void exchangeData();
135 
136  void *data_;
139 
140  char *buf_;
142 };
143 
145 {
147  : statement_(st), inds_(NULL), buf_(NULL), indISCHolder_(0)
148  {}
149 
150  virtual void bind_by_pos(int &position,
151  void *data, details::exchange_type type);
152  virtual void bind_by_name(std::string const &name,
153  void *data, details::exchange_type type);
154 
155  virtual void pre_use(indicator const *ind);
156 
157  virtual std::size_t size();
158 
159  virtual void clean_up();
160 
162  virtual void exchangeData(std::size_t row);
163 
164  void *data_;
167  indicator const *inds_;
168 
169  char *buf_;
171 };
172 
175 {
177 
178  virtual void alloc();
179  virtual void clean_up();
180  virtual void prepare(std::string const &query,
182 
183  virtual exec_fetch_result execute(int number);
184  virtual exec_fetch_result fetch(int number);
185 
186  virtual long long get_affected_rows();
187  virtual int get_number_of_rows();
188 
189  virtual std::string rewrite_for_procedure_call(std::string const &query);
190 
191  virtual int prepare_for_describe();
192  virtual void describe_column(int colNum, data_type &dtype,
193  std::string &columnName);
194 
195  virtual firebird_standard_into_type_backend * make_into_type_backend();
196  virtual firebird_standard_use_type_backend * make_use_type_backend();
197  virtual firebird_vector_into_type_backend * make_vector_into_type_backend();
198  virtual firebird_vector_use_type_backend * make_vector_use_type_backend();
199 
201 
202  isc_stmt_handle stmtp_;
203  XSQLDA * sqldap_;
204  XSQLDA * sqlda2p_;
205 
208 
213 
214 protected:
217 
218  long long rowsAffectedBulk_; // number of rows affected by the last bulk operation
219 
220  virtual void exchangeData(bool gotData, int row);
221  virtual void prepareSQLDA(XSQLDA ** sqldap, int size = 10);
222  virtual void rewriteQuery(std::string const & query,
223  std::vector<char> & buffer);
224  virtual void rewriteParameters(std::string const & src,
225  std::vector<char> & dst);
226 
229 
230  std::vector<std::vector<indicator> > inds_;
231  std::vector<void*> intos_;
232  std::vector<void*> uses_;
233 
234  // named parameters
235  std::map <std::string, int> names_;
236 
238 };
239 
241 {
243 
245 };
246 
248 {
250 
252 
253  virtual std::size_t get_len();
254  virtual std::size_t read(std::size_t offset, char *buf,
255  std::size_t toRead);
256  virtual std::size_t write(std::size_t offset, char const *buf,
257  std::size_t toWrite);
258  virtual std::size_t append(char const *buf, std::size_t toWrite);
259  virtual void trim(std::size_t newLen);
260 
262 
263  virtual void save();
264  virtual void assign(ISC_QUAD const & bid)
265  {
266  cleanUp();
267 
268  bid_ = bid;
269  from_db_ = true;
270  }
271 
272  // BLOB id from in database
273  ISC_QUAD bid_;
274 
275  // BLOB id was fetched from database (true)
276  // or this is new BLOB
277  bool from_db_;
278 
279  // BLOB handle
280  isc_blob_handle bhp_;
281 
282 protected:
283 
284  virtual void open();
285  virtual long getBLOBInfo();
286  virtual void load();
287  virtual void writeBuffer(std::size_t offset, char const * buf,
288  std::size_t toWrite);
289  virtual void cleanUp();
290 
291  // buffer for BLOB data
292  std::vector<char> data_;
293 
294  bool loaded_;
296 };
297 
299 {
301 
303 
304  virtual void begin();
305  virtual void commit();
306  virtual void rollback();
307 
308  virtual bool get_next_sequence_value(session & s,
309  std::string const & sequence, long & value);
310 
311  virtual std::string get_backend_name() const { return "firebird"; }
312 
313  void cleanUp();
314 
315  virtual firebird_statement_backend * make_statement_backend();
316  virtual firebird_rowid_backend * make_rowid_backend();
317  virtual firebird_blob_backend * make_blob_backend();
318 
319  virtual void setDPBOption(int const option, std::string const & value);
320 
321  bool get_option_decimals_as_strings() { return decimals_as_strings_; }
322 
323  isc_db_handle dbhp_;
324  isc_tr_handle trhp_;
325  std::string dpb_;
327 };
328 
330 {
332  virtual firebird_session_backend * make_session(
333  connection_parameters const & parameters) const;
334 };
335 
337 
338 extern "C"
339 {
340 
341 // for dynamic backend loading
344 
345 } // extern "C"
346 
347 } // namespace soci
348 
349 #endif // SOCI_FIREBIRD_H_INCLUDED
std::vector< void * > uses_
virtual void assign(ISC_QUAD const &bid)
firebird_standard_into_type_backend(firebird_statement_backend &st)
Definition: soci-firebird.h:65
SOCI_FIREBIRD_DECL backend_factory const * factory_firebird()
std::vector< char > data_
Definition: row.h:41
firebird_vector_into_type_backend(firebird_statement_backend &st)
Definition: soci-firebird.h:91
virtual std::string get_backend_name() const
firebird_session_backend & session_
SOCI_FIREBIRD_DECL void register_factory_firebird()
std::vector< void * > intos_
firebird_statement_backend & statement_
std::size_t const stat_size
Definition: soci-firebird.h:40
SOCI_FIREBIRD_DECL firebird_backend_factory const firebird
#define SOCI_FIREBIRD_DECL
Definition: soci-firebird.h:25
firebird_statement_backend & statement_
std::size_t const SOCI_FIREBIRD_ERRMSG
Definition: soci-firebird.h:44
firebird_session_backend & session_
std::map< std::string, int > names_
firebird_statement_backend & statement_
Definition: soci-firebird.h:78
std::vector< ISM::CombinatorialTrainerParameters > parameters
firebird_standard_use_type_backend(firebird_statement_backend &st)
std::vector< std::vector< indicator > > inds_
firebird_statement_backend & statement_
firebird_vector_use_type_backend(firebird_statement_backend &st)


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