Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef STREAM_REDIRECT_H
00018 #define STREAM_REDIRECT_H
00019
00020 #include <iostream>
00021 #include <streambuf>
00022 #include <string>
00023 #include <QMutex>
00024
00025 class QPlainTextEdit;
00026
00030 class StreamRedirect : public std::basic_streambuf<char>
00031 {
00032 public:
00033 typedef std::char_traits<char>::int_type int_type;
00034
00035 public:
00036 StreamRedirect(std::ostream &stream, QPlainTextEdit* te);
00037 ~StreamRedirect();
00038
00039 protected:
00040 virtual std::char_traits<char>::int_type overflow(int_type v);
00041 virtual std::streamsize xsputn(const char *p, std::streamsize n);
00042
00043 private:
00044 std::ostream& _stream;
00045 std::streambuf* _old_buf;
00046 std::string _buffer;
00047 QPlainTextEdit* _te;
00048 QMutex _mutex;
00049 };
00050
00051 #endif