1 | #pragma once |
---|---|
2 | |
3 | #include <mbgl/style/expression/expression.hpp> |
4 | #include <mbgl/style/conversion.hpp> |
5 | #include <mbgl/style/expression/parsing_context.hpp> |
6 | |
7 | #include <memory> |
8 | #include <map> |
9 | |
10 | namespace mbgl { |
11 | namespace style { |
12 | namespace expression { |
13 | |
14 | class Coalesce : public Expression { |
15 | public: |
16 | using Args = std::vector<std::unique_ptr<Expression>>; |
17 | Coalesce(const type::Type& type_, Args args_) : |
18 | Expression(Kind::Coalesce, type_), |
19 | args(std::move(args_)) |
20 | {} |
21 | |
22 | static ParseResult parse(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx); |
23 | |
24 | |
25 | EvaluationResult evaluate(const EvaluationContext& params) const override; |
26 | |
27 | void eachChild(const std::function<void(const Expression&)>& visit) const override; |
28 | |
29 | bool operator==(const Expression& e) const override; |
30 | |
31 | std::vector<optional<Value>> possibleOutputs() const override; |
32 | |
33 | std::size_t getLength() const { |
34 | return args.size(); |
35 | } |
36 | |
37 | Expression* getChild(std::size_t i) const { |
38 | return args.at(n: i).get(); |
39 | } |
40 | |
41 | std::string getOperator() const override { return "coalesce"; } |
42 | private: |
43 | Args args; |
44 | }; |
45 | |
46 | } // namespace expression |
47 | } // namespace style |
48 | } // namespace mbgl |
49 |