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

@@ -350,7 +350,7 @@ void SkyBrowserModule::moveHoverCircle(const std::string& imageUrl, bool useScri
// Show the circle
if (useScript) {
const std::string script = fmt::format(
const std::string script = std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.Fade', 1.0);",
id
);
@@ -374,7 +374,7 @@ void SkyBrowserModule::moveHoverCircle(const std::string& imageUrl, bool useScri
pos *= skybrowser::CelestialSphereRadius * 1.1;
// Note that the position can only be set through the script engine
const std::string script = fmt::format(
const std::string script = std::format(
"openspace.setPropertyValueSingle('Scene.{}.Translation.Position', {});",
id, ghoul::to_string(pos)
);
@@ -388,7 +388,7 @@ void SkyBrowserModule::moveHoverCircle(const std::string& imageUrl, bool useScri
void SkyBrowserModule::disableHoverCircle(bool useScript) {
if (_hoverCircle && _hoverCircle->renderable()) {
if (useScript) {
const std::string script = fmt::format(
const std::string script = std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.Fade', 0.0);",
_hoverCircle->identifier()
);
@@ -439,7 +439,7 @@ TargetBrowserPair* SkyBrowserModule::pair(std::string_view id) const {
);
TargetBrowserPair* found = it != _targetsBrowsers.end() ? it->get() : nullptr;
if (found == nullptr) {
LINFO(fmt::format("Identifier '{}' not found", id));
LINFO(std::format("Identifier '{}' not found", id));
}
return found;
}

View File

@@ -111,7 +111,7 @@ std::string prunedIdentifier(std::string identifier) {
imageUrl
);
if (!found.has_value()) {
LINFO(fmt::format(
LINFO(std::format(
"No image with identifier '{}' was found in the collection.", imageUrl
));
return;
@@ -160,7 +160,7 @@ std::string prunedIdentifier(std::string identifier) {
SceneGraphNode* circle = global::renderEngine->scene()->sceneGraphNode(identifier);
if (!circle) {
throw ghoul::lua::LuaError(fmt::format(
throw ghoul::lua::LuaError(std::format(
"Could not find node to set as hover circle: {}", identifier
));
}
@@ -242,7 +242,7 @@ std::string prunedIdentifier(std::string identifier) {
for (const std::unique_ptr<TargetBrowserPair>& pair : pairs) {
std::string id = pair->browserId();
glm::ivec3 color = pair->borderColor();
std::string script = fmt::format(
std::string script = std::format(
"openspace.skybrowser.setBorderColor('{}', {}, {}, {})",
id, color.r, color.g, color.b
);

View File

@@ -142,7 +142,7 @@ void Browser::deinitializeGL() {
_texture = nullptr;
LDEBUG(fmt::format("Deinitializing browser '{}'", _url.value()));
LDEBUG(std::format("Deinitializing browser '{}'", _url.value()));
_browserInstance->close(true);

View File

@@ -221,7 +221,7 @@ bool ScreenSpaceSkyBrowser::shouldUpdateWhileTargetAnimates() const {
void ScreenSpaceSkyBrowser::setIdInBrowser() const {
int currentNode = global::windowDelegate->currentNode();
WwtCommunicator::setIdInBrowser(fmt::format("{}_{}", identifier(), currentNode));
WwtCommunicator::setIdInBrowser(std::format("{}_{}", identifier(), currentNode));
}
void ScreenSpaceSkyBrowser::setIsInitialized(bool isInitialized) {

View File

@@ -45,7 +45,7 @@ namespace {
const glm::dvec3 positionCelestial = glm::normalize(direction) *
openspace::skybrowser::CelestialSphereRadius;
const std::string script = fmt::format(
const std::string script = std::format(
"openspace.setPropertyValueSingle('Scene.{}.Translation.Position', {});",
id, ghoul::to_string(positionCelestial)
);
@@ -322,7 +322,7 @@ void TargetBrowserPair::incrementallyAnimateToCoordinate() {
}
void TargetBrowserPair::startFading(float goal, float fadeTime) {
const std::string script = fmt::format(
const std::string script = std::format(
"openspace.setPropertyValueSingle('Scene.{0}.Renderable.Fade', {2}, {3});"
"openspace.setPropertyValueSingle('ScreenSpace.{1}.Fade', {2}, {3});",
_targetNode->identifier(), _browser->identifier(), goal, fadeTime

View File

@@ -187,7 +187,7 @@ void WwtCommunicator::removeSelectedImage(const std::string& imageUrl) {
void WwtCommunicator::sendMessageToWwt(const ghoul::Dictionary& msg) const {
std::string m = ghoul::formatJson(msg);
executeJavascript(fmt::format("sendMessageToWWT({});", m));
executeJavascript(std::format("sendMessageToWWT({});", m));
}
std::vector<std::string> WwtCommunicator::selectedImages() const {
@@ -239,12 +239,12 @@ void WwtCommunicator::setBorderColor(glm::ivec3 color) {
void WwtCommunicator::setBorderRadius(double radius) {
_borderRadius = radius;
const std::string scr = fmt::format("setBorderRadius({});", radius);
const std::string scr = std::format("setBorderRadius({});", radius);
executeJavascript(scr);
}
void WwtCommunicator::updateBorderColor() const {
const std::string script = fmt::format(
const std::string script = std::format(
"setBackgroundColor('rgb({},{},{})');",
_wwtBorderColor.x, _wwtBorderColor.y, _wwtBorderColor.z
);
@@ -348,7 +348,7 @@ void WwtCommunicator::setImageCollectionIsLoaded(bool isLoaded) {
void WwtCommunicator::setIdInBrowser(const std::string& id) const {
// Send ID to its browser
executeJavascript(fmt::format("setId('{}')", id));
executeJavascript(std::format("setId('{}')", id));
}
glm::ivec3 WwtCommunicator::borderColor() const {

View File

@@ -135,7 +135,7 @@ namespace {
const std::filesystem::path file = directory.string() + fileName + ".aspx";
const bool success = downloadFile(url, file);
if (!success) {
LINFO(fmt::format(
LINFO(std::format(
"Could not download file '{}' to directory '{}'", url, directory
));
return false;
@@ -154,7 +154,7 @@ namespace {
// If the file contains no folders, or there are folders but without urls,
// stop recursion
if (!folderExists || folderContainNoUrls) {
LINFO(fmt::format("Saving '{}'", url));
LINFO(std::format("Saving '{}'", url));
return true;
}
@@ -261,7 +261,7 @@ void WwtDataHandler::loadImages(const std::string& root,
// 1.
if (!directoryExists(directory)) {
LINFO(fmt::format("Creating directory '{}'", directory));
LINFO(std::format("Creating directory '{}'", directory));
std::filesystem::create_directory(directory);
}
@@ -291,7 +291,7 @@ void WwtDataHandler::loadImages(const std::string& root,
// Check if the hash has changed. This will be ignored if either the local of remote
// hash does not exist
if (!localHash.empty() && !remoteHash.empty() && localHash != remoteHash) {
LINFO(fmt::format(
LINFO(std::format(
"Local hash '{}' differs from remote hash '{}'. Cleaning directory",
localHash, remoteHash
));
@@ -338,7 +338,7 @@ void WwtDataHandler::loadImages(const std::string& root,
_images[imageVector[i].imageUrl].identifier = std::to_string(i);
}
LINFO(fmt::format("Loaded {} WorldWide Telescope images", _images.size()));
LINFO(std::format("Loaded {} WorldWide Telescope images", _images.size()));
}
int WwtDataHandler::nLoadedImages() const {
@@ -380,7 +380,7 @@ void WwtDataHandler::saveImagesFromXml(const tinyxml2::XMLElement* root,
// If node is another folder, open recursively
else if (name == Folder) {
const std::string nodeName = attribute(node, Name);
const std::string newCollectionName = fmt::format(
const std::string newCollectionName = std::format(
"{}/{}", collection, nodeName
);
saveImagesFromXml(node, newCollectionName);