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:
Kitzunu 2024-09-03 12:59:37 +02:00 committed by GitHub
parent f6fd978a7a
commit de2bcbdabf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 100 additions and 115 deletions

View File

@ -62,12 +62,12 @@ def isPAppend(line):
else :
return False
# def isStringFormat(line):
# substring = 'StringFormat'
# if substring in line:
# return True
# else :
# return False
def isStringFormat(line):
substring = 'StringFormat'
if substring in line:
return True
else :
return False
def haveDelimeter(line):
if ';' in line:
@ -96,8 +96,8 @@ def checkSoloLine(line):
# return handleCleanup(line), False
# elif isPSendSysMessage(line):
# return handleCleanup(line), False
# elif isStringFormat(line):
# return handleCleanup(line), False
elif isStringFormat(line):
return handleCleanup(line), False
else:
return line, False
@ -122,8 +122,8 @@ def startMultiLine(line):
elif isPAppend(line):
line = line.replace("PAppend", "Append");
return handleCleanup(line), True
# elif isStringFormat(line):
# return handleCleanup(line), True
elif isStringFormat(line):
return handleCleanup(line), True
else :
return line, False

View File

@ -21,7 +21,7 @@
void Acore::Banner::Show(std::string_view applicationName, void(*log)(std::string_view text), void(*logExtraInfo)())
{
log(Acore::StringFormatFmt("{} ({})", GitRevision::GetFullVersion(), applicationName));
log(Acore::StringFormat("{} ({})", GitRevision::GetFullVersion(), applicationName));
log("<Ctrl-C> to stop.\n");
log(" █████╗ ███████╗███████╗██████╗ ██████╗ ████████╗██╗ ██╗");
log(" ██╔══██╗╚══███╔╝██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝██║ ██║");

View File

@ -85,7 +85,7 @@ namespace MMAP
}
// load and init dtNavMesh - read parameters from file
std::string fileName = Acore::StringFormat(MAP_FILE_NAME_FORMAT, sConfigMgr->GetOption<std::string>("DataDir", ".").c_str(), mapId);
std::string fileName = Acore::StringFormat(MAP_FILE_NAME_FORMAT, sConfigMgr->GetOption<std::string>("DataDir", "."), mapId);
FILE* file = fopen(fileName.c_str(), "rb");
if (!file)
@ -146,7 +146,7 @@ namespace MMAP
}
// load this tile :: mmaps/MMMXXYY.mmtile
std::string fileName = Acore::StringFormat(TILE_FILE_NAME_FORMAT, sConfigMgr->GetOption<std::string>("DataDir", ".").c_str(), mapId, x, y);
std::string fileName = Acore::StringFormat(TILE_FILE_NAME_FORMAT, sConfigMgr->GetOption<std::string>("DataDir", "."), mapId, x, y);
FILE* file = fopen(fileName.c_str(), "rb");
if (!file)
{

View File

@ -65,7 +65,7 @@ namespace
template<typename Format, typename... Args>
inline void PrintError(std::string_view filename, Format&& fmt, Args&& ... args)
{
std::string message = Acore::StringFormatFmt(std::forward<Format>(fmt), std::forward<Args>(args)...);
std::string message = Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...);
if (IsAppConfig(filename))
{
@ -117,7 +117,7 @@ namespace
return false;
}
throw ConfigException(Acore::StringFormatFmt("Config::LoadFile: Failed open {}file '{}'", isOptional ? "optional " : "", file));
throw ConfigException(Acore::StringFormat("Config::LoadFile: Failed open {}file '{}'", isOptional ? "optional " : "", file));
}
uint32 count = 0;
@ -144,7 +144,7 @@ namespace
// read line error
if (!in.good() && !in.eof())
throw ConfigException(Acore::StringFormatFmt("> Config::LoadFile: Failure to read line number {} in file '{}'", lineNumber, file));
throw ConfigException(Acore::StringFormat("> Config::LoadFile: Failure to read line number {} in file '{}'", lineNumber, file));
// remove whitespace in line
line = Acore::String::Trim(line, in.getloc());
@ -187,7 +187,7 @@ namespace
return false;
}
throw ConfigException(Acore::StringFormatFmt("Config::LoadFile: Empty file '{}'", file));
throw ConfigException(Acore::StringFormat("Config::LoadFile: Empty file '{}'", file));
}
// Add correct keys if file load without errors

