mirror of
https://github.com/open-goal/jak-project
synced 2026-07-05 05:40:00 -04:00
d/jak2: cleanup more of editable and editable-player (#2029)
- Rough start of the SQLite integration to facilitate the SQL queries - Cleanup and disable a little bit of code so the game no longer crashes when entering the editor - Implement some of the mouse data stuff  https://user-images.githubusercontent.com/13153231/202881484-399747e7-dcdb-4e09-93e9-b561a45c8a18.mp4 This is a very old branch so best to get it merged now that it's at a decent point so it can be iterated on.
This commit is contained in:
+84
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @file Backup.cpp
|
||||
* @ingroup SQLiteCpp
|
||||
* @brief Backup is used to backup a database file in a safe and online way.
|
||||
*
|
||||
* Copyright (c) 2015 Shibao HONG (shibaohong@outlook.com)
|
||||
* Copyright (c) 2015-2022 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
*/
|
||||
#include <SQLiteCpp/Backup.h>
|
||||
|
||||
#include <SQLiteCpp/Exception.h>
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
namespace SQLite
|
||||
{
|
||||
|
||||
// Initialize resource for SQLite database backup
|
||||
Backup::Backup(Database& aDestDatabase,
|
||||
const char* apDestDatabaseName,
|
||||
Database& aSrcDatabase,
|
||||
const char* apSrcDatabaseName)
|
||||
{
|
||||
mpSQLiteBackup.reset(sqlite3_backup_init(aDestDatabase.getHandle(),
|
||||
apDestDatabaseName,
|
||||
aSrcDatabase.getHandle(),
|
||||
apSrcDatabaseName));
|
||||
if (nullptr == mpSQLiteBackup)
|
||||
{
|
||||
// If an error occurs, the error code and message are attached to the destination database connection.
|
||||
throw SQLite::Exception(aDestDatabase.getHandle());
|
||||
}
|
||||
}
|
||||
|
||||
Backup::Backup(Database& aDestDatabase,
|
||||
const std::string& aDestDatabaseName,
|
||||
Database& aSrcDatabase,
|
||||
const std::string& aSrcDatabaseName) :
|
||||
Backup(aDestDatabase, aDestDatabaseName.c_str(), aSrcDatabase, aSrcDatabaseName.c_str())
|
||||
{
|
||||
}
|
||||
|
||||
Backup::Backup(Database &aDestDatabase, Database &aSrcDatabase) :
|
||||
Backup(aDestDatabase, "main", aSrcDatabase, "main")
|
||||
{
|
||||
}
|
||||
|
||||
// Execute backup step with a given number of source pages to be copied
|
||||
int Backup::executeStep(const int aNumPage /* = -1 */)
|
||||
{
|
||||
const int res = sqlite3_backup_step(mpSQLiteBackup.get(), aNumPage);
|
||||
if (SQLITE_OK != res && SQLITE_DONE != res && SQLITE_BUSY != res && SQLITE_LOCKED != res)
|
||||
{
|
||||
throw SQLite::Exception(sqlite3_errstr(res), res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Get the number of remaining source pages to be copied in this backup process
|
||||
int Backup::getRemainingPageCount() const
|
||||
{
|
||||
return sqlite3_backup_remaining(mpSQLiteBackup.get());
|
||||
}
|
||||
|
||||
// Get the number of total source pages to be copied in this backup process
|
||||
int Backup::getTotalPageCount() const
|
||||
{
|
||||
return sqlite3_backup_pagecount(mpSQLiteBackup.get());
|
||||
}
|
||||
|
||||
// Release resource for SQLite database backup
|
||||
void SQLite::Backup::Deleter::operator()(sqlite3_backup* apBackup)
|
||||
{
|
||||
if (apBackup)
|
||||
{
|
||||
sqlite3_backup_finish(apBackup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace SQLite
|
||||
Reference in New Issue
Block a user