2 // Copyright 2007-2008 Christian Henning, Andreas Pokorny
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
8 #ifndef BOOST_GIL_IO_CONVERSION_POLICIES_HPP
9 #define BOOST_GIL_IO_CONVERSION_POLICIES_HPP
11 #include <boost/gil/image_view_factory.hpp>
12 #include <boost/gil/detail/mp11.hpp>
13 #include <boost/gil/io/error.hpp>
17 #include <type_traits>
19 namespace boost{ namespace gil { namespace detail {
21 struct read_and_no_convert
24 using color_converter_type = void *;
26 template <typename InIterator, typename OutIterator>
28 InIterator const& /*begin*/, InIterator const& /*end*/ , OutIterator /*out*/,
29 typename std::enable_if
35 typename std::iterator_traits<InIterator>::value_type,
36 typename std::iterator_traits<OutIterator>::value_type
39 >::type* /*dummy*/ = nullptr)
41 io_error("Data cannot be copied because the pixels are incompatible.");
44 template <typename InIterator, typename OutIterator>
45 void read(InIterator const& begin, InIterator const& end, OutIterator out,
46 typename std::enable_if
50 typename std::iterator_traits<InIterator>::value_type,
51 typename std::iterator_traits<OutIterator>::value_type
53 >::type* /*dummy*/ = nullptr)
55 std::copy(begin, end, out);
60 struct read_and_convert
63 using color_converter_type = default_color_converter;
69 read_and_convert( const color_converter_type& cc )
73 template< typename InIterator
74 , typename OutIterator
76 void read( const InIterator& begin
77 , const InIterator& end
81 using deref_t = color_convert_deref_fn<typename std::iterator_traits<InIterator>::reference
82 , typename std::iterator_traits<OutIterator>::value_type //reference?
94 /// is_read_only metafunction
95 /// \brief Determines if reader type is read only ( no conversion ).
96 template< typename Conversion_Policy >
97 struct is_read_only : std::false_type {};
100 struct is_read_only<detail::read_and_no_convert> : std::true_type {};
102 } // namespace detail