diff options
author | asynts <asynts@gmail.com> | 2020-09-20 13:03:23 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-21 09:37:49 +0200 |
commit | 31bb107922f8c869bfecb348288a7e4dc74d8937 (patch) | |
tree | db30e6304d24eaa1987a209a3aa8016b2a4958f1 /Libraries/LibJS/Heap/Heap.cpp | |
parent | c879ecf5096e112bd271801f9d919a853bc38bfb (diff) | |
download | serenity-31bb107922f8c869bfecb348288a7e4dc74d8937.zip |
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>.
Diffstat (limited to 'Libraries/LibJS/Heap/Heap.cpp')
0 files changed, 0 insertions, 0 deletions