1 #ifndef OSMIUM_VISITOR_HPP
2 #define OSMIUM_VISITOR_HPP
36 #include <type_traits>
53 template <
typename T,
typename U>
56 template <
typename THandler,
typename TItem>
57 inline void apply_item_recurse(TItem& item, THandler& handler) {
58 switch (item.type()) {
62 handler.osm_object(
static_cast<ConstIfConst<TItem, osmium::OSMObject>&
>(item));
63 handler.node(
static_cast<ConstIfConst<TItem, osmium::Node>&
>(item));
66 handler.osm_object(
static_cast<ConstIfConst<TItem, osmium::OSMObject>&
>(item));
67 handler.way(
static_cast<ConstIfConst<TItem, osmium::Way>&
>(item));
70 handler.osm_object(
static_cast<ConstIfConst<TItem, osmium::OSMObject>&
>(item));
71 handler.relation(
static_cast<ConstIfConst<TItem, osmium::Relation>&
>(item));
74 handler.osm_object(
static_cast<ConstIfConst<TItem, osmium::OSMObject>&
>(item));
75 handler.area(
static_cast<ConstIfConst<TItem, osmium::Area>&
>(item));
78 handler.changeset(
static_cast<ConstIfConst<TItem, osmium::Changeset>&
>(item));
81 handler.tag_list(
static_cast<ConstIfConst<TItem, osmium::TagList>&
>(item));
84 handler.way_node_list(
static_cast<ConstIfConst<TItem, osmium::WayNodeList>&
>(item));
88 handler.relation_member_list(
static_cast<ConstIfConst<TItem, osmium::RelationMemberList>&
>(item));
91 handler.outer_ring(
static_cast<ConstIfConst<TItem, osmium::OuterRing>&
>(item));
94 handler.inner_ring(
static_cast<ConstIfConst<TItem, osmium::InnerRing>&
>(item));
97 handler.changeset_discussion(
static_cast<ConstIfConst<TItem, osmium::ChangesetDiscussion>&
>(item));
102 template <
typename THandler>
103 inline void apply_item_recurse(
const osmium::OSMEntity& item, THandler& handler) {
104 switch (item.
type()) {
106 handler.osm_object(static_cast<const osmium::OSMObject&>(item));
107 handler.node(static_cast<const osmium::Node&>(item));
110 handler.osm_object(static_cast<const osmium::OSMObject&>(item));
111 handler.way(static_cast<const osmium::Way&>(item));
114 handler.osm_object(static_cast<const osmium::OSMObject&>(item));
115 handler.relation(static_cast<const osmium::Relation&>(item));
118 handler.osm_object(static_cast<const osmium::OSMObject&>(item));
119 handler.area(static_cast<const osmium::Area&>(item));
122 handler.changeset(static_cast<const osmium::Changeset&>(item));
129 template <
typename THandler>
131 switch (item.
type()) {
133 handler.osm_object(static_cast<osmium::OSMObject&>(item));
134 handler.node(static_cast<osmium::Node&>(item));
137 handler.osm_object(static_cast<osmium::OSMObject&>(item));
138 handler.way(static_cast<osmium::Way&>(item));
141 handler.osm_object(static_cast<osmium::OSMObject&>(item));
142 handler.relation(static_cast<osmium::Relation&>(item));
145 handler.osm_object(static_cast<osmium::OSMObject&>(item));
146 handler.area(static_cast<osmium::Area&>(item));
149 handler.changeset(static_cast<osmium::Changeset&>(item));
156 template <
typename THandler>
157 inline void apply_item_recurse(
const osmium::OSMObject& item, THandler& handler) {
158 switch (item.
type()) {
160 handler.osm_object(item);
161 handler.node(static_cast<const osmium::Node&>(item));
164 handler.osm_object(item);
165 handler.way(static_cast<const osmium::Way&>(item));
168 handler.osm_object(item);
169 handler.relation(static_cast<const osmium::Relation&>(item));
172 handler.osm_object(item);
173 handler.area(static_cast<const osmium::Area&>(item));
180 template <
typename THandler>
182 switch (item.
type()) {
184 handler.osm_object(item);
185 handler.node(static_cast<osmium::Node&>(item));
188 handler.osm_object(item);
189 handler.way(static_cast<osmium::Way&>(item));
192 handler.osm_object(item);
193 handler.relation(static_cast<osmium::Relation&>(item));
196 handler.osm_object(item);
197 handler.area(static_cast<osmium::Area&>(item));
204 template <
typename THandler,
typename TItem,
typename... TRest>
205 inline void apply_item_recurse(TItem& item, THandler& handler, TRest&... more) {
206 apply_item_recurse(item, handler);
207 apply_item_recurse(item, more...);
210 template <
typename THandler>
211 inline void flush_recurse(THandler& handler) {
215 template <
typename THandler,
typename... TRest>
216 inline void flush_recurse(THandler& handler, TRest&... more) {
217 flush_recurse(handler);
218 flush_recurse(more...);
223 template <
typename... THandlers>
225 detail::apply_item_recurse(item, handlers...);
228 template <
typename... THandlers>
230 detail::apply_item_recurse(item, handlers...);
233 template <
typename TIterator,
typename... THandlers>
234 inline void apply(TIterator it, TIterator
end, THandlers&... handlers) {
235 for (; it !=
end; ++it) {
236 detail::apply_item_recurse(*it, handlers...);
238 detail::flush_recurse(handlers...);
241 template <
typename TContainer,
typename... THandlers>
242 inline void apply(TContainer& c, THandlers&... handlers) {
246 template <
typename... THandlers>
253 #endif // OSMIUM_VISITOR_HPP
t_const_iterator< T > cend() const
Definition: buffer.hpp:626
Definition: item_type.hpp:198
type
Definition: entity_bits.hpp:60
OSMEntity is the abstract base class for the OSMObject and Changeset classes.
Definition: entity.hpp:64
void apply(TIterator it, TIterator end, THandlers &...handlers)
Definition: visitor.hpp:234
void apply_item(const osmium::memory::Item &item, THandlers &...handlers)
Definition: visitor.hpp:224
Namespace for everything in the Osmium library.
Definition: assembler.hpp:59
osmium::io::InputIterator< osmium::io::Reader > end(osmium::io::Reader &)
Definition: reader_iterator.hpp:45
Definition: buffer.hpp:97
t_const_iterator< T > cbegin() const
Definition: buffer.hpp:604
osmium::io::InputIterator< osmium::io::Reader > begin(osmium::io::Reader &reader)
Definition: reader_iterator.hpp:41
item_type type() const noexcept
Definition: item.hpp:155
Definition: object.hpp:58