blob: ae2dd4ba356f5255b64b2cd03414d1039aaae8bc [file] [log] [blame]
Krzysztof Grobelny973b4bb2022-04-25 17:07:27 +02001#pragma once
2
3#include "utils/conversion.hpp"
4
5#include <sdbusplus/exception.hpp>
6
7#include <array>
8#include <cstdint>
9#include <string_view>
10#include <type_traits>
11
12enum class ErrorType : uint32_t
13{
14 propertyConflict
15};
16
17namespace utils
18{
19
Krzysztof Grobelny62c08e92022-09-16 10:28:53 +020020template <>
21struct EnumTraits<ErrorType>
22{
23 static constexpr auto propertyName = ConstexprString{"ErrorType"};
24};
25
Patrick Williams3a1c2972023-05-10 07:51:04 -050026constexpr auto convDataErrorType = std::array{
27 std::make_pair<std::string_view, ErrorType>("PropertyConflict",
28 ErrorType::propertyConflict)};
Krzysztof Grobelny973b4bb2022-04-25 17:07:27 +020029
30inline ErrorType toErrorType(std::underlying_type_t<ErrorType> value)
31{
32 return toEnum<ErrorType, minEnumValue(convDataErrorType),
33 maxEnumValue(convDataErrorType)>(value);
34}
35
36inline ErrorType toErrorType(const std::string& value)
37{
38 return toEnum(convDataErrorType, value);
39}
40
41inline std::string enumToString(ErrorType value)
42{
43 return std::string(enumToString(convDataErrorType, value));
44}
45
46} // namespace utils