View File

@ -62,19 +62,19 @@ namespace
inline std::string MakeMessage(std::string_view messageType, std::string_view file, uint32 line, std::string_view function,
std::string_view message, std::string_view fmtMessage = {}, std::string_view debugInfo = {})
{
std::string msg = Acore::StringFormatFmt("\n>> {}\n\n# Location: {}:{}\n# Function: {}\n# Condition: {}\n", messageType, file, line, function, message);
std::string msg = Acore::StringFormat("\n>> {}\n\n# Location: {}:{}\n# Function: {}\n# Condition: {}\n", messageType, file, line, function, message);
if (!fmtMessage.empty())
{
msg.append(Acore::StringFormatFmt("# Message: {}\n", fmtMessage));
msg.append(Acore::StringFormat("# Message: {}\n", fmtMessage));
}
if (!debugInfo.empty())
{
msg.append(Acore::StringFormatFmt("\n# Debug info: {}\n", debugInfo));
msg.append(Acore::StringFormat("\n# Debug info: {}\n", debugInfo));
}
return Acore::StringFormatFmt(
return Acore::StringFormat(
"#{0:-^{2}}#\n"
" {1: ^{2}} \n"
"#{0:-^{2}}#\n", "", msg, 70);
@ -90,14 +90,14 @@ namespace
*/
inline std::string MakeAbortMessage(std::string_view file, uint32 line, std::string_view function, std::string_view fmtMessage = {})
{
std::string msg = Acore::StringFormatFmt("\n>> ABORTED\n\n# Location '{}:{}'\n# Function '{}'\n", file, line, function);
std::string msg = Acore::StringFormat("\n>> ABORTED\n\n# Location '{}:{}'\n# Function '{}'\n", file, line, function);
if (!fmtMessage.empty())
{
msg.append(Acore::StringFormatFmt("# Message '{}'\n", fmtMessage));
msg.append(Acore::StringFormat("# Message '{}'\n", fmtMessage));
}
return Acore::StringFormatFmt(
return Acore::StringFormat(
"\n#{0:-^{2}}#\n"
" {1: ^{2}} \n"
"#{0:-^{2}}#\n", "", msg, 70);
@ -148,7 +148,7 @@ void Acore::Abort(std::string_view file, uint32 line, std::string_view function,
void Acore::AbortHandler(int sigval)
{
// nothing useful to log here, no way to pass args
std::string formattedMessage = StringFormatFmt("Caught signal {}\n", sigval);
std::string formattedMessage = StringFormat("Caught signal {}\n", sigval);
fmt::print(stderr, "{}", formattedMessage);
fflush(stderr);
Crash(formattedMessage.c_str());

View File

@ -31,19 +31,19 @@ namespace Acore
template<typename... Args>
AC_COMMON_API inline void Assert(std::string_view file, uint32 line, std::string_view function, std::string_view debugInfo, std::string_view message, std::string_view fmt, Args&&... args)
{
Assert(file, line, function, debugInfo, message, StringFormatFmt(fmt, std::forward<Args>(args)...));
Assert(file, line, function, debugInfo, message, StringFormat(fmt, std::forward<Args>(args)...));
}
template<typename... Args>
AC_COMMON_API inline void Fatal(std::string_view file, uint32 line, std::string_view function, std::string_view message, std::string_view fmt, Args&&... args)
{
Fatal(file, line, function, message, StringFormatFmt(fmt, std::forward<Args>(args)...));
Fatal(file, line, function, message, StringFormat(fmt, std::forward<Args>(args)...));
}
template<typename... Args>
AC_COMMON_API inline void Abort(std::string_view file, uint32 line, std::string_view function, std::string_view fmt, Args&&... args)
{
Abort(file, line, function, StringFormatFmt(fmt, std::forward<Args>(args)...));
Abort(file, line, function, StringFormat(fmt, std::forward<Args>(args)...));
}
AC_COMMON_API void Warning(std::string_view file, uint32 line, std::string_view function, std::string_view message);

View File

@ -52,7 +52,7 @@ void AppenderConsole::InitColors(std::string const& name, std::string_view str)
std::vector<std::string_view> colorStrs = Acore::Tokenize(str, ' ', false);
if (colorStrs.size() != NUM_ENABLED_LOG_LEVELS)
{
throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Invalid color data '{}' for console appender {} (expected {} entries, got {})",
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid color data '{}' for console appender {} (expected {} entries, got {})",
str, name, NUM_ENABLED_LOG_LEVELS, colorStrs.size()));
}
@ -64,7 +64,7 @@ void AppenderConsole::InitColors(std::string const& name, std::string_view str)
}
else
{
throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Invalid color '{}' for log level {} on console appender {}",
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid color '{}' for log level {} on console appender {}",
colorStrs[i], EnumUtils::ToTitle(static_cast<LogLevel>(i)), name));
}
}

