Function Template get

# 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, EOF, WOULD_BLOCK

        using namespace std;
        using namespace boost::io;

        struct tolower_filter : public input_filter {
            template<typename Source>
            int get(Source& src)
            {
                int c;
                return (c == boost::iostreams::get(src)) != EOF &&
                        c != WOULD_BLOCK
                            ?
                    tolower((unsigned char) c) :
                    c;
            }
        };

## Headers

`<boost/iostreams/get.hpp>`
`<boost/iostreams/operations.hpp>`

## Reference

#### Description

Attemps to extract a character from a given instance of the template parameter `Source`, returning the extracted character or one of the special values `traits_type::eof` or `traits_type::would_block`, where `traits_type` is an appropriate specialization of `boost::iostreams::char_traits`

#### Synopsis

    namespace boost { namespace iostreams {

        template<typename Source>
        typename int_type_of<Source>::type
        get(Source& src);

    } } // End namespace boost::io

#### Template Parameters

Source | - | A model of Source.

#### Function Parameters

src | - | An instance of `Source`

#### Semantics

        template<typename Source>
        typename int_type_of<Source>::type
        get(Source& src);

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

`category_of<Source>::type` | semantics
--- | ---
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 one of the special values `traits_type::eof` or `traits_type::would_block` otherwise, where `traits_type` is `boost::iostreams::char_traits<Source>`

© Copyright 2008 CodeRage, LLC
© Copyright 2004-2007 Jonathan Turkanis

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)