Commit 0a352e55 authored by louiz’'s avatar louiz’

Move the irc callbacks into the cpp file

parent 8c249f14
......@@ -23,6 +23,98 @@
using namespace std::string_literals;
using namespace std::chrono_literals;
/**
* Define a map of functions to be called for each IRC command we can
* handle.
*/
typedef void (IrcClient::*irc_callback_t)(const IrcMessage&);
static const std::unordered_map<std::string,
std::pair<irc_callback_t, std::pair<std::size_t, std::size_t>>> irc_callbacks = {
{"NOTICE", {&IrcClient::on_notice, {2, 0}}},
{"002", {&IrcClient::forward_server_message, {2, 0}}},
{"003", {&IrcClient::forward_server_message, {2, 0}}},
{"005", {&IrcClient::on_isupport_message, {0, 0}}},
{"RPL_LISTSTART", {&IrcClient::on_rpl_liststart, {0, 0}}},
{"321", {&IrcClient::on_rpl_liststart, {0, 0}}},
{"RPL_LIST", {&IrcClient::on_rpl_list, {0, 0}}},
{"322", {&IrcClient::on_rpl_list, {0, 0}}},
{"RPL_LISTEND", {&IrcClient::on_rpl_listend, {0, 0}}},
{"323", {&IrcClient::on_rpl_listend, {0, 0}}},
{"RPL_MOTDSTART", {&IrcClient::empty_motd, {0, 0}}},
{"375", {&IrcClient::empty_motd, {0, 0}}},
{"RPL_MOTD", {&IrcClient::on_motd_line, {2, 0}}},
{"372", {&IrcClient::on_motd_line, {2, 0}}},
{"RPL_MOTDEND", {&IrcClient::send_motd, {0, 0}}},
{"376", {&IrcClient::send_motd, {0, 0}}},
{"JOIN", {&IrcClient::on_channel_join, {1, 0}}},
{"PRIVMSG", {&IrcClient::on_channel_message, {2, 0}}},
{"353", {&IrcClient::set_and_forward_user_list, {4, 0}}},
{"332", {&IrcClient::on_topic_received, {2, 0}}},
{"TOPIC", {&IrcClient::on_topic_received, {2, 0}}},
{"366", {&IrcClient::on_channel_completely_joined, {2, 0}}},
{"432", {&IrcClient::on_erroneous_nickname, {2, 0}}},
{"433", {&IrcClient::on_nickname_conflict, {2, 0}}},
{"438", {&IrcClient::on_nickname_change_too_fast, {2, 0}}},
{"001", {&IrcClient::on_welcome_message, {1, 0}}},
{"PART", {&IrcClient::on_part, {1, 0}}},
{"ERROR", {&IrcClient::on_error, {1, 0}}},
{"QUIT", {&IrcClient::on_quit, {0, 0}}},
{"NICK", {&IrcClient::on_nick, {1, 0}}},
{"MODE", {&IrcClient::on_mode, {1, 0}}},
{"PING", {&IrcClient::send_pong_command, {1, 0}}},
{"PONG", {&IrcClient::on_pong, {0, 0}}},
{"KICK", {&IrcClient::on_kick, {3, 0}}},
{"401", {&IrcClient::on_generic_error, {2, 0}}},
{"402", {&IrcClient::on_generic_error, {2, 0}}},
{"403", {&IrcClient::on_generic_error, {2, 0}}},
{"404", {&IrcClient::on_generic_error, {2, 0}}},
{"405", {&IrcClient::on_generic_error, {2, 0}}},
{"406", {&IrcClient::on_generic_error, {2, 0}}},
{"407", {&IrcClient::on_generic_error, {2, 0}}},
{"408", {&IrcClient::on_generic_error, {2, 0}}},
{"409", {&IrcClient::on_generic_error, {2, 0}}},
{"410", {&IrcClient::on_generic_error, {2, 0}}},
{"411", {&IrcClient::on_generic_error, {2, 0}}},
{"412", {&IrcClient::on_generic_error, {2, 0}}},
{"414", {&IrcClient::on_generic_error, {2, 0}}},
{"421", {&IrcClient::on_generic_error, {2, 0}}},
{"422", {&IrcClient::on_generic_error, {2, 0}}},
{"423", {&IrcClient::on_generic_error, {2, 0}}},
{"424", {&IrcClient::on_generic_error, {2, 0}}},
{"431", {&IrcClient::on_generic_error, {2, 0}}},
{"436", {&IrcClient::on_generic_error, {2, 0}}},
{"441", {&IrcClient::on_generic_error, {2, 0}}},
{"442", {&IrcClient::on_generic_error, {2, 0}}},
{"443", {&IrcClient::on_generic_error, {2, 0}}},
{"444", {&IrcClient::on_generic_error, {2, 0}}},
{"446", {&IrcClient::on_generic_error, {2, 0}}},
{"451", {&IrcClient::on_generic_error, {2, 0}}},
{"461", {&IrcClient::on_generic_error, {2, 0}}},
{"462", {&IrcClient::on_generic_error, {2, 0}}},
{"463", {&IrcClient::on_generic_error, {2, 0}}},
{"464", {&IrcClient::on_generic_error, {2, 0}}},
{"465", {&IrcClient::on_generic_error, {2, 0}}},
{"467", {&IrcClient::on_generic_error, {2, 0}}},
{"470", {&IrcClient::on_generic_error, {2, 0}}},
{"471", {&IrcClient::on_generic_error, {2, 0}}},
{"472", {&IrcClient::on_generic_error, {2, 0}}},
{"473", {&IrcClient::on_generic_error, {2, 0}}},
{"474", {&IrcClient::on_generic_error, {2, 0}}},
{"475", {&IrcClient::on_generic_error, {2, 0}}},
{"476", {&IrcClient::on_generic_error, {2, 0}}},
{"477", {&IrcClient::on_generic_error, {2, 0}}},
{"481", {&IrcClient::on_generic_error, {2, 0}}},
{"482", {&IrcClient::on_generic_error, {2, 0}}},
{"483", {&IrcClient::on_generic_error, {2, 0}}},
{"484", {&IrcClient::on_generic_error, {2, 0}}},
{"485", {&IrcClient::on_generic_error, {2, 0}}},
{"487", {&IrcClient::on_generic_error, {2, 0}}},
{"491", {&IrcClient::on_generic_error, {2, 0}}},
{"501", {&IrcClient::on_generic_error, {2, 0}}},
{"502", {&IrcClient::on_generic_error, {2, 0}}},
};
IrcClient::IrcClient(std::shared_ptr<Poller> poller, const std::string& hostname,
const std::string& nickname, const std::string& username,
......
......@@ -355,97 +355,4 @@ private:
IrcClient& operator=(IrcClient&&) = delete;
};
/**
* Define a map of functions to be called for each IRC command we can
* handle.
*/
typedef void (IrcClient::*irc_callback_t)(const IrcMessage&);
static const std::unordered_map<std::string,
std::pair<irc_callback_t, std::pair<std::size_t, std::size_t>>> irc_callbacks = {
{"NOTICE", {&IrcClient::on_notice, {2, 0}}},
{"002", {&IrcClient::forward_server_message, {2, 0}}},
{"003", {&IrcClient::forward_server_message, {2, 0}}},
{"005", {&IrcClient::on_isupport_message, {0, 0}}},
{"RPL_LISTSTART", {&IrcClient::on_rpl_liststart, {0, 0}}},
{"321", {&IrcClient::on_rpl_liststart, {0, 0}}},
{"RPL_LIST", {&IrcClient::on_rpl_list, {0, 0}}},
{"322", {&IrcClient::on_rpl_list, {0, 0}}},
{"RPL_LISTEND", {&IrcClient::on_rpl_listend, {0, 0}}},
{"323", {&IrcClient::on_rpl_listend, {0, 0}}},
{"RPL_MOTDSTART", {&IrcClient::empty_motd, {0, 0}}},
{"375", {&IrcClient::empty_motd, {0, 0}}},
{"RPL_MOTD", {&IrcClient::on_motd_line, {2, 0}}},
{"372", {&IrcClient::on_motd_line, {2, 0}}},
{"RPL_MOTDEND", {&IrcClient::send_motd, {0, 0}}},
{"376", {&IrcClient::send_motd, {0, 0}}},
{"JOIN", {&IrcClient::on_channel_join, {1, 0}}},
{"PRIVMSG", {&IrcClient::on_channel_message, {2, 0}}},
{"353", {&IrcClient::set_and_forward_user_list, {4, 0}}},
{"332", {&IrcClient::on_topic_received, {2, 0}}},
{"TOPIC", {&IrcClient::on_topic_received, {2, 0}}},
{"366", {&IrcClient::on_channel_completely_joined, {2, 0}}},
{"432", {&IrcClient::on_erroneous_nickname, {2, 0}}},
{"433", {&IrcClient::on_nickname_conflict, {2, 0}}},
{"438", {&IrcClient::on_nickname_change_too_fast, {2, 0}}},
{"001", {&IrcClient::on_welcome_message, {1, 0}}},
{"PART", {&IrcClient::on_part, {1, 0}}},
{"ERROR", {&IrcClient::on_error, {1, 0}}},
{"QUIT", {&IrcClient::on_quit, {0, 0}}},
{"NICK", {&IrcClient::on_nick, {1, 0}}},
{"MODE", {&IrcClient::on_mode, {1, 0}}},
{"PING", {&IrcClient::send_pong_command, {1, 0}}},
{"PONG", {&IrcClient::on_pong, {0, 0}}},
{"KICK", {&IrcClient::on_kick, {3, 0}}},
{"401", {&IrcClient::on_generic_error, {2, 0}}},
{"402", {&IrcClient::on_generic_error, {2, 0}}},
{"403", {&IrcClient::on_generic_error, {2, 0}}},
{"404", {&IrcClient::on_generic_error, {2, 0}}},
{"405", {&IrcClient::on_generic_error, {2, 0}}},
{"406", {&IrcClient::on_generic_error, {2, 0}}},
{"407", {&IrcClient::on_generic_error, {2, 0}}},
{"408", {&IrcClient::on_generic_error, {2, 0}}},
{"409", {&IrcClient::on_generic_error, {2, 0}}},
{"410", {&IrcClient::on_generic_error, {2, 0}}},
{"411", {&IrcClient::on_generic_error, {2, 0}}},
{"412", {&IrcClient::on_generic_error, {2, 0}}},
{"414", {&IrcClient::on_generic_error, {2, 0}}},
{"421", {&IrcClient::on_generic_error, {2, 0}}},
{"422", {&IrcClient::on_generic_error, {2, 0}}},
{"423", {&IrcClient::on_generic_error, {2, 0}}},
{"424", {&IrcClient::on_generic_error, {2, 0}}},
{"431", {&IrcClient::on_generic_error, {2, 0}}},
{"436", {&IrcClient::on_generic_error, {2, 0}}},
{"441", {&IrcClient::on_generic_error, {2, 0}}},
{"442", {&IrcClient::on_generic_error, {2, 0}}},
{"443", {&IrcClient::on_generic_error, {2, 0}}},
{"444", {&IrcClient::on_generic_error, {2, 0}}},
{"446", {&IrcClient::on_generic_error, {2, 0}}},
{"451", {&IrcClient::on_generic_error, {2, 0}}},
{"461", {&IrcClient::on_generic_error, {2, 0}}},
{"462", {&IrcClient::on_generic_error, {2, 0}}},
{"463", {&IrcClient::on_generic_error, {2, 0}}},
{"464", {&IrcClient::on_generic_error, {2, 0}}},
{"465", {&IrcClient::on_generic_error, {2, 0}}},
{"467", {&IrcClient::on_generic_error, {2, 0}}},
{"470", {&IrcClient::on_generic_error, {2, 0}}},
{"471", {&IrcClient::on_generic_error, {2, 0}}},
{"472", {&IrcClient::on_generic_error, {2, 0}}},
{"473", {&IrcClient::on_generic_error, {2, 0}}},
{"474", {&IrcClient::on_generic_error, {2, 0}}},
{"475", {&IrcClient::on_generic_error, {2, 0}}},
{"476", {&IrcClient::on_generic_error, {2, 0}}},
{"477", {&IrcClient::on_generic_error, {2, 0}}},
{"481", {&IrcClient::on_generic_error, {2, 0}}},
{"482", {&IrcClient::on_generic_error, {2, 0}}},
{"483", {&IrcClient::on_generic_error, {2, 0}}},
{"484", {&IrcClient::on_generic_error, {2, 0}}},
{"485", {&IrcClient::on_generic_error, {2, 0}}},
{"487", {&IrcClient::on_generic_error, {2, 0}}},
{"491", {&IrcClient::on_generic_error, {2, 0}}},
{"501", {&IrcClient::on_generic_error, {2, 0}}},
{"502", {&IrcClient::on_generic_error, {2, 0}}},
};
#endif // IRC_CLIENT_INCLUDED
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment