From f10036b7c5c4cf4a9b7d032f1b6569c887cb6ccb Mon Sep 17 00:00:00 2001 From: faxe1008 Date: Tue, 16 Nov 2021 20:08:29 +0100 Subject: LibConfig: Add list methods for groups and keys Use the methods exposed by ConfigServer to list groups and keys. --- Userland/Libraries/LibConfig/Client.cpp | 10 ++++++++++ Userland/Libraries/LibConfig/Client.h | 13 +++++++++++++ 2 files changed, 23 insertions(+) (limited to 'Userland/Libraries/LibConfig') diff --git a/Userland/Libraries/LibConfig/Client.cpp b/Userland/Libraries/LibConfig/Client.cpp index bae912a9e3..3394d22b58 100644 --- a/Userland/Libraries/LibConfig/Client.cpp +++ b/Userland/Libraries/LibConfig/Client.cpp @@ -30,6 +30,16 @@ void Client::monitor_domain(String const& domain) async_monitor_domain(domain); } +Vector Client::list_keys(StringView domain, StringView group) +{ + return list_config_keys(domain, group); +} + +Vector Client::list_groups(StringView domain) +{ + return list_config_groups(domain); +} + String Client::read_string(StringView domain, StringView group, StringView key, StringView fallback) { return read_string_value(domain, group, key).value_or(fallback); diff --git a/Userland/Libraries/LibConfig/Client.h b/Userland/Libraries/LibConfig/Client.h index 04e33fb94f..6f01a05aa2 100644 --- a/Userland/Libraries/LibConfig/Client.h +++ b/Userland/Libraries/LibConfig/Client.h @@ -24,6 +24,9 @@ public: void pledge_domains(Vector const&); void monitor_domain(String const&); + Vector list_groups(StringView domain); + Vector list_keys(StringView domain, StringView group); + String read_string(StringView domain, StringView group, StringView key, StringView fallback); i32 read_i32(StringView domain, StringView group, StringView key, i32 fallback); bool read_bool(StringView domain, StringView group, StringView key, bool fallback); @@ -47,6 +50,16 @@ private: void notify_removed_key(String const& domain, String const& group, String const& key) override; }; +inline Vector list_groups(StringView domain) +{ + return Client::the().list_groups(domain); +} + +inline Vector list_keys(StringView domain, StringView group) +{ + return Client::the().list_keys(domain, group); +} + inline String read_string(StringView domain, StringView group, StringView key, StringView fallback = {}) { return Client::the().read_string(domain, group, key, fallback); -- cgit v1.2.3