#include <mrpt/utils/CConsoleRedirector.h>
Public Member Functions | |
CConsoleRedirector (const std::string &out_file, bool also_to_console=true, bool also_cerr=true, bool append_file=false, int bufferSize=1000) | |
Constructor. | |
virtual | ~CConsoleRedirector () |
void | flush () |
virtual void | writeString (const std::string &str) |
Protected Attributes | |
std::ofstream | m_of |
The text output file stream. | |
std::streambuf * | sbOld |
The "old" std::cout. | |
std::streambuf * | sbOld_cerr |
The "old" std::cout. | |
bool | m_also_to_console |
mrpt::synch::CCriticalSection | m_cs |
Private Member Functions | |
int | overflow (int c) |
int | sync () |
Based on code from http://www.devmaster.net/forums/showthread.php?t=7037
Definition at line 42 of file CConsoleRedirector.h.
mrpt::utils::CConsoleRedirector::CConsoleRedirector | ( | const std::string & | out_file, | |
bool | also_to_console = true , |
|||
bool | also_cerr = true , |
|||
bool | append_file = false , |
|||
int | bufferSize = 1000 | |||
) | [inline] |
Constructor.
out_file | The file to create / append | |
also_to_console | Whether to redirect data to file *and* also dump data to the console as usual. | |
append_file | If set to false the file will be truncated on open | |
bufferSize | It's recommended to buffer the data instead of writing characters one by one. | |
also_cerr | Whether to redirect the output to std::cerr in addition to std::cout. |
std::exception | If the file cannot be opened. |
Definition at line 60 of file CConsoleRedirector.h.
References m_of, sbOld, sbOld_cerr, and THROW_EXCEPTION_CUSTOM_MSG1.
virtual mrpt::utils::CConsoleRedirector::~CConsoleRedirector | ( | ) | [inline, virtual] |
void mrpt::utils::CConsoleRedirector::flush | ( | ) | [inline] |
int mrpt::utils::CConsoleRedirector::overflow | ( | int | c | ) | [inline, private] |
Definition at line 113 of file CConsoleRedirector.h.
References mrpt::synch::CCriticalSection::enter(), mrpt::synch::CCriticalSection::leave(), m_cs, sync(), and writeString().
int mrpt::utils::CConsoleRedirector::sync | ( | ) | [inline, private] |
Definition at line 134 of file CConsoleRedirector.h.
References mrpt::synch::CCriticalSection::enter(), mrpt::synch::CCriticalSection::leave(), m_cs, and writeString().
Referenced by flush(), overflow(), and ~CConsoleRedirector().
virtual void mrpt::utils::CConsoleRedirector::writeString | ( | const std::string & | str | ) | [inline, virtual] |
Definition at line 106 of file CConsoleRedirector.h.
References m_also_to_console, m_of, and sbOld.
Referenced by overflow(), and sync().
bool mrpt::utils::CConsoleRedirector::m_also_to_console [protected] |
std::ofstream mrpt::utils::CConsoleRedirector::m_of [protected] |
The text output file stream.
Definition at line 45 of file CConsoleRedirector.h.
Referenced by CConsoleRedirector(), and writeString().
std::streambuf* mrpt::utils::CConsoleRedirector::sbOld [protected] |
The "old" std::cout.
Definition at line 46 of file CConsoleRedirector.h.
Referenced by CConsoleRedirector(), writeString(), and ~CConsoleRedirector().
std::streambuf* mrpt::utils::CConsoleRedirector::sbOld_cerr [protected] |
The "old" std::cout.
Definition at line 47 of file CConsoleRedirector.h.
Referenced by CConsoleRedirector(), and ~CConsoleRedirector().
Page generated by Doxygen 1.5.8 for MRPT 0.6.5 SVN: at Thu Feb 26 02:07:47 EST 2009 |