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

View File

@@ -96,7 +96,7 @@ std::string constructHorizonsUrl(HorizonsType type, const std::string& target,
break;
}
url += fmt::format(
url += std::format(
"{}'{}'{}'{}'{}'{}'{}'{}'",
Command, ghoul::encodeUrl(target),
Center, ghoul::encodeUrl(observer),
@@ -105,10 +105,10 @@ std::string constructHorizonsUrl(HorizonsType type, const std::string& target,
);
if (unit.empty()) {
url += fmt::format("{}'{}'", StepSize, ghoul::encodeUrl(stepSize));
url += std::format("{}'{}'", StepSize, ghoul::encodeUrl(stepSize));
}
else {
url += fmt::format(
url += std::format(
"{}'{}%20{}'", StepSize, ghoul::encodeUrl(stepSize), unit
);
}
@@ -130,7 +130,7 @@ json sendHorizonsRequest(const std::string& url, const std::filesystem::path& fi
bool failed = false;
dl->wait();
if (!dl->hasSucceeded()) {
LERROR(fmt::format("Error downloading horizons file with URL '{}'", dl->url()));
LERROR(std::format("Error downloading horizons file with URL '{}'", dl->url()));
failed = true;
}
@@ -163,7 +163,7 @@ HorizonsResultCode isValidHorizonsAnswer(const json& answer) {
if (auto signature = answer.find("signature"); signature != answer.end()) {
if (auto source = signature->find("source"); source != signature->end()) {
if (*source != static_cast<std::string>(ApiSource)) {
LWARNING(fmt::format(
LWARNING(std::format(
"Horizons answer from unknown source '{}'", source->dump()
));
}
@@ -178,7 +178,7 @@ HorizonsResultCode isValidHorizonsAnswer(const json& answer) {
v = v.substr(0, v.find('.'));
if (v != CurrentMajorVersion) {
LWARNING(fmt::format(
LWARNING(std::format(
"Unknown Horizons major version '{}' found. The currently supported "
"major version is {}", version->dump(), CurrentMajorVersion
));
@@ -388,7 +388,7 @@ void HorizonsFile::displayErrorMessage(HorizonsResultCode code) const {
break;
}
LINFO(fmt::format(
LINFO(std::format(
"Valid time range is '{}' to '{}'",
validTimeRange.first, validTimeRange.second
));
@@ -423,7 +423,7 @@ void HorizonsFile::displayErrorMessage(HorizonsResultCode code) const {
for (const std::string& station : matchingstations) {
matches += '\n' + station;
}
LINFO(fmt::format("Matching Observer Stations: {}", matches));
LINFO(std::format("Matching Observer Stations: {}", matches));
break;
}
case HorizonsResultCode::MultipleObserver: {
@@ -440,7 +440,7 @@ void HorizonsFile::displayErrorMessage(HorizonsResultCode code) const {
for (const std::string& observer : matchingObservers) {
matches += '\n' + observer;
}
LINFO(fmt::format("Matching Observers: {}", matches));
LINFO(std::format("Matching Observers: {}", matches));
break;
}
case HorizonsResultCode::ErrorNoTarget:
@@ -471,7 +471,7 @@ void HorizonsFile::displayErrorMessage(HorizonsResultCode code) const {
for (const std::string& target : matchingTargets) {
matches += '\n' + target;
}
LINFO(fmt::format("Matching targets: {}", matches));
LINFO(std::format("Matching targets: {}", matches));
break;
}
case HorizonsResultCode::UnknownError:
@@ -495,7 +495,7 @@ HorizonsResult readHorizonsFile(std::filesystem::path file) {
std::ifstream fileStream(file);
if (!fileStream.good()) {
LERROR(fmt::format("Failed to open Horizons file '{}'", file));
LERROR(std::format("Failed to open Horizons file '{}'", file));
return HorizonsResult();
}
@@ -527,7 +527,7 @@ HorizonsResult readHorizonsVectorFile(std::filesystem::path file) {
std::ifstream fileStream(file);
if (!fileStream.good()) {
LERROR(fmt::format("Failed to open Horizons text file {}", file));
LERROR(std::format("Failed to open Horizons text file {}", file));
return HorizonsResult();
}
@@ -557,7 +557,7 @@ HorizonsResult readHorizonsVectorFile(std::filesystem::path file) {
// Get next line of same data point
std::getline(fileStream, line);
if (!fileStream.good()) {
LERROR(fmt::format("Malformed Horizons file '{}'", file));
LERROR(std::format("Malformed Horizons file '{}'", file));
return HorizonsResult();
}
std::stringstream str2(line);
@@ -569,7 +569,7 @@ HorizonsResult readHorizonsVectorFile(std::filesystem::path file) {
str2 >> xPos >> yPos >> zPos;
// Convert date and time to seconds after 2000
const std::string timeString = fmt::format("{} {}", date, time);
const std::string timeString = std::format("{} {}", date, time);
const double timeInJ2000 = Time::convertTime(timeString);
glm::dvec3 pos = glm::dvec3(1000 * xPos, 1000 * yPos, 1000 * zPos);
const glm::dmat3 transform =
@@ -596,7 +596,7 @@ HorizonsResult readHorizonsObserverFile(std::filesystem::path file) {
std::ifstream fileStream(file);
if (!fileStream.good()) {
LERROR(fmt::format("Failed to open Horizons text file '{}'", file));
LERROR(std::format("Failed to open Horizons text file '{}'", file));
return HorizonsResult();
}
@@ -631,7 +631,7 @@ HorizonsResult readHorizonsObserverFile(std::filesystem::path file) {
// Convert date and time to seconds after 2000
// and pos to Galactic positions in meter from Observer.
const std::string timeString = fmt::format("{} {}", date, time);
const std::string timeString = std::format("{} {}", date, time);
// Add position to stored data
dataPoint.time = Time::convertTime(timeString);
@@ -793,10 +793,10 @@ std::pair<std::string, std::string> HorizonsFile::parseValidTimeRange(
// Parse time stamps backwards
// Format: Trajectory file Name, Start, End (yyyy-mon-dd hh:mm)
if (hasTime && words.size() > 4) {
startTime = fmt::format(
startTime = std::format(
"{} T {}", words[words.size() - 4], words[words.size() - 3]
);
endTime = fmt::format(
endTime = std::format(
"{} T {}", words[words.size() - 2], words[words.size() - 1]
);
}
@@ -831,7 +831,7 @@ std::pair<std::string, std::string> HorizonsFile::parseValidTimeRange(
// Parse time stamps backwards
// Format: Trajectory file Name, Start, End (yyyy-mon-dd hh:mm)
if (hasTime && words.size() > 4) {
endTime = fmt::format(
endTime = std::format(
"{} T {}", words[words.size() - 2], words[words.size() - 1]
);
}