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