blob: 5665e79ef40ea0127562ca640b1b4641c0465730 [file] [log] [blame]
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +00001#pragma once
2
3#include "utils/conversion.hpp"
4
5#include <array>
6#include <cstdint>
7#include <string_view>
8
9enum class OperationType : uint32_t
10{
11 single,
12 max,
13 min,
14 avg,
15 sum
16};
17
18namespace utils
19{
20
21constexpr 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
34inline OperationType
35 toOperationType(std::underlying_type_t<OperationType> value)
36{
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010037 return toEnum<OperationType, minEnumValue(convDataOperationType),
38 maxEnumValue(convDataOperationType)>(value);
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000039}
40
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010041inline OperationType toOperationType(const std::string& value)
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000042{
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010043 return toEnum(convDataOperationType, value);
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000044}
45
46inline std::string enumToString(OperationType value)
47{
48 return std::string(enumToString(convDataOperationType, value));
49}
50
51} // namespace utils