summaryrefslogtreecommitdiff
path: root/include/mbgl/style/expression/in.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/style/expression/in.hpp')
-rw-r--r--include/mbgl/style/expression/in.hpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/include/mbgl/style/expression/in.hpp b/include/mbgl/style/expression/in.hpp
new file mode 100644
index 0000000000..ab8e2e9ff2
--- /dev/null
+++ b/include/mbgl/style/expression/in.hpp
@@ -0,0 +1,43 @@
+#pragma once
+
+#include <mbgl/style/conversion.hpp>
+#include <mbgl/style/expression/expression.hpp>
+#include <memory>
+
+namespace mbgl {
+namespace style {
+namespace expression {
+
+class In : public Expression {
+public:
+ In(std::unique_ptr<Expression> needle_, std::unique_ptr<Expression> haystack_)
+ : Expression(Kind::In, type::Boolean), needle(std::move(needle_)), haystack(std::move(haystack_)) {}
+
+ static ParseResult parse(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx);
+
+ EvaluationResult evaluate(const EvaluationContext& params) const override;
+ void eachChild(const std::function<void(const Expression&)>&) const override;
+
+ bool operator==(const Expression& e) const override {
+ if (e.getKind() == Kind::In) {
+ auto rhs = static_cast<const In*>(&e);
+ return *needle == *(rhs->needle) && *haystack == *(rhs->haystack);
+ }
+ return false;
+ }
+
+ std::vector<optional<Value>> possibleOutputs() const override { return {nullopt}; }
+
+ std::string getOperator() const override { return "in"; }
+
+private:
+ std::unique_ptr<Expression> needle;
+ std::unique_ptr<Expression> haystack;
+ static bool isComparableType(type::Type type);
+ static bool isComparableRuntimeValue(type::Type type);
+ static bool isSearchableRuntimeValue(type::Type type);
+};
+
+} // namespace expression
+} // namespace style
+} // namespace mbgl