summaryrefslogtreecommitdiff
path: root/modules/chanserv/cs_mode.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2025-03-12 10:29:11 +0000
committerSadie Powell <sadie@witchery.services>2025-03-12 15:53:52 +0000
commitcdcf0e2f9a8fb0e1c363fc65f71f3131fc6c5ea5 (patch)
tree3a665673235bb4dea58b99474492d90e0f711697 /modules/chanserv/cs_mode.cpp
parent718f2e922a6e1113d66fc6e96131213942d507b2 (diff)
Move serialization from Serializable to a Serialize::Type child.
Diffstat (limited to 'modules/chanserv/cs_mode.cpp')
-rw-r--r--modules/chanserv/cs_mode.cpp41
1 files changed, 25 insertions, 16 deletions
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