1#pragma once
2
3#include <mbgl/style/property_expression.hpp>
4#include <mbgl/style/conversion.hpp>
5#include <mbgl/style/conversion/constant.hpp>
6#include <mbgl/style/expression/expression.hpp>
7#include <mbgl/style/expression/value.hpp>
8
9namespace mbgl {
10namespace style {
11namespace conversion {
12
13bool hasTokens(const std::string&);
14std::unique_ptr<expression::Expression> convertTokenStringToExpression(const std::string&);
15
16optional<std::unique_ptr<expression::Expression>> convertFunctionToExpression(expression::type::Type, const Convertible&, Error&, bool convertTokens);
17
18template <class T>
19optional<PropertyExpression<T>> convertFunctionToExpression(const Convertible& value, Error& error, bool convertTokens) {
20 auto expression = convertFunctionToExpression(expression::valueTypeToExpressionType<T>(), value, error, convertTokens);
21 if (!expression) {
22 return {};
23 }
24
25 optional<T> defaultValue;
26
27 auto defaultValueValue = objectMember(v: value, name: "default");
28 if (defaultValueValue) {
29 defaultValue = convert<T>(*defaultValueValue, error);
30 if (!defaultValue) {
31 error = { .message: R"(wrong type for "default": )" + error.message };
32 return {};
33 }
34 }
35
36 return PropertyExpression<T>(std::move(*expression), defaultValue);
37}
38
39} // namespace conversion
40} // namespace style
41} // namespace mbgl
42

source code of qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/style/conversion/function.hpp