From b7f71b71224238a8b7bdb76b6feb98db9bac7aa9 Mon Sep 17 00:00:00 2001
From: Dan Goodliffe <dan@randomdan.homeip.net>
Date: Tue, 21 Sep 2021 17:59:41 +0100
Subject: First commit passing IWYU

---
 libodbcpp/odbc-column.cpp        | 13 ++++++++++---
 libodbcpp/odbc-column.h          |  5 ++++-
 libodbcpp/odbc-command.cpp       |  3 ++-
 libodbcpp/odbc-command.h         | 14 ++++++++++++--
 libodbcpp/odbc-connection.cpp    |  8 ++++++--
 libodbcpp/odbc-connection.h      |  5 +++--
 libodbcpp/odbc-dsn.cpp           |  1 +
 libodbcpp/odbc-error.cpp         |  2 ++
 libodbcpp/odbc-error.h           |  4 ++--
 libodbcpp/odbc-mock.cpp          |  5 +++--
 libodbcpp/odbc-mock.h            |  3 +++
 libodbcpp/odbc-modifycommand.cpp |  4 ++++
 libodbcpp/odbc-modifycommand.h   |  2 ++
 libodbcpp/odbc-param.cpp         | 12 +++++++++++-
 libodbcpp/odbc-param.h           |  9 +++++++--
 libodbcpp/odbc-selectcommand.cpp | 15 ++++++++++++---
 libodbcpp/odbc-selectcommand.h   |  5 +++++
 libodbcpp/unittests/testodbc.cpp | 13 ++++++++++---
 18 files changed, 99 insertions(+), 24 deletions(-)

diff --git a/libodbcpp/odbc-column.cpp b/libodbcpp/odbc-column.cpp
index df22cfb..bddff4b 100644
--- a/libodbcpp/odbc-column.cpp
+++ b/libodbcpp/odbc-column.cpp
@@ -1,10 +1,17 @@
 #include "odbc-column.h"
-#include "odbc-command.h"
+#include "column.h"
 #include "odbc-error.h"
+#include "odbc-param_fwd.h"
 #include "odbc-selectcommand.h"
+#include <boost/date_time/gregorian/greg_date.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/date_time/posix_time/ptime.hpp>
+#include <boost/date_time/time_duration.hpp>
 #include <cstdio>
