get_read_device.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // Copyright 2012 Christian Henning
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #ifndef BOOST_GIL_IO_GET_READ_DEVICE_HPP
  9. #define BOOST_GIL_IO_GET_READ_DEVICE_HPP
  10. #include <boost/gil/detail/mp11.hpp>
  11. #include <boost/gil/io/device.hpp>
  12. #include <boost/gil/io/path_spec.hpp>
  13. #include <type_traits>
  14. namespace boost { namespace gil {
  15. template< typename T
  16. , typename FormatTag
  17. , class Enable = void
  18. >
  19. struct get_read_device
  20. {};
  21. template <typename Device, typename FormatTag>
  22. struct get_read_device
  23. <
  24. Device,
  25. FormatTag,
  26. typename std::enable_if
  27. <
  28. mp11::mp_and
  29. <
  30. detail::is_adaptable_input_device<FormatTag, Device>,
  31. is_format_tag<FormatTag>
  32. >::value
  33. >::type
  34. >
  35. {
  36. using type = typename detail::is_adaptable_input_device
  37. <
  38. FormatTag,
  39. Device
  40. >::device_type;
  41. };
  42. template <typename String, typename FormatTag>
  43. struct get_read_device
  44. <
  45. String,
  46. FormatTag,
  47. typename std::enable_if
  48. <
  49. mp11::mp_and
  50. <
  51. detail::is_supported_path_spec<String>,
  52. is_format_tag<FormatTag>
  53. >::value
  54. >::type
  55. >
  56. {
  57. using type = detail::file_stream_device<FormatTag>;
  58. };
  59. } // namespace gil
  60. } // namespace boost
  61. #endif