MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
case.hpp
Go to the documentation of this file.
1 #pragma once
2 
6 
7 #include <memory>
8 #include <utility>
9 #include <vector>
10 
11 namespace mbgl {
12 namespace style {
13 namespace expression {
14 
15 class Case : public Expression {
16 public:
17  using Branch = std::pair<std::unique_ptr<Expression>, std::unique_ptr<Expression>>;
18 
19  Case(type::Type type_, std::vector<Branch> branches_, std::unique_ptr<Expression> otherwise_)
20  : Expression(Kind::Case, std::move(type_)), branches(std::move(branches_)), otherwise(std::move(otherwise_)) {}
21 
23 
24  EvaluationResult evaluate(const EvaluationContext& params) const override;
25  void eachChild(const std::function<void(const Expression&)>& visit) const override;
26 
27  bool operator==(const Expression& e) const override;
28 
29  std::vector<std::optional<Value>> possibleOutputs() const override;
30 
31  std::string getOperator() const override { return "case"; }
32 private:
33  std::vector<Branch> branches;
34  std::unique_ptr<Expression> otherwise;
35 };
36 
37 } // namespace expression
38 } // namespace style
39 } // namespace mbgl
std::pair< std::unique_ptr< Expression >, std::unique_ptr< Expression > > Branch
Definition: case.hpp:17
Case(type::Type type_, std::vector< Branch > branches_, std::unique_ptr< Expression > otherwise_)
Definition: case.hpp:19
bool operator==(const Expression &e) const override
std::string getOperator() const override
Definition: case.hpp:31
EvaluationResult evaluate(const EvaluationContext &params) const override
static ParseResult parse(const mbgl::style::conversion::Convertible &value, ParsingContext &ctx)
std::vector< std::optional< Value > > possibleOutputs() const override
void eachChild(const std::function< void(const Expression &)> &visit) const override
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)
variant< NullType, NumberType, BooleanType, StringType, ColorType, ObjectType, ValueType, mapbox::util::recursive_wrapper< Array >, CollatorType, FormattedType, ErrorType, ImageType > Type
Definition: type.hpp:108
std::optional< std::unique_ptr< Expression > > ParseResult
Definition: actor.hpp:15
Definition: tile_id.hpp:256