summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-02-04 16:57:11 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2019-02-04 19:59:56 +0000
commit7e70a20a99ec44be63973a64ed5138c7a732a20d (patch)
tree0a96adb728fd33bb0cab6ec4d6dfef20da6932c1
parentUpdate PQ test submodule (diff)
downloadlibdbpp-7e70a20a99ec44be63973a64ed5138c7a732a20d.tar.bz2
libdbpp-7e70a20a99ec44be63973a64ed5138c7a732a20d.tar.xz
libdbpp-7e70a20a99ec44be63973a64ed5138c7a732a20d.zip
Switch to string_view
-rw-r--r--libdbpp/column.h4
-rw-r--r--libdbpp/command.cpp4
-rw-r--r--libdbpp/command.h7
-rw-r--r--libdbpp/testCore.cpp6
-rw-r--r--libdbpp/testCore.h2
m---------libdbpp/unittests/libdbpp-postgresql0
6 files changed, 15 insertions, 8 deletions
diff --git a/libdbpp/column.h b/libdbpp/column.h
index 1c76710..ae7634f 100644
--- a/libdbpp/column.h
+++ b/libdbpp/column.h
@@ -17,7 +17,7 @@ namespace DB {
/// The field is null.
virtual void null() = 0;
/// The field contains text data.
- virtual void string(const char *, size_t len) = 0;
+ virtual void string(std::string_view) = 0;
/// The field is an integer.
virtual void integer(int64_t) = 0;
/// The field is a boolean/bit.
@@ -65,7 +65,7 @@ namespace DB {
void floatingpoint(double v) override { (*this)(v); }
void integer(int64_t v) override { (*this)(v); }
void boolean(bool v) override { (*this)(v); }
- void string(const char * v, size_t len) override { (*this)(std::string_view(v, len)); }
+ void string(const std::string_view v) override { (*this)(v); }
void timestamp(const boost::posix_time::ptime & v) override { (*this)(v); }
void interval(const boost::posix_time::time_duration & v) override { (*this)(v); }
void blob(const Blob & v) override { (*this)(v); }
diff --git a/libdbpp/command.cpp b/libdbpp/command.cpp
index 3c914f8..551f4bc 100644
--- a/libdbpp/command.cpp
+++ b/libdbpp/command.cpp
@@ -36,7 +36,7 @@ void
DB::Command::bindParamS(unsigned int i, const char * const o)
{
if (o)
- bindParamS(i, Glib::ustring(o));
+ bindParamS(i, std::string_view(o));
else
bindNull(i);
}
@@ -46,7 +46,7 @@ void
DB::Command::bindParamS(unsigned int i, char * const o)
{
if (o)
- bindParamS(i, Glib::ustring(o));
+ bindParamS(i, std::string_view(o));
else
bindNull(i);
}
diff --git a/libdbpp/command.h b/libdbpp/command.h
index eed0561..f200d69 100644
--- a/libdbpp/command.h
+++ b/libdbpp/command.h
@@ -81,6 +81,13 @@ namespace DB {
/// Bind a string to parameter i.
virtual void bindParamS(unsigned int i, const Glib::ustring &) = 0;
+ /// Bind a string_view to parameter i.
+ virtual void bindParamS(unsigned int i, const std::string_view &) = 0;
+ /// Bind a string to parameter i (wraps string_view).
+ inline void bindParamS(unsigned int i, const std::string & v)
+ {
+ bindParamS(i, std::string_view(v));
+ }
/// Bind a duration to parameter i.
virtual void bindParamT(unsigned int i, const boost::posix_time::time_duration &) = 0;
diff --git a/libdbpp/testCore.cpp b/libdbpp/testCore.cpp
index b55d16d..d142000 100644
--- a/libdbpp/testCore.cpp
+++ b/libdbpp/testCore.cpp
@@ -24,7 +24,7 @@ class Assert : public DB::HandleField {
void floatingpoint(double v) override { (*this)(v); }
void integer(int64_t v) override { (*this)(v); }
void boolean(bool v) override { (*this)(v); }
- void string(const char * v, size_t len) override { (*this)(std::string(v, len)); }
+ void string(const std::string_view v) override { (*this)(v); }
void timestamp(const boost::posix_time::ptime & v) override { (*this)(v); }
void interval(const boost::posix_time::time_duration & v) override { (*this)(v); }
void blob(const Blob & v) override { (*this)(v); }
@@ -72,7 +72,7 @@ template void TestCore::assertScalarValueHelper<bool>(SelectCommand &, const boo
template void TestCore::assertScalarValueHelper<int64_t>(SelectCommand &, const int64_t &) const;
template void TestCore::assertScalarValueHelper<int>(SelectCommand &, const int &) const;
template void TestCore::assertScalarValueHelper<double>(SelectCommand &, const double &) const;
-template void TestCore::assertScalarValueHelper<std::string>(SelectCommand &, const std::string &) const;
+template void TestCore::assertScalarValueHelper<std::string_view>(SelectCommand &, const std::string_view &) const;
template void TestCore::assertScalarValueHelper<boost::posix_time::ptime>(SelectCommand &, const boost::posix_time::ptime &) const;
template void TestCore::assertScalarValueHelper<boost::posix_time::time_duration>(SelectCommand &, const boost::posix_time::time_duration &) const;
template void TestCore::assertScalarValueHelper<DB::Blob>(SelectCommand &, const DB::Blob &) const;
@@ -81,7 +81,7 @@ template void TestCore::assertColumnValueHelper<bool>(SelectCommand &, unsigned
template void TestCore::assertColumnValueHelper<int>(SelectCommand &, unsigned int, const int &) const;
template void TestCore::assertColumnValueHelper<int64_t>(SelectCommand &, unsigned int, const int64_t &) const;
template void TestCore::assertColumnValueHelper<double>(SelectCommand &, unsigned int, const double &) const;
-template void TestCore::assertColumnValueHelper<std::string>(SelectCommand &, unsigned int, const std::string &) const;
+template void TestCore::assertColumnValueHelper<std::string_view>(SelectCommand &, unsigned int, const std::string_view &) const;
template void TestCore::assertColumnValueHelper<boost::posix_time::ptime>(SelectCommand &, unsigned int, const boost::posix_time::ptime &) const;
template void TestCore::assertColumnValueHelper<boost::posix_time::time_duration>(SelectCommand &, unsigned int, const boost::posix_time::time_duration &) const;
template void TestCore::assertColumnValueHelper<DB::Blob>(SelectCommand &, unsigned int, const DB::Blob &) const;
diff --git a/libdbpp/testCore.h b/libdbpp/testCore.h
index c51e2f9..71bd732 100644
--- a/libdbpp/testCore.h
+++ b/libdbpp/testCore.h
@@ -15,7 +15,7 @@ class DLL_PUBLIC TestCore {
int64_t testInt;
double testDouble;
- std::string testString;
+ std::string_view testString;
bool testBool;
boost::posix_time::ptime testDateTime;
boost::posix_time::time_duration testInterval;
diff --git a/libdbpp/unittests/libdbpp-postgresql b/libdbpp/unittests/libdbpp-postgresql
-Subproject 8000e52bd39ecce1c31feffdde435853bde48e9
+Subproject 36d1ebb68359d7faa194a1f62c17011b462a3a1