View File

@ -31,7 +31,7 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap
{
if (args.size() < 4)
{
throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Missing file name for appender {}", name));
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Missing file name for appender {}", name));
}
_fileName.assign(args[3]);
@ -63,7 +63,7 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap
}
else
{
throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Invalid size '{}' for appender {}", args[5], name));
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid size '{}' for appender {}", args[5], name));
}
}

View File

@ -69,7 +69,7 @@ public:
template<typename... Args>
inline void outMessage(std::string const& filter, LogLevel const level, Acore::FormatString<Args...> fmt, Args&&... args)
{
_outMessage(filter, level, Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
_outMessage(filter, level, Acore::StringFormat(fmt, std::forward<Args>(args)...));
}
template<typename... Args>
@ -80,7 +80,7 @@ public:
return;
}
_outCommand(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...), std::to_string(account));
_outCommand(Acore::StringFormat(fmt, std::forward<Args>(args)...), std::to_string(account));
}
void SetRealmId(uint32 id);

View File

@ -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
{

View File

@ -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);
}
}

View File

@ -103,7 +103,7 @@ public:
if (sql.empty())
return;
Execute(Acore::StringFormatFmt(sql, std::forward<Args>(args)...));
Execute(Acore::StringFormat(sql, std::forward<Args>(args)...));
}
//! Enqueues a one-way SQL operation in prepared statement format that will be executed asynchronously.
@ -126,7 +126,7 @@ public:
if (sql.empty())
return;
DirectExecute(Acore::StringFormatFmt(sql, std::forward<Args>(args)...));
DirectExecute(Acore::StringFormat(sql, std::forward<Args>(args)...));
}
//! Directly executes a one-way SQL operation in prepared statement format, that will block the calling thread until finished.
@ -149,7 +149,7 @@ public:
if (sql.empty())
return QueryResult(nullptr);
return Query(Acore::StringFormatFmt(sql, std::forward<Args>(args)...));
return Query(Acore::StringFormat(sql, std::forward<Args>(args)...));
}
//! Directly executes an SQL query in prepared format that will block the calling thread until finished.

View File

@ -104,7 +104,7 @@ bool PreparedStatementTask::Execute()
template<typename T>
std::string PreparedStatementData::ToString(T value)
{
return Acore::StringFormatFmt("{}", value);
return Acore::StringFormat("{}", value);
}
template<>

View File

@ -45,7 +45,7 @@ public:
template<typename... Args>
void Append(std::string_view sql, Args&&... args)
{
Append(Acore::StringFormatFmt(sql, std::forward<Args>(args)...));
Append(Acore::StringFormat(sql, std::forward<Args>(args)...));
}
[[nodiscard]] std::size_t GetSize() const { return m_queries.size(); }

View File

