Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 623999701586b0ea103ff2ccad7954a6 > files > 7112

boost-doc-1.44.0-1.fc14.noarch.rpm

<!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"></A>
<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="../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>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">&lt;ctype.h&gt;</SPAN>                        <SPAN CLASS="comment">// toupper</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">// output_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">// put</SPAN>

    <SPAN CLASS="keyword">using</SPAN> <SPAN CLASS="keyword">namespace</SPAN> std;
    <SPAN CLASS="keyword">namespace</SPAN> io = boost::iostreams;

    <SPAN CLASS="keyword">struct</SPAN> toupper_filter : <SPAN CLASS="keyword">public</SPAN> io::output_filter {
        <SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> Sink&gt;
        <SPAN CLASS="keyword">bool</SPAN> put(Sink& snk, <SPAN CLASS="keyword">char</SPAN> c)
        {
            <SPAN CLASS="keyword">return</SPAN> io::put(snk, toupper((<SPAN CLASS="keyword">unsigned</SPAN> <SPAN CLASS="keyword">char</SPAN>) c));
        }
    };</PRE>

<A NAME="headers"></A>
<H2>Headers</H2>

<DL>
  <DT><A CLASS="header" HREF="../../../../boost/iostreams/operations.hpp"><CODE>&lt;boost/iostreams/operations.hpp&gt;</CODE></A></DT>
  <DT><A CLASS="header" HREF="../../../../boost/iostreams/put.hpp"><CODE>&lt;boost/iostreams/put.hpp&gt;</CODE></A></DT>
</DL>

<A NAME="reference"></A>
<H2>Reference</H2>

<A NAME="description"></A>
<H4>Description</H4>

<P>Attempts to write a character to a given instance of the template parameter <CODE>Sink</CODE>, returning <CODE>true</CODE> for success.</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>&lt;<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#template_params">Sink</A>&gt;     
    <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);

} } <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 <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.
    </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>&lt;<SPAN CLASS="keyword">typename</SPAN> Sink&gt;     
    <SPAN CLASS="keyword">void</SPAN> put(Sink& snk, <SPAN CLASS="keyword">typename</SPAN> char_type_of&lt;Sink&gt;::type c);</PRE>

<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>

<TABLE STYLE="margin:0,0,2em,2em" BORDER=1 CELLPADDING=4>
    <TR><TH><CODE>category_of&lt;Sink&gt;::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>ostream_tag</CODE></A></TD>
        <TD>invokes <CODE>snk.put(c)</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>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 02 Feb 2008</P>

<P CLASS="copyright">&copy; Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a><br/>&copy; Copyright 2004-2007 <a href="http://www.coderage.com/turkanis/" 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>