Oncaphillis::niftyLib

niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT > Class Template Reference

#include <io/str_log_filter.h>

Inheritance diagram for niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >:
Collaboration diagram for niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >:

Detailed Description

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
class niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >

A basic_log_filter subclass which dumps out a given string at the beginning of every detected newline-sequence.

It overwrites the virtual method basic_log_filter::line_intro and dumps out an associated string everytime the output hits a line-feed.

Example

        device_streambuf<wchar_t,device<char> > *db;
        str_log_filterf< char >                 *lf;

        // Create a std::wostream which pumps utf-8 chars into
        // std::cerr by attaching a streambuf_device to the
        // rdbuf placing our str_log_filter in front of our
        // streambuf_device.
        
        std::wostream os (db = new device_streambuf<wchar_t,device<char> >
                         ( lf = new str_log_filter<char>( 
                               new streambuf_device<char>( std::cerr.rdbuf()))));

        // Set the current intro line
        // which will be dumped out whenever the stream_buf
        // has seen a <LF>
        
        lf->set_intro(" my log::");

        for(int i=0;i<100;i++) {
         os << " my message #" << i << std::endl;
        }
        
        delete db;

Furthermore you might want to have a look at the intro_line stream manipulator which makes the functionality of associating new log intro lines available on stream level.

See also:
basic_log_filter, time_log_filter

Public Types

typedef super::char_type char_type
 We inherit the char_type from our associated output device.
typedef super::traits_type traits_type
 We also inherit the traits_type from our associated output device.
typedef super::device_ptr device_ptr
 Internal typedef of a pointer to device.

Public Member Functions

 str_log_filter (device_ptr d, bool o=true)
 Standard CTOR.
 str_log_filter (device_ptr d, const std::string &i, bool o=true)
virtual ~str_log_filter ()
virtual std::streamsize line_intro ()
 Method to generate the start of every new line.
void set_intro (const std::basic_string< char_type, traits_type > &s)
const std::basic_string
< char_type, traits_type > & 
get_intro () const

Protected Member Functions

 str_log_filter ()
 str_log_filter (const str_log_filter &)

Member Typedef Documentation

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
typedef super::char_type niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::char_type

We inherit the char_type from our associated output device.

This definition has to be here in order to make us work properly with a device_streambuf

Reimplemented from niftyLib::IO::basic_log_filter< CharT, TraitsT, DeviceT >.

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
typedef super::traits_type niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::traits_type

We also inherit the traits_type from our associated output device.

Reimplemented from niftyLib::IO::basic_log_filter< CharT, TraitsT, DeviceT >.

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
typedef super::device_ptr niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::device_ptr

Internal typedef of a pointer to device.

Reimplemented from niftyLib::IO::basic_log_filter< CharT, TraitsT, DeviceT >.


Constructor & Destructor Documentation

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::str_log_filter ( device_ptr  d,
bool  o = true 
) [inline]

Standard CTOR.

We set the state to LF as if the last char sequence has been a valid LF sequence since the very first thing we have to output on a new buffer is the line_intro sequence.

The last argument specifies if basic_str_log_filter should hold ownership of the given device. This defuats to true which means we delete the device upon deletion.

See also:
device<CharT>, filter<CharT>

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::str_log_filter ( device_ptr  d,
const std::string &  i,
bool  o = true 
) [inline]

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
virtual niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::~str_log_filter (  )  [inline, virtual]

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::str_log_filter (  )  [inline, protected]

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::str_log_filter ( const str_log_filter< CharT, TraitsT, DeviceT > &   )  [inline, protected]


Member Function Documentation

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
virtual std::streamsize niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::line_intro (  )  [inline, virtual]

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
void niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::set_intro ( const std::basic_string< char_type, traits_type > &  s  )  [inline]

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
const std::basic_string<char_type,traits_type>& niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >::get_intro (  )  const [inline]


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

Generated by  doxygen
© 2008; Dr. Sebastian Kloska ( Oncaphillis )
Powered by: [?]