blob: a35728d874232e54b84c996c28f66736eacbc877 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#ifndef MBGL_LAYOUT_PROPERTY
#define MBGL_LAYOUT_PROPERTY
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/style/function.hpp>
#include <mbgl/util/rapidjson.hpp>
#include <utility>
namespace mbgl {
template <typename T>
class LayoutProperty {
public:
explicit LayoutProperty(T v) : value(std::move(v)) {}
void parse(const char * name, const JSValue& layout) {
if (layout.HasMember(name)) {
parsedValue = parseProperty<Function<T>>(name, layout[name]);
}
}
void calculate(const StyleCalculationParameters& parameters) {
if (parsedValue) {
value = (*parsedValue).evaluate(parameters);
}
}
void operator=(const T& v) { value = v; }
operator T() const { return value; }
optional<Function<T>> parsedValue;
T value;
};
} // namespace mbgl
#endif
|