*/
class nullbuf : public streambuf {
protected:
+#ifndef MODERN_STL_STREAMS
+ typedef char char_type;
+ typedef int int_type;
///
virtual int sync() { return 0; }
+#endif
///
- virtual streamsize xsputn(char const *, streamsize n) {
+ virtual streamsize xsputn(char_type const *, streamsize n) {
// fakes a purge of the buffer by returning n
return n;
}
///
- virtual int overflow(int c = EOF) {
+ virtual int_type overflow(int_type c = EOF) {
// fakes success by returning c
return c == EOF ? ' ' : c;
}
teebuf(streambuf * b1, streambuf * b2)
: streambuf(), sb1(b1), sb2(b2) {}
protected:
+#ifndef MODERN_STL_STREAMS
+ typedef char char_type;
+ typedef int int_type;
+#endif
///
virtual int sync() {
#ifdef MODERN_STL_STREAMS
#endif
}
///
- virtual streamsize xsputn(char const * p, streamsize n) {
+ virtual streamsize xsputn(char_type const * p, streamsize n) {
#ifdef MODERN_STL_STREAMS
sb2->sputn(p, n);
return sb1->sputn(p, n);
#endif
}
///
- virtual int overflow(int c = EOF) {
+ virtual int_type overflow(int_type c = EOF) {
#ifdef MODERN_STL_STREAMS
sb2->sputc(c);
return sb1->sputc(c);
debugbuf(streambuf * b)
: streambuf(), sb(b) {}
protected:
+#ifndef MODERN_STL_STREAMS
+ typedef char char_type;
+ typedef int int_type;
+#endif
///
virtual int sync() {
#ifdef MODERN_STL_STREAMS
#endif
}
///
- virtual streamsize xsputn(char const * p, streamsize n) {
+ virtual streamsize xsputn(char_type const * p, streamsize n) {
#ifdef MODERN_STL_STREAMS
return sb->sputn(p, n);
#else
#endif
}
///
- virtual int overflow(int c = EOF) {
+ virtual int_type overflow(int_type c = EOF) {
#ifdef MODERN_STL_STREAMS
return sb->sputc(c);
#else
streambuf * sb;
};
+
/// So that public parts of DebugStream does not need to know about filebuf
struct DebugStream::debugstream_internal {
/// Used when logging to file.
filebuf fbuf;
};
+
/// Constructor, sets the debug level to t.
DebugStream::DebugStream(Debug::type t)
: ostream(new debugbuf(cerr.rdbuf())),
delete internal;
}
+
/// Sets the debugstreams' logfile to f.
void DebugStream::logFile(char const * f)
{