Update to C++20
This commit is contained in:
@@ -87,7 +87,7 @@ FORCE_INLINE void SetROMCIC(u32 checksum, ROM &rom) {
|
||||
}
|
||||
|
||||
std::vector<u8> Mem::OpenArchive(const std::string &path, size_t &sizeAdjusted) {
|
||||
auto stream = ar_open_file(fs::path(path).u8string().c_str());
|
||||
auto stream = ar_open_file(fs::path(path).c_str());
|
||||
|
||||
if (!stream) {
|
||||
Util::panic("Could not open archive! Are you sure it's an archive?");
|
||||
|
||||
@@ -17,73 +17,73 @@ static constexpr auto globalLogLevel = Info;
|
||||
#endif
|
||||
|
||||
template <LogLevel messageType = Info, typename... Args>
|
||||
constexpr void print(const std::string &fmt, Args... args) {
|
||||
if constexpr (messageType >= globalLogLevel) {
|
||||
void print(const std::string &fmt, Args... args) {
|
||||
if (messageType >= globalLogLevel) {
|
||||
#ifndef _WIN32
|
||||
if constexpr (messageType == Error) {
|
||||
fmt::print(fmt::emphasis::bold | fg(fmt::color::red), fmt, args...);
|
||||
} else if constexpr (messageType == Warn) {
|
||||
fmt::print(fg(fmt::color::yellow), fmt, args...);
|
||||
} else if constexpr (messageType == Info || messageType == Trace || messageType == Always) {
|
||||
fmt::print(fmt, args...);
|
||||
} else if constexpr (messageType == Debug) {
|
||||
if (messageType == Error) {
|
||||
fmt::print(fmt::emphasis::bold | fg(fmt::color::red), fmt::runtime(fmt), args...);
|
||||
} else if (messageType == Warn) {
|
||||
fmt::print(fg(fmt::color::yellow), fmt::runtime(fmt), args...);
|
||||
} else if (messageType == Info || messageType == Trace || messageType == Always) {
|
||||
fmt::print(fmt::runtime(fmt), args...);
|
||||
} else if (messageType == Debug) {
|
||||
#ifndef NDEBUG
|
||||
fmt::print(fmt, args...);
|
||||
fmt::print(fmt::runtime(fmt), args...);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
if constexpr (messageType == Debug) {
|
||||
if (messageType == Debug) {
|
||||
#ifndef NDEBUG
|
||||
fmt::print(fmt, args...);
|
||||
fmt::print(fmt::runtime(fmt), args...);
|
||||
#endif
|
||||
} else {
|
||||
fmt::print(fmt, args...);
|
||||
fmt::print(fmt::runtime(fmt), args...);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
constexpr void panic(const std::string &fmt, Args... args) {
|
||||
void panic(const std::string &fmt, Args... args) {
|
||||
print<Error>("[FATAL] " + fmt + "\n", args...);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
constexpr void error(const std::string &fmt, Args... args) {
|
||||
void error(const std::string &fmt, Args... args) {
|
||||
print<Error>("[ERROR] " + fmt + "\n", args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
constexpr void warn(const std::string &fmt, Args... args) {
|
||||
void warn(const std::string &fmt, Args... args) {
|
||||
print<Warn>("[WARN] " + fmt + "\n", args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
constexpr void info(const std::string &fmt, Args... args) {
|
||||
void info(const std::string &fmt, Args... args) {
|
||||
print("[INFO] " + fmt + "\n", args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
constexpr void debug(const std::string &fmt, Args... args) {
|
||||
void debug(const std::string &fmt, Args... args) {
|
||||
print<Debug>("[DEBUG] " + fmt + "\n", args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
constexpr void trace(const std::string &fmt, Args... args) {
|
||||
void trace(const std::string &fmt, Args... args) {
|
||||
print<Trace>("[TRACE] " + fmt + "\n", args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
constexpr void always(const std::string &fmt, Args... args) {
|
||||
void always(const std::string &fmt, Args... args) {
|
||||
print<Always>(fmt + "\n", args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
constexpr void panic_trace(const std::string &fmt, Args... args) {
|
||||
void panic_trace(const std::string &fmt, Args... args) {
|
||||
#if !defined(NDEBUG) && !defined(_WIN32)
|
||||
Dl_info info;
|
||||
auto tmp = fmt::format(fmt + '\n', args...);
|
||||
auto tmp = fmt::format(fmt::runtime(fmt + '\n'), args...);
|
||||
tmp += "Called by:\n";
|
||||
if (dladdr(__builtin_return_address(0), &info))
|
||||
tmp += fmt::format("\t-> {}\n", info.dli_sname);
|
||||
|
||||
Reference in New Issue
Block a user