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) {
|
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) {
|
if (!stream) {
|
||||||
Util::panic("Could not open archive! Are you sure it's an archive?");
|
Util::panic("Could not open archive! Are you sure it's an archive?");
|
||||||
|
|||||||
@@ -17,73 +17,73 @@ static constexpr auto globalLogLevel = Info;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <LogLevel messageType = Info, typename... Args>
|
template <LogLevel messageType = Info, typename... Args>
|
||||||
constexpr void print(const std::string &fmt, Args... args) {
|
void print(const std::string &fmt, Args... args) {
|
||||||
if constexpr (messageType >= globalLogLevel) {
|
if (messageType >= globalLogLevel) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if constexpr (messageType == Error) {
|
if (messageType == Error) {
|
||||||
fmt::print(fmt::emphasis::bold | fg(fmt::color::red), fmt, args...);
|
fmt::print(fmt::emphasis::bold | fg(fmt::color::red), fmt::runtime(fmt), args...);
|
||||||
} else if constexpr (messageType == Warn) {
|
} else if (messageType == Warn) {
|
||||||
fmt::print(fg(fmt::color::yellow), fmt, args...);
|
fmt::print(fg(fmt::color::yellow), fmt::runtime(fmt), args...);
|
||||||
} else if constexpr (messageType == Info || messageType == Trace || messageType == Always) {
|
} else if (messageType == Info || messageType == Trace || messageType == Always) {
|
||||||
fmt::print(fmt, args...);
|
fmt::print(fmt::runtime(fmt), args...);
|
||||||
} else if constexpr (messageType == Debug) {
|
} else if (messageType == Debug) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
fmt::print(fmt, args...);
|
fmt::print(fmt::runtime(fmt), args...);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if constexpr (messageType == Debug) {
|
if (messageType == Debug) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
fmt::print(fmt, args...);
|
fmt::print(fmt::runtime(fmt), args...);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
fmt::print(fmt, args...);
|
fmt::print(fmt::runtime(fmt), args...);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
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...);
|
print<Error>("[FATAL] " + fmt + "\n", args...);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
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...);
|
print<Error>("[ERROR] " + fmt + "\n", args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... 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...);
|
print<Warn>("[WARN] " + fmt + "\n", args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... 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...);
|
print("[INFO] " + fmt + "\n", args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... 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...);
|
print<Debug>("[DEBUG] " + fmt + "\n", args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... 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...);
|
print<Trace>("[TRACE] " + fmt + "\n", args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... 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...);
|
print<Always>(fmt + "\n", args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... 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)
|
#if !defined(NDEBUG) && !defined(_WIN32)
|
||||||
Dl_info info;
|
Dl_info info;
|
||||||
auto tmp = fmt::format(fmt + '\n', args...);
|
auto tmp = fmt::format(fmt::runtime(fmt + '\n'), args...);
|
||||||
tmp += "Called by:\n";
|
tmp += "Called by:\n";
|
||||||
if (dladdr(__builtin_return_address(0), &info))
|
if (dladdr(__builtin_return_address(0), &info))
|
||||||
tmp += fmt::format("\t-> {}\n", info.dli_sname);
|
tmp += fmt::format("\t-> {}\n", info.dli_sname);
|
||||||
|
|||||||
Reference in New Issue
Block a user