23#ifndef BCELOGSTREAM_HPP
24#define BCELOGSTREAM_HPP
47 m_old_buf = stream.rdbuf();
55 if (!m_string.empty()) {
56 QMetaObject::invokeMethod(
log_window,
"append", Qt::QueuedConnection,
57 Q_ARG(QString, m_string.c_str()));
65 virtual int_type overflow(int_type v)
69 QMetaObject::invokeMethod(
log_window,
"append", Qt::QueuedConnection,
70 Q_ARG(QString, m_string.c_str()));
72 m_string.erase(m_string.begin(), m_string.end());
80 virtual std::streamsize xsputn(
const char *p, std::streamsize n)
82 m_string.append(p, p + n);
85 while (pos != std::string::npos)
87 pos = m_string.find(
'\n');
88 if (pos != std::string::npos)
90 std::string tmp(m_string.begin(), m_string.begin() + pos);
91 QMetaObject::invokeMethod(
log_window,
"append", Qt::QueuedConnection,
92 Q_ARG(QString, tmp.c_str()));
94 m_string.erase(m_string.begin(), m_string.begin() + pos + 1);
107 std::streambuf *m_old_buf;
108 std::string m_string;
Redirects all couts in the program to the log tab.
Definition: bcelogstream.hpp:41
~BCELogStream()
Destructor.
Definition: bcelogstream.hpp:52
QTextEdit * log_window
Text Edit where redirected stout/stderr will be sent.
Definition: bcelogstream.hpp:103
BCELogStream(std::ostream &stream, QTextEdit *text_edit)
Constructor.
Definition: bcelogstream.hpp:44
std::ostream & m_stream
Type of ostream redirected (e.g. "cout," "cerr," etc.)
Definition: bcelogstream.hpp:106