9 #ifndef BOOST_GIL_IO_MAKE_BACKEND_HPP 10 #define BOOST_GIL_IO_MAKE_BACKEND_HPP 12 #include <boost/gil/detail/mp11.hpp> 13 #include <boost/gil/io/get_reader.hpp> 15 #include <type_traits> 17 namespace boost {
namespace gil {
19 template <
typename String,
typename FormatTag>
21 auto make_reader_backend(
22 String
const& file_name, image_read_settings<FormatTag>
const& settings,
23 typename std::enable_if
27 detail::is_supported_path_spec<String>,
28 is_format_tag<FormatTag>
31 ->
typename get_reader_backend<String, FormatTag>::type
33 using device_t =
typename get_read_device<String, FormatTag>::type;
36 detail::convert_to_native_string(file_name),
37 typename detail::file_stream_device<FormatTag>::read_tag());
39 return reader_backend<device_t, FormatTag>(device, settings);
42 template <
typename FormatTag>
44 auto make_reader_backend(
45 std::wstring
const& file_name, image_read_settings<FormatTag>
const& settings)
46 ->
typename get_reader_backend<std::wstring, FormatTag>::type
48 char const* str = detail::convert_to_native_string(file_name);
50 using device_t =
typename get_read_device<std::wstring, FormatTag>::type;
51 device_t device(str,
typename detail::file_stream_device<FormatTag>::read_tag());
55 return reader_backend<device_t, FormatTag>(device, settings);
58 #ifdef BOOST_GIL_IO_ADD_FS_PATH_SUPPORT 59 template <
typename FormatTag>
61 auto make_reader_backend(
62 filesystem::path
const& path,
63 image_read_settings<FormatTag>
const& settings)
64 ->
typename get_reader_backend<std::wstring, FormatTag>::type
66 return make_reader_backend(path.wstring(), settings);
68 #endif // BOOST_GIL_IO_ADD_FS_PATH_SUPPORT 70 template <
typename Device,
typename FormatTag>
72 auto make_reader_backend(Device& io_dev, image_read_settings<FormatTag>
const& settings,
73 typename std::enable_if
77 detail::is_adaptable_input_device<FormatTag, Device>,
78 is_format_tag<FormatTag>
81 ->
typename get_reader_backend<Device, FormatTag>::type
83 using device_t =
typename get_read_device<Device, FormatTag>::type;
84 device_t device(io_dev);
86 return reader_backend<device_t, FormatTag>(device, settings);
89 template <
typename String,
typename FormatTag>
91 auto make_reader_backend(String
const& file_name, FormatTag
const&,
92 typename std::enable_if
96 detail::is_supported_path_spec<String>,
97 is_format_tag<FormatTag>
100 ->
typename get_reader_backend<String, FormatTag>::type
102 return make_reader_backend(file_name, image_read_settings<FormatTag>());
105 template <
typename Device,
typename FormatTag>
107 auto make_reader_backend(Device& io_dev, FormatTag
const&,
108 typename std::enable_if
112 detail::is_adaptable_input_device<FormatTag, Device>,
113 is_format_tag<FormatTag>
116 ->
typename get_reader_backend<Device, FormatTag>::type
118 return make_reader_backend(io_dev, image_read_settings<FormatTag>());