summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers/layer.cpp.ejs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/layers/layer.cpp.ejs')
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index 0cd9a82d75..04d4a81dce 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -190,23 +190,26 @@ TransitionOptions <%- camelize(type) %>Layer::get<%- camelize(property.name) %>T
using namespace conversion;
-optional<Error> <%- camelize(type) %>Layer::setPaintProperty(const std::string& name, const Convertible& value) {
- enum class Property {
+namespace {
+
+enum class Property {
<% for (const property of paintProperties) { -%>
- <%- camelize(property.name) %>,
+ <%- camelize(property.name) %>,
<% } -%>
<% for (const property of paintProperties) { -%>
- <%- camelize(property.name) %>Transition,
+ <%- camelize(property.name) %>Transition,
<% } -%>
- };
+};
- MAPBOX_ETERNAL_CONSTEXPR const auto properties = mapbox::eternal::hash_map<mapbox::eternal::string, uint8_t>({
- <%- paintProperties.map(p => `{ "${p.name}", mbgl::underlying_type(Property::${camelize(p.name)}) }`).join(',\n ') %>,
- <%- paintProperties.map(p => `{ "${p.name}-transition", mbgl::underlying_type(Property::${camelize(p.name)}Transition) }`).join(',\n ') %>
- });
+MAPBOX_ETERNAL_CONSTEXPR const auto paintProperties = mapbox::eternal::hash_map<mapbox::eternal::string, uint8_t>(
+ {<%- paintProperties.map(p => `{"${p.name}", mbgl::underlying_type(Property::${camelize(p.name)})}`).join(',\n ') %>,
+ <%- paintProperties.map(p => `{"${p.name}-transition", mbgl::underlying_type(Property::${camelize(p.name)}Transition)}`).join(',\n ') %>});
- const auto it = properties.find(name.c_str());
- if (it == properties.end()) {
+} // namespace
+
+optional<Error> <%- camelize(type) %>Layer::setPaintProperty(const std::string& name, const Convertible& value) {
+ const auto it = paintProperties.find(name.c_str());
+ if (it == paintProperties.end()) {
return Error { "layer doesn't support this property" };
}
@@ -258,6 +261,25 @@ optional<Error> <%- camelize(type) %>Layer::setPaintProperty(const std::string&
return Error { "layer doesn't support this property" };
}
+LayerProperty <%- camelize(type) %>Layer::getPaintProperty(const std::string& name) const {
+ const auto it = paintProperties.find(name.c_str());
+ if (it == paintProperties.end()) {
+ return {};
+ }
+
+ switch (static_cast<Property>(it->second)) {
+<% for (const property of paintProperties) { -%>
+ case Property::<%- camelize(property.name) %>:
+ return conversion::makeLayerProperty(get<%- camelize(property.name) %>());
+<% } -%>
+<% for (const property of paintProperties) { -%>
+ case Property::<%- camelize(property.name) %>Transition:
+ return conversion::makeLayerProperty(get<%- camelize(property.name) %>Transition());
+<% } -%>
+ }
+ return {};
+}
+
optional<Error> <%- camelize(type) %>Layer::setLayoutProperty(const std::string& name, const Convertible& value) {
if (name == "visibility") {
return Layer::setVisibility(value);