summaryrefslogtreecommitdiff
path: root/include/mbgl/style/conversion/constant.hpp
diff options
context:
space:
mode:
authorWilhelm Berg <wb@BergWerk-GIS.at>2018-08-22 16:56:32 +0200
committerWilhelm Berg <wb@BergWerk-GIS.at>2018-08-22 16:56:32 +0200
commit797f622a26b34db5a30e7f1728d87c6700a2ec1e (patch)
tree75ea93979db2baf3eb2234c6fbb3d1a9c5b70329 /include/mbgl/style/conversion/constant.hpp
parent86fc3f525e42d042f239876b93525ff411ad7182 (diff)
parent520df7f02049cdbbb9e68041e755d6c3a8d5b21f (diff)
downloadqtlocation-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.hpp35
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 <>