19 #ifndef KompexSQLiteStatement_H
20 #define KompexSQLiteStatement_H
63 void SqlStatement(
const char *sqlStatement);
75 void SqlStatement(
const wchar_t *sqlStatement);
80 inline void Sql(
const std::string &sql) {Prepare(sql.c_str());}
84 inline void Sql(
const char *sql) {Prepare(sql);}
88 inline void Sql(
const std::wstring &sql) {Prepare(sql.c_str());}
92 inline void Sql(
const wchar_t *sql) {Prepare(sql);}
96 bool FetchRow()
const;
104 float SqlAggregateFuncResult(
const std::string &countSql);
109 float SqlAggregateFuncResult(
wchar_t *countSql);
114 float SqlAggregateFuncResult(
const char *countSql);
119 const char *GetColumnName(
int column)
const;
123 const char *GetColumnName(
const std::string &column)
const;
128 wchar_t *GetColumnName16(
int column)
const;
132 wchar_t *GetColumnName16(
const std::string &column)
const;
143 int GetColumnType(
int column)
const;
153 int GetColumnType(
const std::string &column)
const;
159 const unsigned char *GetColumnCString(
int column)
const;
164 const unsigned char *GetColumnCString(
const std::string &column)
const;
170 std::string GetColumnString(
int column)
const;
175 std::string GetColumnString(
const std::string &column)
const;
181 wchar_t *GetColumnString16(
int column)
const;
186 wchar_t *GetColumnString16(
const std::string &column)
const;
191 double GetColumnDouble(
int column)
const;
195 double GetColumnDouble(
const std::string &column)
const;
200 int GetColumnInt(
int column)
const;
204 int GetColumnInt(
const std::string &column)
const;
212 bool GetColumnBool(
int column)
const;
219 bool GetColumnBool(
const std::string &column)
const;
224 int64 GetColumnInt64(
int column)
const;
228 int64 GetColumnInt64(
const std::string &column)
const;
233 const void *GetColumnBlob(
int column)
const;
237 const void *GetColumnBlob(
const std::string &column)
const;
242 int GetColumnBytes(
int column)
const;
246 int GetColumnBytes(
const std::string &column)
const;
250 int GetColumnBytes16(
int column)
const;
254 int GetColumnBytes16(
const std::string &column)
const;
259 const char *GetColumnDatabaseName(
int column)
const;
263 const char *GetColumnDatabaseName(
const std::string &column)
const;
267 wchar_t *GetColumnDatabaseName16(
int column)
const;
271 wchar_t *GetColumnDatabaseName16(
const std::string &column)
const;
276 const char *GetColumnTableName(
int column)
const;
280 const char *GetColumnTableName(
const std::string &column)
const;
284 wchar_t *GetColumnTableName16(
int column)
const;
288 wchar_t *GetColumnTableName16(
const std::string &column)
const;
293 const char *GetColumnOriginName(
int column)
const;
297 const char *GetColumnOriginName(
const std::string &column)
const;
301 wchar_t *GetColumnOriginName16(
int column)
const;
305 wchar_t *GetColumnOriginName16(
const std::string &column)
const;
310 const char *GetColumnDeclaredDatatype(
int column)
const;
314 const char *GetColumnDeclaredDatatype(
const std::string &column)
const;
318 wchar_t *GetColumnDeclaredDatatype16(
int column)
const;
322 wchar_t *GetColumnDeclaredDatatype16(
const std::string &column)
const;
326 int GetColumnCount()
const;
329 inline int GetDataCount()
const {
return sqlite3_data_count(mStatement);}
335 void BindInt(
int column,
int value)
const;
340 void BindBool(
int column,
bool value)
const;
345 void BindString(
int column,
const std::string &
string)
const;
350 void BindString16(
int column,
const wchar_t *
string)
const;
357 void BindString64(
int column,
const char *
string,
uint64 byteLength,
ENCODING encoding)
const;
362 void BindDouble(
int column,
double value)
const;
367 void BindInt64(
int column,
int64 value)
const;
371 void BindNull(
int column)
const;
381 void BindBlob(
int column,
const void* data,
int numberOfBytes = -1)
const;
392 void BindBlob64(
int column,
const void* data,
uint64 numberOfBytes = -1)
const;
397 void BindZeroBlob(
int column,
int length)
const;
403 void BindZeroBlob64(
int column,
uint64 length)
const;
410 void Execute()
const;
413 void ExecuteAndFree();
420 void GetTable(
const std::string &sql,
unsigned short consoleOutputColumnWidth = 20)
const;
427 void GetTableColumnMetadata(
const std::string &tableName,
const std::string &columnName)
const;
431 void ClearBindings()
const;
439 void BeginTransaction();
442 void CommitTransaction();
447 SqlStatement(
"ROLLBACK;");
456 inline void Transaction(
const char *sql) {mTransactionSQL[mTransactionID++] = std::make_pair(sql,
false);}
463 inline void Transaction(
const std::string &sql) {mTransactionSQL[mTransactionID++] = std::make_pair(sql.c_str(),
false);}
470 inline void Transaction(
const wchar_t *sql) {mTransactionSQL16[mTransactionID++] = std::make_pair(sql,
false);}
477 void SecureTransaction(
const char *sql);
483 void SecureTransaction(
const std::string sql);
489 void SecureTransaction(
const wchar_t *sql);
494 std::string GetSqlResultString(
const std::string &sql,
const std::string &defaultReturnValue =
"");
498 std::string GetSqlResultString(
const char *sql,
const std::string &defaultReturnValue =
"");
502 std::string GetSqlResultString(
const wchar_t *sql,
const std::string &defaultReturnValue =
"");
507 int GetSqlResultInt(
const std::string &sql,
int defaultReturnValue = -1);
511 int GetSqlResultInt(
const char *sql,
int defaultReturnValue = -1);
515 int GetSqlResultInt(
const wchar_t *sql,
int defaultReturnValue = -1);
520 int64 GetSqlResultInt64(
const std::string &sql,
int64 defaultReturnValue = -1);
524 int64 GetSqlResultInt64(
const char *sql,
int64 defaultReturnValue = -1);
528 int64 GetSqlResultInt64(
const wchar_t *sql,
int64 defaultReturnValue = -1);
533 double GetSqlResultDouble(
const std::string &sql,
double defaultReturnValue = -1);
537 double GetSqlResultDouble(
const char *sql,
double defaultReturnValue = -1);
541 double GetSqlResultDouble(
const wchar_t *sql,
double defaultReturnValue = -1);
551 const unsigned char *GetSqlResultCString(
const std::string &sql,
const unsigned char *defaultReturnValue = 0);
560 const unsigned char *GetSqlResultCString(
const char *sql,
const unsigned char *defaultReturnValue = 0);
569 const unsigned char *GetSqlResultCString(
const wchar_t *sql,
const unsigned char *defaultReturnValue = 0);
579 wchar_t *GetSqlResultString16(
const std::string &sql,
wchar_t *defaultReturnValue = 0);
588 wchar_t *GetSqlResultString16(
const char *sql,
wchar_t *defaultReturnValue = 0);
597 wchar_t *GetSqlResultString16(
const wchar_t *sql,
wchar_t *defaultReturnValue = 0);
607 const void *GetSqlResultBlob(
const std::string &sql,
const void *defaultReturnValue = 0);
616 const void *GetSqlResultBlob(
const char *sql,
const void *defaultReturnValue = 0);
625 const void *GetSqlResultBlob(
const wchar_t *sql,
const void *defaultReturnValue = 0);
631 unsigned int GetNumberOfRows();
649 static std::string Mprintf(
const char *sql, ...);
666 static std::string Vmprintf(
const char *sql, va_list args);
671 void Prepare(
const char *sqlStatement);
674 void Prepare(
const wchar_t *sqlStatement);
678 void CheckStatement()
const;
680 void CheckDatabase()
const;
686 const unsigned char *SqlResultCString(
const unsigned char *defaultReturnValue);
688 wchar_t *SqlResultString16(
wchar_t *defaultReturnValue);
690 const void *SqlResultBlob(
const void *defaultReturnValue);
695 void CheckColumnNumber(
int columnNumber,
const std::string &functionName =
"")
const;
698 void CleanUpTransaction();
714 template<
class S,
class T>
715 T GetColumnValue(S sql, T(
Kompex::SQLiteStatement::*getColumnFunc)(
int columnNumber)
const, T defaultReturnValue);
719 void AssignColumnNumberToColumnName()
const;
721 int GetAssignedColumnNumber(
const std::string &columnName)
const;
749 #endif // KompexSQLiteStatement_H
Execution of SQL statements and result processing.
Definition: KompexSQLiteStatement.h:43
void Sql(const std::wstring &sql)
Definition: KompexSQLiteStatement.h:88
TTransactionSQL16 mTransactionSQL16
Stores UTF-16 transaction statements.
Definition: KompexSQLiteStatement.h:736
struct sqlite3_stmt * mStatement
SQL statement.
Definition: KompexSQLiteStatement.h:724
Definition: KompexSQLiteStatement.h:36
Definition: KompexSQLiteStatement.h:35
int GetDataCount() const
Definition: KompexSQLiteStatement.h:329
TTransactionSQL mTransactionSQL
Stores UTF-8 transaction statements.
Definition: KompexSQLiteStatement.h:734
Definition: KompexSQLiteStatement.h:39
std::map< unsigned short, std::pair< const char *, bool > > TTransactionSQL
typedef for UTF-8 transaction statements
Definition: KompexSQLiteStatement.h:729
void Sql(const wchar_t *sql)
Definition: KompexSQLiteStatement.h:92
Definition: KompexSQLiteStatement.h:37
sqlite3_stmt * GetStatementHandle() const
Returns the SQLite statement handle.
Definition: KompexSQLiteStatement.h:683
ENCODING
Definition: KompexSQLiteStatement.h:33
bool mIsColumnNumberAssignedToColumnName
Saves whether the assignments for every column number and the corresponding column name was already d...
Definition: KompexSQLiteStatement.h:744
unsigned short mTransactionID
ID for transactions.
Definition: KompexSQLiteStatement.h:739
Administration of the database and all concerning settings.
Definition: KompexSQLiteDatabase.h:31
unsigned long long int uint64
Definition: KompexSQLitePrerequisites.h:42
void Transaction(const char *sql)
Definition: KompexSQLiteStatement.h:456
void Sql(const char *sql)
Definition: KompexSQLiteStatement.h:84
long long int int64
Definition: KompexSQLitePrerequisites.h:41
SQLiteDatabase * mDatabase
Database pointer.
Definition: KompexSQLiteStatement.h:726
#define _SQLiteWrapperExport
Definition: KompexSQLitePrerequisites.h:32
Definition: KompexSQLiteStatement.h:38
void DeleteTransactionSqlStr(bool isMemAllocated, T *str)
Definition: KompexSQLiteStatement.h:704
void SqlStatement(const std::wstring &sqlStatement)
Definition: KompexSQLiteStatement.h:69
void Transaction(const std::string &sql)
Definition: KompexSQLiteStatement.h:463
void SqlStatement(const std::string &sqlStatement)
Definition: KompexSQLiteStatement.h:57
void RollbackTransaction()
Rollback a transaction.
Definition: KompexSQLiteStatement.h:444
void Transaction(const wchar_t *sql)
Definition: KompexSQLiteStatement.h:470
std::map< std::string, int > mColumnNumberToColumnNameAssignment
Container which stores the assignments for every column number and the corresponding column name (cac...
Definition: KompexSQLiteStatement.h:742
void Sql(const std::string &sql)
Definition: KompexSQLiteStatement.h:80
std::map< unsigned short, std::pair< const wchar_t *, bool > > TTransactionSQL16
typedef for UTF-16 transaction statements
Definition: KompexSQLiteStatement.h:731
Definition: KompexSQLiteBlob.h:26