1 #ifndef s11n_net_SQ3_HPP_INCLUDED 2 #define s11n_net_SQ3_HPP_INCLUDED 1 9 # define SQ3_USE_WCHAR 0 16 # ifdef _GLIBCXX_USE_WCHAR_T 17 # define SQ3_USE_WCHAR 1 18 # elif defined(UNICODE) // Windows uses this 19 # define SQ3_USE_WCHAR 1 21 # define SQ3_USE_WCHAR 0 // default 26 # warning SQ3_USE_WCHAR: INCOMPLETE/BROKEN code is enabled! 35 #include "refcount.hpp" 249 sqlite3 * handle()
const;
270 void take_handle( sqlite3 * dbh, std::string
const & name =
"" );
279 sqlite3 * take_handle();
293 explicit database( std::string
const & filename );
305 bool is_open()
const;
310 std::string name()
const;
320 std::string errormsg()
const;
378 virtual int open(
char const *,
long flags = 0 );
386 int open( std::string
const &,
long flags = 0 );
417 int close(
bool force =
false );
443 int setbusytimeout(
int ms );
448 int execute(
const std::string &sql);
457 int execute(
char const * sql);
466 int execute(std::string
const & sql,
int & tgt);
471 int execute(
char const * sql,
int & tgt);
476 int execute(
char const * sql, int64_t & tgt);
481 int execute(std::string
const & sql, int64_t & tgt);
486 int execute(
char const * sql,
double & tgt);
490 int execute(std::string
const & sql,
double & tgt);
495 int execute(
char const * sql, std::string & tgt);
499 int execute(std::string
const & sql, std::string & tgt);
514 int execute(
char const * sql, sqlite3_text_char_t
const ** tgt,
int & len );
519 int execute(std::string
const & sql, sqlite3_text_char_t
const ** tgt,
int & len );
527 int execute(std::string
const & sql,
void const ** tgt,
int & sz );
533 int execute(
char const * sql,
void const ** tgt,
int & sz );
543 int execute( std::string
const & sql, sqlite3_callback callback,
void * data, std::string & errmsg );
547 int execute(
char const * sql, sqlite3_callback callback,
void * data, std::string & errmsg );
554 int execute( std::string
const & sql, sqlite3_callback callback,
void * data = 0 );
560 int execute(
char const * sql, sqlite3_callback callback,
void * data = 0 );
569 int pragma(
char const * code );
579 int open(
wchar_t const * dbname );
580 int open( std::wstring
const & dbname );
583 #endif // SQ3_USE_WCHAR 614 virtual int on_open();
693 typedef std::map<std::string,int> NameToIndexMap;
694 NameToIndexMap * m_cn;
701 void copy(
cursor const & rhs );
720 int index_colnames();
813 int isnull(
int index,
bool & tgt );
821 int get(
int index,
int & tgt );
825 int get(
int index, int64_t & tgt );
829 int get(
int index,
double & tgt );
833 int get(
int index, std::string & tgt );
846 int get(
int index, sqlite3_text_char_t
const ** tgt,
int & sz );
851 int get(
int index,
void const ** tgt,
int & sz );
871 int get( std::string
const & key,
int & tgt );
875 int get( std::string
const & key, int64_t & tgt );
879 int get( std::string
const & key,
double & tgt );
883 int get( std::string
const & key, std::string & tgt );
896 int get( std::string
const & key, sqlite3_text_char_t
const ** tgt,
int & sz );
901 int get( std::string
const & key,
void const ** tgt,
int & sz );
909 int colname(
int index, std::string & str );
922 int colname(
int index,
char const ** str );
1013 int prepare( std::string
const & sql );
1019 int prepare(
char const * sql,
int byteCount = -1 );
1029 int prepare( sqlite3_wstring_t
const sql,
int byteCount = -1 );
1034 #endif // SQ3_USE_WCHAR 1055 int bind(
int index );
1060 int bind(
int index,
int data );
1065 int bind(
int index, int64_t data );
1070 int bind(
int index,
double data );
1075 int bind(
int index,
char const * data,
int len );
1080 int bind(
int index,
void const * data,
int len );
1086 int bind(
int index, std::string
const & data );
1105 int bind(
char const * index );
1110 int bind(
char const * index,
int data );
1115 int bind(
char const * index, int64_t data );
1120 int bind(
char const * index,
double data );
1126 int bind(
char const * index,
char const * data,
int len );
1132 int bind(
char const * index,
void const * data,
int len );
1138 int bind(
char const * index, std::string
const & data );
1179 int execute(
int & tgt );
1182 int execute( int64_t & tgt );
1185 int execute(
double & tgt );
1188 int execute( std::string & tgt );
1201 int execute( sqlite3_text_char_t
const ** tgt,
int & len );
1217 int execute(
void const ** tgt,
int & len );
1238 bool is_prepared()
const;
1259 char const * colname(
int index );
1270 int colname(
int index,
char const ** cn );
1277 #endif // s11n_net_SQ3_HPP_INCLUDED Encapsulates a connection to an sqlite database.
char unsigned sqlite3_text_char_t
The published result codes from the sqlite3 API.
sqlite_uint64 uint64_t
The type used for unsigned 64-bit integer operations.
This class represents a prepared database statement.
void operator()(sqlite3 *&t)
Calls sqlite3_close(t) and assigns t to 0.
This type represents a transaction block in an SQL session.
A specialized dtor to call reset sqlite3_stmt handles(), for use with refcount::rcptr<sqlite3,sqlite3_stmt_reset_finalizer>.
The sq3 namespace encapsulates an OO sqlite3 API very similar to the sqlite3x API, but this one uses no exception handling (i.e., it doesn't throw on errors).
A specialized dtor to close sqlite3 handles, for use with refcount::rcptr<sqlite3,sqlite3_finalizer >.
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.
sqlite_int64 int64_t
The type used for signed 64-bit integer operations.
A specialized dtor to finalize sqlite3_stmt handles, for use with refcount::rcptr<sqlite3,sqlite3_stmt_finalizer>.
A bare-bones non-intrusive reference-counted pointer type with the ability for the client to specify ...
This type is for stepping through a db query result.
A specialized dtor to reset (not close) sq3::statement objects, for use with refcount::rcptr<sqlite3...