8 #ifndef BOOST_GIL_IO_MAKE_WRITER_HPP
9 #define BOOST_GIL_IO_MAKE_WRITER_HPP
11 #include <boost/gil/detail/mp11.hpp>
12 #include <boost/gil/io/get_writer.hpp>
14 #include <type_traits>
16 namespace boost {
namespace gil {
18 template <
typename String,
typename FormatTag>
20 auto make_writer(String
const& file_name, image_write_info<FormatTag>
const& info,
21 typename std::enable_if
25 detail::is_supported_path_spec<String>,
26 is_format_tag<FormatTag>
27 >::value>::type* =
nullptr)
28 ->
typename get_writer<String, FormatTag>::type
30 typename get_write_device<String, FormatTag>::type device(
31 detail::convert_to_native_string(file_name),
32 typename detail::file_stream_device<FormatTag>::write_tag());
34 return typename get_writer<String, FormatTag>::type(device, info);
37 template<
typename FormatTag >
39 typename get_writer< std::wstring
42 make_writer(
const std::wstring& file_name
43 ,
const image_write_info< FormatTag >& info
46 const char* str = detail::convert_to_native_string( file_name );
48 typename get_write_device< std::wstring
51 ,
typename detail::file_stream_device< FormatTag >::write_tag()
56 return typename get_writer< std::wstring
63 template<
typename FormatTag >
65 typename get_writer< std::wstring
68 make_writer( detail::filesystem::path
const& path
69 ,
const image_write_info< FormatTag >& info
72 return make_writer( path.wstring()
77 template <
typename Device,
typename FormatTag>
79 auto make_writer(Device& file, image_write_info<FormatTag>
const& info,
80 typename std::enable_if
84 typename detail::is_adaptable_output_device<FormatTag, Device>::type,
85 is_format_tag<FormatTag>
88 ->
typename get_writer<Device, FormatTag>::type
90 typename get_write_device<Device, FormatTag>::type device(file);
91 return typename get_writer<Device, FormatTag>::type(device, info);
96 template <
typename String,
typename FormatTag>
98 auto make_writer(String
const& file_name, FormatTag
const&,
99 typename std::enable_if
103 detail::is_supported_path_spec<String>,
104 is_format_tag<FormatTag>
107 ->
typename get_writer<String, FormatTag>::type
109 return make_writer(file_name, image_write_info<FormatTag>());
112 template<
typename FormatTag >
114 typename get_writer< std::wstring
117 make_writer(
const std::wstring& file_name
121 return make_writer( file_name
122 , image_write_info< FormatTag >()
126 template<
typename FormatTag >
128 typename get_writer< std::wstring
131 make_writer( detail::filesystem::path
const& path
132 ,
const FormatTag& tag
135 return make_writer( path.wstring()
140 template <
typename Device,
typename FormatTag>
142 auto make_writer(Device& file, FormatTag
const&,
143 typename std::enable_if
147 typename detail::is_adaptable_output_device<FormatTag, Device>::type,
148 is_format_tag<FormatTag>
151 ->
typename get_writer<Device, FormatTag>::type
153 return make_writer(file, image_write_info<FormatTag>());