Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "utils/conversion.hpp" |
| 4 | |
| 5 | #include <array> |
| 6 | #include <cstdint> |
| 7 | #include <string_view> |
| 8 | |
| 9 | enum class OperationType : uint32_t |
| 10 | { |
| 11 | single, |
| 12 | max, |
| 13 | min, |
| 14 | avg, |
| 15 | sum |
| 16 | }; |
| 17 | |
| 18 | namespace utils |
| 19 | { |
| 20 | |
| 21 | constexpr std::array<std::pair<std::string_view, OperationType>, 5> |
| 22 | convDataOperationType = { |
| 23 | {std::make_pair<std::string_view, OperationType>("SINGLE", |
| 24 | OperationType::single), |
| 25 | std::make_pair<std::string_view, OperationType>("MAX", |
| 26 | OperationType::max), |
| 27 | std::make_pair<std::string_view, OperationType>("MIN", |
| 28 | OperationType::min), |
| 29 | std::make_pair<std::string_view, OperationType>("AVG", |
| 30 | OperationType::avg), |
| 31 | std::make_pair<std::string_view, OperationType>("SUM", |
| 32 | OperationType::sum)}}; |
| 33 | |
| 34 | inline OperationType |
| 35 | toOperationType(std::underlying_type_t<OperationType> value) |
| 36 | { |
| 37 | return toEnum<OperationType, OperationType::single, OperationType::sum>( |
| 38 | value); |
| 39 | } |
| 40 | |
| 41 | inline OperationType stringToOperationType(const std::string& value) |
| 42 | { |
| 43 | return stringToEnum(convDataOperationType, value); |
| 44 | } |
| 45 | |
| 46 | inline std::string enumToString(OperationType value) |
| 47 | { |
| 48 | return std::string(enumToString(convDataOperationType, value)); |
| 49 | } |
| 50 | |
| 51 | } // namespace utils |