LibIPC: Remove redundant IPC::Dictionary type
We already have and use HashMap<DeprecatedString, DeprecatedString> nearly everywhere, which is essentially equivalent.
This commit is contained in:
parent
d030f0fe9b
commit
943ecaede6
Notes:
sideshowbarker
2024-07-17 02:39:10 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/943ecaede6 Pull-request: https://github.com/SerenityOS/serenity/pull/18928
7 changed files with 0 additions and 94 deletions
|
@ -779,7 +779,6 @@ void build(StringBuilder& builder, Vector<Endpoint> const& endpoints)
|
|||
#include <AK/Utf8View.h>
|
||||
#include <LibIPC/Connection.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Dictionary.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
#include <LibIPC/File.h>
|
||||
#include <LibIPC/Message.h>
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <LibCore/Proxy.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Dictionary.h>
|
||||
#include <LibIPC/File.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
@ -84,21 +83,6 @@ ErrorOr<URL> decode(Decoder& decoder)
|
|||
return URL { url };
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<Dictionary> decode(Decoder& decoder)
|
||||
{
|
||||
auto size = TRY(decoder.decode_size());
|
||||
Dictionary dictionary {};
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
auto key = TRY(decoder.decode<DeprecatedString>());
|
||||
auto value = TRY(decoder.decode<DeprecatedString>());
|
||||
dictionary.add(move(key), move(value));
|
||||
}
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<File> decode(Decoder& decoder)
|
||||
{
|
||||
|
|
|
@ -99,9 +99,6 @@ ErrorOr<Time> decode(Decoder&);
|
|||
template<>
|
||||
ErrorOr<URL> decode(Decoder&);
|
||||
|
||||
template<>
|
||||
ErrorOr<Dictionary> decode(Decoder&);
|
||||
|
||||
template<>
|
||||
ErrorOr<File> decode(Decoder&);
|
||||
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Concepts.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
|
||||
namespace IPC {
|
||||
|
||||
class Dictionary {
|
||||
public:
|
||||
Dictionary() = default;
|
||||
|
||||
Dictionary(HashMap<DeprecatedString, DeprecatedString>&& initial_entries)
|
||||
: m_entries(move(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);
|
||||
}
|
||||
}
|
||||
|
||||
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:
|
||||
HashMap<DeprecatedString, DeprecatedString> m_entries;
|
||||
};
|
||||
|
||||
}
|
|
@ -19,7 +19,6 @@
|
|||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/Proxy.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibIPC/Dictionary.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
#include <LibIPC/File.h>
|
||||
|
||||
|
@ -97,20 +96,6 @@ ErrorOr<void> encode(Encoder& encoder, URL const& value)
|
|||
return encoder.encode(value.to_deprecated_string());
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, Dictionary const& dictionary)
|
||||
{
|
||||
TRY(encoder.encode_size(dictionary.size()));
|
||||
|
||||
TRY(dictionary.try_for_each_entry([&](auto const& key, auto const& value) -> ErrorOr<void> {
|
||||
TRY(encoder.encode(key));
|
||||
TRY(encoder.encode(value));
|
||||
return {};
|
||||
}));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, File const& file)
|
||||
{
|
||||
|
|
|
@ -128,9 +128,6 @@ ErrorOr<void> encode(Encoder&, Time const&);
|
|||
template<>
|
||||
ErrorOr<void> encode(Encoder&, URL const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, Dictionary const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, File const&);
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
namespace IPC {
|
||||
|
||||
class Decoder;
|
||||
class Dictionary;
|
||||
class Encoder;
|
||||
class Message;
|
||||
class File;
|
||||
|
|
Loading…
Add table
Reference in a new issue