mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Renamed Backup accessors and use a forward declaration to sqlite3_backup
This commit is contained in:
parent
9fa00ea5ed
commit
db7aefb271
@ -10,12 +10,13 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
#include <SQLiteCpp/Database.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
// Forward declaration to avoid including the sqlite3.h header
|
||||
struct sqlite3_backup;
|
||||
|
||||
namespace SQLite
|
||||
{
|
||||
|
||||
@ -97,9 +98,7 @@ public:
|
||||
Backup(Database& aDestDatabase,
|
||||
Database& aSrcDatabase);
|
||||
|
||||
/**
|
||||
* @brief Release the SQLite Backup resource.
|
||||
*/
|
||||
/// Release the SQLite Backup resource.
|
||||
virtual ~Backup() noexcept;
|
||||
|
||||
/**
|
||||
@ -117,19 +116,11 @@ public:
|
||||
*/
|
||||
int executeStep(const int aNumPage = -1);
|
||||
|
||||
/**
|
||||
* @brief Get the remaining number of source pages to be copied.
|
||||
*
|
||||
* @return the remaining number of source pages to be copied
|
||||
*/
|
||||
int remainingPageCount();
|
||||
/// Return the number of source pages still to be backed up as of the most recent call to executeStep().
|
||||
int getRemainingPageCount();
|
||||
|
||||
/**
|
||||
* @brief Get the total number of source pages.
|
||||
*
|
||||
* @return the total number of source pages
|
||||
*/
|
||||
int totalPageCount();
|
||||
/// Return the total number of pages in the source database as of the most recent call to executeStep().
|
||||
int getTotalPageCount();
|
||||
|
||||
private:
|
||||
/// @{ Backup must be non-copyable
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
#include <SQLiteCpp/Exception.h>
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace SQLite
|
||||
@ -90,13 +92,13 @@ int Backup::executeStep(const int aNumPage /* = -1 */)
|
||||
}
|
||||
|
||||
// Get the number of remaining source pages to be copied in this backup process
|
||||
int Backup::remainingPageCount()
|
||||
int Backup::getRemainingPageCount()
|
||||
{
|
||||
return sqlite3_backup_remaining(mpSQLiteBackup);
|
||||
}
|
||||
|
||||
// Get the number of total source pages to be copied in this backup process
|
||||
int Backup::totalPageCount()
|
||||
int Backup::getTotalPageCount()
|
||||
{
|
||||
return sqlite3_backup_pagecount(mpSQLiteBackup);
|
||||
}
|
||||
|
@ -44,13 +44,13 @@ TEST(Backup, executeStepOne) {
|
||||
SQLite::Backup backup(destDB, "main", srcDB, "main");
|
||||
int res = backup.executeStep(1); // backup only one page at a time
|
||||
ASSERT_EQ(SQLITE_OK, res);
|
||||
const int total = backup.totalPageCount();
|
||||
const int total = backup.getTotalPageCount();
|
||||
ASSERT_EQ(2, total);
|
||||
int remaining = backup.remainingPageCount();
|
||||
int remaining = backup.getRemainingPageCount();
|
||||
ASSERT_EQ(1, remaining);
|
||||
res = backup.executeStep(1); // backup the second and last page
|
||||
ASSERT_EQ(SQLITE_DONE, res);
|
||||
remaining = backup.remainingPageCount();
|
||||
remaining = backup.getRemainingPageCount();
|
||||
ASSERT_EQ(0, remaining);
|
||||
|
||||
SQLite::Statement query(destDB, "SELECT * FROM backup_test ORDER BY id ASC");
|
||||
@ -76,9 +76,9 @@ TEST(Backup, executeStepAll) {
|
||||
SQLite::Backup backup(destDB, srcDB);
|
||||
const int res = backup.executeStep(); // uses default argument "-1" => execute all steps at once
|
||||
ASSERT_EQ(res, SQLITE_DONE);
|
||||
const int total = backup.totalPageCount();
|
||||
const int total = backup.getTotalPageCount();
|
||||
ASSERT_EQ(2, total);
|
||||
const int remaining = backup.remainingPageCount();
|
||||
const int remaining = backup.getRemainingPageCount();
|
||||
ASSERT_EQ(0, remaining);
|
||||
|
||||
SQLite::Statement query(destDB, "SELECT * FROM backup_test ORDER BY id ASC");
|
||||
|
Loading…
x
Reference in New Issue
Block a user