Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from fmtlib to std::format. #2031

Merged
merged 3 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
with:
qt-modules: qtpositioning qtwebchannel qtwebengine qtwebsockets
mo2-third-parties:
7z zlib fmt gtest libbsarch libloot openssl libffi bzip2 python lz4 spdlog
7z zlib gtest libbsarch libloot openssl bzip2 python lz4 spdlog
boost boost-di sip pyqt pybind11 ss licenses explorerpp usvfs
mo2-dependencies: cmake_common uibase githubpp bsatk esptk archive lootcli game_gamebryo
26 changes: 11 additions & 15 deletions src/categories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void CategoryFactory::loadCategories()
bool ok = false;
int temp = iter->toInt(&ok);
if (!ok) {
log::error(tr("invalid category id {}").toStdString(), iter->constData());
log::error(tr("invalid category id {0}"), iter->constData());
}
nexusCats.push_back(NexusCategory("Unknown", temp));
}
Expand All @@ -84,8 +84,7 @@ void CategoryFactory::loadCategories()
int id = cells[0].toInt(&cell0Ok);
int parentID = cells[3].trimmed().toInt(&cell3Ok);
if (!cell0Ok || !cell3Ok) {
log::error(tr("invalid category line {}: {}").toStdString(), lineNum,
line.constData());
log::error(tr("invalid category line {0}: {1}"), lineNum, line.constData());
}
addCategory(id, QString::fromUtf8(cells[1].constData()), nexusCats, parentID);
} else if (cells.count() == 3) {
Expand All @@ -94,14 +93,13 @@ void CategoryFactory::loadCategories()
int id = cells[0].toInt(&cell0Ok);
int parentID = cells[2].trimmed().toInt(&cell3Ok);
if (!cell0Ok || !cell3Ok) {
log::error(tr("invalid category line {}: {}").toStdString(), lineNum,
line.constData());
log::error(tr("invalid category line {0}: {1}"), lineNum, line.constData());
}

addCategory(id, QString::fromUtf8(cells[1].constData()),
std::vector<NexusCategory>(), parentID);
} else {
log::error(tr("invalid category line {}: {} ({} cells)").toStdString(), lineNum,
log::error(tr("invalid category line {0}: {1} ({2} cells)"), lineNum,
line.constData(), cells.count());
}
}
Expand All @@ -122,19 +120,17 @@ void CategoryFactory::loadCategories()
bool ok = false;
int nexID = nexCells[2].toInt(&ok);
if (!ok) {
log::error(tr("invalid nexus ID {}").toStdString(),
nexCells[2].constData());
log::error(tr("invalid nexus ID {}"), nexCells[2].constData());
}
int catID = nexCells[0].toInt(&ok);
if (!ok) {
log::error(tr("invalid category id {}").toStdString(),
nexCells[0].constData());
log::error(tr("invalid category id {}"), nexCells[0].constData());
}
m_NexusMap.insert_or_assign(nexID, NexusCategory(nexName, nexID));
m_NexusMap.at(nexID).setCategoryID(catID);
} else {
log::error(tr("invalid nexus category line {}: {} ({} cells)").toStdString(),
lineNum, nexLine.constData(), nexCells.count());
log::error(tr("invalid nexus category line {0}: {1} ({2} cells)"), lineNum,
nexLine.constData(), nexCells.count());
}
}
}
Expand Down Expand Up @@ -394,7 +390,7 @@ bool CategoryFactory::isDescendantOfImpl(int id, int parentID,
return isDescendantOfImpl(m_Categories[index].parentID(), parentID, seen);
}
} else {
log::warn(tr("{} is no valid category id").toStdString(), id);
log::warn(tr("{} is no valid category id"), id);
return false;
}
}
Expand Down Expand Up @@ -513,11 +509,11 @@ unsigned int CategoryFactory::resolveNexusID(int nexusID) const
auto result = m_NexusMap.find(nexusID);
if (result != m_NexusMap.end()) {
if (m_IDMap.count(result->second.categoryID())) {
log::debug(tr("nexus category id {} maps to internal {}").toStdString(), nexusID,
log::debug(tr("nexus category id {0} maps to internal {1}"), nexusID,
m_IDMap.at(result->second.categoryID()));
return m_IDMap.at(result->second.categoryID());
}
}
log::debug(tr("nexus category id {} not mapped").toStdString(), nexusID);
log::debug(tr("nexus category id {} not mapped"), nexusID);
return 0U;
}
6 changes: 3 additions & 3 deletions src/directoryrefresher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void dumpStats(std::vector<DirectoryStats>& stats)

if (run == 0) {
std::ofstream out(file, std::ios::out | std::ios::trunc);
out << fmt::format("what,run,{}", DirectoryStats::csvHeader()) << "\n";
out << std::format("what,run,{}", DirectoryStats::csvHeader()) << "\n";
}

std::sort(stats.begin(), stats.end(), [](auto&& a, auto&& b) {
Expand All @@ -150,11 +150,11 @@ void dumpStats(std::vector<DirectoryStats>& stats)

DirectoryStats total;
for (const auto& s : stats) {
out << fmt::format("{},{},{}", s.mod, run, s.toCsv()) << "\n";
out << std::format("{},{},{}", s.mod, run, s.toCsv()) << "\n";
total += s;
}

out << fmt::format("total,{},{}", run, total.toCsv()) << "\n";
out << std::format("total,{},{}", run, total.toCsv()) << "\n";

++run;
}
Expand Down
12 changes: 8 additions & 4 deletions src/envshell.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#include "envshell.h"

#include <format>

#include <log.h>
#include <utility.h>
#include <windowsx.h>

#include "envshell.h"

namespace env
{

Expand All @@ -16,7 +20,7 @@ class MenuFailed : public std::runtime_error
public:
MenuFailed(HRESULT r, const std::string& what)
: runtime_error(
fmt::format("{}, {}", what,
std::format("{}, {}", what,
QString::fromStdWString(formatSystemMessage(r)).toStdString()))
{}
};
Expand Down Expand Up @@ -478,7 +482,7 @@ void ShellMenu::invoke(const QPoint& p, int cmd)
const auto r = m_cm->InvokeCommand((CMINVOKECOMMANDINFO*)&info);

if (FAILED(r)) {
throw MenuFailed(r, fmt::format("InvokeCommand failed, verb={}", cmd));
throw MenuFailed(r, std::format("InvokeCommand failed, verb={}", cmd));
}
}

Expand Down Expand Up @@ -568,7 +572,7 @@ void ShellMenuCollection::exec(const QPoint& pos)
}

if (!m_active) {
log::debug("SMC: command {} selected without active submenu");
log::debug("SMC: command {} selected without active submenu", cmd);
return;
}

Expand Down
Loading
Loading