summaryrefslogtreecommitdiff
path: root/include/mbgl/style/function/categorical_stops.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-10-28 16:39:50 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-02-02 09:44:42 -0800
commit141e995806576364d185626176c1b993fc519291 (patch)
treeecdc41fc7699f2a1a9e9456157348451ebe99597 /include/mbgl/style/function/categorical_stops.hpp
parent6a6bddb4537004cc1bfc506e76772de74d33f3f7 (diff)
downloadqtlocation-mapboxgl-141e995806576364d185626176c1b993fc519291.tar.gz
[core] Add support for data-driven styling
Diffstat (limited to 'include/mbgl/style/function/categorical_stops.hpp')
-rw-r--r--include/mbgl/style/function/categorical_stops.hpp42
1 files changed, 42 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..11ec2a0e5a
--- /dev/null
+++ b/include/mbgl/style/function/categorical_stops.hpp
@@ -0,0 +1,42 @@
+#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;
+ T defaultValue;
+
+ CategoricalStops() = default;
+ CategoricalStops(Stops stops_, T defaultValue_ = T())
+ : stops(std::move(stops_)),
+ defaultValue(std::move(defaultValue_)) {
+ assert(stops.size() > 0);
+ }
+
+ T evaluate(const Value&) const;
+
+ friend bool operator==(const CategoricalStops& lhs,
+ const CategoricalStops& rhs) {
+ return lhs.stops == rhs.stops && lhs.defaultValue == rhs.defaultValue;
+ }
+};
+
+} // namespace style
+} // namespace mbgl