Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / gil / io / read_image_info.hpp
1 //
2 // Copyright 2007-2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
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_READ_IMAGE_INFO_HPP
9 #define BOOST_GIL_IO_READ_IMAGE_INFO_HPP
10
11 #include <boost/gil/io/base.hpp>
12 #include <boost/gil/io/device.hpp>
13 #include <boost/gil/io/get_reader.hpp>
14 #include <boost/gil/io/path_spec.hpp>
15 #include <boost/gil/detail/mp11.hpp>
16
17 #include <type_traits>
18
19 namespace boost{ namespace gil {
20
21 /// \ingroup IO
22
23 /// \brief Returns the image format backend. Backend is format specific.
24 /// \param file      It's a device. Must satisfy is_adaptable_input_device metafunction.
25 /// \param settings  Specifies read settings depending on the image format.
26 /// \return image_read_info object dependent on the image format.
27 /// \throw std::ios_base::failure
28 template <typename Device, typename FormatTag>
29 inline
30 auto read_image_info(Device& file, image_read_settings<FormatTag> const& settings,
31     typename std::enable_if
32     <
33         mp11::mp_and
34         <
35             detail::is_adaptable_input_device<FormatTag, Device>,
36             is_format_tag<FormatTag>
37         >::value
38     >::type* /*dummy*/ = nullptr)
39     -> typename get_reader_backend<Device, FormatTag>::type
40 {
41     return make_reader_backend(file, settings);
42 }
43
44 /// \brief Returns the image format backend. Backend is format specific.
45 /// \param file It's a device. Must satisfy is_adaptable_input_device metafunction.
46 /// \param tag  Defines the image format. Must satisfy is_format_tag metafunction.
47 /// \return image_read_info object dependent on the image format.
48 /// \throw std::ios_base::failure
49 template <typename Device, typename FormatTag>
50 inline
51 auto read_image_info(Device& file, FormatTag const&,
52     typename std::enable_if
53     <
54         mp11::mp_and
55         <
56             detail::is_adaptable_input_device<FormatTag, Device>,
57             is_format_tag<FormatTag>
58         >::value
59     >::type* /*dummy*/ = nullptr)
60     -> typename get_reader_backend<Device, FormatTag>::type
61 {
62     return read_image_info(file, image_read_settings<FormatTag>());
63 }
64
65 /// \brief Returns the image format backend. Backend is format specific.
66 /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
67 /// \param settings  Specifies read settings depending on the image format.
68 /// \return image_read_info object dependent on the image format.
69 /// \throw std::ios_base::failure
70 template <typename String, typename FormatTag>
71 inline
72 auto read_image_info(
73     String const& file_name, image_read_settings<FormatTag> const& settings,
74     typename std::enable_if
75     <
76         mp11::mp_and
77         <
78             is_format_tag<FormatTag>,
79             detail::is_supported_path_spec<String>
80         >::value
81     >::type* /*dummy*/ = nullptr)
82     -> typename get_reader_backend<String, FormatTag>::type
83 {
84     return make_reader_backend(file_name, settings);
85 }
86
87 /// \brief Returns the image format backend. Backend is format specific.
88 /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
89 /// \param tag       Defines the image format. Must satisfy is_format_tag metafunction.
90 /// \return image_read_info object dependent on the image format.
91 /// \throw std::ios_base::failure
92 template <typename String, typename FormatTag>
93 inline
94 auto read_image_info(String const& file_name, FormatTag const&,
95     typename std::enable_if
96     <
97         mp11::mp_and
98         <
99             is_format_tag<FormatTag>,
100             detail::is_supported_path_spec<String>
101         >::value
102     >::type* /*dummy*/ = nullptr)
103     -> typename get_reader_backend<String, FormatTag>::type
104 {
105     return read_image_info(file_name, image_read_settings<FormatTag>());
106 }
107
108 }} // namespace boost::gil
109
110 #endif