Function Template get

Overview
Example
Headers
Reference

Overview

The function template get provides a uniform interface for reading a character from a Source, for use in the definitions of new Filter types (see Example).

Example

The following code illustrates the use of the function get in the definition of an InputFilter.

    #include <ctype.h>                 // tolower
    #include <boost/iostreams/concepts.hpp>   // input_filter 
    #include <boost/iostreams/operations.hpp> // get

    using namespace std;
    using namespace boost::io;

    struct tolower_filter : public input_filter {
        template<typename Source>
        int get(Source& src)
            {
                return tolower(boost::iostreams::get(src));
            }
    };

Headers

<boost/iostreams/operations.hpp>

Reference

Description

Attemps to extract a character from a given instance of the template parameter Source, returning the extracted character if successful and an end-of-file indicator otherwise.

Synopsis

namespace boost { namespace iostreams {
              
    template<typename Source>     
    [int type] get(Source& src);

} } // End namespace boost::io

Template Parameters

Source- A model of Source or a standard input stream or stream buffer type.

Function Parameters

src- An instance of Source

Return Type

An integral type large enough to represent every element of the character type of Source plus an end-of-file indicator. Specifically:

    typename std::char_traits<typename io_char<Source>::type>::int_type

Return Value

The next character in the filtered sequence, or traits_type::eof(), where traits_type is

    std::char_traits<typename io_char<Source>::type>

Semantics

    template<typename Source>     
    [int type] get(Source& src);

The semantics of get depends on the category of Source as follows:

io_category<Source>::typesemantics
convertible to direct_tag compile-time error
convertible to istream_tag returns src.get()
convertible to streambuf_tag but not to istream_tag returns src.sbumpc()
otherwise attempts to extract a single character using src.read(), returning the extracted character if successful and an end-of-file indicator otherwise