19 #ifndef OST_IO_SQLITE_WRAP_HH
20 #define OST_IO_SQLITE_WRAP_HH
27 #include <boost/shared_ptr.hpp>
35 namespace ost {
namespace db {
57 return sqlite3_step(statement_)==SQLITE_DONE;
62 sqlite3_bind_int(statement_, col, value);
67 sqlite3_bind_int64(statement_, col, value);
72 sqlite3_bind_text(statement_, col, text.c_str(),
73 static_cast<int>(text.size()), NULL);
76 void BindBlob(
int col,
const char* start,
size_t size)
78 sqlite3_bind_blob(statement_, col, start, size, NULL);
81 sqlite3_stmt* statement_;
110 template <
typename R>
114 stmt_(stmt), value_()
119 stmt_(), value_(), cur_val_(SQLITE_DONE)
132 return cur_val_!=SQLITE_ROW;
137 cur_val_=sqlite3_step(stmt_->Handle());
138 if (cur_val_==SQLITE_ROW) {
168 sqlite3_int64 LastRowID();
RowSet< R > & operator++()
boost::shared_ptr< PreparedStatement > PreparedStatementPtr
void BindText(int col, const String &text)
bind String value to placeholder
void BindBlob(int col, const char *start, size_t size)
bind binary blob to placeholder
bool Submit()
submit query after binding all a parameters.
void BindInt(int col, int value)
bind integer value to placeholder
DatabaseError(const String &msg)
void SqlConvert(sqlite3_stmt *stmt, int &value, int col=0)
sqlite3 * Handle()
Get SQLite handle.
void BindInt64(int col, sqlite3_int64 value)
bind 64 bit integer value to placeholder
RowSet(PreparedStatementPtr stmt)
boost::shared_ptr< Database > DatabasePtr