1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 19:14:47 +02:00

Add defines for the core serialisation type names.

This commit is contained in:
Sadie Powell
2025-03-12 14:20:43 +00:00
parent cdcf0e2f9a
commit e7b18609f6
12 changed files with 73 additions and 39 deletions
+10
View File
@@ -16,6 +16,16 @@
#include "anope.h"
#include "base.h"
/** Names of serialization types implemented in the core. */
#define AUTOKICK_TYPE "AutoKick"
#define BOTINFO_TYPE "BotInfo"
#define CHANACCESS_TYPE "ChanAccess"
#define CHANNELINFO_TYPE "ChannelInfo"
#define MEMO_TYPE "Memo"
#define NICKALIAS_TYPE "NickAlias"
#define NICKCORE_TYPE "NickCore"
#define XLINE_TYPE "XLine"
namespace Serialize
{
enum class DataType
+2 -2
View File
@@ -45,7 +45,7 @@ struct KickerDataImpl final
void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override
{
if (s->GetSerializableType()->GetName() != "ChannelInfo")
if (s->GetSerializableType()->GetName() != CHANNELINFO_TYPE)
return;
const ChannelInfo *ci = anope_dynamic_static_cast<const ChannelInfo *>(e);
@@ -79,7 +79,7 @@ struct KickerDataImpl final
void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
{
if (s->GetSerializableType()->GetName() != "ChannelInfo")
if (s->GetSerializableType()->GetName() != CHANNELINFO_TYPE)
return;
ChannelInfo *ci = anope_dynamic_static_cast<ChannelInfo *>(e);
+2 -2
View File
@@ -1057,7 +1057,7 @@ class CSSet final
{
SerializableExtensibleItem<bool>::ExtensibleSerialize(e, s, data);
if (s->GetSerializableType()->GetName() != "ChannelInfo")
if (s->GetSerializableType()->GetName() != CHANNELINFO_TYPE)
return;
const ChannelInfo *ci = anope_dynamic_static_cast<const ChannelInfo *>(s);
@@ -1077,7 +1077,7 @@ class CSSet final
{
SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data);
if (s->GetSerializableType()->GetName() != "ChannelInfo")
if (s->GetSerializableType()->GetName() != CHANNELINFO_TYPE)
return;
ChannelInfo *ci = anope_dynamic_static_cast<ChannelInfo *>(s);
+2 -2
View File
@@ -160,7 +160,7 @@ public:
void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override
{
if (s->GetSerializableType()->GetName() != "NickCore")
if (s->GetSerializableType()->GetName() != NICKCORE_TYPE)
return;
const NickCore *n = anope_dynamic_static_cast<const NickCore *>(e);
@@ -176,7 +176,7 @@ public:
void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
{
if (s->GetSerializableType()->GetName() != "NickCore")
if (s->GetSerializableType()->GetName() != NICKCORE_TYPE)
return;
NickCore *n = anope_dynamic_static_cast<NickCore *>(e);
+2 -2
View File
@@ -119,7 +119,7 @@ private:
{
SerializableExtensibleItem<bool>::ExtensibleSerialize(e, s, data);
if (s->GetSerializableType()->GetName() != "NickCore")
if (s->GetSerializableType()->GetName() != NICKCORE_TYPE)
return;
const NickCore *nc = anope_dynamic_static_cast<const NickCore *>(s);
@@ -139,7 +139,7 @@ private:
{
SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data);
if (s->GetSerializableType()->GetName() != "NickCore")
if (s->GetSerializableType()->GetName() != NICKCORE_TYPE)
return;
NickCore *nc = anope_dynamic_static_cast<NickCore *>(s);
+4 -2
View File
@@ -91,7 +91,9 @@ const std::list<AccessProvider *>& AccessProvider::GetProviders()
return Providers;
}
ChanAccess::ChanAccess(AccessProvider *p) : Serializable("ChanAccess"), provider(p)
ChanAccess::ChanAccess(AccessProvider *p)
: Serializable(CHANACCESS_TYPE)
, provider(p)
{
}
@@ -160,7 +162,7 @@ NickCore *ChanAccess::GetAccount() const
ChanAccess::Type::Type()
: Serialize::Type("ChanAccess")
: Serialize::Type(CHANACCESS_TYPE)
{
}
+4 -4
View File
@@ -18,12 +18,12 @@
#include "language.h"
#include "serialize.h"
Serialize::Checker<botinfo_map> BotListByNick("BotInfo"), BotListByUID("BotInfo");
Serialize::Checker<botinfo_map> BotListByNick(BOTINFO_TYPE), BotListByUID(BOTINFO_TYPE);
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes)
: User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", {}, IRCD ? IRCD->UID_Retrieve() : "", NULL)
, Serializable("BotInfo")
, channels("ChannelInfo")
, Serializable(BOTINFO_TYPE)
, channels(CHANNELINFO_TYPE)
, botmodes(bmodes)
{
this->lastmsg = this->created = Anope::CurTime;
@@ -85,7 +85,7 @@ BotInfo::~BotInfo()
}
BotInfo::Type::Type()
: Serialize::Type("BotInfo")
: Serialize::Type(BOTINFO_TYPE)
{
}
+5 -3
View File
@@ -17,7 +17,8 @@
#include "account.h"
#include "regchannel.h"
Memo::Memo() : Serializable("Memo")
Memo::Memo()
: Serializable(MEMO_TYPE)
{
mi = NULL;
unread = receipt = false;
@@ -35,7 +36,7 @@ Memo::~Memo()
}
Memo::Type::Type()
: Serialize::Type("Memo")
: Serialize::Type(MEMO_TYPE)
{
}
@@ -82,7 +83,8 @@ Serializable *Memo::Type::Unserialize(Serializable *obj, Serialize::Data &data)
return m;
}
MemoInfo::MemoInfo() : memos("Memo")
MemoInfo::MemoInfo()
: memos(MEMO_TYPE)
{
}
+3 -3
View File
@@ -18,10 +18,10 @@
#include "servers.h"
#include "config.h"
Serialize::Checker<nickalias_map> NickAliasList("NickAlias");
Serialize::Checker<nickalias_map> NickAliasList(NICKALIAS_TYPE);
NickAlias::NickAlias(const Anope::string &nickname, NickCore *nickcore)
: Serializable("NickAlias")
: Serializable(NICKALIAS_TYPE)
, nick(nickname)
, nc(nickcore)
{
@@ -140,7 +140,7 @@ NickAlias *NickAlias::Find(const Anope::string &nick)
}
NickAlias::Type::Type()
: Serialize::Type("NickAlias")
: Serialize::Type(NICKALIAS_TYPE)
{
}
+6 -6
View File
@@ -15,15 +15,15 @@
#include "config.h"
#include <climits>
Serialize::Checker<nickcore_map> NickCoreList("NickCore");
Serialize::Checker<nickcoreid_map> NickCoreIdList("NickCore");
Serialize::Checker<nickcore_map> NickCoreList(NICKCORE_TYPE);
Serialize::Checker<nickcoreid_map> NickCoreIdList(NICKCORE_TYPE);
NickCore::NickCore(const Anope::string &coredisplay, uint64_t coreid)
: Serializable("NickCore")
, chanaccess("ChannelInfo")
: Serializable(NICKCORE_TYPE)
, chanaccess(CHANNELINFO_TYPE)
, id(coreid)
, display(coredisplay)
, aliases("NickAlias")
, aliases(NICKALIAS_TYPE)
{
if (coredisplay.empty())
throw CoreException("Empty display passed to NickCore constructor");
@@ -67,7 +67,7 @@ NickCore::~NickCore()
}
NickCore::Type::Type()
: Serialize::Type("NickCore")
: Serialize::Type(NICKCORE_TYPE)
{
}
+13 -8
View File
@@ -19,9 +19,10 @@
#include "bots.h"
#include "servers.h"
Serialize::Checker<registered_channel_map> RegisteredChannelList("ChannelInfo");
Serialize::Checker<registered_channel_map> RegisteredChannelList(CHANNELINFO_TYPE);
AutoKick::AutoKick() : Serializable("AutoKick")
AutoKick::AutoKick()
: Serializable(AUTOKICK_TYPE)
{
}
@@ -39,7 +40,7 @@ AutoKick::~AutoKick()
}
AutoKick::Type::Type()
: Serialize::Type("AutoKick")
: Serialize::Type(AUTOKICK_TYPE)
{
}
@@ -101,8 +102,10 @@ Serializable *AutoKick::Type::Unserialize(Serializable *obj, Serialize::Data &da
return ak;
}
ChannelInfo::ChannelInfo(const Anope::string &chname) : Serializable("ChannelInfo"),
access("ChanAccess"), akick("AutoKick")
ChannelInfo::ChannelInfo(const Anope::string &chname)
: Serializable(CHANNELINFO_TYPE)
, access(CHANACCESS_TYPE)
, akick(AUTOKICK_TYPE)
{
if (chname.empty())
throw CoreException("Empty channel passed to ChannelInfo constructor");
@@ -130,8 +133,10 @@ ChannelInfo::ChannelInfo(const Anope::string &chname) : Serializable("ChannelInf
FOREACH_MOD(OnCreateChan, (this));
}
ChannelInfo::ChannelInfo(const ChannelInfo &ci) : Serializable("ChannelInfo"),
access("ChanAccess"), akick("AutoKick")
ChannelInfo::ChannelInfo(const ChannelInfo &ci)
: Serializable(CHANNELINFO_TYPE)
, access(CHANACCESS_TYPE)
, akick(AUTOKICK_TYPE)
{
*this = ci;
@@ -185,7 +190,7 @@ ChannelInfo::~ChannelInfo()
}
ChannelInfo::Type::Type()
: Serialize::Type("ChannelInfo")
: Serialize::Type(CHANNELINFO_TYPE)
{
}
+20 -5
View File
@@ -21,7 +21,7 @@
/* List of XLine managers we check users against in XLineManager::CheckAll */
std::list<XLineManager *> XLineManager::XLineManagers;
Serialize::Checker<std::multimap<Anope::string, XLine *, ci::less> > XLineManager::XLinesByUID("XLine");
Serialize::Checker<std::multimap<Anope::string, XLine *, ci::less> > XLineManager::XLinesByUID(XLINE_TYPE);
void XLine::Init()
{
@@ -86,7 +86,12 @@ void XLine::Init()
}
}
XLine::XLine(const Anope::string &ma, const Anope::string &r, const Anope::string &uid) : Serializable("XLine"), mask(ma), by(Me->GetName()), reason(r), id(uid)
XLine::XLine(const Anope::string &ma, const Anope::string &r, const Anope::string &uid)
: Serializable(XLINE_TYPE)
, mask(ma)
, by(Me->GetName())
, reason(r)
, id(uid)
{
regex = NULL;
manager = NULL;
@@ -95,7 +100,14 @@ XLine::XLine(const Anope::string &ma, const Anope::string &r, const Anope::strin
this->Init();
}
XLine::XLine(const Anope::string &ma, const Anope::string &b, const time_t ex, const Anope::string &r, const Anope::string &uid) : Serializable("XLine"), mask(ma), by(b), created(Anope::CurTime), expires(ex), reason(r), id(uid)
XLine::XLine(const Anope::string &ma, const Anope::string &b, const time_t ex, const Anope::string &r, const Anope::string &uid)
: Serializable(XLINE_TYPE)
, mask(ma)
, by(b)
, created(Anope::CurTime)
, expires(ex)
, reason(r)
, id(uid)
{
regex = NULL;
manager = NULL;
@@ -152,7 +164,7 @@ bool XLine::IsRegex() const
}
XLine::Type::Type()
: Serialize::Type("XLine")
: Serialize::Type(XLINE_TYPE)
{
}
@@ -266,7 +278,10 @@ Anope::string XLineManager::GenerateUID()
return id;
}
XLineManager::XLineManager(Module *creator, const Anope::string &xname, char t) : Service(creator, "XLineManager", xname), type(t), xlines("XLine")
XLineManager::XLineManager(Module *creator, const Anope::string &xname, char t)
: Service(creator, "XLineManager", xname)
, type(t)
, xlines(XLINE_TYPE)
{
}