Files
iostreams/doc/functions/get.html
Jonathan Turkanis 5b886642b4 switched to double quotes in HTML attributes
[SVN r27367]
2005-02-14 01:51:10 +00:00

159 lines
6.6 KiB
HTML
Executable File

<!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">
<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="../concepts.html#filter_concepts">Filter</A> types (<I>see</I> <A HREF="#example">Example</A>).
</P>
<A NAME="example">
<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">&lt;ctype.h&gt;</SPAN> <SPAN CLASS="comment">// tolower</SPAN>
<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>
<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</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>&lt;<SPAN CLASS="keyword">typename</SPAN> Source&gt;
<SPAN CLASS="keyword">int</SPAN> get(Source& src)
{
<SPAN CLASS="keyword">return</SPAN> tolower(boost::iostreams::get(src));
}
};</PRE>
<A NAME="headers">
<H2>Headers</H2>
<DL>
<DT><A CLASS="header" HREF="../../../../boost/iostreams/operations.hpp"><CODE>&lt;boost/iostreams/operations.hpp&gt;</CODE></A></DT>
</DL>
<A NAME="reference">
<H2>Reference</H2>
<A NAME="description">
<H4>Description</H4>
<P>Attemps to extract a character from a given instance of the template parameter <CODE>Source</CODE>, returning the extracted character if successful and an end-of-file indicator otherwise.</P>
<A NAME="synopsis">
<H4>Synopsis</H4>
<PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {
<SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#template_params">Source</A>&gt;
<A STYLE="text-decoration:none" HREF="#return_type"><SPAN CLASS="omitted">[int type]</SPAN></A> <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> or a standard input stream or stream buffer type.
</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="return_type"></A>
<H4>Return Type</H4>
<P>An integral type large enough to represent every element of the <A HREF="../traits.html#char_type">character type</A> of <CODE>Source</CODE> plus an end-of-file indicator. Specifically:
<PRE CLASS="broken_ie"> <SPAN CLASS="keyword">typename</SPAN> std::char_traits&lt;<SPAN CLASS="keyword">typename</SPAN> io_char&lt;Source&gt;::type&gt;::int_type</PRE>
<A NAME="return_value"></A>
<H4>Return Value</H4>
<P>The next character in the filtered sequence, or <CODE>traits_type::eof()</CODE>, where <CODE>traits_type</CODE> is</P>
<PRE CLASS="broken_ie"> std::char_traits&lt;<SPAN CLASS="keyword">typename</SPAN> io_char&lt;Source&gt;::type&gt;</PRE>
<A NAME="semantics"></A>
<H4>Semantics</H4>
<PRE CLASS="broken_ie"> <SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> Source&gt;
<SPAN CLASS="omitted">[int type]</SPAN> get(Source& src);</PRE>
<P>The semantics of <CODE>get</CODE> depends on the <A HREF="../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>io_category&lt;Source&gt;::type</CODE></TH><TH>semantics</TH></TR>
<TR>
<TD VALIGN="top">convertible to <A HREF="../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="../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="../traits.html#category_tags"><CODE>streambuf_tag</CODE></A> but not to <A HREF="../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 an end-of-file indicator otherwise
</TD>
</TR>
</TABLE>
<!-- Begin Footer -->
<HR>
<P CLASS="copyright">Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
20 May, 2004
<!--webbot bot="Timestamp" endspan i-checksum="38504" -->
</P>
<P CLASS="copyright">&copy; Copyright Jonathan Turkanis, 2004</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>