mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
Common: Use fmt where applicable
Begins the transition to using fmt for string formatting where applicable. Given fmt supports formatting std::string instances out of the box, we can remove now-unnecessary calls to .c_str() and .data(). Note that this change does not touch the actual logging subsystem aside from converting the final StringFromFormat call in the process over to fmt::format. Given our logging system is heavily used throughout the entire codebase, and converting that over will be quite a large change by itself, this will be tackled near the end of the conversion process.
This commit is contained in:
@ -9,6 +9,8 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
@ -28,21 +30,20 @@ static std::string RootUserPath(std::optional<FromWhichRoot> from)
|
||||
|
||||
std::string GetImportTitlePath(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return RootUserPath(from) + StringFromFormat("/import/%08x/%08x",
|
||||
static_cast<u32>(title_id >> 32),
|
||||
static_cast<u32>(title_id));
|
||||
return RootUserPath(from) + fmt::format("/import/{:08x}/{:08x}", static_cast<u32>(title_id >> 32),
|
||||
static_cast<u32>(title_id));
|
||||
}
|
||||
|
||||
std::string GetTicketFileName(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return StringFromFormat("%s/ticket/%08x/%08x.tik", RootUserPath(from).c_str(),
|
||||
static_cast<u32>(title_id >> 32), static_cast<u32>(title_id));
|
||||
return fmt::format("{}/ticket/{:08x}/{:08x}.tik", RootUserPath(from),
|
||||
static_cast<u32>(title_id >> 32), static_cast<u32>(title_id));
|
||||
}
|
||||
|
||||
std::string GetTitlePath(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return StringFromFormat("%s/title/%08x/%08x", RootUserPath(from).c_str(),
|
||||
static_cast<u32>(title_id >> 32), static_cast<u32>(title_id));
|
||||
return fmt::format("{}/title/{:08x}/{:08x}", RootUserPath(from), static_cast<u32>(title_id >> 32),
|
||||
static_cast<u32>(title_id));
|
||||
}
|
||||
|
||||
std::string GetTitleDataPath(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
@ -62,7 +63,7 @@ std::string GetTMDFileName(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
|
||||
std::string GetMiiDatabasePath(std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return StringFromFormat("%s/shared2/menu/FaceLib/RFL_DB.dat", RootUserPath(from).c_str());
|
||||
return fmt::format("{}/shared2/menu/FaceLib/RFL_DB.dat", RootUserPath(from));
|
||||
}
|
||||
|
||||
bool IsTitlePath(const std::string& path, std::optional<FromWhichRoot> from, u64* title_id)
|
||||
@ -111,7 +112,7 @@ std::string EscapeFileName(const std::string& filename)
|
||||
for (char c : filename_with_escaped_double_underscores)
|
||||
{
|
||||
if ((c >= 0 && c <= 0x1F) || chars_to_replace.find(c) != chars_to_replace.end())
|
||||
result.append(StringFromFormat("__%02x__", c));
|
||||
result.append(fmt::format("__{:02x}__", c));
|
||||
else
|
||||
result.push_back(c);
|
||||
}
|
||||
|
Reference in New Issue
Block a user