@ -235,7 +235,7 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool, std::string_view modulesL
auto CheckUpdateTable = [&](std::string const& tableName)
{
auto checkTable = DBUpdater<T>::Retrieve(pool, Acore::StringFormatFmt("SHOW TABLES LIKE '{}'", tableName));
auto checkTable = DBUpdater<T>::Retrieve(pool, Acore::StringFormat("SHOW TABLES LIKE '{}'", tableName));
if (!checkTable)
{
LOG_WARN("sql.updates", "> Table '{}' not exist! Try add based table", tableName);
@ -279,7 +279,7 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool, std::string_view modulesL
return false;
}
std::string const info = Acore::StringFormatFmt("Containing {} new and {} archived updates.", result.recent, result.archived);
std::string const info = Acore::StringFormat("Containing {} new and {} archived updates.", result.recent, result.archived);
if (!result.updated)
LOG_INFO("sql.updates", ">> {} database is up-to-date! {}", DBUpdater<T>::GetTableName(), info);
@ -307,7 +307,7 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool, std::vector<std::string>
auto CheckUpdateTable = [&](std::string const& tableName)
{
auto checkTable = DBUpdater<T>::Retrieve(pool, Acore::StringFormatFmt("SHOW TABLES LIKE '{}'", tableName));
auto checkTable = DBUpdater<T>::Retrieve(pool, Acore::StringFormat("SHOW TABLES LIKE '{}'", tableName));
if (!checkTable)
{
Path const temp(GetBaseFilesDirectory() + tableName + ".sql");
@ -507,7 +507,7 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
// Execute sql file
args.emplace_back("-e");
args.emplace_back(Acore::StringFormat("BEGIN; SOURCE %s; COMMIT;", path.generic_string().c_str()));
args.emplace_back(Acore::StringFormat("BEGIN; SOURCE {}; COMMIT;", path.generic_string()));
// Database
if (!database.empty())

View File

@ -35,7 +35,7 @@ protected:
// For Logging purpose
std::string ToString() const override
{
return Acore::StringFormatFmt("Damage done: {}, Healing done: {}, Killing blows: {}", DamageDone, HealingDone, KillingBlows);
return Acore::StringFormat("Damage done: {}, Healing done: {}, Killing blows: {}", DamageDone, HealingDone, KillingBlows);
}
uint8 PvPTeamId;

View File

@ -1107,7 +1107,7 @@ void BattlegroundQueue::SendJoinMessageArenaQueue(Player* leader, GroupQueueInfo
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
auto bgName = bg->GetName();
auto arenatype = Acore::StringFormat("%uv%u", ginfo->ArenaType, ginfo->ArenaType);
auto arenatype = Acore::StringFormat("{}v{}", ginfo->ArenaType, ginfo->ArenaType);
uint32 playersNeed = ArenaTeam::GetReqPlayersForType(ginfo->ArenaType);
uint32 q_min_level = std::min(bracketEntry->minLevel, (uint32)80);
uint32 q_max_level = std::min(bracketEntry->maxLevel, (uint32)80);

View File

@ -56,13 +56,13 @@ public:
void SendNotification(uint32 strId, Args&&... args)
{
if (HasSession())
SendNotification(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...));
SendNotification(Acore::StringFormat(GetAcoreString(strId), std::forward<Args>(args)...));
}
template<typename... Args>
void SendNotification(char const* fmt, Args&&... args)
{
if (HasSession())
SendNotification(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
SendNotification(Acore::StringFormat(fmt, std::forward<Args>(args)...));
}
void SendGMText(std::string_view str);
@ -73,7 +73,7 @@ public:
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendGMText(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...));
SendGMText(Acore::StringFormat(GetAcoreString(strId), std::forward<Args>(args)...));
});
}
template<typename... Args>
@ -83,7 +83,7 @@ public:
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendGMText(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
SendGMText(Acore::StringFormat(fmt, std::forward<Args>(args)...));
});
}
@ -95,7 +95,7 @@ public:
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendWorldText(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...));
SendWorldText(Acore::StringFormat(GetAcoreString(strId), std::forward<Args>(args)...));
});
}
template<typename... Args>
@ -105,7 +105,7 @@ public:
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendWorldText(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
SendWorldText(Acore::StringFormat(fmt, std::forward<Args>(args)...));
});
}
@ -117,7 +117,7 @@ public:
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendWorldTextOptional(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...), flag);
SendWorldTextOptional(Acore::StringFormat(GetAcoreString(strId), std::forward<Args>(args)...), flag);
});
}
template<typename... Args>
@ -127,7 +127,7 @@ public:
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendWorldTextOptional(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...), flag);
SendWorldTextOptional(Acore::StringFormat(fmt, std::forward<Args>(args)...), flag);
});
}
@ -142,7 +142,7 @@ public:
void PSendSysMessage(char const* fmt, Args&&... args)
{
if (HasSession())
SendSysMessage(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
SendSysMessage(Acore::StringFormat(fmt, std::forward<Args>(args)...));
}
template<typename... Args>
@ -155,7 +155,7 @@ public:
template<typename... Args>
std::string PGetParseString(uint32 entry, Args&&... args) const
{
return Acore::StringFormatFmt(GetAcoreString(entry), std::forward<Args>(args)...);
return Acore::StringFormat(GetAcoreString(entry), std::forward<Args>(args)...);
}
std::string const* GetModuleString(std::string module, uint32 id) const;
@ -170,7 +170,7 @@ public:
template<typename... Args>
std::string PGetParseModuleString(std::string module, uint32 id, Args&&... args) const
{
return Acore::StringFormatFmt(GetModuleString(module, id)->c_str(), std::forward<Args>(args)...);
return Acore::StringFormat(GetModuleString(module, id)->c_str(), std::forward<Args>(args)...);
}
void SendErrorMessage(uint32 entry);

View File

@ -175,7 +175,7 @@ static void LogCommandUsage(WorldSession const& session, std::string_view cmdStr
zoneName = zone->area_name[locale];
}
std::string logMessage = Acore::StringFormatFmt("Command: {} [Player: {} ({}) (Account: {}) X: {} Y: {} Z: {} Map: {} ({}) Area: {} ({}) Zone: {} ({}) Selected: {} ({})]",
std::string logMessage = Acore::StringFormat("Command: {} [Player: {} ({}) (Account: {}) X: {} Y: {} Z: {} Map: {} ({}) Area: {} ({}) Zone: {} ({}) Selected: {} ({})]",
cmdStr, player->GetName(), player->GetGUID().ToString(),
session.GetAccountId(),
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(),
@ -443,11 +443,11 @@ namespace Acore::Impl::ChatCommands
{
if (prefix.empty())
{
return Acore::StringFormatFmt("{}{}{}", match, COMMAND_DELIMITER, suffix);
return Acore::StringFormat("{}{}{}", match, COMMAND_DELIMITER, suffix);
}
else
{
return Acore::StringFormatFmt("{}{}{}{}{}", prefix, COMMAND_DELIMITER, match, COMMAND_DELIMITER, suffix);
return Acore::StringFormat("{}{}{}{}{}", prefix, COMMAND_DELIMITER, match, COMMAND_DELIMITER, suffix);
}
});
@ -465,7 +465,7 @@ namespace Acore::Impl::ChatCommands
path.assign(it1->first);
else
{
path = Acore::StringFormatFmt("{}{}{}", path, COMMAND_DELIMITER, it1->first);
path = Acore::StringFormat("{}{}{}", path, COMMAND_DELIMITER, it1->first);
}
cmd = &it1->second;
map = &cmd->_subCommands;
@ -477,7 +477,7 @@ namespace Acore::Impl::ChatCommands
{ /* there is some trailing text, leave it as is */
if (cmd)
{ /* if we matched a command at some point, auto-complete it */
return { Acore::StringFormatFmt("{}{}{}", path, COMMAND_DELIMITER, oldTail) };
return { Acore::StringFormat("{}{}{}", path, COMMAND_DELIMITER, oldTail) };
}
else
return {};
@ -490,7 +490,7 @@ namespace Acore::Impl::ChatCommands
return std::string(match);
else
{
return Acore::StringFormatFmt("{}{}{}", prefix, COMMAND_DELIMITER, match);
return Acore::StringFormat("{}{}{}", prefix, COMMAND_DELIMITER, match);
}
});

View File

@ -91,7 +91,7 @@ namespace Acore::Impl::ChatCommands
return result2;
if (result1.HasErrorMessage() && result2.HasErrorMessage())
{
return Acore::StringFormatFmt("{} \"{}\"\n{} \"{}\"",
return Acore::StringFormat("{} \"{}\"\n{} \"{}\"",
GetAcoreString(handler, LANG_CMDPARSER_EITHER), result2.GetErrorMessage(),
GetAcoreString(handler, LANG_CMDPARSER_OR), result1.GetErrorMessage());
}

View File

@ -273,9 +273,9 @@ namespace Acore::Impl::ChatCommands
if (!nestedResult.HasErrorMessage())
return thisResult;
if (StringStartsWith(nestedResult.GetErrorMessage(), "\""))
return Acore::StringFormat("\"%s\"\n%s %s", thisResult.GetErrorMessage().c_str(), GetAcoreString(handler, LANG_CMDPARSER_OR), nestedResult.GetErrorMessage().c_str());
return Acore::StringFormat("\"{}\"\n{} {}", thisResult.GetErrorMessage(), GetAcoreString(handler, LANG_CMDPARSER_OR), nestedResult.GetErrorMessage());
else
return Acore::StringFormat("\"%s\"\n%s \"%s\"", thisResult.GetErrorMessage().c_str(), GetAcoreString(handler, LANG_CMDPARSER_OR), nestedResult.GetErrorMessage().c_str());
return Acore::StringFormat("\"{}\"\n{} \"{}\"", thisResult.GetErrorMessage(), GetAcoreString(handler, LANG_CMDPARSER_OR), nestedResult.GetErrorMessage());
}
}
else
@ -286,7 +286,7 @@ namespace Acore::Impl::ChatCommands
{
ChatCommandResult result = TryAtIndex<0>(val, handler, args);
if (result.HasErrorMessage() && (result.GetErrorMessage().find('\n') != std::string::npos))
return Acore::StringFormat("%s %s", GetAcoreString(handler, LANG_CMDPARSER_EITHER), result.GetErrorMessage().c_str());
return Acore::StringFormat("{} {}", GetAcoreString(handler, LANG_CMDPARSER_EITHER), result.GetErrorMessage());
return result;
}
};

