28 #ifndef CConsoleRedirector_H
29 #define CConsoleRedirector_H
62 const std::string &out_file,
63 bool also_to_console=
true,
64 bool also_cerr =
true,
65 bool append_file =
false,
69 std::ios_base::openmode openMode = std::ios_base::binary | std::ios_base::out;
70 if ( append_file ) openMode |= std::ios_base::app;
71 m_of.open(out_file.c_str(), openMode );
76 char *ptr =
new char[bufferSize];
77 setp(ptr, ptr + bufferSize);
83 sbOld = std::cout.rdbuf();
84 std::cout.rdbuf(
this );
89 std::cerr.rdbuf(
this );
97 std::cout.rdbuf(
sbOld);
99 if (pbase())
delete[] pbase();
121 if (pbase() == epptr())
138 if (pbase() != pptr())
140 int len = int(pptr() - pbase());
141 std::string temp(pbase(), len);
143 setp(pbase(), epptr());