Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/iostreams/doc/functions/get.html @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 6.9 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4    <TITLE>Function Template get</TITLE>
5    <LINK REL="stylesheet" HREF="../../../../boost.css">
6    <LINK REL="stylesheet" HREF="../theme/iostreams.css">
7</HEAD>
8<BODY>
9
10<!-- Begin Banner -->
11
12    <H1 CLASS="title">Function Template <CODE>get</CODE></H1>
13    <HR CLASS="banner">
14
15<!-- End Banner -->
16
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>
22</DL>
23
24<A NAME="overview"></A>
25<H2>Overview</H2>
26
27<P>
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>).
29</P>
30
31<A NAME="example"></A>
32<H2>Example</H2>
33
34<P>
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>.
36</P>
37
38<PRE CLASS="broken_ie">    <SPAN CLASS="preprocessor">#include</SPAN> <SPAN CLASS="literal">&lt;ctype.h&gt;</SPAN>                        <SPAN CLASS="comment">// tolower</SPAN>   
39    <SPAN CLASS="preprocessor">#include</SPAN> <A CLASS="header" HREF="../../../../boost/iostreams/concepts.hpp"><SPAN CLASS="literal">&lt;boost/iostreams/concepts.hpp&gt;</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">&lt;boost/iostreams/operations.hpp&gt;</SPAN></A> <SPAN CLASS="comment">// get, EOF, WOULD_BLOCK</SPAN>
41
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;
44
45    <SPAN CLASS="keyword">struct</SPAN> tolower_filter : <SPAN CLASS="keyword">public</SPAN> input_filter {
46        <SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> Source&gt;
47        <SPAN CLASS="keyword">int</SPAN> get(Source& src)
48        {
49            <SPAN CLASS="keyword">int</SPAN> c;
50            <SPAN CLASS="keyword">return</SPAN> (c == boost::iostreams::get(src)) != <SPAN CLASS='numeric_literal'>EOF</SPAN> &amp;&amp; 
51                    c != WOULD_BLOCK
52                        ?
53                tolower((<SPAN CLASS="keyword">unsigned</SPAN> <SPAN CLASS="keyword">char</SPAN>) c) :
54                c;
55        }
56    };</PRE>
57
58<A NAME="headers"></A>
59<H2>Headers</H2>
60
61<DL>
62  <DT><A CLASS="header" HREF="../../../../boost/iostreams/get.hpp"><CODE>&lt;boost/iostreams/get.hpp&gt;</CODE></A></DT>
63  <DT><A CLASS="header" HREF="../../../../boost/iostreams/operations.hpp"><CODE>&lt;boost/iostreams/operations.hpp&gt;</CODE></A></DT>
64</DL>
65
66<A NAME="reference"></A>
67<H2>Reference</H2>
68
69<A NAME="description"></A>
70<H4>Description</H4>
71
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>
73
74<A NAME="synopsis"></A>
75<H4>Synopsis</H4>
76
77<PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {
78             
79    <SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#template_params">Source</A>&gt;     
80    <SPAN CLASS="keyword">typename</SPAN> <A CLASS='documented' HREF="../guide/traits.html#int_type_of_ref">int_type_of</A>&lt;Source&gt;::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>);
82
83} } <SPAN CLASS="comment">// End namespace boost::io</SPAN></PRE>
84
85<A NAME="template_params"></A>
86<H4>Template Parameters</H4>
87
88<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
89<TR>
90    <TR>
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>.
93    </TR>
94</TABLE>
95
96<A NAME="function_params"></A>
97<H4>Function Parameters</H4>
98
99<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
100<TR>
101    <TR>
102        <TD VALIGN="top"><I>src</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
103        <TD>An instance of <CODE>Source</CODE></TD>
104    </TR>
105</TABLE>
106
107<A NAME="semantics"></A>
108<H4>Semantics</H4>
109
110<PRE CLASS="broken_ie">    <SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> Source&gt;     
111    <SPAN CLASS="keyword">typename</SPAN> int_type_of&lt;Source&gt;::type
112    get(Source& src);</PRE>
113
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>
115
116<TABLE STYLE="margin:0,0,2em,2em" BORDER=1 CELLPADDING=4>
117    <TR><TH><CODE>category_of&lt;Source&gt;::type</CODE></TH><TH>semantics</TH></TR>
118    <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>
121    </TR>
122    <TR>
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>
125    </TR>
126    <TR>
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>
129    </TR>
130    <TR>
131        <TD VALIGN="top">otherwise</TD>
132        <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&lt;Source&gt;</CODE></A>
134        </TD>
135    </TR>
136</TABLE>
137
138<!-- Begin Footer -->
139
140<HR>
141<P CLASS="copyright">Revised
142<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
14320 May, 2004
144<!--webbot bot="Timestamp" endspan i-checksum="38504" -->
145</P>
146
147<P CLASS="copyright">&copy; Copyright <A HREF="http://www.kangaroologic.com" TARGET="_top">Jonathan Turkanis</A>, 2004</P>
148<P CLASS="copyright"> 
149    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>)
150</P>
151
152<!-- End Footer -->
153
154</BODY>
Note: See TracBrowser for help on using the repository browser.