1 #ifndef OSRM_EXTRACTOR_CLASSES_DATA_HPP
2 #define OSRM_EXTRACTOR_CLASSES_DATA_HPP
3 
4 #include "util/bit_range.hpp"
5 
6 #include <algorithm>
7 #include <cctype>
8 #include <cstdint>
9 
10 namespace osrm
11 {
12 namespace extractor
13 {
14 
15 using ClassData = std::uint8_t;
16 constexpr ClassData INAVLID_CLASS_DATA = std::numeric_limits<ClassData>::max();
17 static const std::uint8_t MAX_CLASS_INDEX = 8 - 1;
18 static const std::uint8_t MAX_EXCLUDABLE_CLASSES = 8;
19 
isSubset(const ClassData lhs,const ClassData rhs)20 inline bool isSubset(const ClassData lhs, const ClassData rhs) { return (lhs & rhs) == lhs; }
21 
getClassIndexes(const ClassData data)22 inline auto getClassIndexes(const ClassData data) { return util::makeBitRange<ClassData>(data); }
23 
getClassData(const std::size_t index)24 inline auto getClassData(const std::size_t index)
25 {
26     BOOST_ASSERT(index <= MAX_CLASS_INDEX);
27     return uint8_t{1} << index;
28 }
29 
isValidClassName(const std::string & name)30 inline bool isValidClassName(const std::string &name)
31 {
32     return std::find_if_not(name.begin(), name.end(), [](const auto c) {
33                return std::isalnum(c);
34            }) == name.end();
35 }
36 } // namespace extractor
37 } // namespace osrm
38 
39 #endif
40