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

AK: Remove BufferStream class.

There are three classes avaliable that share the functionality of
BufferStream:

 1. InputMemoryStream is for reading from static buffers. Example:

        Bytes input = /* ... */;
        InputMemoryStream stream { input };

        LittleEndian<u32> little_endian_value;
        input >> little_endian_value;

        u32 host_endian_value;
        input >> host_endian_value;

        SomeComplexStruct complex_struct;
        input >> Bytes { &complex_struct, sizeof(complex_struct) };

 2. OutputMemoryStream is for writing to static buffers. Example:

        Array<u8, 4096> buffer;
        OutputMemoryStream stream;

        stream << LittleEndian<u32> { 42 };
        stream << ReadonlyBytes { &complex_struct, sizeof(complex_struct) };

        foo(stream.bytes());

 3. DuplexMemoryStream for writing to dynamic buffers, can also be used
    as an intermediate buffer by reading from it directly. Example:

        DuplexMemoryStream stream;

        stream << NetworkOrdered<u32> { 13 };
        stream << NetowkrOrdered<u64> { 22 };

        NetworkOrdered<u32> value;
        stream >> value;
        ASSERT(value == 13);

        foo(stream.copy_into_contiguous_buffer());

Unlike BufferStream these streams do not use a fixed endianness
(BufferStream used little endian) these have to be explicitly specified.
There are helper types in <AK/Endian.h>.
This commit is contained in:
asynts 2020-09-20 13:03:23 +02:00 committed by Andreas Kling
parent c879ecf509
commit 31bb107922
2 changed files with 0 additions and 406 deletions

View file

@ -31,7 +31,6 @@
namespace AK {
class Bitmap;
class BufferStream;
class ByteBuffer;
class DebugLogStream;
class IPv4Address;
@ -130,7 +129,6 @@ using AK::Array;
using AK::Atomic;
using AK::Badge;
using AK::Bitmap;
using AK::BufferStream;
using AK::ByteBuffer;
using AK::Bytes;
using AK::CircularDuplexStream;