|
CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
|
A log stream that does not output a message that have been recently output. More...
#include <log_stream_concise.hpp>
Public Member Functions | |
| log_stream_concise (log_stream *s, std::size_t max_history_size=25) | |
| Constructor. | |
| virtual | ~log_stream_concise () |
| Destructor. | |
| virtual void | write (const std::string &str) |
| Write a string in the stream. | |
| virtual void | flush () |
| Flush the stream. | |
Private Member Functions | |
| void | output_current_line () |
| Output the current line, if not in the history. | |
Private Attributes | |
| log_stream * | m_stream |
| The stream in which the messages are finally written. | |
| std::string | m_current_line |
| The current line to send into the stream. | |
| std::list< std::string > | m_previous_lines |
| Recent lines sent to the stream. | |
| std::size_t | m_max_history_size |
| Maximum number of lines in the history. | |
A log stream that does not output a message that have been recently output.
Definition at line 61 of file log_stream_concise.hpp.
| claw::log_stream_concise::log_stream_concise | ( | log_stream * | s, |
| std::size_t | max_history_size = 25 |
||
| ) | [explicit] |
Constructor.
| s | The stream in which the messages are finally written. It will be deleted in the destructor. |
| max_history_size | The maximum number of lines in the history. |
Definition at line 42 of file log_stream_concise.cpp.
: m_stream(s), m_max_history_size(max_history_size) { } // log_stream_concise::log_stream_concise()
| claw::log_stream_concise::~log_stream_concise | ( | ) | [virtual] |
Destructor.
Definition at line 52 of file log_stream_concise.cpp.
References m_stream.
{
delete m_stream;
} // log_stream_concise::~log_stream_concise()
| void claw::log_stream_concise::flush | ( | ) | [virtual] |
Flush the stream.
Reimplemented from claw::log_stream.
Definition at line 84 of file log_stream_concise.cpp.
{
m_stream->flush();
} // log_stream_concise::flush()
| void claw::log_stream_concise::output_current_line | ( | ) | [private] |
Output the current line, if not in the history.
Definition at line 93 of file log_stream_concise.cpp.
{
if ( std::find
(m_previous_lines.begin(), m_previous_lines.end(), m_current_line)
== m_previous_lines.end() )
{
m_previous_lines.push_back( m_current_line );
m_stream->write( m_current_line );
if (m_previous_lines.size() > m_max_history_size)
m_previous_lines.pop_front();
}
m_current_line.clear();
} // log_stream_concise::output_current_line()
| void claw::log_stream_concise::write | ( | const std::string & | str | ) | [virtual] |
Write a string in the stream.
| str | The sring to write. |
Implements claw::log_stream.
Definition at line 62 of file log_stream_concise.cpp.
{
std::string::size_type p = str.find_first_of('\n');
if ( p == std::string::npos )
m_current_line += str;
else
{
++p; // includes the '\n'
m_current_line += str.substr(0, p);
output_current_line();
if ( p != str.length() )
write( str.substr(p) );
}
} // log_stream_concise::write()
std::string claw::log_stream_concise::m_current_line [private] |
The current line to send into the stream.
Definition at line 81 of file log_stream_concise.hpp.
std::size_t claw::log_stream_concise::m_max_history_size [private] |
Maximum number of lines in the history.
Definition at line 87 of file log_stream_concise.hpp.
std::list<std::string> claw::log_stream_concise::m_previous_lines [private] |
Recent lines sent to the stream.
Definition at line 84 of file log_stream_concise.hpp.
log_stream* claw::log_stream_concise::m_stream [private] |
The stream in which the messages are finally written.
Definition at line 78 of file log_stream_concise.hpp.
Referenced by ~log_stream_concise().
1.7.3