mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-10-31 19:36:16 +00:00
flush method on hstream
This commit is contained in:
parent
b99e0f448f
commit
d6bf35201c
@ -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<class T> void write(const T& t) { hwrite(*this, t); }
|
||||
template<class T> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user