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

@@ -64,7 +64,7 @@ glm::vec3 computeStarColor(float bv) {
std::ifstream colorMap(absPath(bvColormapPath), std::ios::in);
if (!colorMap.good()) {
LERROR(fmt::format(
LERROR(std::format(
"Failed to open colormap data file '{}'", absPath(bvColormapPath)
));
return glm::vec3(0.f);

View File

@@ -268,7 +268,7 @@ std::string ExoplanetsModule::exoplanetsDataPath() const {
ghoul_assert(hasDataFiles(), "Data files not loaded");
return absPath(
fmt::format("{}/{}", _exoplanetsDataFolder.value(), ExoplanetsDataFileName)
std::format("{}/{}", _exoplanetsDataFolder.value(), ExoplanetsDataFileName)
).string();
}
@@ -276,14 +276,14 @@ std::string ExoplanetsModule::lookUpTablePath() const {
ghoul_assert(hasDataFiles(), "Data files not loaded");
return absPath(
fmt::format("{}/{}", _exoplanetsDataFolder.value(), LookupTableFileName)
std::format("{}/{}", _exoplanetsDataFolder.value(), LookupTableFileName)
).string();
}
std::string ExoplanetsModule::teffToBvConversionFilePath() const {
ghoul_assert(hasDataFiles(), "Data files not loaded");
return absPath(fmt::format(
return absPath(std::format(
"{}/{}", _exoplanetsDataFolder.value(), TeffToBvConversionFileName
)).string();
}

View File

@@ -53,14 +53,14 @@ openspace::exoplanets::ExoplanetSystem findExoplanetSystemInData(
const std::string binPath = module->exoplanetsDataPath();
std::ifstream data(absPath(binPath), std::ios::in | std::ios::binary);
if (!data.good()) {
LERROR(fmt::format("Failed to open exoplanets data file '{}'", binPath));
LERROR(std::format("Failed to open exoplanets data file '{}'", binPath));
return ExoplanetSystem();
}
const std::string lutPath = module->lookUpTablePath();
std::ifstream lut(absPath(lutPath));
if (!lut.good()) {
LERROR(fmt::format("Failed to open exoplanets look-up table '{}'", lutPath));
LERROR(std::format("Failed to open exoplanets look-up table '{}'", lutPath));
return ExoplanetSystem();
}
@@ -90,7 +90,7 @@ openspace::exoplanets::ExoplanetSystem findExoplanetSystemInData(
sanitizeNameString(name);
if (!hasSufficientData(p)) {
LWARNING(fmt::format("Insufficient data for exoplanet '{}'", name));
LWARNING(std::format("Insufficient data for exoplanet '{}'", name));
continue;
}
@@ -115,11 +115,11 @@ void createExoplanetSystem(const std::string& starName,
std::string sanitizedStarName = starName;
sanitizeNameString(sanitizedStarName);
const std::string guiPath = fmt::format("{}{}", ExoplanetsGuiPath, sanitizedStarName);
const std::string guiPath = std::format("{}{}", ExoplanetsGuiPath, sanitizedStarName);
SceneGraphNode* existingStarNode = sceneGraphNode(starIdentifier);
if (existingStarNode) {
LERROR(fmt::format(
LERROR(std::format(
"Adding of exoplanet system '{}' failed. The system has already been added",
starName
));
@@ -128,7 +128,7 @@ void createExoplanetSystem(const std::string& starName,
const glm::vec3 starPosInParsec = system.starData.position;
if (!isValidPosition(starPosInParsec)) {
LERROR(fmt::format(
LERROR(std::format(
"Insufficient data available for exoplanet system '{}'. Could not determine "
"star position", starName
));
@@ -560,14 +560,14 @@ std::vector<std::string> hostStarsWithSufficientData() {
const std::string lutPath = module->lookUpTablePath();
std::ifstream lookupTableFile(absPath(lutPath));
if (!lookupTableFile.good()) {
LERROR(fmt::format("Failed to open lookup table file '{}'", lutPath));
LERROR(std::format("Failed to open lookup table file '{}'", lutPath));
return {};
}
const std::string binPath = module->exoplanetsDataPath();
std::ifstream data(absPath(binPath), std::ios::in | std::ios::binary);
if (!data.good()) {
LERROR(fmt::format("Failed to open data file '{}'", binPath));
LERROR(std::format("Failed to open data file '{}'", binPath));
return {};
}
@@ -634,7 +634,7 @@ std::vector<std::string> hostStarsWithSufficientData() {
findExoplanetSystemInData(starName);
if (systemData.planetsData.empty()) {
LERROR(fmt::format("Exoplanet system '{}' could not be found", starName));
LERROR(std::format("Exoplanet system '{}' could not be found", starName));
return;
}
@@ -691,7 +691,7 @@ listOfExoplanetsDeprecated()
output.pop_back();
output.pop_back();
LINFO(fmt::format(
LINFO(std::format(
"There is data available for the following {} exoplanet systems: {}",
names.size(), output
));
@@ -724,7 +724,7 @@ listOfExoplanetsDeprecated()
std::ifstream inputDataFile(csvFile);
if (!inputDataFile.good()) {
LERROR(fmt::format("Failed to open input file '{}'", csvFile));
LERROR(std::format("Failed to open input file '{}'", csvFile));
return;
}
@@ -746,10 +746,10 @@ listOfExoplanetsDeprecated()
module->teffToBvConversionFilePath()
);
LINFO(fmt::format("Reading data for planet '{}'", planetData.name));
LINFO(std::format("Reading data for planet '{}'", planetData.name));
if (!hasSufficientData(planetData.dataEntry)) {
LWARNING(fmt::format(
LWARNING(std::format(
"Insufficient data for exoplanet '{}'", planetData.name
));
continue;
@@ -785,7 +785,7 @@ listOfExoplanetsDeprecated()
createExoplanetSystem(hostName, data);
}
LINFO(fmt::format(
LINFO(std::format(
"Read data for {} exoplanet systems from CSV file: {}. Please wait until "
"they are all finished initializing. You may have to reload the user interface.",
hostNameToSystemDataMap.size(), csvFile

View File

@@ -100,7 +100,7 @@ ExoplanetsDataPreparationTask::ExoplanetsDataPreparationTask(
}
std::string ExoplanetsDataPreparationTask::description() {
return fmt::format(
return std::format(
"Extract data about exoplanets from file '{}' and write as bin to '{}'. The data "
"file should be a csv version of the Planetary Systems Composite Data from the "
"NASA exoplanets archive (https://exoplanetarchive.ipac.caltech.edu/)",
@@ -113,7 +113,7 @@ void ExoplanetsDataPreparationTask::perform(
{
std::ifstream inputDataFile(_inputDataPath);
if (!inputDataFile.good()) {
LERROR(fmt::format("Failed to open input file '{}'", _inputDataPath));
LERROR(std::format("Failed to open input file '{}'", _inputDataPath));
return;
}
@@ -121,7 +121,7 @@ void ExoplanetsDataPreparationTask::perform(
std::ofstream lutFile(_outputLutPath);
if (!binFile.good()) {
LERROR(fmt::format("Error when writing to '{}'",_outputBinPath));
LERROR(std::format("Error when writing to '{}'",_outputBinPath));
if (!std::filesystem::is_directory(_outputBinPath.parent_path())) {
LERROR("Output directory does not exist");
}
@@ -129,7 +129,7 @@ void ExoplanetsDataPreparationTask::perform(
}
if (!lutFile.good()) {
LERROR(fmt::format("Error when writing to '{}'", _outputLutPath));
LERROR(std::format("Error when writing to '{}'", _outputLutPath));
if (!std::filesystem::is_directory(_outputLutPath.parent_path())) {
LERROR("Output directory does not exist");
}
@@ -156,7 +156,7 @@ void ExoplanetsDataPreparationTask::perform(
// containing the data names, again
readFirstDataRow(inputDataFile);
LINFO(fmt::format("Loading {} exoplanets", total));
LINFO(std::format("Loading {} exoplanets", total));
int exoplanetCount = 0;
while (std::getline(inputDataFile, row)) {
@@ -453,7 +453,7 @@ glm::vec3 ExoplanetsDataPreparationTask::starPosition(const std::string& starNam
std::ifstream exoplanetsFile(sourceFile);
if (!exoplanetsFile) {
LERROR(fmt::format("Error opening file '{}'", sourceFile));
LERROR(std::format("Error opening file '{}'", sourceFile));
}
std::string line;
@@ -499,7 +499,7 @@ float ExoplanetsDataPreparationTask::bvFromTeff(float teff,
std::ifstream teffToBvFile(conversionFile);
if (!teffToBvFile.good()) {
LERROR(fmt::format("Failed to open file '{}'", conversionFile));
LERROR(std::format("Failed to open file '{}'", conversionFile));
return std::numeric_limits<float>::quiet_NaN();
}