summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layout_property.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-10-26 10:14:24 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-11-10 11:33:17 -0800
commita5625675890213f94de7632d4ef152ade627c9a5 (patch)
treed6a3f816e80417bbedc16d0b34383d8ee191bf92 /src/mbgl/style/layout_property.hpp
parent728a9858ea88751e74de57694746c2ea1546ce25 (diff)
downloadqtlocation-mapboxgl-a5625675890213f94de7632d4ef152ade627c9a5.tar.gz
[core] Eliminate use of ClassProperties for layout
Diffstat (limited to 'src/mbgl/style/layout_property.hpp')
-rw-r--r--src/mbgl/style/layout_property.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mbgl/style/layout_property.hpp b/src/mbgl/style/layout_property.hpp
new file mode 100644
index 0000000000..5f24e5b133
--- /dev/null
+++ b/src/mbgl/style/layout_property.hpp
@@ -0,0 +1,38 @@
+#ifndef MBGL_LAYOUT_PROPERTY
+#define MBGL_LAYOUT_PROPERTY
+
+#include <mbgl/style/property_parsing.hpp>
+#include <mbgl/style/function.hpp>
+
+#include <rapidjson/document.h>
+
+namespace mbgl {
+
+using JSVal = rapidjson::Value;
+
+template <typename T>
+class LayoutProperty {
+public:
+ LayoutProperty(T v) : value(v) {}
+
+ void parse(const char * name, const JSVal& layout) {
+ if (layout.HasMember(name)) {
+ parsedValue = detail::parseProperty<Function<T>>(name, layout[name]);
+ }
+ }
+
+ void calculate(const StyleCalculationParameters& parameters) {
+ if (parsedValue) {
+ value = (*parsedValue).evaluate(parameters);
+ }
+ }
+
+ operator T() const { return value; }
+
+ mapbox::util::optional<Function<T>> parsedValue;
+ T value;
+};
+
+}
+
+#endif