Remove fmt::format and replace with std::format

This commit is contained in:
Alexander Bock
2024-03-24 20:19:14 +01:00
parent 9878bfc8f7
commit 3ba346a227
246 changed files with 1343 additions and 1300 deletions
+9 -9
View File
@@ -111,7 +111,7 @@ void HttpSynchronization::start() {
return;
}
const std::string query = fmt::format(
const std::string query = std::format(
"?identifier={}&file_version={}&application_version={}",
_identifier, _version, ApplicationVersion
);
@@ -158,7 +158,7 @@ void HttpSynchronization::cancel() {
}
std::string HttpSynchronization::generateUid() {
return fmt::format("{}/{}", _identifier, _version);
return std::format("{}/{}", _identifier, _version);
}
void HttpSynchronization::createSyncFile(bool isFullySynchronized) const {
@@ -168,7 +168,7 @@ void HttpSynchronization::createSyncFile(bool isFullySynchronized) const {
dir.replace_extension("ossync");
std::ofstream syncFile(dir, std::ofstream::out);
syncFile << fmt::format(
syncFile << std::format(
"{}\n{}\n",
OssyncVersionNumber,
(isFullySynchronized ? SynchronizationToken : "Partial Synchronized")
@@ -227,7 +227,7 @@ bool HttpSynchronization::isEachFileDownloaded() {
}
}
else {
LERROR(fmt::format(
LERROR(std::format(
"{}: Unknown ossync version number read."
"Got {} while {} and below are valid.",
_identifier,
@@ -286,7 +286,7 @@ HttpSynchronization::trySyncFromUrl(std::string url) {
const std::filesystem::path destination = directory() / (filename + ".tmp");
if (sizeData.find(line) != sizeData.end()) {
LWARNING(fmt::format("{}: Duplicate entry for {}", _identifier, line));
LWARNING(std::format("{}: Duplicate entry for {}", _identifier, line));
continue;
}
@@ -372,7 +372,7 @@ HttpSynchronization::trySyncFromUrl(std::string url) {
for (const std::unique_ptr<HttpFileDownload>& d : downloads) {
d->wait();
if (!d->hasSucceeded()) {
LERROR(fmt::format("Error downloading file from URL '{}'", d->url()));
LERROR(std::format("Error downloading file from URL '{}'", d->url()));
failed = true;
continue;
}
@@ -391,7 +391,7 @@ HttpSynchronization::trySyncFromUrl(std::string url) {
std::error_code ec;
std::filesystem::rename(tempName, originalName, ec);
if (ec) {
LERROR(fmt::format("Error renaming '{}' to '{}'", tempName, originalName));
LERROR(std::format("Error renaming '{}' to '{}'", tempName, originalName));
failed = true;
}
@@ -407,7 +407,7 @@ HttpSynchronization::trySyncFromUrl(std::string url) {
zip_close(z);
if (is64) {
LERROR(fmt::format(
LERROR(std::format(
"Error while unzipping '{}': Zip64 archives are not supported", source
));
continue;
@@ -415,7 +415,7 @@ HttpSynchronization::trySyncFromUrl(std::string url) {
int ret = zip_extract(source.c_str(), dest.c_str(), nullptr, nullptr);
if (ret != 0) {
LERROR(fmt::format("Error '{}' while unzipping '{}'", ret, source));
LERROR(std::format("Error '{}' while unzipping '{}'", ret, source));
continue;
}
+9 -9
View File
@@ -99,7 +99,7 @@ UrlSynchronization::UrlSynchronization(const ghoul::Dictionary& dictionary,
}
if (p.filename.has_value() && _urls.size() > 1) {
throw ghoul::RuntimeError(fmt::format(
throw ghoul::RuntimeError(std::format(
"UrlSynchronization ({}) requested overwrite filename but specified {} URLs "
"to download, which is not legal",
p.identifier, _urls.size()
@@ -128,11 +128,11 @@ UrlSynchronization::UrlSynchronization(const ghoul::Dictionary& dictionary,
size_t hash = std::hash<std::string>{}(
std::accumulate(urls.begin(), urls.end(), std::string())
);
_identifier += fmt::format("({})", hash);
_identifier += std::format("({})", hash);
}
if (p.forceOverride.has_value()) {
LWARNING(fmt::format(
LWARNING(std::format(
"{}: The variable ForceOverride has been deprecated. "
"Optionally, use SecondsUntilResync instead to specify file validity date.",
p.identifier
@@ -230,7 +230,7 @@ bool UrlSynchronization::isEachFileValid() {
// Issue warning if file is kept but user changed setting to download on startup.
if ((fileValidAsJ2000 > todaysDateAsJ2000) && _secondsUntilResync == 0) {
LWARNING(fmt::format(
LWARNING(std::format(
"{}: File is valid to {} but asset specifies SecondsUntilResync = {} "
"Did you mean to re-download the file? If so, remove file from sync "
"folder to resync",
@@ -247,7 +247,7 @@ bool UrlSynchronization::isEachFileValid() {
return false;
}
else {
LERROR(fmt::format(
LERROR(std::format(
"{}: Unknown ossync version number read. Got {} while {} and below are valid",
_identifier, ossyncVersion, OssyncVersionNumber
));
@@ -279,7 +279,7 @@ void UrlSynchronization::createSyncFile(bool) const {
"YYYY-MM-DDTHR:MN:SC.###"
);
const std::string msg = fmt::format("{}\n{}\n", OssyncVersionNumber, fileIsValidTo);
const std::string msg = std::format("{}\n{}\n", OssyncVersionNumber, fileIsValidTo);
syncFile << msg;
}
@@ -311,7 +311,7 @@ bool UrlSynchronization::trySyncUrls() {
std::filesystem::path destination = directory() / (_filename + ".tmp");
if (sizeData.find(url) != sizeData.end()) {
LWARNING(fmt::format("{}: Duplicate entry for '{}'", _identifier, url));
LWARNING(std::format("{}: Duplicate entry for '{}'", _identifier, url));
continue;
}
@@ -360,7 +360,7 @@ bool UrlSynchronization::trySyncUrls() {
d->wait();
if (!d->hasSucceeded()) {
failed = true;
LERROR(fmt::format("Error downloading file from URL: {}", d->url()));
LERROR(std::format("Error downloading file from URL: {}", d->url()));
continue;
}
@@ -381,7 +381,7 @@ bool UrlSynchronization::trySyncUrls() {
if (ec) {
LERRORC(
"URLSynchronization",
fmt::format("Error renaming file '{}' to '{}'", tempName, originalName)
std::format("Error renaming file '{}' to '{}'", tempName, originalName)
);
failed = true;