From ab47c39c82abee7f0e0cff981dc352fdc310a6fe Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 24 Feb 2019 13:06:07 +0000 Subject: Bring up-to-date with libdbpp. --- libsqlitepp/Jamfile.jam | 6 ++---- libsqlitepp/sqlite-command.cpp | 7 ++++++- libsqlitepp/sqlite-command.h | 1 + libsqlitepp/sqlite-mock.cpp | 11 +++++------ libsqlitepp/sqlite-mock.h | 8 ++++---- libsqlitepp/sqlite-selectcommand.cpp | 4 ++-- 6 files changed, 20 insertions(+), 17 deletions(-) (limited to 'libsqlitepp') diff --git a/libsqlitepp/Jamfile.jam b/libsqlitepp/Jamfile.jam index 6d99b4b..b624c3f 100644 --- a/libsqlitepp/Jamfile.jam +++ b/libsqlitepp/Jamfile.jam @@ -4,8 +4,7 @@ lib libsqlite : : sqlite3 ; lib adhocutil : : : : /usr/include/adhocutil ; lib dbppcore : : : : /usr/include/dbpp ; lib boost_date_time ; -lib boost_filesystem ; -lib boost_system ; +lib stdc++fs ; lib dbpp-sqlite : [ glob *.cpp ] : @@ -14,8 +13,7 @@ lib dbpp-sqlite : adhocutil dbppcore boost_date_time - boost_system - boost_filesystem + stdc++fs : : . ..//glibmm diff --git a/libsqlitepp/sqlite-command.cpp b/libsqlitepp/sqlite-command.cpp index 3d8ac07..adaf41e 100644 --- a/libsqlitepp/sqlite-command.cpp +++ b/libsqlitepp/sqlite-command.cpp @@ -76,7 +76,12 @@ SQLite::Command::bindParamF(unsigned int n, float v) void SQLite::Command::bindParamS(unsigned int n, const Glib::ustring & s) { - if (sqlite3_bind_text(stmt, n + 1, s.c_str(), s.length(), SQLITE_STATIC) != SQLITE_OK) { + return bindParamS(n, std::string_view(s.raw())); +} +void +SQLite::Command::bindParamS(unsigned int n, const std::string_view & s) +{ + if (sqlite3_bind_text(stmt, n + 1, s.data(), s.length(), SQLITE_STATIC) != SQLITE_OK) { throw Error(c->db); } } diff --git a/libsqlitepp/sqlite-command.h b/libsqlitepp/sqlite-command.h index c66d71d..cbc9932 100644 --- a/libsqlitepp/sqlite-command.h +++ b/libsqlitepp/sqlite-command.h @@ -24,6 +24,7 @@ namespace SQLite { void bindParamF(unsigned int, float) override; void bindParamS(unsigned int, const Glib::ustring&) override; + void bindParamS(unsigned int, const std::string_view&) override; void bindParamT(unsigned int, const boost::posix_time::time_duration &) override; void bindParamT(unsigned int, const boost::posix_time::ptime &) override; diff --git a/libsqlitepp/sqlite-mock.cpp b/libsqlitepp/sqlite-mock.cpp index 7a18b87..510b209 100644 --- a/libsqlitepp/sqlite-mock.cpp +++ b/libsqlitepp/sqlite-mock.cpp @@ -1,20 +1,19 @@ #include "sqlite-mock.h" #include "sqlite-connection.h" #include -#include NAMEDFACTORY("sqlite", SQLite::Mock, DB::MockDatabaseFactory); namespace SQLite { -Mock::Mock(const std::string & root, const std::string & name, const std::vector & ss) : - testDbPath(boost::filesystem::path(root) / name / boost::lexical_cast(getpid()) / boost::lexical_cast(++DB::MockDatabase::mocked)) +Mock::Mock(const std::string & root, const std::string & name, const std::vector & ss) : + testDbPath(std::filesystem::path(root) / name / boost::lexical_cast(getpid()) / boost::lexical_cast(++DB::MockDatabase::mocked)) { CreateNewDatabase(); PlaySchemaScripts(ss); } -Mock::Mock(const std::string & name, const std::vector & ss) : +Mock::Mock(const std::string & name, const std::vector & ss) : Mock("/tmp/sqliteut", name, ss) { } @@ -32,12 +31,12 @@ Mock::~Mock() void Mock::DropDatabase() const { - boost::filesystem::remove(testDbPath); + std::filesystem::remove(testDbPath); } void Mock::CreateNewDatabase() const { - boost::filesystem::create_directories(testDbPath.parent_path()); + std::filesystem::create_directories(testDbPath.parent_path()); openConnection(); // Triggers file creation } diff --git a/libsqlitepp/sqlite-mock.h b/libsqlitepp/sqlite-mock.h index 4580778..cc182d4 100644 --- a/libsqlitepp/sqlite-mock.h +++ b/libsqlitepp/sqlite-mock.h @@ -2,15 +2,15 @@ #define MOCKSQLITEDATASOURCE_H #include -#include +#include #include namespace SQLite { class DLL_PUBLIC Mock : public DB::MockDatabase { public: - Mock(const std::string & root, const std::string & name, const std::vector & ss); - Mock(const std::string & name, const std::vector & ss); + Mock(const std::string & root, const std::string & name, const std::vector & ss); + Mock(const std::string & name, const std::vector & ss); ~Mock(); protected: @@ -20,7 +20,7 @@ class DLL_PUBLIC Mock : public DB::MockDatabase { DB::ConnectionPtr openConnection() const override; private: - const boost::filesystem::path testDbPath; + const std::filesystem::path testDbPath; }; } diff --git a/libsqlitepp/sqlite-selectcommand.cpp b/libsqlitepp/sqlite-selectcommand.cpp index 67e90ba..909dc5c 100644 --- a/libsqlitepp/sqlite-selectcommand.cpp +++ b/libsqlitepp/sqlite-selectcommand.cpp @@ -30,7 +30,7 @@ namespace SQLite { { auto t = sqlite3_column_text(stmt, colNo); auto l = sqlite3_column_bytes(stmt, colNo); - h.string(reinterpret_cast(t), l); + h.string({ reinterpret_cast(t), (std::size_t)l }); return; } case SQLITE_NULL: @@ -66,7 +66,7 @@ SQLite::SelectCommand::fetch() case SQLITE_ROW: if (!columnCount()) { for (int c = sqlite3_data_count(stmt) - 1; c >= 0; c -= 1) { - insertColumn(std::make_shared(sqlite3_column_name(stmt, c), c, stmt)); + insertColumn(std::make_unique(sqlite3_column_name(stmt, c), c, stmt)); } } return true; -- cgit v1.2.3