sqlite doesn't have a datetime type :childish:

This commit is contained in:
malloc 2018-04-27 16:29:30 -05:00
parent 6491e7170b
commit 227a9df1e8
2 changed files with 35 additions and 2 deletions

View file

@ -2,27 +2,60 @@
#define SOSC_DATABASE_H
#include "sqlite/sqlite3.h"
#include "../utils/time.hpp"
#include <vector>
#include <string>
#define DB_COL_TEXT 1
#define DB_COL_BLOB 2
namespace sosc {
namespace db {
class Query;
class ResultSet {
public:
bool IsOpen() const;
bool IsReadable() const;
bool Step();
template<typename T>
T Get(int column);
std::string Get(int column, int type = DB_COL_TEXT);
private:
ResultSet(Query* query, sqlite3_stmt* stmt);
sqlite3_stmt* statement;
Query* query;
bool readable;
friend class Query;
};
double ResultSet::Get<double>(int column);
int32_t ResultSet::Get<int32_t>(int column);
int64_t ResultSet::Get<int64_t>(int column);
sosc::time ResultSet::Get<sosc::time>(int column);
class Query {
public:
Query();
Query(const std::string& query);
void SetQuery(const std::string& query);
void NonQuery();
ResultSet* GetResults() const;
inline bool IsOpen() const {
return this->open;
}
void Reset();
void Close();
private:
ResultSet results;
sqlite3_stmt* statement;
std::string query;
bool open;
};