| 105 | } |
| 106 | |
| 107 | void setup( const const_string& stream_name, |
| 108 | boost::function<void ()> const &cleaner_callback = boost::function<void ()>() ) |
| 109 | { |
| 110 | if(stream_name.empty()) |
| 111 | return; |
| 112 | |
| 113 | if( stream_name == "stderr" ) { |
| 114 | m_stream = &std::cerr; |
| 115 | if(cleaner_callback) { |
| 116 | m_cleaner = boost::make_shared<callback_cleaner>(cleaner_callback); |
| 117 | } |
| 118 | else { |
| 119 | m_cleaner.reset(); |
| 120 | } |
| 121 | } |
| 122 | else if( stream_name == "stdout" ) { |
| 123 | m_stream = &std::cout; |
| 124 | if (cleaner_callback) { |
| 125 | m_cleaner = boost::make_shared<callback_cleaner>(cleaner_callback); |
| 126 | } |
| 127 | else { |
| 128 | m_cleaner.reset(); |
| 129 | } |
| 130 | } |
| 131 | else { |
| 132 | m_cleaner = boost::make_shared<callback_cleaner>(cleaner_callback); |
| 133 | m_cleaner->m_file.open( std::string(stream_name.begin(), stream_name.end()).c_str() ); |
| 134 | m_stream = &m_cleaner->m_file; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | // Access methods |
| 139 | std::ostream& ref() const { return *m_stream; } |
no test coverage detected