// Truck Computer Dooom! // // Douglas Thrift // // $Id$ #include "sqlite3.hpp" namespace SQLite3 { Connection::Connection(const std::string &db) { CheckError(::sqlite3_open(db.c_str(), &connection), connection); } Connection::~Connection() { CheckError(::sqlite3_close(connection), connection); } Statement::Statement(Connection &connection, const std::string &statement) : connection(connection) { CheckError(::sqlite3_prepare_v2(connection.GetHandle(), statement.data(), statement.size(), &this->statement, NULL), connection.GetHandle()); } Statement::~Statement() { ::sqlite3_finalize(statement); } void Statement::Set(unsigned index, double value) { CheckError(::sqlite3_bind_double(statement, index, value), connection.GetHandle()); } void Statement::Set(unsigned index, int value) { CheckError(::sqlite3_bind_int(statement, index, value), connection.GetHandle()); } void Statement::Set(unsigned index, int64_t value) { CheckError(::sqlite3_bind_int64(statement, index, value), connection.GetHandle()); } void Statement::Set(unsigned index, const Null &value) { CheckError(::sqlite3_bind_null(statement, index), connection.GetHandle()); } void Statement::Set(unsigned index, const std::string &value) { CheckError(::sqlite3_bind_text(statement, index, value.data(), value.size(), SQLITE_TRANSIENT), connection.GetHandle()); } }