refactor(zebin decoder): parsing enums

This commit simplifies parsing of enums in zebin decoder and removes
unnecessary tests.

Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
This commit is contained in:
Krystian Chmielewski
2022-08-09 18:46:36 +00:00
committed by Compute-Runtime-Automation
parent 7b86c8da2e
commit 9bd2c7da2b
7 changed files with 224 additions and 653 deletions

View File

@@ -10,6 +10,7 @@
#include "shared/source/helpers/debug_helpers.h"
#include <array>
#include <optional>
#include <utility>
template <typename KeyT, typename ValueT, size_t NumElements>
@@ -17,13 +18,23 @@ struct LookupArray {
using LookupMapArrayT = std::array<std::pair<KeyT, ValueT>, NumElements>;
constexpr LookupArray(const LookupMapArrayT &lookupArray) : lookupArray(lookupArray){};
constexpr ValueT lookUp(const KeyT &keyToFind) const {
constexpr std::optional<ValueT> find(const KeyT &keyToFind) const {
for (auto &[key, value] : lookupArray) {
if (keyToFind == key) {
return value;
}
}
UNRECOVERABLE_IF(true);
return std::nullopt;
}
constexpr ValueT lookUp(const KeyT &keyToFind) const {
auto value = find(keyToFind);
UNRECOVERABLE_IF(false == value.has_value());
return *value;
}
constexpr size_t size() const {
return NumElements;
}
protected: