Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "utils/conversion.hpp" |
| 4 | |
| 5 | #include <array> |
| 6 | #include <cstdint> |
| 7 | #include <string_view> |
| 8 | #include <type_traits> |
| 9 | |
| 10 | enum class CollectionTimeScope : uint32_t |
| 11 | { |
| 12 | point, |
| 13 | interval, |
| 14 | startup |
| 15 | }; |
| 16 | |
| 17 | namespace utils |
| 18 | { |
| 19 | |
| 20 | constexpr std::array<std::pair<std::string_view, CollectionTimeScope>, 3> |
| 21 | convDataCollectionTimeScope = { |
| 22 | {std::make_pair<std::string_view, CollectionTimeScope>( |
| 23 | "Point", CollectionTimeScope::point), |
| 24 | std::make_pair<std::string_view, CollectionTimeScope>( |
| 25 | "Interval", CollectionTimeScope::interval), |
| 26 | std::make_pair<std::string_view, CollectionTimeScope>( |
| 27 | "StartupInterval", CollectionTimeScope::startup)}}; |
| 28 | |
| 29 | inline CollectionTimeScope |
| 30 | toCollectionTimeScope(std::underlying_type_t<CollectionTimeScope> value) |
| 31 | { |
| 32 | return toEnum<CollectionTimeScope, CollectionTimeScope::point, |
| 33 | CollectionTimeScope::startup>(value); |
| 34 | } |
| 35 | |
| 36 | inline CollectionTimeScope stringToCollectionTimeScope(const std::string& value) |
| 37 | { |
| 38 | return stringToEnum(convDataCollectionTimeScope, value); |
| 39 | } |
| 40 | |
| 41 | inline std::string enumToString(CollectionTimeScope value) |
| 42 | { |
| 43 | return std::string(enumToString(convDataCollectionTimeScope, value)); |
| 44 | } |
| 45 | |
| 46 | } // namespace utils |