summaryrefslogtreecommitdiff
path: root/include/llmr
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-07-16 17:57:11 -0700
committerKonstantin Käfer <mail@kkaefer.com>2014-07-16 18:26:35 -0700
commita1d7da71c6f382258b2569020b50483958cfef0a (patch)
tree7c12b176c95482e622b302b62f39cf84d2ffefa1 /include/llmr
parentbecce08a32f0515a069d4aa26b61234d893d42ad (diff)
downloadqtlocation-mapboxgl-a1d7da71c6f382258b2569020b50483958cfef0a.tar.gz
add more comparison tests
Diffstat (limited to 'include/llmr')
-rw-r--r--include/llmr/map/vector_tile.hpp2
-rw-r--r--include/llmr/style/filter_expression.hpp25
-rw-r--r--include/llmr/style/filter_expression_private.hpp2
-rw-r--r--include/llmr/style/style_parser.hpp2
-rw-r--r--include/llmr/style/value_comparison.hpp9
5 files changed, 21 insertions, 19 deletions
diff --git a/include/llmr/map/vector_tile.hpp b/include/llmr/map/vector_tile.hpp
index ad7a0eea14..4a77f83172 100644
--- a/include/llmr/map/vector_tile.hpp
+++ b/include/llmr/map/vector_tile.hpp
@@ -46,7 +46,7 @@ public:
VectorTileTagExtractor(const VectorTileLayer &layer);
void setTags(const pbf &pbf);
- std::forward_list<Value> getValues(const std::string &key) const;
+ std::vector<Value> getValues(const std::string &key) const;
void setType(FilterExpression::GeometryType type);
FilterExpression::GeometryType getType() const;
diff --git a/include/llmr/style/filter_expression.hpp b/include/llmr/style/filter_expression.hpp
index 61e0fae3c8..97ba8c9719 100644
--- a/include/llmr/style/filter_expression.hpp
+++ b/include/llmr/style/filter_expression.hpp
@@ -4,10 +4,9 @@
#include <llmr/style/value.hpp>
#include <llmr/util/recursive_wrapper.hpp>
-#include <forward_list>
+#include <vector>
#include <string>
-#include <ostream>
-#include <iostream>
+#include <iosfwd>
namespace llmr {
@@ -26,20 +25,14 @@ public:
class Instance {
public:
- Instance(Operator op, std::forward_list<Value> &&values)
+ Instance(Operator op, std::vector<Value> &&values)
: op(op), values(values) {}
- bool compare(const Value &property_value) const;
- bool compare(const std::forward_list<Value> &property_values) const;
-
- private:
- template <typename Comparer> inline bool includes(const Value &property_value, const Comparer &comparer) const;
- template <typename Comparer> inline bool compare(const Value &property_value, const Comparer &comparer) const;
- template <typename Comparer> inline bool all(const std::forward_list<Value> &property_values, const Comparer &comparer) const;
+ bool compare(const std::vector<Value> &property_values) const;
private:
Operator op = Operator::Equal;
- std::forward_list<Value> values;
+ std::vector<Value> values;
friend std::ostream& operator <<(std::ostream &, const Instance &);
};
@@ -52,12 +45,12 @@ public:
template <typename ...Args>
inline void add(Args&& ...args) {
- instances.emplace_front(::std::forward<Args>(args)...);
+ instances.emplace_back(::std::forward<Args>(args)...);
}
private:
std::string field;
- std::forward_list<Instance> instances;
+ std::vector<Instance> instances;
friend std::ostream& operator <<(std::ostream &, const FilterComparison &);
};
@@ -101,8 +94,8 @@ public:
private:
Operator op = Operator::And;
GeometryType type = GeometryType::Any;
- std::forward_list<FilterComparison> comparisons;
- std::forward_list<FilterExpression::Wrapper> expressions;
+ std::vector<FilterComparison> comparisons;
+ std::vector<FilterExpression::Wrapper> expressions;
friend std::ostream& operator <<(std::ostream &, const FilterExpression &);
};
diff --git a/include/llmr/style/filter_expression_private.hpp b/include/llmr/style/filter_expression_private.hpp
index 9a1f9fed30..c21fcac085 100644
--- a/include/llmr/style/filter_expression_private.hpp
+++ b/include/llmr/style/filter_expression_private.hpp
@@ -7,7 +7,7 @@ namespace llmr {
template <typename Extractor>
inline bool FilterComparison::compare(const Extractor &extractor) const {
- const std::forward_list<Value> values = extractor.getValues(field);
+ const std::vector<Value> values = extractor.getValues(field);
// All instances are ANDed together.
for (const Instance &instance : instances) {
diff --git a/include/llmr/style/style_parser.hpp b/include/llmr/style/style_parser.hpp
index 38ef343e53..eb3b39eb04 100644
--- a/include/llmr/style/style_parser.hpp
+++ b/include/llmr/style/style_parser.hpp
@@ -91,7 +91,7 @@ private:
FilterExpression parseFilter(JSVal, FilterExpression::Operator op);
FilterExpression parseFilter(JSVal);
Value parseValue(JSVal value);
- std::forward_list<Value> parseValues(JSVal values);
+ std::vector<Value> parseValues(JSVal values);
private:
std::unordered_map<std::string, const rapidjson::Value *> constants;
diff --git a/include/llmr/style/value_comparison.hpp b/include/llmr/style/value_comparison.hpp
index d69142bc5b..4386fae595 100644
--- a/include/llmr/style/value_comparison.hpp
+++ b/include/llmr/style/value_comparison.hpp
@@ -51,6 +51,11 @@ struct relaxed_equal_operator {
inline bool operator()(T0 lhs, T1 rhs) const { return lhs == rhs; }
};
+struct relaxed_not_equal_operator {
+ template <typename T0, typename T1>
+ inline bool operator()(T0 lhs, T1 rhs) const { return lhs != rhs; }
+};
+
struct relaxed_greater_operator {
template <typename T0, typename T1>
inline bool operator()(T0 lhs, T1 rhs) const { return lhs > rhs; }
@@ -77,6 +82,10 @@ inline bool relaxed_equal(Value const &lhs, Value const &rhs) {
return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_equal_operator>(), lhs, rhs);
}
+inline bool relaxed_not_equal(Value const &lhs, Value const &rhs) {
+ return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_not_equal_operator>(), lhs, rhs);
+}
+
inline bool relaxed_greater(Value const &lhs, Value const &rhs) {
return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_greater_operator>(), lhs, rhs);
}