LibIPC: Add a Dictionary for-each method for fallible callbacks

Similar to a similar change to JsonObject (13b18a1).
This commit is contained in:
Timothy Flynn 2023-01-01 23:36:21 -05:00 committed by Andreas Kling
parent af2ae7fda1
commit d0f3f3d5ff
Notes: sideshowbarker 2024-07-18 01:43:16 +09:00

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/Concepts.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
@ -37,6 +38,14 @@ public:
}
}
template<FallibleFunction<DeprecatedString const&, DeprecatedString const&> Callback>
ErrorOr<void> try_for_each_entry(Callback&& callback) const
{
for (auto const& it : m_entries)
TRY(callback(it.key, it.value));
return {};
}
HashMap<DeprecatedString, DeprecatedString> const& entries() const { return m_entries; }
private: