From 1ca0cd42419656cf4a4b9e37c5f3cfb51ccafbb5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 16 Feb 2019 14:20:14 +0000 Subject: Modernize clang tidy fixes --- libpqpp/pq-bulkselectcommand.cpp | 2 +- libpqpp/pq-column.cpp | 2 +- libpqpp/pq-command.cpp | 4 ++-- libpqpp/pq-connection.cpp | 2 +- libpqpp/pq-cursorselectcommand.cpp | 8 ++++---- libpqpp/pq-error.cpp | 3 +-- libpqpp/pq-error.h | 2 +- libpqpp/pq-modifycommand.cpp | 2 +- libpqpp/pq-prepared.cpp | 2 +- libpqpp/pq-selectbase.cpp | 2 +- libpqpp/unittests/testpq.cpp | 6 +++--- 11 files changed, 17 insertions(+), 18 deletions(-) diff --git a/libpqpp/pq-bulkselectcommand.cpp b/libpqpp/pq-bulkselectcommand.cpp index 81f3e48..c098aad 100644 --- a/libpqpp/pq-bulkselectcommand.cpp +++ b/libpqpp/pq-bulkselectcommand.cpp @@ -34,7 +34,7 @@ PQ::BulkSelectCommand::fetch() } else { PQclear(execRes); - execRes = NULL; + execRes = nullptr; executed = false; return false; } diff --git a/libpqpp/pq-column.cpp b/libpqpp/pq-column.cpp index eb5d291..addd002 100644 --- a/libpqpp/pq-column.cpp +++ b/libpqpp/pq-column.cpp @@ -1,7 +1,7 @@ #include "pq-column.h" #include "pq-selectbase.h" #include "pq-error.h" -#include +#include #include PQ::Column::Column(const SelectBase * s, unsigned int i) : diff --git a/libpqpp/pq-command.cpp b/libpqpp/pq-command.cpp index 8857fb5..147d988 100644 --- a/libpqpp/pq-command.cpp +++ b/libpqpp/pq-command.cpp @@ -1,7 +1,7 @@ #include "pq-command.h" #include "pq-connection.h" -#include -#include +#include +#include #include #include #include diff --git a/libpqpp/pq-connection.cpp b/libpqpp/pq-connection.cpp index 4ebda84..f20dfb5 100644 --- a/libpqpp/pq-connection.cpp +++ b/libpqpp/pq-connection.cpp @@ -34,7 +34,7 @@ PQ::Connection::Connection(const std::string & info) : auto dc = std::unique_ptr(conn, &PQfinish); throw ConnectionError(dc.get()); } - PQsetNoticeProcessor(conn, noNoticeProcessor, NULL); + PQsetNoticeProcessor(conn, noNoticeProcessor, nullptr); } PQ::Connection::~Connection() diff --git a/libpqpp/pq-cursorselectcommand.cpp b/libpqpp/pq-cursorselectcommand.cpp index 02c9fce..2873067 100644 --- a/libpqpp/pq-cursorselectcommand.cpp +++ b/libpqpp/pq-cursorselectcommand.cpp @@ -42,7 +42,7 @@ PQ::CursorSelectCommand::execute() s_declare = mkdeclare(); } c->checkResultFree( - PQexecParams(c->conn, s_declare.c_str(), values.size(), NULL, &values.front(), &lengths.front(), &formats.front(), binary), + PQexecParams(c->conn, s_declare.c_str(), values.size(), nullptr, &values.front(), &lengths.front(), &formats.front(), binary), PGRES_COMMAND_OK); fetchTuples(); createColumns(execRes); @@ -53,7 +53,7 @@ PQ::CursorSelectCommand::execute() void PQ::CursorSelectCommand::fetchTuples() { - execRes = c->checkResult(PQexecParams(c->conn, s_fetch.c_str(), 0, NULL, NULL, NULL, NULL, binary), PGRES_TUPLES_OK); + execRes = c->checkResult(PQexecParams(c->conn, s_fetch.c_str(), 0, nullptr, nullptr, nullptr, nullptr, binary), PGRES_TUPLES_OK); nTuples = PQntuples(execRes); tuple = -1; } @@ -65,7 +65,7 @@ PQ::CursorSelectCommand::fetch() if ((tuple >= (nTuples - 1)) && (nTuples == fTuples)) { // Delete the previous result set PQclear(execRes); - execRes = NULL; + execRes = nullptr; fetchTuples(); } if (tuple++ < (nTuples - 1)) { @@ -74,7 +74,7 @@ PQ::CursorSelectCommand::fetch() else { PQclear(PQexec(c->conn, s_close.c_str())); PQclear(execRes); - execRes = NULL; + execRes = nullptr; executed = false; return false; } diff --git a/libpqpp/pq-error.cpp b/libpqpp/pq-error.cpp index 3a16185..964d66b 100644 --- a/libpqpp/pq-error.cpp +++ b/libpqpp/pq-error.cpp @@ -1,5 +1,4 @@ #include "pq-error.h" -#include PQ::Error::Error(const PGconn * conn) : msg(PQerrorMessage(conn)) @@ -7,7 +6,7 @@ PQ::Error::Error(const PGconn * conn) : } std::string -PQ::Error::message() const throw() +PQ::Error::message() const noexcept { return msg; } diff --git a/libpqpp/pq-error.h b/libpqpp/pq-error.h index fdc855b..c9693f7 100644 --- a/libpqpp/pq-error.h +++ b/libpqpp/pq-error.h @@ -10,7 +10,7 @@ namespace PQ { public: Error(const PGconn *); - std::string message() const throw() override; + std::string message() const noexcept override; private: std::string msg; diff --git a/libpqpp/pq-modifycommand.cpp b/libpqpp/pq-modifycommand.cpp index bb21bc7..797c678 100644 --- a/libpqpp/pq-modifycommand.cpp +++ b/libpqpp/pq-modifycommand.cpp @@ -1,6 +1,6 @@ #include "pq-modifycommand.h" #include "pq-error.h" -#include +#include #include "pq-connection.h" PQ::ModifyCommand::ModifyCommand(Connection * conn, const std::string & sql, const DB::CommandOptionsCPtr & opts) : diff --git a/libpqpp/pq-prepared.cpp b/libpqpp/pq-prepared.cpp index 6c447f8..3162349 100644 --- a/libpqpp/pq-prepared.cpp +++ b/libpqpp/pq-prepared.cpp @@ -21,7 +21,7 @@ PQ::PreparedStatement::prepare() const std::stringstream psql; prepareSql(psql, sql); c->checkResultFree(PQprepare( - c->conn, stmntName.c_str(), psql.str().c_str(), values.size(), NULL), PGRES_COMMAND_OK); + c->conn, stmntName.c_str(), psql.str().c_str(), values.size(), nullptr), PGRES_COMMAND_OK); return (pstmt = c->preparedStatements.insert({hash, stmntName}).first->second.c_str()); } diff --git a/libpqpp/pq-selectbase.cpp b/libpqpp/pq-selectbase.cpp index f9a2eb0..0950d37 100644 --- a/libpqpp/pq-selectbase.cpp +++ b/libpqpp/pq-selectbase.cpp @@ -8,7 +8,7 @@ PQ::SelectBase::SelectBase(const std::string & sql, const PQ::CommandOptionsCPtr DB::SelectCommand(sql), nTuples(0), tuple(0), - execRes(NULL), + execRes(nullptr), binary(pqco ? pqco->fetchBinary : false) { } diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp index 0a13c1e..5b584b7 100644 --- a/libpqpp/unittests/testpq.cpp +++ b/libpqpp/unittests/testpq.cpp @@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE( bindAndSelectOther ) assertColumnValueHelper(*select, 1, 123.45); assertColumnValueHelper(*select, 2, std::string_view("some text with a ; in it and a ' too")); assertColumnValueHelper(*select, 3, true); - assertColumnValueHelper(*select, 4, boost::posix_time::ptime_from_tm({ 3, 6, 23, 27, 3, 115, 0, 0, 0, 0, 0})); + assertColumnValueHelper(*select, 4, boost::posix_time::ptime_from_tm({ 3, 6, 23, 27, 3, 115, 0, 0, 0, 0, nullptr})); assertColumnValueHelper(*select, 5, boost::posix_time::time_duration(38, 13, 12)); rows += 1; } @@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE( bulkload ) auto count = ro->select("SELECT COUNT(*) FROM bulktest"); // Test empty ro->beginBulkUpload("bulktest", ""); - ro->endBulkUpload(NULL); + ro->endBulkUpload(nullptr); assertScalarValueHelper(*count, 0); // Test sample file ro->beginBulkUpload("bulktest", ""); @@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE( bulkload ) for (std::streamsize r; (r = in.readsome(buf, sizeof(buf))) > 0; ) { ro->bulkUploadData(buf, r); } - ro->endBulkUpload(NULL); + ro->endBulkUpload(nullptr); assertScalarValueHelper(*count, 800); } -- cgit v1.2.3