From db7aefb27123eb072acc6fe43aa01085a40d93d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Tue, 5 Jul 2016 07:49:38 +0200 Subject: [PATCH] Renamed Backup accessors and use a forward declaration to sqlite3_backup --- include/SQLiteCpp/Backup.h | 25 ++++++++----------------- src/Backup.cpp | 6 ++++-- tests/Backup_test.cpp | 10 +++++----- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/include/SQLiteCpp/Backup.h b/include/SQLiteCpp/Backup.h index 48bb389..b3a378e 100644 --- a/include/SQLiteCpp/Backup.h +++ b/include/SQLiteCpp/Backup.h @@ -10,12 +10,13 @@ */ #pragma once -#include - #include #include +// 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 diff --git a/src/Backup.cpp b/src/Backup.cpp index f256116..e495d96 100644 --- a/src/Backup.cpp +++ b/src/Backup.cpp @@ -13,6 +13,8 @@ #include +#include + #include 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); } diff --git a/tests/Backup_test.cpp b/tests/Backup_test.cpp index c4783c3..0567882 100644 --- a/tests/Backup_test.cpp +++ b/tests/Backup_test.cpp @@ -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");