From d6bf35201cf078ce50aa30c78a3a111cf11feeb6 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 8 Jan 2022 18:54:08 +0100 Subject: [PATCH] flush method on hstream --- hprint.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hprint.cpp b/hprint.cpp index 6cde00c3..4e14f4ce 100644 --- a/hprint.cpp +++ b/hprint.cpp @@ -81,6 +81,7 @@ struct hstream { virtual char read_char() = 0; virtual void read_chars(char* c, size_t q) { while(q--) *(c++) = read_char(); } virtual color_t get_vernum() { return VERNUM_HEX; } + virtual void flush() {} template void write(const T& t) { hwrite(*this, t); } template void read(T& t) { hread(*this, t); } @@ -148,6 +149,7 @@ struct fhstream : hstream { void write_chars(const char* c, size_t i) override { if(fwrite(c, i, 1, f) != 1) throw hstream_exception(); } void read_chars(char* c, size_t i) override { if(fread(c, i, 1, f) != 1) throw hstream_exception(); } char read_char() override { char c; read_chars(&c, 1); return c; } + virtual void flush() override { fflush(f); } }; struct shstream : hstream { @@ -263,6 +265,7 @@ struct logger : hstream { explicit logger() { doindent = false; } void write_char(char c) override; char read_char() override { throw hstream_exception(); } + void flush() override { fflush(stdout); } }; extern logger hlog;