mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:57:35 +00:00
LibAudio+LibCore: Remove unnecessary IODeviceStreamReader.h
IODeviceStreamReader isn't pulling its weight. It's essentially a subset of InputFileStream with only one user (WavLoader). This refactors WavLoader to use InputFileStream instead.
This commit is contained in:
parent
06ea31d0d5
commit
3938b56577
3 changed files with 21 additions and 85 deletions
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <LibCore/IODevice.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IODeviceStreamReader {
|
||||
public:
|
||||
IODeviceStreamReader(IODevice& device)
|
||||
: m_device(device)
|
||||
{
|
||||
}
|
||||
|
||||
bool handle_read_failure()
|
||||
{
|
||||
return exchange(m_had_failure, false);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
IODeviceStreamReader& operator>>(T& value)
|
||||
{
|
||||
int nread = m_device.read((u8*)&value, sizeof(T));
|
||||
VERIFY(nread == sizeof(T));
|
||||
if (nread != sizeof(T))
|
||||
m_had_failure = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
IODevice& m_device;
|
||||
bool m_had_failure { false };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue