From 465ea24362ee267cf83909efa0b5cdee689ff1f7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 21 Sep 2021 17:59:41 +0100 Subject: First commit passing IWYU --- libpqpp/pq-binarycolumn.cpp | 6 +++++- libpqpp/pq-binarycolumn.h | 4 ++++ libpqpp/pq-bulkselectcommand.cpp | 8 ++++++-- libpqpp/pq-bulkselectcommand.h | 6 +++--- libpqpp/pq-column.cpp | 14 ++++++++++++-- libpqpp/pq-command.cpp | 16 ++++++++++++---- libpqpp/pq-command.h | 27 +++++++++++++++++++++++---- libpqpp/pq-connection.cpp | 8 ++++++++ libpqpp/pq-connection.h | 6 +++++- libpqpp/pq-cursorselectcommand.cpp | 7 ++++++- libpqpp/pq-cursorselectcommand.h | 5 ++--- libpqpp/pq-error.cpp | 1 + libpqpp/pq-error.h | 4 +++- libpqpp/pq-mock.cpp | 7 ++++++- libpqpp/pq-mock.h | 5 ++++- libpqpp/pq-modifycommand.cpp | 6 +++++- libpqpp/pq-modifycommand.h | 4 +++- libpqpp/pq-prepared.cpp | 7 +++++++ libpqpp/pq-prepared.h | 3 +++ libpqpp/pq-selectbase.cpp | 5 +++++ libpqpp/pq-selectbase.h | 1 + libpqpp/unittests/testpq.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 22 files changed, 160 insertions(+), 28 deletions(-) (limited to 'libpqpp') diff --git a/libpqpp/pq-binarycolumn.cpp b/libpqpp/pq-binarycolumn.cpp index ce4e8c1..0a488f7 100644 --- a/libpqpp/pq-binarycolumn.cpp +++ b/libpqpp/pq-binarycolumn.cpp @@ -1,5 +1,9 @@ #include "pq-binarycolumn.h" -#include "pq-selectbase.h" +#include "column.h" +#include "dbTypes.h" +#include "pq-column.h" +#include +#include #include PQ::BinaryColumn::BinaryColumn(const PQ::SelectBase * s, unsigned int f) : PQ::Column(s, f) { } diff --git a/libpqpp/pq-binarycolumn.h b/libpqpp/pq-binarycolumn.h index 402d0bb..ed6eae7 100644 --- a/libpqpp/pq-binarycolumn.h +++ b/libpqpp/pq-binarycolumn.h @@ -3,7 +3,11 @@ #include "pq-column.h" +namespace DB { + class HandleField; +} namespace PQ { + class SelectBase; class BinaryColumn : public Column { public: BinaryColumn(const SelectBase *, unsigned int field); diff --git a/libpqpp/pq-bulkselectcommand.cpp b/libpqpp/pq-bulkselectcommand.cpp index de2ecb4..8c9e1f0 100644 --- a/libpqpp/pq-bulkselectcommand.cpp +++ b/libpqpp/pq-bulkselectcommand.cpp @@ -1,7 +1,11 @@ #include "pq-bulkselectcommand.h" -#include "pq-column.h" +#include "command.h" +#include "libpq-fe.h" +#include "pq-command.h" #include "pq-connection.h" -#include "pq-error.h" +#include "pq-prepared.h" +#include "pq-selectbase.h" +#include PQ::BulkSelectCommand::BulkSelectCommand(Connection * conn, const std::string & sql, const PQ::CommandOptionsCPtr & pqco, const DB::CommandOptionsCPtr & opts) : diff --git a/libpqpp/pq-bulkselectcommand.h b/libpqpp/pq-bulkselectcommand.h index 9c1c51b..6470905 100644 --- a/libpqpp/pq-bulkselectcommand.h +++ b/libpqpp/pq-bulkselectcommand.h @@ -1,14 +1,14 @@ #ifndef PQ_BULKSELECTCOMMAND_H #define PQ_BULKSELECTCOMMAND_H +#include "command_fwd.h" +#include "pq-command.h" #include "pq-prepared.h" #include "pq-selectbase.h" -#include -#include +#include namespace PQ { class Connection; - class Column; class BulkSelectCommand : public SelectBase, public PreparedStatement { public: BulkSelectCommand(Connection *, const std::string & sql, const PQ::CommandOptionsCPtr & pqco, diff --git a/libpqpp/pq-column.cpp b/libpqpp/pq-column.cpp index c1e0d40..d3f9b11 100644 --- a/libpqpp/pq-column.cpp +++ b/libpqpp/pq-column.cpp @@ -1,8 +1,18 @@ #include "pq-column.h" -#include "pq-error.h" +#include "column.h" +#include "dbTypes.h" #include "pq-selectbase.h" -#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include PQ::Column::Column(const SelectBase * s, unsigned int i) : DB::Column(PQfname(s->execRes, static_cast(i)), i), sc(s), oid(PQftype(sc->execRes, static_cast(colNo))), diff --git a/libpqpp/pq-command.cpp b/libpqpp/pq-command.cpp index aaa8260..37de3b0 100644 --- a/libpqpp/pq-command.cpp +++ b/libpqpp/pq-command.cpp @@ -1,10 +1,18 @@ #include "pq-command.h" -#include "pq-connection.h" -#include +#include +#include #include -#include -#include +#include #include +#include +#include + +namespace Glib { + class ustring; +} +namespace PQ { + class Connection; +} NAMEDFACTORY("postgresql", PQ::CommandOptions, DB::CommandOptionsFactory) diff --git a/libpqpp/pq-command.h b/libpqpp/pq-command.h index 839c991..7e8cd94 100644 --- a/libpqpp/pq-command.h +++ b/libpqpp/pq-command.h @@ -1,16 +1,35 @@ #ifndef PQ_COMMAND_H #define PQ_COMMAND_H +#include "command.h" #include "pq-connection.h" -#include -#include #include #include #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#ifndef __clang__ +# pragma GCC diagnostic ignored "-Wuseless-cast" +#endif +#include +#pragma GCC diagnostic pop +#include "command_fwd.h" +#include +#include +#include +#include +#include +#include -namespace PQ { - class Connection; +namespace DB { + class Blob; +} +namespace boost::posix_time { + class time_duration; +} +namespace PQ { class DLL_PUBLIC CommandOptions : public DB::CommandOptions { public: CommandOptions(std::size_t, const DB::CommandOptionsMap &); diff --git a/libpqpp/pq-connection.cpp b/libpqpp/pq-connection.cpp index 4b201f5..049ca8c 100644 --- a/libpqpp/pq-connection.cpp +++ b/libpqpp/pq-connection.cpp @@ -1,10 +1,18 @@ #include "pq-connection.h" +#include "column.h" +#include "command.h" +#include "connection.h" #include "pq-bulkselectcommand.h" +#include "pq-command.h" #include "pq-cursorselectcommand.h" #include "pq-error.h" #include "pq-modifycommand.h" +#include "selectcommand.h" #include #include +#include +#include +#include #include #include diff --git a/libpqpp/pq-connection.h b/libpqpp/pq-connection.h index ec1ae81..83da2d4 100644 --- a/libpqpp/pq-connection.h +++ b/libpqpp/pq-connection.h @@ -1,11 +1,15 @@ #ifndef PQ_CONNECTION_H #define PQ_CONNECTION_H +#include "command_fwd.h" #include "pq-error.h" #include #include +#include +#include #include -#include +#include +#include #include namespace PQ { diff --git a/libpqpp/pq-cursorselectcommand.cpp b/libpqpp/pq-cursorselectcommand.cpp index 9ae9655..da0a95b 100644 --- a/libpqpp/pq-cursorselectcommand.cpp +++ b/libpqpp/pq-cursorselectcommand.cpp @@ -1,7 +1,12 @@ #include "pq-cursorselectcommand.h" +#include "command.h" +#include "pq-command.h" #include "pq-connection.h" -#include "pq-error.h" +#include "pq-selectbase.h" #include +#include +#include +#include AdHocFormatter(PQCursorSelectDeclare, "DECLARE %? NO SCROLL CURSOR WITH HOLD FOR "); AdHocFormatter(PQCursorSelectFetch, "FETCH %? IN %?"); diff --git a/libpqpp/pq-cursorselectcommand.h b/libpqpp/pq-cursorselectcommand.h index 853be47..36070bc 100644 --- a/libpqpp/pq-cursorselectcommand.h +++ b/libpqpp/pq-cursorselectcommand.h @@ -1,14 +1,13 @@ #ifndef PQ_CURSORSELECTCOMMAND_H #define PQ_CURSORSELECTCOMMAND_H +#include "command_fwd.h" // for CommandOptionsCPtr #include "pq-command.h" #include "pq-selectbase.h" -#include -#include +#include // for string namespace PQ { class Connection; - class Column; class CursorSelectCommand : public SelectBase, public Command { public: CursorSelectCommand( diff --git a/libpqpp/pq-error.cpp b/libpqpp/pq-error.cpp index ca33a26..17b4e0a 100644 --- a/libpqpp/pq-error.cpp +++ b/libpqpp/pq-error.cpp @@ -1,4 +1,5 @@ #include "pq-error.h" +#include PQ::Error::Error(const PGconn * conn) : msg(PQerrorMessage(conn)) { } diff --git a/libpqpp/pq-error.h b/libpqpp/pq-error.h index 9c14e2d..bc701fa 100644 --- a/libpqpp/pq-error.h +++ b/libpqpp/pq-error.h @@ -1,9 +1,11 @@ #ifndef PQ_ERROR_H #define PQ_ERROR_H -#include +#include "error.h" // IWYU pragma: export #include #include +#include +// IWYU pragma: no_forward_declare DB::Error namespace PQ { class Error : public AdHoc::Exception { diff --git a/libpqpp/pq-mock.cpp b/libpqpp/pq-mock.cpp index fcff52e..748a350 100644 --- a/libpqpp/pq-mock.cpp +++ b/libpqpp/pq-mock.cpp @@ -1,10 +1,15 @@ #include "pq-mock.h" +#include "connection.h" +#include "mockDatabase.h" #include "pq-connection.h" -#include +#include #include +#include +#include #include #include #include +// IWYU pragma: no_include NAMEDFACTORY("postgresql", PQ::Mock, DB::MockDatabaseFactory) diff --git a/libpqpp/pq-mock.h b/libpqpp/pq-mock.h index a8d9143..2cb6b68 100644 --- a/libpqpp/pq-mock.h +++ b/libpqpp/pq-mock.h @@ -1,9 +1,12 @@ #ifndef MOCKPQDATASOURCE_H #define MOCKPQDATASOURCE_H -#include "pq-connection.h" +#include "connection_fwd.h" +#include #include #include +#include +#include #include namespace PQ { diff --git a/libpqpp/pq-modifycommand.cpp b/libpqpp/pq-modifycommand.cpp index 8697b10..38c10f6 100644 --- a/libpqpp/pq-modifycommand.cpp +++ b/libpqpp/pq-modifycommand.cpp @@ -1,7 +1,11 @@ #include "pq-modifycommand.h" +#include "command.h" +#include "modifycommand.h" #include "pq-connection.h" -#include "pq-error.h" +#include "pq-prepared.h" #include +#include +#include PQ::ModifyCommand::ModifyCommand(Connection * conn, const std::string & sql, const DB::CommandOptionsCPtr & opts) : DB::Command(sql), DB::ModifyCommand(sql), PQ::PreparedStatement(conn, sql, opts) diff --git a/libpqpp/pq-modifycommand.h b/libpqpp/pq-modifycommand.h index 36de37a..cc4ce7b 100644 --- a/libpqpp/pq-modifycommand.h +++ b/libpqpp/pq-modifycommand.h @@ -1,11 +1,13 @@ #ifndef PQ_MODIFYCOMMAND_H #define PQ_MODIFYCOMMAND_H -#include "pq-connection.h" +#include "command_fwd.h" #include "pq-prepared.h" #include +#include namespace PQ { + class Connection; class ModifyCommand : public DB::ModifyCommand, public PreparedStatement { public: ModifyCommand(Connection *, const std::string & sql, const DB::CommandOptionsCPtr &); diff --git a/libpqpp/pq-prepared.cpp b/libpqpp/pq-prepared.cpp index 640b3db..78ad285 100644 --- a/libpqpp/pq-prepared.cpp +++ b/libpqpp/pq-prepared.cpp @@ -1,5 +1,12 @@ #include "pq-prepared.h" +#include "command.h" +#include "pq-command.h" #include "pq-connection.h" +#include +#include +#include +#include +#include PQ::PreparedStatement::PreparedStatement(Connection * c, const std::string & sql, const DB::CommandOptionsCPtr & opts) : DB::Command(sql), Command(c, sql, opts), pstmt(nullptr) diff --git a/libpqpp/pq-prepared.h b/libpqpp/pq-prepared.h index 6d32f5f..bf88f9e 100644 --- a/libpqpp/pq-prepared.h +++ b/libpqpp/pq-prepared.h @@ -1,9 +1,12 @@ #ifndef stuff #define stuff +#include "command_fwd.h" #include "pq-command.h" +#include namespace PQ { + class Connection; class PreparedStatement : public Command { protected: PreparedStatement(Connection *, const std::string &, const DB::CommandOptionsCPtr &); diff --git a/libpqpp/pq-selectbase.cpp b/libpqpp/pq-selectbase.cpp index 4d4cada..d884d06 100644 --- a/libpqpp/pq-selectbase.cpp +++ b/libpqpp/pq-selectbase.cpp @@ -1,7 +1,12 @@ #include "pq-selectbase.h" +#include "command.h" #include "pq-binarycolumn.h" #include "pq-column.h" #include "pq-command.h" +#include +#include +#include +#include PQ::SelectBase::SelectBase(const std::string & sql, const PQ::CommandOptionsCPtr & pqco) : DB::Command(sql), DB::SelectCommand(sql), nTuples(0), tuple(0), execRes(nullptr), diff --git a/libpqpp/pq-selectbase.h b/libpqpp/pq-selectbase.h index 87dcc9d..19bef7a 100644 --- a/libpqpp/pq-selectbase.h +++ b/libpqpp/pq-selectbase.h @@ -4,6 +4,7 @@ #include "pq-command.h" #include #include +#include namespace PQ { class SelectBase : public DB::SelectCommand { diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp index 2314fb9..ba7fb6b 100644 --- a/libpqpp/unittests/testpq.cpp +++ b/libpqpp/unittests/testpq.cpp @@ -1,19 +1,53 @@ #define BOOST_TEST_MODULE TestPQ #include -#include +#include "command_fwd.h" +#include "connection.h" +#include "dbTypes.h" +#include "mockDatabase.h" +#include +#include +#include +#include // IWYU pragma: keep +#include +#include +#include +#include #include +#include +#include +#include #include +#include #include #include +#include +#include #include +#include #include #include -#include #include #include #include +#include +#include +#include #include +#include +#include +#include +#include + +namespace DB { + class ColumnTypeNotSupported; +} +namespace DB { + class Error; +} +namespace boost::posix_time { + class time_duration; +} class StandardMockDatabase : public DB::PluginMock { public: -- cgit v1.2.3