Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:03

0001 //
0002 // Copyright 2012 Christian Henning
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 #ifndef BOOST_GIL_IO_MAKE_SCANLINE_READER_HPP
0009 #define BOOST_GIL_IO_MAKE_SCANLINE_READER_HPP
0010 
0011 #include <boost/gil/detail/mp11.hpp>
0012 #include <boost/gil/io/get_reader.hpp>
0013 
0014 #include <type_traits>
0015 
0016 namespace boost { namespace gil {
0017 
0018 template <typename String, typename FormatTag>
0019 inline
0020 auto make_scanline_reader(String const& file_name, FormatTag const&,
0021     typename std::enable_if
0022     <
0023         mp11::mp_and
0024         <
0025             detail::is_supported_path_spec<String>,
0026             is_format_tag<FormatTag>
0027         >::value
0028     >::type* /*dummy*/ = nullptr)
0029     -> typename get_scanline_reader<String, FormatTag>::type
0030 {
0031     using device_t = typename get_read_device<String, FormatTag>::type;
0032     device_t device(
0033         detail::convert_to_native_string(file_name),
0034         typename detail::file_stream_device<FormatTag>::read_tag());
0035 
0036     return typename get_scanline_reader<String, FormatTag>::type(
0037         device, image_read_settings<FormatTag>());
0038 }
0039 
0040 template <typename FormatTag>
0041 inline
0042 auto make_scanline_reader(std::wstring const& file_name, FormatTag const&)
0043     -> typename get_scanline_reader<std::wstring, FormatTag>::type
0044 {
0045     const char* str = detail::convert_to_native_string( file_name );
0046 
0047     typename get_read_device< std::wstring
0048                             , FormatTag
0049                             >::type device( str
0050                                           , typename detail::file_stream_device< FormatTag >::read_tag()
0051                                           );
0052 
0053     delete[] str;
0054 
0055     return typename get_scanline_reader< std::wstring
0056                                        , FormatTag
0057                                        >::type( device
0058                                               , image_read_settings< FormatTag >()
0059                                               );
0060 }
0061 
0062 template <typename FormatTag>
0063 inline
0064 auto make_scanline_reader(detail::filesystem::path const& path, FormatTag const&)
0065     -> typename get_scanline_reader<std::wstring, FormatTag>::type
0066 {
0067     return make_scanline_reader(path.wstring(), image_read_settings<FormatTag>());
0068 }
0069 
0070 template <typename Device, typename FormatTag>
0071 inline
0072 auto make_scanline_reader(Device& io_dev, FormatTag const&,
0073     typename std::enable_if
0074     <
0075         mp11::mp_and
0076         <
0077             detail::is_adaptable_input_device<FormatTag, Device>,
0078             is_format_tag<FormatTag>
0079         >::value
0080     >::type* /*dummy*/ = nullptr)
0081     -> typename get_scanline_reader<Device, FormatTag>::type
0082 {
0083     return make_scanline_reader(io_dev, image_read_settings<FormatTag>());
0084 }
0085 
0086 }} // namespace boost::gil
0087 
0088 #endif