2024-08-03 17:11:34 +08:00
|
|
|
#include "GenericHelper.hpp"
|
2024-08-04 17:43:18 +08:00
|
|
|
#include <cstdarg>
|
2024-08-03 17:11:34 +08:00
|
|
|
|
|
|
|
|
namespace VSW {
|
|
|
|
|
|
2024-08-04 17:43:18 +08:00
|
|
|
Reporter::Reporter() {}
|
|
|
|
|
Reporter::~Reporter() {}
|
2024-08-03 17:11:34 +08:00
|
|
|
|
2024-08-06 18:06:17 +08:00
|
|
|
void Reporter::PrePrint(const YYCC::yycc_char8_t* strl) const {}
|
2024-08-04 17:43:18 +08:00
|
|
|
|
2024-08-09 16:19:26 +08:00
|
|
|
#define GENERIC_REPORTER_WRITE(ty, data) YYCC::yycc_u8string cache(YYCC_U8("[" #ty "] ")); \
|
|
|
|
|
cache += data; \
|
|
|
|
|
this->PrePrint(cache.c_str()); \
|
|
|
|
|
YYCC::ConsoleHelper::WriteLine(cache.c_str());
|
|
|
|
|
#define GENERIC_REPORTER_FORMAT(ty, data) va_list argptr; \
|
2024-08-04 17:43:18 +08:00
|
|
|
va_start(argptr, data); \
|
2024-08-09 16:19:26 +08:00
|
|
|
YYCC::yycc_u8string cache(YYCC::StringHelper::VPrintf(data, argptr)); \
|
|
|
|
|
cache.insert(0u, YYCC_U8("[" #ty "] ")); \
|
|
|
|
|
this->PrePrint(cache.c_str()); \
|
|
|
|
|
YYCC::ConsoleHelper::WriteLine(cache.c_str()); \
|
2024-08-04 17:43:18 +08:00
|
|
|
va_end(argptr);
|
|
|
|
|
|
2024-08-06 18:06:17 +08:00
|
|
|
void Reporter::Err(const YYCC::yycc_char8_t* strl) const {
|
2024-08-04 17:43:18 +08:00
|
|
|
GENERIC_REPORTER_WRITE(Error, strl);
|
|
|
|
|
}
|
2024-08-06 18:06:17 +08:00
|
|
|
void Reporter::ErrF(const YYCC::yycc_char8_t* fmt, ...) const {
|
2024-08-04 17:43:18 +08:00
|
|
|
GENERIC_REPORTER_FORMAT(Error ,fmt);
|
|
|
|
|
}
|
2024-08-06 18:06:17 +08:00
|
|
|
void Reporter::Warn(const YYCC::yycc_char8_t* strl) const {
|
2024-08-04 17:43:18 +08:00
|
|
|
GENERIC_REPORTER_WRITE(Warning, strl);
|
|
|
|
|
}
|
2024-08-06 18:06:17 +08:00
|
|
|
void Reporter::WarnF(const YYCC::yycc_char8_t* fmt, ...) const {
|
2024-08-04 17:43:18 +08:00
|
|
|
GENERIC_REPORTER_FORMAT(Warning ,fmt);
|
|
|
|
|
}
|
2024-08-06 18:06:17 +08:00
|
|
|
void Reporter::Info(const YYCC::yycc_char8_t* strl) const {
|
2024-08-04 17:43:18 +08:00
|
|
|
GENERIC_REPORTER_WRITE(Info, strl);
|
|
|
|
|
}
|
2024-08-06 18:06:17 +08:00
|
|
|
void Reporter::InfoF(const YYCC::yycc_char8_t* fmt, ...) const {
|
2024-08-04 17:43:18 +08:00
|
|
|
GENERIC_REPORTER_FORMAT(Info ,fmt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef GENERIC_REPORTER_WRITE
|
|
|
|
|
#undef GENERIC_REPORTER_FORMAT
|
2024-08-03 17:11:34 +08:00
|
|
|
|
|
|
|
|
}
|