From a16bac5e05cfde6dac1665612b84117fa2909d6a Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 11 Nov 2020 22:19:54 +0000 Subject: Convert IRCv3::Replies::Reply#Send[IfCap] to variadic functions. --- include/modules/ircv3_replies.h | 112 +++------------------------------------- 1 file changed, 6 insertions(+), 106 deletions(-) (limited to 'include/modules') diff --git a/include/modules/ircv3_replies.h b/include/modules/ircv3_replies.h index 15b23c74a..ae5784741 100644 --- a/include/modules/ircv3_replies.h +++ b/include/modules/ircv3_replies.h @@ -97,74 +97,14 @@ class IRCv3::Replies::Reply SendInternal(user, msg); } - template - void Send(LocalUser* user, Command* command, const std::string& code, const T1& p1, const std::string& description) - { - ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName); - msg.PushParamRef(command->name); - msg.PushParam(code); - msg.PushParam(ConvToStr(p1)); - msg.PushParam(description); - SendInternal(user, msg); - } - - template - void Send(LocalUser* user, Command* command, const std::string& code, const T1& p1, const T2& p2, + template + void Send(LocalUser* user, Command* command, const std::string& code, Args&&... args, const std::string& description) { ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName); msg.PushParamRef(command->name); msg.PushParam(code); - msg.PushParam(ConvToStr(p1)); - msg.PushParam(ConvToStr(p2)); - msg.PushParam(description); - SendInternal(user, msg); - } - - template - void Send(LocalUser* user, Command* command, const std::string& code, const T1& p1, const T2& p2, - const T3& p3, const std::string& description) - { - ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName); - msg.PushParamRef(command->name); - msg.PushParam(code); - msg.PushParam(ConvToStr(p1)); - msg.PushParam(ConvToStr(p2)); - msg.PushParam(ConvToStr(p3)); - msg.PushParam(description); - SendInternal(user, msg); - } - - template - void Send(LocalUser* user, Command* command, const std::string& code, const T1& p1, const T2& p2, - const T3& p3, const T4& p4, const std::string& description) - { - ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName); - msg.PushParamRef(command->name); - msg.PushParam(code); - msg.PushParam(ConvToStr(p1)); - msg.PushParam(ConvToStr(p2)); - msg.PushParam(ConvToStr(p3)); - msg.PushParam(ConvToStr(p4)); - msg.PushParam(description); - SendInternal(user, msg); - } - - template - void Send(LocalUser* user, Command* command, const std::string& code, const T1& p1, const T2& p2, - const T3& p3, const T4& p4, const T5& p5, const std::string& description) - { - ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName); - if (command) - msg.PushParamRef(command->name); - else - msg.PushParam("*"); - msg.PushParam(code); - msg.PushParam(ConvToStr(p1)); - msg.PushParam(ConvToStr(p2)); - msg.PushParam(ConvToStr(p3)); - msg.PushParam(ConvToStr(p4)); - msg.PushParam(ConvToStr(p5)); + msg.PushParam(std::forward(args)...); msg.PushParam(description); SendInternal(user, msg); } @@ -186,52 +126,12 @@ class IRCv3::Replies::Reply SendNoticeInternal(user, command, description); } - template - void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, - const T1& p1, const std::string& description) - { - if (cap.IsEnabled(user)) - Send(user, command, code, p1, description); - else - SendNoticeInternal(user, command, description); - } - - template - void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, - const T1& p1, const T2& p2, const std::string& description) - { - if (cap.IsEnabled(user)) - Send(user, command, code, p1, p2, description); - else - SendNoticeInternal(user, command, description); - } - - template - void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, - const T1& p1, const T2& p2, const T3& p3, const std::string& description) - { - if (cap.IsEnabled(user)) - Send(user, command, code, p1, p2, p3, description); - else - SendNoticeInternal(user, command, description); - } - - template - void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, - const T1& p1, const T2& p2, const T3& p3, const T4& p4, const std::string& description) - { - if (cap.IsEnabled(user)) - Send(user, command, code, p1, p2, p3, p4, description); - else - SendNoticeInternal(user, command, description); - } - - template + template void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, - const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const std::string& description) + Args&&... args, const std::string& description) { if (cap.IsEnabled(user)) - Send(user, command, code, p1, p2, p3, p4, p5, description); + Send(user, command, code, std::forward(args)..., description); else SendNoticeInternal(user, command, description); } -- cgit v1.3.1-10-gc9f91