summaryrefslogtreecommitdiff
path: root/libodbcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libodbcpp')
-rw-r--r--libodbcpp/Jamfile.jam1
-rw-r--r--libodbcpp/odbc-column.cpp2
-rw-r--r--libodbcpp/odbc-command.h1
-rw-r--r--libodbcpp/odbc-mock.cpp2
-rw-r--r--libodbcpp/odbc-mock.h4
-rw-r--r--libodbcpp/odbc-param.cpp18
-rw-r--r--libodbcpp/odbc-param.h11
-rw-r--r--libodbcpp/odbc-selectcommand.cpp20
-rw-r--r--libodbcpp/odbc-selectcommand.h2
-rw-r--r--libodbcpp/unittests/Jamfile.jam6
-rw-r--r--libodbcpp/unittests/testodbc.cpp2
11 files changed, 41 insertions, 28 deletions
diff --git a/libodbcpp/Jamfile.jam b/libodbcpp/Jamfile.jam
index af25db4..2b54e33 100644
--- a/libodbcpp/Jamfile.jam
+++ b/libodbcpp/Jamfile.jam
@@ -13,7 +13,6 @@ lib dbpp-odbc :
<library>adhocutil
<library>dbppcore
<library>boost_date_time
- <library>boost_system
: :
<include>.
<library>..//glibmm
diff --git a/libodbcpp/odbc-column.cpp b/libodbcpp/odbc-column.cpp
index 18926f5..f51aad5 100644
--- a/libodbcpp/odbc-column.cpp
+++ b/libodbcpp/odbc-column.cpp
@@ -82,7 +82,7 @@ void
ODBC::CharArrayColumn::apply(DB::HandleField & h) const
{
if (isNull()) return h.null();
- h.string(&data.front(), bindLen);
+ h.string({ data.data(), (std::size_t)bindLen });
}
void
ODBC::TimeStampColumn::apply(DB::HandleField & h) const
diff --git a/libodbcpp/odbc-command.h b/libodbcpp/odbc-command.h
index ab3f65b..a3a4338 100644
--- a/libodbcpp/odbc-command.h
+++ b/libodbcpp/odbc-command.h
@@ -27,6 +27,7 @@ namespace ODBC {
void bindParamF(unsigned int i, float val) override;
void bindParamS(unsigned int i, const Glib::ustring &) override;
+ void bindParamS(unsigned int i, const std::string_view &) override;
void bindParamT(unsigned int i, const boost::posix_time::time_duration &) override;
void bindParamT(unsigned int i, const boost::posix_time::ptime &) override;
diff --git a/libodbcpp/odbc-mock.cpp b/libodbcpp/odbc-mock.cpp
index cf28570..f8386e7 100644
--- a/libodbcpp/odbc-mock.cpp
+++ b/libodbcpp/odbc-mock.cpp
@@ -4,7 +4,7 @@
namespace ODBC {
-Mock::Mock(const std::string & b, const std::string & masterdb, const std::string & name, const std::vector<boost::filesystem::path> & ss) :
+Mock::Mock(const std::string & b, const std::string & masterdb, const std::string & name, const std::vector<std::filesystem::path> & ss) :
MockServerDatabase(b + ";" + masterdb, name, "odbc"),
base(b)
{
diff --git a/libodbcpp/odbc-mock.h b/libodbcpp/odbc-mock.h
index 442e3d7..8fc2974 100644
--- a/libodbcpp/odbc-mock.h
+++ b/libodbcpp/odbc-mock.h
@@ -2,14 +2,14 @@
#define MOCKODBCDATASOURCE_H
#include <mockDatabase.h>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include <visibility.h>
namespace ODBC {
class DLL_PUBLIC Mock : public DB::MockServerDatabase {
public:
- Mock(const std::string & base, const std::string & master, const std::string & name, const std::vector<boost::filesystem::path> & ss);
+ Mock(const std::string & base, const std::string & master, const std::string & name, const std::vector<std::filesystem::path> & ss);
~Mock();
const std::string base;
diff --git a/libodbcpp/odbc-param.cpp b/libodbcpp/odbc-param.cpp
index f165d60..120703e 100644
--- a/libodbcpp/odbc-param.cpp
+++ b/libodbcpp/odbc-param.cpp
@@ -74,7 +74,8 @@ SIMPLEBINDER(bool, BooleanParam, B);
SIMPLEBINDER(double, FloatingPointParam, F);
SIMPLEBINDER(float, FloatingPointParam, F);
-SIMPLEBINDER(const Glib::ustring &, GlibUstringParam, S);
+SIMPLEBINDER(const Glib::ustring &, StdStringParam, S);
+SIMPLEBINDER(const std::string_view &, StdStringParam, S);
SIMPLEBINDER(const boost::posix_time::ptime &, TimeStampParam, T);
SIMPLEBINDER(const boost::posix_time::time_duration &, IntervalParam, T);
@@ -86,7 +87,7 @@ ODBC::Command::bindNull(unsigned int i)
}
void
-ODBC::GlibUstringParam::operator=(Glib::ustring const & d)
+ODBC::StdStringParam::operator=(Glib::ustring const & d)
{
const char * addr = data.data();
data = d;
@@ -99,6 +100,19 @@ ODBC::GlibUstringParam::operator=(Glib::ustring const & d)
}
void
+ODBC::StdStringParam::operator=(std::string_view const & d)
+{
+ const char * addr = data.data();
+ data = d;
+ bindLen = d.length();
+ paramBound &= (addr == data.data());
+ if (!paramBound) {
+ paramBound = false;
+ bind();
+ }
+}
+
+void
ODBC::TimeStampParam::operator=(const boost::posix_time::ptime & d)
{
data.year = d.date().year();
diff --git a/libodbcpp/odbc-param.h b/libodbcpp/odbc-param.h
index 96ab7f3..0981fe9 100644
--- a/libodbcpp/odbc-param.h
+++ b/libodbcpp/odbc-param.h
@@ -80,18 +80,19 @@ namespace ODBC {
protected:
SQLDOUBLE data;
};
- class GlibUstringParam : public Param {
+ class StdStringParam : public Param {
public:
- GlibUstringParam() : Param() { }
- GlibUstringParam(Command * c, unsigned int i) : Param(c, i) { bindLen = size(); }
+ StdStringParam() : Param() { }
+ StdStringParam(Command * c, unsigned int i) : Param(c, i) { bindLen = size(); }
virtual SQLSMALLINT ctype() const override { return SQL_C_CHAR; }
virtual SQLSMALLINT stype() const override { return SQL_CHAR; }
- virtual SQLULEN size() const override { return data.bytes(); }
+ virtual SQLULEN size() const override { return data.length(); }
virtual SQLINTEGER dp() const override { return 0; }
virtual const void * dataAddress() const override { return data.data(); }
+ void operator=(const std::string_view & d);
void operator=(const Glib::ustring & d);
protected:
- Glib::ustring data;
+ std::string data;
};
class IntervalParam : public Param {
public:
diff --git a/libodbcpp/odbc-selectcommand.cpp b/libodbcpp/odbc-selectcommand.cpp
index 5e26053..01da513 100644
--- a/libodbcpp/odbc-selectcommand.cpp
+++ b/libodbcpp/odbc-selectcommand.cpp
@@ -50,7 +50,7 @@ ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset)
fprintf(stderr, "truncation\n");
}
}
- // fall-through
+ [[ fallthrough ]];
case SQL_SUCCESS:
{
bool resized = false;
@@ -88,20 +88,20 @@ ODBC::SelectCommand::execute()
throw Error(rc, SQL_HANDLE_STMT, hStmt);
}
Glib::ustring colName((const char *)_colName, nameLen);
- DB::ColumnPtr ncol;
+ DB::Column * ncol;
switch (bindType) {
case SQL_DECIMAL:
case SQL_NUMERIC:
case SQL_REAL:
case SQL_FLOAT:
case SQL_DOUBLE:
- ncol = insertColumn(std::make_shared<FloatingPointColumn>(this, colName, col));
+ ncol = insertColumn(std::make_unique<FloatingPointColumn>(this, colName, col)).get();
break;
case SQL_SMALLINT:
case SQL_INTEGER:
case SQL_TINYINT:
case SQL_BIGINT:
- ncol = insertColumn(std::make_shared<SignedIntegerColumn>(this, colName, col));
+ ncol = insertColumn(std::make_unique<SignedIntegerColumn>(this, colName, col)).get();
break;
case SQL_TYPE_TIME:
case SQL_INTERVAL_YEAR:
@@ -117,13 +117,13 @@ ODBC::SelectCommand::execute()
case SQL_INTERVAL_HOUR_TO_MINUTE:
case SQL_INTERVAL_HOUR_TO_SECOND:
case SQL_INTERVAL_MINUTE_TO_SECOND:
- ncol = insertColumn(std::make_shared<IntervalColumn>(this, colName, col));
+ ncol = insertColumn(std::make_unique<IntervalColumn>(this, colName, col)).get();
break;
case SQL_TIMESTAMP:
case SQL_DATETIME:
case SQL_TYPE_DATE:
case SQL_TYPE_TIMESTAMP:
- ncol = insertColumn(std::make_shared<TimeStampColumn>(this, colName, col));
+ ncol = insertColumn(std::make_unique<TimeStampColumn>(this, colName, col)).get();
break;
case SQL_UNKNOWN_TYPE:
throw DB::ColumnTypeNotSupported();
@@ -133,12 +133,12 @@ ODBC::SelectCommand::execute()
throw Error(rc, SQL_HANDLE_STMT, hStmt);
}
bindSize = octetSize;
- auto lc = std::make_shared<CharArrayColumn>(this, colName, col, bindSize);
- ncol = insertColumn(lc);
- largeColumns.insert(lc);
+ auto lc = std::make_unique<CharArrayColumn>(this, colName, col, bindSize);
+ largeColumns.insert(lc.get());
+ ncol = insertColumn(std::move(lc)).get();
break;
};
- std::dynamic_pointer_cast<Column>(ncol)->bind();
+ dynamic_cast<Column *>(ncol)->bind();
}
}
diff --git a/libodbcpp/odbc-selectcommand.h b/libodbcpp/odbc-selectcommand.h
index 1c71d57..efa584e 100644
--- a/libodbcpp/odbc-selectcommand.h
+++ b/libodbcpp/odbc-selectcommand.h
@@ -16,7 +16,7 @@ namespace ODBC {
private:
bool fetch(SQLSMALLINT orientation = SQL_FETCH_NEXT, SQLLEN offset = 0);
typedef std::shared_ptr<Column> ColumnPtr;
- typedef std::set<ColumnPtr> Columns;
+ typedef std::set<Column *> Columns;
Columns largeColumns;
};
}
diff --git a/libodbcpp/unittests/Jamfile.jam b/libodbcpp/unittests/Jamfile.jam
index 523c64a..1d9233d 100644
--- a/libodbcpp/unittests/Jamfile.jam
+++ b/libodbcpp/unittests/Jamfile.jam
@@ -3,8 +3,7 @@ import testing ;
path-constant me : . ;
lib boost_utf : : <name>boost_unit_test_framework ;
-lib boost_filesystem ;
-lib boost_system ;
+lib stdc++fs ;
lib dbpptestcore : : : : <include>/usr/include/dbpp ;
run
@@ -16,8 +15,7 @@ run
<library>..//adhocutil
<library>dbpptestcore
<library>boost_utf
- <library>boost_filesystem
- <library>boost_system
+ <library>stdc++fs
:
testodbc
;
diff --git a/libodbcpp/unittests/testodbc.cpp b/libodbcpp/unittests/testodbc.cpp
index 9a810c7..d0373a7 100644
--- a/libodbcpp/unittests/testodbc.cpp
+++ b/libodbcpp/unittests/testodbc.cpp
@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE( bindAndSelectOther )
while (select->fetch()) {
assertColumnValueHelper(*select, 0, 4);
assertColumnValueHelper(*select, 1, 123.45);
- assertColumnValueHelper(*select, 2, std::string("some text"));
+ assertColumnValueHelper(*select, 2, std::string_view("some text"));
// assertColumnValueHelper(*select, 3, true);
assertColumnValueHelper(*select, 4, boost::posix_time::ptime_from_tm({ 3, 6, 23, 27, 3, 115, 0, 0, 0, 0, 0}));
rows += 1;