summaryrefslogtreecommitdiff
path: root/src/mbgl/style/expression/is_expression.cpp
blob: 77212f6a1e929a9d7e89d033e32b76a8cb9e6c43 (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
#include <mbgl/style/expression/is_expression.hpp>
#include <mbgl/style/expression/compound_expression.hpp>
#include <mbgl/style/expression/parsing_context.hpp>

#include <mbgl/style/conversion.hpp>

#include <unordered_set>

namespace mbgl {
namespace style {
namespace expression {

using namespace mbgl::style::conversion;

bool isExpression(const Convertible& value) {
    const ExpressionRegistry& registry = getExpressionRegistry();

    if (!isArray(value) || arrayLength(value) == 0) return false;
    optional<std::string> name = toString(arrayMember(value, 0));
    if (!name) return false;
    
    return (registry.find(*name) != registry.end()) ||
        (CompoundExpressionRegistry::definitions.find(*name) != CompoundExpressionRegistry::definitions.end());
}


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