Libosmium
2.20.0
Fast and flexible C++ library for working with OpenStreetMap data
|
#include <tags_filter.hpp>
Public Types | |
using | iterator = osmium::memory::CollectionFilterIterator< TagsFilterBase, const osmium::Tag > |
Public Member Functions | |
TagsFilterBase (const TResult default_result=TResult{}) | |
void | set_default_result (const TResult default_result) noexcept |
TagsFilterBase & | add_rule (const TResult result, const TagMatcher &matcher) |
template<typename... TArgs> | |
TagsFilterBase & | add_rule (const TResult result, TArgs &&... args) |
TResult | operator() (const osmium::Tag &tag) const noexcept |
std::size_t | count () const noexcept |
bool | empty () const noexcept |
Private Attributes | |
std::vector< std::pair< TResult, TagMatcher > > | m_rules |
TResult | m_default_result |
A TagsFilterBase is a list of rules (defined using TagMatchers) to check tags against. The first rule that matches sets the result.
Usually you want to use the TagsFilter class, which is simply a specialization with TResult=bool. But TResult can be any class that has a default constructor and a conversion to bool. The class should be small, because it is copied around in some places.
Here is an example matching any "highway" tag except "highway=motorway":
Use this instead of the old osmium::tags::Filter.
using osmium::TagsFilterBase< TResult >::iterator = osmium::memory::CollectionFilterIterator<TagsFilterBase, const osmium::Tag> |
|
inlineexplicit |
Constructor.
default_result | The result the matching function will return if none of the rules matched. |
|
inline |
Add a rule to the filter.
result | The result returned when this rule matches. |
matcher | The TagMatcher for checking tags. |
|
inline |
Add a rule to the filter.
result | The result returned when this rule matches. |
args | Arguments to construct a TagMatcher from that is used for checking tags. |
|
inlinenoexcept |
Return the number of rules in this filter.
Complexity: Constant.
|
inlinenoexcept |
Is this filter empty, ie are there no rules defined?
Complexity: Constant.
|
inlinenoexcept |
Matching function. Check the specified tag against the rules.
tag | A tag. |
|
inlinenoexcept |
Set the default result, the result the matching function will return if none of the rules matched.
|
private |
|
private |