GCC doesn't implement <format> yet, use fmt

This commit is contained in:
Dan Paulat 2023-04-17 18:24:50 -05:00
parent 593010acc2
commit 31db9a4315
12 changed files with 27 additions and 28 deletions

View file

@ -4,7 +4,6 @@
#include <scwx/common/sites.hpp>
#include <scwx/util/logger.hpp>
#include <format>
#include <shared_mutex>
#include <unordered_map>
@ -118,18 +117,18 @@ std::string RadarSite::location_name() const
if (p->country_ == "USA")
{
locationName = std::format("{}, {}", p->place_, p->state_);
locationName = fmt::format("{}, {}", p->place_, p->state_);
}
else if (std::all_of(p->state_.cbegin(),
p->state_.cend(),
[](char c) { return std::isdigit(c); }))
{
locationName = std::format("{}, {}", p->place_, p->country_);
locationName = fmt::format("{}, {}", p->place_, p->country_);
}
else
{
locationName =
std::format("{}, {}, {}", p->place_, p->state_, p->country_);
fmt::format("{}, {}, {}", p->place_, p->state_, p->country_);
}
return locationName;

View file

@ -254,14 +254,14 @@ std::string ProviderManager::name() const
if (group_ == common::RadarProductGroup::Level3)
{
name = std::format("{}, {}, {}",
name = fmt::format("{}, {}, {}",
radarId_,
common::GetRadarProductGroupName(group_),
product_);
}
else
{
name = std::format(
name = fmt::format(
"{}, {}", radarId_, common::GetRadarProductGroupName(group_));
}

View file

@ -18,6 +18,7 @@
#include <backends/imgui_impl_opengl3.h>
#include <backends/imgui_impl_qt.hpp>
#include <boost/uuid/random_generator.hpp>
#include <fmt/format.h>
#include <imgui.h>
#include <QApplication>
#include <QColor>
@ -89,7 +90,7 @@ public:
// Create ImGui Context
static size_t currentMapId_ {0u};
imGuiContextName_ = std::format("Map {}", ++currentMapId_);
imGuiContextName_ = fmt::format("Map {}", ++currentMapId_);
imGuiContext_ =
model::ImGuiContextModel::Instance().CreateContext(imGuiContextName_);

View file

@ -5,8 +5,6 @@
#include <scwx/common/geographic.hpp>
#include <scwx/util/logger.hpp>
#include <format>
namespace scwx
{
namespace qt

View file

@ -2,10 +2,10 @@
#include <scwx/qt/settings/settings_variable.hpp>
#include <scwx/qt/util/color.hpp>
#include <format>
#include <regex>
#include <boost/gil.hpp>
#include <fmt/format.h>
namespace scwx
{
@ -74,8 +74,8 @@ public:
for (auto& alert : kAlertColors_)
{
std::string phenomenonCode = awips::GetPhenomenonCode(alert.first);
std::string activeName = std::format("{}-active", phenomenonCode);
std::string inactiveName = std::format("{}-inactive", phenomenonCode);
std::string activeName = fmt::format("{}-active", phenomenonCode);
std::string inactiveName = fmt::format("{}-inactive", phenomenonCode);
auto activeResult = activeAlertColor_.emplace(
alert.first, SettingsVariable<std::string> {activeName});

View file

@ -1,8 +1,7 @@
#include <scwx/qt/types/text_event_key.hpp>
#include <format>
#include <boost/container_hash/hash.hpp>
#include <fmt/format.h>
namespace scwx
{
@ -15,7 +14,7 @@ static const std::string logPrefix_ = "scwx::qt::types::text_event_key";
std::string TextEventKey::ToFullString() const
{
return std::format("{} {} {} {:04}",
return fmt::format("{} {} {} {:04}",
officeId_,
awips::GetPhenomenonText(phenomenon_),
awips::GetSignificanceText(significance_),
@ -24,7 +23,7 @@ std::string TextEventKey::ToFullString() const
std::string TextEventKey::ToString() const
{
return std::format("{}.{}.{}.{:04}",
return fmt::format("{}.{}.{}.{:04}",
officeId_,
awips::GetPhenomenonCode(phenomenon_),
awips::GetSignificanceCode(significance_),

View file

@ -6,6 +6,7 @@
#include <imgui.h>
#include <backends/imgui_impl_opengl3.h>
#include <backends/imgui_impl_qt.hpp>
#include <fmt/format.h>
namespace scwx
{
@ -23,7 +24,7 @@ public:
{
// Create ImGui Context
static size_t currentIndex_ {0u};
contextName_ = std::format("ImGui Debug {}", ++currentIndex_);
contextName_ = fmt::format("ImGui Debug {}", ++currentIndex_);
context_ =
model::ImGuiContextModel::Instance().CreateContext(contextName_);
currentContext_ = context_;

View file

@ -12,8 +12,7 @@
#include <scwx/util/logger.hpp>
#include <scwx/util/threads.hpp>
#include <format>
#include <fmt/format.h>
#include <QColorDialog>
#include <QFileDialog>
#include <QToolButton>
@ -622,7 +621,7 @@ void SettingsDialogImpl::SetBackgroundColor(const std::string& value,
QFrame* frame)
{
frame->setStyleSheet(
QString::fromStdString(std::format("background-color: {}", value)));
QString::fromStdString(fmt::format("background-color: {}", value)));
}
void SettingsDialogImpl::UpdateRadarDialogLocation(const std::string& id)
@ -676,7 +675,7 @@ void SettingsDialogImpl::ResetToDefault()
std::string SettingsDialogImpl::RadarSiteLabel(
std::shared_ptr<config::RadarSite>& radarSite)
{
return std::format("{} ({})", radarSite->id(), radarSite->location_name());
return fmt::format("{} ({})", radarSite->id(), radarSite->location_name());
}
} // namespace ui

View file

@ -1,6 +1,6 @@
#include <scwx/qt/util/color.hpp>
#include <format>
#include <fmt/format.h>
#include <QColor>
namespace scwx
@ -16,7 +16,7 @@ static const std::string logPrefix_ = "scwx::qt::util::color";
std::string ToArgbString(const boost::gil::rgba8_pixel_t& color)
{
return std::format(
return fmt::format(
"#{:02x}{:02x}{:02x}{:02x}", color[3], color[0], color[1], color[2]);
}

View file

@ -13,6 +13,7 @@
#include <unordered_map>
#include <boost/timer/timer.hpp>
#include <fmt/format.h>
#include <imgui.h>
#include <QFile>
#include <QFileInfo>
@ -273,7 +274,7 @@ void FontImpl::CreateImGuiFont(QFile& fontFile,
// Assign name to font
strncpy(fontConfig.Name,
std::format("{}:{}", fileInfo.fileName().toStdString(), fontSize)
fmt::format("{}:{}", fileInfo.fileName().toStdString(), fontSize)
.c_str(),
sizeof(fontConfig.Name));
fontConfig.Name[sizeof(fontConfig.Name) - 1] = 0;

View file

@ -84,7 +84,7 @@ std::vector<std::string> Ugc::fips_ids() const
{
for (auto& id : fipsIdList.second)
{
fipsIds.push_back(std::format("{}{}{:03}",
fipsIds.push_back(fmt::format("{}{}{:03}",
fipsIdList.first,
ugcFormatMap_.left.at(p->format_),
id));

View file

@ -1,9 +1,10 @@
#include <scwx/common/geographic.hpp>
#include <scwx/common/characters.hpp>
#include <format>
#include <numbers>
#include <fmt/format.h>
namespace scwx
{
namespace common
@ -95,7 +96,7 @@ static std::string GetDegreeString(double degrees,
{
case DegreeStringType::Decimal:
degreeString =
std::format("{:.6f}{}{}", degrees, Unicode::kDegree, suffix);
fmt::format("{:.6f}{}{}", degrees, Unicode::kDegree, suffix);
break;
case DegreeStringType::DegreesMinutesSeconds:
{
@ -103,7 +104,7 @@ static std::string GetDegreeString(double degrees,
degrees = (degrees - dd) * 60.0;
uint32_t mm = static_cast<uint32_t>(degrees);
double ss = (degrees - mm) * 60.0;
degreeString = std::format(
degreeString = fmt::format(
"{}{} {}' {:.2f}\"{}", dd, Unicode::kDegree, mm, ss, suffix);
break;
}