MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
is_constant.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace mbgl {
7 namespace style {
8 namespace expression {
9 
10 template <typename T>
11 bool isGlobalPropertyConstant(const Expression& expression, const T& properties) {
12  if (expression.getKind() == Kind::CompoundExpression) {
13  auto e = static_cast<const CompoundExpression*>(&expression);
14  for (const std::string& property : properties) {
15  if (e->getOperator() == property) {
16  return false;
17  }
18  }
19  }
20 
21  bool isConstant = true;
22  expression.eachChild([&](const Expression& e) {
23  if (isConstant && !isGlobalPropertyConstant(e, properties)) {
24  isConstant = false;
25  }
26  });
27  return isConstant;
28 }
29 
30 bool isFeatureConstant(const Expression& expression);
31 bool isZoomConstant(const Expression& e);
32 
35 
36 } // namespace expression
37 } // namespace style
38 } // namespace mbgl
virtual void eachChild(const std::function< void(const Expression &)> &) const =0
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)
bool isRuntimeConstant(const Expression &e)
Returns true if expression does not depend on information provided by the runtime.
bool isFeatureConstant(const Expression &expression)
bool isGlobalPropertyConstant(const Expression &expression, const T &properties)
Definition: is_constant.hpp:11
bool isZoomConstant(const Expression &e)
Definition: actor.hpp:15