From 60178705ae5331cf616ab8e76d7e370aa8c179c6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 21 Jan 2019 21:09:14 +0000 Subject: Update doxygen comments --- libdbpp/column.cpp | 4 +--- libdbpp/column.h | 9 +++++++-- libdbpp/command.cpp | 4 +--- libdbpp/connection.cpp | 4 +--- libdbpp/connectionPool.h | 1 + libdbpp/dbTypes.h | 1 + libdbpp/error.h | 2 ++ libdbpp/mockDatabase.h | 7 ++++++- libdbpp/modifycommand.cpp | 4 +--- libdbpp/selectcommand.cpp | 7 ++----- libdbpp/selectcommand.h | 4 +++- 11 files changed, 26 insertions(+), 21 deletions(-) diff --git a/libdbpp/column.cpp b/libdbpp/column.cpp index c630430..a02ba01 100644 --- a/libdbpp/column.cpp +++ b/libdbpp/column.cpp @@ -11,9 +11,7 @@ Column::Column(const Glib::ustring & n, unsigned int i) : { } -Column::~Column() -{ -} +Column::~Column() = default; static std::string diff --git a/libdbpp/column.h b/libdbpp/column.h index 8989d17..1c76710 100644 --- a/libdbpp/column.h +++ b/libdbpp/column.h @@ -45,9 +45,10 @@ namespace DB { /// Apply a field handler (any sub-class of HandleField) virtual void apply(HandleField &) const = 0; + /// Column handler dealing with trivial (sensible) type conversions template class Extract : public DB::HandleField { - public: + private: template struct is_optional { static constexpr bool value = false; static constexpr bool is_arithmetic = std::is_arithmetic::value; @@ -57,6 +58,8 @@ namespace DB { static constexpr bool is_arithmetic = std::is_arithmetic::value; }; + public: + /// Create an extrator given a target variable. Extract(T & t) : target(t) { } void floatingpoint(double v) override { (*this)(v); } @@ -76,6 +79,7 @@ namespace DB { } } + /// Default call operation to [convert and] assign field value to target. template inline void operator()(const D & v) @@ -94,10 +98,11 @@ namespace DB { throw InvalidConversion(typeid(D).name(), typeid(T).name()); } + private: T & target; }; - /// STL like string extractor. + /// STL like extractor. template void operator>>(T & v) const { diff --git a/libdbpp/command.cpp b/libdbpp/command.cpp index 2751b54..3c914f8 100644 --- a/libdbpp/command.cpp +++ b/libdbpp/command.cpp @@ -11,9 +11,7 @@ DB::Command::Command(const std::string & s) : { } -DB::Command::~Command() -{ -} +DB::Command::~Command() = default; DB::ParameterTypeNotSupported::ParameterTypeNotSupported() { diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp index f7c7b53..a7092e5 100644 --- a/libdbpp/connection.cpp +++ b/libdbpp/connection.cpp @@ -23,9 +23,7 @@ DB::Connection::Connection() : { } -DB::Connection::~Connection() -{ -} +DB::Connection::~Connection() = default; void DB::Connection::execute(const std::string & sql, const CommandOptionsCPtr & opts) diff --git a/libdbpp/connectionPool.h b/libdbpp/connectionPool.h index a3312ce..f7760aa 100644 --- a/libdbpp/connectionPool.h +++ b/libdbpp/connectionPool.h @@ -22,6 +22,7 @@ namespace DB { void testResource(Connection const *) const override; }; + /// Standard specialisation of AdHoc::ResourcePool for database connections given a type and connection string. class DLL_PUBLIC ConnectionPool : public BasicConnectionPool { public: /// Create a new connection pool. diff --git a/libdbpp/dbTypes.h b/libdbpp/dbTypes.h index a75f0d3..3055974 100644 --- a/libdbpp/dbTypes.h +++ b/libdbpp/dbTypes.h @@ -28,6 +28,7 @@ namespace DB { { } + /// Byte-wise equality operation. bool operator==(const DB::Blob b) const; /// The beginning of the binary data. diff --git a/libdbpp/error.h b/libdbpp/error.h index 05f0a39..c36d864 100644 --- a/libdbpp/error.h +++ b/libdbpp/error.h @@ -36,8 +36,10 @@ namespace DB { const std::string to; }; + /// Exception thrown when a null value occurs when reading into a non-optional value. class DLL_PUBLIC UnexpectedNullValue : public AdHoc::Exception { public: + /// Create a new UnexpectedNullValue given the source type name. UnexpectedNullValue(const char * const from); private: diff --git a/libdbpp/mockDatabase.h b/libdbpp/mockDatabase.h index d3e5bff..8a2c2cf 100644 --- a/libdbpp/mockDatabase.h +++ b/libdbpp/mockDatabase.h @@ -13,7 +13,6 @@ namespace DB { class DLL_PUBLIC MockDatabase : public AdHoc::AbstractPluginImplementation { public: /// Creates and registers a new database. - /// @param mockName the name the database will register as. virtual ~MockDatabase() = default; /// Open a connection to this database instance. @@ -60,9 +59,14 @@ class DLL_PUBLIC MockServerDatabase : public MockDatabase { const std::string testDbName; }; +/// Helper class for creating instances of mock databases template class PluginMock { public: + /// Create and register a new mock database. + /// @param name the name of the mock database to register. + /// @param s the collection of scripts to populate the mock database. + /// @param args arguments to the mock database constructor. template PluginMock(const std::string & name, const std::initializer_list & s, const Args & ... args) : mockName(name) @@ -73,6 +77,7 @@ class PluginMock { { AdHoc::PluginManager::getDefault()->remove(mockName); } + /// Get the name of the mock database. const std::string & databaseName() const { return std::dynamic_pointer_cast(AdHoc::PluginManager::getDefault()->get(mockName)->implementation())->databaseName(); diff --git a/libdbpp/modifycommand.cpp b/libdbpp/modifycommand.cpp index f46a6a2..b3bd36d 100644 --- a/libdbpp/modifycommand.cpp +++ b/libdbpp/modifycommand.cpp @@ -5,9 +5,7 @@ DB::ModifyCommand::ModifyCommand(const std::string & s) : { } -DB::ModifyCommand::~ModifyCommand() -{ -} +DB::ModifyCommand::~ModifyCommand() = default; DB::NoRowsAffected::NoRowsAffected() { diff --git a/libdbpp/selectcommand.cpp b/libdbpp/selectcommand.cpp index d47137d..1e67ce6 100644 --- a/libdbpp/selectcommand.cpp +++ b/libdbpp/selectcommand.cpp @@ -35,14 +35,11 @@ namespace DB { DB::SelectCommand::SelectCommand(const std::string & sql) : DB::Command(sql), - columns(new Columns) + columns(std::make_unique()) { } -DB::SelectCommand::~SelectCommand() -{ - delete columns; -} +DB::SelectCommand::~SelectCommand() = default; const DB::Column& DB::SelectCommand::operator[](unsigned int n) const diff --git a/libdbpp/selectcommand.h b/libdbpp/selectcommand.h index 5399b01..05ec2ce 100644 --- a/libdbpp/selectcommand.h +++ b/libdbpp/selectcommand.h @@ -133,17 +133,19 @@ namespace DB { class Columns; /// Columns in the result set. - Columns * columns; + std::unique_ptr columns; }; } namespace std { + /// @cond template struct tuple_size> { static constexpr auto value = sizeof...(Fn); }; template struct tuple_element> { typedef typename std::tuple_element>::type type; }; + /// @endcond } #endif -- cgit v1.2.3