File indexing completed on 2025-01-18 09:38:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_IOSTREAMS_NULL_HPP_INCLUDED
0011 #define BOOST_IOSTREAMS_NULL_HPP_INCLUDED
0012
0013 #if defined(_MSC_VER)
0014 # pragma once
0015 #endif
0016
0017 #include <boost/iostreams/categories.hpp>
0018 #include <boost/iostreams/detail/ios.hpp> // openmode, streamsize.
0019 #include <boost/iostreams/positioning.hpp>
0020
0021 namespace boost { namespace iostreams {
0022
0023 template<typename Ch, typename Mode>
0024 class basic_null_device {
0025 public:
0026 typedef Ch char_type;
0027 struct category
0028 : public Mode,
0029 public device_tag,
0030 public closable_tag
0031 { };
0032 std::streamsize read(Ch*, std::streamsize) { return -1; }
0033 std::streamsize write(const Ch*, std::streamsize n) { return n; }
0034 std::streampos seek( stream_offset, BOOST_IOS::seekdir,
0035 BOOST_IOS::openmode =
0036 BOOST_IOS::in | BOOST_IOS::out )
0037 { return -1; }
0038 void close() { }
0039 void close(BOOST_IOS::openmode) { }
0040 };
0041
0042 template<typename Ch>
0043 struct basic_null_source : private basic_null_device<Ch, input> {
0044 typedef Ch char_type;
0045 typedef source_tag category;
0046 using basic_null_device<Ch, input>::read;
0047 using basic_null_device<Ch, input>::close;
0048 };
0049
0050 typedef basic_null_source<char> null_source;
0051 typedef basic_null_source<wchar_t> wnull_source;
0052
0053 template<typename Ch>
0054 struct basic_null_sink : private basic_null_device<Ch, output> {
0055 typedef Ch char_type;
0056 typedef sink_tag category;
0057 using basic_null_device<Ch, output>::write;
0058 using basic_null_device<Ch, output>::close;
0059 };
0060
0061 typedef basic_null_sink<char> null_sink;
0062 typedef basic_null_sink<wchar_t> wnull_sink;
0063
0064 } }
0065
0066 #endif