mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +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;
|
return *this << u.as_u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
Encoder& Encoder::operator<<(const char* value)
|
Encoder& Encoder::operator<<(char const* value)
|
||||||
{
|
{
|
||||||
return *this << StringView(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;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Encoder& Encoder::operator<<(const String& value)
|
Encoder& Encoder::operator<<(String const& value)
|
||||||
{
|
{
|
||||||
if (value.is_null())
|
if (value.is_null())
|
||||||
return *this << (i32)-1;
|
return *this << (i32)-1;
|
||||||
|
@ -125,19 +125,19 @@ Encoder& Encoder::operator<<(const String& value)
|
||||||
return *this << value.view();
|
return *this << value.view();
|
||||||
}
|
}
|
||||||
|
|
||||||
Encoder& Encoder::operator<<(const ByteBuffer& value)
|
Encoder& Encoder::operator<<(ByteBuffer const& value)
|
||||||
{
|
{
|
||||||
*this << static_cast<i32>(value.size());
|
*this << static_cast<i32>(value.size());
|
||||||
m_buffer.data.append(value.data(), value.size());
|
m_buffer.data.append(value.data(), value.size());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Encoder& Encoder::operator<<(const URL& value)
|
Encoder& Encoder::operator<<(URL const& value)
|
||||||
{
|
{
|
||||||
return *this << value.to_string();
|
return *this << value.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
Encoder& Encoder::operator<<(const Dictionary& dictionary)
|
Encoder& Encoder::operator<<(Dictionary const& dictionary)
|
||||||
{
|
{
|
||||||
*this << (u64)dictionary.size();
|
*this << (u64)dictionary.size();
|
||||||
dictionary.for_each_entry([this](auto& key, auto& value) {
|
dictionary.for_each_entry([this](auto& key, auto& value) {
|
||||||
|
@ -146,7 +146,7 @@ Encoder& Encoder::operator<<(const Dictionary& dictionary)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Encoder& Encoder::operator<<(const File& file)
|
Encoder& Encoder::operator<<(File const& file)
|
||||||
{
|
{
|
||||||
int fd = file.fd();
|
int fd = file.fd();
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
|
@ -161,7 +161,7 @@ Encoder& Encoder::operator<<(const File& file)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool encode(Encoder& encoder, const Core::AnonymousBuffer& buffer)
|
bool encode(Encoder& encoder, Core::AnonymousBuffer const& buffer)
|
||||||
{
|
{
|
||||||
encoder << buffer.is_valid();
|
encoder << buffer.is_valid();
|
||||||
if (buffer.is_valid()) {
|
if (buffer.is_valid()) {
|
||||||
|
@ -171,7 +171,7 @@ bool encode(Encoder& encoder, const Core::AnonymousBuffer& buffer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool encode(Encoder& encoder, const Core::DateTime& datetime)
|
bool encode(Encoder& encoder, Core::DateTime const& datetime)
|
||||||
{
|
{
|
||||||
encoder << static_cast<i64>(datetime.timestamp());
|
encoder << static_cast<i64>(datetime.timestamp());
|
||||||
return true;
|
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
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -37,15 +37,15 @@ public:
|
||||||
Encoder& operator<<(i32);
|
Encoder& operator<<(i32);
|
||||||
Encoder& operator<<(i64);
|
Encoder& operator<<(i64);
|
||||||
Encoder& operator<<(float);
|
Encoder& operator<<(float);
|
||||||
Encoder& operator<<(const char*);
|
Encoder& operator<<(char const*);
|
||||||
Encoder& operator<<(const StringView&);
|
Encoder& operator<<(StringView const&);
|
||||||
Encoder& operator<<(const String&);
|
Encoder& operator<<(String const&);
|
||||||
Encoder& operator<<(const ByteBuffer&);
|
Encoder& operator<<(ByteBuffer const&);
|
||||||
Encoder& operator<<(const URL&);
|
Encoder& operator<<(URL const&);
|
||||||
Encoder& operator<<(const Dictionary&);
|
Encoder& operator<<(Dictionary const&);
|
||||||
Encoder& operator<<(const File&);
|
Encoder& operator<<(File const&);
|
||||||
template<typename K, typename V>
|
template<typename K, typename V>
|
||||||
Encoder& operator<<(const HashMap<K, V>& hashmap)
|
Encoder& operator<<(HashMap<K, V> const& hashmap)
|
||||||
{
|
{
|
||||||
*this << (u32)hashmap.size();
|
*this << (u32)hashmap.size();
|
||||||
for (auto it : hashmap) {
|
for (auto it : hashmap) {
|
||||||
|
@ -56,7 +56,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Encoder& operator<<(const Vector<T>& vector)
|
Encoder& operator<<(Vector<T> const& vector)
|
||||||
{
|
{
|
||||||
*this << (u64)vector.size();
|
*this << (u64)vector.size();
|
||||||
for (auto& value : vector)
|
for (auto& value : vector)
|
||||||
|
@ -72,14 +72,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Encoder& operator<<(const T& value)
|
Encoder& operator<<(T const& value)
|
||||||
{
|
{
|
||||||
encode(value);
|
encode(value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Encoder& operator<<(const Optional<T>& optional)
|
Encoder& operator<<(Optional<T> const& optional)
|
||||||
{
|
{
|
||||||
*this << optional.has_value();
|
*this << optional.has_value();
|
||||||
if (optional.has_value())
|
if (optional.has_value())
|
||||||
|
@ -88,7 +88,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void encode(const T& value)
|
void encode(T const& value)
|
||||||
{
|
{
|
||||||
IPC::encode(*this, value);
|
IPC::encode(*this, value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue