150 lines
6.9 KiB
HTML
150 lines
6.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>Function Template get</TITLE>
|
|
<LINK REL="stylesheet" HREF="../../../../boost.css">
|
|
<LINK REL="stylesheet" HREF="../theme/iostreams.css">
|
|
</HEAD>
|
|
<BODY>
|
|
|
|
<!-- Begin Banner -->
|
|
|
|
<H1 CLASS="title">Function Template <CODE>get</CODE></H1>
|
|
<HR CLASS="banner">
|
|
|
|
<!-- End Banner -->
|
|
|
|
<DL class="page-index">
|
|
<DT><A href="#overview">Overview</A></DT>
|
|
<DT><A href="#example">Example</A></DT>
|
|
<DT><A href="#headers">Headers</A></DT>
|
|
<DT><A href="#reference">Reference</A></DT>
|
|
</DL>
|
|
|
|
<A NAME="overview"></A>
|
|
<H2>Overview</H2>
|
|
|
|
<P>
|
|
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>).
|
|
</P>
|
|
|
|
<A NAME="example"></A>
|
|
<H2>Example</H2>
|
|
|
|
<P>
|
|
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>.
|
|
</P>
|
|
|
|
<PRE CLASS="broken_ie"> <SPAN CLASS="preprocessor">#include</SPAN> <SPAN CLASS="literal"><ctype.h></SPAN> <SPAN CLASS="comment">// tolower</SPAN>
|
|
<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>
|
|
<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>
|
|
|
|
<SPAN CLASS="keyword">using</SPAN> <SPAN CLASS="keyword">namespace</SPAN> std;
|
|
<SPAN CLASS="keyword">using</SPAN> <SPAN CLASS="keyword">namespace</SPAN> boost::io;
|
|
|
|
<SPAN CLASS="keyword">struct</SPAN> tolower_filter : <SPAN CLASS="keyword">public</SPAN> input_filter {
|
|
<SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Source>
|
|
<SPAN CLASS="keyword">int</SPAN> get(Source& src)
|
|
{
|
|
<SPAN CLASS="keyword">int</SPAN> c;
|
|
<SPAN CLASS="keyword">return</SPAN> (c = boost::iostreams::get(src)) != <SPAN CLASS='numeric_literal'>EOF</SPAN> &&
|
|
c != WOULD_BLOCK
|
|
?
|
|
tolower((<SPAN CLASS="keyword">unsigned</SPAN> <SPAN CLASS="keyword">char</SPAN>) c) :
|
|
c;
|
|
}
|
|
};</PRE>
|
|
|
|
<A NAME="headers"></A>
|
|
<H2>Headers</H2>
|
|
|
|
<DL>
|
|
<DT><A CLASS="header" HREF="../../../../boost/iostreams/get.hpp"><CODE><boost/iostreams/get.hpp></CODE></A></DT>
|
|
<DT><A CLASS="header" HREF="../../../../boost/iostreams/operations.hpp"><CODE><boost/iostreams/operations.hpp></CODE></A></DT>
|
|
</DL>
|
|
|
|
<A NAME="reference"></A>
|
|
<H2>Reference</H2>
|
|
|
|
<A NAME="description"></A>
|
|
<H4>Description</H4>
|
|
|
|
<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>
|
|
|
|
<A NAME="synopsis"></A>
|
|
<H4>Synopsis</H4>
|
|
|
|
<PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {
|
|
|
|
<SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#template_params">Source</A>>
|
|
<SPAN CLASS="keyword">typename</SPAN> <A CLASS='documented' HREF="../guide/traits.html#int_type_of_ref">int_type_of</A><Source>::type
|
|
<A CLASS="documented" HREF="#semantics">get</A>(<A CLASS="documented" HREF="#template_params">Source</A>& <A CLASS="documented" HREF="#function_params">src</A>);
|
|
|
|
} } <SPAN CLASS="comment">// End namespace boost::io</SPAN></PRE>
|
|
|
|
<A NAME="template_params"></A>
|
|
<H4>Template Parameters</H4>
|
|
|
|
<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
|
|
<TR>
|
|
<TR>
|
|
<TD VALIGN="top"><I>Source</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
|
|
<TD>A model of <A HREF="../concepts/source.html">Source</A>.
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<A NAME="function_params"></A>
|
|
<H4>Function Parameters</H4>
|
|
|
|
<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
|
|
<TR>
|
|
<TR>
|
|
<TD VALIGN="top"><I>src</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
|
|
<TD>An instance of <CODE>Source</CODE></TD>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<A NAME="semantics"></A>
|
|
<H4>Semantics</H4>
|
|
|
|
<PRE CLASS="broken_ie"> <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Source>
|
|
<SPAN CLASS="keyword">typename</SPAN> int_type_of<Source>::type
|
|
get(Source& src);</PRE>
|
|
|
|
<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>
|
|
|
|
<TABLE STYLE="margin:0,0,2em,2em" BORDER=1 CELLPADDING=4>
|
|
<TR><TH><CODE>category_of<Source>::type</CODE></TH><TH>semantics</TH></TR>
|
|
<TR>
|
|
<TD VALIGN="top">convertible to <A HREF="../guide/traits.html#category_tags"><CODE>direct_tag</CODE></A></TD>
|
|
<TD>compile-time error</CODE></TD>
|
|
</TR>
|
|
<TR>
|
|
<TD VALIGN="top">convertible to <A HREF="../guide/traits.html#category_tags"><CODE>istream_tag</CODE></A></TD>
|
|
<TD>returns <CODE>src.get()</CODE></TD>
|
|
</TR>
|
|
<TR>
|
|
<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>
|
|
<TD>returns <CODE>src.sbumpc()</CODE></TD>
|
|
</TR>
|
|
<TR>
|
|
<TD VALIGN="top">otherwise</TD>
|
|
<TD>
|
|
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>
|
|
</TD>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<!-- Begin Footer -->
|
|
|
|
<HR>
|
|
|
|
<P CLASS="copyright">© Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a><br/>© Copyright 2004-2007 <a href="https://www.boost.org/users/people/jonathan_turkanis.html" target="_top">Jonathan Turkanis</a></P>
|
|
<P CLASS="copyright">
|
|
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>)
|
|
</P>
|
|
|
|
<!-- End Footer -->
|
|
|
|
</BODY>
|