mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 15:17:46 +00:00
AK: Deprecate the old AK::Stream
This also removes a few cases where the respective header wasn't actually required to be included.
This commit is contained in:
parent
230cb3b0cb
commit
ae64b68717
38 changed files with 116 additions and 120 deletions
|
@ -119,7 +119,7 @@ private:
|
|||
};
|
||||
|
||||
template<typename StreamType, size_t Size>
|
||||
requires(IsBaseOf<OutputStream, StreamType>) class Buffered<StreamType, Size> : public OutputStream {
|
||||
requires(IsBaseOf<DeprecatedOutputStream, StreamType>) class Buffered<StreamType, Size> : public DeprecatedOutputStream {
|
||||
AK_MAKE_NONCOPYABLE(Buffered);
|
||||
|
||||
public:
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedStream.h>
|
||||
#include <AK/LEB128.h>
|
||||
#include <AK/MemMem.h>
|
||||
#include <AK/Stream.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
class InputMemoryStream final : public InputStream {
|
||||
class DeprecatedInputMemoryStream final : public DeprecatedInputStream {
|
||||
public:
|
||||
explicit InputMemoryStream(ReadonlyBytes bytes)
|
||||
explicit DeprecatedInputMemoryStream(ReadonlyBytes bytes)
|
||||
: m_bytes(bytes)
|
||||
{
|
||||
}
|
||||
|
@ -89,9 +89,9 @@ private:
|
|||
size_t m_offset { 0 };
|
||||
};
|
||||
|
||||
class OutputMemoryStream final : public OutputStream {
|
||||
class DeprecatedOutputMemoryStream final : public DeprecatedOutputStream {
|
||||
public:
|
||||
explicit OutputMemoryStream(Bytes bytes)
|
||||
explicit DeprecatedOutputMemoryStream(Bytes bytes)
|
||||
: m_bytes(bytes)
|
||||
{
|
||||
}
|
||||
|
@ -141,7 +141,6 @@ private:
|
|||
}
|
||||
|
||||
#if USING_AK_GLOBALLY
|
||||
using AK::InputMemoryStream;
|
||||
using AK::InputStream;
|
||||
using AK::OutputMemoryStream;
|
||||
using AK::DeprecatedInputMemoryStream;
|
||||
using AK::DeprecatedOutputMemoryStream;
|
||||
#endif
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
namespace AK::Detail {
|
||||
|
||||
class Stream {
|
||||
class DeprecatedStream {
|
||||
public:
|
||||
virtual ~Stream() { VERIFY(!has_any_error()); }
|
||||
virtual ~DeprecatedStream() { VERIFY(!has_any_error()); }
|
||||
|
||||
virtual bool has_recoverable_error() const { return m_recoverable_error; }
|
||||
virtual bool has_fatal_error() const { return m_fatal_error; }
|
||||
|
@ -60,7 +60,7 @@ private:
|
|||
|
||||
namespace AK {
|
||||
|
||||
class InputStream : public virtual Detail::Stream {
|
||||
class DeprecatedInputStream : public virtual Detail::DeprecatedStream {
|
||||
public:
|
||||
// Reads at least one byte unless none are requested or none are available. Does nothing
|
||||
// and returns zero if there is already an error.
|
||||
|
@ -81,52 +81,52 @@ public:
|
|||
virtual bool discard_or_error(size_t count) = 0;
|
||||
};
|
||||
|
||||
class OutputStream : public virtual Detail::Stream {
|
||||
class DeprecatedOutputStream : public virtual Detail::DeprecatedStream {
|
||||
public:
|
||||
virtual size_t write(ReadonlyBytes) = 0;
|
||||
virtual bool write_or_error(ReadonlyBytes) = 0;
|
||||
};
|
||||
|
||||
class DuplexStream
|
||||
: public InputStream
|
||||
, public OutputStream {
|
||||
class DeprecatedDuplexStream
|
||||
: public DeprecatedInputStream
|
||||
, public DeprecatedOutputStream {
|
||||
};
|
||||
|
||||
inline InputStream& operator>>(InputStream& stream, Bytes bytes)
|
||||
inline DeprecatedInputStream& operator>>(DeprecatedInputStream& stream, Bytes bytes)
|
||||
{
|
||||
stream.read_or_error(bytes);
|
||||
return stream;
|
||||
}
|
||||
inline OutputStream& operator<<(OutputStream& stream, ReadonlyBytes bytes)
|
||||
inline DeprecatedOutputStream& operator<<(DeprecatedOutputStream& stream, ReadonlyBytes bytes)
|
||||
{
|
||||
stream.write_or_error(bytes);
|
||||
return stream;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
InputStream& operator>>(InputStream& stream, LittleEndian<T>& value)
|
||||
DeprecatedInputStream& operator>>(DeprecatedInputStream& stream, LittleEndian<T>& value)
|
||||
{
|
||||
return stream >> Bytes { &value.m_value, sizeof(value.m_value) };
|
||||
}
|
||||
template<typename T>
|
||||
OutputStream& operator<<(OutputStream& stream, LittleEndian<T> value)
|
||||
DeprecatedOutputStream& operator<<(DeprecatedOutputStream& stream, LittleEndian<T> value)
|
||||
{
|
||||
return stream << ReadonlyBytes { &value.m_value, sizeof(value.m_value) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
InputStream& operator>>(InputStream& stream, BigEndian<T>& value)
|
||||
DeprecatedInputStream& operator>>(DeprecatedInputStream& stream, BigEndian<T>& value)
|
||||
{
|
||||
return stream >> Bytes { &value.m_value, sizeof(value.m_value) };
|
||||
}
|
||||
template<typename T>
|
||||
OutputStream& operator<<(OutputStream& stream, BigEndian<T> value)
|
||||
DeprecatedOutputStream& operator<<(DeprecatedOutputStream& stream, BigEndian<T> value)
|
||||
{
|
||||
return stream << ReadonlyBytes { &value.m_value, sizeof(value.m_value) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
InputStream& operator>>(InputStream& stream, Optional<T>& value)
|
||||
DeprecatedInputStream& operator>>(DeprecatedInputStream& stream, Optional<T>& value)
|
||||
{
|
||||
T temporary;
|
||||
stream >> temporary;
|
||||
|
@ -135,13 +135,13 @@ InputStream& operator>>(InputStream& stream, Optional<T>& value)
|
|||
}
|
||||
|
||||
template<Integral I>
|
||||
InputStream& operator>>(InputStream& stream, I& value)
|
||||
DeprecatedInputStream& operator>>(DeprecatedInputStream& stream, I& value)
|
||||
{
|
||||
stream.read_or_error({ &value, sizeof(value) });
|
||||
return stream;
|
||||
}
|
||||
template<Integral I>
|
||||
OutputStream& operator<<(OutputStream& stream, I value)
|
||||
DeprecatedOutputStream& operator<<(DeprecatedOutputStream& stream, I value)
|
||||
{
|
||||
stream.write_or_error({ &value, sizeof(value) });
|
||||
return stream;
|
||||
|
@ -150,13 +150,13 @@ OutputStream& operator<<(OutputStream& stream, I value)
|
|||
#ifndef KERNEL
|
||||
|
||||
template<FloatingPoint F>
|
||||
InputStream& operator>>(InputStream& stream, F& value)
|
||||
DeprecatedInputStream& operator>>(DeprecatedInputStream& stream, F& value)
|
||||
{
|
||||
stream.read_or_error({ &value, sizeof(value) });
|
||||
return stream;
|
||||
}
|
||||
template<FloatingPoint F>
|
||||
OutputStream& operator<<(OutputStream& stream, F value)
|
||||
DeprecatedOutputStream& operator<<(DeprecatedOutputStream& stream, F value)
|
||||
{
|
||||
stream.write_or_error({ &value, sizeof(value) });
|
||||
return stream;
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/DeprecatedStream.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Function.h>
|
||||
|
@ -415,7 +416,7 @@ bool DeprecatedString::operator==(char const* cstring) const
|
|||
return view() == cstring;
|
||||
}
|
||||
|
||||
InputStream& operator>>(InputStream& stream, DeprecatedString& string)
|
||||
DeprecatedInputStream& operator>>(DeprecatedInputStream& stream, DeprecatedString& string)
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <AK/Format.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Stream.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringImpl.h>
|
||||
#include <AK/StringUtils.h>
|
||||
|
@ -339,7 +338,7 @@ struct CaseInsensitiveStringTraits : public Traits<DeprecatedString> {
|
|||
|
||||
DeprecatedString escape_html_entities(StringView html);
|
||||
|
||||
InputStream& operator>>(InputStream& stream, DeprecatedString& string);
|
||||
DeprecatedInputStream& operator>>(DeprecatedInputStream& stream, DeprecatedString& string);
|
||||
|
||||
}
|
||||
|
||||
|
|
16
AK/Endian.h
16
AK/Endian.h
|
@ -80,16 +80,16 @@ template<typename T>
|
|||
class LittleEndian;
|
||||
|
||||
template<typename T>
|
||||
InputStream& operator>>(InputStream&, LittleEndian<T>&);
|
||||
DeprecatedInputStream& operator>>(DeprecatedInputStream&, LittleEndian<T>&);
|
||||
|
||||
template<typename T>
|
||||
OutputStream& operator<<(OutputStream&, LittleEndian<T>);
|
||||
DeprecatedOutputStream& operator<<(DeprecatedOutputStream&, LittleEndian<T>);
|
||||
|
||||
template<typename T>
|
||||
class [[gnu::packed]] LittleEndian {
|
||||
public:
|
||||
friend InputStream& operator>><T>(InputStream&, LittleEndian<T>&);
|
||||
friend OutputStream& operator<< <T>(OutputStream&, LittleEndian<T>);
|
||||
friend DeprecatedInputStream& operator>><T>(DeprecatedInputStream&, LittleEndian<T>&);
|
||||
friend DeprecatedOutputStream& operator<< <T>(DeprecatedOutputStream&, LittleEndian<T>);
|
||||
|
||||
constexpr LittleEndian() = default;
|
||||
|
||||
|
@ -112,16 +112,16 @@ template<typename T>
|
|||
class BigEndian;
|
||||
|
||||
template<typename T>
|
||||
InputStream& operator>>(InputStream&, BigEndian<T>&);
|
||||
DeprecatedInputStream& operator>>(DeprecatedInputStream&, BigEndian<T>&);
|
||||
|
||||
template<typename T>
|
||||
OutputStream& operator<<(OutputStream&, BigEndian<T>);
|
||||
DeprecatedOutputStream& operator<<(DeprecatedOutputStream&, BigEndian<T>);
|
||||
|
||||
template<typename T>
|
||||
class [[gnu::packed]] BigEndian {
|
||||
public:
|
||||
friend InputStream& operator>><T>(InputStream&, BigEndian<T>&);
|
||||
friend OutputStream& operator<< <T>(OutputStream&, BigEndian<T>);
|
||||
friend DeprecatedInputStream& operator>><T>(DeprecatedInputStream&, BigEndian<T>&);
|
||||
friend DeprecatedOutputStream& operator<< <T>(DeprecatedOutputStream&, BigEndian<T>);
|
||||
|
||||
constexpr BigEndian() = default;
|
||||
|
||||
|
|
16
AK/Forward.h
16
AK/Forward.h
|
@ -20,6 +20,10 @@ class ByteBuffer;
|
|||
class Bitmap;
|
||||
using ByteBuffer = Detail::ByteBuffer<32>;
|
||||
class CircularBuffer;
|
||||
class DeprecatedInputStream;
|
||||
class DeprecatedInputMemoryStream;
|
||||
class DeprecatedOutputStream;
|
||||
class DeprecatedOutputMemoryStream;
|
||||
class Error;
|
||||
class FlyString;
|
||||
class GenericLexer;
|
||||
|
@ -41,10 +45,6 @@ class Utf16View;
|
|||
class Utf32View;
|
||||
class Utf8CodePointIterator;
|
||||
class Utf8View;
|
||||
class InputStream;
|
||||
class InputMemoryStream;
|
||||
class OutputStream;
|
||||
class OutputMemoryStream;
|
||||
|
||||
template<typename T>
|
||||
class Span;
|
||||
|
@ -156,6 +156,10 @@ using AK::Bytes;
|
|||
using AK::CircularBuffer;
|
||||
using AK::CircularQueue;
|
||||
using AK::DeprecatedFlyString;
|
||||
using AK::DeprecatedInputMemoryStream;
|
||||
using AK::DeprecatedInputStream;
|
||||
using AK::DeprecatedOutputMemoryStream;
|
||||
using AK::DeprecatedOutputStream;
|
||||
using AK::DeprecatedString;
|
||||
using AK::DeprecatedStringCodePointIterator;
|
||||
using AK::DoublyLinkedList;
|
||||
|
@ -167,8 +171,6 @@ using AK::Function;
|
|||
using AK::GenericLexer;
|
||||
using AK::HashMap;
|
||||
using AK::HashTable;
|
||||
using AK::InputMemoryStream;
|
||||
using AK::InputStream;
|
||||
using AK::IPv4Address;
|
||||
using AK::JsonArray;
|
||||
using AK::JsonObject;
|
||||
|
@ -178,8 +180,6 @@ using AK::NonnullOwnPtrVector;
|
|||
using AK::NonnullRefPtr;
|
||||
using AK::NonnullRefPtrVector;
|
||||
using AK::Optional;
|
||||
using AK::OutputMemoryStream;
|
||||
using AK::OutputStream;
|
||||
using AK::OwnPtr;
|
||||
using AK::ReadonlyBytes;
|
||||
using AK::RefPtr;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedStream.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <AK/Stream.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace AK {
|
||||
|
@ -19,7 +19,7 @@ struct LEB128 {
|
|||
[[maybe_unused]] size_t backup_offset = 0;
|
||||
if constexpr (requires { stream.offset(); })
|
||||
backup_offset = stream.offset();
|
||||
InputStream& input_stream { stream };
|
||||
DeprecatedInputStream& input_stream { stream };
|
||||
|
||||
result = 0;
|
||||
size_t num_bytes = 0;
|
||||
|
@ -62,7 +62,7 @@ struct LEB128 {
|
|||
[[maybe_unused]] size_t backup_offset = 0;
|
||||
if constexpr (requires { stream.offset(); })
|
||||
backup_offset = stream.offset();
|
||||
InputStream& input_stream { stream };
|
||||
DeprecatedInputStream& input_stream { stream };
|
||||
|
||||
i64 temp = 0;
|
||||
size_t num_bytes = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue