#pragma once #include #include #include #include #include #include #include namespace mbgl { namespace style { namespace conversion { template using LayoutPropertySetter = optional (*) (Layer&, const V&); template using PaintPropertySetter = optional (*) (Layer&, const V&, const optional&); template optional setLayoutProperty(Layer& layer, const V& value) { L* typedLayer = layer.as(); if (!typedLayer) { return Error { "layer doesn't support this property" }; } Error error; optional typedValue = convert(value, error); if (!typedValue) { return error; } (typedLayer->*setter)(*typedValue); return {}; } template &)> optional setPaintProperty(Layer& layer, const V& value, const optional& klass) { L* typedLayer = layer.as(); if (!typedLayer) { return Error { "layer doesn't support this property" }; } Error error; optional typedValue = convert(value, error); if (!typedValue) { return error; } (typedLayer->*setter)(*typedValue, klass); return {}; } template &)> optional setTransition(Layer& layer, const V& value, const optional& klass) { L* typedLayer = layer.as(); if (!typedLayer) { return Error { "layer doesn't support this property" }; } Error error; optional transition = convert(value, error); if (!transition) { return error; } (typedLayer->*setter)(*transition, klass); return {}; } template optional setVisibility(Layer& layer, const V& value) { if (isUndefined(value)) { layer.setVisibility(VisibilityType::Visible); return {}; } Error error; optional visibility = convert(value, error); if (!visibility) { return error; } layer.setVisibility(*visibility); return {}; } } // namespace conversion } // namespace style } // namespace mbgl