12 #ifndef _forwardingstreambuf_h 13 #define _forwardingstreambuf_h 20 #include "consolestreambuf.h" 27 class ForwardingStreambuf :
public std::streambuf {
29 ConsoleStreambuf& delegate;
33 ForwardingStreambuf(ConsoleStreambuf& del,
bool err =
false)
34 : delegate(del), isStderr(err) {
38 virtual bool isBlocked() {
39 return delegate.isBlocked();
42 virtual int overflow(
int ch = EOF) {
43 return delegate.overflow(ch, isStderr);
46 virtual int overflow(
int ch,
bool isStderr) {
47 return delegate.overflow(ch, isStderr);
51 return delegate.sync(isStderr);
54 virtual int sync(
bool isStderr) {
55 return delegate.sync(isStderr);
58 virtual int underflow() {
59 return delegate.underflow();
64 virtual std::streamsize in_avail() {
65 return delegate.in_avail();
68 virtual int snextc() {
69 return delegate.snextc();
72 virtual int sbumpc() {
73 return delegate.sbumpc();
77 return delegate.sgetc();
80 virtual std::streamsize sgetn(
char* s, std::streamsize n) {
81 return delegate.sgetn(s, n);
84 virtual int sputbackc(
char c) {
85 return delegate.sputbackc(c);
88 virtual int sungetc() {
89 return delegate.sungetc();
92 virtual int sputc(
char c) {
93 return delegate.sputc(c);
96 virtual std::streamsize sputn(
const char* s, std::streamsize n) {
97 return delegate.sputn(s, n);
100 virtual std::locale pubimbue(
const std::locale& loc) {
101 return delegate.pubimbue(loc);
104 virtual std::locale getloc()
const {
105 return delegate.getloc();
108 virtual std::streambuf* pubsetbuf(
char* s, std::streamsize n) {
109 return delegate.pubsetbuf(s, n);
112 virtual std::streampos pubseekoff(std::streamoff off, std::ios_base::seekdir way,
113 std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) {
114 return delegate.pubseekoff(off, way, which);
117 virtual std::streampos pubseekpos(std::streampos pos, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) {
118 return delegate.pubseekpos(pos, which);
121 virtual int pubsync() {
122 return delegate.pubsync();
127 #endif // _forwardingstreambuf_h Definition: console.h:293