MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
format_expression.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace mbgl {
7 namespace style {
8 namespace expression {
9 
11  explicit FormatExpressionSection(std::unique_ptr<Expression> content_);
12 
13  void setTextSectionOptions(std::optional<std::unique_ptr<Expression>> fontScale_,
14  std::optional<std::unique_ptr<Expression>> textFont_,
15  std::optional<std::unique_ptr<Expression>> textColor_);
16 
17  // Content can be expression that evaluates to String or Image.
18  std::shared_ptr<Expression> content;
19 
20  // Text related section options.
21  std::optional<std::shared_ptr<Expression>> fontScale;
22  std::optional<std::shared_ptr<Expression>> textFont;
23  std::optional<std::shared_ptr<Expression>> textColor;
24 };
25 
26 class FormatExpression final : public Expression {
27 public:
28  explicit FormatExpression(std::vector<FormatExpressionSection> sections);
29 
32 
33  void eachChild(const std::function<void(const Expression&)>&) const override;
34 
35  bool operator==(const Expression& e) const override;
36 
37  std::vector<std::optional<Value>> possibleOutputs() const override {
38  // Technically the combinatoric set of all children
39  // Usually, this.text will be undefined anyway
40  return { std::nullopt };
41  }
42 
43  const std::vector<FormatExpressionSection>& getSections() const { return sections; }
44 
45  mbgl::Value serialize() const override;
46  std::string getOperator() const override { return "format"; }
47 private:
48  std::vector<FormatExpressionSection> sections;
49 };
50 
51 } // namespace expression
52 } // namespace style
53 } // namespace mbgl
static ParseResult parse(const mbgl::style::conversion::Convertible &, ParsingContext &)
std::string getOperator() const override
FormatExpression(std::vector< FormatExpressionSection > sections)
EvaluationResult evaluate(const EvaluationContext &) const override
std::vector< std::optional< Value > > possibleOutputs() const override
bool operator==(const Expression &e) const override
void eachChild(const std::function< void(const Expression &)> &) const override
const std::vector< FormatExpressionSection > & getSections() const
mbgl::Value serialize() const override
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)
std::optional< std::unique_ptr< Expression > > ParseResult
Definition: actor.hpp:15
mapbox::base::Value Value
Definition: feature.hpp:11
std::optional< std::shared_ptr< Expression > > fontScale
void setTextSectionOptions(std::optional< std::unique_ptr< Expression >> fontScale_, std::optional< std::unique_ptr< Expression >> textFont_, std::optional< std::unique_ptr< Expression >> textColor_)
std::optional< std::shared_ptr< Expression > > textColor
std::optional< std::shared_ptr< Expression > > textFont
FormatExpressionSection(std::unique_ptr< Expression > content_)