summaryrefslogtreecommitdiff
path: root/modules/chanserv
diff options
context:
space:
mode:
Diffstat (limited to 'modules/chanserv')
-rw-r--r--modules/chanserv/cs_entrymsg.cpp33
-rw-r--r--modules/chanserv/cs_log.cpp41
-rw-r--r--modules/chanserv/cs_mode.cpp41
-rw-r--r--modules/chanserv/cs_seen.cpp35
-rw-r--r--modules/chanserv/cs_set_misc.cpp27
-rw-r--r--modules/chanserv/cs_suspend.cpp34
6 files changed, 139 insertions, 72 deletions
diff --git a/modules/chanserv/cs_entrymsg.cpp b/modules/chanserv/cs_entrymsg.cpp
index 01fa5e445..bbb3f03cb 100644
--- a/modules/chanserv/cs_entrymsg.cpp
+++ b/modules/chanserv/cs_entrymsg.cpp
@@ -29,16 +29,26 @@ struct EntryMsgImpl final
}
~EntryMsgImpl() override;
+};
+
+struct EntryMsgTypeImpl final
+ : Serialize::Type
+{
+ EntryMsgTypeImpl()
+ : Serialize::Type("EntryMsg")
+ {
+ }
- void Serialize(Serialize::Data &data) const override
+ void Serialize(const Serializable *obj, Serialize::Data &data) const override
{
- data.Store("ci", this->chan);
- data.Store("creator", this->creator);
- data.Store("message", this->message);
- data.Store("when", this->when);
+ const auto *msg = static_cast<const EntryMsgImpl *>(obj);
+ data.Store("ci", msg->chan);
+ data.Store("creator", msg->creator);
+ data.Store("message", msg->message);
+ data.Store("when", msg->when);
}
- static Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
+ Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
};
struct EntryMessageListImpl final
@@ -68,7 +78,7 @@ EntryMsgImpl::~EntryMsgImpl()
}
-Serializable *EntryMsgImpl::Unserialize(Serializable *obj, Serialize::Data &data)
+Serializable *EntryMsgTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
{
Anope::string sci, screator, smessage;
time_t swhen;
@@ -264,12 +274,13 @@ class CSEntryMessage final
{
CommandEntryMessage commandentrymsg;
ExtensibleItem<EntryMessageListImpl> eml;
- Serialize::Type entrymsg_type;
+ EntryMsgTypeImpl entrymsg_type;
public:
- CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
- commandentrymsg(this),
- eml(this, "entrymsg"), entrymsg_type("EntryMsg", EntryMsgImpl::Unserialize)
+ CSEntryMessage(const Anope::string &modname, const Anope::string &creator)
+ : Module(modname, creator, VENDOR)
+ , commandentrymsg(this)
+ , eml(this, "entrymsg")
{
}
diff --git a/modules/chanserv/cs_log.cpp b/modules/chanserv/cs_log.cpp
index 3da80b713..e704b7021 100644
--- a/modules/chanserv/cs_log.cpp
+++ b/modules/chanserv/cs_log.cpp
@@ -34,20 +34,30 @@ struct LogSettingImpl final
}
}
}
+};
+
+struct LogSettingTypeImpl final
+ : Serialize::Type
+{
+ LogSettingTypeImpl()
+ : Serialize::Type("LogSetting")
+ {
+ }
- void Serialize(Serialize::Data &data) const override
+ void Serialize(const Serializable *obj, Serialize::Data &data) const override
{
- data.Store("ci", chan);
- data.Store("service_name", service_name);
- data.Store("command_service", command_service);
- data.Store("command_name", command_name);
- data.Store("method", method);
- data.Store("extra", extra);
- data.Store("creator", creator);
- data.Store("created", created);
+ const auto *ls = static_cast<const LogSettingImpl *>(obj);
+ data.Store("ci", ls->chan);
+ data.Store("service_name", ls->service_name);
+ data.Store("command_service", ls->command_service);
+ data.Store("command_name", ls->command_name);
+ data.Store("method", ls->method);
+ data.Store("extra", ls->extra);
+ data.Store("creator", ls->creator);
+ data.Store("created", ls->created);
}
- static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
+ Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
{
Anope::string sci;
data["ci"] >> sci;
@@ -291,7 +301,7 @@ class CSLog final
ServiceReference<MemoServService> MSService;
CommandCSLog commandcslog;
ExtensibleItem<LogSettingsImpl> logsettings;
- Serialize::Type logsetting_type;
+ LogSettingTypeImpl logsetting_type;
struct LogDefault final
{
@@ -301,11 +311,12 @@ class CSLog final
std::vector<LogDefault> defaults;
public:
- CSLog(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
- MSService("MemoServService", "MemoServ"), commandcslog(this),
- logsettings(this, "logsettings"), logsetting_type("LogSetting", LogSettingImpl::Unserialize)
+ CSLog(const Anope::string &modname, const Anope::string &creator)
+ : Module(modname, creator, VENDOR)
+ , MSService("MemoServService", "MemoServ")
+ , commandcslog(this)
+ , logsettings(this, "logsettings")
{
-
}
void OnReload(Configuration::Conf &conf) override
diff --git a/modules/chanserv/cs_mode.cpp b/modules/chanserv/cs_mode.cpp
index d20d92581..20638973b 100644
--- a/modules/chanserv/cs_mode.cpp
+++ b/modules/chanserv/cs_mode.cpp
@@ -30,9 +30,17 @@ struct ModeLockImpl final
ml->RemoveMLock(this);
}
}
+};
- void Serialize(Serialize::Data &data) const override;
- static Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
+struct ModeLockTypeImpl final
+ : Serialize::Type
+{
+ ModeLockTypeImpl()
+ : Serialize::Type("ModeLock")
+ {
+ }
+ void Serialize(const Serializable *obj, Serialize::Data &data) const override;
+ Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
};
struct ModeLocksImpl final
@@ -203,17 +211,18 @@ struct ModeLocksImpl final
}
};
-void ModeLockImpl::Serialize(Serialize::Data &data) const
+void ModeLockTypeImpl::Serialize(const Serializable *obj, Serialize::Data &data) const
{
- data.Store("ci", this->ci);
- data.Store("set", this->set);
- data.Store("name", this->name);
- data.Store("param", this->param);
- data.Store("setter", this->setter);
- data.Store("created", this->created);
+ const auto *ml = static_cast<const ModeLockImpl *>(obj);
+ data.Store("ci", ml->ci);
+ data.Store("set", ml->set);
+ data.Store("name", ml->name);
+ data.Store("param", ml->param);
+ data.Store("setter", ml->setter);
+ data.Store("created", ml->created);
}
-Serializable *ModeLockImpl::Unserialize(Serializable *obj, Serialize::Data &data)
+Serializable *ModeLockTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
{
Anope::string sci;
@@ -935,15 +944,15 @@ class CSMode final
CommandCSMode commandcsmode;
CommandCSModes commandcsmodes;
ExtensibleItem<ModeLocksImpl> modelocks;
- Serialize::Type modelocks_type;
+ ModeLockTypeImpl modelocks_type;
public:
- CSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
- commandcsmode(this), commandcsmodes(this),
- modelocks(this, "modelocks"),
- modelocks_type("ModeLock", ModeLockImpl::Unserialize)
+ CSMode(const Anope::string &modname, const Anope::string &creator)
+ : Module(modname, creator, VENDOR)
+ , commandcsmode(this)
+ , commandcsmodes(this)
+ , modelocks(this, "modelocks")
{
-
}
void OnReload(Configuration::Conf &conf) override
diff --git a/modules/chanserv/cs_seen.cpp b/modules/chanserv/cs_seen.cpp
index d8e4e118b..835e3b124 100644
--- a/modules/chanserv/cs_seen.cpp
+++ b/modules/chanserv/cs_seen.cpp
@@ -43,19 +43,29 @@ struct SeenInfo final
if (iter != database.end() && iter->second == this)
database.erase(iter);
}
+};
+
+struct SeenInfoType final
+ : Serialize::Type
+{
+ SeenInfoType()
+ : Serialize::Type("SeenInfo")
+ {
+ }
- void Serialize(Serialize::Data &data) const override
+ void Serialize(const Serializable *obj, Serialize::Data &data) const override
{
- data.Store("nick", nick);
- data.Store("vhost", vhost);
- data.Store("type", type);
- data.Store("nick2", nick2);
- data.Store("channel", channel);
- data.Store("message", message);
- data.Store("last", last);
+ const auto *s = static_cast<const SeenInfo *>(obj);
+ data.Store("nick", s->nick);
+ data.Store("vhost", s->vhost);
+ data.Store("type", s->type);
+ data.Store("nick2", s->nick2);
+ data.Store("channel", s->channel);
+ data.Store("message", s->message);
+ data.Store("last", s->last);
}
- static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
+ Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
{
Anope::string snick;
@@ -374,11 +384,14 @@ public:
class CSSeen final
: public Module
{
- Serialize::Type seeninfo_type;
+ SeenInfoType seeninfo_type;
CommandSeen commandseen;
CommandOSSeen commandosseen;
public:
- CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this)
+ CSSeen(const Anope::string &modname, const Anope::string &creator)
+ : Module(modname, creator, VENDOR)
+ , commandseen(this)
+ , commandosseen(this)
{
}
diff --git a/modules/chanserv/cs_set_misc.cpp b/modules/chanserv/cs_set_misc.cpp
index 4439589a8..71afbe942 100644
--- a/modules/chanserv/cs_set_misc.cpp
+++ b/modules/chanserv/cs_set_misc.cpp
@@ -44,15 +44,25 @@ struct CSMiscData final
name = n;
data = d;
}
+};
+
+struct CSMiscDataType
+ : Serialize::Type
+{
+ CSMiscDataType()
+ : Serialize::Type("CSMiscData")
+ {
+ }
- void Serialize(Serialize::Data &sdata) const override
+ void Serialize(const Serializable *obj, Serialize::Data &sdata) const override
{
- sdata.Store("ci", this->object);
- sdata.Store("name", this->name);
- sdata.Store("data", this->data);
+ const auto *d = static_cast<const CSMiscData *>(obj);
+ sdata.Store("ci", d->object);
+ sdata.Store("name", d->name);
+ sdata.Store("data", d->data);
}
- static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
+ Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
{
Anope::string sci, sname, sdata;
@@ -172,11 +182,12 @@ class CSSetMisc final
: public Module
{
CommandCSSetMisc commandcssetmisc;
- Serialize::Type csmiscdata_type;
+ CSMiscDataType csmiscdata_type;
public:
- CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
- commandcssetmisc(this), csmiscdata_type("CSMiscData", CSMiscData::Unserialize)
+ CSSetMisc(const Anope::string &modname, const Anope::string &creator)
+ : Module(modname, creator, VENDOR)
+ , commandcssetmisc(this)
{
me = this;
}
diff --git a/modules/chanserv/cs_suspend.cpp b/modules/chanserv/cs_suspend.cpp
index b06fa195a..bda608481 100644
--- a/modules/chanserv/cs_suspend.cpp
+++ b/modules/chanserv/cs_suspend.cpp
@@ -17,17 +17,27 @@ struct CSSuspendInfo final
, Serializable
{
CSSuspendInfo(Extensible *) : Serializable("CSSuspendInfo") { }
+};
+
+struct CSSuspendInfoType final
+ : Serialize::Type
+{
+ CSSuspendInfoType()
+ : Serialize::Type("CSSuspendInfo")
+ {
+ }
- void Serialize(Serialize::Data &data) const override
+ void Serialize(const Serializable *obj, Serialize::Data &data) const override
{
- data.Store("chan", what);
- data.Store("by", by);
- data.Store("reason", reason);
- data.Store("time", when);
- data.Store("expires", expires);
+ const auto *si = static_cast<const CSSuspendInfo *>(obj);
+ data.Store("chan", si->what);
+ data.Store("by", si->by);
+ data.Store("reason", si->reason);
+ data.Store("time", si->when);
+ data.Store("expires", si->expires);
}
- static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
+ Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
{
Anope::string schan;
data["chan"] >> schan;
@@ -203,7 +213,7 @@ class CSSuspend final
CommandCSSuspend commandcssuspend;
CommandCSUnSuspend commandcsunsuspend;
ExtensibleItem<CSSuspendInfo> suspend;
- Serialize::Type suspend_type;
+ CSSuspendInfoType suspend_type;
std::vector<Anope::string> show;
struct trim final
@@ -227,9 +237,11 @@ class CSSuspend final
}
public:
- CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
- commandcssuspend(this), commandcsunsuspend(this), suspend(this, "CS_SUSPENDED"),
- suspend_type("CSSuspendInfo", CSSuspendInfo::Unserialize)
+ CSSuspend(const Anope::string &modname, const Anope::string &creator)
+ : Module(modname, creator, VENDOR)
+ , commandcssuspend(this)
+ , commandcsunsuspend(this)
+ , suspend(this, "CS_SUSPENDED")
{
}