RobWorkProject  24.5.15-
Public Types | Public Member Functions | Protected Member Functions | List of all members
LogBufferedChar Class Reference

Buffers characters before writing them to the output stream. More...

#include <LogBufferedChar.hpp>

Inherits LogWriter.

Public Types

enum  OverflowPolicy { REMOVE_FIRST , REMOVE_LAST , AUTO_FLUSH }
 Behaviors for the OverflowPolicy. More...
 
- Public Types inherited from LogWriter
typedef rw::core::Ptr< LogWriterPtr
 smart pointer type to this class
 

Public Member Functions

 LogBufferedChar (size_t size, std::ostream *stream, OverflowPolicy policy=REMOVE_FIRST)
 Constructs a LogBufferedChar. More...
 
virtual ~LogBufferedChar ()
 Destructor. More...
 
- Public Member Functions inherited from LogWriter
virtual ~LogWriter ()
 Descructor.
 
void flush ()
 Flush method.
 
void setTabLevel (int tabLevel)
 Set the tab level.
 
void write (const std::string &str)
 Writes str to the log. More...
 
void write (const Message &msg)
 Writes msg to the log. More...
 
void writeln (const std::string &str)
 Writes str as a line. More...
 
template<class T >
LogWriteroperator<< (T t)
 general stream operator
 
LogWriteroperator<< (const std::string &str)
 specialized stream operator 2
 
LogWriteroperator<< (const Message &msg)
 Write Message to log. More...
 
LogWriteroperator<< (const char *str)
 specialized stream operator
 
LogWriteroperator<< (std::ostream &(*pf)(std::ostream &))
 Handle the std::endl and other stream functions.
 

Protected Member Functions

void doWrite (const std::string &str)
 Writes str to the buffer. More...
 
void doFlush ()
 Flushes the buffer to the output stream.
 
void doSetTabLevel (int tablevel)
 Set the tab level. More...
 

Detailed Description

Buffers characters before writing them to the output stream.

The size of the buffer is fixed. On overflow the behavior depends on the specified OverFlowPolicy. If a single message is larger than the entire content of the buffer it is truncated.

Member Enumeration Documentation

◆ OverflowPolicy

Behaviors for the OverflowPolicy.

Enumerator
REMOVE_FIRST 

Remove the first added content (circular queue)

REMOVE_LAST 

Skip the content which does not fit input the buffer.

AUTO_FLUSH 

Automatically calls flush to write the buffer and the new message to the output stream. Using AUTO_FLUSH it is possible to write messages larger than the buffer size.

Constructor & Destructor Documentation

◆ LogBufferedChar()

LogBufferedChar ( size_t  size,
std::ostream *  stream,
OverflowPolicy  policy = REMOVE_FIRST 
)

Constructs a LogBufferedChar.

The LogBufferedMsg keeps a reference to the stream object. Destroying the stream object while the LogBufferedChar has a reference to it results in undefined behavior.

Parameters
size[in] Size of buffer (in characters)
stream[in] Stream to write to
policy[in] Overflow policy. Default is REMOVE_FIRST

◆ ~LogBufferedChar()

virtual ~LogBufferedChar ( )
virtual

Destructor.

Calls flush before destroying the object

Member Function Documentation

◆ doSetTabLevel()

void doSetTabLevel ( int  tablevel)
protectedvirtual

Set the tab level.

Implements LogWriter.

◆ doWrite()

void doWrite ( const std::string &  str)
protectedvirtual

Writes str to the buffer.

Parameters
str[in] String to write

Implements LogWriter.


The documentation for this class was generated from the following file: