blob: 7e9cb95969b3898b1b94e271bf180d6f643c1325 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#pragma once
#include <mbgl/style/expression/check_subtype.hpp>
#include <mbgl/style/expression/expression.hpp>
#include <mbgl/style/expression/parsing_context.hpp>
#include <mbgl/style/conversion.hpp>
namespace mbgl {
namespace style {
namespace expression {
using InputType = variant<int64_t, std::string>;
template <typename T>
class Match : public Expression {
public:
using Cases = std::unordered_map<T, std::shared_ptr<Expression>>;
Match(type::Type type,
std::unique_ptr<Expression> input_,
Cases cases_,
std::unique_ptr<Expression> otherwise_
) : Expression(type),
input(std::move(input_)),
cases(std::move(cases_)),
otherwise(std::move(otherwise_))
{}
bool isFeatureConstant() const override {
if (!input->isFeatureConstant()) { return false; }
if (!otherwise->isFeatureConstant()) { return false; }
for (const auto& pair : cases) {
if (!pair.second->isFeatureConstant()) { return false; }
}
return true;
}
bool isZoomConstant() const override {
if (!input->isZoomConstant()) { return false; }
if (!otherwise->isZoomConstant()) { return false; }
for (const auto& pair : cases) {
if (!pair.second->isZoomConstant()) { return false; }
}
return true;
}
EvaluationResult evaluate(const EvaluationParameters& params) const override;
private:
std::unique_ptr<Expression> input;
Cases cases;
std::unique_ptr<Expression> otherwise;
};
} // namespace expression
} // namespace style
} // namespace mbgl
|