Class that represents a connection to a database. More...
#include <DBConnection.h>
Public Member Functions | |
| dbconnection () noexcept | |
| Default constructor. | |
| dbconnection (const dbconnection &other) noexcept | |
| Copy constructor. More... | |
| dbconnection (dbconnection &&other) noexcept | |
| Copy constructor. More... | |
| dbconnection (const std::string &filename, openmode mode=openmode::read_write|openmode::create, const std::chrono::milliseconds timeout=DEFAULT_TIMEOUT) | |
| Open the provided database UTF-8 filename. More... | |
| dbconnection (const std::string &filename, const std::chrono::milliseconds timeout) | |
| Open the provided database UTF-8 filename. More... | |
| dbconnection (const std::u16string &filename, const std::chrono::milliseconds timeout=DEFAULT_TIMEOUT) | |
| Open the provided database UTF-16 filename. More... | |
| dbconnection & | operator= (const dbconnection &other) noexcept |
| Copy assignment operator. More... | |
| dbconnection & | operator= (dbconnection &&other) noexcept |
| Move assignment operator. More... | |
| sqlite::mutex | mutex () |
| Returns a mutex that serializes access to the database. More... | |
| operator bool () const noexcept | |
| Specifies if the dbconnection has a open database connection. More... | |
| sqlite3 * | handle () const noexcept |
| Returns pointer to the underlying "sqlite3" object. | |
| void | open (const std::string &filename, openmode mode=openmode::read_write|openmode::create) |
| Open an SQLite database file as specified by the filename argument. More... | |
| void | open (const std::u16string &filename) |
| Open an SQLite database file as specified by the filname argument. More... | |
| long long | row_id () const noexcept |
| Returns the rowid of the most recent successful "INSERT" into a rowid table or virtual table on database connection. More... | |
| template<typename F > | |
| void | create_general_function (const std::string &name, F &&function, int is_deterministic=false, const textencoding encoding=textencoding::utf8, int nargs=-1) |
| Used to add SQL functions or redefine the behavior of existing SQL functions. More... | |
| template<typename F > | |
| void | create_function (const std::string &name, F &&function, bool is_deterministic=false, const textencoding encoding=textencoding::utf8) |
| Used to add SQL functions or redefine the behavior of existing SQL functions. More... | |
| template<typename A > | |
| void | create_aggregate (const std::string &name, bool is_deterministic=false, const textencoding encoding=textencoding::utf8) |
| Used to add SQL aggregate functions or redefine the behavior of existing SQL aggregate functions. More... | |
| template<typename F > | |
| void | create_collation (const std::string &name, F &&function, const textencoding encoding=textencoding::utf8) |
| Used to add an SQL collation or redefine the behavior of existing SQL collations. More... | |
Static Public Member Functions | |
| static dbconnection | memory () |
| Create a purely in memory database. More... | |
| static dbconnection | wide_memory () |
| Create a purely in memory database with UTF-16 as the native byte order. More... | |
Class that represents a connection to a database.
The class dbconnection is a wrapper around the "sqlite3" structure.
Definition at line 24 of file DBConnection.h.
|
noexcept |
Copy constructor.
| [in] | other | another dbconnection object to use as source to initialize object with. |
Definition at line 11 of file DBConnection.cpp.
|
noexcept |
Copy constructor.
Constructs a dbconnection object with a copy of the contents of other using move semantics.
| [in] | other | another dbconnection object to use as source to initialize object with. |
Definition at line 15 of file DBConnection.cpp.
| sqlite::dbconnection::dbconnection | ( | const std::string & | filename, |
| openmode | mode = openmode::read_write | openmode::create, |
||
| const std::chrono::milliseconds | timeout = DEFAULT_TIMEOUT |
||
| ) |
Open the provided database UTF-8 filename.
| [in] | filename | UTF-8 path/uri to the database database file |
| [in] | mode | file opening options specified by combination of openmode flags |
| [in] | timeout | amount of milliseconds to wait before returning sqlite::busy_exception when a table is locked |
Definition at line 35 of file DBConnection.cpp.
| sqlite::dbconnection::dbconnection | ( | const std::string & | filename, |
| const std::chrono::milliseconds | timeout | ||
| ) |
Open the provided database UTF-8 filename.
| [in] | filename | UTF-8 path/uri to the database database file |
| [in] | timeout | amount of milliseconds to wait before returning sqlite::busy_exception when a table is locked |
Definition at line 44 of file DBConnection.cpp.
| sqlite::dbconnection::dbconnection | ( | const std::u16string & | filename, |
| const std::chrono::milliseconds | timeout = DEFAULT_TIMEOUT |
||
| ) |
Open the provided database UTF-16 filename.
| [in] | filename | UTF-16 path/uri to the database database file |
| [in] | timeout | Amount of milliseconds to wait before returning sqlite::busy_exception when a table is locked |
Definition at line 52 of file DBConnection.cpp.
|
inline |
Used to add SQL aggregate functions or redefine the behavior of existing SQL aggregate functions.
| A | The class to use as the aggregate function. |
| [in] | name | the name of the aggregate function to be used in an SQL query |
| [in] | is_deterministic | specifies if the function will always return the same result given the same inputs within a single SQL statement. |
| [in] | encoding | specifies the test encoding the SQL function prefers for its parameters |
Definition at line 203 of file DBConnection.h.
|
inline |
Used to add an SQL collation or redefine the behavior of existing SQL collations.
The function created should not throw an exception, if so the results is unknown.
| F | The function type to use to create the function. |
| [in] | name | the name of the function to be used in an SQL query |
| [in] | function | the implementation to the function |
| [in] | encoding | specifies the test encoding the SQL function prefers for its parameters |
Definition at line 239 of file DBConnection.h.
|
inline |
Used to add SQL functions or redefine the behavior of existing SQL functions.
| F | The function type to use to create the function. |
| [in] | name | the name of the function to be used in an SQL query |
| [in] | function | the implementation to the function |
| [in] | is_deterministic | specifies if the function will always return the same result given the same inputs within a single SQL statement. |
| [in] | encoding | specifies the test encoding the SQL function prefers for its parameters |
Definition at line 168 of file DBConnection.h.
|
inline |
Used to add SQL functions or redefine the behavior of existing SQL functions.
| F | The function type to use to create the function. |
| [in] | name | the name of the function to be used in an SQL query |
| [in] | function | the implementation to the function |
| [in] | is_deterministic | specifies if the function will always return the same result given the same inputs within a single SQL statement. |
| [in] | encoding | specifies the text encoding the SQL function prefers for its parameters. |
| [in] | nargs | the number of arguments that the SQL function takes. -1 means the SQL function can take any number of arguments. |
Definition at line 131 of file DBConnection.h.
|
static |
Create a purely in memory database.
Definition at line 60 of file DBConnection.cpp.
| mutex sqlite::dbconnection::mutex | ( | ) |
Returns a mutex that serializes access to the database.
Definition at line 70 of file DBConnection.cpp.
| void sqlite::dbconnection::open | ( | const std::string & | filename, |
| openmode | mode = openmode::read_write | openmode::create |
||
| ) |
Open an SQLite database file as specified by the filename argument.
| [in] | filename | path to SQLite file |
| [in] | mode | specifies the privileges to use when opening the database. |
Definition at line 89 of file DBConnection.cpp.
| void sqlite::dbconnection::open | ( | const std::u16string & | filename | ) |
Open an SQLite database file as specified by the filname argument.
The database file will have UTF-16 native byte order.
| [in] | filename | path to SQLite file |
Definition at line 101 of file DBConnection.cpp.
|
explicitnoexcept |
Specifies if the dbconnection has a open database connection.
Definition at line 79 of file DBConnection.cpp.
|
noexcept |
Copy assignment operator.
Replaces the contents with those of other.
| [in] | other | another dbconnection object to use as source to initialize object with. |
Definition at line 19 of file DBConnection.cpp.
|
noexcept |
Move assignment operator.
Replaces the contents with those of other using move semantics.
| [in] | other | another dbconnection object to use as source to initialize object with. |
Definition at line 28 of file DBConnection.cpp.
|
noexcept |
Returns the rowid of the most recent successful "INSERT" into a rowid table or virtual table on database connection.
Definition at line 113 of file DBConnection.cpp.
|
static |
Create a purely in memory database with UTF-16 as the native byte order.
Definition at line 65 of file DBConnection.cpp.
1.8.6