diff --git a/include/mapnik/text/properties_util.hpp b/include/mapnik/text/properties_util.hpp index d823942db..2ebe7125c 100644 --- a/include/mapnik/text/properties_util.hpp +++ b/include/mapnik/text/properties_util.hpp @@ -32,9 +32,19 @@ namespace mapnik { namespace detail { -// text_layout_properties +template +struct is_mapnik_enumeration +{ + static constexpr bool value = false; +}; -template +template +struct is_mapnik_enumeration::value>::type> +{ + static constexpr bool value = true; +}; + +template struct set_property_from_xml_impl { using target_type = T0; @@ -57,30 +67,29 @@ struct set_property_from_xml_impl } }; -template -struct set_property_from_xml_impl +template +struct set_property_from_xml_impl { - using target_type = T; - static void apply(T & val, char const* name, xml_node const& node) + using target_enum_type = T0; + static void apply(T1 & val, char const* name, xml_node const& node) { try { boost::optional enum_str = node.get_opt_attr(name); if (enum_str) { - text_transform_e e; + target_enum_type e; e.from_string(*enum_str); val = enumeration_wrapper(e); } } - catch (...)//config_error const& ex) + catch (...) { boost::optional expr = node.get_opt_attr(name); if (expr) val = *expr; else { throw config_error(std::string("set_property_from_xml'"+ std::string(name))); - //ex.append_context(std::string("set_property_from_xml'"+ std::string(name) + "'"), node); } } } @@ -91,7 +100,7 @@ struct set_property_from_xml_impl template void set_property_from_xml(T1 & val, char const* name, xml_node const& node) { - detail::set_property_from_xml_impl::apply(val, name, node); + detail::set_property_from_xml_impl::value>::apply(val, name, node); } void serialize_property(std::string const& name, symbolizer_base::value_type const& val, boost::property_tree::ptree & node);