diff options
Diffstat (limited to 'libpqpp/pq-command.cpp')
-rw-r--r-- | libpqpp/pq-command.cpp | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/libpqpp/pq-command.cpp b/libpqpp/pq-command.cpp index 3e359c0..550520c 100644 --- a/libpqpp/pq-command.cpp +++ b/libpqpp/pq-command.cpp @@ -24,13 +24,13 @@ PQ::Command::Command(Connection * conn, const std::string & sql, const DB::Comma } PQ::CommandOptions::CommandOptions(std::size_t hash, const DB::CommandOptionsMap & map) : - DB::CommandOptions(hash), fetchTuples(get(map, "page-size", 35U)), useCursor(!isSet(map, "no-cursor")), - fetchBinary(isSet(map, "fetch-binary")) + DB::CommandOptions(hash), fetchTuples(get(map, "page-size", DEFAULT_FETCH_TUPLES)), + useCursor(!isSet(map, "no-cursor")), fetchBinary(isSet(map, "fetch-binary")) { } -PQ::CommandOptions::CommandOptions(std::size_t hash, unsigned int ft, bool uc, bool fb) : - DB::CommandOptions(hash), fetchTuples(ft), useCursor(uc), fetchBinary(fb) +PQ::CommandOptions::CommandOptions(std::size_t hash, unsigned int fetchTuples, bool useCursor, bool fetchBinary) : + DB::CommandOptions(hash), fetchTuples(fetchTuples), useCursor(useCursor), fetchBinary(fetchBinary) { } @@ -43,18 +43,18 @@ PQ::Command::prepareSql(std::stringstream & psql, const std::string & sql) const psql << sql; return; } - int p = 1; + int paramNo = 1; bool inquote = false; - for (const auto & i : sql) { - if (i == '?' && !inquote) { - PQCommandParamName::write(psql, p++); + for (const auto & sqlChr : sql) { + if (sqlChr == '?' && !inquote) { + PQCommandParamName::write(psql, paramNo++); } - else if (i == '\'') { + else if (sqlChr == '\'') { inquote = !inquote; - psql << i; + psql << sqlChr; } else { - psql << i; + psql << sqlChr; } } } @@ -74,111 +74,111 @@ AdHocFormatter(PQCommandParamFmt, "%?"); template<typename... T> void -PQ::Command::paramSet(unsigned int n, T &&... v) +PQ::Command::paramSet(unsigned int n, T &&... paramValues) { paramsAtLeast(n); // cppcheck-suppress constStatement - bufs[n] = std::make_unique<std::string>(PQCommandParamFmt::get(std::forward<T>(v)...)); + bufs[n] = std::make_unique<std::string>(PQCommandParamFmt::get(std::forward<T>(paramValues)...)); lengths[n] = static_cast<int>(bufs[n]->length()); formats[n] = 0; values[n] = bufs[n]->data(); } void -PQ::Command::paramSet(unsigned int n, const std::string_view b) +PQ::Command::paramSet(unsigned int n, const std::string_view paramValue) { paramsAtLeast(n); - bufs[n] = std::make_unique<std::string>(b); - lengths[n] = static_cast<int>(b.length()); + bufs[n] = std::make_unique<std::string>(paramValue); + lengths[n] = static_cast<int>(paramValue.length()); formats[n] = 0; values[n] = bufs[n]->data(); } void -PQ::Command::bindParamI(unsigned int n, int v) +PQ::Command::bindParamI(unsigned int n, int paramValue) { - paramSet(n, v); + paramSet(n, paramValue); } void -PQ::Command::bindParamI(unsigned int n, long int v) +PQ::Command::bindParamI(unsigned int n, long int paramValue) { - paramSet(n, v); + paramSet(n, paramValue); } void -PQ::Command::bindParamI(unsigned int n, long long int v) +PQ::Command::bindParamI(unsigned int n, long long int paramValue) { - paramSet(n, v); + paramSet(n, paramValue); } void -PQ::Command::bindParamI(unsigned int n, unsigned int v) +PQ::Command::bindParamI(unsigned int n, unsigned int paramValue) { - paramSet(n, v); + paramSet(n, paramValue); } void -PQ::Command::bindParamI(unsigned int n, long unsigned int v) +PQ::Command::bindParamI(unsigned int n, long unsigned int paramValue) { - paramSet(n, v); + paramSet(n, paramValue); } void -PQ::Command::bindParamI(unsigned int n, long long unsigned int v) +PQ::Command::bindParamI(unsigned int n, long long unsigned int paramValue) { - paramSet(n, v); + paramSet(n, paramValue); } void -PQ::Command::bindParamB(unsigned int n, bool v) +PQ::Command::bindParamB(unsigned int n, bool paramValue) { - paramSet(n, v); + paramSet(n, paramValue); } void -PQ::Command::bindParamF(unsigned int n, double v) +PQ::Command::bindParamF(unsigned int n, double paramValue) { - paramSet(n, v); + paramSet(n, paramValue); } void -PQ::Command::bindParamF(unsigned int n, float v) +PQ::Command::bindParamF(unsigned int n, float paramValue) { - paramSet(n, v); + paramSet(n, paramValue); } void -PQ::Command::bindParamS(unsigned int n, const Glib::ustring & s) +PQ::Command::bindParamS(unsigned int n, const Glib::ustring & paramValue) { - paramSet(n, std::string_view(s.data(), s.bytes())); + paramSet(n, std::string_view(paramValue.data(), paramValue.bytes())); } void -PQ::Command::bindParamS(unsigned int n, const std::string_view s) +PQ::Command::bindParamS(unsigned int n, const std::string_view paramValue) { - paramSet(n, s); + paramSet(n, paramValue); } void -PQ::Command::bindParamT(unsigned int n, const boost::posix_time::time_duration v) +PQ::Command::bindParamT(unsigned int n, const boost::posix_time::time_duration paramValue) { - paramSet(n, boost::posix_time::to_simple_string(v)); + paramSet(n, boost::posix_time::to_simple_string(paramValue)); } void -PQ::Command::bindParamT(unsigned int n, const boost::posix_time::ptime v) +PQ::Command::bindParamT(unsigned int n, const boost::posix_time::ptime paramValue) { - paramSet(n, boost::posix_time::to_iso_extended_string(v)); + paramSet(n, boost::posix_time::to_iso_extended_string(paramValue)); } void -PQ::Command::bindParamBLOB(unsigned int n, const DB::Blob & v) +PQ::Command::bindParamBLOB(unsigned int n, const DB::Blob & paramValue) { paramsAtLeast(n); - lengths[n] = static_cast<int>(v.len); + lengths[n] = static_cast<int>(paramValue.len); formats[n] = 1; - values[n] = static_cast<const char *>(v.data); + values[n] = static_cast<const char *>(paramValue.data); bufs[n].reset(); } |