diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-07-30 08:38:14 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-08-13 12:39:44 -0700 |
commit | b2f60a4bf2fb95c107bb94543ba6345779970e98 (patch) | |
tree | 2fd85df5cf2121b9a55d24c9d6e331b9e1bb4aca /src/mbgl/style/conversion/property_setter.hpp | |
parent | 3c8acb228e0ff1124ce8ca6c710dc46cf99d87fc (diff) | |
download | qtlocation-mapboxgl-b2f60a4bf2fb95c107bb94543ba6345779970e98.tar.gz |
[core] Eliminate setProperty & co.
Diffstat (limited to 'src/mbgl/style/conversion/property_setter.hpp')
-rw-r--r-- | src/mbgl/style/conversion/property_setter.hpp | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/src/mbgl/style/conversion/property_setter.hpp b/src/mbgl/style/conversion/property_setter.hpp deleted file mode 100644 index 3c5c65f96a..0000000000 --- a/src/mbgl/style/conversion/property_setter.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#pragma once - -#include <mbgl/style/layer.hpp> -#include <mbgl/style/layers/symbol_layer.hpp> -#include <mbgl/style/conversion.hpp> -#include <mbgl/style/conversion/color_ramp_property_value.hpp> -#include <mbgl/style/conversion/constant.hpp> -#include <mbgl/style/conversion/property_value.hpp> -#include <mbgl/style/conversion/transition_options.hpp> - -#include <string> - -namespace mbgl { -namespace style { -namespace conversion { - -using PropertySetter = optional<Error> (*) (Layer&, const Convertible&); - -template <class L, class PropertyValue, void (L::*setter)(PropertyValue), bool allowDataExpressions, bool convertTokens> -optional<Error> setProperty(Layer& layer, const Convertible& value) { - auto* typedLayer = layer.as<L>(); - if (!typedLayer) { - return Error { "layer doesn't support this property" }; - } - - Error error; - optional<PropertyValue> typedValue = convert<PropertyValue>(value, error, allowDataExpressions, convertTokens); - if (!typedValue) { - return error; - } - - (typedLayer->*setter)(*typedValue); - return nullopt; -} - -template <class L, void (L::*setter)(const TransitionOptions&)> -optional<Error> setTransition(Layer& layer, const Convertible& value) { - auto* typedLayer = layer.as<L>(); - if (!typedLayer) { - return Error { "layer doesn't support this property" }; - } - - Error error; - optional<TransitionOptions> transition = convert<TransitionOptions>(value, error); - if (!transition) { - return error; - } - - (typedLayer->*setter)(*transition); - return nullopt; -} - -inline optional<Error> setVisibility(Layer& layer, const Convertible& value) { - if (isUndefined(value)) { - layer.setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - layer.setVisibility(*visibility); - return nullopt; -} - -} // namespace conversion -} // namespace style -} // namespace mbgl |