From 0b4fa41aff35ac8d190e5daaeed12f12614a0e9c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 11 May 2014 18:34:09 +0200 Subject: InputStream: "protect" attributes --- src/input/InputStream.hxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/input/InputStream.hxx') diff --git a/src/input/InputStream.hxx b/src/input/InputStream.hxx index 13f6af32b..5f754940b 100644 --- a/src/input/InputStream.hxx +++ b/src/input/InputStream.hxx @@ -64,6 +64,7 @@ public: */ Cond &cond; +protected: /** * indicates whether the stream is ready for reading and * whether the other attributes in this struct are valid @@ -80,7 +81,6 @@ public: */ offset_type size; -public: /** * the current offset within the stream */ @@ -217,6 +217,13 @@ public: mime = _mime; } + gcc_pure + bool KnownSize() const { + assert(ready); + + return size >= 0; + } + gcc_pure offset_type GetSize() const { assert(ready); @@ -239,6 +246,15 @@ public: return offset; } + gcc_pure + offset_type GetRest() const { + assert(ready); + assert(size >= 0); + assert(offset >= 0); + + return size - offset; + } + gcc_pure bool IsSeekable() const { assert(ready); -- cgit v1.2.3