拆分核心库和服务
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "adminive/adapter.hpp"
|
||||
#include "magic_enum/magic_enum.hpp"
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
namespace adminive {
|
||||
template <class Enum>
|
||||
requires std::is_enum_v<Enum>
|
||||
struct Enum_Adapter<Enum> {
|
||||
static std::vector<Enum> values() {
|
||||
const auto source = magic_enum::enum_values<Enum>();
|
||||
return std::vector<Enum>(source.begin(), source.end());
|
||||
}
|
||||
static std::string_view name(Enum value) {
|
||||
return magic_enum::enum_name(value);
|
||||
}
|
||||
static std::optional<Enum> cast(std::string_view value) {
|
||||
return magic_enum::enum_cast<Enum>(value);
|
||||
}
|
||||
static std::optional<Enum> cast(std::underlying_type_t<Enum> value) {
|
||||
return magic_enum::enum_cast<Enum>(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user