diff options
author | Wilhelm Berg <wb@BergWerk-GIS.at> | 2018-08-22 16:56:32 +0200 |
---|---|---|
committer | Wilhelm Berg <wb@BergWerk-GIS.at> | 2018-08-22 16:56:32 +0200 |
commit | 797f622a26b34db5a30e7f1728d87c6700a2ec1e (patch) | |
tree | 75ea93979db2baf3eb2234c6fbb3d1a9c5b70329 /include/mbgl/style/conversion/constant.hpp | |
parent | 86fc3f525e42d042f239876b93525ff411ad7182 (diff) | |
parent | 520df7f02049cdbbb9e68041e755d6c3a8d5b21f (diff) | |
download | qtlocation-mapboxgl-797f622a26b34db5a30e7f1728d87c6700a2ec1e.tar.gz |
Merge branch 'master' of github.com:mapbox/mapbox-gl-native into bwg-vs2017
Diffstat (limited to 'include/mbgl/style/conversion/constant.hpp')
-rw-r--r-- | include/mbgl/style/conversion/constant.hpp | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/include/mbgl/style/conversion/constant.hpp b/include/mbgl/style/conversion/constant.hpp index 7d74ec42ce..40657528c4 100644 --- a/include/mbgl/style/conversion/constant.hpp +++ b/include/mbgl/style/conversion/constant.hpp @@ -1,6 +1,7 @@ #pragma once #include <mbgl/style/conversion.hpp> +#include <mbgl/style/types.hpp> #include <mbgl/util/color.hpp> #include <mbgl/util/enum.hpp> #include <mbgl/util/string.hpp> @@ -30,21 +31,7 @@ struct Converter<std::string> { template <class T> struct Converter<T, typename std::enable_if_t<std::is_enum<T>::value>> { - optional<T> operator()(const Convertible& value, Error& error) const { - optional<std::string> string = toString(value); - if (!string) { - error.message = "value must be a string"; - return nullopt; - } - - const auto result = Enum<T>::toEnum(*string); - if (!result) { - error.message = "value must be a valid enumeration value"; - return nullopt; - } - - return *result; - } + optional<T> operator()(const Convertible& value, Error& error) const; }; template <> @@ -54,23 +41,7 @@ struct Converter<Color> { template <size_t N> struct Converter<std::array<float, N>> { - optional<std::array<float, N>> operator()(const Convertible& value, Error& error) const { - if (!isArray(value) || arrayLength(value) != N) { - error.message = "value must be an array of " + util::toString(N) + " numbers"; - return nullopt; - } - - std::array<float, N> result; - for (size_t i = 0; i < N; i++) { - optional<float> n = toNumber(arrayMember(value, i)); - if (!n) { - error.message = "value must be an array of " + util::toString(N) + " numbers"; - return nullopt; - } - result[i] = *n; - } - return result; - } + optional<std::array<float, N>> operator()(const Convertible& value, Error& error) const; }; template <> |