std::string API (implementing issue #13

This commit is contained in:
r4d2
2014-01-12 00:15:10 +01:00
parent d7f349ba62
commit 905c3d7bb5
4 changed files with 170 additions and 0 deletions

View File

@@ -33,6 +33,20 @@ Database::Database(const char* apFilename, const int aFlags /*= SQLITE_OPEN_READ
}
}
// Open the provided database UTF-8 filename with SQLITE_OPEN_xxx provided flags.
Database::Database(const std::string& aFilename, const int aFlags /*= SQLITE_OPEN_READONLY*/) : // throw(SQLite::Exception)
mpSQLite(NULL),
mFilename(aFilename)
{
int ret = sqlite3_open_v2(aFilename.c_str(), &mpSQLite, aFlags, NULL);
if (SQLITE_OK != ret)
{
std::string strerr = sqlite3_errmsg(mpSQLite);
sqlite3_close(mpSQLite); // close is required even in case of error on opening
throw SQLite::Exception(strerr);
}
}
// Close the SQLite database connection.
Database::~Database(void) throw() // nothrow
{