`invert`

- Description
- Headers
- Reference

The class template `inverse`

is an adapter which transforms an InputFilter into an OutputFilter or *vice versa*. The function template `invert`

is an object generator which when passed a Filter returns a instance of an appropriate specialization of `inverse`

.

Given an InputFilter `f`

, the inverse of `f`

is Multi-Character OutputFilter whose member function `write`

is implemented as follows. Given a Sink `snk`

and a character buffer `s`

of length `n`

, we

- construct a Source based on the buffer
`s`

and`compose`

it with`f`

to form a Source, then - repeatedly read sequences of characters from the composite Source and write them to
`snk`

until the buffer`s`

is exhausted.

Similarly, given an OutputFilter `f`

, the inverse of `f`

is Multi-Character InputFilter whose member function `read`

is implemented as follows. Given a Source `src`

and a character buffer `s`

of length `n`

, we

- construct a Sink based on the buffer
`s`

and`compose`

it with`f`

to form a Sink, then - repeatedly read sequences of characters from
`src`

and write them to the composite Sink until the buffer`s`

is full.

The mode of a specialization of `inverse`

is equal to output if the mode of the underlying filter refines input, and to input otherwise.

`<boost/iostreams/invert.hpp>`

namespace boost { namespace iostreams { template<typename Filter> class inverse { public: typedef typename char_type_of<Filter>::type char_type; typedef see above mode; inverse(const Filter& filter); // Filter member functions }; template<typename Filter> inverse<Filter> invert(const Filter& filter); } } // End namespace boost::io

`inverse`

Filter | - | A model of Filter |

`inverse::inverse`

` inverse(const Filter& filter);`

Constructs an instance of `inverse`

based on the given filter.

`invert`

template<typename Filter> inverse<Filter> invert(const Filter& filter);

Filter | - | A model of Filter |

Constructs an instance of an appropriate specialization of `inverse`

based on the given filter.

Revised 02 Feb 2008

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