#include <boost/gil/extension/io/tiff/tags.hpp>
#include <boost/gil/extension/io/tiff/detail/log.hpp>
-
+#include <boost/gil/detail/mp11.hpp>
#include <boost/gil/io/base.hpp>
#include <boost/gil/io/device.hpp>
-#include <boost/mpl/size.hpp>
-
#include <algorithm>
#include <memory>
#include <sstream>
+#include <type_traits>
// taken from jpegxx - https://bitbucket.org/edd/jpegxx/src/ea2492a1a4a6/src/ijg_headers.hpp
#ifndef BOOST_GIL_EXTENSION_IO_TIFF_C_LIB_COMPILED_AS_CPLUSPLUS
// Specialisation for multi-valued properties. @todo: add one of
// these for the three-parameter fields too.
template <typename Property>
- bool call_me(typename Property:: type & vs, std::shared_ptr<TIFF>& file) const
+ bool call_me(typename Property::type& vs, std::shared_ptr<TIFF>& file) const
{
- typename mpl:: at <typename Property:: arg_types, mpl::int_<0> >:: type length;
- typename mpl:: at <typename Property:: arg_types, mpl::int_<1> >:: type pointer;
- if (1 == TIFFGetFieldDefaulted( file.get()
- , Property:: tag
- , & length
- , & pointer)) {
- std:: copy_n (static_cast <typename Property:: type:: const_pointer> (pointer), length, std:: back_inserter (vs));
+ mp11::mp_at<typename Property::arg_types, std::integral_constant<int, 0>> length;
+ mp11::mp_at<typename Property::arg_types, std::integral_constant<int, 1>> pointer;
+ if (1 == TIFFGetFieldDefaulted(file.get(), Property:: tag, & length, & pointer))
+ {
+ std:: copy_n(static_cast<typename Property::type::const_pointer>(pointer), length, std:: back_inserter(vs));
return true;
} else
return false;
inline
bool call_me(typename Property:: type const & values, std::shared_ptr<TIFF>& file) const
{
- typename mpl:: at <typename Property:: arg_types, mpl::int_<0> >:: type const length = values. size ();
- typename mpl:: at <typename Property:: arg_types, mpl::int_<1> >:: type const pointer = & (values. front ());
- return (1 == TIFFSetField( file.get()
- , Property:: tag
- , length
- , pointer));
+ using length_t = mp11::mp_at_c<typename Property::arg_types, 0>;
+ auto const length = static_cast<length_t>(values.size());
+
+ using pointer_t = mp11::mp_at_c<typename Property::arg_types, 1>;
+ auto const pointer = static_cast<pointer_t>(&(values.front()));
+ return (1 == TIFFSetField( file.get(), Property:: tag, length, pointer));
}
};
template <typename Property>
bool get_property( typename Property::type& value )
{
- return get_property_f <mpl:: size <typename Property:: arg_types>::value > ().template call_me<Property>(value, _tiff_file);
+ return get_property_f<mp11::mp_size<typename Property::arg_types>::value>().template call_me<Property>(value, _tiff_file);
}
template <typename Property>
bool set_property( const typename Property::type& value )
{
// http://www.remotesensing.org/libtiff/man/TIFFSetField.3tiff.html
- return set_property_f <mpl:: size <typename Property:: arg_types>::value > ().template call_me<Property> (value, _tiff_file);
+ return set_property_f<mp11::mp_size<typename Property::arg_types>::value>().template call_me<Property>(value, _tiff_file);
}
// TIFFIsByteSwapped returns a non-zero value if the image data was in a different
/*
template< typename T, typename D >
-struct is_adaptable_input_device< tiff_tag, T, D > : mpl::false_{};
+struct is_adaptable_input_device< tiff_tag, T, D > : std::false_type {};
*/
-template< typename FormatTag >
-struct is_adaptable_input_device< FormatTag
- , TIFF*
- , void
- >
- : mpl::true_
+template<typename FormatTag>
+struct is_adaptable_input_device<FormatTag, TIFF*, void> : std::true_type
{
using device_type = file_stream_device<FormatTag>;
};
-template< typename FormatTag >
-struct is_adaptable_output_device< FormatTag
- , TIFF*
- , void
- >
- : mpl::true_
+template<typename FormatTag>
+struct is_adaptable_output_device<FormatTag, TIFF*, void> : std::true_type
{
using device_type = file_stream_device<FormatTag>;
};
-template < typename Channel > struct sample_format : public mpl::int_<SAMPLEFORMAT_UINT> {};
-template<> struct sample_format<uint8_t> : public mpl::int_<SAMPLEFORMAT_UINT> {};
-template<> struct sample_format<uint16_t> : public mpl::int_<SAMPLEFORMAT_UINT> {};
-template<> struct sample_format<uint32_t> : public mpl::int_<SAMPLEFORMAT_UINT> {};
-template<> struct sample_format<float32_t> : public mpl::int_<SAMPLEFORMAT_IEEEFP> {};
-template<> struct sample_format<double> : public mpl::int_<SAMPLEFORMAT_IEEEFP> {};
-template<> struct sample_format<int8_t> : public mpl::int_<SAMPLEFORMAT_INT> {};
-template<> struct sample_format<int16_t> : public mpl::int_<SAMPLEFORMAT_INT> {};
-template<> struct sample_format<int32_t> : public mpl::int_<SAMPLEFORMAT_INT> {};
-
-template <typename Channel> struct photometric_interpretation {};
-template<> struct photometric_interpretation< gray_t > : public mpl::int_< PHOTOMETRIC_MINISBLACK > {};
-template<> struct photometric_interpretation< rgb_t > : public mpl::int_< PHOTOMETRIC_RGB > {};
-template<> struct photometric_interpretation< rgba_t > : public mpl::int_< PHOTOMETRIC_RGB > {};
-template<> struct photometric_interpretation< cmyk_t > : public mpl::int_< PHOTOMETRIC_SEPARATED > {};
+template <typename Channel>
+struct sample_format : std::integral_constant<int, SAMPLEFORMAT_UINT> {};
+template<>
+struct sample_format<uint8_t> : std::integral_constant<int, SAMPLEFORMAT_UINT> {};
+template<>
+struct sample_format<uint16_t> : std::integral_constant<int, SAMPLEFORMAT_UINT> {};
+template<>
+struct sample_format<uint32_t> : std::integral_constant<int, SAMPLEFORMAT_UINT> {};
+template<>
+struct sample_format<float32_t> : std::integral_constant<int, SAMPLEFORMAT_IEEEFP> {};
+template<>
+struct sample_format<double> : std::integral_constant<int, SAMPLEFORMAT_IEEEFP> {};
+template<>
+struct sample_format<int8_t> : std::integral_constant<int, SAMPLEFORMAT_INT> {};
+template<>
+struct sample_format<int16_t> : std::integral_constant<int, SAMPLEFORMAT_INT> {};
+template<>
+struct sample_format<int32_t> : std::integral_constant<int, SAMPLEFORMAT_INT> {};
+
+template <typename Channel>
+struct photometric_interpretation {};
+template<>
+struct photometric_interpretation<gray_t>
+ : std::integral_constant<int, PHOTOMETRIC_MINISBLACK> {};
+template<>
+struct photometric_interpretation<rgb_t>
+ : std::integral_constant<int, PHOTOMETRIC_RGB> {};
+template<>
+struct photometric_interpretation<rgba_t>
+ : std::integral_constant<int, PHOTOMETRIC_RGB> {};
+template<>
+struct photometric_interpretation<cmyk_t>
+ : std::integral_constant<int, PHOTOMETRIC_SEPARATED> {};
} // namespace detail
} // namespace gil