Remove ostream from class StreamBuffer
This commit is contained in:
@@ -62,6 +62,39 @@ static DrivenEngine *make_engine(std::string_view kind) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The stdostream
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class StreamBufferWriter : public std::streambuf, public eng::opnew {
|
||||
private:
|
||||
StreamBuffer *target_;
|
||||
public:
|
||||
StreamBufferWriter(StreamBuffer *t) : target_(t) {}
|
||||
|
||||
virtual int_type overflow(int_type c) {
|
||||
if (c != EOF) {
|
||||
target_->write_uint8(c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class StreamBufferOStream : public std::ostream, public eng::opnew {
|
||||
private:
|
||||
StreamBufferWriter writer_;
|
||||
public:
|
||||
StreamBufferOStream(StreamBuffer *t) : std::ostream(nullptr), writer_(t) {
|
||||
rdbuf(&writer_);
|
||||
}
|
||||
virtual ~StreamBufferOStream() {
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -156,6 +189,7 @@ void DrivenEngine::stop_driver() {
|
||||
DrivenEngine::DrivenEngine() {
|
||||
next_unused_chid_ = 1;
|
||||
stdio_channel_ = eng::make_shared<Channel>(this, 0, 0, "", false);
|
||||
stdostream_.reset(new StreamBufferOStream(stdio_channel_->out()));
|
||||
channels_[0] = stdio_channel_;
|
||||
rescan_lua_source_ = false;
|
||||
clock_ = 0.0;
|
||||
|
||||
Reference in New Issue
Block a user