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

AK: Add DuplexMemoryStream class.

This class is similar to BufferStream because it is possible to both
read and write to it. However, it differs in the following ways:

  - DuplexMemoryStream keeps a history of 64KiB and discards the rest,
    BufferStream always keeps everything around.

  - DuplexMemoryStream tracks reading and writing seperately, the
    following is valid:

        DuplexMemoryStream stream;
        stream << 42;
        int value;
        stream >> value;

    For BufferStream it would read:

        BufferStream stream;
        stream << 42;
        int value;
        stream.seek(0);
        stream >> value;

In the future I would like to replace all usages of BufferStream with
InputMemoryStream, OutputMemoryStream (doesn't exist yet) and
DuplexMemoryStream. For now I just add DuplexMemoryStream though.
This commit is contained in:
asynts 2020-08-18 18:04:17 +02:00 committed by Andreas Kling
parent a15556638d
commit 30abadcff9
3 changed files with 222 additions and 1 deletions

View file

@ -50,6 +50,7 @@ class Utf32View;
class Utf8View;
class InputStream;
class InputMemoryStream;
class DuplexMemoryStream;
template<typename T>
class Span;
@ -125,6 +126,7 @@ using AK::Bytes;
using AK::CircularQueue;
using AK::DebugLogStream;
using AK::DoublyLinkedList;
using AK::DuplexMemoryStream;
using AK::FixedArray;
using AK::FlyString;
using AK::Function;