Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/iostreams/doc/functions/put.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.1 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4    <TITLE>Function Template put</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>put</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>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="../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>put</CODE> in the definition of an <A HREF="../concepts/output_filter.html">OutputFilter</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">// toupper</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">// output_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">// put</SPAN>
41
42    <SPAN CLASS="keyword">using</SPAN> <SPAN CLASS="keyword">namespace</SPAN> std;
43    <SPAN CLASS="keyword">namespace</SPAN> io = boost::iostreams;
44
45    <SPAN CLASS="keyword">struct</SPAN> toupper_filter : <SPAN CLASS="keyword">public</SPAN> io::output_filter {
46        <SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> Sink&gt;
47        <SPAN CLASS="keyword">bool</SPAN> put(Sink& snk, <SPAN CLASS="keyword">char</SPAN> c)
48        {
49            <SPAN CLASS="keyword">return</SPAN> io::put(snk, toupper((<SPAN CLASS="keyword">unsigned</SPAN> <SPAN CLASS="keyword">char</SPAN>) c));
50        }
51    };</PRE>
52
53<A NAME="headers"></A>
54<H2>Headers</H2>
55
56<DL>
57  <DT><A CLASS="header" HREF="../../../../boost/iostreams/operations.hpp"><CODE>&lt;boost/iostreams/operations.hpp&gt;</CODE></A></DT>
58  <DT><A CLASS="header" HREF="../../../../boost/iostreams/put.hpp"><CODE>&lt;boost/iostreams/put.hpp&gt;</CODE></A></DT>
59</DL>
60
61<A NAME="reference"></A>
62<H2>Reference</H2>
63
64<A NAME="description"></A>
65<H4>Description</H4>
66
67<P>Attempts to write a character to a given instance of the template parameter <CODE>Sink</CODE>, returning <CODE>true</CODE> for success.</P>
68
69<A NAME="synopsis"></A>
70<H4>Synopsis</H4>
71
72<PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {
73             
74    <SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#template_params">Sink</A>&gt;     
75    <SPAN CLASS="keyword">void</SPAN> put(Sink& <A CLASS="documented" HREF="#function_params">snk</A>, <SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="../guide/traits.html#char_type_of_ref">char_type_of</A>&lt;Sink&gt;::type c);
76
77} } <SPAN CLASS="comment">// End namespace boost::io</SPAN></PRE>
78
79<A NAME="template_params"></A>
80<H4>Template Parameters</H4>
81
82<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
83<TR>
84    <TR>
85        <TD VALIGN="top"><I>Sink</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
86        <TD>A <A HREF="../concepts/direct.html">indirect</A> model of <A HREF="../concepts/sink.html">Sink</A> or a standard output stream or stream buffer type.
87    </TR>
88</TABLE>
89
90<A NAME="function_params"></A>
91<H4>Function Parameters</H4>
92
93<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
94<TR>
95    <TR>
96        <TD VALIGN="top"><I>snk</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
97        <TD>An instance of <CODE>Sink</CODE></TD>
98    </TR>
99</TABLE>
100
101<A NAME="semantics"></A>
102<H4>Semantics</H4>
103
104<PRE CLASS="broken_ie">    <SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> Sink&gt;     
105    <SPAN CLASS="keyword">void</SPAN> put(Sink& snk, <SPAN CLASS="keyword">typename</SPAN> char_type_of&lt;Sink&gt;::type c);</PRE>
106
107<P>The semantics of <CODE>put</CODE> depends on the <A HREF="../guide/traits.html#category">category</A> of <CODE>Sink</CODE> as follows:</P>
108
109<TABLE STYLE="margin:0,0,2em,2em" BORDER=1 CELLPADDING=4>
110    <TR><TH><CODE>category_of&lt;Sink&gt;::type</CODE></TH><TH>semantics</TH></TR>
111    <TR>
112        <TD VALIGN="top">convertible to <A HREF="../guide/traits.html#category_tags"><CODE>direct_tag</CODE></A></TD>
113        <TD>compile-time error</CODE></TD>
114    </TR>
115    <TR>
116        <TD VALIGN="top">convertible to <A HREF="../guide/traits.html#category_tags"><CODE>ostream_tag</CODE></A></TD>
117        <TD>invokes <CODE>snk.put(c)</CODE></TD>
118    </TR>
119    <TR>
120        <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>ostream_tag</CODE></A></TD>
121        <TD>invokes <CODE>snk.sputc(c)</CODE></TD>
122    </TR>
123    <TR>
124        <TD VALIGN="top">otherwise</TD>
125        <TD>invokes <CODE>snk.write(&c, 1)</CODE></TD>
126    </TR>
127</TABLE>
128
129<!-- Begin Footer -->
130
131<HR>
132<P CLASS="copyright">Revised
133<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
13420 May, 2004
135<!--webbot bot="Timestamp" endspan i-checksum="38504" -->
136</P>
137
138<P CLASS="copyright">&copy; Copyright <A HREF="http://www.kangaroologic.com" TARGET="_top">Jonathan Turkanis</A>, 2004</P>
139<P CLASS="copyright"> 
140    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>)
141</P>
142
143<!-- End Footer -->
144
145</BODY>
Note: See TracBrowser for help on using the repository browser.