filter_adapter.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Defines the class template boost::iostreams::detail::filter_adapter,
  3. * a convenience base class for filter adapters.
  4. *
  5. * File: boost/iostreams/detail/adapter/filter_adapter.hpp
  6. * Date: Mon Nov 26 14:35:48 MST 2007
  7. * Copyright: 2007-2008 CodeRage, LLC
  8. * Author: Jonathan Turkanis
  9. * Contact: turkanis at coderage dot com
  10. *
  11. * Distributed under the Boost Software License, Version 1.0.(See accompanying
  12. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  13. *
  14. * See http://www.boost.org/libs/iostreams for documentation.
  15. */
  16. #ifndef BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
  17. #define BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
  18. #include <boost/iostreams/categories.hpp>
  19. #include <boost/iostreams/detail/call_traits.hpp>
  20. #include <boost/iostreams/detail/ios.hpp>
  21. #include <boost/iostreams/operations.hpp>
  22. #include <boost/iostreams/traits.hpp>
  23. #include <boost/static_assert.hpp>
  24. namespace boost { namespace iostreams { namespace detail {
  25. template<typename T>
  26. class filter_adapter {
  27. private:
  28. typedef typename detail::value_type<T>::type value_type;
  29. typedef typename detail::param_type<T>::type param_type;
  30. public:
  31. explicit filter_adapter(param_type t) : t_(t) { }
  32. T& component() { return t_; }
  33. template<typename Device>
  34. void close(Device& dev)
  35. {
  36. detail::close_all(t_, dev);
  37. }
  38. template<typename Device>
  39. void close(Device& dev, BOOST_IOS::openmode which)
  40. {
  41. iostreams::close(t_, dev, which);
  42. }
  43. template<typename Device>
  44. void flush(Device& dev)
  45. {
  46. return iostreams::flush(t_, dev);
  47. }
  48. template<typename Locale> // Avoid dependency on <locale>
  49. void imbue(const Locale& loc) { iostreams::imbue(t_, loc); }
  50. std::streamsize optimal_buffer_size() const
  51. { return iostreams::optimal_buffer_size(t_); }
  52. public:
  53. value_type t_;
  54. };
  55. //----------------------------------------------------------------------------//
  56. } } } // End namespaces detail, iostreams, boost.
  57. #endif // #ifndef BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED