ladybird/Userland/Libraries/LibIPC/Dictionary.h
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

45 lines
874 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/HashMap.h>
#include <AK/String.h>
namespace IPC {
class Dictionary {
public:
Dictionary() { }
Dictionary(const HashMap<String, String>& 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(String key, String 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);
}
}
const HashMap<String, String>& entries() const { return m_entries; }
private:
HashMap<String, String> m_entries;
};
}