From fb5508921aae455610fac2737869047591fdd5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Fri, 8 Jul 2016 17:07:59 +0200 Subject: [PATCH] Move #include from Database.h to the .cpp --- include/SQLiteCpp/Backup.h | 2 +- include/SQLiteCpp/Database.h | 46 ++++++++++++----------------------- include/SQLiteCpp/Statement.h | 2 +- src/Database.cpp | 31 +++++++++++++++++++++++ 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/include/SQLiteCpp/Backup.h b/include/SQLiteCpp/Backup.h index bd9a143..1ac14bd 100644 --- a/include/SQLiteCpp/Backup.h +++ b/include/SQLiteCpp/Backup.h @@ -14,7 +14,7 @@ #include -// Forward declaration to avoid including the header +// Forward declaration to avoid inclusion of in a header struct sqlite3_backup; namespace SQLite diff --git a/include/SQLiteCpp/Database.h b/include/SQLiteCpp/Database.h index 45ffb49..085da10 100644 --- a/include/SQLiteCpp/Database.h +++ b/include/SQLiteCpp/Database.h @@ -10,12 +10,15 @@ */ #pragma once -#include - #include #include +// Forward declarations to avoid inclusion of 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; } /** diff --git a/include/SQLiteCpp/Statement.h b/include/SQLiteCpp/Statement.h index 95b5d05..a3344aa 100644 --- a/include/SQLiteCpp/Statement.h +++ b/include/SQLiteCpp/Statement.h @@ -16,7 +16,7 @@ #include -// Forward declaration to avoid including the header +// Forward declarations to avoid inclusion of in a header struct sqlite3; struct sqlite3_stmt; diff --git a/src/Database.cpp b/src/Database.cpp index 1322104..f44f2b4 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -14,6 +14,7 @@ #include #include +#include #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,