1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 14:05:06 +00:00
serenity/Userland/Libraries/LibIPC/Dictionary.h
Linus Groh 6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00

46 lines
1,021 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
namespace IPC {
class Dictionary {
public:
Dictionary() = default;
Dictionary(HashMap<DeprecatedString, DeprecatedString> const& initial_entries)
: m_entries(initial_entries)
{
}
bool is_empty() const { return m_entries.is_empty(); }
size_t size() const { return m_entries.size(); }
void add(DeprecatedString key, DeprecatedString value)
{
m_entries.set(move(key), move(value));
}
template<typename Callback>
void for_each_entry(Callback callback) const
{
for (auto& it : m_entries) {
callback(it.key, it.value);
}
}
HashMap<DeprecatedString, DeprecatedString> const& entries() const { return m_entries; }
private:
HashMap<DeprecatedString, DeprecatedString> m_entries;
};
}