2#include "sqlite3x_settings_db.hpp"
31 return 0 != this->m_db;
67 static std::string SettingsDb_Set_SQL =
"insert into settings values(?,?)";
89 st.
bind( 2, val ? 1 : 0 );
113 st.
bind( 2, val ? val :
"" );
117 void settings_db::init()
119 this->m_db->
executenonquery(
"create table if not exists settings(key PRIMARY KEY ON CONFLICT REPLACE,value)" );
124 static std::string SettingsDb_Get_SQL =
"select value from settings where key = ?";
void clear()
Empties the database.
void open(std::string const &dbname)
Opens the database dbname or throws on error.
settings_db()
Creates an unopened database.
~settings_db()
Closes this database.
bool is_open() const
Returns true if open() has succeeded.
sqlite3_connection * db()
If you want low-level info about the db, here's the handle to it.
bool get(std::string const &key, int &val)
Fetches the given key from the db.
void set(std::string const &key, int val)
Sets the given key/value pair.
void close()
Closes this database.
Encapsulates a command to send to an sqlite3_connection.
int executeint()
Executes the query, which is expected to have an integer field as the first result field.
void executenonquery()
Executes the query and provides no way to get the results.
double executedouble()
Executes the query, which is expected to have a double field as the first result field.
std::string executestring()
Executes the query, which is expected to have a string or blob field as the first result field.
int64_t executeint64()
Executes the query, which is expected to have a (int64_t) field as the first result field.
void bind(int index)
Binds NULL to the given index.
Represents a connection to an sqlite3 database.
void close()
Closes this database.
void executenonquery(const std::string &sql)
Executes a command which is assumed to have a single step and a void result.
This namespace encapsulates a C++ API wrapper for sqlite3 databases.