OpenM++ runtime library (libopenm)
dbExec.h
Go to the documentation of this file.
1 
5 // Copyright (c) 2013-2015 OpenM++
6 // This code is licensed under the MIT license (see LICENSE.txt for details)
7 
8 #ifndef DB_EXEC_H
9 #define DB_EXEC_H
10 
11 #include <mutex>
12 using namespace std;
13 
14 #include "libopenm/omLog.h"
15 #include "libopenm/db/dbCommon.h"
16 
17 namespace openm
18 {
20  class IDbExec
21  {
22  public:
24  virtual ~IDbExec(void) noexcept = 0;
25 
31  static IDbExec * create(const string & i_sqlProvider, const string & i_connectionStr);
32 
41  virtual int selectToInt(const string & i_sql, int i_default) = 0;
42 
51  virtual long long selectToLong(const string & i_sql, long long i_default) = 0;
52 
60  virtual string selectToStr(const string & i_sql) = 0;
61 
69  virtual bool selectToBool(const string & i_sql) = 0;
70 
79  virtual double selectToDouble(const string & i_sql, double i_default) = 0;
80 
88  virtual vector<string> selectRowStr(const string & i_sql) = 0;
89 
98  virtual IRowBaseVec selectRowVector(const string & i_sql, const IRowAdapter & i_adapter) = 0;
99 
108  virtual IRowBaseList selectRowList(const string & i_sql, const IRowAdapter & i_adapter) = 0;
109 
119  virtual void selectToRowProcessor(const string & i_sql, const IRowAdapter & i_adapter, IRowProcessor & i_processor) = 0;
120 
137  virtual size_t selectColumn(
138  const string & i_sql, int i_column, const type_info & i_type, size_t i_size, void * io_valueArr
139  ) = 0;
140 
148  virtual size_t update(const string & i_sql) = 0;
149 
151  virtual void beginTransaction(void) = 0;
152 
154  virtual unique_lock<recursive_mutex> beginTransactionThreaded(void) = 0;
155 
157  virtual void commit(void) = 0;
158 
160  virtual void rollback(void) = 0;
161 
163  virtual bool isTransaction(void) = 0;
164 
184  virtual void createStatement(const string & i_sql, int i_paramCount, const type_info ** i_typeArr) = 0;
185 
201  virtual void releaseStatement(void) noexcept = 0;
202 
222  virtual void executeStatement(int i_paramCount, const DbValue * i_valueArr) = 0;
223 
225  static list<string> parseListOfProviderNames(const string & i_sqlProviderNames);
226 
228  static bool isValidProviderName(const char * i_sqlProvider);
229 
231  static int maxDbTableNameSize(const string & i_sqlProvider);
232 
234  static string bigIntTypeName(const string & i_sqlProvider);
235 
237  static string floatTypeName(const string & i_sqlProvider);
238 
240  static string textTypeName(const string & i_sqlProvider, int i_size);
241 
243  static string makeSqlBeginTransaction(const string & i_sqlProvider);
244 
246  static string makeSqlCommitTransaction(const string & i_sqlProvider);
247 
262  static string makeSqlCreateTableIfNotExist(
263  const string & i_sqlProvider, const string & i_tableName, const string & i_tableBodySql
264  );
265 
282  static string makeSqlCreateViewReplace(
283  const string & i_sqlProvider, const string & i_viewName, const string & i_viewBodySql
284  );
285 
311  virtual void runSqlScript(const string & i_sqlScript) = 0;
312  };
313 }
314 
315 #endif // DB_EXEC_H
public interafce for row processing during select, ie: select and append to row list ...
Definition: dbCommon.h:180
OpenM++: public interface for log and trace support.
union to pass value to database methods
Definition: dbCommon.h:72
list< IRowBaseUptr > IRowBaseList
db rows: list of unique pointers to db row
Definition: omHelper.h:193
openM++ namespace
Definition: argReader.cpp:16
database connection wrapper to execute sql commands.
Definition: dbExec.h:20
vector< IRowBaseUptr > IRowBaseVec
db rows: vector of unique pointers to db row
Definition: omHelper.h:190
row factory and setter interface to select row from database
Definition: dbCommon.h:44
OpenM++ data library: public interface for db common structures.