9 #ifndef CMyRedirector_H 10 #define CMyRedirector_H 12 #include <wx/string.h> 13 #include <wx/textctrl.h> 15 #include <wx/thread.h> 50 bool yieldApplication =
false,
51 int bufferSize = 3000,
52 bool also_cerr =
false,
53 bool threadSafe =
false,
58 char *ptr =
new char[bufferSize];
59 setp(ptr, ptr + bufferSize);
65 sbOld = std::cout.rdbuf();
66 std::cout.rdbuf(
this );
71 std::cerr.rdbuf(
this );
79 std::cout.rdbuf(
sbOld);
98 s = wxString(str.c_str(), wxConvUTF8);
103 #if wxCHECK_VERSION(3,0,0) 104 m_txt->GetEventHandler()->CallAfter(&wxTextCtrl::WriteText,
s);
122 wxCriticalSectionLocker lock(
m_cs);
143 wxCriticalSectionLocker lock(
m_cs);
144 if (pbase() == epptr())
159 wxCriticalSectionLocker lock(
m_cs);
161 if (pbase() != pptr())
163 int len = int(pptr() - pbase());
166 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).