Commit af420738 authored by louiz’'s avatar louiz’

Style fix

Move all constructors at the top of classes
parent 305e01c0
......@@ -28,8 +28,13 @@ typedef std::function<void()> 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<std::string, std::string> values;
std::vector<t_config_changed_callback> callbacks;
Config(const Config&) = delete;
Config& operator=(const Config&) = delete;
Config(Config&&) = delete;
Config& operator=(Config&&) = delete;
};
#endif // CONFIG_INCLUDED
......@@ -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;
......
......@@ -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<Botan::X509_Certificate>&) override final;
......
......@@ -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)
......
......@@ -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<std::unique_ptr<DNSSocketHandler>> socket_handlers;
ares_channel channel;
DNSHandler(const DNSHandler&) = delete;
DNSHandler(DNSHandler&&) = delete;
DNSHandler& operator=(const DNSHandler&) = delete;
DNSHandler& operator=(DNSHandler&&) = delete;
};
#endif /* CARES_FOUND */
......
......@@ -13,10 +13,6 @@ DNSSocketHandler::DNSSocketHandler(std::shared_ptr<Poller> poller,
{
}
DNSSocketHandler::~DNSSocketHandler()
{
}
void DNSSocketHandler::connect()
{
}
......
......@@ -18,7 +18,12 @@ class DNSSocketHandler: public SocketHandler
{
public:
explicit DNSSocketHandler(std::shared_ptr<Poller> 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
......
......@@ -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
......@@ -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);
......
......@@ -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
......@@ -28,9 +28,13 @@ class TCPSocketHandler: public SocketHandler
{
protected:
~TCPSocketHandler();
public:
explicit TCPSocketHandler(std::shared_ptr<Poller> 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.
*/
......
......@@ -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<std::function<void()>> callbacks;
ScopeGuard(const ScopeGuard&) = delete;
ScopeGuard& operator=(ScopeGuard&&) = delete;
ScopeGuard(ScopeGuard&&) = delete;
ScopeGuard& operator=(const ScopeGuard&) = delete;
};
}
......
......@@ -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);
......
......@@ -31,7 +31,12 @@ public:
std::function<void()> 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<TimedEvent> events;
TimedEventsManager(const TimedEventsManager&) = delete;
TimedEventsManager(TimedEventsManager&&) = delete;
TimedEventsManager& operator=(const TimedEventsManager&) = delete;
TimedEventsManager& operator=(TimedEventsManager&&) = delete;
explicit TimedEventsManager() = default;
};
#endif // TIMED_EVENTS_HPP
......@@ -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)
......
......@@ -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<std::pair<const std::string, const std::string>, AdhocSession> sessions;
AdhocCommandsHandler(const AdhocCommandsHandler&) = delete;
AdhocCommandsHandler(AdhocCommandsHandler&&) = delete;
AdhocCommandsHandler& operator=(const AdhocCommandsHandler&) = delete;
AdhocCommandsHandler& operator=(AdhocCommandsHandler&&) = delete;
};
#endif // ADHOC_COMMANDS_HANDLER_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<std::string, std::string> vars;
private:
AdhocSession(const AdhocSession&) = delete;
AdhocSession(AdhocSession&&) = delete;
AdhocSession& operator=(const AdhocSession&) = delete;
AdhocSession& operator=(AdhocSession&&) = delete;
};
#endif // ADHOC_SESSION_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;
};
/**
......
......@@ -38,6 +38,11 @@ public:
explicit XmppComponent(std::shared_ptr<Poller> 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<std::string, std::function<void(const Stanza&)>> 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
......@@ -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());
}
}
}
......
......@@ -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<std::function<void(const Stanza&)>> stanza_callbacks;
std::vector<std::function<void(const XmlNode&)>> stream_open_callbacks;
std::vector<std::function<void(const XmlNode&)>> stream_close_callbacks;
XmppParser(const XmppParser&) = delete;
XmppParser& operator=(const XmppParser&) = delete;
};
#endif // XMPP_PARSER_INCLUDED
......@@ -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<XmlNode>(*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<std::unique_ptr<XmlNode>> 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);
......
......@@ -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<std::string, std::string> get_role_affiliation_from_irc_mode(const char mode)
......
......@@ -34,7 +34,12 @@ class Bridge
{
public:
explicit Bridge(const std::string& user_jid, BiboumiComponent& xmpp, std::shared_ptr<Poller> 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<irc_responder_callback_t> waiting_irc;
Bridge(const Bridge&) = delete;
Bridge(Bridge&& other) = delete;
Bridge& operator=(const Bridge&) = delete;
Bridge& operator=(Bridge&&) = delete;
};
struct IRCNotConnected: public std::exception
......
......@@ -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<typename PersistentType>
......@@ -42,11 +47,6 @@ private:
static std::unique_ptr<db::BibouDB> 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 */
......
......@@ -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)
......
......@@ -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 {
......
......@@ -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<IrcUser> self;
std::vector<std::unique_ptr<IrcUser>> 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
......@@ -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
......@@ -47,10 +47,6 @@ IrcMessage::IrcMessage(std::string&& command,
{
}
IrcMessage::~IrcMessage()
{
}
std::ostream& operator<<(std::ostream& os, const IrcMessage& message)
{
os << "IrcMessage";
......
......@@ -11,16 +11,16 @@ public:
IrcMessage(std::string&& line);