summaryrefslogtreecommitdiff
path: root/libpqpp/pq-command.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-10-08 14:44:46 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-10-08 14:44:46 +0100
commit5ff1709a9e039ec155caecd6d0ea3c512f4be3cb (patch)
treec93c1e7c30bfae1b634911af0395ea9d5a40ea4e /libpqpp/pq-command.cpp
parentUse proper defines for column types (diff)
downloadlibdbpp-postgresql-5ff1709a9e039ec155caecd6d0ea3c512f4be3cb.tar.bz2
libdbpp-postgresql-5ff1709a9e039ec155caecd6d0ea3c512f4be3cb.tar.xz
libdbpp-postgresql-5ff1709a9e039ec155caecd6d0ea3c512f4be3cb.zip
Reformat with new clang-format
Diffstat (limited to 'libpqpp/pq-command.cpp')
-rw-r--r--libpqpp/pq-command.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/libpqpp/pq-command.cpp b/libpqpp/pq-command.cpp
index e366c51..3e359c0 100644
--- a/libpqpp/pq-command.cpp
+++ b/libpqpp/pq-command.cpp
@@ -8,6 +8,7 @@
namespace Glib {
class ustring;
}
+
namespace PQ {
class Connection;
}
@@ -15,6 +16,7 @@ namespace PQ {
NAMEDFACTORY("postgresql", PQ::CommandOptions, DB::CommandOptionsFactory)
AdHocFormatter(PQCommondStatement, "pStatement_id%?");
+
PQ::Command::Command(Connection * conn, const std::string & sql, const DB::CommandOptionsCPtr & opts) :
DB::Command(sql), hash(opts && opts->hash ? *opts->hash : std::hash<std::string>()(sql)),
stmntName(PQCommondStatement::get(hash)), c(conn)
@@ -33,6 +35,7 @@ PQ::CommandOptions::CommandOptions(std::size_t hash, unsigned int ft, bool uc, b
}
AdHocFormatter(PQCommandParamName, "$%?");
+
void
PQ::Command::prepareSql(std::stringstream & psql, const std::string & sql) const
{
@@ -68,6 +71,7 @@ PQ::Command::paramsAtLeast(unsigned int n)
}
AdHocFormatter(PQCommandParamFmt, "%?");
+
template<typename... T>
void
PQ::Command::paramSet(unsigned int n, T &&... v)
@@ -95,66 +99,79 @@ PQ::Command::bindParamI(unsigned int n, int v)
{
paramSet(n, v);
}
+
void
PQ::Command::bindParamI(unsigned int n, long int v)
{
paramSet(n, v);
}
+
void
PQ::Command::bindParamI(unsigned int n, long long int v)
{
paramSet(n, v);
}
+
void
PQ::Command::bindParamI(unsigned int n, unsigned int v)
{
paramSet(n, v);
}
+
void
PQ::Command::bindParamI(unsigned int n, long unsigned int v)
{
paramSet(n, v);
}
+
void
PQ::Command::bindParamI(unsigned int n, long long unsigned int v)
{
paramSet(n, v);
}
+
void
PQ::Command::bindParamB(unsigned int n, bool v)
{
paramSet(n, v);
}
+
void
PQ::Command::bindParamF(unsigned int n, double v)
{
paramSet(n, v);
}
+
void
PQ::Command::bindParamF(unsigned int n, float v)
{
paramSet(n, v);
}
+
void
PQ::Command::bindParamS(unsigned int n, const Glib::ustring & s)
{
paramSet(n, std::string_view(s.data(), s.bytes()));
}
+
void
PQ::Command::bindParamS(unsigned int n, const std::string_view s)
{
paramSet(n, s);
}
+
void
PQ::Command::bindParamT(unsigned int n, const boost::posix_time::time_duration v)
{
paramSet(n, boost::posix_time::to_simple_string(v));
}
+
void
PQ::Command::bindParamT(unsigned int n, const boost::posix_time::ptime v)
{
paramSet(n, boost::posix_time::to_iso_extended_string(v));
}
+
void
PQ::Command::bindParamBLOB(unsigned int n, const DB::Blob & v)
{
@@ -164,6 +181,7 @@ PQ::Command::bindParamBLOB(unsigned int n, const DB::Blob & v)
values[n] = static_cast<const char *>(v.data);
bufs[n].reset();
}
+
void
PQ::Command::bindNull(unsigned int n)
{