diff options
author | kevin <kevin.li@mapbox.com> | 2020-02-06 16:39:50 +0800 |
---|---|---|
committer | kevin <kevin.li@mapbox.com> | 2020-02-15 08:52:23 +0800 |
commit | 2e2bba8dc33665df952e80beb381741894a5331d (patch) | |
tree | c64634a8398be2b9fa9e542c1bfa1543cbfcd3e0 /include/mbgl/style/expression/in.hpp | |
parent | 59294aaef333bdd455bd13d6bab6fca730379b52 (diff) | |
download | qtlocation-mapboxgl-2e2bba8dc33665df952e80beb381741894a5331d.tar.gz |
Implement in.cpp
Diffstat (limited to 'include/mbgl/style/expression/in.hpp')
-rw-r--r-- | include/mbgl/style/expression/in.hpp | 43 |
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 |