From af42073830087d97385e507f27f601e8769541b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 4 May 2016 14:16:40 +0200 Subject: Style fix Move all constructors at the top of classes --- louloulibs/config/config.hpp | 13 +++++++------ louloulibs/logger/logger.hpp | 8 +++++--- louloulibs/network/credentials_manager.hpp | 6 ++++++ louloulibs/network/dns_handler.cpp | 4 +++- louloulibs/network/dns_handler.hpp | 10 +++++----- louloulibs/network/dns_socket_handler.cpp | 4 ---- louloulibs/network/dns_socket_handler.hpp | 11 ++++++----- louloulibs/network/poller.hpp | 9 ++++----- louloulibs/network/resolver.hpp | 9 ++++----- louloulibs/network/socket_handler.hpp | 11 +++++------ louloulibs/network/tcp_socket_handler.hpp | 11 +++++------ louloulibs/utils/scopeguard.hpp | 10 ++++++---- louloulibs/utils/timed_events.cpp | 4 ---- louloulibs/utils/timed_events.hpp | 25 ++++++++++++++----------- louloulibs/utils/timed_events_manager.cpp | 8 -------- louloulibs/xmpp/adhoc_commands_handler.hpp | 11 ++++++----- louloulibs/xmpp/adhoc_session.hpp | 12 ++++++------ louloulibs/xmpp/jid.hpp | 11 +++++------ louloulibs/xmpp/xmpp_component.hpp | 10 +++++----- louloulibs/xmpp/xmpp_parser.cpp | 4 ++-- louloulibs/xmpp/xmpp_parser.hpp | 16 +++++++++------- louloulibs/xmpp/xmpp_stanza.hpp | 8 ++++---- src/bridge/bridge.cpp | 4 ---- src/bridge/bridge.hpp | 12 ++++++------ src/database/database.hpp | 10 +++++----- src/irc/iid.cpp | 8 -------- src/irc/iid.hpp | 12 ++++++------ src/irc/irc_channel.hpp | 20 +++++++++----------- src/irc/irc_client.hpp | 11 ++++++----- src/irc/irc_message.cpp | 4 ---- src/irc/irc_message.hpp | 10 +++++----- src/irc/irc_user.hpp | 13 +++++++------ src/xmpp/biboumi_component.hpp | 10 +++++----- 33 files changed, 156 insertions(+), 173 deletions(-) diff --git a/louloulibs/config/config.hpp b/louloulibs/config/config.hpp index 688c081..72620c0 100644 --- a/louloulibs/config/config.hpp +++ b/louloulibs/config/config.hpp @@ -28,8 +28,13 @@ typedef std::function t_config_changed_callback; class Config { public: - Config(){}; - ~Config(){}; + Config() = default; + ~Config() = default; + Config(const Config&) = delete; + Config& operator=(const Config&) = delete; + Config(Config&&) = delete; + Config& operator=(Config&&) = delete; + /** * returns a value from the config. If it doesn’t exist, use * the second argument as the default. @@ -88,10 +93,6 @@ private: std::map values; std::vector callbacks; - Config(const Config&) = delete; - Config& operator=(const Config&) = delete; - Config(Config&&) = delete; - Config& operator=(Config&&) = delete; }; #endif // CONFIG_INCLUDED diff --git a/louloulibs/logger/logger.hpp b/louloulibs/logger/logger.hpp index ab8bdf1..3547513 100644 --- a/louloulibs/logger/logger.hpp +++ b/louloulibs/logger/logger.hpp @@ -67,10 +67,12 @@ public: Logger(const int log_level, const std::string& log_file); Logger(const int log_level); -private: - Logger(const Logger&); - Logger& operator=(const Logger&); + Logger(const Logger&) = delete; + Logger& operator=(const Logger&) = delete; + Logger(Logger&&) = delete; + Logger& operator=(Logger&&) = delete; +private: const int log_level; std::ofstream ofstream; nullstream null_stream; diff --git a/louloulibs/network/credentials_manager.hpp b/louloulibs/network/credentials_manager.hpp index 153c4d6..c0d23ae 100644 --- a/louloulibs/network/credentials_manager.hpp +++ b/louloulibs/network/credentials_manager.hpp @@ -14,6 +14,12 @@ class BasicCredentialsManager: public Botan::Credentials_Manager { public: BasicCredentialsManager(const TCPSocketHandler* const socket_handler); + + BasicCredentialsManager(BasicCredentialsManager&&) = delete; + BasicCredentialsManager(const BasicCredentialsManager&) = delete; + BasicCredentialsManager& operator=(const BasicCredentialsManager&) = delete; + BasicCredentialsManager& operator=(BasicCredentialsManager&&) = delete; + void verify_certificate_chain(const std::string& type, const std::string& purported_hostname, const std::vector&) override final; diff --git a/louloulibs/network/dns_handler.cpp b/louloulibs/network/dns_handler.cpp index a8d0f9c..5e19f8c 100644 --- a/louloulibs/network/dns_handler.cpp +++ b/louloulibs/network/dns_handler.cpp @@ -13,7 +13,9 @@ DNSHandler DNSHandler::instance; using namespace std::string_literals; -DNSHandler::DNSHandler() +DNSHandler::DNSHandler(): + socket_handlers{}, + channel{nullptr} { int ares_error; if ((ares_error = ::ares_library_init(ARES_LIB_INIT_ALL)) != 0) diff --git a/louloulibs/network/dns_handler.hpp b/louloulibs/network/dns_handler.hpp index 61e2302..d2b48d2 100644 --- a/louloulibs/network/dns_handler.hpp +++ b/louloulibs/network/dns_handler.hpp @@ -24,6 +24,11 @@ class DNSHandler public: DNSHandler(); ~DNSHandler() = default; + DNSHandler(const DNSHandler&) = delete; + DNSHandler(DNSHandler&&) = delete; + DNSHandler& operator=(const DNSHandler&) = delete; + DNSHandler& operator=(DNSHandler&&) = delete; + void gethostbyname(const std::string& name, ares_host_callback callback, void* socket_handler, int family); /** @@ -48,11 +53,6 @@ private: */ std::vector> socket_handlers; ares_channel channel; - - DNSHandler(const DNSHandler&) = delete; - DNSHandler(DNSHandler&&) = delete; - DNSHandler& operator=(const DNSHandler&) = delete; - DNSHandler& operator=(DNSHandler&&) = delete; }; #endif /* CARES_FOUND */ diff --git a/louloulibs/network/dns_socket_handler.cpp b/louloulibs/network/dns_socket_handler.cpp index 124c9b2..faaabdb 100644 --- a/louloulibs/network/dns_socket_handler.cpp +++ b/louloulibs/network/dns_socket_handler.cpp @@ -13,10 +13,6 @@ DNSSocketHandler::DNSSocketHandler(std::shared_ptr poller, { } -DNSSocketHandler::~DNSSocketHandler() -{ -} - void DNSSocketHandler::connect() { } diff --git a/louloulibs/network/dns_socket_handler.hpp b/louloulibs/network/dns_socket_handler.hpp index ad119e1..5ea9846 100644 --- a/louloulibs/network/dns_socket_handler.hpp +++ b/louloulibs/network/dns_socket_handler.hpp @@ -18,7 +18,12 @@ class DNSSocketHandler: public SocketHandler { public: explicit DNSSocketHandler(std::shared_ptr poller, const socket_t socket); - ~DNSSocketHandler(); + ~DNSSocketHandler() = default; + DNSSocketHandler(const DNSSocketHandler&) = delete; + DNSSocketHandler(DNSSocketHandler&&) = delete; + DNSSocketHandler& operator=(const DNSSocketHandler&) = delete; + DNSSocketHandler& operator=(DNSSocketHandler&&) = delete; + /** * Just call dns_process_fd, c-ares will do its work of send()ing or * recv()ing the data it wants on that socket. @@ -36,10 +41,6 @@ public: bool is_connected() const override final; private: - DNSSocketHandler(const DNSSocketHandler&) = delete; - DNSSocketHandler(DNSSocketHandler&&) = delete; - DNSSocketHandler& operator=(const DNSSocketHandler&) = delete; - DNSSocketHandler& operator=(DNSSocketHandler&&) = delete; }; #endif // CARES_FOUND diff --git a/louloulibs/network/poller.hpp b/louloulibs/network/poller.hpp index de0cb48..4bf7432 100644 --- a/louloulibs/network/poller.hpp +++ b/louloulibs/network/poller.hpp @@ -38,6 +38,10 @@ class Poller public: explicit Poller(); ~Poller(); + Poller(const Poller&) = delete; + Poller(Poller&&) = delete; + Poller& operator=(const Poller&) = delete; + Poller& operator=(Poller&&) = delete; /** * Add a SocketHandler to be monitored by this Poller. All receive events * are always automatically watched. @@ -85,11 +89,6 @@ private: #elif POLLER == EPOLL int epfd; #endif - - Poller(const Poller&) = delete; - Poller(Poller&&) = delete; - Poller& operator=(const Poller&) = delete; - Poller& operator=(Poller&&) = delete; }; #endif // POLLER_INCLUDED diff --git a/louloulibs/network/resolver.hpp b/louloulibs/network/resolver.hpp index f9e9134..fd57e25 100644 --- a/louloulibs/network/resolver.hpp +++ b/louloulibs/network/resolver.hpp @@ -37,6 +37,10 @@ public: Resolver(); ~Resolver() = default; + Resolver(const Resolver&) = delete; + Resolver(Resolver&&) = delete; + Resolver& operator=(const Resolver&) = delete; + Resolver& operator=(Resolver&&) = delete; bool is_resolving() const { @@ -117,11 +121,6 @@ private: ErrorCallbackType error_cb; SuccessCallbackType success_cb; - - Resolver(const Resolver&) = delete; - Resolver(Resolver&&) = delete; - Resolver& operator=(const Resolver&) = delete; - Resolver& operator=(Resolver&&) = delete; }; std::string addr_to_string(const struct addrinfo* rp); diff --git a/louloulibs/network/socket_handler.hpp b/louloulibs/network/socket_handler.hpp index d01ac5d..daa4413 100644 --- a/louloulibs/network/socket_handler.hpp +++ b/louloulibs/network/socket_handler.hpp @@ -16,6 +16,11 @@ public: socket(socket) {} virtual ~SocketHandler() {} + SocketHandler(const SocketHandler&) = delete; + SocketHandler(SocketHandler&&) = delete; + SocketHandler& operator=(const SocketHandler&) = delete; + SocketHandler& operator=(SocketHandler&&) = delete; + virtual void on_recv() = 0; virtual void on_send() = 0; virtual void connect() = 0; @@ -34,12 +39,6 @@ protected: * The handled socket. */ socket_t socket; - -private: - SocketHandler(const SocketHandler&) = delete; - SocketHandler(SocketHandler&&) = delete; - SocketHandler& operator=(const SocketHandler&) = delete; - SocketHandler& operator=(SocketHandler&&) = delete; }; #endif // SOCKET_HANDLER_HPP diff --git a/louloulibs/network/tcp_socket_handler.hpp b/louloulibs/network/tcp_socket_handler.hpp index 62b2ce7..dd4e82e 100644 --- a/louloulibs/network/tcp_socket_handler.hpp +++ b/louloulibs/network/tcp_socket_handler.hpp @@ -28,9 +28,13 @@ class TCPSocketHandler: public SocketHandler { protected: ~TCPSocketHandler(); - public: explicit TCPSocketHandler(std::shared_ptr poller); + TCPSocketHandler(const TCPSocketHandler&) = delete; + TCPSocketHandler(TCPSocketHandler&&) = delete; + TCPSocketHandler& operator=(const TCPSocketHandler&) = delete; + TCPSocketHandler& operator=(TCPSocketHandler&&) = delete; + /** * Connect to the remote server, and call on_connected() if this * succeeds. If tls is true, we set use_tls to true and will also call @@ -231,11 +235,6 @@ protected: std::string bind_addr; private: - TCPSocketHandler(const TCPSocketHandler&) = delete; - TCPSocketHandler(TCPSocketHandler&&) = delete; - TCPSocketHandler& operator=(const TCPSocketHandler&) = delete; - TCPSocketHandler& operator=(TCPSocketHandler&&) = delete; - /** * Display the resolved IP, just for information purpose. */ diff --git a/louloulibs/utils/scopeguard.hpp b/louloulibs/utils/scopeguard.hpp index df78831..fed40ff 100644 --- a/louloulibs/utils/scopeguard.hpp +++ b/louloulibs/utils/scopeguard.hpp @@ -40,6 +40,12 @@ public: { this->add_callback(std::move(func)); } + + ScopeGuard(const ScopeGuard&) = delete; + ScopeGuard& operator=(ScopeGuard&&) = delete; + ScopeGuard(ScopeGuard&&) = delete; + ScopeGuard& operator=(const ScopeGuard&) = delete; + /** * default constructor, the scope guard is enabled but empty, use * add_callback() @@ -78,10 +84,6 @@ private: bool enabled; std::vector> callbacks; - ScopeGuard(const ScopeGuard&) = delete; - ScopeGuard& operator=(ScopeGuard&&) = delete; - ScopeGuard(ScopeGuard&&) = delete; - ScopeGuard& operator=(const ScopeGuard&) = delete; }; } diff --git a/louloulibs/utils/timed_events.cpp b/louloulibs/utils/timed_events.cpp index 5010a3f..930380b 100644 --- a/louloulibs/utils/timed_events.cpp +++ b/louloulibs/utils/timed_events.cpp @@ -29,10 +29,6 @@ TimedEvent::TimedEvent(TimedEvent&& other): { } -TimedEvent::~TimedEvent() -{ -} - bool TimedEvent::is_after(const TimedEvent& other) const { return this->is_after(other.time_point); diff --git a/louloulibs/utils/timed_events.hpp b/louloulibs/utils/timed_events.hpp index 4e2800c..c3dfc40 100644 --- a/louloulibs/utils/timed_events.hpp +++ b/louloulibs/utils/timed_events.hpp @@ -31,7 +31,12 @@ public: std::function callback, const std::string& name=""); explicit TimedEvent(TimedEvent&&); - ~TimedEvent(); + ~TimedEvent() = default; + + TimedEvent(const TimedEvent&) = delete; + TimedEvent& operator=(const TimedEvent&) = delete; + TimedEvent& operator=(TimedEvent&&) = delete; + /** * Whether or not this event happens after the other one. */ @@ -70,10 +75,6 @@ private: * unique. */ const std::string name; - - TimedEvent(const TimedEvent&) = delete; - TimedEvent& operator=(const TimedEvent&) = delete; - TimedEvent& operator=(TimedEvent&&) = delete; }; /** @@ -84,7 +85,13 @@ private: class TimedEventsManager { public: - ~TimedEventsManager(); + ~TimedEventsManager() = default; + + TimedEventsManager(const TimedEventsManager&) = delete; + TimedEventsManager(TimedEventsManager&&) = delete; + TimedEventsManager& operator=(const TimedEventsManager&) = delete; + TimedEventsManager& operator=(TimedEventsManager&&) = delete; + /** * Return the unique instance of this class */ @@ -121,12 +128,8 @@ public: std::size_t size() const; private: - explicit TimedEventsManager(); std::list events; - TimedEventsManager(const TimedEventsManager&) = delete; - TimedEventsManager(TimedEventsManager&&) = delete; - TimedEventsManager& operator=(const TimedEventsManager&) = delete; - TimedEventsManager& operator=(TimedEventsManager&&) = delete; + explicit TimedEventsManager() = default; }; #endif // TIMED_EVENTS_HPP diff --git a/louloulibs/utils/timed_events_manager.cpp b/louloulibs/utils/timed_events_manager.cpp index 2c75e48..b90a237 100644 --- a/louloulibs/utils/timed_events_manager.cpp +++ b/louloulibs/utils/timed_events_manager.cpp @@ -6,14 +6,6 @@ TimedEventsManager& TimedEventsManager::instance() return inst; } -TimedEventsManager::TimedEventsManager() -{ -} - -TimedEventsManager::~TimedEventsManager() -{ -} - void TimedEventsManager::add_event(TimedEvent&& event) { for (auto it = this->events.begin(); it != this->events.end(); ++it) diff --git a/louloulibs/xmpp/adhoc_commands_handler.hpp b/louloulibs/xmpp/adhoc_commands_handler.hpp index 0614b2f..65b094d 100644 --- a/louloulibs/xmpp/adhoc_commands_handler.hpp +++ b/louloulibs/xmpp/adhoc_commands_handler.hpp @@ -21,6 +21,12 @@ public: commands{} { } ~AdhocCommandsHandler() = default; + + AdhocCommandsHandler(const AdhocCommandsHandler&) = delete; + AdhocCommandsHandler(AdhocCommandsHandler&&) = delete; + AdhocCommandsHandler& operator=(const AdhocCommandsHandler&) = delete; + AdhocCommandsHandler& operator=(AdhocCommandsHandler&&) = delete; + /** * Returns the list of available commands. */ @@ -63,11 +69,6 @@ private: * Of the form: {{session_id, owner_jid}, session}. */ std::map, AdhocSession> sessions; - - AdhocCommandsHandler(const AdhocCommandsHandler&) = delete; - AdhocCommandsHandler(AdhocCommandsHandler&&) = delete; - AdhocCommandsHandler& operator=(const AdhocCommandsHandler&) = delete; - AdhocCommandsHandler& operator=(AdhocCommandsHandler&&) = delete; }; #endif // ADHOC_COMMANDS_HANDLER_HPP diff --git a/louloulibs/xmpp/adhoc_session.hpp b/louloulibs/xmpp/adhoc_session.hpp index e98b6a8..0966c4e 100644 --- a/louloulibs/xmpp/adhoc_session.hpp +++ b/louloulibs/xmpp/adhoc_session.hpp @@ -25,6 +25,12 @@ public: explicit AdhocSession(const AdhocCommand& command, const std::string& owner_jid, const std::string& to_jid); ~AdhocSession() = default; + + AdhocSession(const AdhocSession&) = delete; + AdhocSession(AdhocSession&&) = delete; + AdhocSession& operator=(const AdhocSession&) = delete; + AdhocSession& operator=(AdhocSession&&) = delete; + /** * Return the function to be executed, found in our AdhocCommand, for the * current_step. And increment the current_step. @@ -80,12 +86,6 @@ public: * any key in there. */ std::map vars; - -private: - AdhocSession(const AdhocSession&) = delete; - AdhocSession(AdhocSession&&) = delete; - AdhocSession& operator=(const AdhocSession&) = delete; - AdhocSession& operator=(AdhocSession&&) = delete; }; #endif // ADHOC_SESSION_HPP diff --git a/louloulibs/xmpp/jid.hpp b/louloulibs/xmpp/jid.hpp index e2ee586..5ff5a4f 100644 --- a/louloulibs/xmpp/jid.hpp +++ b/louloulibs/xmpp/jid.hpp @@ -11,6 +11,11 @@ class Jid public: explicit Jid(const std::string& jid); + Jid(const Jid&) = delete; + Jid(Jid&&) = delete; + Jid& operator=(const Jid&) = delete; + Jid& operator=(Jid&&) = delete; + std::string domain; std::string local; std::string resource; @@ -23,12 +28,6 @@ public: { return this->local + "@" + this->domain + "/" + this->resource; } - -private: - Jid(const Jid&) = delete; - Jid(Jid&&) = delete; - Jid& operator=(const Jid&) = delete; - Jid& operator=(Jid&&) = delete; }; /** diff --git a/louloulibs/xmpp/xmpp_component.hpp b/louloulibs/xmpp/xmpp_component.hpp index 07322dd..913e337 100644 --- a/louloulibs/xmpp/xmpp_component.hpp +++ b/louloulibs/xmpp/xmpp_component.hpp @@ -38,6 +38,11 @@ public: explicit XmppComponent(std::shared_ptr poller, const std::string& hostname, const std::string& secret); virtual ~XmppComponent() = default; + XmppComponent(const XmppComponent&) = delete; + XmppComponent(XmppComponent&&) = delete; + XmppComponent& operator=(const XmppComponent&) = delete; + XmppComponent& operator=(XmppComponent&&) = delete; + void on_connection_failed(const std::string& reason) override final; void on_connected() override final; void on_connection_close(const std::string& error) override final; @@ -231,11 +236,6 @@ protected: std::unordered_map> stanza_handlers; AdhocCommandsHandler adhoc_commands_handler; - - XmppComponent(const XmppComponent&) = delete; - XmppComponent(XmppComponent&&) = delete; - XmppComponent& operator=(const XmppComponent&) = delete; - XmppComponent& operator=(XmppComponent&&) = delete; }; #endif // XMPP_COMPONENT_INCLUDED diff --git a/louloulibs/xmpp/xmpp_parser.cpp b/louloulibs/xmpp/xmpp_parser.cpp index 69de145..dc12000 100644 --- a/louloulibs/xmpp/xmpp_parser.cpp +++ b/louloulibs/xmpp/xmpp_parser.cpp @@ -118,7 +118,7 @@ void XmppParser::end_element(const XML_Char*) this->stanza_event(*this->current_node); // Note: deleting all the children of our parent deletes ourself, // so current_node is an invalid pointer after this line - this->current_node->get_parent()->delete_all_children(); + parent->delete_all_children(); } this->current_node = parent; } @@ -139,7 +139,7 @@ void XmppParser::stanza_event(const Stanza& stanza) const try { callback(stanza); } catch (const std::exception& e) { - log_debug("Unhandled exception: " << e.what()); + log_error("Unhandled exception: " << e.what()); } } } diff --git a/louloulibs/xmpp/xmpp_parser.hpp b/louloulibs/xmpp/xmpp_parser.hpp index 3474b13..93c6c53 100644 --- a/louloulibs/xmpp/xmpp_parser.hpp +++ b/louloulibs/xmpp/xmpp_parser.hpp @@ -32,12 +32,12 @@ class XmppParser public: explicit XmppParser(); ~XmppParser(); + XmppParser(const XmppParser&) = delete; + XmppParser& operator=(const XmppParser&) = delete; + XmppParser(XmppParser&&) = delete; + XmppParser& operator=(XmppParser&&) = delete; public: - /** - * Init the XML parser and install the callbacks - */ - void init_xml_parser(); /** * Feed the parser with some XML data */ @@ -98,6 +98,11 @@ public: void stream_close_event(const XmlNode& node) const; private: + /** + * Init the XML parser and install the callbacks + */ + void init_xml_parser(); + /** * Expat structure. */ @@ -123,9 +128,6 @@ private: std::vector> stanza_callbacks; std::vector> stream_open_callbacks; std::vector> stream_close_callbacks; - - XmppParser(const XmppParser&) = delete; - XmppParser& operator=(const XmppParser&) = delete; }; #endif // XMPP_PARSER_INCLUDED diff --git a/louloulibs/xmpp/xmpp_stanza.hpp b/louloulibs/xmpp/xmpp_stanza.hpp index 77ab206..28b8414 100644 --- a/louloulibs/xmpp/xmpp_stanza.hpp +++ b/louloulibs/xmpp/xmpp_stanza.hpp @@ -25,7 +25,6 @@ class XmlNode public: explicit XmlNode(const std::string& name, XmlNode* parent); explicit XmlNode(const std::string& name); - XmlNode(XmlNode&& node) = default; /** * The copy constructor does not copy the parent attribute. The children * nodes are all copied recursively. @@ -42,6 +41,10 @@ public: this->add_child(std::make_unique(*child)); } + XmlNode(XmlNode&& node) = default; + XmlNode& operator=(const XmlNode&) = delete; + XmlNode& operator=(XmlNode&&) = delete; + ~XmlNode() = default; void delete_all_children(); @@ -129,9 +132,6 @@ private: std::vector> children; std::string inner; std::string tail; - - XmlNode& operator=(const XmlNode&) = delete; - XmlNode& operator=(XmlNode&&) = delete; }; std::ostream& operator<<(std::ostream& os, const XmlNode& node); diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 2815da9..6008dfc 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -45,10 +45,6 @@ Bridge::Bridge(const std::string& user_jid, BiboumiComponent& xmpp, std::shared_ { } -Bridge::~Bridge() -{ -} - /** * Return the role and affiliation, corresponding to the given irc mode */ static std::tuple get_role_affiliation_from_irc_mode(const char mode) diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp index 6222ef0..2676d1d 100644 --- a/src/bridge/bridge.hpp +++ b/src/bridge/bridge.hpp @@ -34,7 +34,12 @@ class Bridge { public: explicit Bridge(const std::string& user_jid, BiboumiComponent& xmpp, std::shared_ptr poller); - ~Bridge(); + ~Bridge() = default; + + Bridge(const Bridge&) = delete; + Bridge(Bridge&& other) = delete; + Bridge& operator=(const Bridge&) = delete; + Bridge& operator=(Bridge&&) = delete; /** * QUIT all connected IRC servers. */ @@ -239,11 +244,6 @@ private: * response iq. */ std::list waiting_irc; - - Bridge(const Bridge&) = delete; - Bridge(Bridge&& other) = delete; - Bridge& operator=(const Bridge&) = delete; - Bridge& operator=(Bridge&&) = delete; }; struct IRCNotConnected: public std::exception diff --git a/src/database/database.hpp b/src/database/database.hpp index fc957bd..7bd41a3 100644 --- a/src/database/database.hpp +++ b/src/database/database.hpp @@ -16,6 +16,11 @@ public: Database() = default; ~Database() = default; + Database(const Database&) = delete; + Database(Database&&) = delete; + Database& operator=(const Database&) = delete; + Database& operator=(Database&&) = delete; + static void set_verbose(const bool val); template @@ -42,11 +47,6 @@ private: static std::unique_ptr db; static db::BibouDB& get_db(); - - Database(const Database&) = delete; - Database(Database&&) = delete; - Database& operator=(const Database&) = delete; - Database& operator=(Database&&) = delete; }; #endif /* USE_DATABASE */ diff --git a/src/irc/iid.cpp b/src/irc/iid.cpp index 9d39129..212fb8f 100644 --- a/src/irc/iid.cpp +++ b/src/irc/iid.cpp @@ -51,14 +51,6 @@ void Iid::init_with_fixed_server(const std::string& iid, const std::string& host } } -Iid::Iid(const Iid& other): - is_channel(other.is_channel), - is_user(other.is_user), - local(other.local), - server(other.server) -{ -} - Iid::Iid(): is_channel(false), is_user(false) diff --git a/src/irc/iid.hpp b/src/irc/iid.hpp index 91779b2..1c026e8 100644 --- a/src/irc/iid.hpp +++ b/src/irc/iid.hpp @@ -43,8 +43,12 @@ class Iid { public: Iid(const std::string& iid); - explicit Iid(const Iid&); - explicit Iid(); + Iid(); + Iid(const Iid&) = default; + + Iid(Iid&&) = delete; + Iid& operator=(const Iid&) = delete; + Iid& operator=(Iid&&) = delete; void set_local(const std::string& loc); void set_server(const std::string& serv); @@ -63,10 +67,6 @@ private: std::string local; std::string server; - - Iid(Iid&&) = delete; - Iid& operator=(const Iid&) = delete; - Iid& operator=(Iid&&) = delete; }; namespace std { diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index 651b8ed..e22947b 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -16,6 +16,11 @@ class IrcChannel public: explicit IrcChannel(); + IrcChannel(const IrcChannel&) = delete; + IrcChannel(IrcChannel&&) = delete; + IrcChannel& operator=(const IrcChannel&) = delete; + IrcChannel& operator=(IrcChannel&&) = delete; + bool joined; std::string topic; std::string topic_author; @@ -30,12 +35,6 @@ public: protected: std::unique_ptr self; std::vector> users; - -private: - IrcChannel(const IrcChannel&) = delete; - IrcChannel(IrcChannel&&) = delete; - IrcChannel& operator=(const IrcChannel&) = delete; - IrcChannel& operator=(IrcChannel&&) = delete; }; /** @@ -50,6 +49,10 @@ class DummyIrcChannel: public IrcChannel { public: explicit DummyIrcChannel(); + DummyIrcChannel(const DummyIrcChannel&) = delete; + DummyIrcChannel(DummyIrcChannel&&) = delete; + DummyIrcChannel& operator=(const DummyIrcChannel&) = delete; + DummyIrcChannel& operator=(DummyIrcChannel&&) = delete; /** * This flag is at true whenever the user wants to join this channel, but @@ -60,11 +63,6 @@ public: * the channel, we don’t use that flag, we just join it immediately. */ bool joining; -private: - DummyIrcChannel(const DummyIrcChannel&) = delete; - DummyIrcChannel(DummyIrcChannel&&) = delete; - DummyIrcChannel& operator=(const DummyIrcChannel&) = delete; - DummyIrcChannel& operator=(DummyIrcChannel&&) = delete; }; #endif // IRC_CHANNEL_INCLUDED diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index ceaa860..7af097c 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -31,6 +31,12 @@ public: const std::string& realname, const std::string& user_hostname, Bridge& bridge); ~IrcClient(); + + IrcClient(const IrcClient&) = delete; + IrcClient(IrcClient&&) = delete; + IrcClient& operator=(const IrcClient&) = delete; + IrcClient& operator=(IrcClient&&) = delete; + /** * Connect to the IRC server */ @@ -360,11 +366,6 @@ private: * the WebIRC protocole. */ Resolver dns_resolver; - - IrcClient(const IrcClient&) = delete; - IrcClient(IrcClient&&) = delete; - IrcClient& operator=(const IrcClient&) = delete; - IrcClient& operator=(IrcClient&&) = delete; }; #endif // IRC_CLIENT_INCLUDED diff --git a/src/irc/irc_message.cpp b/src/irc/irc_message.cpp index eb3eb47..966a47c 100644 --- a/src/irc/irc_message.cpp +++ b/src/irc/irc_message.cpp @@ -47,10 +47,6 @@ IrcMessage::IrcMessage(std::string&& command, { } -IrcMessage::~IrcMessage() -{ -} - std::ostream& operator<<(std::ostream& os, const IrcMessage& message) { os << "IrcMessage"; diff --git a/src/irc/irc_message.hpp b/src/irc/irc_message.hpp index 01e78cf..29ed946 100644 --- a/src/irc/irc_message.hpp +++ b/src/irc/irc_message.hpp @@ -11,16 +11,16 @@ public: IrcMessage(std::string&& line); IrcMessage(std::string&& prefix, std::string&& command, std::vector&& args); IrcMessage(std::string&& command, std::vector&& args); - ~IrcMessage(); - - std::string prefix; - std::string command; - std::vector arguments; + ~IrcMessage() = default; IrcMessage(const IrcMessage&) = delete; IrcMessage(IrcMessage&&) = delete; IrcMessage& operator=(const IrcMessage&) = delete; IrcMessage& operator=(IrcMessage&&) = delete; + + std::string prefix; + std::string command; + std::vector arguments; }; std::ostream& operator<<(std::ostream& os, const IrcMessage& message); diff --git a/src/irc/irc_user.hpp b/src/irc/irc_user.hpp index d3397ca..4b6cd7a 100644 --- a/src/irc/irc_user.hpp +++ b/src/irc/irc_user.hpp @@ -15,18 +15,19 @@ public: explicit IrcUser(const std::string& name, const std::map& prefix_to_mode); explicit IrcUser(const std::string& name); + + IrcUser(const IrcUser&) = delete; + IrcUser(IrcUser&&) = delete; + IrcUser& operator=(const IrcUser&) = delete; + IrcUser& operator=(IrcUser&&) = delete; + void add_mode(const char mode); void remove_mode(const char mode); char get_most_significant_mode(const std::vector& sorted_user_modes) const; + std::string nick; std::string host; std::set modes; - -private: - IrcUser(const IrcUser&) = delete; - IrcUser(IrcUser&&) = delete; - IrcUser& operator=(const IrcUser&) = delete; - IrcUser& operator=(IrcUser&&) = delete; }; #endif // IRC_USER_INCLUDED diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index 7602332..f1817e2 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -26,6 +26,11 @@ public: explicit BiboumiComponent(std::shared_ptr poller, const std::string& hostname, const std::string& secret); ~BiboumiComponent() = default; + BiboumiComponent(const BiboumiComponent&) = delete; + BiboumiComponent(BiboumiComponent&&) = delete; + BiboumiComponent& operator=(const BiboumiComponent&) = delete; + BiboumiComponent& operator=(BiboumiComponent&&) = delete; + /** * Returns the bridge for the given user. If it does not exist, return * nullptr. @@ -99,11 +104,6 @@ private: AdhocCommandsHandler irc_server_adhoc_commands_handler; AdhocCommandsHandler irc_channel_adhoc_commands_handler; - - BiboumiComponent(const BiboumiComponent&) = delete; - BiboumiComponent(BiboumiComponent&&) = delete; - BiboumiComponent& operator=(const BiboumiComponent&) = delete; - BiboumiComponent& operator=(BiboumiComponent&&) = delete; }; #endif // BIBOUMI_COMPONENT_INCLUDED -- cgit v1.2.3