1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4 <TITLE>Filtering Streams and Stream Buffers</TITLE> 5 <LINK REL="stylesheet" href="../../../../boost.css"> 6 <LINK REL="stylesheet" href="../theme/iostreams.css"> 7 <STYLE> 8 .caption_code { font: bold 8pt monospace } 9 </STYLE> 10</HEAD> 11<BODY> 12 13<!-- Begin Banner --> 14 15 <H1 CLASS="title">User's Guide</H1> 16 <HR CLASS="banner"> 17 18<!-- End Banner --> 19 20<!-- Begin Nav --> 21 22<DIV CLASS='nav'> 23 <A HREF='generic_streams.html'><IMG BORDER=0 WIDTH=19 HEIGHT=19 SRC='../../../../doc/src/images/prev.png'></A> 24 <A HREF='guide.html'><IMG BORDER=0 WIDTH=19 HEIGHT=19 SRC='../../../../doc/src/images/up.png'></A> 25 <A HREF='code_conversion.html'><IMG BORDER=0 WIDTH=19 HEIGHT=19 SRC='../../../../doc/src/images/next.png'></A> 26</DIV> 27 28<!-- End Nav --> 29 30<A NAME="overview"></A> 31<H2>3.4 Filtering Streams and Stream Buffers</H2> 32 33<HR STYLE="margin-top:1em"> 34 35<P> 36 The class templates <A href="../classes/filtering_streambuf.html"><CODE>filtering_streambuf</CODE></A> and <A href="../classes/filtering_stream.html"><CODE>filtering_stream</CODE></A> are the fundamental components provided by the Iostreams library for filtering data. Each <CODE>filtering_streambuf</CODE> or <CODE>filtering_stream</CODE> contains a chain of zero or more <A HREF="../concepts/filter.html">Filters</A> followed by an optional <A HREF="../concepts/device.html">Device</A>, accessed with an interface similar to that of <CODE>std::stack</CODE>. These chains are represented by of the class template <A HREF="../classes/chain.html"><CODE>chain</CODE></A>. If the chain ends with a Device it is called <SPAN CLASS="term">complete</SPAN> and may be used to perform i/o. 37</P> 38<P> 39 The <A HREF="modes.html">mode</A> of each <CODE>stream_buffer</CODE> in the chain must refine the mode of the <CODE>filtering_streambuf</CODE> or <CODE>filtering_stream</CODE>. For example, one cannot use a Filter or Device having mode <A HREF="modes.html#output">output</A> with a <CODE>filtering_streambuf</CODE> having mode <A HREF="modes.html#input">input</A>. 40</P> 41<P> 42 If a <CODE>filtering_streambuf</CODE> or <CODE>filtering_stream</CODE> has mode <A HREF="modes.html#input">input</A>, data flows from the chain's end to its beginning — starting at a <A href="../concepts/source.html">Source</A> and passing through zero or more <A href="../concepts/input_filter.html">InputFilters</A>. If it has mode <A HREF="modes.html#output">output</A>, data flows in the opposite direction — from the beginning of the chain, through zero or more <A href="../concepts/output_filter.html">OutputFilters</A>, towards <A href="../concepts/source.html">Sink</A> at the end of the chain. If a <CODE>filtering_streambuf</CODE> or <CODE>filtering_stream</CODE> performs both input and output, data flows in both directions. 43 44<!-- Begin Footer --> 45 46<HR STYLE="margin-top:1em"> 47 48<P CLASS="copyright">© Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a><br/>© Copyright 2004-2007 <a href="https://www.boost.org/users/people/jonathan_turkanis.html" target="_top">Jonathan Turkanis</a></P> 49<P CLASS="copyright"> 50 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>) 51</P> 52 53<!-- End Footer --> 54 55</BODY>