I'm trying to follow the logic of this question to create a custom streambuf
in Rcpp
. Someone contributed the basic behaviour that allows us to write things like
Rcout << "some text" ;
where we implemented xsputn
and overflow
to redirect to Rprintf
function.
std::streamsize Rcpp::Rstreambuf::xsputn(const char *s, std::streamsize num ) {
Rprintf( "%.*s", num, s );
return num;
}
int Rcpp::Rstreambuf::overflow(int c ) {
if (c != EOF) {
Rprintf( "%.1s", &c );
}
return c;
}
I would like to implement flushing too, i.e. support this syntax:
Rcout << "some text" << std::flush ;
Which method do I need to implement so that the flush
manipulator works on my custom stream ?