mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 13:16:23 +00:00
refactor(Core/Misc): Acore::StringFormat to fmt format (#19838)
refactor(Core/Utilities): Acore::StringFormat to fmt format * closes https://github.com/azerothcore/azerothcore-wotlk/issues/10356
This commit is contained in:
@@ -26,27 +26,12 @@
|
||||
|
||||
namespace Acore
|
||||
{
|
||||
/// Default AC string format function.
|
||||
template<typename Format, typename... Args>
|
||||
inline std::string StringFormat(Format&& fmt, Args&& ... args)
|
||||
{
|
||||
try
|
||||
{
|
||||
return fmt::sprintf(std::forward<Format>(fmt), std::forward<Args>(args)...);
|
||||
}
|
||||
catch (const fmt::format_error& formatError)
|
||||
{
|
||||
std::string error = "An error occurred formatting string \"" + std::string(fmt) + "\" : " + std::string(formatError.what());
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
using FormatString = fmt::format_string<Args...>;
|
||||
|
||||
// Default string format function.
|
||||
/// Default AC string format function.
|
||||
template<typename... Args>
|
||||
inline std::string StringFormatFmt(FormatString<Args...> fmt, Args&&... args)
|
||||
inline std::string StringFormat(FormatString<Args...> fmt, Args&&... args)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -86,27 +86,27 @@ AC_COMMON_API std::string Acore::Time::ToTimeString<Microseconds>(uint64 duratio
|
||||
{
|
||||
if (days)
|
||||
{
|
||||
return Acore::StringFormatFmt("{}:{:02}:{:02}:{:02}:{:02}:{:02}", days, hours, minutes, secs, millisecs);
|
||||
return Acore::StringFormat("{}:{:02}:{:02}:{:02}:{:02}:{:02}", days, hours, minutes, secs, millisecs);
|
||||
}
|
||||
else if (hours)
|
||||
{
|
||||
return Acore::StringFormatFmt("{}:{:02}:{:02}:{:02}:{:02}", hours, minutes, secs, millisecs);
|
||||
return Acore::StringFormat("{}:{:02}:{:02}:{:02}:{:02}", hours, minutes, secs, millisecs);
|
||||
}
|
||||
else if (minutes)
|
||||
{
|
||||
return Acore::StringFormatFmt("{}:{:02}:{:02}:{:02}", minutes, secs, millisecs);
|
||||
return Acore::StringFormat("{}:{:02}:{:02}:{:02}", minutes, secs, millisecs);
|
||||
}
|
||||
else if (secs)
|
||||
{
|
||||
return Acore::StringFormatFmt("{}:{:02}:{:02}", secs, millisecs);
|
||||
return Acore::StringFormat("{}:{:02}:{:02}", secs, millisecs);
|
||||
}
|
||||
else if (millisecs)
|
||||
{
|
||||
return Acore::StringFormatFmt("{}:{:02}", millisecs);
|
||||
return Acore::StringFormat("{}:{:02}", millisecs);
|
||||
}
|
||||
else // microsecs
|
||||
{
|
||||
return Acore::StringFormatFmt("{}", microsecs);
|
||||
return Acore::StringFormat("{}", microsecs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user