Loading...
Searching...
No Matches
entity_bits.hpp
Go to the documentation of this file.
#ifndef OSMIUM_OSM_ENTITY_BITS_HPP
#define OSMIUM_OSM_ENTITY_BITS_HPP
/*
This file is part of Osmium (https://osmcode.org/libosmium).
Copyright 2013-2026 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <osmium/osm/item_type.hpp>
#include <cassert>
#include <type_traits>
namespace osmium {
namespace osm_entity_bits {
// NOLINTBEGIN(clang-analyzer-optin.core.EnumCastOutOfRange)
enum type : unsigned char { // this should have been an enum class
// but now we can't change it any more
// without breaking lots of code
nothing = 0x00,
node = 0x01,
way = 0x02,
nw = 0x03,
relation = 0x04,
nr = 0x05,
wr = 0x06,
nwr = 0x07,
area = 0x08,
na = 0x09,
wa = 0x0a,
nwa = 0x0b,
ra = 0x0c,
nra = 0x0d,
wra = 0x0e,
nwra = 0x0f,
object = 0x0f,
changeset = 0x10,
all = 0x1f
}; // enum type
constexpr type operator|(const type lhs, const type rhs) noexcept {
return static_cast<type>(static_cast<unsigned char>(lhs) | static_cast<unsigned char>(rhs));
}
constexpr type operator&(const type lhs, const type rhs) noexcept {
return static_cast<type>(static_cast<unsigned char>(lhs) & static_cast<unsigned char>(rhs));
}
constexpr type operator~(const type value) noexcept {
return all & static_cast<type>(~static_cast<unsigned char>(value));
}
inline type& operator|=(type& lhs, const type rhs) noexcept {
lhs = lhs | rhs;
return lhs;
}
inline type operator&=(type& lhs, const type rhs) noexcept {
lhs = lhs & rhs;
return lhs;
}
inline type from_item_type(osmium::item_type item_type) noexcept {
const auto ut = static_cast<std::underlying_type_t<osmium::item_type>>(item_type);
assert(ut <= 0x05);
if (ut == 0) {
return nothing;
}
return static_cast<osmium::osm_entity_bits::type>(1U << (ut - 1U));
}
// NOLINTEND(clang-analyzer-optin.core.EnumCastOutOfRange)
} // namespace osm_entity_bits
} // namespace osmium
#endif // OSMIUM_OSM_ENTITY_BITS_HPP
item_type.hpp
osmium::osm_entity_bits
Bit field for OSM entity types.
Definition entity_bits.hpp:46
osmium::osm_entity_bits::operator|=
type & operator|=(type &lhs, const type rhs) noexcept
Definition entity_bits.hpp:103
osmium::osm_entity_bits::operator&=
type operator&=(type &lhs, const type rhs) noexcept
Definition entity_bits.hpp:108
osmium::osm_entity_bits::type
type
Definition entity_bits.hpp:65
osmium::osm_entity_bits::nw
@ nw
node or way object
Definition entity_bits.hpp:72
osmium::osm_entity_bits::ra
@ ra
relation or area object
Definition entity_bits.hpp:81
osmium::osm_entity_bits::node
@ node
Definition entity_bits.hpp:70
osmium::osm_entity_bits::changeset
@ changeset
Definition entity_bits.hpp:86
osmium::osm_entity_bits::wa
@ wa
way or area object
Definition entity_bits.hpp:79
osmium::osm_entity_bits::wra
@ wra
way, relation or area object
Definition entity_bits.hpp:83
osmium::osm_entity_bits::nra
@ nra
node, relation or area object
Definition entity_bits.hpp:82
osmium::osm_entity_bits::all
@ all
object or changeset
Definition entity_bits.hpp:87
osmium::osm_entity_bits::nwa
@ nwa
node, way or area object
Definition entity_bits.hpp:80
osmium::osm_entity_bits::nwr
@ nwr
node, way, or relation object
Definition entity_bits.hpp:76
osmium::osm_entity_bits::nwra
@ nwra
node, way, relation, or area object
Definition entity_bits.hpp:84
osmium::osm_entity_bits::relation
@ relation
Definition entity_bits.hpp:73
osmium::osm_entity_bits::wr
@ wr
way or relation object
Definition entity_bits.hpp:75
osmium::osm_entity_bits::area
@ area
Definition entity_bits.hpp:77
osmium::osm_entity_bits::nothing
@ nothing
Definition entity_bits.hpp:69
osmium::osm_entity_bits::way
@ way
Definition entity_bits.hpp:71
osmium::osm_entity_bits::na
@ na
node or area object
Definition entity_bits.hpp:78
osmium::osm_entity_bits::nr
@ nr
node or relation object
Definition entity_bits.hpp:74
osmium::osm_entity_bits::operator|
constexpr type operator|(const type lhs, const type rhs) noexcept
Definition entity_bits.hpp:91
osmium::osm_entity_bits::operator~
constexpr type operator~(const type value) noexcept
Definition entity_bits.hpp:99
osmium::osm_entity_bits::operator&
constexpr type operator&(const type lhs, const type rhs) noexcept
Definition entity_bits.hpp:95
osmium::osm_entity_bits::from_item_type
type from_item_type(osmium::item_type item_type) noexcept
Definition entity_bits.hpp:119
osmium
Namespace for everything in the Osmium library.
Definition assembler.hpp:53
osmium::item_type
item_type
Definition item_type.hpp:45