git is fucking trasH

This commit is contained in:
malloc 2018-04-30 09:54:34 -05:00
commit 9ebac99dcc
2 changed files with 35 additions and 2 deletions

View file

@ -2,27 +2,60 @@
#define SOSC_DATABASE_H #define SOSC_DATABASE_H
#include "sqlite/sqlite3.h" #include "sqlite/sqlite3.h"
#include "../utils/time.hpp"
#include <vector> #include <vector>
#include <string> #include <string>
#define DB_COL_TEXT 1
#define DB_COL_BLOB 2
namespace sosc { namespace sosc {
namespace db { namespace db {
class Query;
class ResultSet { class ResultSet {
public: 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: 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 { class Query {
public: public:
Query(); Query();
Query(const std::string& query); Query(const std::string& query);
void SetQuery(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 Reset();
void Close(); void Close();
private: private:
ResultSet results;
sqlite3_stmt* statement;
std::string query; std::string query;
bool open; bool open;
}; };