summaryrefslogtreecommitdiff
path: root/src/regchannel.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-08-14 02:40:48 +0100
committerSadie Powell <sadie@witchery.services>2024-08-14 05:47:55 +0100
commit528b5938ec71abed396248cf5e00f346e685aaea (patch)
treee923fed32be3fb62f946d44c633cd85ce855550b /src/regchannel.cpp
parent03bee1706383d2766923e5d8edbb90d7ad1948b6 (diff)
Automatically determine SQL column type from the field.
Also add more column types to ensure we are storing data in the best format in the database.
Diffstat (limited to 'src/regchannel.cpp')
-rw-r--r--src/regchannel.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index f01b31f3e..1a68b537f 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -40,15 +40,15 @@ AutoKick::~AutoKick()
void AutoKick::Serialize(Serialize::Data &data) const
{
- data["ci"] << this->ci->name;
+ data.Store("ci", this->ci->name);
if (this->nc)
- data["nc"] << this->nc->display;
+ data.Store("nc", this->nc->display);
else
- data["mask"] << this->mask;
- data["reason"] << this->reason;
- data["creator"] << this->creator;
- data.SetType("addtime", Serialize::Data::DT_INT); data["addtime"] << this->addtime;
- data.SetType("last_used", Serialize::Data::DT_INT); data["last_used"] << this->last_used;
+ data.Store("mask", this->mask);
+ data.Store("reason", this->reason);
+ data.Store("creator", this->creator);
+ data.Store("addtime", this->addtime);
+ data.Store("last_used", this->last_used);
}
Serializable *AutoKick::Unserialize(Serializable *obj, Serialize::Data &data)
@@ -180,30 +180,33 @@ ChannelInfo::~ChannelInfo()
void ChannelInfo::Serialize(Serialize::Data &data) const
{
- data["name"] << this->name;
+ data.Store("name", this->name);
if (this->founder)
- data["founder"] << this->founder->display;
+ data.Store("founder", this->founder->display);
if (this->successor)
- data["successor"] << this->successor->display;
- data["description"] << this->desc;
- data.SetType("time_registered", Serialize::Data::DT_INT); data["time_registered"] << this->time_registered;
- data.SetType("last_used", Serialize::Data::DT_INT); data["last_used"] << this->last_used;
- data["last_topic"] << this->last_topic;
- data["last_topic_setter"] << this->last_topic_setter;
- data.SetType("last_topic_time", Serialize::Data::DT_INT); data["last_topic_time"] << this->last_topic_time;
- data.SetType("bantype", Serialize::Data::DT_INT); data["bantype"] << this->bantype;
+ data.Store("successor", this->successor->display);
+ data.Store("description", this->desc);
+ data.Store("time_registered", this->time_registered);
+ data.Store("last_used", this->last_used);
+ data.Store("last_topic", this->last_topic);
+ data.Store("last_topic_setter", this->last_topic_setter);
+ data.Store("last_topic_time", this->last_topic_time);
+ data.Store("bantype", this->bantype);
{
Anope::string levels_buffer;
for (const auto &[name, level] : this->levels)
levels_buffer += name + " " + Anope::ToString(level) + " ";
- data["levels"] << levels_buffer;
+ data.Store("levels", levels_buffer);
}
if (this->bi)
- data["bi"] << this->bi->nick;
- data.SetType("banexpire", Serialize::Data::DT_INT); data["banexpire"] << this->banexpire;
- data["memomax"] << this->memos.memomax;
+ data.Store("bi", this->bi->nick);
+ data.Store("banexpire", this->banexpire);
+ data.Store("memomax", this->memos.memomax);
+
+ std::ostringstream oss;
for (const auto &ignore : this->memos.ignores)
- data["memoignores"] << ignore << " ";
+ oss << ignore << " ";
+ data.Store("memoignores", oss.str());
Extensible::ExtensibleSerialize(this, this, data);
}