put
The function template put
provides a uniform interface for writing a character to a Sink, for use in the definitions of new Filter types (see Example).
The following code illustrates the use of the function put
in the definition of an OutputFilter.
#include <ctype.h> // toupper #include <boost/iostreams/concepts.hpp> // output_filter #include <boost/iostreams/operations.hpp> // put using namespace std; namespace io = boost::iostreams; struct toupper_filter : public io::output_filter { template<typename Sink> bool put(Sink& snk, char c) { return io::put(snk, toupper((unsigned char) c)); } };
<boost/iostreams/operations.hpp>
<boost/iostreams/put.hpp>
Attempts to write a character to a given instance of the template parameter Sink
, returning true
for success.
namespace boost { namespace iostreams { template<typename Sink> void put(Sink& snk, typename char_type_of<Sink>::type c); } } // End namespace boost::io
Sink | - | A indirect model of Sink or a standard output stream or stream buffer type. |
snk | - | An instance of Sink |
template<typename Sink> void put(Sink& snk, typename char_type_of<Sink>::type c);
The semantics of put
depends on the category of Sink
as follows:
category_of<Sink>::type | semantics |
---|---|
convertible to direct_tag |
compile-time error |
convertible to ostream_tag |
invokes snk.put(c) |
convertible to streambuf_tag but not to ostream_tag |
invokes snk.sputc(c) |
otherwise | invokes snk.write(&c, 1) |
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)