Add throw exception case in executeStep

Add Comments
This commit is contained in:
hongshibao 2015-10-26 00:35:36 +08:00
parent 05d304b7c9
commit c9dcf64cd0
2 changed files with 27 additions and 3 deletions

View File

@ -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:

View File

@ -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;
}