1 #pragma once
2 
3 #include <mbgl/style/expression/expression.hpp>
4 #include <mbgl/style/conversion.hpp>
5 #include <memory>
6 
7 namespace mbgl {
8 namespace style {
9 namespace expression {
10 
11 class At : public Expression {
12 public:
At(std::unique_ptr<Expression> index_,std::unique_ptr<Expression> input_)13     At(std::unique_ptr<Expression> index_, std::unique_ptr<Expression> input_) :
14         Expression(Kind::At, input_->getType().get<type::Array>().itemType),
15         index(std::move(index_)),
16         input(std::move(input_))
17     {}
18 
19     static ParseResult parse(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx);
20 
21     EvaluationResult evaluate(const EvaluationContext& params) const override;
22     void eachChild(const std::function<void(const Expression&)>&) const override;
23 
operator ==(const Expression & e) const24     bool operator==(const Expression& e) const override {
25         if (e.getKind() == Kind::At) {
26             auto rhs = static_cast<const At*>(&e);
27             return *index == *(rhs->index) && *input == *(rhs->input);
28         }
29         return false;
30     }
31 
possibleOutputs() const32     std::vector<optional<Value>> possibleOutputs() const override {
33         return { nullopt };
34     }
35 
getOperator() const36     std::string getOperator() const override { return "at"; }
37 
38 private:
39     std::unique_ptr<Expression> index;
40     std::unique_ptr<Expression> input;
41 };
42 
43 } // namespace expression
44 } // namespace style
45 } // namespace mbgl
46