View File

@ -125,7 +125,7 @@ namespace Acore::Impl::ChatCommands
template <typename... Ts>
std::string FormatAcoreString(ChatHandler const* handler, AcoreStrings which, Ts&&... args)
{
return Acore::StringFormatFmt(GetAcoreString(handler, which), std::forward<Ts>(args)...);
return Acore::StringFormat(GetAcoreString(handler, which), std::forward<Ts>(args)...);
}
}

View File

@ -304,7 +304,7 @@ void PlayerDump::InitializeTables()
// item0 - item18
for (uint32 j = 0; j < EQUIPMENT_SLOT_END; ++j)
{
std::string itColumn = Acore::StringFormat("item%u", j);
std::string itColumn = Acore::StringFormat("item{}", j);
MarkDependentColumn(t, itColumn, GUID_TYPE_ITEM);
}
break;
@ -923,7 +923,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::istream& input, uint32 account, std::
if (name.empty())
{
// generate a temporary name
std::string guidPart = Acore::StringFormat("%X", guid);
std::string guidPart = Acore::StringFormat("{:X}", guid);
std::size_t maxCharsFromOriginalName = MAX_PLAYER_NAME - guidPart.length();
name = GetColumn(ts, line, "name").substr(0, maxCharsFromOriginalName) + guidPart;

View File

@ -246,14 +246,14 @@ void Warden::ApplyPenalty(uint16 checkId, std::string const& reason)
if (Player const* plr = _session->GetPlayer())
{
std::string const reportFormat = "Player {} (guid {}, account id: {}) failed warden {} check ({}). Action: {}";
reportMsg = Acore::StringFormatFmt(reportFormat, plr->GetName(), plr->GetGUID().GetCounter(), _session->GetAccountId(),
reportMsg = Acore::StringFormat(reportFormat, plr->GetName(), plr->GetGUID().GetCounter(), _session->GetAccountId(),
checkId, ((checkData && !checkData->Comment.empty()) ? checkData->Comment : "<warden comment is not set>"),
GetWardenActionStr(action));
}
else
{
std::string const reportFormat = "Account id: {} failed warden {} check. Action: {}";
reportMsg = Acore::StringFormatFmt(reportFormat, _session->GetAccountId(), checkId, GetWardenActionStr(action));
reportMsg = Acore::StringFormat(reportFormat, _session->GetAccountId(), checkId, GetWardenActionStr(action));
}
}
else
@ -261,12 +261,12 @@ void Warden::ApplyPenalty(uint16 checkId, std::string const& reason)
if (Player const* plr = _session->GetPlayer())
{
std::string const reportFormat = "Player {} (guid {}, account id: {}) triggered warden penalty by reason: {}. Action: {}";
reportMsg = Acore::StringFormatFmt(reportFormat, plr->GetName(), plr->GetGUID().GetCounter(), _session->GetAccountId(), causeMsg, GetWardenActionStr(action));
reportMsg = Acore::StringFormat(reportFormat, plr->GetName(), plr->GetGUID().GetCounter(), _session->GetAccountId(), causeMsg, GetWardenActionStr(action));
}
else
{
std::string const reportFormat = "Account id: {} failed warden {} check. Action: {}";
reportMsg = Acore::StringFormatFmt(reportFormat, _session->GetAccountId(), causeMsg, GetWardenActionStr(action));
reportMsg = Acore::StringFormat(reportFormat, _session->GetAccountId(), causeMsg, GetWardenActionStr(action));
}
}

