Commit 971450f0 authored by Max Kellermann's avatar Max Kellermann

input/InputStream: make IsEOF() and IsAvailable() const

parent 40a48cfb
......@@ -71,7 +71,7 @@ public:
~Bzip2InputStream();
/* virtual methods from InputStream */
bool IsEOF() noexcept override;
bool IsEOF() const noexcept override;
size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t size) override;
......@@ -183,7 +183,7 @@ Bzip2InputStream::Read(std::unique_lock<Mutex> &, void *ptr, size_t length)
}
bool
Bzip2InputStream::IsEOF() noexcept
Bzip2InputStream::IsEOF() const noexcept
{
return eof;
}
......
......@@ -156,7 +156,7 @@ public:
}
/* virtual methods from InputStream */
bool IsEOF() noexcept override;
bool IsEOF() const noexcept override;
size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t size) override;
};
......@@ -210,7 +210,7 @@ Iso9660InputStream::Read(std::unique_lock<Mutex> &,
}
bool
Iso9660InputStream::IsEOF() noexcept
Iso9660InputStream::IsEOF() const noexcept
{
return offset == size;
}
......
......@@ -110,7 +110,7 @@ public:
}
/* virtual methods from InputStream */
bool IsEOF() noexcept override;
bool IsEOF() const noexcept override;
size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t size) override;
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
......@@ -144,7 +144,7 @@ ZzipInputStream::Read(std::unique_lock<Mutex> &, void *ptr, size_t read_size)
}
bool
ZzipInputStream::IsEOF() noexcept
ZzipInputStream::IsEOF() const noexcept
{
return offset_type(zzip_tell(file)) == size;
}
......
......@@ -88,7 +88,7 @@ AsyncInputStream::Check()
}
bool
AsyncInputStream::IsEOF() noexcept
AsyncInputStream::IsEOF() const noexcept
{
return (KnownSize() && offset >= size) ||
(!open && buffer.empty());
......@@ -164,7 +164,7 @@ AsyncInputStream::ReadTag() noexcept
}
bool
AsyncInputStream::IsAvailable() noexcept
AsyncInputStream::IsAvailable() const noexcept
{
return postponed_exception ||
IsEOF() ||
......
......@@ -82,11 +82,11 @@ public:
/* virtual methods from InputStream */
void Check() final;
bool IsEOF() noexcept final;
bool IsEOF() const noexcept final;
void Seek(std::unique_lock<Mutex> &lock,
offset_type new_offset) final;
std::unique_ptr<Tag> ReadTag() noexcept final;
bool IsAvailable() noexcept final;
bool IsAvailable() const noexcept final;
size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t read_size) final;
......
......@@ -53,13 +53,13 @@ BufferedInputStream::Seek(std::unique_lock<Mutex> &,
}
bool
BufferedInputStream::IsEOF() noexcept
BufferedInputStream::IsEOF() const noexcept
{
return InputStream::offset == BufferingInputStream::size();
}
bool
BufferedInputStream::IsAvailable() noexcept
BufferedInputStream::IsAvailable() const noexcept
{
return BufferingInputStream::IsAvailable(offset);
}
......
......@@ -55,10 +55,10 @@ public:
have been copied already in our constructor */
//void Update() noexcept;
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
bool IsEOF() noexcept override;
bool IsEOF() const noexcept override;
/* we don't support tags */
// std::unique_ptr<Tag> ReadTag() override;
bool IsAvailable() noexcept override;
bool IsAvailable() const noexcept override;
size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t size) override;
......
......@@ -56,7 +56,7 @@ BufferingInputStream::Check()
}
bool
BufferingInputStream::IsAvailable(size_t offset) noexcept
BufferingInputStream::IsAvailable(size_t offset) const noexcept
{
if (offset >= size() || error)
return true;
......
......@@ -57,7 +57,9 @@ class BufferingInputStream : InputStreamHandler {
bool stop = false;
size_t want_offset = INVALID_OFFSET;
/* must be mutable because IsAvailable() acts as a hint to
modify this attribute */
mutable size_t want_offset = INVALID_OFFSET;
std::exception_ptr error, seek_error;
......@@ -100,7 +102,7 @@ public:
* Check whether data is available in the buffer at the given
* offset..
*/
bool IsAvailable(size_t offset) noexcept;
bool IsAvailable(size_t offset) const noexcept;
/**
* Copy data from the buffer into the given pointer.
......
......@@ -49,7 +49,7 @@ public:
std::rethrow_exception(error);
}
bool IsEOF() noexcept override {
bool IsEOF() const noexcept override {
return false;
}
......
......@@ -105,7 +105,7 @@ InputStream::LockReadTag() noexcept
}
bool
InputStream::IsAvailable() noexcept
InputStream::IsAvailable() const noexcept
{
return true;
}
......@@ -153,7 +153,7 @@ InputStream::LockReadFull(void *ptr, size_t _size)
}
bool
InputStream::LockIsEOF() noexcept
InputStream::LockIsEOF() const noexcept
{
const std::lock_guard<Mutex> protect(mutex);
return IsEOF();
......
......@@ -310,14 +310,14 @@ public:
* The caller must lock the mutex.
*/
gcc_pure
virtual bool IsEOF() noexcept = 0;
virtual bool IsEOF() const noexcept = 0;
/**
* Wrapper for IsEOF() which locks and unlocks the mutex; the
* caller must not be holding it already.
*/
gcc_pure
bool LockIsEOF() noexcept;
bool LockIsEOF() const noexcept;
/**
* Reads the tag from the stream.
......@@ -343,7 +343,7 @@ public:
* The caller must lock the mutex.
*/
gcc_pure
virtual bool IsAvailable() noexcept;
virtual bool IsAvailable() const noexcept;
/**
* Reads data from the stream into the caller-supplied buffer.
......
......@@ -99,7 +99,7 @@ ProxyInputStream::Seek(std::unique_lock<Mutex> &lock,
}
bool
ProxyInputStream::IsEOF() noexcept
ProxyInputStream::IsEOF() const noexcept
{
return input && input->IsEOF();
}
......@@ -114,7 +114,7 @@ ProxyInputStream::ReadTag() noexcept
}
bool
ProxyInputStream::IsAvailable() noexcept
ProxyInputStream::IsAvailable() const noexcept
{
return input && input->IsAvailable();
}
......
......@@ -62,9 +62,9 @@ public:
void Update() noexcept override;
void Seek(std::unique_lock<Mutex> &lock,
offset_type new_offset) override;
bool IsEOF() noexcept override;
bool IsEOF() const noexcept override;
std::unique_ptr<Tag> ReadTag() noexcept override;
bool IsAvailable() noexcept override;
bool IsAvailable() const noexcept override;
size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t read_size) override;
......
......@@ -56,7 +56,7 @@ public:
ProxyInputStream::Update();
}
bool IsEOF() noexcept override {
bool IsEOF() const noexcept override {
return !ReadingFromBuffer() && ProxyInputStream::IsEOF();
}
......
......@@ -122,7 +122,7 @@ ThreadInputStream::Check()
}
bool
ThreadInputStream::IsAvailable() noexcept
ThreadInputStream::IsAvailable() const noexcept
{
assert(!thread.IsInside());
......@@ -160,7 +160,7 @@ ThreadInputStream::Read(std::unique_lock<Mutex> &lock,
}
bool
ThreadInputStream::IsEOF() noexcept
ThreadInputStream::IsEOF() const noexcept
{
assert(!thread.IsInside());
......
......@@ -91,9 +91,9 @@ public:
void Start();
/* virtual methods from InputStream */
void Check() override final;
bool IsEOF() noexcept final;
bool IsAvailable() noexcept final;
void Check() final;
bool IsEOF() const noexcept final;
bool IsAvailable() const noexcept final;
size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t size) override final;
......
......@@ -90,7 +90,7 @@ class CdioParanoiaInputStream final : public InputStream {
}
/* virtual methods from InputStream */
bool IsEOF() noexcept override;
bool IsEOF() const noexcept override;
size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t size) override;
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
......@@ -344,7 +344,7 @@ CdioParanoiaInputStream::Read(std::unique_lock<Mutex> &,
}
bool
CdioParanoiaInputStream::IsEOF() noexcept
CdioParanoiaInputStream::IsEOF() const noexcept
{
return lsn_from + lsn_relofs > lsn_to;
}
......
......@@ -48,7 +48,7 @@ public:
}
/* virtual methods from InputStream */
bool IsEOF() noexcept override;
bool IsEOF() const noexcept override;
size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t size) override;
void Seek(std::unique_lock<Mutex> &lock,
......@@ -96,7 +96,7 @@ FfmpegInputStream::Read(std::unique_lock<Mutex> &,
}
bool
FfmpegInputStream::IsEOF() noexcept
FfmpegInputStream::IsEOF() const noexcept
{
return io.IsEOF();
}
......
......@@ -44,7 +44,7 @@ public:
/* virtual methods from InputStream */
bool IsEOF() noexcept override {
bool IsEOF() const noexcept override {
return GetOffset() >= GetSize();
}
......
......@@ -52,7 +52,7 @@ public:
/* virtual methods from InputStream */
bool IsEOF() noexcept override {
bool IsEOF() const noexcept override {
return offset >= size;
}
......
......@@ -24,7 +24,7 @@ public:
}
/* virtual methods from InputStream */
bool IsEOF() noexcept override {
bool IsEOF() const noexcept override {
return remaining == 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment