diff --git a/stream/filters/pure_filter.hpp b/stream/filters/pure_filter.hpp index ed1690d8c..f0ce91f87 100644 --- a/stream/filters/pure_filter.hpp +++ b/stream/filters/pure_filter.hpp @@ -31,6 +31,7 @@ class PureFilter : public Stream size_t read(void *buf, size_t count) { return src->read(buf, count); } size_t write(const void *buf, size_t count) { return src->write(buf,count); } + void flush() { src->flush(); } void seek(size_t pos) { src->seek(pos); } size_t tell() const { return src->tell(); } size_t size() const { return src->size(); } diff --git a/stream/filters/slice_stream.hpp b/stream/filters/slice_stream.hpp index 20f202bdc..6337b9d57 100644 --- a/stream/filters/slice_stream.hpp +++ b/stream/filters/slice_stream.hpp @@ -72,6 +72,7 @@ class SliceStream : public Stream bool eof() const { return pos == length; } size_t tell() const { return pos; } size_t size() const { return length; } + void flush() { src->flush(); } const void *getPtr() { return getPtr(0, length); } const void *getPtr(size_t size) diff --git a/stream/servers/std_ostream.hpp b/stream/servers/std_ostream.hpp index 32999e8c1..9ec6609e9 100644 --- a/stream/servers/std_ostream.hpp +++ b/stream/servers/std_ostream.hpp @@ -37,13 +37,16 @@ class StdOStream : public Stream inf->write((const char*)buf, len); if(inf->fail()) fail("error writing to stream"); - - // Unfortunately, stupid std::ostream doesn't have a pcount() to - // match gcount() for input. In general the std::iostream system - // is an idiotically designed stream library. + // Just return len, but that is ok. The only cases where we would + // return less than len is when an error occured. return len; } + void flush() + { + inf->flush(); + } + void seek(size_t pos) { inf->seekp(pos); diff --git a/stream/stream.hpp b/stream/stream.hpp index bc369f6cd..aa9c14a9e 100644 --- a/stream/stream.hpp +++ b/stream/stream.hpp @@ -52,6 +52,9 @@ class Stream */ virtual size_t write(const void *buf, size_t count) { assert(0); return 0; } + /// Flush an output stream. Does nothing for non-writing streams. + virtual void flush() {} + /// Seek to an absolute position in this stream. Not all streams are /// seekable. virtual void seek(size_t pos) = 0;