2017-06-27 18:01:05 -04:00
|
|
|
#ifndef OSRM_EXTRACTOR_CLASSES_DATA_HPP
|
|
|
|
#define OSRM_EXTRACTOR_CLASSES_DATA_HPP
|
|
|
|
|
|
|
|
#include "util/bit_range.hpp"
|
|
|
|
|
2017-08-18 17:42:05 -04:00
|
|
|
#include <algorithm>
|
|
|
|
#include <cctype>
|
2017-06-27 18:01:05 -04:00
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
|
|
|
|
using ClassData = std::uint8_t;
|
2017-07-28 05:49:49 -04:00
|
|
|
constexpr ClassData INAVLID_CLASS_DATA = std::numeric_limits<ClassData>::max();
|
2017-06-27 18:01:05 -04:00
|
|
|
static const std::uint8_t MAX_CLASS_INDEX = 8 - 1;
|
2017-08-16 16:21:19 -04:00
|
|
|
static const std::uint8_t MAX_EXCLUDABLE_CLASSES = 8;
|
2017-06-27 18:01:05 -04:00
|
|
|
|
|
|
|
inline bool isSubset(const ClassData lhs, const ClassData rhs) { return (lhs & rhs) == lhs; }
|
|
|
|
|
|
|
|
inline auto getClassIndexes(const ClassData data) { return util::makeBitRange<ClassData>(data); }
|
2017-07-21 17:55:19 -04:00
|
|
|
|
|
|
|
inline auto getClassData(const std::size_t index)
|
|
|
|
{
|
|
|
|
BOOST_ASSERT(index <= MAX_CLASS_INDEX);
|
|
|
|
return uint8_t{1} << index;
|
|
|
|
}
|
2017-08-18 17:42:05 -04:00
|
|
|
|
|
|
|
inline bool isValidClassName(const std::string &name)
|
|
|
|
{
|
|
|
|
return std::find_if_not(name.begin(), name.end(), [](const auto c) {
|
|
|
|
return std::isalnum(c);
|
|
|
|
}) == name.end();
|
|
|
|
}
|
2020-11-26 10:21:39 -05:00
|
|
|
} // namespace extractor
|
|
|
|
} // namespace osrm
|
2017-06-27 18:01:05 -04:00
|
|
|
|
|
|
|
#endif
|