1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <TITLE>Class Template chain</TITLE>
5 <LINK REL="stylesheet" HREF="../../../../boost.css">
6 <LINK REL="stylesheet" HREF="../theme/iostreams.css">
12 <H1 CLASS="title">Function Template <CODE>invert</CODE></H1>
17 <DL class="page-index">
18 <DT><A href="#description">Description</A></DT>
19 <DT><A href="#headers">Headers</A></DT>
20 <DT><A href="#reference">Reference</A></DT>
25 <A NAME="description"></A>
29 The class template <CODE>inverse</CODE> is an adapter which transforms an <A HREF='../concepts/input_filter.html'>InputFilter</A> into an <A HREF='../concepts/output_filter.html'>OutputFilter</A> or <I>vice versa</I>. The function template <CODE>invert</CODE> is an <A HREF='http://www.boost.org/more/generic_programming.html#object_generator' TARGET='_top'>object generator</A> which when passed a Filter returns a instance of an appropriate specialization of <CODE>inverse</CODE>.
32 <P>Given an <A HREF='../concepts/input_filter.html'>InputFilter</A> <CODE>f</CODE>, the inverse of <CODE>f</CODE> is <A HREF='../concepts/multi_character.html'>Multi-Character</A> <A HREF='../concepts/output_filter.html'>OutputFilter</A> whose member function <CODE>write</CODE> is implemented as follows. Given a <A HREF='../concepts/sink.html'>Sink</A> <CODE>snk</CODE> and a character buffer <CODE>s</CODE> of length <CODE>n</CODE>, we
35 <LI>construct a <A HREF='../concepts/source.html'>Source</A> based on the buffer <CODE>s</CODE> and <A HREF='compose.html'><CODE>compose</CODE></A> it with <CODE>f</CODE> to form a Source, then
36 <LI>repeatedly read sequences of characters from the composite Source and write them to <CODE>snk</CODE> until the buffer <CODE>s</CODE> is exhausted.
39 <P>Similarly, given an <A HREF='../concepts/output_filter.html'>OutputFilter</A> <CODE>f</CODE>, the inverse of <CODE>f</CODE> is <A HREF='../concepts/multi_character.html'>Multi-Character</A> <A HREF='../concepts/input_filter.html'>InputFilter</A> whose member function <CODE>read</CODE> is implemented as follows. Given a <A HREF='../concepts/source.html'>Source</A> <CODE>src</CODE> and a character buffer <CODE>s</CODE> of length <CODE>n</CODE>, we
42 <LI>construct a <A HREF='../concepts/sink.html'>Sink</A> based on the buffer <CODE>s</CODE> and <A HREF='compose.html'><CODE>compose</CODE></A> it with <CODE>f</CODE> to form a Sink, then
43 <LI>repeatedly read sequences of characters from <CODE>src</CODE> and write them to the composite Sink until the buffer <CODE>s</CODE> is full.
47 The <A HREF='../guide/modes.html'>mode</A> of a specialization of <CODE>inverse</CODE> is equal to <A HREF='../guide/modes.html#output'>output</A> if the mode of the underlying filter refines input, and to <A HREF='../guide/modes.html#input'>input</A> otherwise.
50 <A NAME="headers"></A>
53 <DL class="page-index">
54 <DT><A CLASS="header" HREF="../../../../boost/iostreams/invert.hpp"><CODE><boost/iostreams/invert.hpp></CODE></A></DT>
57 <A NAME="reference"></A>
60 <A NAME="synopsis"></A>
63 <PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {
65 <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#inverse_template_params">Filter</A>>
66 <SPAN CLASS='keyword'>class</SPAN> <A CLASS='documented' HREF='#inverse'>inverse</A> {
67 <SPAN CLASS='keyword'>public:</SPAN>
68 <SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='keyword'>typename</SPAN> <A CLASS='documented' HREF='../guide/traits.html#char_type_of_ref'>char_type_of</A><Filter>::type char_type;
69 <SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>see above</SPAN> mode;
71 <A CLASS='documented' HREF='#inverse_ctor'>inverse</A>(<SPAN CLASS='keyword'>const</SPAN> Filter& filter);
73 <SPAN CLASS='comment'>// Filter member functions</SPAN>
76 <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#invert_template_params">Filter</A>>
77 <A CLASS='documented' HREF='#inverse'>inverse</A><Filter> <A CLASS='documented' HREF='#invert'>invert</A>(<SPAN CLASS='keyword'>const</SPAN> Filter& filter);
79 } } // End namespace boost::io</PRE>
81 <A NAME="inverse"></A>
82 <H2>Class Template <CODE>inverse</CODE></H2>
84 <A NAME="inverse_template_params"></A>
85 <H4>Template parameters</H4>
87 <TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
90 <TD VALIGN="top"><I>Filter</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
91 <TD>A model of <A HREF='../concepts/filter.html'>Filter</A></TD>
95 <A NAME="inverse_ctor"></A>
96 <H4><CODE>inverse::inverse</CODE></H4>
98 <PRE CLASS="broken_ie"> inverse(<SPAN CLASS='keyword'>const</SPAN> Filter& filter);</PRE>
101 Constructs an instance of <CODE>inverse</CODE> based on the given filter.
104 <A NAME="invert"></A>
105 <H2>Function Template <CODE>invert</CODE></H2>
107 <PRE CLASS="broken_ie"><SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Filter>
108 inverse<Filter> invert(<SPAN CLASS='keyword'>const</SPAN> Filter& filter);</PRE>
110 <A NAME="invert_template_params"></A>
111 <H4>Template parameters</H4>
113 <TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
116 <TD VALIGN="top"><I>Filter</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
117 <TD>A model of <A HREF='../concepts/filter.html'>Filter</A></TD>
122 Constructs an instance of an appropriate specialization of <CODE>inverse</CODE> based on the given filter.
125 <!-- Begin Footer -->
129 <P CLASS="copyright">© Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a><br/>© Copyright 2004-2007 <a href="http://www.coderage.com/turkanis/" target="_top">Jonathan Turkanis</a></P>
130 <P CLASS="copyright">
131 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>)