Krzysztof Grobelny | 973b4bb | 2022-04-25 17:07:27 +0200 | [diff] [blame] | 1 | #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 | |
| 12 | enum class ErrorType : uint32_t |
| 13 | { |
| 14 | propertyConflict |
| 15 | }; |
| 16 | |
| 17 | namespace utils |
| 18 | { |
| 19 | |
| 20 | constexpr auto convDataErrorType = |
| 21 | std::array{std::make_pair<std::string_view, ErrorType>( |
| 22 | "PropertyConflict", ErrorType::propertyConflict)}; |
| 23 | |
| 24 | inline ErrorType toErrorType(std::underlying_type_t<ErrorType> value) |
| 25 | { |
| 26 | return toEnum<ErrorType, minEnumValue(convDataErrorType), |
| 27 | maxEnumValue(convDataErrorType)>(value); |
| 28 | } |
| 29 | |
| 30 | inline ErrorType toErrorType(const std::string& value) |
| 31 | { |
| 32 | return toEnum(convDataErrorType, value); |
| 33 | } |
| 34 | |
| 35 | inline std::string enumToString(ErrorType value) |
| 36 | { |
| 37 | return std::string(enumToString(convDataErrorType, value)); |
| 38 | } |
| 39 | |
| 40 | } // namespace utils |