feat: add reporter

- add general reporter.
- fix various compile error.
This commit is contained in:
2024-08-04 17:43:18 +08:00
parent f179907a3a
commit d4a5e83a87
12 changed files with 158 additions and 162 deletions

View File

@@ -1,7 +1,41 @@
#include "GenericHelper.hpp"
#include <cstdarg>
namespace VSW {
Reporter::Reporter() {}
Reporter::~Reporter() {}
void Reporter::PrePrint(const YYCC::yycc_char8_t* strl) {}
#define GENERIC_REPORTER_WRITE(ty, data) YYCC::ConsoleHelper::Write(YYCC_U8("[" #ty "] ")); \
YYCC::ConsoleHelper::WriteLine(data);
#define GENERIC_REPORTER_FORMAT(ty, data) YYCC::ConsoleHelper::Write(YYCC_U8("[" #ty "] ")); \
va_list argptr; \
va_start(argptr, data); \
YYCC::ConsoleHelper::WriteLine(YYCC::StringHelper::VPrintf(data, argptr).c_str()); \
va_end(argptr);
void Reporter::Err(const YYCC::yycc_char8_t* strl) {
GENERIC_REPORTER_WRITE(Error, strl);
}
void Reporter::ErrF(const YYCC::yycc_char8_t* fmt, ...) {
GENERIC_REPORTER_FORMAT(Error ,fmt);
}
void Reporter::Warn(const YYCC::yycc_char8_t* strl) {
GENERIC_REPORTER_WRITE(Warning, strl);
}
void Reporter::WarnF(const YYCC::yycc_char8_t* fmt, ...) {
GENERIC_REPORTER_FORMAT(Warning ,fmt);
}
void Reporter::Info(const YYCC::yycc_char8_t* strl) {
GENERIC_REPORTER_WRITE(Info, strl);
}
void Reporter::InfoF(const YYCC::yycc_char8_t* fmt, ...) {
GENERIC_REPORTER_FORMAT(Info ,fmt);
}
#undef GENERIC_REPORTER_WRITE
#undef GENERIC_REPORTER_FORMAT
}