diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-06-28 13:59:55 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-06-29 15:38:11 -0700 |
commit | 25ac89e018a27fc689f742429c78ba492682b0a0 (patch) | |
tree | c3434d5b652502f2fd3b64e2efdaeb2b7319f36b /src | |
parent | 6dfe56510caa87b3e0fdbb8256d13ec955764d53 (diff) | |
download | qtlocation-mapboxgl-25ac89e018a27fc689f742429c78ba492682b0a0.tar.gz |
[core] Remove stops-based *Function constructors
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/style/function/convert.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/mbgl/style/function/convert.cpp b/src/mbgl/style/function/convert.cpp new file mode 100644 index 0000000000..a3b19f287b --- /dev/null +++ b/src/mbgl/style/function/convert.cpp @@ -0,0 +1,40 @@ +#include <mbgl/style/function/convert.hpp> + +namespace mbgl { +namespace style { +namespace expression { + +std::unique_ptr<Expression> Convert::fromIdentityFunction(const std::string& property, type::Type type) { + return type.match( + [&] (const type::StringType&) { + return makeGet(type::String, property); + }, + [&] (const type::NumberType&) { + return makeGet(type::Number, property); + }, + [&] (const type::BooleanType&) { + return makeGet(type::Boolean, property); + }, + [&] (const type::ColorType&) { + std::vector<std::unique_ptr<Expression>> args; + args.push_back(makeGet(type::String, property)); + return std::make_unique<Coercion>(type::Color, std::move(args)); + }, + [&] (const type::Array& arr) { + std::vector<std::unique_ptr<Expression>> getArgs; + getArgs.push_back(makeLiteral(property)); + ParsingContext ctx; + ParseResult get = createCompoundExpression("get", std::move(getArgs), ctx); + assert(get); + assert(ctx.getErrors().size() == 0); + return std::make_unique<ArrayAssertion>(arr, std::move(*get)); + }, + [&] (const auto&) -> std::unique_ptr<Expression> { + return makeLiteral(Null); + } + ); +} + +} // namespace expression +} // namespace style +} // namespace mbgl |