diff options
| author | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
| commit | 42238034490fb5479d787bd1695750387d508200 (patch) | |
| tree | c93c62e0e1c936e656ae5b9ee1b62380ce2a194c /modules/commands/ns_alist.cpp | |
| parent | d492923610d9c9146b2a2b63de38deab2cfd4ca7 (diff) | |
Rewrite serializable to have field level granularity
Represent serializable objects in a digraph, and as a result made most
object relationships implicitly defined, and use the graph to trace
references between objects to determine relationships. Edges may
also be marked as having a dependency of the object they point to,
which allows for automatic cleanup and deletion of most objects when
no longer needed.
Additionally, this allows not having to require in-memory copies of
everything when using external databases. db_sql has been rewritten
for this and now always requires a database to function. db_sql with
MySQL now requires InnoDB to make use of transactions and foreign
key constraints.
Diffstat (limited to 'modules/commands/ns_alist.cpp')
| -rw-r--r-- | modules/commands/ns_alist.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp index 58ec600fe..01a0419b7 100644 --- a/modules/commands/ns_alist.cpp +++ b/modules/commands/ns_alist.cpp @@ -15,7 +15,7 @@ class CommandNSAList : public Command { static bool ChannelSort(ChanServ::Channel *ci1, ChanServ::Channel *ci2) { - return ci::less()(ci1->name, ci2->name); + return ci::less()(ci1->GetName(), ci2->GetName()); } public: @@ -33,13 +33,13 @@ class CommandNSAList : public Command if (params.size() && source.HasPriv("nickserv/alist")) { nick = params[0]; - const NickServ::Nick *na = NickServ::FindNick(nick); + NickServ::Nick *na = NickServ::FindNick(nick); if (!na) { source.Reply(_("\002{0}\002 isn't registered."), nick); return; } - nc = na->nc; + nc = na->GetAccount(); } ListFormatter list(source.GetAccount()); @@ -47,22 +47,19 @@ class CommandNSAList : public Command list.AddColumn(_("Number")).AddColumn(_("Channel")).AddColumn(_("Access")).AddColumn(_("Description")); - std::deque<ChanServ::Channel *> queue; - nc->GetChannelReferences(queue); - std::sort(queue.begin(), queue.end(), ChannelSort); - - for (unsigned i = 0; i < queue.size(); ++i) + std::vector<ChanServ::Channel *> chans = nc->GetRefs<ChanServ::Channel *>(ChanServ::channel); + std::sort(chans.begin(), chans.end(), ChannelSort); + for (ChanServ::Channel *ci : chans) { - ChanServ::Channel *ci = queue[i]; ListFormatter::ListEntry entry; if (ci->GetFounder() == nc) { ++chan_count; entry["Number"] = stringify(chan_count); - entry["Channel"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name; + entry["Channel"] = (ci->HasFieldS("CS_NO_EXPIRE") ? "!" : "") + ci->GetName(); entry["Access"] = Language::Translate(source.GetAccount(), _("Founder")); - entry["Description"] = ci->desc; + entry["Description"] = ci->GetDesc(); list.AddEntry(entry); continue; } @@ -71,9 +68,9 @@ class CommandNSAList : public Command { ++chan_count; entry["Number"] = stringify(chan_count); - entry["Channel"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name; + entry["Channel"] = (ci->HasFieldS("CS_NO_EXPIRE") ? "!" : "") + ci->GetName(); entry["Access"] = Language::Translate(source.GetAccount(), _("Successor")); - entry["Description"] = ci->desc; + entry["Description"] = ci->GetDesc(); list.AddEntry(entry); continue; } @@ -85,11 +82,11 @@ class CommandNSAList : public Command ++chan_count; entry["Number"] = stringify(chan_count); - entry["Channel"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name; + entry["Channel"] = (ci->HasFieldS("CS_NO_EXPIRE") ? "!" : "") + ci->GetName(); for (unsigned j = 0; j < access.size(); ++j) entry["Access"] = entry["Access"] + ", " + access[j]->AccessSerialize(); entry["Access"] = entry["Access"].substr(2); - entry["Description"] = ci->desc; + entry["Description"] = ci->GetDesc(); list.AddEntry(entry); } @@ -98,11 +95,11 @@ class CommandNSAList : public Command if (!chan_count) { - source.Reply(_("\002{0}\002 has no access in any channels."), nc->display); + source.Reply(_("\002{0}\002 has no access in any channels."), nc->GetDisplay()); } else { - source.Reply(_("Channels that \002{0}\002 has access on:"), nc->display); + source.Reply(_("Channels that \002{0}\002 has access on:"), nc->GetDisplay()); for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); |
