mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:37:34 +00:00
AK: Add Buffered<T> which wraps a stream, adding input buffering.
This commit is contained in:
parent
b011f87d34
commit
359fcf348f
2 changed files with 195 additions and 8 deletions
16
AK/Stream.h
16
AK/Stream.h
|
@ -39,17 +39,17 @@ class Stream {
|
|||
public:
|
||||
virtual ~Stream() { ASSERT(!has_any_error()); }
|
||||
|
||||
bool has_recoverable_error() const { return m_recoverable_error; }
|
||||
bool has_fatal_error() const { return m_fatal_error; }
|
||||
bool has_any_error() const { return has_recoverable_error() || has_fatal_error(); }
|
||||
virtual bool has_recoverable_error() const { return m_recoverable_error; }
|
||||
virtual bool has_fatal_error() const { return m_fatal_error; }
|
||||
virtual bool has_any_error() const { return has_recoverable_error() || has_fatal_error(); }
|
||||
|
||||
bool handle_recoverable_error()
|
||||
virtual bool handle_recoverable_error()
|
||||
{
|
||||
ASSERT(!has_fatal_error());
|
||||
return exchange(m_recoverable_error, false);
|
||||
}
|
||||
bool handle_fatal_error() { return exchange(m_fatal_error, false); }
|
||||
bool handle_any_error()
|
||||
virtual bool handle_fatal_error() { return exchange(m_fatal_error, false); }
|
||||
virtual bool handle_any_error()
|
||||
{
|
||||
if (has_any_error()) {
|
||||
m_recoverable_error = false;
|
||||
|
@ -61,8 +61,8 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void set_recoverable_error() const { m_recoverable_error = true; }
|
||||
void set_fatal_error() const { m_fatal_error = true; }
|
||||
virtual void set_recoverable_error() const { m_recoverable_error = true; }
|
||||
virtual void set_fatal_error() const { m_fatal_error = true; }
|
||||
|
||||
private:
|
||||
mutable bool m_recoverable_error { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue