mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-11 19:16:24 +00:00
LibIPC: Add a Dictionary for-each method for fallible callbacks
Similar to a similar change to JsonObject (13b18a1).
This commit is contained in:
committed by
Andreas Kling
parent
af2ae7fda1
commit
d0f3f3d5ff
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user