diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-06-01 00:01:22 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-06-02 11:14:09 +0200 |
commit | 99b6a700ef8e3bedd6cc0aae189026eabb3e9c93 (patch) | |
tree | 5db91b1e09199fcfae7a825d3123d7d38ed601fb | |
parent | 1d3d0bd85ccd54a1bb8a5f05121189e47d600789 (diff) | |
download | qtlocation-mapboxgl-99b6a700ef8e3bedd6cc0aae189026eabb3e9c93.tar.gz |
move both variant options to recursive_wrapper
-rw-r--r-- | include/llmr/map/filter_expression.hpp | 11 | ||||
-rw-r--r-- | src/map/vector_tile.cpp | 4 | ||||
-rw-r--r-- | src/style/style_parser.cpp | 18 |
3 files changed, 18 insertions, 15 deletions
diff --git a/include/llmr/map/filter_expression.hpp b/include/llmr/map/filter_expression.hpp index d536a5a34b..0748a63fcd 100644 --- a/include/llmr/map/filter_expression.hpp +++ b/include/llmr/map/filter_expression.hpp @@ -43,9 +43,15 @@ inline ExpressionOperator expressionOperatorType(const std::string &op) { } - +class PropertyFilter; class PropertyExpression; +typedef util::variant< + util::recursive_wrapper<PropertyFilter>, + util::recursive_wrapper<PropertyExpression> +> PropertyFilterExpression; + + class PropertyFilter { public: inline PropertyFilter(const std::string &field, FilterOperator op, const Value &value) : field(field), op(op), value(value) {}; @@ -80,9 +86,6 @@ public: Value value; }; -typedef util::variant<PropertyFilter, util::recursive_wrapper<PropertyExpression>> PropertyFilterExpression; - - class PropertyExpression { public: inline PropertyExpression() {} diff --git a/src/map/vector_tile.cpp b/src/map/vector_tile.cpp index 0e96cccd1d..b30b997e7a 100644 --- a/src/map/vector_tile.cpp +++ b/src/map/vector_tile.cpp @@ -123,8 +123,8 @@ FilteredVectorTileLayer::iterator::iterator(const FilteredVectorTileLayer& paren } bool FilteredVectorTileLayer::iterator::matchesFilterExpression(const PropertyFilterExpression &filterExpression, const pbf &tags_pbf) { - if (filterExpression.is<PropertyFilter>()) { - return matchesFilter(filterExpression.get<PropertyFilter>(), tags_pbf); + if (filterExpression.is<util::recursive_wrapper<PropertyFilter>>()) { + return matchesFilter(filterExpression.get<util::recursive_wrapper<PropertyFilter>>().get(), tags_pbf); } else if (filterExpression.is<util::recursive_wrapper<PropertyExpression>>()) { return matchesExpression(filterExpression.get<util::recursive_wrapper<PropertyExpression>>().get(), tags_pbf); } else { diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 18b2ab3af0..c774d0fca3 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -23,17 +23,17 @@ void StyleParser::parseBuckets(JSVal value, std::map<std::string, BucketDescript PropertyFilterExpression StyleParser::parseFilterOrExpression(JSVal value) { if (value.IsArray()) { // This is an expression. - PropertyExpression expression; + util::recursive_wrapper<PropertyExpression> expression; for (rapidjson::SizeType i = 0; i < value.Size(); ++i) { JSVal filter_item = value[i]; if (filter_item.IsString()) { - expression.op = expressionOperatorType({ filter_item.GetString(), filter_item.GetStringLength() }); + expression.get().op = expressionOperatorType({ filter_item.GetString(), filter_item.GetStringLength() }); } else { - expression.operands.emplace_back(parseFilterOrExpression(filter_item)); + expression.get().operands.emplace_back(parseFilterOrExpression(filter_item)); } } - return util::recursive_wrapper<PropertyExpression>(std::move(expression)); + return std::move(expression); } else if (value.IsObject() && value.HasMember("field") && value.HasMember("value")) { // This is a filter. JSVal field = value["field"]; @@ -55,19 +55,19 @@ PropertyFilterExpression StyleParser::parseFilterOrExpression(JSVal value) { if (val.IsArray()) { // The filter has several values, so it's an OR sub-expression. - PropertyExpression expression; + util::recursive_wrapper<PropertyExpression> expression; for (rapidjson::SizeType i = 0; i < val.Size(); ++i) { - expression.operands.emplace_back(PropertyFilter { field_name, op, parseValue(val[i]) }); + expression.get().operands.emplace_back(util::recursive_wrapper<PropertyFilter>(PropertyFilter { field_name, op, parseValue(val[i]) })); } - return util::recursive_wrapper<PropertyExpression>(std::move(expression)); + return std::move(expression); } else { // The filter only has a single value, so it is a real filter. - return PropertyFilter { field_name, op, parseValue(val) }; + return std::move(util::recursive_wrapper<PropertyFilter>(PropertyFilter { field_name, op, parseValue(val) })); } } - return util::recursive_wrapper<PropertyExpression>(); + return std::move(util::recursive_wrapper<PropertyExpression>()); } BucketDescription StyleParser::parseBucket(JSVal value) { |