Move #include <sqlite3.h> from Database.h to the .cpp

This commit is contained in:
Sébastien Rombauts 2016-07-08 17:07:59 +02:00
parent 67a88298df
commit fb5508921a
4 changed files with 48 additions and 33 deletions

View File

@ -14,7 +14,7 @@
#include <string>
// Forward declaration to avoid including the <sqlite3.h> header
// Forward declaration to avoid inclusion of <sqlite3.h> in a header
struct sqlite3_backup;
namespace SQLite

View File

@ -10,12 +10,15 @@
*/
#pragma once
#include <sqlite3.h>
#include <SQLiteCpp/Column.h>
#include <string>
// Forward declarations to avoid inclusion of <sqlite3.h> in a header
struct sqlite3;
struct sqlite3_context;
struct Mem;
typedef struct Mem sqlite3_value;
namespace SQLite
{
@ -237,43 +240,24 @@ public:
*
* @return Rowid of the most recent successful INSERT into the database, or 0 if there was none.
*/
inline int64_t getLastInsertRowid() const noexcept // nothrow
{
return sqlite3_last_insert_rowid(mpSQLite);
}
int64_t getLastInsertRowid() const noexcept; // nothrow
/**
* @brief Get total number of rows modified by all INSERT, UPDATE or DELETE statement since connection.
*
* @return Total number of rows modified since connection to the database. DROP tables does not count.
*/
inline int getTotalChanges() const noexcept // nothrow
{
return sqlite3_total_changes(mpSQLite);
}
/// Return the filename used to open the database.
inline const std::string& getFilename() const noexcept // nothrow
{
return mFilename;
}
/// Get total number of rows modified by all INSERT, UPDATE or DELETE statement since connection (not DROP table).
int getTotalChanges() const noexcept; // nothrow
/// Return the numeric result code for the most recent failed API call (if any).
inline int getErrorCode() const noexcept // nothrow
{
return sqlite3_errcode(mpSQLite);
}
int getErrorCode() const noexcept; // nothrow
/// Return the extended numeric result code for the most recent failed API call (if any).
inline int getExtendedErrorCode() const noexcept // nothrow
{
return sqlite3_extended_errcode(mpSQLite);
}
int getExtendedErrorCode() const noexcept; // nothrow
/// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
inline const char* errmsg() const noexcept // nothrow
const char* errmsg() const noexcept; // nothrow
/// Return the filename used to open the database.
const std::string& getFilename() const noexcept // nothrow
{
return sqlite3_errmsg(mpSQLite);
return mFilename;
}
/**

View File

@ -16,7 +16,7 @@
#include <SQLiteCpp/Exception.h>
// Forward declaration to avoid including the <sqlite3.h> header
// Forward declarations to avoid inclusion of <sqlite3.h> in a header
struct sqlite3;
struct sqlite3_stmt;

View File

@ -14,6 +14,7 @@
#include <SQLiteCpp/Assertion.h>
#include <SQLiteCpp/Exception.h>
#include <sqlite3.h>
#ifndef SQLITE_DETERMINISTIC
#define SQLITE_DETERMINISTIC 0x800
@ -132,6 +133,36 @@ bool Database::tableExists(const char* apTableName)
return (1 == query.getColumn(0).getInt());
}
// Get the rowid of the most recent successful INSERT into the database from the current connection.
int64_t Database::getLastInsertRowid() const noexcept // nothrow
{
return sqlite3_last_insert_rowid(mpSQLite);
}
// Get total number of rows modified by all INSERT, UPDATE or DELETE statement since connection.
int Database::getTotalChanges() const noexcept // nothrow
{
return sqlite3_total_changes(mpSQLite);
}
// Return the numeric result code for the most recent failed API call (if any).
int Database::getErrorCode() const noexcept // nothrow
{
return sqlite3_errcode(mpSQLite);
}
// Return the extended numeric result code for the most recent failed API call (if any).
int Database::getExtendedErrorCode() const noexcept // nothrow
{
return sqlite3_extended_errcode(mpSQLite);
}
// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
const char* Database::errmsg() const noexcept // nothrow
{
return sqlite3_errmsg(mpSQLite);
}
// Attach a custom function to your sqlite database. Assumes UTF8 text representation.
// Parameter details can be found here: http://www.sqlite.org/c3ref/create_function.html
void Database::createFunction(const char* apFuncName,