annotate DEPENDENCIES/generic/include/boost/iostreams/detail/functional.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*
Chris@16 2 * Distributed under the Boost Software License, Version 1.0.(See accompanying
Chris@16 3 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
Chris@16 4 *
Chris@16 5 * See http://www.boost.org/libs/iostreams for documentation.
Chris@16 6
Chris@16 7 * File: boost/iostreams/detail/functional.hpp
Chris@16 8 * Date: Sun Dec 09 05:38:03 MST 2007
Chris@16 9 * Copyright: 2007-2008 CodeRage, LLC
Chris@16 10 * Author: Jonathan Turkanis
Chris@16 11 * Contact: turkanis at coderage dot com
Chris@16 12
Chris@16 13 * Defines several function objects and object generators for use with
Chris@16 14 * execute_all()
Chris@16 15 */
Chris@16 16
Chris@16 17 #ifndef BOOST_IOSTREAMS_DETAIL_FUNCTIONAL_HPP_INCLUDED
Chris@16 18 #define BOOST_IOSTREAMS_DETAIL_FUNCTIONAL_HPP_INCLUDED
Chris@16 19
Chris@16 20 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
Chris@16 21 # pragma once
Chris@16 22 #endif
Chris@16 23
Chris@16 24 #include <boost/iostreams/close.hpp>
Chris@16 25 #include <boost/iostreams/detail/ios.hpp> // BOOST_IOS
Chris@16 26
Chris@16 27 namespace boost { namespace iostreams { namespace detail {
Chris@16 28
Chris@16 29 // Function objects and object generators for invoking
Chris@16 30 // boost::iostreams::close
Chris@16 31
Chris@16 32 template<typename T>
Chris@16 33 class device_close_operation {
Chris@16 34 public:
Chris@16 35 typedef void result_type;
Chris@16 36 device_close_operation(T& t, BOOST_IOS::openmode which)
Chris@16 37 : t_(t), which_(which)
Chris@16 38 { }
Chris@16 39 void operator()() const { boost::iostreams::close(t_, which_); }
Chris@16 40 private:
Chris@16 41 device_close_operation& operator=(const device_close_operation&);
Chris@16 42 T& t_;
Chris@16 43 BOOST_IOS::openmode which_;
Chris@16 44 };
Chris@16 45
Chris@16 46 template<typename T, typename Sink>
Chris@16 47 class filter_close_operation {
Chris@16 48 public:
Chris@16 49 typedef void result_type;
Chris@16 50 filter_close_operation(T& t, Sink& snk, BOOST_IOS::openmode which)
Chris@16 51 : t_(t), snk_(snk), which_(which)
Chris@16 52 { }
Chris@16 53 void operator()() const { boost::iostreams::close(t_, snk_, which_); }
Chris@16 54 private:
Chris@16 55 filter_close_operation& operator=(const filter_close_operation&);
Chris@16 56 T& t_;
Chris@16 57 Sink& snk_;
Chris@16 58 BOOST_IOS::openmode which_;
Chris@16 59 };
Chris@16 60
Chris@16 61 template<typename T>
Chris@16 62 device_close_operation<T>
Chris@16 63 call_close(T& t, BOOST_IOS::openmode which)
Chris@16 64 { return device_close_operation<T>(t, which); }
Chris@16 65
Chris@16 66 template<typename T, typename Sink>
Chris@16 67 filter_close_operation<T, Sink>
Chris@16 68 call_close(T& t, Sink& snk, BOOST_IOS::openmode which)
Chris@16 69 { return filter_close_operation<T, Sink>(t, snk, which); }
Chris@16 70
Chris@16 71 // Function objects and object generators for invoking
Chris@16 72 // boost::iostreams::detail::close_all
Chris@16 73
Chris@16 74 template<typename T>
Chris@16 75 class device_close_all_operation {
Chris@16 76 public:
Chris@16 77 typedef void result_type;
Chris@16 78 device_close_all_operation(T& t) : t_(t) { }
Chris@16 79 void operator()() const { detail::close_all(t_); }
Chris@16 80 private:
Chris@16 81 device_close_all_operation& operator=(const device_close_all_operation&);
Chris@16 82 T& t_;
Chris@16 83 };
Chris@16 84
Chris@16 85 template<typename T, typename Sink>
Chris@16 86 class filter_close_all_operation {
Chris@16 87 public:
Chris@16 88 typedef void result_type;
Chris@16 89 filter_close_all_operation(T& t, Sink& snk) : t_(t), snk_(snk) { }
Chris@16 90 void operator()() const { detail::close_all(t_, snk_); }
Chris@16 91 private:
Chris@16 92 filter_close_all_operation& operator=(const filter_close_all_operation&);
Chris@16 93 T& t_;
Chris@16 94 Sink& snk_;
Chris@16 95 };
Chris@16 96
Chris@16 97 template<typename T>
Chris@16 98 device_close_all_operation<T> call_close_all(T& t)
Chris@16 99 { return device_close_all_operation<T>(t); }
Chris@16 100
Chris@16 101 template<typename T, typename Sink>
Chris@16 102 filter_close_all_operation<T, Sink>
Chris@16 103 call_close_all(T& t, Sink& snk)
Chris@16 104 { return filter_close_all_operation<T, Sink>(t, snk); }
Chris@16 105
Chris@16 106 // Function object and object generator for invoking a
Chris@16 107 // member function void close(std::ios_base::openmode)
Chris@16 108
Chris@16 109 template<typename T>
Chris@16 110 class member_close_operation {
Chris@16 111 public:
Chris@16 112 typedef void result_type;
Chris@16 113 member_close_operation(T& t, BOOST_IOS::openmode which)
Chris@16 114 : t_(t), which_(which)
Chris@16 115 { }
Chris@16 116 void operator()() const { t_.close(which_); }
Chris@16 117 private:
Chris@16 118 member_close_operation& operator=(const member_close_operation&);
Chris@16 119 T& t_;
Chris@16 120 BOOST_IOS::openmode which_;
Chris@16 121 };
Chris@16 122
Chris@16 123 template<typename T>
Chris@16 124 member_close_operation<T> call_member_close(T& t, BOOST_IOS::openmode which)
Chris@16 125 { return member_close_operation<T>(t, which); }
Chris@16 126
Chris@16 127 // Function object and object generator for invoking a
Chris@16 128 // member function void reset()
Chris@16 129
Chris@16 130 template<typename T>
Chris@16 131 class reset_operation {
Chris@16 132 public:
Chris@16 133 reset_operation(T& t) : t_(t) { }
Chris@16 134 void operator()() const { t_.reset(); }
Chris@16 135 private:
Chris@16 136 reset_operation& operator=(const reset_operation&);
Chris@16 137 T& t_;
Chris@16 138 };
Chris@16 139
Chris@16 140 template<typename T>
Chris@16 141 reset_operation<T> call_reset(T& t) { return reset_operation<T>(t); }
Chris@16 142
Chris@16 143 // Function object and object generator for clearing a flag
Chris@16 144
Chris@16 145 template<typename T>
Chris@16 146 class clear_flags_operation {
Chris@16 147 public:
Chris@16 148 typedef void result_type;
Chris@16 149 clear_flags_operation(T& t) : t_(t) { }
Chris@16 150 void operator()() const { t_ = 0; }
Chris@16 151 private:
Chris@16 152 clear_flags_operation& operator=(const clear_flags_operation&);
Chris@16 153 T& t_;
Chris@16 154 };
Chris@16 155
Chris@16 156 template<typename T>
Chris@16 157 clear_flags_operation<T> clear_flags(T& t)
Chris@16 158 { return clear_flags_operation<T>(t); }
Chris@16 159
Chris@16 160 // Function object and generator for flushing a buffer
Chris@16 161
Chris@16 162 // Function object for use with execute_all()
Chris@16 163 template<typename Buffer, typename Device>
Chris@16 164 class flush_buffer_operation {
Chris@16 165 public:
Chris@16 166 typedef void result_type;
Chris@16 167 flush_buffer_operation(Buffer& buf, Device& dev, bool flush)
Chris@16 168 : buf_(buf), dev_(dev), flush_(flush)
Chris@16 169 { }
Chris@16 170 void operator()() const
Chris@16 171 {
Chris@16 172 if (flush_)
Chris@16 173 buf_.flush(dev_);
Chris@16 174 }
Chris@16 175 private:
Chris@16 176 flush_buffer_operation& operator=(const flush_buffer_operation&);
Chris@16 177 Buffer& buf_;
Chris@16 178 Device& dev_;
Chris@16 179 bool flush_;
Chris@16 180 };
Chris@16 181
Chris@16 182 template<typename Buffer, typename Device>
Chris@16 183 flush_buffer_operation<Buffer, Device>
Chris@16 184 flush_buffer(Buffer& buf, Device& dev, bool flush)
Chris@16 185 { return flush_buffer_operation<Buffer, Device>(buf, dev, flush); }
Chris@16 186
Chris@16 187 } } } // End namespaces detail, iostreams, boost.
Chris@16 188
Chris@16 189 #endif // #ifndef BOOST_IOSTREAMS_DETAIL_FUNCTIONAL_HPP_INCLUDED