Libosmium  2.8.0
Fast and flexible C++ library for working with OpenStreetMap data
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 (http://osmcode.org/libosmium).
7 
8 Copyright 2013-2016 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 <cassert>
37 #include <type_traits>
38 
39 #include <osmium/osm/item_type.hpp>
40 
41 namespace osmium {
42 
46  namespace osm_entity_bits {
47 
63  enum type : unsigned char {
64 
65  nothing = 0x00,
66  node = 0x01,
67  way = 0x02,
68  relation = 0x04,
69  nwr = 0x07,
70  area = 0x08,
71  nwra = 0x0f,
72  object = 0x0f,
73  changeset = 0x10,
74  all = 0x1f
75 
76  }; // enum type
77 
78  inline type operator|(const type lhs, const type rhs) noexcept {
79  return static_cast<type>(static_cast<int>(lhs) | static_cast<int> (rhs));
80  }
81 
82  inline type& operator|=(type& lhs, const type rhs) noexcept {
83  lhs = lhs | rhs;
84  return lhs;
85  }
86 
87  inline type operator&(const type lhs, const type rhs) noexcept {
88  return static_cast<type>(static_cast<int>(lhs) & static_cast<int> (rhs));
89  }
90 
91  inline type operator~(const type value) noexcept {
92  return static_cast<type>(~static_cast<int>(value));
93  }
94 
95  inline type operator&=(type& lhs, const type rhs) noexcept {
96  lhs = lhs & rhs;
97  return lhs;
98  }
99 
108  assert(ut <= 0x05);
109  if (ut == 0) {
110  return nothing;
111  }
112  return static_cast<osmium::osm_entity_bits::type>(0x1 << (ut - 1));
113  }
114 
115  } // namespace osm_entity_bits
116 
117 } // namespace osmium
118 
119 #endif // OSMIUM_OSM_ENTITY_BITS_HPP
type
Definition: entity_bits.hpp:63
item_type
Definition: item_type.hpp:43
Definition: entity_bits.hpp:70
Definition: entity_bits.hpp:73
object or changeset
Definition: entity_bits.hpp:74
type from_item_type(osmium::item_type item_type) noexcept
Definition: entity_bits.hpp:106
Definition: entity_bits.hpp:67
node, way, or relation object
Definition: entity_bits.hpp:69
Namespace for everything in the Osmium library.
Definition: assembler.hpp:66
type operator&=(type &lhs, const type rhs) noexcept
Definition: entity_bits.hpp:95
type operator&(const type lhs, const type rhs) noexcept
Definition: entity_bits.hpp:87
type operator|(const type lhs, const type rhs) noexcept
Definition: entity_bits.hpp:78
Definition: entity_bits.hpp:66
node, way, relation, or area object
Definition: entity_bits.hpp:71
Definition: entity_bits.hpp:65
type & operator|=(type &lhs, const type rhs) noexcept
Definition: entity_bits.hpp:82
Definition: entity_bits.hpp:68
type operator~(const type value) noexcept
Definition: entity_bits.hpp:91