Class Template basic_stdio_filter

Description
Headers
Reference
Example

Description

The class template basic_stdio_filter is a DualUseFilter for use as a base class by Filters which read unfiltered data from standard input and write filtered data to standard output.

basic_stdio_filter is implemented by redirecting std::cin and std::cout (or std::wcin and std::wcout). Before do_filter is invoked, the entire stream of unfiltered data is read and stored in memory. As a result, basic_stdio_filter is unsuitable for use in low-memory environments or in conjunction with streams of data that have no natural end, such as stock tickers. Because of these limitations, basic_stdio_filter is best used as an aid to those learning to use the Iostreams library.

Headers

<boost/iostreams/filter/stdio.hpp>

Reference

Synopsis

namespace boost { namespace iostreams {

template<typename Ch>
class basic_stdio_filter {
public:
    typedef Ch                        char_type;
    typedef [implementation-defined]  category;
protected:
    basic_stdio_filter();
public:
    virtual ~basic_stdio_filter();
private:
    virtual void do_filter() = 0;
};

typedef basic_stdio_filter<char>     stdio_filter;
typedef basic_stdio_filter<wchar_t>  wstdio_filter;

} } // End namespace boost::io

Template parameters

Ch- The character type

counter::do_filter

    virtual void do_filter() = 0;

Reads from standard input and writes to standard output until standard input is exhausted. If Ch is char, uses std::cin and std::cout; if Ch is wchar_t, uses std::wcin and std::wcout.

Example

Five examples of stdio_filters are presented in the Tutorial.