input/InputStream: make IsEOF() and IsAvailable() const
This commit is contained in:
parent
40a48cfba0
commit
971450f0d4
@ -71,7 +71,7 @@ public:
|
|||||||
~Bzip2InputStream();
|
~Bzip2InputStream();
|
||||||
|
|
||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
bool IsEOF() noexcept override;
|
bool IsEOF() const noexcept override;
|
||||||
size_t Read(std::unique_lock<Mutex> &lock,
|
size_t Read(std::unique_lock<Mutex> &lock,
|
||||||
void *ptr, size_t size) override;
|
void *ptr, size_t size) override;
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ Bzip2InputStream::Read(std::unique_lock<Mutex> &, void *ptr, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Bzip2InputStream::IsEOF() noexcept
|
Bzip2InputStream::IsEOF() const noexcept
|
||||||
{
|
{
|
||||||
return eof;
|
return eof;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
bool IsEOF() noexcept override;
|
bool IsEOF() const noexcept override;
|
||||||
size_t Read(std::unique_lock<Mutex> &lock,
|
size_t Read(std::unique_lock<Mutex> &lock,
|
||||||
void *ptr, size_t size) override;
|
void *ptr, size_t size) override;
|
||||||
};
|
};
|
||||||
@ -210,7 +210,7 @@ Iso9660InputStream::Read(std::unique_lock<Mutex> &,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Iso9660InputStream::IsEOF() noexcept
|
Iso9660InputStream::IsEOF() const noexcept
|
||||||
{
|
{
|
||||||
return offset == size;
|
return offset == size;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
bool IsEOF() noexcept override;
|
bool IsEOF() const noexcept override;
|
||||||
size_t Read(std::unique_lock<Mutex> &lock,
|
size_t Read(std::unique_lock<Mutex> &lock,
|
||||||
void *ptr, size_t size) override;
|
void *ptr, size_t size) override;
|
||||||
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) 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
|
bool
|
||||||
ZzipInputStream::IsEOF() noexcept
|
ZzipInputStream::IsEOF() const noexcept
|
||||||
{
|
{
|
||||||
return offset_type(zzip_tell(file)) == size;
|
return offset_type(zzip_tell(file)) == size;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ AsyncInputStream::Check()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AsyncInputStream::IsEOF() noexcept
|
AsyncInputStream::IsEOF() const noexcept
|
||||||
{
|
{
|
||||||
return (KnownSize() && offset >= size) ||
|
return (KnownSize() && offset >= size) ||
|
||||||
(!open && buffer.empty());
|
(!open && buffer.empty());
|
||||||
@ -164,7 +164,7 @@ AsyncInputStream::ReadTag() noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AsyncInputStream::IsAvailable() noexcept
|
AsyncInputStream::IsAvailable() const noexcept
|
||||||
{
|
{
|
||||||
return postponed_exception ||
|
return postponed_exception ||
|
||||||
IsEOF() ||
|
IsEOF() ||
|
||||||
|
@ -82,11 +82,11 @@ public:
|
|||||||
|
|
||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
void Check() final;
|
void Check() final;
|
||||||
bool IsEOF() noexcept final;
|
bool IsEOF() const noexcept final;
|
||||||
void Seek(std::unique_lock<Mutex> &lock,
|
void Seek(std::unique_lock<Mutex> &lock,
|
||||||
offset_type new_offset) final;
|
offset_type new_offset) final;
|
||||||
std::unique_ptr<Tag> ReadTag() noexcept 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,
|
size_t Read(std::unique_lock<Mutex> &lock,
|
||||||
void *ptr, size_t read_size) final;
|
void *ptr, size_t read_size) final;
|
||||||
|
|
||||||
|
@ -53,13 +53,13 @@ BufferedInputStream::Seek(std::unique_lock<Mutex> &,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BufferedInputStream::IsEOF() noexcept
|
BufferedInputStream::IsEOF() const noexcept
|
||||||
{
|
{
|
||||||
return InputStream::offset == BufferingInputStream::size();
|
return InputStream::offset == BufferingInputStream::size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BufferedInputStream::IsAvailable() noexcept
|
BufferedInputStream::IsAvailable() const noexcept
|
||||||
{
|
{
|
||||||
return BufferingInputStream::IsAvailable(offset);
|
return BufferingInputStream::IsAvailable(offset);
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,10 @@ public:
|
|||||||
have been copied already in our constructor */
|
have been copied already in our constructor */
|
||||||
//void Update() noexcept;
|
//void Update() noexcept;
|
||||||
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
|
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 */
|
/* we don't support tags */
|
||||||
// std::unique_ptr<Tag> ReadTag() override;
|
// std::unique_ptr<Tag> ReadTag() override;
|
||||||
bool IsAvailable() noexcept override;
|
bool IsAvailable() const noexcept override;
|
||||||
size_t Read(std::unique_lock<Mutex> &lock,
|
size_t Read(std::unique_lock<Mutex> &lock,
|
||||||
void *ptr, size_t size) override;
|
void *ptr, size_t size) override;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ BufferingInputStream::Check()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BufferingInputStream::IsAvailable(size_t offset) noexcept
|
BufferingInputStream::IsAvailable(size_t offset) const noexcept
|
||||||
{
|
{
|
||||||
if (offset >= size() || error)
|
if (offset >= size() || error)
|
||||||
return true;
|
return true;
|
||||||
|
@ -57,7 +57,9 @@ class BufferingInputStream : InputStreamHandler {
|
|||||||
|
|
||||||
bool stop = false;
|
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;
|
std::exception_ptr error, seek_error;
|
||||||
|
|
||||||
@ -100,7 +102,7 @@ public:
|
|||||||
* Check whether data is available in the buffer at the given
|
* Check whether data is available in the buffer at the given
|
||||||
* offset..
|
* offset..
|
||||||
*/
|
*/
|
||||||
bool IsAvailable(size_t offset) noexcept;
|
bool IsAvailable(size_t offset) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy data from the buffer into the given pointer.
|
* Copy data from the buffer into the given pointer.
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
std::rethrow_exception(error);
|
std::rethrow_exception(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsEOF() noexcept override {
|
bool IsEOF() const noexcept override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ InputStream::LockReadTag() noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InputStream::IsAvailable() noexcept
|
InputStream::IsAvailable() const noexcept
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ InputStream::LockReadFull(void *ptr, size_t _size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InputStream::LockIsEOF() noexcept
|
InputStream::LockIsEOF() const noexcept
|
||||||
{
|
{
|
||||||
const std::lock_guard<Mutex> protect(mutex);
|
const std::lock_guard<Mutex> protect(mutex);
|
||||||
return IsEOF();
|
return IsEOF();
|
||||||
|
@ -310,14 +310,14 @@ public:
|
|||||||
* The caller must lock the mutex.
|
* The caller must lock the mutex.
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
virtual bool IsEOF() noexcept = 0;
|
virtual bool IsEOF() const noexcept = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for IsEOF() which locks and unlocks the mutex; the
|
* Wrapper for IsEOF() which locks and unlocks the mutex; the
|
||||||
* caller must not be holding it already.
|
* caller must not be holding it already.
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool LockIsEOF() noexcept;
|
bool LockIsEOF() const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the tag from the stream.
|
* Reads the tag from the stream.
|
||||||
@ -343,7 +343,7 @@ public:
|
|||||||
* The caller must lock the mutex.
|
* The caller must lock the mutex.
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
virtual bool IsAvailable() noexcept;
|
virtual bool IsAvailable() const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads data from the stream into the caller-supplied buffer.
|
* Reads data from the stream into the caller-supplied buffer.
|
||||||
|
@ -99,7 +99,7 @@ ProxyInputStream::Seek(std::unique_lock<Mutex> &lock,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ProxyInputStream::IsEOF() noexcept
|
ProxyInputStream::IsEOF() const noexcept
|
||||||
{
|
{
|
||||||
return input && input->IsEOF();
|
return input && input->IsEOF();
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ ProxyInputStream::ReadTag() noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ProxyInputStream::IsAvailable() noexcept
|
ProxyInputStream::IsAvailable() const noexcept
|
||||||
{
|
{
|
||||||
return input && input->IsAvailable();
|
return input && input->IsAvailable();
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,9 @@ public:
|
|||||||
void Update() noexcept override;
|
void Update() noexcept override;
|
||||||
void Seek(std::unique_lock<Mutex> &lock,
|
void Seek(std::unique_lock<Mutex> &lock,
|
||||||
offset_type new_offset) override;
|
offset_type new_offset) override;
|
||||||
bool IsEOF() noexcept override;
|
bool IsEOF() const noexcept override;
|
||||||
std::unique_ptr<Tag> ReadTag() 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,
|
size_t Read(std::unique_lock<Mutex> &lock,
|
||||||
void *ptr, size_t read_size) override;
|
void *ptr, size_t read_size) override;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
ProxyInputStream::Update();
|
ProxyInputStream::Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsEOF() noexcept override {
|
bool IsEOF() const noexcept override {
|
||||||
return !ReadingFromBuffer() && ProxyInputStream::IsEOF();
|
return !ReadingFromBuffer() && ProxyInputStream::IsEOF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ ThreadInputStream::Check()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ThreadInputStream::IsAvailable() noexcept
|
ThreadInputStream::IsAvailable() const noexcept
|
||||||
{
|
{
|
||||||
assert(!thread.IsInside());
|
assert(!thread.IsInside());
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ ThreadInputStream::Read(std::unique_lock<Mutex> &lock,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ThreadInputStream::IsEOF() noexcept
|
ThreadInputStream::IsEOF() const noexcept
|
||||||
{
|
{
|
||||||
assert(!thread.IsInside());
|
assert(!thread.IsInside());
|
||||||
|
|
||||||
|
@ -91,9 +91,9 @@ public:
|
|||||||
void Start();
|
void Start();
|
||||||
|
|
||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
void Check() override final;
|
void Check() final;
|
||||||
bool IsEOF() noexcept final;
|
bool IsEOF() const noexcept final;
|
||||||
bool IsAvailable() noexcept final;
|
bool IsAvailable() const noexcept final;
|
||||||
size_t Read(std::unique_lock<Mutex> &lock,
|
size_t Read(std::unique_lock<Mutex> &lock,
|
||||||
void *ptr, size_t size) override final;
|
void *ptr, size_t size) override final;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class CdioParanoiaInputStream final : public InputStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
bool IsEOF() noexcept override;
|
bool IsEOF() const noexcept override;
|
||||||
size_t Read(std::unique_lock<Mutex> &lock,
|
size_t Read(std::unique_lock<Mutex> &lock,
|
||||||
void *ptr, size_t size) override;
|
void *ptr, size_t size) override;
|
||||||
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
|
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
|
||||||
@ -344,7 +344,7 @@ CdioParanoiaInputStream::Read(std::unique_lock<Mutex> &,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CdioParanoiaInputStream::IsEOF() noexcept
|
CdioParanoiaInputStream::IsEOF() const noexcept
|
||||||
{
|
{
|
||||||
return lsn_from + lsn_relofs > lsn_to;
|
return lsn_from + lsn_relofs > lsn_to;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
bool IsEOF() noexcept override;
|
bool IsEOF() const noexcept override;
|
||||||
size_t Read(std::unique_lock<Mutex> &lock,
|
size_t Read(std::unique_lock<Mutex> &lock,
|
||||||
void *ptr, size_t size) override;
|
void *ptr, size_t size) override;
|
||||||
void Seek(std::unique_lock<Mutex> &lock,
|
void Seek(std::unique_lock<Mutex> &lock,
|
||||||
@ -96,7 +96,7 @@ FfmpegInputStream::Read(std::unique_lock<Mutex> &,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FfmpegInputStream::IsEOF() noexcept
|
FfmpegInputStream::IsEOF() const noexcept
|
||||||
{
|
{
|
||||||
return io.IsEOF();
|
return io.IsEOF();
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
|
|
||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
|
|
||||||
bool IsEOF() noexcept override {
|
bool IsEOF() const noexcept override {
|
||||||
return GetOffset() >= GetSize();
|
return GetOffset() >= GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
|
|
||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
|
|
||||||
bool IsEOF() noexcept override {
|
bool IsEOF() const noexcept override {
|
||||||
return offset >= size;
|
return offset >= size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
bool IsEOF() noexcept override {
|
bool IsEOF() const noexcept override {
|
||||||
return remaining == 0;
|
return remaining == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user