From 5dd91c7b80443c1f0e747088159c4d8b78d1856d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 24 Dec 2015 04:13:24 +0000 Subject: SQLite files prefixed with sqlite- --- libsqlitepp/connection.cpp | 134 --------------------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 libsqlitepp/connection.cpp (limited to 'libsqlitepp/connection.cpp') diff --git a/libsqlitepp/connection.cpp b/libsqlitepp/connection.cpp deleted file mode 100644 index 3331024..0000000 --- a/libsqlitepp/connection.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include "connection.h" -#include "error.h" -#include "selectcommand.h" -#include "modifycommand.h" - -SQLite::Connection::Connection(const std::string & str) : - txDepth(0), - rolledback(false) -{ - if (sqlite3_open(str.c_str(), &db) != SQLITE_OK) { - if (db) { - std::string err(sqlite3_errmsg(db)); - sqlite3_close(db); - throw Error(err.c_str()); - } - throw Error("Unknown error opening database"); - } -} - -SQLite::Connection::~Connection() -{ - sqlite3_close(db); -} - -void -SQLite::Connection::finish() const -{ - if (txDepth != 0) { - rollbackTx(); - throw Error("Transaction still open"); - } -} - -int -SQLite::Connection::beginTx() const -{ - if (txDepth == 0) { - if (sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, NULL) != SQLITE_OK) { - throw Error(sqlite3_errmsg(db)); - } - rolledback = false; - } - return ++txDepth; -} - -int -SQLite::Connection::commitTx() const -{ - if (rolledback) { - return rollbackTx(); - } - if (--txDepth == 0) { - if (sqlite3_exec(db, "COMMIT TRANSACTION", NULL, NULL, NULL) != SQLITE_OK) { - throw Error(sqlite3_errmsg(db)); - } - } - return txDepth; -} - -int -SQLite::Connection::rollbackTx() const -{ - if (--txDepth == 0) { - if (sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL) != SQLITE_OK) { - throw Error(sqlite3_errmsg(db)); - } - } - else { - rolledback = true; - } - return txDepth; -} - -bool -SQLite::Connection::inTx() const -{ - return txDepth; -} - -DB::BulkDeleteStyle -SQLite::Connection::bulkDeleteStyle() const -{ - return DB::BulkDeleteUsingUsingAlias; -} - -DB::BulkUpdateStyle -SQLite::Connection::bulkUpdateStyle() const -{ - return DB::BulkUpdateUsingJoin; -} - -void -SQLite::Connection::ping() const -{ - // Can this fail? -} - - -DB::SelectCommand * -SQLite::Connection::newSelectCommand(const std::string & sql) const -{ - return new SelectCommand(this, sql); -} - -DB::ModifyCommand * -SQLite::Connection::newModifyCommand(const std::string & sql) const -{ - return new ModifyCommand(this, sql); -} - -void -SQLite::Connection::beginBulkUpload(const char *, const char *) const -{ - throw Error("Not implemented"); -} - -void -SQLite::Connection::endBulkUpload(const char *) const -{ - throw Error("Not implemented"); -} - -size_t -SQLite::Connection::bulkUploadData(const char *, size_t) const -{ - throw Error("Not implemented"); -} - -int64_t -SQLite::Connection::insertId() const -{ - return sqlite3_last_insert_rowid(db); -} - -- cgit v1.2.3