Support flushing output streams
This commit is contained in:
parent
a56cdcfc73
commit
82e7164670
3 changed files with 9 additions and 0 deletions
|
|
@ -83,6 +83,8 @@ namespace psemek::io
|
|||
|
||||
std::size_t write(char const * p, std::size_t size) override;
|
||||
|
||||
void flush() override;
|
||||
|
||||
~file_ostream() override
|
||||
{
|
||||
reset();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ namespace psemek::io
|
|||
struct ostream
|
||||
{
|
||||
virtual std::size_t write(char const * p, std::size_t size) = 0;
|
||||
virtual void flush() {}
|
||||
|
||||
virtual ~ostream() {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -63,4 +63,10 @@ namespace psemek::io
|
|||
return std::fwrite(p, 1, size, file_);
|
||||
}
|
||||
|
||||
void file_ostream::flush()
|
||||
{
|
||||
if (!file_) throw null_ostream{};
|
||||
std::fflush(file_);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue