diff options
author | Sadie Powell <sadie@witchery.services> | 2025-02-23 00:07:05 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2025-02-23 17:50:05 +0000 |
commit | ee08b3e8804074c73245ca24c3663e43158eb790 (patch) | |
tree | dab5279bd4d3cecc3635b407f25eaf76dec2575c | |
parent | a4bfd52b7ed4a11d0795d8f35676c5892812ff43 (diff) |
Rename RPC::Block to RPC::Map.
-rw-r--r-- | include/modules/rpc.h | 26 | ||||
-rw-r--r-- | modules/extra/xmlrpc.cpp | 10 | ||||
-rw-r--r-- | modules/rpc/jsonrpc.cpp | 10 | ||||
-rw-r--r-- | modules/rpc/rpc_main.cpp | 6 |
4 files changed, 26 insertions, 26 deletions
diff --git a/include/modules/rpc.h b/include/modules/rpc.h index ca23a0286..c9f9200a7 100644 --- a/include/modules/rpc.h +++ b/include/modules/rpc.h @@ -14,13 +14,13 @@ namespace RPC { - class Block; class Event; + class Map; class Request; class ServiceInterface; /** Represents possible types of RPC value. */ - using Value = std::variant<Block, Anope::string, std::nullptr_t, bool, double, int64_t, uint64_t>; + using Value = std::variant<Map, Anope::string, std::nullptr_t, bool, double, int64_t, uint64_t>; /** Represents standard RPC errors from the JSON-RPC and XML-RPC specifications. */ enum Error @@ -35,50 +35,50 @@ namespace RPC }; } -class RPC::Block +class RPC::Map { public: /** Retrieves the list of RPC replies. */ inline const auto &GetReplies() const { return this->replies; } template <typename Stringable> - inline Block &Reply(const Anope::string &key, const Stringable &value) + inline Map &Reply(const Anope::string &key, const Stringable &value) { this->replies.emplace(key, Anope::ToString(value)); return *this; } - inline Block &ReplyBlock(const Anope::string &key) + inline Map &ReplyMap(const Anope::string &key) { - auto it = this->replies.emplace(key, Block()); - return std::get<Block>(it.first->second); + auto it = this->replies.emplace(key, Map()); + return std::get<Map>(it.first->second); } - inline Block &ReplyBool(const Anope::string &key, bool value) + inline Map &ReplyBool(const Anope::string &key, bool value) { this->replies.emplace(key, value); return *this; } - inline Block &ReplyFloat(const Anope::string &key, double value) + inline Map &ReplyFloat(const Anope::string &key, double value) { this->replies.emplace(key, value); return *this; } - inline Block &ReplyInt(const Anope::string &key, int64_t value) + inline Map &ReplyInt(const Anope::string &key, int64_t value) { this->replies.emplace(key, value); return *this; } - inline Block &ReplyNull(const Anope::string &key) + inline Map &ReplyNull(const Anope::string &key) { this->replies.emplace(key, nullptr); return *this; } - inline Block &ReplyUInt(const Anope::string &key, uint64_t value) + inline Map &ReplyUInt(const Anope::string &key, uint64_t value) { this->replies.emplace(key, value); return *this; @@ -89,7 +89,7 @@ private: }; class RPC::Request final - : public RPC::Block + : public RPC::Map { private: std::optional<std::pair<int64_t, Anope::string>> error; diff --git a/modules/extra/xmlrpc.cpp b/modules/extra/xmlrpc.cpp index df566c0a4..86cdaf9f7 100644 --- a/modules/extra/xmlrpc.cpp +++ b/modules/extra/xmlrpc.cpp @@ -42,17 +42,17 @@ private: xmlrpc_env_clean(&env); } - static void SerializeObject(xmlrpc_env &env, xmlrpc_value *value, const RPC::Block &block) + static void SerializeMap(xmlrpc_env &env, xmlrpc_value *value, const RPC::Map &map) { - for (const auto &[k, v] : block.GetReplies()) + for (const auto &[k, v] : map.GetReplies()) { xmlrpc_value *elem; std::visit(overloaded { - [&env, &elem](const RPC::Block &b) + [&env, &elem](const RPC::Map &m) { elem = xmlrpc_struct_new(&env); - SerializeObject(env, elem, b); + SerializeMap(env, elem, m); }, [&env, &elem](const Anope::string &s) { @@ -194,7 +194,7 @@ public: } auto *value = xmlrpc_struct_new(&env); - SerializeObject(env, value, request); + SerializeMap(env, value, request); auto *response = xmlrpc_mem_block_new(&env, 0); xmlrpc_serialize_response(&env, response, value); diff --git a/modules/rpc/jsonrpc.cpp b/modules/rpc/jsonrpc.cpp index 1b1c35a4d..b7c1f4042 100644 --- a/modules/rpc/jsonrpc.cpp +++ b/modules/rpc/jsonrpc.cpp @@ -59,18 +59,18 @@ private: yyjson_mut_doc_free(doc); } - static void SerializeObject(yyjson_mut_doc *doc, yyjson_mut_val *root, const char *key, const RPC::Block &block) + static void SerializeMap(yyjson_mut_doc *doc, yyjson_mut_val *root, const char *key, const RPC::Map &map) { auto *result = yyjson_mut_obj(doc); - for (const auto &reply : block.GetReplies()) + for (const auto &reply : map.GetReplies()) { // Captured structured bindings are a C++20 extension. const auto &k = reply.first; std::visit(overloaded { - [&doc, &result, &k](const RPC::Block &b) + [&doc, &result, &k](const RPC::Map &m) { - SerializeObject(doc, result, k.c_str(), b); + SerializeMap(doc, result, k.c_str(), m); }, [&doc, &result, &k](const Anope::string &s) { @@ -194,7 +194,7 @@ public: yyjson_mut_obj_add_strn(doc, root, "id", request.id.c_str(), request.id.length()); if (!request.GetReplies().empty()) - SerializeObject(doc, root, "result", request); + SerializeMap(doc, root, "result", request); yyjson_mut_obj_add_str(doc, root, "jsonrpc", "2.0"); diff --git a/modules/rpc/rpc_main.cpp b/modules/rpc/rpc_main.cpp index cee9d8837..7be09be22 100644 --- a/modules/rpc/rpc_main.cpp +++ b/modules/rpc/rpc_main.cpp @@ -192,19 +192,19 @@ public: if (c) { - auto &bans = request.ReplyBlock("bans"); + auto &bans = request.ReplyMap("bans"); bans.ReplyUInt("count", c->HasMode("BAN")); int count = 0; for (auto &ban : c->GetModeList("BAN")) bans.Reply(Anope::ToString(++count), ban); - auto &excepts = request.ReplyBlock("excepts"); + auto &excepts = request.ReplyMap("excepts"); excepts.ReplyUInt("count", c->HasMode("EXCEPT")); count = 0; for (auto &except : c->GetModeList("EXCEPT")) excepts.Reply(Anope::ToString(++count), except); - auto &invites = request.ReplyBlock("invites"); + auto &invites = request.ReplyMap("invites"); invites.ReplyUInt("count", c->HasMode("INVITEOVERRIDE")); count = 0; for (auto &invite : c->GetModeList("INVITEOVERRIDE")) |