Initial commit

This commit is contained in:
2020-02-12 19:57:50 +01:00
commit 8ecca3824b
13 changed files with 440 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#ifndef SQLITECLIENT_H
#define SQLITECLIENT_H
#include "SQLiteResultSet.h"
#include "SQLiteStatement.h"
#include <string>
class sqlite3;
namespace SQLite {
class SQLiteClient
{
public:
SQLiteClient(const std::string& filename);
~SQLiteClient();
operator sqlite3*();
public:
SQLiteResultSet ExecuteQuery(const std::string& query);
void BeginTransaction();
void EndTransaction();
private:
SQLiteResultSet RetrieveResultSet(SQLiteStatement& statement);
private:
sqlite3* m_pSQLite3;
};
} // namespace SQLite
#endif // SQLITECLIENT_H
+56
View File
@@ -0,0 +1,56 @@
#ifndef SQLITERESULTSET_H
#define SQLITERESULTSET_H
#include "SQLiteStatement.h"
#include <string>
#include <vector>
#include <stdint.h>
namespace SQLite {
class SQLiteResultSet
{
public:
SQLiteResultSet(SQLiteStatement& statement);
public:
void AfterLast();
void BeforeFirst();
bool First();
bool IsAfterLast() const;
bool IsBeforeFirst() const;
bool IsFirst() const;
bool IsLast() const;
bool Last();
bool Next();
bool Previous();
size_t Row() const;
size_t RowsCount() const;
bool Empty() const;
uint32_t FindColumn(const std::string& columnName) const;
long double Double(uint32_t columnIndex) const;
long double Double(const std::string& columnLabel) const;
int32_t Int(uint32_t columnIndex) const;
int32_t Int(const std::string& columnLabel) const;
std::string String(uint32_t columnIndex) const;
std::string String(const std::string& columnName) const;
void Print() const;
private:
int Size() const;
int LastIndex() const;
private:
std::vector<std::string> m_columns;
std::vector<std::vector<std::string>> m_values;
int m_currentRow;
};
} // namespace SQLite
#endif // SQLITERESULTSET_H
+27
View File
@@ -0,0 +1,27 @@
#ifndef SQLITESTATEMENT_H
#define SQLITESTATEMENT_H
#include <string>
class sqlite3_stmt;
namespace SQLite {
class SQLiteClient;
class SQLiteStatement
{
public:
SQLiteStatement(SQLiteClient& client, const std::string& query);
~SQLiteStatement();
operator sqlite3_stmt*();
private:
sqlite3_stmt* m_pStatement;
};
} // namespace SQLite
#endif // SQLITESTATEMENT_H