From 1bf824e97e9da3da4710c2524b3077f49d377ae6 Mon Sep 17 00:00:00 2001 From: smlu Date: Sat, 4 Jul 2020 20:34:47 +0200 Subject: [PATCH] Refactor (inputStream): Add 'remaining' member function New member function remaining() returns number of bytes in stream from current position to the end of the stream. --- libraries/libim/io/stream.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libraries/libim/io/stream.h b/libraries/libim/io/stream.h index 1c2813c..7b85529 100644 --- a/libraries/libim/io/stream.h +++ b/libraries/libim/io/stream.h @@ -282,11 +282,18 @@ namespace libim { }; - /* - Fix typed classes for Stream to represent only input or output stream. - */ + /** + * Specialized classes for Stream to represent only input or output stream. + */ + class InputStream : public virtual Stream { + public: + inline std::size_t remaining() const + { + return size() - tell(); + } + private: using Stream::flush; using Stream::write;