summaryrefslogtreecommitdiff
path: root/include/mbgl/style/function/categorical_stops.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/style/function/categorical_stops.hpp')
-rw-r--r--include/mbgl/style/function/categorical_stops.hpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/include/mbgl/style/function/categorical_stops.hpp b/include/mbgl/style/function/categorical_stops.hpp
new file mode 100644
index 0000000000..c8505115ab
--- /dev/null
+++ b/include/mbgl/style/function/categorical_stops.hpp
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <mbgl/util/feature.hpp>
+#include <mbgl/util/variant.hpp>
+
+#include <cassert>
+#include <utility>
+#include <map>
+
+namespace mbgl {
+namespace style {
+
+class CategoricalValue : public variant<bool, int64_t, std::string> {
+public:
+ using variant<bool, int64_t, std::string>::variant;
+};
+
+template <class T>
+class CategoricalStops {
+public:
+ using Stops = std::map<CategoricalValue, T>;
+
+ Stops stops;
+
+ CategoricalStops() = default;
+ CategoricalStops(Stops stops_)
+ : stops(std::move(stops_)) {
+ assert(stops.size() > 0);
+ }
+
+ optional<T> evaluate(const Value&) const;
+
+ friend bool operator==(const CategoricalStops& lhs,
+ const CategoricalStops& rhs) {
+ return lhs.stops == rhs.stops;
+ }
+};
+
+} // namespace style
+} // namespace mbgl