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