annotate DEPENDENCIES/generic/include/boost/iostreams/flush.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
Chris@16 2 // (C) Copyright 2003-2007 Jonathan Turkanis
Chris@16 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
Chris@16 5
Chris@16 6 // See http://www.boost.org/libs/iostreams for documentation.
Chris@16 7
Chris@16 8 #ifndef BOOST_IOSTREAMS_FLUSH_HPP_INCLUDED
Chris@16 9 #define BOOST_IOSTREAMS_FLUSH_HPP_INCLUDED
Chris@16 10
Chris@16 11 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
Chris@16 12 # pragma once
Chris@16 13 #endif
Chris@16 14
Chris@16 15 #include <boost/config.hpp> // DEDUCED_TYPENAME, MSVC.
Chris@16 16 #include <boost/detail/workaround.hpp>
Chris@16 17 #include <boost/iostreams/detail/dispatch.hpp>
Chris@16 18 #include <boost/iostreams/detail/streambuf.hpp>
Chris@16 19 #include <boost/iostreams/detail/wrap_unwrap.hpp>
Chris@16 20 #include <boost/iostreams/operations_fwd.hpp>
Chris@16 21 #include <boost/iostreams/traits.hpp>
Chris@16 22 #include <boost/mpl/if.hpp>
Chris@16 23
Chris@16 24 // Must come last.
Chris@16 25 #include <boost/iostreams/detail/config/disable_warnings.hpp>
Chris@16 26
Chris@16 27 namespace boost { namespace iostreams {
Chris@16 28
Chris@16 29 namespace detail {
Chris@16 30
Chris@16 31 template<typename T>
Chris@16 32 struct flush_device_impl;
Chris@16 33
Chris@16 34 template<typename T>
Chris@16 35 struct flush_filter_impl;
Chris@16 36
Chris@16 37 } // End namespace detail.
Chris@16 38
Chris@16 39 template<typename T>
Chris@16 40 bool flush(T& t)
Chris@16 41 { return detail::flush_device_impl<T>::flush(detail::unwrap(t)); }
Chris@16 42
Chris@16 43 template<typename T, typename Sink>
Chris@16 44 bool flush(T& t, Sink& snk)
Chris@16 45 { return detail::flush_filter_impl<T>::flush(detail::unwrap(t), snk); }
Chris@16 46
Chris@16 47 namespace detail {
Chris@16 48
Chris@16 49 //------------------Definition of flush_device_impl---------------------------//
Chris@16 50
Chris@16 51 template<typename T>
Chris@16 52 struct flush_device_impl
Chris@16 53 : mpl::if_<
Chris@16 54 is_custom<T>,
Chris@16 55 operations<T>,
Chris@16 56 flush_device_impl<
Chris@16 57 BOOST_DEDUCED_TYPENAME
Chris@16 58 dispatch<
Chris@16 59 T, ostream_tag, streambuf_tag, flushable_tag, any_tag
Chris@16 60 >::type
Chris@16 61 >
Chris@16 62 >::type
Chris@16 63 { };
Chris@16 64
Chris@16 65 template<>
Chris@16 66 struct flush_device_impl<ostream_tag> {
Chris@16 67 template<typename T>
Chris@16 68 static bool flush(T& t)
Chris@16 69 { return t.rdbuf()->BOOST_IOSTREAMS_PUBSYNC() == 0; }
Chris@16 70 };
Chris@16 71
Chris@16 72 template<>
Chris@16 73 struct flush_device_impl<streambuf_tag> {
Chris@16 74 template<typename T>
Chris@16 75 static bool flush(T& t)
Chris@16 76 { return t.BOOST_IOSTREAMS_PUBSYNC() == 0; }
Chris@16 77 };
Chris@16 78
Chris@16 79 template<>
Chris@16 80 struct flush_device_impl<flushable_tag> {
Chris@16 81 template<typename T>
Chris@16 82 static bool flush(T& t) { return t.flush(); }
Chris@16 83 };
Chris@16 84
Chris@16 85 template<>
Chris@16 86 struct flush_device_impl<any_tag> {
Chris@16 87 template<typename T>
Chris@16 88 static bool flush(T&) { return true; }
Chris@16 89 };
Chris@16 90
Chris@16 91 //------------------Definition of flush_filter_impl---------------------------//
Chris@16 92
Chris@16 93 template<typename T>
Chris@16 94 struct flush_filter_impl
Chris@16 95 : mpl::if_<
Chris@16 96 is_custom<T>,
Chris@16 97 operations<T>,
Chris@16 98 flush_filter_impl<
Chris@16 99 BOOST_DEDUCED_TYPENAME
Chris@16 100 dispatch<
Chris@16 101 T, flushable_tag, any_tag
Chris@16 102 >::type
Chris@16 103 >
Chris@16 104 >::type
Chris@16 105 { };
Chris@16 106
Chris@16 107 template<>
Chris@16 108 struct flush_filter_impl<flushable_tag> {
Chris@16 109 template<typename T, typename Sink>
Chris@16 110 static bool flush(T& t, Sink& snk) { return t.flush(snk); }
Chris@16 111 };
Chris@16 112
Chris@16 113 template<>
Chris@16 114 struct flush_filter_impl<any_tag> {
Chris@16 115 template<typename T, typename Sink>
Chris@16 116 static bool flush(T&, Sink&) { return false; }
Chris@16 117 };
Chris@16 118
Chris@16 119 } // End namespace detail.
Chris@16 120
Chris@16 121 } } // End namespaces iostreams, boost.
Chris@16 122
Chris@16 123 #include <boost/iostreams/detail/config/enable_warnings.hpp>
Chris@16 124
Chris@16 125 #endif // #ifndef BOOST_IOSTREAMS_FLUSH_HPP_INCLUDED