1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

LibIPC: Use InputMemoryStream instead of BufferStream.

This commit is contained in:
asynts 2020-09-20 13:00:54 +02:00 committed by Andreas Kling
parent 7d1b22bbb1
commit c879ecf509
4 changed files with 24 additions and 27 deletions

View file

@ -24,7 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/BufferStream.h>
#include <AK/MemoryStream.h>
#include <AK/URL.h>
#include <LibIPC/Decoder.h>
#include <LibIPC/Dictionary.h>
@ -34,68 +34,68 @@ namespace IPC {
bool Decoder::decode(bool& value)
{
m_stream >> value;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(u8& value)
{
m_stream >> value;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(u16& value)
{
m_stream >> value;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(u32& value)
{
m_stream >> value;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(u64& value)
{
m_stream >> value;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(i8& value)
{
m_stream >> value;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(i16& value)
{
m_stream >> value;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(i32& value)
{
m_stream >> value;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(i64& value)
{
m_stream >> value;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(float& value)
{
m_stream >> value;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(String& value)
{
i32 length = 0;
m_stream >> length;
if (m_stream.handle_read_failure())
if (m_stream.handle_any_error())
return false;
if (length < 0) {
value = {};
@ -107,11 +107,9 @@ bool Decoder::decode(String& value)
}
char* text_buffer = nullptr;
auto text_impl = StringImpl::create_uninitialized(static_cast<size_t>(length), text_buffer);
for (size_t i = 0; i < static_cast<size_t>(length); ++i) {
m_stream >> text_buffer[i];
}
m_stream >> Bytes { text_buffer, static_cast<size_t>(length) };
value = *text_impl;
return !m_stream.handle_read_failure();
return !m_stream.handle_any_error();
}
bool Decoder::decode(URL& value)
@ -127,7 +125,7 @@ bool Decoder::decode(Dictionary& dictionary)
{
u64 size = 0;
m_stream >> size;
if (m_stream.handle_read_failure())
if (m_stream.handle_any_error())
return false;
if (size >= NumericLimits<i32>::max()) {
ASSERT_NOT_REACHED();

View file

@ -43,7 +43,7 @@ inline bool decode(Decoder&, T&)
class Decoder {
public:
explicit Decoder(BufferStream& stream)
explicit Decoder(InputMemoryStream& stream)
: m_stream(stream)
{
}
@ -101,7 +101,7 @@ public:
}
private:
BufferStream& m_stream;
InputMemoryStream& m_stream;
};
}

View file

@ -32,10 +32,9 @@
namespace IPC {
template<typename T>
bool encode(BufferStream&, T&)
bool encode(Encoder&, T&)
{
ASSERT_NOT_REACHED();
return false;
}
class Encoder {