diff options
| author | Sadie Powell <sadie@witchery.services> | 2025-03-12 10:29:11 +0000 |
|---|---|---|
| committer | Sadie Powell <sadie@witchery.services> | 2025-03-12 15:53:52 +0000 |
| commit | cdcf0e2f9a8fb0e1c363fc65f71f3131fc6c5ea5 (patch) | |
| tree | 3a665673235bb4dea58b99474492d90e0f711697 /modules/botserv | |
| parent | 718f2e922a6e1113d66fc6e96131213942d507b2 (diff) | |
Move serialization from Serializable to a Serialize::Type child.
Diffstat (limited to 'modules/botserv')
| -rw-r--r-- | modules/botserv/bs_badwords.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/modules/botserv/bs_badwords.cpp b/modules/botserv/bs_badwords.cpp index e1a283eb7..946549713 100644 --- a/modules/botserv/bs_badwords.cpp +++ b/modules/botserv/bs_badwords.cpp @@ -18,15 +18,25 @@ struct BadWordImpl final { BadWordImpl() : Serializable("BadWord") { } ~BadWordImpl() override; +}; + +struct BadWordTypeImpl final + : Serialize::Type +{ + BadWordTypeImpl() + : Serialize::Type("BadWord") + { + } - void Serialize(Serialize::Data &data) const override + void Serialize(const Serializable *obj, Serialize::Data &data) const override { - data.Store("ci", this->chan); - data.Store("word", this->word); - data.Store("type", this->type); + const auto *bw = static_cast<const BadWordImpl *>(obj); + data.Store("ci", bw->chan); + data.Store("word", bw->word); + data.Store("type", bw->type); } - static Serializable *Unserialize(Serializable *obj, Serialize::Data &); + Serializable *Unserialize(Serializable *obj, Serialize::Data &) const override; }; struct BadWordsImpl final @@ -117,7 +127,7 @@ BadWordImpl::~BadWordImpl() } } -Serializable *BadWordImpl::Unserialize(Serializable *obj, Serialize::Data &data) +Serializable *BadWordTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const { Anope::string sci, sword; @@ -464,11 +474,13 @@ class BSBadwords final { CommandBSBadwords commandbsbadwords; ExtensibleItem<BadWordsImpl> badwords; - Serialize::Type badword_type; + BadWordTypeImpl badword_type; public: - BSBadwords(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandbsbadwords(this), badwords(this, "badwords"), badword_type("BadWord", BadWordImpl::Unserialize) + BSBadwords(const Anope::string &modname, const Anope::string &creator) + : Module(modname, creator, VENDOR) + , commandbsbadwords(this) + , badwords(this, "badwords") { } }; |
