2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 11:44:55 +00:00

Use StringView in MultiProgressPrinter

Also fixes the SpecMP1/2/3 using string_view instead of SystemStringView
This commit is contained in:
Henrique Gemignani Passos Lima
2021-06-29 00:01:04 +03:00
committed by Luke Street
parent de4ddcaa9c
commit d310dcfecb
9 changed files with 25 additions and 24 deletions

View File

@@ -107,7 +107,7 @@ public:
hecl::SystemString fileOut = hecl::SystemString(outPath.getAbsolutePath()) + _SYS_STR('/') + idView.c_str();
hecl::MultiProgressPrinter printer(true);
auto progFunc = [&printer](float totalProg, nod::SystemStringView fileName, size_t fileBytesXfered) {
printer.print(fileName.data(), nullptr, totalProg);
printer.print(fileName, std::nullopt, totalProg);
};
if (id[0] == 'G') {
fileOut += _SYS_STR(".gcm");

View File

@@ -2,6 +2,7 @@
#include <cstdint>
#include <mutex>
#include <optional>
#include <thread>
#include <vector>
@@ -55,7 +56,8 @@ class MultiProgressPrinter {
public:
MultiProgressPrinter(bool activate = false);
~MultiProgressPrinter();
void print(const hecl::SystemChar* message, const hecl::SystemChar* submessage, float factor = -1.f,
void print(std::optional<hecl::SystemStringView> message, std::optional<hecl::SystemStringView> submessage,
float factor = -1.f,
int threadIdx = 0) const;
void setMainFactor(float factor) const;
void setMainIndeterminate(bool indeterminate) const;

View File

@@ -184,7 +184,7 @@ bool ClientProcess::syncCook(const hecl::ProjectPath& path, Database::IDataSpec*
str = fmt::format(FMT_STRING(_SYS_STR("Cooking {}")), path.getRelativePath());
else
str = fmt::format(FMT_STRING(_SYS_STR("Cooking {}|{}")), path.getRelativePath(), path.getAuxInfo());
m_progPrinter->print(str.c_str(), nullptr, -1.f, hecl::ClientProcess::GetThreadWorkerIdx());
m_progPrinter->print(str, std::nullopt, -1.f, hecl::ClientProcess::GetThreadWorkerIdx());
m_progPrinter->flush();
} else {
if (path.getAuxInfo().empty())
@@ -199,7 +199,7 @@ bool ClientProcess::syncCook(const hecl::ProjectPath& path, Database::IDataSpec*
str = fmt::format(FMT_STRING(_SYS_STR("Cooked {}")), path.getRelativePath());
else
str = fmt::format(FMT_STRING(_SYS_STR("Cooked {}|{}")), path.getRelativePath(), path.getAuxInfo());
m_progPrinter->print(str.c_str(), nullptr, -1.f, hecl::ClientProcess::GetThreadWorkerIdx());
m_progPrinter->print(str, std::nullopt, -1.f, hecl::ClientProcess::GetThreadWorkerIdx());
m_progPrinter->flush();
}
}

View File

@@ -286,7 +286,9 @@ MultiProgressPrinter::~MultiProgressPrinter() {
m_logThread.join();
}
void MultiProgressPrinter::print(const hecl::SystemChar* message, const hecl::SystemChar* submessage, float factor,
void MultiProgressPrinter::print(std::optional<hecl::SystemStringView> message,
std::optional<hecl::SystemStringView> submessage,
float factor,
int threadIdx) const {
if (!m_running) {
return;
@@ -302,12 +304,12 @@ void MultiProgressPrinter::print(const hecl::SystemChar* message, const hecl::Sy
ThreadStat& stat = m_threadStats[threadIdx];
if (message) {
stat.m_message = message;
stat.m_message = *message;
} else {
stat.m_message.clear();
}
if (submessage) {
stat.m_submessage = submessage;
stat.m_submessage = *submessage;
} else {
stat.m_submessage.clear();
}

View File

@@ -322,7 +322,7 @@ public:
submsg += _SYS_STR(" (");
submsg += specEnt->m_name.data();
submsg += _SYS_STR(')');
m_progPrinter.print(m_dir, submsg.c_str(), m_prog);
m_progPrinter.print(m_dir, submsg, m_prog);
}
void reportFile(const DataSpecEntry* specEnt, const SystemChar* extra) {
SystemString submsg(m_file);
@@ -331,9 +331,9 @@ public:
submsg += _SYS_STR(", ");
submsg += extra;
submsg += _SYS_STR(')');
m_progPrinter.print(m_dir, submsg.c_str(), m_prog);
m_progPrinter.print(m_dir, submsg, m_prog);
}
void reportDirComplete() { m_progPrinter.print(m_dir, nullptr, 1.f); }
void reportDirComplete() { m_progPrinter.print(m_dir, std::nullopt, 1.f); }
};
static void VisitFile(const ProjectPath& path, bool force, bool fast,