Mercurial > irccd
changeset 775:dc9af75c609c
Misc: more style cleanup
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 29 Oct 2018 13:08:51 +0100 |
parents | bfc51f8a00f3 |
children | 27a6cbb18897 |
files | libirccd-core/irccd/stream.hpp libirccd-core/irccd/string_util.hpp libirccd-core/irccd/system.cpp libirccd-ctl/irccd/ctl/controller.cpp libirccd-ctl/irccd/ctl/controller.hpp libirccd/irccd/daemon/command.hpp libirccd/irccd/daemon/dynlib_plugin.cpp libirccd/irccd/daemon/irc.cpp libirccd/irccd/daemon/irc.hpp libirccd/irccd/daemon/irccd.cpp libirccd/irccd/daemon/logger.cpp libirccd/irccd/daemon/plugin.cpp libirccd/irccd/daemon/plugin.hpp libirccd/irccd/daemon/plugin_service.cpp libirccd/irccd/daemon/plugin_service.hpp libirccd/irccd/daemon/rule.cpp libirccd/irccd/daemon/rule_util.cpp libirccd/irccd/daemon/server.cpp libirccd/irccd/daemon/server_service.cpp libirccd/irccd/daemon/server_service.hpp libirccd/irccd/daemon/transport_server.cpp |
diffstat | 21 files changed, 171 insertions(+), 165 deletions(-) [+] |
line wrap: on
line diff
--- a/libirccd-core/irccd/stream.hpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd-core/irccd/stream.hpp Mon Oct 29 13:08:51 2018 +0100 @@ -51,35 +51,35 @@ */ using write_handler = std::function<void (std::error_code)>; - /** - * Default constructor. - */ - stream() = default; + /** + * Default constructor. + */ + stream() = default; - /** - * Virtual destructor defaulted. - */ - virtual ~stream() = default; + /** + * Virtual destructor defaulted. + */ + virtual ~stream() = default; - /** - * Start asynchronous read. - * - * \pre another read operation must not be running - * \pre handler != nullptr - * \param handler the handler - */ - virtual void read(read_handler handler) = 0; + /** + * Start asynchronous read. + * + * \pre another read operation must not be running + * \pre handler != nullptr + * \param handler the handler + */ + virtual void read(read_handler handler) = 0; - /** - * Start asynchronous write. - * - * \pre json.is_object() - * \pre another write operation must not be running - * \pre handler != nullptr - * \param json the JSON message - * \param handler the handler - */ - virtual void write(const nlohmann::json& json, write_handler handler) = 0; + /** + * Start asynchronous write. + * + * \pre json.is_object() + * \pre another write operation must not be running + * \pre handler != nullptr + * \param json the JSON message + * \param handler the handler + */ + virtual void write(const nlohmann::json& json, write_handler handler) = 0; }; } // !irccd
--- a/libirccd-core/irccd/string_util.hpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd-core/irccd/string_util.hpp Mon Oct 29 13:08:51 2018 +0100 @@ -54,7 +54,7 @@ env = (1 << 2), //!< environment variables shell = (1 << 3), //!< command line command irc_attrs = (1 << 4), //!< IRC escape codes - shell_attrs = (1 << 5) //!< shell attributes + shell_attrs = (1 << 5) //!< shell attributes }; /**
--- a/libirccd-core/irccd/system.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd-core/irccd/system.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -112,10 +112,11 @@ * Compute the system directory path for the given component. * * Referenced by: - * - cachedir, - * - datadir, - * - sysconfigdir, - * - plugindir. + * + * - cachedir, + * - datadir, + * - sysconfigdir, + * - plugindir. */ auto system_directory(const std::string& component) -> boost::filesystem::path { @@ -137,10 +138,14 @@ * * Get user configuration directory. * - * Referenced by: config_filenames. + * Referenced by: + * + * - config_filenames. + * * Requires: - * - Windows: - * - <shlobj.h> + * + * - Windows: + * - <shlobj.h> */ auto user_config_directory() -> boost::filesystem::path { @@ -176,10 +181,14 @@ * user_plugin_directory * ------------------------------------------------------------------ * - * Referenced by: plugin_filenames. + * Referenced by: + * + * - plugin_filenames. + * * Requires: - * - Windows: - * - <shlobj.h> + * + * - Windows: + * - <shlobj.h> * * Like add user_config_directory but for plugins. */ @@ -266,10 +275,11 @@ /* * Requires: - * - Windows: - * - <windows.h> - * - Others: - * - <sys/utsname.h> + * + * - Windows: + * - <windows.h> + * - Others: + * - <sys/utsname.h> */ auto version() -> std::string { @@ -295,15 +305,16 @@ /* * Requires: - * - Windows: - * - <windows.h> - * - Linux: - * - <sys/sysinfo.h> - * - Mac: - * - <sys/types.h> - * - <sys/sysctl.h> - * - Others: - * - <ctime> + * + * - Windows: + * - <windows.h> + * - Linux: + * - <sys/sysinfo.h> + * - Mac: + * - <sys/types.h> + * - <sys/sysctl.h> + * - Others: + * - <ctime> */ auto uptime() -> std::uint64_t { @@ -343,10 +354,11 @@ /* * Requires: - * - Windows: - * - <sys/timeb.h> - * - Others: - * - <sys/times.h> + * + * - Windows: + * - <sys/timeb.h> + * - Others: + * - <sys/times.h> */ auto ticks() -> std::uint64_t { @@ -371,8 +383,9 @@ /* * Requires: - * - Windows: - * - <shlobj.h> + * + * - Windows: + * - <shlobj.h> */ auto home() -> std::string { @@ -394,7 +407,8 @@ /* * Requires: - * - <cstdlib> + * + * - <cstdlib> */ auto env(const std::string& var) -> std::string {
--- a/libirccd-ctl/irccd/ctl/controller.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd-ctl/irccd/ctl/controller.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -28,11 +28,9 @@ #include "controller.hpp" -namespace irccd { +using irccd::json_util::deserializer; -using json_util::deserializer; - -namespace ctl { +namespace irccd::ctl { void controller::authenticate(connect_handler handler, nlohmann::json info) { @@ -156,6 +154,4 @@ }); } -} // !ctl - -} // !irccd +} // !irccd::ctl
--- a/libirccd-ctl/irccd/ctl/controller.hpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd-ctl/irccd/ctl/controller.hpp Mon Oct 29 13:08:51 2018 +0100 @@ -29,9 +29,7 @@ #include <irccd/connector.hpp> #include <irccd/stream.hpp> -namespace irccd { - -namespace ctl { +namespace irccd::ctl { /** * \brief Main irccdctl interface. @@ -119,8 +117,6 @@ void write(nlohmann::json message, stream::write_handler handler = nullptr); }; -} // !ctl - -} // !irccd +} // !irccd::ctl #endif // !IRCCD_CTL_CONTROLLER_HPP
--- a/libirccd/irccd/daemon/command.hpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/command.hpp Mon Oct 29 13:08:51 2018 +0100 @@ -97,7 +97,7 @@ * * Replies: * - * - plugin_error::not_found + * - plugin_error::not_found */ class plugin_config_command : public command { public: @@ -121,7 +121,7 @@ * * Replies: * - * - plugin_error::not_found + * - plugin_error::not_found */ class plugin_info_command : public command { public: @@ -165,9 +165,9 @@ * * Replies: * - * - plugin_error::already_exists - * - plugin_error::not_found - * - plugin_error::exec_error + * - plugin_error::already_exists + * - plugin_error::not_found + * - plugin_error::exec_error */ class plugin_load_command : public command { public: @@ -191,8 +191,8 @@ * * Replies: * - * - plugin_error::not_found - * - plugin_error::exec_error + * - plugin_error::not_found + * - plugin_error::exec_error */ class plugin_reload_command : public command { public: @@ -216,8 +216,8 @@ * * Replies: * - * - plugin_error::not_found - * - plugin_error::exec_error + * - plugin_error::not_found + * - plugin_error::exec_error */ class plugin_unload_command : public command { public: @@ -241,7 +241,7 @@ * * Replies: * - * - rule_error::invalid_action + * - rule_error::invalid_action */ class rule_add_command : public command { public: @@ -265,8 +265,8 @@ * * Replies: * - * - rule_error::invalid_index - * - rule_error::invalid_action + * - rule_error::invalid_index + * - rule_error::invalid_action */ class rule_edit_command : public command { public: @@ -290,7 +290,7 @@ * * Replies: * - * - rule_error::invalid_index + * - rule_error::invalid_index */ class rule_info_command : public command { public: @@ -334,7 +334,7 @@ * * Replies: * - * - rule_error::invalid_index + * - rule_error::invalid_index */ class rule_move_command : public command { public: @@ -358,7 +358,7 @@ * * Replies: * - * - rule_error::invalid_index + * - rule_error::invalid_index */ class rule_remove_command : public command { public: @@ -382,11 +382,11 @@ * * Replies: * - * - server_error::already_exists, - * - server_error::invalid_hostname, - * - server_error::invalid_identifier, - * - server_error::invalid_port_number, - * - server_error::ssl_disabled. + * - server_error::already_exists, + * - server_error::invalid_hostname, + * - server_error::invalid_identifier, + * - server_error::invalid_port_number, + * - server_error::ssl_disabled. */ class server_connect_command : public command { public: @@ -410,8 +410,8 @@ * * Replies: * - * - server_error::invalid_identifier, - * - server_error::not_found. + * - server_error::invalid_identifier, + * - server_error::not_found. */ class server_disconnect_command : public command { public: @@ -435,8 +435,8 @@ * * Replies: * - * - server_error::invalid_identifier, - * - server_error::not_found. + * - server_error::invalid_identifier, + * - server_error::not_found. */ class server_info_command : public command { public: @@ -460,10 +460,10 @@ * * Replies: * - * - server_error::invalid_channel, - * - server_error::invalid_identifier, - * - server_error::invalid_nickname, - * - server_error::not_found. + * - server_error::invalid_channel, + * - server_error::invalid_identifier, + * - server_error::invalid_nickname, + * - server_error::not_found. */ class server_invite_command : public command { public: @@ -487,9 +487,9 @@ * * Replies: * - * - server_error::invalid_channel, - * - server_error::invalid_identifier, - * - server_error::not_found. + * - server_error::invalid_channel, + * - server_error::invalid_identifier, + * - server_error::not_found. */ class server_join_command : public command { public: @@ -513,10 +513,10 @@ * * Replies: * - * - server_error::invalid_channel, - * - server_error::invalid_identifier, - * - server_error::invalid_nickname, - * - server_error::not_found. + * - server_error::invalid_channel, + * - server_error::invalid_identifier, + * - server_error::invalid_nickname, + * - server_error::not_found. */ class server_kick_command : public command { public: @@ -560,9 +560,9 @@ * * Replies: * - * - server_error::invalid_channel, - * - server_error::invalid_identifier, - * - server_error::not_found. + * - server_error::invalid_channel, + * - server_error::invalid_identifier, + * - server_error::not_found. */ class server_me_command : public command { public: @@ -586,9 +586,9 @@ * * Replies: * - * - server_error::invalid_channel, - * - server_error::invalid_identifier, - * - server_error::not_found. + * - server_error::invalid_channel, + * - server_error::invalid_identifier, + * - server_error::not_found. */ class server_message_command : public command { public: @@ -612,10 +612,10 @@ * * Replies: * - * - server_error::invalid_channel, - * - server_error::invalid_identifier, - * - server_error::invalid_mode, - * - server_error::not_found. + * - server_error::invalid_channel, + * - server_error::invalid_identifier, + * - server_error::invalid_mode, + * - server_error::not_found. */ class server_mode_command : public command { public: @@ -639,9 +639,9 @@ * * Replies: * - * - server_error::invalid_identifier, - * - server_error::invalid_nickname, - * - server_error::not_found. + * - server_error::invalid_identifier, + * - server_error::invalid_nickname, + * - server_error::not_found. */ class server_nick_command : public command { public: @@ -665,9 +665,9 @@ * * Replies: * - * - server_error::invalid_channel, - * - server_error::invalid_identifier, - * - server_error::not_found. + * - server_error::invalid_channel, + * - server_error::invalid_identifier, + * - server_error::not_found. */ class server_notice_command : public command { public: @@ -691,9 +691,9 @@ * * Replies: * - * - server_error::invalid_channel, - * - server_error::invalid_identifier, - * - server_error::not_found. + * - server_error::invalid_channel, + * - server_error::invalid_identifier, + * - server_error::not_found. */ class server_part_command : public command { public: @@ -717,8 +717,8 @@ * * Replies: * - * - server_error::invalid_identifier, - * - server_error::not_found. + * - server_error::invalid_identifier, + * - server_error::not_found. */ class server_reconnect_command : public command { public: @@ -742,9 +742,9 @@ * * Replies: * - * - server_error::invalid_channel, - * - server_error::invalid_identifier, - * - server_error::not_found. + * - server_error::invalid_channel, + * - server_error::invalid_identifier, + * - server_error::not_found. */ class server_topic_command : public command { public:
--- a/libirccd/irccd/daemon/dynlib_plugin.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/dynlib_plugin.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -26,11 +26,11 @@ #include "dynlib_plugin.hpp" #if BOOST_OS_WINDOWS -# define DYNLIB_EXTENSION ".dll" +# define DYNLIB_EXTENSION ".dll" #elif BOOST_OS_MACOS -# define DYNLIB_EXTENSION ".dylib" +# define DYNLIB_EXTENSION ".dylib" #else -# define DYNLIB_EXTENSION ".so" +# define DYNLIB_EXTENSION ".so" #endif using boost::format;
--- a/libirccd/irccd/daemon/irc.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/irc.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -35,7 +35,7 @@ return (index >= args.size()) ? dummy : args[index]; } -auto message::is_ctcp(unsigned index) const noexcept -> bool +auto message::is_ctcp(unsigned short index) const noexcept -> bool { const auto a = get(index); @@ -45,7 +45,7 @@ return a.front() == 0x01 && a.back() == 0x01; } -auto message::ctcp(unsigned index) const -> std::string +auto message::ctcp(unsigned short index) const -> std::string { assert(is_ctcp(index));
--- a/libirccd/irccd/daemon/irc.hpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/irc.hpp Mon Oct 29 13:08:51 2018 +0100 @@ -35,7 +35,7 @@ #include <boost/asio.hpp> #if defined(IRCCD_HAVE_SSL) -# include <boost/asio/ssl.hpp> +# include <boost/asio/ssl.hpp> #endif namespace irccd::irc { @@ -1195,8 +1195,8 @@ * \brief Describe a IRC message */ struct message { - std::string prefix; //!< optional prefix - std::string command; //!< command (maybe string or code) + std::string prefix; //!< optional prefix + std::string command; //!< command (maybe string or code) std::vector<std::string> args; //!< parameters /** @@ -1229,7 +1229,7 @@ * \param index the param index (maybe out of bounds) * \return true if CTCP */ - auto is_ctcp(unsigned index) const noexcept -> bool; + auto is_ctcp(unsigned short index) const noexcept -> bool; /** * Parse a CTCP message. @@ -1238,7 +1238,7 @@ * \param index the param index * \return the CTCP command */ - auto ctcp(unsigned index) const -> std::string; + auto ctcp(unsigned short index) const -> std::string; /** * Parse a IRC message. @@ -1381,8 +1381,8 @@ * \param handler the non-null handler */ void connect(const std::string& host, - const std::string& service, - const connect_handler& handler) noexcept; + const std::string& service, + const connect_handler& handler) noexcept; /** * Start receiving data.
--- a/libirccd/irccd/daemon/irccd.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/irccd.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -258,7 +258,7 @@ * Order matters, please be careful when changing this. * * 1. Open logs as early as possible to use the defined outputs on any - * loading errors. + * loading errors. */ // [logs] and [format] sections. @@ -285,12 +285,12 @@ { static const class category : public std::error_category { public: - const char* name() const noexcept override + auto name() const noexcept -> const char* override { return "irccd"; } - std::string message(int e) const override + auto message(int e) const -> std::string override { switch (static_cast<irccd_error::error>(e)) { case irccd_error::error::not_irccd: @@ -318,7 +318,7 @@ auto make_error_code(irccd_error::error e) noexcept -> std::error_code { - return {static_cast<int>(e), irccd_category()}; + return { static_cast<int>(e), irccd_category() }; } } // !irccd
--- a/libirccd/irccd/daemon/logger.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/logger.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -24,7 +24,7 @@ #include "logger.hpp" #if defined(IRCCD_HAVE_SYSLOG) -# include <syslog.h> +# include <syslog.h> #endif // !IRCCD_HAVE_SYSLOG namespace irccd::logger {
--- a/libirccd/irccd/daemon/plugin.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/plugin.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -159,7 +159,7 @@ } plugin_loader::plugin_loader(std::vector<std::string> directories, - std::vector<std::string> extensions) noexcept + std::vector<std::string> extensions) noexcept : directories_(std::move(directories)) , extensions_(std::move(extensions)) { @@ -257,7 +257,7 @@ auto make_error_code(plugin_error::error e) -> std::error_code { - return {static_cast<int>(e), plugin_category()}; + return { static_cast<int>(e), plugin_category() }; } } // !irccd
--- a/libirccd/irccd/daemon/plugin.hpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/plugin.hpp Mon Oct 29 13:08:51 2018 +0100 @@ -346,7 +346,7 @@ * \param extensions the non empty list of extensions supported */ plugin_loader(std::vector<std::string> directories, - std::vector<std::string> extensions) noexcept; + std::vector<std::string> extensions) noexcept; /** * Virtual destructor defaulted.
--- a/libirccd/irccd/daemon/plugin_service.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/plugin_service.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -61,7 +61,7 @@ } } -auto plugin_service::all() const noexcept -> plugins +auto plugin_service::list() const noexcept -> plugins { return plugins_; }
--- a/libirccd/irccd/daemon/plugin_service.hpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/plugin_service.hpp Mon Oct 29 13:08:51 2018 +0100 @@ -76,7 +76,7 @@ * * \return the list of plugins */ - auto all() const noexcept -> plugins; + auto list() const noexcept -> plugins; /** * Check if a plugin is loaded.
--- a/libirccd/irccd/daemon/rule.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/rule.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -51,12 +51,12 @@ { static const class category : public std::error_category { public: - const char* name() const noexcept override + auto name() const noexcept -> const char* override { return "rule"; } - std::string message(int e) const override + auto message(int e) const -> std::string override { switch (static_cast<rule_error::error>(e)) { case rule_error::invalid_action: @@ -74,7 +74,7 @@ auto make_error_code(rule_error::error e) -> std::error_code { - return {static_cast<int>(e), rule_category()}; + return { static_cast<int>(e), rule_category() }; } } // !irccd
--- a/libirccd/irccd/daemon/rule_util.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/rule_util.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -110,10 +110,10 @@ { const auto index = json.find(key); - if (index == json.end() || !index->is_number_integer() || index->get<int>() < 0) + if (index == json.end() || !index->is_number_unsigned()) throw rule_error(rule_error::invalid_index); - return index->get<int>(); + return index->get<unsigned>(); } auto to_json(const rule& rule) -> nlohmann::json
--- a/libirccd/irccd/daemon/server.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/server.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -431,8 +431,8 @@ } void server::handle_recv(const std::error_code& code, - const irc::message& message, - const recv_handler& handler) + const irc::message& message, + const recv_handler& handler) { /* * Once a message is received, dispatch it to individual dispatch_* @@ -844,12 +844,12 @@ { static const class category : public std::error_category { public: - const char* name() const noexcept override + auto name() const noexcept -> const char* override { return "server"; } - std::string message(int e) const override + auto message(int e) const -> std::string override { switch (static_cast<server_error::error>(e)) { case server_error::not_found: @@ -901,7 +901,7 @@ auto make_error_code(server_error::error e) -> std::error_code { - return {static_cast<int>(e), server_category()}; + return { static_cast<int>(e), server_category() }; } } // !irccd
--- a/libirccd/irccd/daemon/server_service.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/server_service.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -553,7 +553,7 @@ { } -auto server_service::all() const noexcept -> const std::vector<std::shared_ptr<server>>& +auto server_service::list() const noexcept -> const std::vector<std::shared_ptr<server>>& { return servers_; }
--- a/libirccd/irccd/daemon/server_service.hpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/server_service.hpp Mon Oct 29 13:08:51 2018 +0100 @@ -64,7 +64,7 @@ * * \return the servers */ - auto all() const noexcept -> const std::vector<std::shared_ptr<server>>&; + auto list() const noexcept -> const std::vector<std::shared_ptr<server>>&; /** * Check if a server exists.
--- a/libirccd/irccd/daemon/transport_server.cpp Fri Oct 26 13:57:36 2018 +0200 +++ b/libirccd/irccd/daemon/transport_server.cpp Mon Oct 29 13:08:51 2018 +0100 @@ -145,12 +145,12 @@ { static const class category : public std::error_category { public: - const char* name() const noexcept override + auto name() const noexcept -> const char* override { return "transport"; } - std::string message(int e) const override + auto message(int e) const -> std::string override { switch (static_cast<transport_error::error>(e)) { case transport_error::auth_required: