qswiki/database/sqlite.h

35 rivejä
848 B
C
Raaka Normaali näkymä Historia

2018-11-03 17:12:20 +01:00
#ifndef SQLITE_H
#define SQLITE_H
#include <string>
#include <sqlite3.h>
#include <sqlite_modern_cpp.h>
#include "database.h"
class Sqlite : public Database
{
private:
2023-07-29 10:00:22 +02:00
static thread_local sqlite::database *db;
2018-11-03 17:12:20 +01:00
template <class T> std::unique_ptr<T> create() const
{
2023-07-29 10:00:22 +02:00
return std::make_unique<T>(database());
2018-11-03 17:12:20 +01:00
}
2023-07-29 10:00:22 +02:00
sqlite::database &database() const;
2018-11-03 17:12:20 +01:00
public:
Sqlite(std::string path);
std::unique_ptr<PageDao> createPageDao() const;
std::unique_ptr<RevisionDao> createRevisionDao() const;
std::unique_ptr<UserDao> createUserDao() const;
std::unique_ptr<SessionDao> createSessionDao() const;
std::unique_ptr<CategoryDao> createCategoryDao() const;
std::unique_ptr<PermissionsDao> createPermissionsDao() const;
2018-11-03 17:12:20 +01:00
void beginTransaction();
void commitTransaction();
void rollbackTransaction();
2023-07-29 10:00:22 +02:00
virtual ~Sqlite();
2018-11-03 17:12:20 +01:00
};
#endif // SQLITE_H