| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include <mbgl/style/expression/expression.hpp> |
| 4 | #include <mbgl/style/expression/parsing_context.hpp> |
| 5 | #include <mbgl/style/conversion.hpp> |
| 6 | |
| 7 | #include <memory> |
| 8 | |
| 9 | namespace mbgl { |
| 10 | namespace style { |
| 11 | namespace expression { |
| 12 | |
| 13 | class CollatorExpression : public Expression { |
| 14 | public: |
| 15 | CollatorExpression(std::unique_ptr<Expression> caseSensitive, |
| 16 | std::unique_ptr<Expression> diacriticSensitive, |
| 17 | optional<std::unique_ptr<Expression>> locale); |
| 18 | |
| 19 | EvaluationResult evaluate(const EvaluationContext&) const override; |
| 20 | static ParseResult parse(const mbgl::style::conversion::Convertible&, ParsingContext&); |
| 21 | |
| 22 | void eachChild(const std::function<void(const Expression&)>&) const override; |
| 23 | |
| 24 | bool operator==(const Expression& e) const override; |
| 25 | |
| 26 | std::vector<optional<Value>> possibleOutputs() const override { |
| 27 | // Technically the set of possible outputs is the combinatoric set of Collators produced |
| 28 | // by all possibleOutputs of locale/caseSensitive/diacriticSensitive |
| 29 | // But for the primary use of Collators in comparison operators, we ignore the Collator's |
| 30 | // possibleOutputs anyway, so we can get away with leaving this undefined for now. |
| 31 | return { nullopt }; |
| 32 | } |
| 33 | |
| 34 | mbgl::Value serialize() const override; |
| 35 | std::string getOperator() const override { return "collator"; } |
| 36 | private: |
| 37 | std::unique_ptr<Expression> caseSensitive; |
| 38 | std::unique_ptr<Expression> diacriticSensitive; |
| 39 | optional<std::unique_ptr<Expression>> locale; |
| 40 | }; |
| 41 | |
| 42 | } // namespace expression |
| 43 | } // namespace style |
| 44 | } // namespace mbgl |
| 45 |
