From d0f3f3d5ff1f783dcad5b6d8d0ceb38bbc397688 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 1 Jan 2023 23:36:21 -0500 Subject: LibIPC: Add a Dictionary for-each method for fallible callbacks Similar to a similar change to JsonObject (13b18a1). --- Userland/Libraries/LibIPC/Dictionary.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Userland/Libraries/LibIPC') diff --git a/Userland/Libraries/LibIPC/Dictionary.h b/Userland/Libraries/LibIPC/Dictionary.h index 437f3bffdd..9a83c03d2c 100644 --- a/Userland/Libraries/LibIPC/Dictionary.h +++ b/Userland/Libraries/LibIPC/Dictionary.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -37,6 +38,14 @@ public: } } + template Callback> + ErrorOr try_for_each_entry(Callback&& callback) const + { + for (auto const& it : m_entries) + TRY(callback(it.key, it.value)); + return {}; + } + HashMap const& entries() const { return m_entries; } private: -- cgit v1.2.3