9 #ifndef CMyRedirector_H 10 #define CMyRedirector_H 12 #include <wx/string.h> 13 #include <wx/textctrl.h> 15 #include <wx/thread.h> 52 wxTextCtrl*
obj,
bool yieldApplication =
false,
int bufferSize = 3000,
53 bool also_cerr =
false,
bool threadSafe =
false,
54 bool also_to_cout_cerr =
false)
63 char* ptr =
new char[bufferSize];
64 setp(ptr, ptr + bufferSize);
70 sbOld = std::cout.rdbuf();
71 std::cout.rdbuf(
this);
76 std::cerr.rdbuf(
this);
84 std::cout.rdbuf(
sbOld);
98 s = wxString(str.c_str(), wxConvUTF8);
103 #if wxCHECK_VERSION(3, 0, 0) && !defined(__APPLE__) // OSX build error? 104 m_txt->GetEventHandler()->CallAfter(&wxTextCtrl::WriteText,
s);
117 wxTheApp->Yield(
true);
126 wxCriticalSectionLocker lock(
m_cs);
147 wxCriticalSectionLocker lock(
m_cs);
148 if (pbase() == epptr())
163 wxCriticalSectionLocker lock(
m_cs);
165 if (pbase() != pptr())
167 int len = int(pptr() - pbase());
170 setp(pbase(), epptr());
const bool m_also_to_cout_cerr
GLsizei GLsizei GLuint * obj
This auxiliary class redirects the output sent to a streambuf to a wxTextCtrl object.
const bool m_yieldApplication
std::streambuf * sbOldErr
GLsizei const GLchar ** string
virtual void writeString(const std::string &str)
CMyRedirector(wxTextCtrl *obj, bool yieldApplication=false, int bufferSize=3000, bool also_cerr=false, bool threadSafe=false, bool also_to_cout_cerr=false)
void dumpNow()
Writes all the stored strings to the text control (only for threadSafe mode).