mirror of
https://github.com/boostorg/iostreams.git
synced 2026-02-22 15:32:20 +00:00
144 lines
5.6 KiB
HTML
Executable File
144 lines
5.6 KiB
HTML
Executable File
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>Function Template put</TITLE>
|
|
<LINK REL='stylesheet' HREF='../../../../boost.css'>
|
|
<LINK REL='stylesheet' HREF='../theme/iostreams.css'>
|
|
</HEAD>
|
|
<BODY>
|
|
|
|
<!-- Begin Banner -->
|
|
|
|
<H1 CLASS='title'>Function Template <CODE>put</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>put</CODE> provides a uniform interface for writing a character to a <A HREF='../concepts/sink.html'>Sink</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>put</CODE> in the definition of an <A HREF='../concepts/output_filter.html'>OutputFilter</A>.
|
|
</P>
|
|
|
|
<PRE CLASS='broken_ie'> <SPAN CLASS='preprocessor'>#include</SPAN> <SPAN CLASS='literal'><ctype.h></SPAN> <SPAN CLASS='comment'>// toupper</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'>// output_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'>// put</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> toupper_filter : <SPAN CLASS="keyword">public</SPAN> output_filter {
|
|
<SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Sink>
|
|
<SPAN CLASS="keyword">void</SPAN> put(Sink& snk, <SPAN CLASS="keyword">char</SPAN> c)
|
|
{
|
|
boost::iostreams::put(snk, toupper(c));
|
|
}
|
|
};</PRE>
|
|
|
|
<A NAME='headers'>
|
|
<H2>Headers</H2>
|
|
|
|
<DL>
|
|
<DT><A CLASS='header' HREF='../../../../boost/iostreams/operations.hpp'><CODE><boost/iostreams/operations.hpp></CODE></A></DT>
|
|
</DL>
|
|
|
|
<A NAME='reference'>
|
|
<H2>Reference</H2>
|
|
|
|
<A NAME='description'>
|
|
<H4>Description</H4>
|
|
|
|
<P>Writes a character to a given instance of the template parameter <CODE>Sink</CODE></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><<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#template_params">Sink</A>>
|
|
<SPAN CLASS="keyword">void</SPAN> put(Sink& <A CLASS="documented" HREF="#function_params">snk</A>, <SPAN CLASS="keyword">typename</SPAN> <A CLASS='documented' HREF='../traits.html#char_type_ref'>io_char</A><Sink>::type c);
|
|
|
|
} } <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>Sink</I></TD><TD WIDTH='2em' VALIGN='top'>-</TD>
|
|
<TD>A model of <A HREF='../concepts/sink.html'>Sink</A> or a standard output 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>snk</I></TD><TD WIDTH='2em' VALIGN='top'>-</TD>
|
|
<TD>An instance of <CODE>Sink</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> Sink>
|
|
<SPAN CLASS="keyword">void</SPAN> put(Sink& snk, <SPAN CLASS="keyword">typename</SPAN> io_char<Sink>::type c);</PRE>
|
|
|
|
<P>The semantics of <CODE>put</CODE> depends on the <A HREF="../traits.html#category">category</A> of <CODE>Sink</CODE> as follows:</P>
|
|
|
|
<TABLE STYLE='margin:0,0,2em,2em' BORDER=1 CELLPADDING=4>
|
|
<TR><TH><CODE>io_category<Sink>::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>ostream_tag</CODE></A></TD>
|
|
<TD>invokes <CODE>snk.put(c)</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>ostream_tag</CODE></A></TD>
|
|
<TD>invokes <CODE>snk.sputc(c)</CODE></TD>
|
|
</TR>
|
|
<TR>
|
|
<TD VALIGN='top'>otherwise</TD>
|
|
<TD>invokes <CODE>snk.write(&c, 1)</CODE></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'>© 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> |