1
0
mirror of https://github.com/anope/anope.git synced 2026-06-28 10:46:38 +02:00

Move serialization from Serializable to a Serialize::Type child.

This commit is contained in:
Sadie Powell
2025-03-12 10:29:11 +00:00
parent 718f2e922a
commit cdcf0e2f9a
40 changed files with 778 additions and 452 deletions
+22 -11
View File
@@ -29,16 +29,26 @@ struct EntryMsgImpl final
}
~EntryMsgImpl() override;
};
void Serialize(Serialize::Data &data) const override
struct EntryMsgTypeImpl final
: Serialize::Type
{
EntryMsgTypeImpl()
: Serialize::Type("EntryMsg")
{
data.Store("ci", this->chan);
data.Store("creator", this->creator);
data.Store("message", this->message);
data.Store("when", this->when);
}
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
void Serialize(const Serializable *obj, Serialize::Data &data) const override
{
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);
}
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")
{
}