diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-22 12:31:49 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-24 09:39:15 -0700 |
commit | 089c4e413fbe80711ebd874520d3b8fdcb997112 (patch) | |
tree | a8088b0ed6cbd36b5cadf247a6e0fc524b6c3a3d /include/mbgl/style/conversion/property_value.hpp | |
parent | cb6a519f7c1e59b584b84039ebf4803c1d7eee71 (diff) | |
download | qtlocation-mapboxgl-089c4e413fbe80711ebd874520d3b8fdcb997112.tar.gz |
[core] Split up and clean up conversion.hpp
Diffstat (limited to 'include/mbgl/style/conversion/property_value.hpp')
-rw-r--r-- | include/mbgl/style/conversion/property_value.hpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/mbgl/style/conversion/property_value.hpp b/include/mbgl/style/conversion/property_value.hpp new file mode 100644 index 0000000000..840643abbe --- /dev/null +++ b/include/mbgl/style/conversion/property_value.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include <mbgl/style/property_value.hpp> +#include <mbgl/style/conversion.hpp> +#include <mbgl/style/conversion/constant.hpp> +#include <mbgl/style/conversion/function.hpp> + +namespace mbgl { +namespace style { +namespace conversion { + +template <class T> +struct Converter<PropertyValue<T>> { + template <class V> + Result<PropertyValue<T>> operator()(const V& value) const { + if (isObject(value)) { + Result<Function<T>> function = convert<Function<T>>(value); + if (!function) { + return function.error(); + } + return *function; + } else { + Result<T> constant = convert<T>(value); + if (!constant) { + return constant.error(); + } + return *constant; + } + } +}; + +} // namespace conversion +} // namespace style +} // namespace mbgl |