summaryrefslogtreecommitdiff
path: root/include/mbgl/style/expression/is_constant.hpp
blob: 2861407af0fa8f1566f322a962b1a680e024b19f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include <mbgl/style/expression/expression.hpp>
#include <mbgl/style/expression/compound_expression.hpp>

namespace mbgl {
namespace style {
namespace expression {

template <typename T>
bool isGlobalPropertyConstant(const Expression& expression, const T& properties) {
    if (expression.getKind() == Kind::CompoundExpression) {
        auto e = static_cast<const CompoundExpression*>(&expression);
        for (const std::string& property : properties) {
            if (e->getOperator() == property) {
                return false;
            }
        }
    }

    bool isConstant = true;
    expression.eachChild([&](const Expression& e) {
        if (isConstant && !isGlobalPropertyConstant(e, properties)) {
            isConstant = false;
        }
    });
    return isConstant;
}

bool isFeatureConstant(const Expression& expression);
bool isZoomConstant(const Expression& e);


} // namespace expression
} // namespace style
} // namespace mbgl