49 const std::string& out_file,
bool also_to_console =
true,
50 bool also_cerr =
true,
bool append_file =
false,
int bufferSize = 1000)
58 std::ios_base::openmode openMode =
59 std::ios_base::binary | std::ios_base::out;
60 if (append_file) openMode |= std::ios_base::app;
61 m_of.open(out_file.c_str(), openMode);
67 char* ptr =
new char[bufferSize];
68 setp(ptr, ptr + bufferSize);
74 sbOld = std::cout.rdbuf();
75 std::cout.rdbuf(
this);
80 std::cerr.rdbuf(
this);
88 std::cout.rdbuf(
sbOld);
90 if (pbase())
delete[] pbase();
108 if (pbase() == epptr())
125 if (pbase() != pptr())
127 int len = int(pptr() - pbase());
130 setp(pbase(), epptr());
std::streambuf * sbOld
The "old" std::cout.
GLsizei const GLchar ** string
CConsoleRedirector(const std::string &out_file, bool also_to_console=true, bool also_cerr=true, bool append_file=false, int bufferSize=1000)
Constructor.
int overflow(int c) override
std::ofstream m_of
The text output file stream.
virtual void writeString(const std::string &str)
By creating an object of this class, all the output to std::cout (and std::cerr) will be redirected t...
virtual ~CConsoleRedirector()
std::streambuf * sbOld_cerr
The "old" std::cout.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)