os/ossrv/ossrv_pub/boost_apis/boost/iostreams/close.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/iostreams/close.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,145 @@
     1.4 +// (C) Copyright Jonathan Turkanis 2003.
     1.5 +// Distributed under the Boost Software License, Version 1.0. (See accompanying
     1.6 +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
     1.7 +
     1.8 +// See http://www.boost.org/libs/iostreams for documentation.
     1.9 +
    1.10 +#ifndef BOOST_IOSTREAMS_CLOSE_HPP_INCLUDED
    1.11 +#define BOOST_IOSTREAMS_CLOSE_HPP_INCLUDED
    1.12 +
    1.13 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
    1.14 +# pragma once
    1.15 +#endif
    1.16 +
    1.17 +#include <boost/config.hpp>  // DEDUCED_TYPENAME, MSVC.
    1.18 +#include <boost/detail/workaround.hpp>
    1.19 +#include <boost/iostreams/categories.hpp>
    1.20 +#include <boost/iostreams/flush.hpp>
    1.21 +#include <boost/iostreams/detail/adapter/non_blocking_adapter.hpp>
    1.22 +#include <boost/iostreams/detail/wrap_unwrap.hpp>
    1.23 +#include <boost/iostreams/operations_fwd.hpp>
    1.24 +#include <boost/iostreams/traits.hpp>
    1.25 +#include <boost/mpl/identity.hpp>
    1.26 +#include <boost/mpl/if.hpp>
    1.27 +#include <boost/type_traits/is_convertible.hpp>
    1.28 +
    1.29 +// Must come last.
    1.30 +#include <boost/iostreams/detail/config/disable_warnings.hpp>
    1.31 +
    1.32 +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //-----------------------------------//
    1.33 +# include <boost/iostreams/detail/vc6/close.hpp>
    1.34 +#else // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //--------------------------//
    1.35 +
    1.36 +namespace boost { namespace iostreams {
    1.37 +
    1.38 +namespace detail {
    1.39 +
    1.40 +template<typename T>
    1.41 +struct close_impl;
    1.42 +
    1.43 +} // End namespace detail.
    1.44 +
    1.45 +template<typename T>
    1.46 +void close(T& t, BOOST_IOS::openmode which)
    1.47 +{ detail::close_impl<T>::close(detail::unwrap(t), which); }
    1.48 +
    1.49 +template<typename T, typename Sink>
    1.50 +void close(T& t, Sink& snk, BOOST_IOS::openmode which)
    1.51 +{ detail::close_impl<T>::close(detail::unwrap(t), snk, which); }
    1.52 +
    1.53 +namespace detail {
    1.54 +
    1.55 +//------------------Definition of close_impl----------------------------------//
    1.56 +
    1.57 +template<typename T>
    1.58 +struct close_tag {
    1.59 +    typedef typename category_of<T>::type category;
    1.60 +    typedef typename
    1.61 +            mpl::eval_if<
    1.62 +                is_convertible<category, closable_tag>,
    1.63 +                mpl::if_<
    1.64 +                    mpl::or_<
    1.65 +                        is_convertible<category, two_sequence>,
    1.66 +                        is_convertible<category, dual_use>
    1.67 +                    >,
    1.68 +                    two_sequence,
    1.69 +                    closable_tag
    1.70 +                >,
    1.71 +                mpl::identity<any_tag>
    1.72 +            >::type type;
    1.73 +};
    1.74 +
    1.75 +template<typename T>
    1.76 +struct close_impl
    1.77 +    : mpl::if_<
    1.78 +          is_custom<T>,
    1.79 +          operations<T>,
    1.80 +          close_impl<BOOST_DEDUCED_TYPENAME close_tag<T>::type>
    1.81 +      >::type
    1.82 +    { };
    1.83 +
    1.84 +template<>
    1.85 +struct close_impl<any_tag> {
    1.86 +    template<typename T>
    1.87 +    static void close(T& t, BOOST_IOS::openmode which)
    1.88 +    {
    1.89 +        if ((which & BOOST_IOS::out) != 0)
    1.90 +            iostreams::flush(t);
    1.91 +    }
    1.92 +
    1.93 +    template<typename T, typename Sink>
    1.94 +    static void close(T& t, Sink& snk, BOOST_IOS::openmode which)
    1.95 +    {
    1.96 +        if ((which & BOOST_IOS::out) != 0) {
    1.97 +            non_blocking_adapter<Sink> nb(snk);
    1.98 +            iostreams::flush(t, nb);
    1.99 +        }
   1.100 +    }
   1.101 +};
   1.102 +
   1.103 +#include <boost/iostreams/detail/config/disable_warnings.hpp> // Borland.
   1.104 +template<>
   1.105 +struct close_impl<closable_tag> {
   1.106 +    template<typename T>
   1.107 +    static void close(T& t, BOOST_IOS::openmode which)
   1.108 +    {
   1.109 +        typedef typename category_of<T>::type category;
   1.110 +        const bool in =  is_convertible<category, input>::value &&
   1.111 +                        !is_convertible<category, output>::value;
   1.112 +        if (in == ((which & BOOST_IOS::in) != 0))
   1.113 +            t.close();
   1.114 +    }
   1.115 +    template<typename T, typename Sink>
   1.116 +    static void close(T& t, Sink& snk, BOOST_IOS::openmode which)
   1.117 +    {
   1.118 +        typedef typename category_of<T>::type category;
   1.119 +        const bool in =  is_convertible<category, input>::value &&
   1.120 +                        !is_convertible<category, output>::value;
   1.121 +        if (in == ((which & BOOST_IOS::in) != 0)) {
   1.122 +            non_blocking_adapter<Sink> nb(snk);
   1.123 +            t.close(nb);
   1.124 +        }
   1.125 +    }
   1.126 +};
   1.127 +
   1.128 +template<>
   1.129 +struct close_impl<two_sequence> {
   1.130 +    template<typename T>
   1.131 +    static void close(T& t, BOOST_IOS::openmode which) { t.close(which); }
   1.132 +    template<typename T, typename Sink>
   1.133 +    static void close(T& t, Sink& snk, BOOST_IOS::openmode which)
   1.134 +    {
   1.135 +        non_blocking_adapter<Sink> nb(snk);
   1.136 +        t.close(nb, which);
   1.137 +    }
   1.138 +};
   1.139 +
   1.140 +} // End namespace detail.
   1.141 +
   1.142 +} } // End namespaces iostreams, boost.
   1.143 +
   1.144 +#endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //-------------------------//
   1.145 +
   1.146 +#include <boost/iostreams/detail/config/enable_warnings.hpp>
   1.147 +
   1.148 +#endif // #ifndef BOOST_IOSTREAMS_CLOSE_HPP_INCLUDED