1 #ifndef OSMIUM_TAGS_FILTER_HPP
2 #define OSMIUM_TAGS_FILTER_HPP
37 #include <type_traits>
40 #include <boost/iterator/filter_iterator.hpp>
49 template <
typename TKey>
51 bool operator()(
const TKey& rule_key,
const char* tag_key) {
52 return rule_key == tag_key;
57 bool operator()(
const std::string& rule_key,
const char* tag_key) {
58 return rule_key.compare(0, std::string::npos, tag_key, 0, rule_key.size()) == 0;
62 template <
typename TValue>
64 bool operator()(
const TValue& rule_value,
const char* tag_value) {
65 return rule_value == tag_value;
76 template <
typename TKey,
typename TValue=
void,
typename TKeyComp=match_key<TKey>,
typename TValueComp=match_value<TValue>>
80 typedef typename std::conditional<std::is_void<TValue>::value, bool, TValue>
::type value_type;
88 explicit Rule(
bool r,
bool ignore,
const key_type& k,
const value_type& v) :
95 explicit Rule(
bool r,
bool ignore,
const key_type& k) :
112 typedef boost::filter_iterator<filter_type, osmium::TagList::const_iterator>
iterator;
114 explicit Filter(
bool default_result =
false) :
115 m_default_result(default_result) {
118 template <typename V=TValue, typename std::enable_if<!std::is_void<V>::value,
int>
::type = 0>
119 Filter&
add(
bool result,
const key_type& key,
const value_type& value) {
120 m_rules.emplace_back(result,
false, key, value);
125 m_rules.emplace_back(result,
true, key);
130 for (
const Rule& rule : m_rules) {
131 if (TKeyComp()(rule.key, tag.
key()) && (rule.ignore_value || TValueComp()(rule.value, tag.
value()))) {
142 return m_rules.count();
149 return m_rules.empty();
162 #endif // OSMIUM_TAGS_FILTER_HPP
type
Definition: entity_bits.hpp:60
const char * value() const
Definition: tag.hpp:83
const char * key() const noexcept
Definition: tag.hpp:79
Namespace for everything in the Osmium library.
Definition: assembler.hpp:59