1
0
forked from Alepha/Alepha

Make the underlying streambuf private in stacks.

This commit is contained in:
2024-04-03 15:01:52 -04:00
parent 8250680e6c
commit d8689b85e8
5 changed files with 55 additions and 24 deletions

View File

@ -24,19 +24,24 @@ namespace Alepha::Hydrogen::IOStreams ::detail:: StackableStreambuf_m
struct exports::StackableStreambuf
: virtual public std::streambuf
{
public:
private:
std::streambuf *underlying;
public:
~StackableStreambuf() override;
// Children must be created by `new`.
explicit StackableStreambuf( std::ios &host );
auto out() const { return std::ostream{ underlying }; }
virtual void writeChar( char ch )= 0;
virtual void drain()= 0;
void unhook( std::ostream &os ) const;
void unhook( std::istream &is ) const;
protected:
std::ostream &out( std::ostream &&res= std::ostream{nullptr} ) const;
int overflow( const int ch ) override;
// Underflow is not overridden. A read-oriented