2026-01-30 20:23:39 +08:00
|
|
|
#include "Utils.hpp"
|
2026-01-31 11:28:03 +08:00
|
|
|
#include <yycc.hpp>
|
|
|
|
|
#include <yycc/cenum.hpp>
|
2026-01-30 20:23:39 +08:00
|
|
|
|
|
|
|
|
namespace BMapInspector::Utils {
|
|
|
|
|
|
2026-01-31 11:28:03 +08:00
|
|
|
std::optional<ReportLevel> ParseReportLevel(const std::u8string_view &value) {
|
|
|
|
|
if (value == u8"error") return ReportLevel::Error;
|
|
|
|
|
else if (value == u8"warning") return ReportLevel::Warning;
|
|
|
|
|
else if (value == u8"info") return ReportLevel::Info;
|
|
|
|
|
return std::nullopt;
|
2026-01-30 20:23:39 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-31 11:28:03 +08:00
|
|
|
bool FilterReportLevel(ReportLevel check, ReportLevel filter) {
|
|
|
|
|
auto num_check = yycc::cenum::integer(check);
|
|
|
|
|
auto num_filter = yycc::cenum::integer(filter);
|
|
|
|
|
return num_check <= num_filter;
|
2026-01-30 20:23:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace BMapInspector::Utils
|