51 lines
1.6 KiB
C++
Executable file
51 lines
1.6 KiB
C++
Executable file
// For license of this file, see <project-root-folder>/LICENSE.md.
|
|
|
|
#ifndef DATABASEDRIVER_H
|
|
#define DATABASEDRIVER_H
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSqlDatabase>
|
|
|
|
class DatabaseDriver : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
// Describes available types of database backend.
|
|
enum class DriverType {
|
|
SQLite,
|
|
MySQL
|
|
};
|
|
|
|
// Describes what type of database user wants.
|
|
enum class DesiredStorageType {
|
|
StrictlyFileBased,
|
|
StrictlyInMemory,
|
|
FromSettings
|
|
};
|
|
|
|
explicit DatabaseDriver(QObject* parent = nullptr);
|
|
|
|
// API.
|
|
virtual QString humanDriverType() const = 0;
|
|
virtual QString qtDriverCode() const = 0;
|
|
virtual DriverType driverType() const = 0;
|
|
virtual QString autoIncrementPrimaryKey() const = 0;
|
|
virtual bool vacuumDatabase() = 0;
|
|
virtual bool saveDatabase() = 0;
|
|
virtual void backupDatabase(const QString& backup_folder, const QString& backup_name) = 0;
|
|
virtual bool initiateRestoration(const QString& database_package_file) = 0;
|
|
virtual bool finishRestoration() = 0;
|
|
virtual qint64 databaseDataSize() = 0;
|
|
virtual QSqlDatabase connection(const QString& connection_name,
|
|
DatabaseDriver::DesiredStorageType desired_type = DatabaseDriver::DesiredStorageType::FromSettings) = 0;
|
|
|
|
protected:
|
|
QStringList prepareScript(const QString& base_sql_folder,
|
|
const QString& sql_file,
|
|
const QString& database_name = {});
|
|
|
|
};
|
|
|
|
#endif // DATABASEDRIVER_H
|