Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / gil / extension / io / pnm / detail / is_allowed.hpp
1 //
2 // Copyright 2009 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_EXTENSION_IO_PNM_DETAIL_IS_ALLOWED_HPP
9 #define BOOST_GIL_EXTENSION_IO_PNM_DETAIL_IS_ALLOWED_HPP
10
11 #include <boost/gil/extension/io/pnm/tags.hpp>
12
13 #include <type_traits>
14
15 namespace boost { namespace gil { namespace detail {
16
17 template< typename View >
18 bool is_allowed( const image_read_info< pnm_tag >& info
19                , std::true_type   // is read_and_no_convert
20                )
21 {
22     pnm_image_type::type asc_type = is_read_supported< typename get_pixel_type< View >::type
23                                                      , pnm_tag
24                                                      >::_asc_type;
25
26     pnm_image_type::type bin_type = is_read_supported< typename get_pixel_type< View >::type
27                                                      , pnm_tag
28                                                      >::_bin_type;
29     if( info._type == pnm_image_type::mono_asc_t::value )
30     {
31         // ascii mono images are read gray8_image_t
32         return (  asc_type == pnm_image_type::gray_asc_t::value );
33     }
34
35
36     return (  asc_type == info._type
37            || bin_type == info._type
38            );
39 }
40
41 template< typename View >
42 bool is_allowed( const image_read_info< pnm_tag >& /* info */
43                , std::false_type  // is read_and_convert
44                )
45 {
46     return true;
47 }
48
49 } // namespace detail
50 } // namespace gil
51 } // namespace boost
52
53 #endif