summaryrefslogtreecommitdiff
path: root/src/modes/cmode_l.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-02-15 14:38:24 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-02-15 14:38:24 +0100
commit0556720b559d7ec5d8badacf0ac9b11e9c864847 (patch)
tree0435a0e5b8e722fe35afb3f820f804bec8c0c7b2 /src/modes/cmode_l.cpp
parent88baaf9e68efd9824b906a69320053734d408e14 (diff)
Add ParamModeBase and ParamMode, change all parameter modes to inherit from ParamMode
- Type of the extension used to store data is a template parameter - The extension is automatically unset when the mode is unset - Handlers inheriting from ParamMode have to provide OnSet() and SerializeParam(); may optionally provide OnUnset() - Transparently handle the case when OnSet() modifies the mode parameter - Remove Channel::custom_mode_params map; ask the mode handlers to serialize their parameters instead
Diffstat (limited to 'src/modes/cmode_l.cpp')
-rw-r--r--src/modes/cmode_l.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/modes/cmode_l.cpp b/src/modes/cmode_l.cpp
index f057a75e6..128854b50 100644
--- a/src/modes/cmode_l.cpp
+++ b/src/modes/cmode_l.cpp
@@ -25,7 +25,8 @@
#include "users.h"
#include "builtinmodes.h"
-ModeChannelLimit::ModeChannelLimit() : ParamChannelModeHandler(NULL, "limit", 'l')
+ModeChannelLimit::ModeChannelLimit()
+ : ParamMode<ModeChannelLimit, LocalIntExt>(NULL, "limit", 'l')
{
}
@@ -35,13 +36,13 @@ bool ModeChannelLimit::ResolveModeConflict(std::string &their_param, const std::
return (atoi(their_param.c_str()) < atoi(our_param.c_str()));
}
-bool ModeChannelLimit::ParamValidate(std::string &parameter)
+ModeAction ModeChannelLimit::OnSet(User* user, Channel* chan, std::string& parameter)
{
- int limit = atoi(parameter.c_str());
-
- if (limit < 0)
- return false;
+ ext.set(chan, ConvToInt(parameter));
+ return MODEACTION_ALLOW;
+}
- parameter = ConvToStr(limit);
- return true;
+void ModeChannelLimit::SerializeParam(Channel* chan, intptr_t n, std::string& out)
+{
+ out += ConvToStr(n);
}