1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">
4 <TITLE>Function Template get
</TITLE>
5 <LINK REL=
"stylesheet" HREF=
"../../../../boost.css">
6 <LINK REL=
"stylesheet" HREF=
"../theme/iostreams.css">
12 <H1 CLASS=
"title">Function Template
<CODE>get
</CODE></H1>
17 <DL class=
"page-index">
18 <DT><A href=
"#overview">Overview
</A></DT>
19 <DT><A href=
"#example">Example
</A></DT>
20 <DT><A href=
"#headers">Headers
</A></DT>
21 <DT><A href=
"#reference">Reference
</A></DT>
24 <A NAME=
"overview"></A>
28 The function template
<CODE>get
</CODE> provides a uniform interface for reading a character from a
<A HREF=
"../concepts/source.html">Source
</A>, for use in the definitions of new
<A HREF=
"../guide/concepts.html#filter_concepts">Filter
</A> types (
<I>see
</I> <A HREF=
"#example">Example
</A>).
31 <A NAME=
"example"></A>
35 The following code illustrates the use of the function
<CODE>get
</CODE> in the definition of an
<A HREF=
"../concepts/input_filter.html">InputFilter
</A>.
38 <PRE CLASS=
"broken_ie"> <SPAN CLASS=
"preprocessor">#include
</SPAN> <SPAN CLASS=
"literal"><ctype.h
></SPAN> <SPAN CLASS=
"comment">// tolower
</SPAN>
39 <SPAN CLASS=
"preprocessor">#include
</SPAN> <A CLASS=
"header" HREF=
"../../../../boost/iostreams/concepts.hpp"><SPAN CLASS=
"literal"><boost/iostreams/concepts.hpp
></SPAN></A> <SPAN CLASS=
"comment">// input_filter
</SPAN>
40 <SPAN CLASS=
"preprocessor">#include
</SPAN> <A CLASS=
"header" HREF=
"../../../../boost/iostreams/operations.hpp"><SPAN CLASS=
"literal"><boost/iostreams/operations.hpp
></SPAN></A> <SPAN CLASS=
"comment">// get, EOF, WOULD_BLOCK
</SPAN>
42 <SPAN CLASS=
"keyword">using
</SPAN> <SPAN CLASS=
"keyword">namespace
</SPAN> std;
43 <SPAN CLASS=
"keyword">using
</SPAN> <SPAN CLASS=
"keyword">namespace
</SPAN> boost::io;
45 <SPAN CLASS=
"keyword">struct
</SPAN> tolower_filter :
<SPAN CLASS=
"keyword">public
</SPAN> input_filter {
46 <SPAN CLASS=
"keyword">template
</SPAN><<SPAN CLASS=
"keyword">typename
</SPAN> Source
>
47 <SPAN CLASS=
"keyword">int
</SPAN> get(Source
& src)
49 <SPAN CLASS=
"keyword">int
</SPAN> c;
50 <SPAN CLASS=
"keyword">return
</SPAN> (c = boost::iostreams::get(src)) !=
<SPAN CLASS='numeric_literal'
>EOF
</SPAN> &&
53 tolower((
<SPAN CLASS=
"keyword">unsigned
</SPAN> <SPAN CLASS=
"keyword">char
</SPAN>) c) :
58 <A NAME=
"headers"></A>
62 <DT><A CLASS=
"header" HREF=
"../../../../boost/iostreams/get.hpp"><CODE><boost/iostreams/get.hpp
></CODE></A></DT>
63 <DT><A CLASS=
"header" HREF=
"../../../../boost/iostreams/operations.hpp"><CODE><boost/iostreams/operations.hpp
></CODE></A></DT>
66 <A NAME=
"reference"></A>
69 <A NAME=
"description"></A>
72 <P>Attemps to extract a character from a given instance of the template parameter
<CODE>Source
</CODE>, returning the extracted character or one of the special values
<CODE>traits_type::eof
</CODE> or
<A HREF=
"../classes/char_traits.html#would_block"><CODE>traits_type::would_block
</CODE></A>, where
<CODE>traits_type
</CODE> is an appropriate specialization of
<A HREF=
"../classes/char_traits.html"><CODE>boost::iostreams::char_traits
</CODE></A></P>
74 <A NAME=
"synopsis"></A>
77 <PRE CLASS=
"broken_ie"><SPAN CLASS=
"keyword">namespace
</SPAN> boost {
<SPAN CLASS=
"keyword">namespace
</SPAN> iostreams {
79 <SPAN CLASS=
"keyword">template
</SPAN><<SPAN CLASS=
"keyword">typename
</SPAN> <A CLASS=
"documented" HREF=
"#template_params">Source
</A>>
80 <SPAN CLASS=
"keyword">typename
</SPAN> <A CLASS='documented'
HREF=
"../guide/traits.html#int_type_of_ref">int_type_of
</A><Source
>::type
81 <A CLASS=
"documented" HREF=
"#semantics">get
</A>(
<A CLASS=
"documented" HREF=
"#template_params">Source
</A>& <A CLASS=
"documented" HREF=
"#function_params">src
</A>);
83 } }
<SPAN CLASS=
"comment">// End namespace boost::io
</SPAN></PRE>
85 <A NAME=
"template_params"></A>
86 <H4>Template Parameters
</H4>
88 <TABLE STYLE=
"margin-left:2em" BORDER=
0 CELLPADDING=
2>
91 <TD VALIGN=
"top"><I>Source
</I></TD><TD WIDTH=
"2em" VALIGN=
"top">-
</TD>
92 <TD>A model of
<A HREF=
"../concepts/source.html">Source
</A>.
96 <A NAME=
"function_params"></A>
97 <H4>Function Parameters
</H4>
99 <TABLE STYLE=
"margin-left:2em" BORDER=
0 CELLPADDING=
2>
102 <TD VALIGN=
"top"><I>src
</I></TD><TD WIDTH=
"2em" VALIGN=
"top">-
</TD>
103 <TD>An instance of
<CODE>Source
</CODE></TD>
107 <A NAME=
"semantics"></A>
110 <PRE CLASS=
"broken_ie"> <SPAN CLASS=
"keyword">template
</SPAN><<SPAN CLASS=
"keyword">typename
</SPAN> Source
>
111 <SPAN CLASS=
"keyword">typename
</SPAN> int_type_of
<Source
>::type
112 get(Source
& src);
</PRE>
114 <P>The semantics of
<CODE>get
</CODE> depends on the
<A HREF=
"../guide/traits.html#category">category
</A> of
<CODE>Source
</CODE> as follows:
</P>
116 <TABLE STYLE=
"margin:0,0,2em,2em" BORDER=
1 CELLPADDING=
4>
117 <TR><TH><CODE>category_of
<Source
>::type
</CODE></TH><TH>semantics
</TH></TR>
119 <TD VALIGN=
"top">convertible to
<A HREF=
"../guide/traits.html#category_tags"><CODE>direct_tag
</CODE></A></TD>
120 <TD>compile-time error
</CODE></TD>
123 <TD VALIGN=
"top">convertible to
<A HREF=
"../guide/traits.html#category_tags"><CODE>istream_tag
</CODE></A></TD>
124 <TD>returns
<CODE>src.get()
</CODE></TD>
127 <TD VALIGN=
"top">convertible to
<A HREF=
"../guide/traits.html#category_tags"><CODE>streambuf_tag
</CODE></A> but not to
<A HREF=
"../guide/traits.html#category_tags"><CODE>istream_tag
</CODE></A></TD>
128 <TD>returns
<CODE>src.sbumpc()
</CODE></TD>
131 <TD VALIGN=
"top">otherwise
</TD>
133 attempts to extract a single character using
<CODE>src.read()
</CODE>, returning the extracted character if successful and one of the special values
<CODE>traits_type::eof
</CODE> or
<A HREF=
"../classes/char_traits.html#would_block"><CODE>traits_type::would_block
</CODE></A> otherwise, where
<CODE>traits_type
</CODE> is
<A HREF=
"../classes/char_traits.html"><CODE>boost::iostreams::char_traits
<Source
></CODE></A>
138 <!-- Begin Footer -->
142 <P CLASS=
"copyright">© Copyright
2008 <a href=
"http://www.coderage.com/" target=
"_top">CodeRage, LLC
</a><br/>© Copyright
2004-
2007 <a href=
"http://www.coderage.com/turkanis/" target=
"_top">Jonathan Turkanis
</a></P>
143 <P CLASS=
"copyright">
144 Distributed under the Boost Software License, Version
1.0. (See accompanying file LICENSE_1_0.txt or copy at
<A HREF=
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt
</A>)