mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:34:57 +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:
parent
af2ae7fda1
commit
d0f3f3d5ff
1 changed files with 9 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue