File indexing completed on 2025-01-18 09:38:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef BOOST_IOSTREAMS_DETAIL_FUNCTIONAL_HPP_INCLUDED
0018 #define BOOST_IOSTREAMS_DETAIL_FUNCTIONAL_HPP_INCLUDED
0019
0020 #if defined(_MSC_VER)
0021 # pragma once
0022 #endif
0023
0024 #include <boost/iostreams/close.hpp>
0025 #include <boost/iostreams/detail/ios.hpp> // BOOST_IOS
0026
0027 namespace boost { namespace iostreams { namespace detail {
0028
0029
0030
0031
0032 template<typename T>
0033 class device_close_operation {
0034 public:
0035 typedef void result_type;
0036 device_close_operation(T& t, BOOST_IOS::openmode which)
0037 : t_(t), which_(which)
0038 { }
0039 void operator()() const { boost::iostreams::close(t_, which_); }
0040 private:
0041 BOOST_DELETED_FUNCTION(device_close_operation& operator=(const device_close_operation&))
0042 T& t_;
0043 BOOST_IOS::openmode which_;
0044 };
0045
0046 template<typename T, typename Sink>
0047 class filter_close_operation {
0048 public:
0049 typedef void result_type;
0050 filter_close_operation(T& t, Sink& snk, BOOST_IOS::openmode which)
0051 : t_(t), snk_(snk), which_(which)
0052 { }
0053 void operator()() const { boost::iostreams::close(t_, snk_, which_); }
0054 private:
0055 BOOST_DELETED_FUNCTION(filter_close_operation& operator=(const filter_close_operation&))
0056 T& t_;
0057 Sink& snk_;
0058 BOOST_IOS::openmode which_;
0059 };
0060
0061 template<typename T>
0062 device_close_operation<T>
0063 call_close(T& t, BOOST_IOS::openmode which)
0064 { return device_close_operation<T>(t, which); }
0065
0066 template<typename T, typename Sink>
0067 filter_close_operation<T, Sink>
0068 call_close(T& t, Sink& snk, BOOST_IOS::openmode which)
0069 { return filter_close_operation<T, Sink>(t, snk, which); }
0070
0071
0072
0073
0074 template<typename T>
0075 class device_close_all_operation {
0076 public:
0077 typedef void result_type;
0078 device_close_all_operation(T& t) : t_(t) { }
0079 void operator()() const { detail::close_all(t_); }
0080 private:
0081 BOOST_DELETED_FUNCTION(device_close_all_operation& operator=(const device_close_all_operation&))
0082 T& t_;
0083 };
0084
0085 template<typename T, typename Sink>
0086 class filter_close_all_operation {
0087 public:
0088 typedef void result_type;
0089 filter_close_all_operation(T& t, Sink& snk) : t_(t), snk_(snk) { }
0090 void operator()() const { detail::close_all(t_, snk_); }
0091 private:
0092 BOOST_DELETED_FUNCTION(filter_close_all_operation& operator=(const filter_close_all_operation&))
0093 T& t_;
0094 Sink& snk_;
0095 };
0096
0097 template<typename T>
0098 device_close_all_operation<T> call_close_all(T& t)
0099 { return device_close_all_operation<T>(t); }
0100
0101 template<typename T, typename Sink>
0102 filter_close_all_operation<T, Sink>
0103 call_close_all(T& t, Sink& snk)
0104 { return filter_close_all_operation<T, Sink>(t, snk); }
0105
0106
0107
0108
0109 template<typename T>
0110 class member_close_operation {
0111 public:
0112 typedef void result_type;
0113 member_close_operation(T& t, BOOST_IOS::openmode which)
0114 : t_(t), which_(which)
0115 { }
0116 void operator()() const { t_.close(which_); }
0117 private:
0118 BOOST_DELETED_FUNCTION(member_close_operation& operator=(const member_close_operation&))
0119 T& t_;
0120 BOOST_IOS::openmode which_;
0121 };
0122
0123 template<typename T>
0124 member_close_operation<T> call_member_close(T& t, BOOST_IOS::openmode which)
0125 { return member_close_operation<T>(t, which); }
0126
0127
0128
0129
0130 template<typename T>
0131 class reset_operation {
0132 public:
0133 reset_operation(T& t) : t_(t) { }
0134 void operator()() const { t_.reset(); }
0135 private:
0136 BOOST_DELETED_FUNCTION(reset_operation& operator=(const reset_operation&))
0137 T& t_;
0138 };
0139
0140 template<typename T>
0141 reset_operation<T> call_reset(T& t) { return reset_operation<T>(t); }
0142
0143
0144
0145 template<typename T>
0146 class clear_flags_operation {
0147 public:
0148 typedef void result_type;
0149 clear_flags_operation(T& t) : t_(t) { }
0150 void operator()() const { t_ = 0; }
0151 private:
0152 BOOST_DELETED_FUNCTION(clear_flags_operation& operator=(const clear_flags_operation&))
0153 T& t_;
0154 };
0155
0156 template<typename T>
0157 clear_flags_operation<T> clear_flags(T& t)
0158 { return clear_flags_operation<T>(t); }
0159
0160
0161
0162
0163 template<typename Buffer, typename Device>
0164 class flush_buffer_operation {
0165 public:
0166 typedef void result_type;
0167 flush_buffer_operation(Buffer& buf, Device& dev, bool flush)
0168 : buf_(buf), dev_(dev), flush_(flush)
0169 { }
0170 void operator()() const
0171 {
0172 if (flush_)
0173 buf_.flush(dev_);
0174 }
0175 private:
0176 BOOST_DELETED_FUNCTION(flush_buffer_operation& operator=(const flush_buffer_operation&))
0177 Buffer& buf_;
0178 Device& dev_;
0179 bool flush_;
0180 };
0181
0182 template<typename Buffer, typename Device>
0183 flush_buffer_operation<Buffer, Device>
0184 flush_buffer(Buffer& buf, Device& dev, bool flush)
0185 { return flush_buffer_operation<Buffer, Device>(buf, dev, flush); }
0186
0187 } } }
0188
0189 #endif