mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-05 10:16:01 -04:00
Move #include <sqlite3.h> from Database.h to the .cpp
This commit is contained in:
parent
67a88298df
commit
fb5508921a
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#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;
|
struct sqlite3_backup;
|
||||||
|
|
||||||
namespace SQLite
|
namespace SQLite
|
||||||
|
@ -10,12 +10,15 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sqlite3.h>
|
|
||||||
|
|
||||||
#include <SQLiteCpp/Column.h>
|
#include <SQLiteCpp/Column.h>
|
||||||
|
|
||||||
#include <string>
|
#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
|
namespace SQLite
|
||||||
{
|
{
|
||||||
@ -237,43 +240,24 @@ public:
|
|||||||
*
|
*
|
||||||
* @return Rowid of the most recent successful INSERT into the database, or 0 if there was none.
|
* @return Rowid of the most recent successful INSERT into the database, or 0 if there was none.
|
||||||
*/
|
*/
|
||||||
inline int64_t getLastInsertRowid() const noexcept // nothrow
|
int64_t 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 (not DROP table).
|
||||||
* @brief Get total number of rows modified by all INSERT, UPDATE or DELETE statement since connection.
|
int getTotalChanges() const noexcept; // nothrow
|
||||||
*
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the numeric result code for the most recent failed API call (if any).
|
/// Return the numeric result code for the most recent failed API call (if any).
|
||||||
inline int getErrorCode() const noexcept // nothrow
|
int getErrorCode() const noexcept; // nothrow
|
||||||
{
|
|
||||||
return sqlite3_errcode(mpSQLite);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the extended numeric result code for the most recent failed API call (if any).
|
/// Return the extended numeric result code for the most recent failed API call (if any).
|
||||||
inline int getExtendedErrorCode() const noexcept // nothrow
|
int 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).
|
/// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <SQLiteCpp/Exception.h>
|
#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;
|
||||||
struct sqlite3_stmt;
|
struct sqlite3_stmt;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <SQLiteCpp/Assertion.h>
|
#include <SQLiteCpp/Assertion.h>
|
||||||
#include <SQLiteCpp/Exception.h>
|
#include <SQLiteCpp/Exception.h>
|
||||||
|
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
#ifndef SQLITE_DETERMINISTIC
|
#ifndef SQLITE_DETERMINISTIC
|
||||||
#define SQLITE_DETERMINISTIC 0x800
|
#define SQLITE_DETERMINISTIC 0x800
|
||||||
@ -132,6 +133,36 @@ bool Database::tableExists(const char* apTableName)
|
|||||||
return (1 == query.getColumn(0).getInt());
|
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.
|
// 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
|
// Parameter details can be found here: http://www.sqlite.org/c3ref/create_function.html
|
||||||
void Database::createFunction(const char* apFuncName,
|
void Database::createFunction(const char* apFuncName,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user