Oncaphillis::niftyLib

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

#include <io/filter.h>

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

Detailed Description

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

Template class filter represents a device which pipes its output/input to/from another device (which of course might be another filter).

This virtual base class might be used to create a new filter class which may modify its output or input retrieved via the device::read and device::write method. Since it defines the necessary methods and typedefs it may be used as a sink/source-device for an device_streambuf.

Like a device it gets its character type and char traits as an template argument. The third argument represents the kind of device one like to link this filter to. This defaults to device&ltCharT,TraitsT&gt but may be changed to any other kind of class with read and write methods.

The baseclass holds a pointer to the associated device which might be retrieved via the device method. A boolean flag determines if the filter should hold ownership of the associated device. If it happens to be true (which is the default) the filter automatically deletes the device.

The associated device does not necessarily have to be an offspring of device The given template class only has to take two template arguments and should support the read/write methods as specified in the virtual class device.

See also:
device

devive_streambuf


Public Types

typedef DeviceT device_type
 Handy definition of the device we are cooperating with.
typedef DeviceT * device_ptr
 Handy typedef for the device we're operating on.
typedef device_type::char_type char_type
 We import the type of character from our superclass.
typedef device_type::traits_type traits_type
 Typedef of the traits_type gets inherited from the superclass which defaults to device<CharT,TraitsT> .
typedef char_type in_char_type
 The internal character type this filter is dealing with.
typedef traits_type in_traits_type
 The internal character traits_type.
typedef device_type::char_type ex_char_type
 This is the data type associated with the bound device i.e.
typedef device_type::traits_type ex_traits_type
 Traits type associated with the bound device i.e.

Public Member Functions

 filter (device_ptr d, bool o=true)
 Ctor of filter.
virtual ~filter ()
 Dtor of filter.
virtual std::streamsize read (char_type *b, std::streamsize n)
 Standard read method does nothing and transfers n char_types to the given input buffer.
virtual std::streamsize write (const char_type *b, std::streamsize n)
device_ptr device ()
 Return a pointer to the associated device.

Protected Member Functions

 filter ()
 filter (const filter &)

Member Typedef Documentation

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
typedef DeviceT niftyLib::IO::filter< CharT, TraitsT, DeviceT >::device_type

Handy definition of the device we are cooperating with.

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

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

We import the type of character from our superclass.

This is the type of char we are supposed to transport as seen from the inside. Meaning if you look at the filter as a device this is the type the device is supposed to tranfer to/from the outside world.

Reimplemented from niftyLib::IO::device< CharT, TraitsT >.

Reimplemented in niftyLib::IO::basic_log_filter< CharT, TraitsT, DeviceT >, multiform_filter< CharT, TraitsT >, niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >, niftyLib::IO::time_log_filter, and niftyLib::IO::basic_log_filter< char >.

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

Typedef of the traits_type gets inherited from the superclass which defaults to device<CharT,TraitsT> .

This is the type of character traits the filter is dealing with as see from the inside. Since we are supposed to function as a device we make it public here.

See also:
device

in_traits_type

ex_traits_type

Reimplemented from niftyLib::IO::device< CharT, TraitsT >.

Reimplemented in niftyLib::IO::basic_log_filter< CharT, TraitsT, DeviceT >, multiform_filter< CharT, TraitsT >, niftyLib::IO::str_log_filter< CharT, TraitsT, DeviceT >, niftyLib::IO::time_log_filter, and niftyLib::IO::basic_log_filter< char >.

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

The internal character type this filter is dealing with.

This should be identical with char_type. It represents the type of data which the methods read and write accept nad is the only data type visible to the inside (i.e callers view).

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

The internal character traits_type.

This defualts to traits_type.

This is the character traits for the filter if you look at the filter as a device.

See also:
traits_type

ex_traits_type

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
typedef device_type::char_type niftyLib::IO::filter< CharT, TraitsT, DeviceT >::ex_char_type

This is the data type associated with the bound device i.e.

the external device this filter is bound to.

See also:
device

in_char_type

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
typedef device_type::traits_type niftyLib::IO::filter< CharT, TraitsT, DeviceT >::ex_traits_type

Traits type associated with the bound device i.e.

the external device this filter is bound to.


Constructor & Destructor Documentation

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

Ctor of filter.

Takes a device_ptr and a bool value (which defaults to true to indicate if this filter should take ownership of the device.

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

Dtor of filter.

If the Ctor has been called with o==true the dtor deletes the associated device

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

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
niftyLib::IO::filter< CharT, TraitsT, DeviceT >::filter ( const 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::filter< CharT, TraitsT, DeviceT >::read ( char_type b,
std::streamsize  n 
) [inline, virtual]

Standard read method does nothing and transfers n char_types to the given input buffer.

  • b char_type pointer. Target array for input chars .
  • n std::streamsize number of chars to transfer.

template<class CharT, class TraitsT = std::char_traits<CharT>, class DeviceT = device<CharT,TraitsT>>
virtual std::streamsize niftyLib::IO::filter< CharT, TraitsT, DeviceT >::write ( const char_type b,
std::streamsize  n 
) [inline, virtual]


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

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