View File

@ -137,7 +137,7 @@ void WardenCheckMgr::LoadWardenChecks()
continue;
}
std::string str2 = Acore::StringFormat("%04u", id);
std::string str2 = Acore::StringFormat("{:04}", id);
ASSERT(str2.size() == 4);
std::copy(str2.begin(), str2.end(), wardenCheck.IdStr.begin());

View File

@ -74,7 +74,7 @@ bool WardenPayloadMgr::RegisterPayload(std::string const& payload, uint16 payloa
wCheck.Str = payload;
wCheck.CheckId = payloadId;
std::string idStr = Acore::StringFormat("%04u", payloadId);
std::string idStr = Acore::StringFormat("{:04}", payloadId);
ASSERT(idStr.size() == 4);
std::copy(idStr.begin(), idStr.end(), wCheck.IdStr.begin());

View File

@ -310,7 +310,7 @@ public:
if (target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index)
activeStr = handler->GetAcoreString(LANG_ACTIVE);
std::string titleName = Acore::StringFormat(name, player->GetName().c_str());
std::string titleName = Acore::StringFormat(name, player->GetName());
// send title in "id (idx:idx) - [namedlink locale]" format
if (handler->GetSession())

View File

@ -733,14 +733,14 @@ public:
if (item->GetOwnerGUID() != player->GetGUID())
{
handler->SendSysMessage(Acore::StringFormatFmt("queue({}): For the item {}, the owner ({}) and the player ({}) don't match!", index, item->GetGUID().ToString(), item->GetOwnerGUID().ToString(), player->GetGUID().ToString()));
handler->SendSysMessage(Acore::StringFormat("queue({}): For the item {}, the owner ({}) and the player ({}) don't match!", index, item->GetGUID().ToString(), item->GetOwnerGUID().ToString(), player->GetGUID().ToString()));
error = true;
continue;
}
if (item->GetQueuePos() != index)
{
handler->SendSysMessage(Acore::StringFormatFmt("queue({}): For the item {}, the queuepos doesn't match it's position in the queue!", index, item->GetGUID().ToString()));
handler->SendSysMessage(Acore::StringFormat("queue({}): For the item {}, the queuepos doesn't match it's position in the queue!", index, item->GetGUID().ToString()));
error = true;
continue;
}
@ -752,14 +752,14 @@ public:
if (!test)
{
handler->SendSysMessage(Acore::StringFormatFmt("queue({}): The bag({}) and slot({}) values for {} are incorrect, the player doesn't have any item at that position!", index, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString()));
handler->SendSysMessage(Acore::StringFormat("queue({}): The bag({}) and slot({}) values for {} are incorrect, the player doesn't have any item at that position!", index, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString()));
error = true;
continue;
}
if (test != item)
{
handler->SendSysMessage(Acore::StringFormatFmt("queue({}): The bag({}) and slot({}) values for the {} are incorrect, {} is there instead!", index, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString(), test->GetGUID().ToString()));
handler->SendSysMessage(Acore::StringFormat("queue({}): The bag({}) and slot({}) values for the {} are incorrect, {} is there instead!", index, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString(), test->GetGUID().ToString()));
error = true;
continue;
}

View File

@ -87,7 +87,7 @@ public:
if (message.empty())
return false;
sWorld->SendServerMessage(SERVER_MSG_STRING, Acore::StringFormatFmt(handler->GetAcoreString(LANG_SYSTEMMESSAGE), message.data()));
sWorld->SendServerMessage(SERVER_MSG_STRING, Acore::StringFormat(handler->GetAcoreString(LANG_SYSTEMMESSAGE), message.data()));
return true;
}

