source: NonGTP/Boost/boost/iostreams/optimal_buffer_size.hpp @ 857

Revision 857, 2.4 KB checked in by igarcia, 19 years ago (diff)
Line 
1// (C) Copyright Jonathan Turkanis 2003.
2// Distributed under the Boost Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
4
5// See http://www.boost.org/libs/iostreams for documentation.
6
7#ifndef BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED
8#define BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED
9
10#if defined(_MSC_VER) && (_MSC_VER >= 1020)
11# pragma once
12#endif
13
14#include <boost/config.hpp>  // DEDUCED_TYPENAME, MSVC.
15#include <boost/detail/workaround.hpp>
16#include <boost/iostreams/constants.hpp>  // constants.
17#include <boost/iostreams/detail/dispatch.hpp>
18#include <boost/iostreams/detail/wrap_unwrap.hpp>
19#include <boost/iostreams/operations_fwd.hpp>
20#include <boost/mpl/if.hpp>
21
22// Must come last.
23#include <boost/iostreams/detail/config/disable_warnings.hpp>
24
25namespace boost { namespace iostreams {
26
27namespace detail {
28
29template<typename T>
30struct optimal_buffer_size_impl;
31
32} // End namespace detail.
33
34template<typename T>
35std::streamsize optimal_buffer_size(const T& t)
36{
37    typedef detail::optimal_buffer_size_impl<T> impl;
38    return impl::optimal_buffer_size(detail::unwrap(t));
39}
40
41namespace detail {
42
43//------------------Definition of optimal_buffer_size_impl--------------------//
44
45template<typename T>
46struct optimal_buffer_size_impl
47    : mpl::if_<
48          is_custom<T>,
49          operations<T>,
50          optimal_buffer_size_impl<
51              BOOST_DEDUCED_TYPENAME
52              dispatch<
53                  T, optimally_buffered_tag, device_tag, filter_tag
54              >::type
55          >
56      >::type
57    { };
58
59template<>
60struct optimal_buffer_size_impl<optimally_buffered_tag> {
61    template<typename T>
62    static std::streamsize optimal_buffer_size(const T& t)
63    { return t.optimal_buffer_size(); }
64};
65
66template<>
67struct optimal_buffer_size_impl<device_tag> {
68    template<typename T>
69    static std::streamsize optimal_buffer_size(const T&)
70    { return default_device_buffer_size; }
71};
72
73template<>
74struct optimal_buffer_size_impl<filter_tag> {
75    template<typename T>
76    static std::streamsize optimal_buffer_size(const T&)
77    { return default_filter_buffer_size; }
78};
79
80} // End namespace detail.
81
82} } // End namespaces iostreams, boost.
83
84#include <boost/iostreams/detail/config/enable_warnings.hpp>
85
86#endif // #ifndef BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.