Skip to content

Commit c1ab707

Browse files
committed
Fix compilation of new enum Database::BackupType for C++98
1 parent 514d7d6 commit c1ab707

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,5 @@ Version ?
136136
- #192 Add wrapper for bind parameter count
137137
- #197 Add tuple_bind and execute_many
138138
- #199 Fix #156 misleading error message in exception from Statement::exec
139-
- #201 Add Statement::getExpandedSQL() to get the SQL text of prepared statement with bound parameters expanded
139+
- #201 Add Statement::getExpandedSQL() to get the SQL text of prepared statement with bound parameters expanded
140+
- #211 Implement Database::backup()

include/SQLiteCpp/Database.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,11 @@ class Database
434434
*/
435435
static bool isUnencrypted(const std::string& aFilename);
436436

437+
/**
438+
* @brief BackupType for the backup() method
439+
*/
440+
enum BackupType { Save, Load };
441+
437442
/**
438443
* @brief Load or save the database content.
439444
*
@@ -443,7 +448,6 @@ class Database
443448
*
444449
* @return SQLITE_OK on success or an error code from SQLite.
445450
*/
446-
enum class BackupType { Save, Load };
447451
int backup(const char* zFilename, BackupType type);
448452

449453
private:

src/Database.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ int Database::backup(const char* zFilename, BackupType type) {
314314
** Otherwise, if this is a 'save' operation (isSave==1), then data
315315
** is copied from mpSQLite to pFile. Set the variables pFrom and
316316
** pTo accordingly. */
317-
sqlite3* pFrom = (type == BackupType::Save ? mpSQLite : pFile);
318-
sqlite3* pTo = (type == BackupType::Save ? pFile : mpSQLite);
317+
sqlite3* pFrom = (type == Save ? mpSQLite : pFile);
318+
sqlite3* pTo = (type == Save ? pFile : mpSQLite);
319319

320320
/* Set up the backup procedure to copy from the "main" database of
321321
** connection pFile to the main database of connection mpSQLite.

tests/Database_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ TEST(Database, import_export)
140140

141141
// Export the data into a file
142142
remove("backup");
143-
EXPECT_EQ(db.backup("backup", SQLite::Database::BackupType::Save), SQLITE_OK);
143+
EXPECT_EQ(db.backup("backup", SQLite::Database::Save), SQLITE_OK);
144144

145145
// Trash the table
146146
db.exec("DROP TABLE test;");
147147
EXPECT_FALSE(db.tableExists("test"));
148148

149149
// Import the data back from the file
150-
EXPECT_EQ(db.backup("backup", SQLite::Database::BackupType::Load), SQLITE_OK);
150+
EXPECT_EQ(db.backup("backup", SQLite::Database::Load), SQLITE_OK);
151151

152152
EXPECT_TRUE(db.tableExists("test"));
153153
}

0 commit comments

Comments
 (0)