get
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).
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)); } };
<boost/iostreams/operations.hpp>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.
namespace boost { namespace iostreams { template<typename Source> [int type] get(Source& src); } } // End namespace boost::io
| Source | - | A model of Source or a standard input stream or stream buffer type. |
| src | - | An instance of Source |
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
The next character in the filtered sequence, or traits_type::eof(), where traits_type is
std::char_traits<typename io_char<Source>::type>
template<typename Source> [int type] get(Source& src);
The semantics of get depends on the category of Source as follows:
io_category<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 an end-of-file indicator otherwise
|
Revised 20 May, 2004
© Copyright Jonathan Turkanis, 2004
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)