mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-05 02:06:02 -04:00
Add throw exception case in executeStep
Add Comments
This commit is contained in:
parent
05d304b7c9
commit
c9dcf64cd0
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file Backup.h
|
||||
* @ingroup SQLiteCpp
|
||||
* @brief Management of a SQLite Database Backup.
|
||||
* @brief Backup is used to backup a database file in a safe and online way.
|
||||
*
|
||||
* Copyright (c) 2015 Shibao HONG (shibaohong@outlook.com)
|
||||
*
|
||||
@ -19,6 +19,23 @@
|
||||
namespace SQLite
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief RAII encapsulation of a SQLite Database Backup process.
|
||||
*
|
||||
* A Backup object is used to backup a source database file to a destination database file
|
||||
* in a safe and online way.
|
||||
*
|
||||
* Resource Acquisition Is Initialization (RAII) means that the Backup Resource
|
||||
* is allocated in the constructor and released in the destructor, so that there is
|
||||
* no need to worry about memory management or the validity of the underlying SQLite Backup.
|
||||
*
|
||||
* Thread-safety: a Backup object shall not be shared by multiple threads, because :
|
||||
* 1) in the SQLite "Thread Safe" mode, "SQLite can be safely used by multiple threads
|
||||
* provided that no single database connection is used simultaneously in two or more threads."
|
||||
* 2) the SQLite "Serialized" mode is not supported by SQLiteC++,
|
||||
* because of the way it shares the underling SQLite precompiled statement
|
||||
* in a custom shared pointer (See the inner class "Statement::Ptr").
|
||||
*/
|
||||
class Backup
|
||||
{
|
||||
public:
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file Backup.cpp
|
||||
* @ingroup SQLiteCpp
|
||||
* @brief Management of a SQLite Database Backup.
|
||||
* @brief Backup is used to backup a database file in a safe and online way.
|
||||
*
|
||||
* Copyright (c) 2015 Shibao HONG (shibaohong@outlook.com)
|
||||
*
|
||||
@ -74,9 +74,16 @@ Backup::~Backup() noexcept
|
||||
}
|
||||
}
|
||||
|
||||
int Backup::executeStep(const int aNumPage)
|
||||
int Backup::executeStep(const int aNumPage /* = -1 */)
|
||||
{
|
||||
const int res = sqlite3_backup_step(mpSQLiteBackup, aNumPage);
|
||||
if (SQLITE_OK != res && SQLITE_DONE != res &&
|
||||
SQLITE_BUSY != res && SQLITE_LOCKED != res)
|
||||
{
|
||||
std::string strerr("Backup executeStep error with message ");
|
||||
strerr += sqlite3_errstr(res);
|
||||
throw SQLite::Exception(strerr);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user