2021-10-16 11:03:15 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_SQLITE3_TRANSACTION_H
|
|
|
|
#define OPENMW_COMPONENTS_SQLITE3_TRANSACTION_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
struct sqlite3;
|
|
|
|
|
|
|
|
namespace Sqlite3
|
|
|
|
{
|
|
|
|
struct Rollback
|
|
|
|
{
|
|
|
|
void operator()(sqlite3* handle) const;
|
|
|
|
};
|
|
|
|
|
2022-03-10 17:34:35 +00:00
|
|
|
enum class TransactionMode
|
|
|
|
{
|
|
|
|
Default,
|
|
|
|
Deferred,
|
|
|
|
Immediate,
|
|
|
|
Exclusive,
|
|
|
|
};
|
|
|
|
|
2021-10-16 11:03:15 +00:00
|
|
|
class Transaction
|
|
|
|
{
|
|
|
|
public:
|
2022-03-10 17:34:35 +00:00
|
|
|
explicit Transaction(sqlite3& db, TransactionMode mode = TransactionMode::Default);
|
2021-10-16 11:03:15 +00:00
|
|
|
|
|
|
|
void commit();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<sqlite3, Rollback> mDb;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|