Libosmium 2.22.0 Fast and flexible C++ library for working with OpenStreetMap data

Loading...
Searching...
No Matches
entity_bits.hpp
Go to the documentation of this file.
1#ifndef OSMIUM_OSM_ENTITY_BITS_HPP
2#define OSMIUM_OSM_ENTITY_BITS_HPP
3
4/*
5
6 This file is part of Osmium (https://osmcode.org/libosmium).
7
8 Copyright 2013-2025 Jochen Topf <jochen@topf.org> and others (see README).
9
10 Boost Software License - Version 1.0 - August 17th, 2003
11
12 Permission is hereby granted, free of charge, to any person or organization
13 obtaining a copy of the software and accompanying documentation covered by
14 this license (the "Software") to use, reproduce, display, distribute,
15 execute, and transmit the Software, and to prepare derivative works of the
16 Software, and to permit third-parties to whom the Software is furnished to
17 do so, all subject to the following:
18
19 The copyright notices in the Software and this entire statement, including
20 the above license grant, this restriction and the following disclaimer,
21 must be included in all copies of the Software, in whole or in part, and
22 all derivative works of the Software, unless such copies or derivative
23 works are solely in the form of machine-executable object code generated by
24 a source language processor.
25
26 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
29 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
30 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
31 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 DEALINGS IN THE SOFTWARE.
33
34*/
35
36#include <osmium/osm/item_type.hpp>
37
38#include <cassert>
39#include <type_traits>
40
41 namespace osmium {
42
46 namespace osm_entity_bits {
47
63 enum type : unsigned char { // this should have been an enum class
64 // but now we can't change it any more
65 // without breaking lots of code
66
67 nothing = 0x00,
68 node = 0x01,
69 way = 0x02,
70 nw = 0x03,
71 relation = 0x04,
72 nr = 0x05,
73 wr = 0x06,
74 nwr = 0x07,
75 area = 0x08,
76 na = 0x09,
77 wa = 0x0a,
78 nwa = 0x0b,
79 ra = 0x0c,
80 nra = 0x0d,
81 wra = 0x0e,
82 nwra = 0x0f,
83 object = 0x0f,
84 changeset = 0x10,
85 all = 0x1f
86
87 }; // enum type
88
89 constexpr type operator|(const type lhs, const type rhs) noexcept {
90 return static_cast<type>(static_cast<unsigned char>(lhs) | static_cast<unsigned char>(rhs));
91 }
92
93 constexpr type operator&(const type lhs, const type rhs) noexcept {
94 return static_cast<type>(static_cast<unsigned char>(lhs) & static_cast<unsigned char>(rhs));
95 }
96
97 constexpr type operator~(const type value) noexcept {
98 return all & static_cast<type>(~static_cast<unsigned char>(value));
99 }
100
101 inline type& operator|=(type& lhs, const type rhs) noexcept {
102 lhs = lhs | rhs;
103 return lhs;
104 }
105
106 inline type operator&=(type& lhs, const type rhs) noexcept {
107 lhs = lhs & rhs;
108 return lhs;
109 }
110
117 inline type from_item_type(osmium::item_type item_type) noexcept {
118 const auto ut = static_cast<std::underlying_type_t<osmium::item_type>>(item_type);
119 assert(ut <= 0x05);
120 if (ut == 0) {
121 return nothing;
122 }
123 return static_cast<osmium::osm_entity_bits::type>(1U << (ut - 1U));
124 }
125
126 } // namespace osm_entity_bits
127
128} // namespace osmium
129
130#endif // OSMIUM_OSM_ENTITY_BITS_HPP
item_type.hpp
osmium::osm_entity_bits::operator|=
type & operator|=(type &lhs, const type rhs) noexcept
Definition entity_bits.hpp:101
osmium::osm_entity_bits::operator&=
type operator&=(type &lhs, const type rhs) noexcept
Definition entity_bits.hpp:106
osmium::osm_entity_bits::type
type
Definition entity_bits.hpp:63
osmium::osm_entity_bits::nw
@ nw
node or way object
Definition entity_bits.hpp:70
osmium::osm_entity_bits::ra
@ ra
relation or area object
Definition entity_bits.hpp:79
osmium::osm_entity_bits::node
@ node
Definition entity_bits.hpp:68
osmium::osm_entity_bits::changeset
@ changeset
Definition entity_bits.hpp:84
osmium::osm_entity_bits::wa
@ wa
way or area object
Definition entity_bits.hpp:77
osmium::osm_entity_bits::wra
@ wra
way, relation or area object
Definition entity_bits.hpp:81
osmium::osm_entity_bits::nra
@ nra
node, relation or area object
Definition entity_bits.hpp:80
osmium::osm_entity_bits::all
@ all
object or changeset
Definition entity_bits.hpp:85
osmium::osm_entity_bits::nwa
@ nwa
node, way or area object
Definition entity_bits.hpp:78
osmium::osm_entity_bits::nwr
@ nwr
node, way, or relation object
Definition entity_bits.hpp:74
osmium::osm_entity_bits::nwra
@ nwra
node, way, relation, or area object
Definition entity_bits.hpp:82
osmium::osm_entity_bits::relation
@ relation
Definition entity_bits.hpp:71
osmium::osm_entity_bits::wr
@ wr
way or relation object
Definition entity_bits.hpp:73
osmium::osm_entity_bits::area
@ area
Definition entity_bits.hpp:75
osmium::osm_entity_bits::nothing
@ nothing
Definition entity_bits.hpp:67
osmium::osm_entity_bits::way
@ way
Definition entity_bits.hpp:69
osmium::osm_entity_bits::na
@ na
node or area object
Definition entity_bits.hpp:76
osmium::osm_entity_bits::nr
@ nr
node or relation object
Definition entity_bits.hpp:72
osmium::osm_entity_bits::operator|
constexpr type operator|(const type lhs, const type rhs) noexcept
Definition entity_bits.hpp:89
osmium::osm_entity_bits::operator~
constexpr type operator~(const type value) noexcept
Definition entity_bits.hpp:97
osmium::osm_entity_bits::operator&
constexpr type operator&(const type lhs, const type rhs) noexcept
Definition entity_bits.hpp:93
osmium::osm_entity_bits::from_item_type
type from_item_type(osmium::item_type item_type) noexcept
Definition entity_bits.hpp:117
osmium
Namespace for everything in the Osmium library.
Definition assembler.hpp:53
osmium::item_type
item_type
Definition item_type.hpp:45