mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +00:00
LibIPC: Convert Encoder class to east-const style
This commit is contained in:
parent
2ef1cd8d12
commit
7df8483379
2 changed files with 23 additions and 23 deletions
|
@ -106,18 +106,18 @@ Encoder& Encoder::operator<<(float value)
|
|||
return *this << u.as_u32;
|
||||
}
|
||||
|
||||
Encoder& Encoder::operator<<(const char* value)
|
||||
Encoder& Encoder::operator<<(char const* value)
|
||||
{
|
||||
return *this << StringView(value);
|
||||
}
|
||||
|
||||
Encoder& Encoder::operator<<(const StringView& value)
|
||||
Encoder& Encoder::operator<<(StringView const& value)
|
||||
{
|
||||
m_buffer.data.append((const u8*)value.characters_without_null_termination(), value.length());
|
||||
m_buffer.data.append((u8 const*)value.characters_without_null_termination(), value.length());
|
||||
return *this;
|
||||
}
|
||||
|
||||
Encoder& Encoder::operator<<(const String& value)
|
||||
Encoder& Encoder::operator<<(String const& value)
|
||||
{
|
||||
if (value.is_null())
|
||||
return *this << (i32)-1;
|
||||
|
@ -125,19 +125,19 @@ Encoder& Encoder::operator<<(const String& value)
|
|||
return *this << value.view();
|
||||
}
|
||||
|
||||
Encoder& Encoder::operator<<(const ByteBuffer& value)
|
||||
Encoder& Encoder::operator<<(ByteBuffer const& value)
|
||||
{
|
||||
*this << static_cast<i32>(value.size());
|
||||
m_buffer.data.append(value.data(), value.size());
|
||||
return *this;
|
||||
}
|
||||
|
||||
Encoder& Encoder::operator<<(const URL& value)
|
||||
Encoder& Encoder::operator<<(URL const& value)
|
||||
{
|
||||
return *this << value.to_string();
|
||||
}
|
||||
|
||||
Encoder& Encoder::operator<<(const Dictionary& dictionary)
|
||||
Encoder& Encoder::operator<<(Dictionary const& dictionary)
|
||||
{
|
||||
*this << (u64)dictionary.size();
|
||||
dictionary.for_each_entry([this](auto& key, auto& value) {
|
||||
|
@ -146,7 +146,7 @@ Encoder& Encoder::operator<<(const Dictionary& dictionary)
|
|||
return *this;
|
||||
}
|
||||
|
||||
Encoder& Encoder::operator<<(const File& file)
|
||||
Encoder& Encoder::operator<<(File const& file)
|
||||
{
|
||||
int fd = file.fd();
|
||||
if (fd != -1) {
|
||||
|
@ -161,7 +161,7 @@ Encoder& Encoder::operator<<(const File& file)
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool encode(Encoder& encoder, const Core::AnonymousBuffer& buffer)
|
||||
bool encode(Encoder& encoder, Core::AnonymousBuffer const& buffer)
|
||||
{
|
||||
encoder << buffer.is_valid();
|
||||
if (buffer.is_valid()) {
|
||||
|
@ -171,7 +171,7 @@ bool encode(Encoder& encoder, const Core::AnonymousBuffer& buffer)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool encode(Encoder& encoder, const Core::DateTime& datetime)
|
||||
bool encode(Encoder& encoder, Core::DateTime const& datetime)
|
||||
{
|
||||
encoder << static_cast<i64>(datetime.timestamp());
|
||||
return true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -37,15 +37,15 @@ public:
|
|||
Encoder& operator<<(i32);
|
||||
Encoder& operator<<(i64);
|
||||
Encoder& operator<<(float);
|
||||
Encoder& operator<<(const char*);
|
||||
Encoder& operator<<(const StringView&);
|
||||
Encoder& operator<<(const String&);
|
||||
Encoder& operator<<(const ByteBuffer&);
|
||||
Encoder& operator<<(const URL&);
|
||||
Encoder& operator<<(const Dictionary&);
|
||||
Encoder& operator<<(const File&);
|
||||
Encoder& operator<<(char const*);
|
||||
Encoder& operator<<(StringView const&);
|
||||
Encoder& operator<<(String const&);
|
||||
Encoder& operator<<(ByteBuffer const&);
|
||||
Encoder& operator<<(URL const&);
|
||||
Encoder& operator<<(Dictionary const&);
|
||||
Encoder& operator<<(File const&);
|
||||
template<typename K, typename V>
|
||||
Encoder& operator<<(const HashMap<K, V>& hashmap)
|
||||
Encoder& operator<<(HashMap<K, V> const& hashmap)
|
||||
{
|
||||
*this << (u32)hashmap.size();
|
||||
for (auto it : hashmap) {
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
Encoder& operator<<(const Vector<T>& vector)
|
||||
Encoder& operator<<(Vector<T> const& vector)
|
||||
{
|
||||
*this << (u64)vector.size();
|
||||
for (auto& value : vector)
|
||||
|
@ -72,14 +72,14 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
Encoder& operator<<(const T& value)
|
||||
Encoder& operator<<(T const& value)
|
||||
{
|
||||
encode(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Encoder& operator<<(const Optional<T>& optional)
|
||||
Encoder& operator<<(Optional<T> const& optional)
|
||||
{
|
||||
*this << optional.has_value();
|
||||
if (optional.has_value())
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void encode(const T& value)
|
||||
void encode(T const& value)
|
||||
{
|
||||
IPC::encode(*this, value);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue