Back to Arangodb

User's Guide

3rdParty/boost/1.78.0/libs/iostreams/doc/guide/pipelines.html

3.12.9.12.9 KB
Original Source

User's Guide

3.8 Pipelines

OverviewExamplesHeadersReference


Overview

A pipeline is an expression of the form

filter1| ... | filtern| filter-or-device

consiting of one or more filters and an optional device, joined using operator|. Pipelines are a convenient way to pass chains of Filters and Devices to the constructor or push function of a filtering_stream or filtering_streambuf.

In order for instances of a model of Filter to appear in a pipeline, it must be declared Pipable using the macro BOOST_IOSTREAMS_PIPABLE.

Pipelines for C++ filtering were introduced by Jan Christiaan van Winkel and John van Krieken. See [van Winkel].

Examples

The following example defines a Pipable InputFilter.

#include[\<boost/iostreams/concepts.hpp\>](../../../../boost/iostreams/concepts.hpp)#include[\<boost/iostreams/pipeline.hpp\>](../../../../boost/iostreams/pipeline.hpp)namespaceio = boost::iostreams;classmy_filter :publicio::input_filter {public:...template<typenameSource>intget(Source& src)
    { ...}
};
BOOST_IOSTREAMS_PIPABLE(my_filter, 0)

No semicolon is required (or allowed) following the macro invocation. The following example shows a filtering_stream constructed from a pipeline.

#include[\<boost/iostreams/filtering\_stream.hpp\>](../../../../boost/iostreams/filtering_stream.hpp)#include[\<boost/iostreams/device/file.hpp\>](../../../../boost/iostreams/device/file.hpp)#include[\<boost/iostreams/filter/counter.hpp\>](../../../../boost/iostreams/filter/counter.hpp)namespaceio = boost::iostreams;intmain()
{// Write to the file "hello," counting// the number of lines and charactersio::filtering_ostream out(io::counter() | io::file("hello"));...}

Headers

<boost/iostreams/pipeline.hpp>

Reference

#defineBOOST_IOSTREAMS_PIPABLE(filter, arity)...

Description

Defines the overloads of operator| necessary for a Filter to appear in pipelines.

Macro parameters

| | | | filter | - | The name of the Filter to be declared Pipable | | arity | - | The Filter's template arity, i.e., the number or its template parameters; a value of 0 indicates that it is not a class template |


© Copyright 2008 CodeRage, LLC
© Copyright 2004-2007 Jonathan Turkanis

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)