SlHelpers
Loading...
Searching...
No Matches
SupportedConf.h
1// SPDX-License-Identifier: GPL-2.0-only
2
3#pragma once
4
5#include <string>
6#include <string_view>
7#include <utility>
8#include <vector>
9
10#include "../helpers/Enum.h"
11
12namespace SlKernCVS {
13
14#define SUPPORT_STATE(X) \
15 X(NonPresent, -3) \
16 X(Unsupported, -2) \
17 X(UnsupportedOptional, -1) \
18 X(Unspecified, 0) \
19 X(Supported, 1) \
20 X(BaseSupported, 2) \
21 X(ExternallySupported, 3) \
22 X(KMPSupported, 4)
23
25enum class SupportState {
26#define EXP(x, v) x = v,
27 SUPPORT_STATE(EXP)
28#undef EXP
29 First = NonPresent,
30 Last = KMPSupported,
31};
32
34static constexpr std::string_view getName(SupportState ss) noexcept {
35 switch (ss) {
36#define EXP(x, v) case SupportState::x: return #x;
37 SUPPORT_STATE(EXP)
38#undef EXP
39 }
40 return "INVALID";
41}
42
43#undef SUPPORT_STATE
44
46using SupportStateRange = SlHelpers::EnumRange<SupportState>;
47
51class SupportedConf {
52public:
53 SupportedConf() = delete;
54
59 SupportedConf(std::string_view conf);
60
66 SupportState supportState(const std::string &module) const;
67private:
68 void parseLine(std::string_view line) noexcept;
69
70 std::vector<std::pair<std::string, SupportState>> entries;
71};
72
73}
SupportState supportState(const std::string &module) const
Find supported state of module.
SupportedConf(std::string_view conf)
Parse conf and store.