1
0

feat: add cli support for BMapInspector

This commit is contained in:
2026-01-31 11:28:03 +08:00
parent 103cb496a2
commit 8f5cc51de4
9 changed files with 418 additions and 136 deletions

View File

@@ -1,45 +1,29 @@
#pragma once
#include <yycc.hpp>
#include <yycc/macro/class_copy_move.hpp>
#include <string>
#include <cstdint>
#include <optional>
#include <string_view>
#include <vector>
#define PRIuSIZET "zu"
namespace BMapInspector::Utils {
enum class ReportKind { Error, Warning, Info };
#define PRIuSIZET "zu"
struct Report {
ReportKind kind; ///< The kind of this report.
std::u8string rule; ///< The name of rule adding this report.
std::u8string content; ///< The content of this report.
#define BMAPINSP_NAME "Ballance Map Inspector"
#define BMAPINSP_DESC "The inspector for checking whether your Ballance custom map can be loaded without any issues."
enum class ReportLevel : std::uint32_t {
Error = 0,
Warning = 1,
Info = 2,
};
class Reporter {
public:
Reporter();
~Reporter();
YYCC_DEFAULT_COPY_MOVE(Reporter)
std::optional<ReportLevel> ParseReportLevel(const std::u8string_view& value);
private:
void AddReport(ReportKind kind, const std::u8string_view& rule, const std::u8string_view& content);
public:
void WriteInfo(const std::u8string_view& rule, const std::u8string_view& content);
void FormatInfo(const std::u8string_view& rule, const char8_t* fmt, ...);
void WriteWarning(const std::u8string_view& rule, const std::u8string_view& content);
void FormatWarning(const std::u8string_view& rule, const char8_t* fmt, ...);
void WriteError(const std::u8string_view& rule, const std::u8string_view& content);
void FormatError(const std::u8string_view& rule, const char8_t* fmt, ...);
public:
void PrintConclusion() const;
void PrintReport() const;
private:
std::vector<Report> reports;
};
/**
* @brief Check whether given report level can pass given filter.
* @param[in] check The level for checking whether it can pass filter.
* @param[in] filter The level of filter.
* @return True if is can pass, otherwise false.
*/
bool FilterReportLevel(ReportLevel check, ReportLevel filter);
} // namespace BMapInspector::Utils