summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-02-19 13:09:31 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-03-14 15:26:28 -0700
commit2912a1423d7b1141e6f77b3c29f350065a084598 (patch)
treef8b0b426d5f750bbd392fe30c7c551d39d3f6364 /src/mbgl
parentbe2fae838c945919e78f72bd737157dcd1b2458c (diff)
downloadqtlocation-mapboxgl-2912a1423d7b1141e6f77b3c29f350065a084598.tar.gz
[core] Stringify expression syntax, not function syntax
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/style/conversion/stringify.hpp131
1 files changed, 6 insertions, 125 deletions
diff --git a/src/mbgl/style/conversion/stringify.hpp b/src/mbgl/style/conversion/stringify.hpp
index 7924a442c4..7b7727d7c4 100644
--- a/src/mbgl/style/conversion/stringify.hpp
+++ b/src/mbgl/style/conversion/stringify.hpp
@@ -290,138 +290,19 @@ void stringify(Writer& writer, const Undefined&) {
writer.Null();
}
-template <class Writer>
-void stringify(Writer& writer, const CategoricalValue& v) {
- CategoricalValue::visit(v, [&] (const auto& v_) { stringify(writer, v_); });
-}
-
-template <class Writer>
-class StringifyStops {
-public:
- Writer& writer;
-
- template <class T>
- void operator()(const ExponentialStops<T>& f) {
- writer.Key("type");
- writer.String("exponential");
- writer.Key("base");
- writer.Double(f.base);
- writer.Key("stops");
- stringifyStops(f.stops);
- }
-
- template <class T>
- void operator()(const IntervalStops<T>& f) {
- writer.Key("type");
- writer.String("interval");
- writer.Key("stops");
- stringifyStops(f.stops);
- }
-
- template <class T>
- void operator()(const CategoricalStops<T>& f) {
- writer.Key("type");
- writer.String("categorical");
- writer.Key("stops");
- stringifyStops(f.stops);
- }
-
- template <class T>
- void operator()(const IdentityStops<T>&) {
- writer.Key("type");
- writer.String("identity");
- }
-
- template <class T>
- void operator()(const CompositeExponentialStops<T>& f) {
- writer.Key("type");
- writer.String("exponential");
- writer.Key("base");
- writer.Double(f.base);
- writer.Key("stops");
- stringifyCompositeStops(f.stops);
- }
-
- template <class T>
- void operator()(const CompositeIntervalStops<T>& f) {
- writer.Key("type");
- writer.String("interval");
- writer.Key("stops");
- stringifyCompositeStops(f.stops);
- }
-
- template <class T>
- void operator()(const CompositeCategoricalStops<T>& f) {
- writer.Key("type");
- writer.String("categorical");
- writer.Key("stops");
- stringifyCompositeStops(f.stops);
- }
-
-private:
- template <class K, class V>
- void stringifyStops(const std::map<K, V>& stops) {
- writer.StartArray();
- for (const auto& stop : stops) {
- writer.StartArray();
- stringify(writer, stop.first);
- stringify(writer, stop.second);
- writer.EndArray();
- }
- writer.EndArray();
- }
-
- template <class InnerStops>
- void stringifyCompositeStops(const std::map<float, InnerStops>& stops) {
- writer.StartArray();
- for (const auto& outer : stops) {
- for (const auto& inner : outer.second) {
- writer.StartArray();
- writer.StartObject();
- writer.Key("zoom");
- writer.Double(outer.first);
- writer.Key("value");
- stringify(writer, inner.first);
- writer.EndObject();
- stringify(writer, inner.second);
- writer.EndArray();
- }
- }
- writer.EndArray();
- }
-};
-
template <class Writer, class T>
-void stringify(Writer& writer, const CameraFunction<T>& f) {
- writer.StartObject();
- CameraFunction<T>::Stops::visit(f.stops, StringifyStops<Writer> { writer });
- writer.EndObject();
+void stringify(Writer& writer, const CameraFunction<T>& fn) {
+ stringify(writer, fn.getExpression().serialize());
}
template <class Writer, class T>
-void stringify(Writer& writer, const SourceFunction<T>& f) {
- writer.StartObject();
- writer.Key("property");
- writer.String(f.property);
- SourceFunction<T>::Stops::visit(f.stops, StringifyStops<Writer> { writer });
- if (f.defaultValue) {
- writer.Key("default");
- stringify(writer, *f.defaultValue);
- }
- writer.EndObject();
+void stringify(Writer& writer, const SourceFunction<T>& fn) {
+ stringify(writer, fn.getExpression().serialize());
}
template <class Writer, class T>
-void stringify(Writer& writer, const CompositeFunction<T>& f) {
- writer.StartObject();
- writer.Key("property");
- writer.String(f.property);
- CompositeFunction<T>::Stops::visit(f.stops, StringifyStops<Writer> { writer });
- if (f.defaultValue) {
- writer.Key("default");
- stringify(writer, *f.defaultValue);
- }
- writer.EndObject();
+void stringify(Writer& writer, const CompositeFunction<T>& fn) {
+ stringify(writer, fn.getExpression().serialize());
}
template <class Writer, class T>