KaliVeda
Toolkit for HIC analysis
KVSQLiteStatement.h
1 
4 /*************************************************************************
5  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TSQLiteStatement
13 #define ROOT_TSQLiteStatement
14 
15 #include "TSQLStatement.h"
16 
17 class sqlite3;
18 class sqlite3_stmt;
19 
20 struct SQLite3_Stmt_t {
21  sqlite3* fConn;
22  sqlite3_stmt* fRes;
23 };
24 
35 
36 private:
37  SQLite3_Stmt_t* fStmt{nullptr};
41 
43  {
44  return fWorkingMode == 1;
45  }
47  {
48  return fWorkingMode == 2;
49  }
50 
51  Bool_t SetSQLParamType(Int_t npar, int sqltype, bool sig, int sqlsize = 0);
52 
53  long double ConvertToNumeric(Int_t npar);
54  const char* ConvertToString(Int_t npar);
55 
56  Bool_t CheckBindError(const char* method, int res);
57 
58 public:
59  KVSQLiteStatement(SQLite3_Stmt_t* stmt, Bool_t errout = kTRUE);
60  virtual ~KVSQLiteStatement();
61 
62  void Close(Option_t* = "") final;
63 
64  Int_t GetBufferLength() const final
65  {
66  return 1;
67  }
68  Int_t GetNumParameters() final;
69 
70  Bool_t SetNull(Int_t npar) final;
71  Bool_t SetInt(Int_t npar, Int_t value) final;
72  Bool_t SetUInt(Int_t npar, UInt_t value) final;
73  Bool_t SetLong(Int_t npar, Long_t value) final;
74  Bool_t SetLong64(Int_t npar, Long64_t value) final;
75  Bool_t SetULong64(Int_t npar, ULong64_t value) final;
76  Bool_t SetDouble(Int_t npar, Double_t value) final;
77  Bool_t SetString(Int_t npar, const char* value, Int_t maxsize = 256) final;
78  Bool_t SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000) final;
79  Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final;
80  Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final;
81  Bool_t SetDatime(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec) final;
83  Bool_t SetTimestamp(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec, Int_t frac = 0) final;
84 
85  Bool_t NextIteration() final;
86 
87  Bool_t Process() final;
88  Int_t GetNumAffectedRows() final;
89 
90  Bool_t StoreResult() final;
91  Int_t GetNumFields() final;
92  const char* GetFieldName(Int_t nfield) final;
93  Bool_t NextResultRow() final;
94 
95  Bool_t IsNull(Int_t npar) final;
96  Int_t GetInt(Int_t npar) final;
97  UInt_t GetUInt(Int_t npar) final;
98  Long_t GetLong(Int_t npar) final;
99  Long64_t GetLong64(Int_t npar) final;
100  ULong64_t GetULong64(Int_t npar) final;
101  Double_t GetDouble(Int_t npar) final;
102  const char* GetString(Int_t npar) final;
103  Bool_t GetBinary(Int_t npar, void*& mem, Long_t& size) final;
104  Bool_t GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day) final;
105  Bool_t GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec) final;
106  Bool_t GetDatime(Int_t npar, Int_t& year, Int_t& month, Int_t& day, Int_t& hour, Int_t& min, Int_t& sec) final;
108  Bool_t GetTimestamp(Int_t npar, Int_t& year, Int_t& month, Int_t& day, Int_t& hour, Int_t& min, Int_t& sec, Int_t&) final;
109 
110  ClassDefOverride(KVSQLiteStatement, 0); // SQL statement class for SQLite DB
111 };
112 
113 #endif
int Int_t
unsigned int UInt_t
long Long_t
bool Bool_t
double Double_t
const char Option_t
Modified copy of TSQLiteStatement.
Bool_t NextIteration() final
Bool_t SetLong(Int_t npar, Long_t value) final
Set parameter value as long.
Bool_t SetSQLParamType(Int_t npar, int sqltype, bool sig, int sqlsize=0)
Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final
Set parameter value as date.
Int_t fIterationCount
Number of bindable / gettable parameters.
Bool_t GetBinary(Int_t npar, void *&mem, Long_t &size) final
Bool_t IsSetParsMode() const
Iteration count.
virtual ~KVSQLiteStatement()
Destructor.
TDatime GetTimestamp(Int_t)
Bool_t SetInt(Int_t npar, Int_t value) final
Set parameter value as integer.
Bool_t GetTime(Int_t npar, Int_t &hour, Int_t &min, Int_t &sec) final
Return field as time.
Bool_t GetDatime(Int_t npar, Int_t &year, Int_t &month, Int_t &day, Int_t &hour, Int_t &min, Int_t &sec) final
Return field value as date & time.
Bool_t SetString(Int_t npar, const char *value, Int_t maxsize=256) final
Set parameter value as string.
Bool_t SetBinary(Int_t npar, void *mem, Long_t size, Long_t maxsize=0x1000) final
Int_t fNumPars
1 - setting parameters, 2 - retrieving results
Bool_t NextResultRow() final
Shift cursor to next row in result set.
const char * GetString(Int_t npar) final
Return field value as string.
ULong64_t GetULong64(Int_t npar) final
Return field value as unsigned 64-bit integer.
Double_t GetDouble(Int_t npar) final
Return field value as double.
const char * GetFieldName(Int_t nfield) final
Returns field name in result set.
const char * ConvertToString(Int_t npar)
Convert field value to string.
Bool_t GetDate(Int_t npar, Int_t &year, Int_t &month, Int_t &day) final
Return field value as date.
Int_t GetNumFields() final
Return number of fields in result set.
Long64_t GetLong64(Int_t npar) final
Get long64.
ClassDefOverride(KVSQLiteStatement, 0)
Bool_t IsResultSetMode() const
Int_t GetBufferLength() const final
Bool_t IsNull(Int_t npar) final
Checks if field value is null.
Bool_t SetULong64(Int_t npar, ULong64_t value) final
Bool_t SetNull(Int_t npar) final
Set NULL as parameter value.
Bool_t StoreResult() final
Int_t GetInt(Int_t npar) final
Get integer.
Bool_t SetLong64(Int_t npar, Long64_t value) final
Set parameter value as 64-bit integer.
Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final
Set parameter value as time.
Int_t fWorkingMode
executed statement
void Close(Option_t *="") final
Close statement.
long double ConvertToNumeric(Int_t npar)
Convert field to numeric.
Bool_t SetDatime(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec) final
Set parameter value as date & time.
Bool_t CheckBindError(const char *method, int res)
Long_t GetLong(Int_t npar) final
Get long.
Int_t GetNumAffectedRows() final
UInt_t GetUInt(Int_t npar) final
Get unsigned integer.
Bool_t SetTimestamp(Int_t, const TDatime &)
Bool_t Process() final
Process statement.
Int_t GetNumParameters() final
Return number of statement parameters.
Bool_t SetUInt(Int_t npar, UInt_t value) final
SQLite3_Stmt_t * fStmt
Bool_t SetDouble(Int_t npar, Double_t value) final
Set parameter value as double value.
KVSQLiteStatement(SQLite3_Stmt_t *stmt, Bool_t errout=kTRUE)
long long Long64_t
unsigned long long ULong64_t
sqlite3_stmt * fRes