View File

@ -79,7 +79,7 @@ public:
itemCount = *Acore::StringTo<uint32>(itemTokens.at(1));
break;
default:
handler->SendSysMessage(Acore::StringFormatFmt("> Incorrect item list format for '{}'", itemString));
handler->SendSysMessage(Acore::StringFormat("> Incorrect item list format for '{}'", itemString));
continue;
}

View File

@ -121,9 +121,9 @@ public:
dbPort = (*res)[0].Get<uint16>();
if (dbPort)
dbPortOutput = Acore::StringFormatFmt("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort);
dbPortOutput = Acore::StringFormat("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort);
else
dbPortOutput = Acore::StringFormatFmt("Realm Id: {} not found in `realmlist` table. Please check your setup", realm.Id.Realm);
dbPortOutput = Acore::StringFormat("Realm Id: {} not found in `realmlist` table. Please check your setup", realm.Id.Realm);
}
HandleServerInfoCommand(handler);

View File

@ -144,7 +144,7 @@ class spell_the_flag_of_ownership : public SpellScript
LocaleConstant loc_idx = caster->ToPlayer()->GetSession()->GetSessionDbLocaleIndex();
BroadcastText const* bct = sObjectMgr->GetBroadcastText(TEXT_FLAG_OF_OWNERSHIP);
std::string bctMsg = Acore::StringFormat(bct->GetText(loc_idx, caster->getGender()), caster->GetName().c_str(), target->GetName().c_str());
std::string bctMsg = Acore::StringFormat(bct->GetText(loc_idx, caster->getGender()), caster->GetName(), target->GetName());
caster->Talk(bctMsg, CHAT_MSG_MONSTER_EMOTE, LANG_UNIVERSAL, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target);
haveTarget = true;

View File

@ -36,7 +36,7 @@ DBCDatabaseLoader::DBCDatabaseLoader(char const* tableName, char const* dbcForma
char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
{
std::string query = Acore::StringFormat("SELECT * FROM `%s` ORDER BY `ID` DESC", _sqlTableName);
std::string query = Acore::StringFormat("SELECT * FROM `{}` ORDER BY `ID` DESC", _sqlTableName);
// no error if empty set
QueryResult result = WorldDatabase.Query(query);

View File

@ -51,7 +51,7 @@ ByteBufferSourceException::ByteBufferSourceException(std::size_t pos, std::size_
ByteBufferInvalidValueException::ByteBufferInvalidValueException(char const* type, char const* value)
{
message().assign(Acore::StringFormat("Invalid %s value (%s) found in ByteBuffer", type, value));
message().assign(Acore::StringFormat("Invalid {} value ({}) found in ByteBuffer", type, value));
}
ByteBuffer& ByteBuffer::operator>>(float& value)

View File

@ -188,11 +188,11 @@ Optional<std::string> SecretMgr::AttemptTransition(Secrets i, Optional<BigNumber
if (hadOldSecret)
{
if (!oldSecret)
return Acore::StringFormat("Cannot decrypt old TOTP tokens - add config key '%s' to authserver.conf!", secret_info[i].oldKey);
return Acore::StringFormat("Cannot decrypt old TOTP tokens - add config key '{}' to authserver.conf!", secret_info[i].oldKey);
bool success = Acore::Crypto::AEDecrypt<Acore::Crypto::AES>(totpSecret, oldSecret->ToByteArray<Acore::Crypto::AES::KEY_SIZE_BYTES>());
if (!success)
return Acore::StringFormat("Cannot decrypt old TOTP tokens - value of '%s' is incorrect for some users!", secret_info[i].oldKey);
return Acore::StringFormat("Cannot decrypt old TOTP tokens - value of '{}' is incorrect for some users!", secret_info[i].oldKey);
}
if (newSecret)

View File

@ -990,7 +990,7 @@ void ExtractMapsFromMpq(uint32 build)
{
printf("Extract %s (%d/%u) \n", map_ids[z].name, z + 1, map_count);
// Loadup map grid data
mpqMapName = Acore::StringFormat(R"(World\Maps\%s\%s.wdt)", map_ids[z].name, map_ids[z].name);
mpqMapName = Acore::StringFormat(R"(World\Maps\{}\{}.wdt)", map_ids[z].name, map_ids[z].name);
WDT_file wdt;
if (!wdt.loadFile(mpqMapName, false))
{
@ -1004,8 +1004,8 @@ void ExtractMapsFromMpq(uint32 build)
{
if (!wdt.main->adt_list[y][x].exist)
continue;
mpqFileName = Acore::StringFormat(R"(World\Maps\%s\%s_%u_%u.adt)", map_ids[z].name, map_ids[z].name, x, y);
outputFileName = Acore::StringFormat("%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x);
mpqFileName = Acore::StringFormat(R"(World\Maps\{}\{}_{}_{}.adt)", map_ids[z].name, map_ids[z].name, x, y);
outputFileName = Acore::StringFormat("{}/maps/{:03}{:02}{:02}.map", output_path, map_ids[z].id, y, x);
ConvertADT(mpqFileName, outputFileName, y, x, build);
}
// draw progress bar