-#include <cstdlib>
-#include <sqlext.h>
+
+namespace Glib {
+	class ustring;
+}
 
 ODBC::Column::Column(SelectCommand * sc, const Glib::ustring & s, unsigned int i) : DB::Column(s, i), selectCmd(sc)
 {
diff --git a/libodbcpp/odbc-column.h b/libodbcpp/odbc-column.h
index bef5d9d..e02649c 100644
--- a/libodbcpp/odbc-column.h
+++ b/libodbcpp/odbc-column.h
@@ -3,10 +3,13 @@
 
 #include "odbc-bind.h"
 #include "odbc-param.h"
+#include "odbc-param_fwd.h"
 #include <algorithm>
 #include <column.h>
 #include <glibmm/ustring.h>
-#include <typeinfo>
+#include <sql.h>
+#include <sqlext.h>
+#include <vector>
 
 namespace ODBC {
 	class SelectCommand;
diff --git a/libodbcpp/odbc-command.cpp b/libodbcpp/odbc-command.cpp
index c3e181d..e33c97f 100644
--- a/libodbcpp/odbc-command.cpp
+++ b/libodbcpp/odbc-command.cpp
@@ -1,6 +1,7 @@
 #include "odbc-command.h"
+#include "odbc-connection.h"
 #include "odbc-error.h"
-#include "odbc-param.h"
+#include <command.h>
 #include <sqlext.h>
 
 ODBC::Command::Command(const Connection & c, const std::string & s) : DB::Command(s), hStmt(nullptr), connection(c)
diff --git a/libodbcpp/odbc-command.h b/libodbcpp/odbc-command.h
index b0aa3fa..ff8b2fe 100644
--- a/libodbcpp/odbc-command.h
+++ b/libodbcpp/odbc-command.h
@@ -1,13 +1,23 @@
 #ifndef ODBC_COMMAND_H
 #define ODBC_COMMAND_H
 
-#include "odbc-connection.h"
-#include "odbc-param_fwd.h"
+#include "odbc-param_fwd.h" // IWYU pragma: keep
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/date_time/posix_time/ptime.hpp>
 #include <command.h>
 #include <glibmm/ustring.h>
+#include <memory>
+#include <sql.h>
+#include <string>
+#include <string_view>
 #include <vector>
 
+namespace boost::posix_time {
+	class time_duration;
+}
+
 namespace ODBC {
+	class Connection;
 	using ParamPtr = std::unique_ptr<Param>;
 	class Command : public virtual DB::Command {
 		using Params = std::vector<ParamPtr>;
diff --git a/libodbcpp/odbc-connection.cpp b/libodbcpp/odbc-connection.cpp
index 9cb5905..4c8edb9 100644
--- a/libodbcpp/odbc-connection.cpp
+++ b/libodbcpp/odbc-connection.cpp
@@ -1,11 +1,15 @@
 #include "odbc-connection.h"
-#include "error.h"
+#include "connection.h"
+#include "odbc-dsn.h"
+#include "odbc-error.h"
 #include "odbc-modifycommand.h"
 #include "odbc-selectcommand.h"
+#include <array>
 #include <cstdio>
 #include <cstring>
+#include <factory.h>
+#include <memory>
 #include <sqlext.h>
-#include <stdexcept>
 
 NAMEDFACTORY("odbc", ODBC::Connection, DB::ConnectionFactory)
 
diff --git a/libodbcpp/odbc-connection.h b/libodbcpp/odbc-connection.h
index 5031410..26b8619 100644
--- a/libodbcpp/odbc-connection.h
+++ b/libodbcpp/odbc-connection.h
@@ -1,13 +1,14 @@
 #ifndef ODBC_CONNECTION_H
 #define ODBC_CONNECTION_H
 
-#include "odbc-dsn.h"
+#include "command_fwd.h"
 #include "odbc-error.h"
 #include <connection.h>
-#include <error.h>
 #include <sql.h>
+#include <string>
 
 namespace ODBC {
+	class DSN;
 	class ConnectionError : public virtual Error, public virtual DB::ConnectionError {
 	public:
 		ConnectionError(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle);
diff --git a/libodbcpp/odbc-dsn.cpp b/libodbcpp/odbc-dsn.cpp
index 9d300f4..a1c4d62 100644
--- a/libodbcpp/odbc-dsn.cpp
+++ b/libodbcpp/odbc-dsn.cpp
@@ -1,4 +1,5 @@
 #include "odbc-dsn.h"
+#include <utility>
 
 ODBC::DSN::DSN(std::string d, std::string u, std::string p) :
 	dsn(std::move(d)), username(std::move(u)), password(std::move(p))
diff --git a/libodbcpp/odbc-error.cpp b/libodbcpp/odbc-error.cpp
index 0f998d5..ad523e9 100644
--- a/libodbcpp/odbc-error.cpp
+++ b/libodbcpp/odbc-error.cpp
@@ -1,6 +1,8 @@
 #include "odbc-error.h"
+#include "error.h"
 #include <array>
 #include <compileTimeFormatter.h>
+#include <cstddef>
 
 namespace AdHoc {
 	StreamWriterT('5') {
diff --git a/libodbcpp/odbc-error.h b/libodbcpp/odbc-error.h
index b19f2c0..6b97d37 100644
--- a/libodbcpp/odbc-error.h
+++ b/libodbcpp/odbc-error.h
@@ -1,10 +1,10 @@
 #ifndef ODBC_ERROR_H
 #define ODBC_ERROR_H
 
-#include <error.h>
+#include <error.h> // IWYU pragma: keep
 #include <exception.h>
 #include <sql.h>
-#include <stdlib.h>
+#include <string>
 
 namespace ODBC {
 	class Error : public AdHoc::Exception<DB::Error> {
diff --git a/libodbcpp/odbc-mock.cpp b/libodbcpp/odbc-mock.cpp
index 21b332a..6b5f5da 100644
--- a/libodbcpp/odbc-mock.cpp
+++ b/libodbcpp/odbc-mock.cpp
@@ -1,9 +1,11 @@
 #include "odbc-mock.h"
+#include "connection_fwd.h"
+#include "mockDatabase.h"
 #include "odbc-connection.h"
 #include <compileTimeFormatter.h>
+#include <memory>
 
 namespace ODBC {
-
 	Mock::Mock(const std::string & b, const std::string & masterdb, const std::string & name,
 			const std::vector<std::filesystem::path> & ss) :
 		MockServerDatabase(b + ";" + masterdb, name, "odbc"),
@@ -30,5 +32,4 @@ namespace ODBC {
 	{
 		MockServerDatabase::DropDatabase();
 	}
-
 }
diff --git a/libodbcpp/odbc-mock.h b/libodbcpp/odbc-mock.h
index 5db50f5..aa51694 100644
--- a/libodbcpp/odbc-mock.h
+++ b/libodbcpp/odbc-mock.h
@@ -2,8 +2,11 @@
 #define MOCKODBCDATASOURCE_H
 
 #include <c++11Helpers.h>
+#include <connection_fwd.h>
 #include <filesystem>
 #include <mockDatabase.h>
+#include <string>
+#include <vector>
 #include <visibility.h>
 
 namespace ODBC {
diff --git a/libodbcpp/odbc-modifycommand.cpp b/libodbcpp/odbc-modifycommand.cpp
index a5f5918..2a8bd1f 100644
--- a/libodbcpp/odbc-modifycommand.cpp
+++ b/libodbcpp/odbc-modifycommand.cpp
@@ -1,5 +1,9 @@
 #include "odbc-modifycommand.h"
+#include "command.h"
+#include "modifycommand.h"
+#include "odbc-command.h"
 #include "odbc-error.h"
+#include <sql.h>
 
 ODBC::ModifyCommand::ModifyCommand(const ODBC::Connection & c, const std::string & sql) :
 	DB::Command(sql), ODBC::Command(c, sql), DB::ModifyCommand(sql)
diff --git a/libodbcpp/odbc-modifycommand.h b/libodbcpp/odbc-modifycommand.h
index de3f7e0..2147082 100644
--- a/libodbcpp/odbc-modifycommand.h
+++ b/libodbcpp/odbc-modifycommand.h
@@ -3,8 +3,10 @@
 
 #include "odbc-command.h"
 #include <modifycommand.h>
+#include <string>
 
 namespace ODBC {
+	class Connection;
 	class ModifyCommand : public Command, public DB::ModifyCommand {
 	public:
 		ModifyCommand(const Connection &, const std::string & sql);
diff --git a/libodbcpp/odbc-param.cpp b/libodbcpp/odbc-param.cpp
index 20a02bb..a7c719c 100644
--- a/libodbcpp/odbc-param.cpp
+++ b/libodbcpp/odbc-param.cpp
@@ -1,9 +1,19 @@
 #include "odbc-param.h"
+#include "command.h"
 #include "odbc-command.h"
 #include "odbc-error.h"
-#include <cstring>
+#include "odbc-param_fwd.h"
+#include <boost/date_time/date.hpp>
+#include <boost/date_time/gregorian_calendar.hpp>
+#include <boost/date_time/time.hpp>
+#include <boost/date_time/time_system_counted.hpp>
+#include <memory>
 #include <sqlext.h>
 
+namespace Glib {
+	class ustring;
+}
+
 ODBC::Param::Param() : paramCmd(nullptr), paramIdx(0), paramBound(false), dataLength(0) { }
 
 ODBC::Param::Param(Command * c, unsigned int i) : paramCmd(c), paramIdx(i), paramBound(false), dataLength(0) { }
diff --git a/libodbcpp/odbc-param.h b/libodbcpp/odbc-param.h
index 58ed9d2..45cdd25 100644
--- a/libodbcpp/odbc-param.h
+++ b/libodbcpp/odbc-param.h
@@ -11,10 +11,15 @@
 #endif
 #include <glibmm/ustring.h>
 #pragma GCC diagnostic pop
-#include <malloc.h>
+#include <boost/date_time/posix_time/posix_time_config.hpp>
+#include <boost/date_time/posix_time/ptime.hpp>
+#include <sql.h>
 #include <sqlext.h>
+#include <string>
+#include <string_view>
 
 namespace ODBC {
+	class Command;
 	class BooleanParam : public Param {
 	public:
 		BooleanParam() : Param() { }
@@ -330,7 +335,7 @@ namespace ODBC {
 		virtual const void *
 		dataAddress() const override
 		{
-			return NULL;
+			return nullptr;
 		}
 	};
 }
diff --git a/libodbcpp/odbc-selectcommand.cpp b/libodbcpp/odbc-selectcommand.cpp
index 191bb1e..d12fc55 100644
--- a/libodbcpp/odbc-selectcommand.cpp
+++ b/libodbcpp/odbc-selectcommand.cpp
@@ -1,11 +1,20 @@
 #include "odbc-selectcommand.h"
+#include "column.h"
+#include "command.h"
+#include "error.h"
 #include "odbc-column.h"
+#include "odbc-command.h"
 #include "odbc-error.h"
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index_container.hpp>
-#include <cstring>
+#include "selectcommand.h"
+#include <array>
+#include <glibmm/ustring.h>
 #include <numeric>
 #include <sqlext.h>
+#include <utility>
+
+namespace ODBC {
+	class Connection;
+}
 
 ODBC::SelectCommand::SelectCommand(const Connection & c, const std::string & s) :
 	DB::Command(s), ODBC::Command(c, s), DB::SelectCommand(s)
diff --git a/libodbcpp/odbc-selectcommand.h b/libodbcpp/odbc-selectcommand.h
index e9d56c7..160b05e 100644
--- a/libodbcpp/odbc-selectcommand.h
+++ b/libodbcpp/odbc-selectcommand.h
@@ -2,9 +2,14 @@
 #define ODBC_SELECTCOMMAND_H
 
 #include "odbc-command.h"
+#include <memory>
 #include <selectcommand.h>
+#include <set>
+#include <sql.h>
+#include <string>
 
 namespace ODBC {
+	class Connection;
 	class Column;
 	class SelectCommand : public Command, public DB::SelectCommand {
 	public:
diff --git a/libodbcpp/unittests/testodbc.cpp b/libodbcpp/unittests/testodbc.cpp
index 0d78d1a..9efbb52 100644
--- a/libodbcpp/unittests/testodbc.cpp
+++ b/libodbcpp/unittests/testodbc.cpp
@@ -1,15 +1,22 @@
 #define BOOST_TEST_MODULE TestODBC
 #include <boost/test/unit_test.hpp>
 
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <column.h>
+#include "mockDatabase.h"
+#include <boost/date_time/posix_time/conversion.hpp>
+#include <boost/date_time/posix_time/ptime.hpp>
+#include <connection.h>
+#include <cstdint>
 #include <definedDirs.h>
-#include <error.h>
+#include <filesystem>
+#include <memory>
 #include <modifycommand.h>
 #include <odbc-mock.h>
 #include <selectcommand.h>
 #include <selectcommandUtil.impl.h>
+#include <string>
+#include <string_view>
 #include <testCore.h>
+#include <type_traits>
 
 class StandardMockDatabase : public DB::PluginMock<ODBC::Mock> {
 public:
-- 
cgit v1.2.3