1 #ifndef s11n_net_SQLITE3X_HPP_INCLUDED 2 #define s11n_net_SQLITE3X_HPP_INCLUDED 94 #ifndef SQLITE3X_USE_WCHAR 95 # ifdef _GLIBCXX_USE_WCHAR_T 96 # define SQLITE3X_USE_WCHAR 1 97 # elif defined(UNICODE) // Windows uses this 98 # define SQLITE3X_USE_WCHAR 1 100 # define SQLITE3X_USE_WCHAR 0 // default 157 mutable struct sqlite3 *m_db;
172 sqlite3 *
db()
const;
205 std::string
name()
const;
231 virtual void open(
char const * );
236 void open(std::string
const &dbname);
259 void take( sqlite3 * dbh );
266 sqlite3 *
take()
throw();
376 int executecallback( std::string
const & sql, sqlite3_callback callback,
void * data, std::string & errmsg );
383 int executecallback( std::string
const & sql, sqlite3_callback callback,
void * data = 0 );
394 #if SQLITE3X_USE_WCHAR 402 std::wstring executestring16(
const std::wstring &sql);
403 std::wstring executestring16(
const std::string &sql);
405 void open(
const wchar_t *dbname);
523 bool isnull(
int index);
529 int getint(
int index);
534 int64_t getint64(
int index);
539 double getdouble(
int index);
544 std::string getstring(
int index);
557 char const * getstring(
int index,
int & size);
563 std::string getblob(
int index);
571 void const * getblob(
int index,
int & size );
577 std::string getcolname(
int index);
581 #if SQLITE3X_USE_WCHAR 582 std::wstring getstring16(
int index);
583 std::wstring getcolname16(
int index);
600 mutable sqlite3_stmt *stmt;
632 void prepare(
char const * sql,
int len = -1 );
636 void prepare( std::string
const & sql );
641 void bind(
int index);
645 void bind(
int index,
int data);
649 void bind(
int index, int64_t data);
653 void bind(
int index,
double data);
659 void bind(
int index,
const char *data,
int datalen = -1);
665 void bind(
int index,
const void *data,
int datalen);
669 void bind(
int index,
const std::string &data);
756 sqlite3_stmt * handle();
764 #if SQLITE3X_USE_WCHAR 766 void bind(
int index,
const wchar_t *data,
int datalen);
767 void bind(
int index,
const std::wstring &data);
768 std::wstring executestring16();
769 #endif // SQLITE3_USE_WCHAR 798 virtual char const * what()
const throw();
916 #endif // s11n_net_SQLITE3X_HPP_INCLUDED
int changes()
Returns the number of database rows that were changed (or inserted or deleted) by the most recently c...
std::string name() const
Returns this object's name.
Encapsulates a command to send to an sqlite3_connection.
std::string executestring(const std::string &sql)
Executes the query, which is expected to have a string or blob field as the first result field...
double executedouble(const std::string &sql)
Executes the query, which is expected to have a double field as the first result field.
bool rc_is_okay(int rc)
rc_is_okay() is an easy way to check if rc is one of SQLITE_OK, SQLITE_ROW, or SQLITE_DONE.
A type for reading results from an sqlite3_command.
int64_t insertid()
Returns the rowid of the most recently inserted row on this db.
This namespace encapsulates a C++ API wrapper for sqlite3 databases.
int executecallback(std::string const &sql, sqlite3_callback callback, void *data, std::string &errmsg)
Executes the given SQL code, calling callback for each row of the data set.
Represents a connection to an sqlite3 database.
std::string executeblob(const std::string &sql)
Executes the query, which is expected to have a string or blob field as the first result field...
int executeint(const std::string &sql)
Executes the query, which is expected to have an integer field as the first result field...
sqlite3_connection()
Default ctor.
void close()
Closes this database.
Manages an sqlite3 transaction.
sqlite3 * take()
Transfers ownership of the returned handle to the caller.
sqlite_int64 int64_t
64-bit integer type used by this code.
void setbusytimeout(int ms)
See sqlite3_busy_timeout().
virtual void open(char const *)
Creates/opens the given db, throwing on error.
void executenonquery(const std::string &sql)
Executes a command which is assumed to have a single step and a void result.
virtual void on_open()
This function is called when open() succeeds.
std::string errormsg() const
Returns the equivalent of sqlite3_errmsg(), or an empty string if that function returns null...
An internal implementation detail of table_generator.
Exception type used by the sqlite3x classes.
virtual ~sqlite3_connection()
Calls this->close() if close() has not already been called.
sqlite3 * db() const
Returns a handle to the underlying sqlite3 database.
int64_t executeint64(const std::string &sql)
Executes the query, which is expected to have a (int64_t) field as the first result field...