mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Use std::string_view and fmtlib across all libraries (#3402)
- Twine, StringRef, Format, and NativeFormatting have been removed - Logging now uses fmtlib style formatting - Nearly all uses of wpi::outs/errs have been replaced with fmt::print() or std::puts()/std::fputs() (for unformatted strings). - A wpi/fmt/raw_ostream.h header has been added to enable fmt::print() with wpi::raw_ostream
This commit is contained in:
@@ -6,6 +6,6 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
wpi::StringRef LayoutType::GetLayoutName() const {
|
||||
std::string_view LayoutType::GetLayoutName() const {
|
||||
return m_layoutName;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ void RecordingController::StopRecording() {
|
||||
m_recordingControlEntry.SetBoolean(false);
|
||||
}
|
||||
|
||||
void RecordingController::SetRecordingFileNameFormat(wpi::StringRef format) {
|
||||
void RecordingController::SetRecordingFileNameFormat(std::string_view format) {
|
||||
m_recordingFileNameFormatEntry.SetString(format);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ void RecordingController::ClearRecordingFileNameFormat() {
|
||||
}
|
||||
|
||||
void RecordingController::AddEventMarker(
|
||||
wpi::StringRef name, wpi::StringRef description,
|
||||
std::string_view name, std::string_view description,
|
||||
ShuffleboardEventImportance importance) {
|
||||
if (name.empty()) {
|
||||
FRC_ReportError(err::Error, "{}",
|
||||
@@ -43,5 +43,6 @@ void RecordingController::AddEventMarker(
|
||||
return;
|
||||
}
|
||||
m_eventsTable->GetSubTable(name)->GetEntry("Info").SetStringArray(
|
||||
{description, ShuffleboardEventImportanceName(importance)});
|
||||
{std::string{description},
|
||||
std::string{ShuffleboardEventImportanceName(importance)}});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ void Shuffleboard::Update() {
|
||||
GetInstance().Update();
|
||||
}
|
||||
|
||||
ShuffleboardTab& Shuffleboard::GetTab(wpi::StringRef title) {
|
||||
ShuffleboardTab& Shuffleboard::GetTab(std::string_view title) {
|
||||
return GetInstance().GetTab(title);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ void Shuffleboard::SelectTab(int index) {
|
||||
GetInstance().SelectTab(index);
|
||||
}
|
||||
|
||||
void Shuffleboard::SelectTab(wpi::StringRef title) {
|
||||
void Shuffleboard::SelectTab(std::string_view title) {
|
||||
GetInstance().SelectTab(title);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ void Shuffleboard::StopRecording() {
|
||||
GetRecordingController().StopRecording();
|
||||
}
|
||||
|
||||
void Shuffleboard::SetRecordingFileNameFormat(wpi::StringRef format) {
|
||||
void Shuffleboard::SetRecordingFileNameFormat(std::string_view format) {
|
||||
GetRecordingController().SetRecordingFileNameFormat(format);
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ void Shuffleboard::ClearRecordingFileNameFormat() {
|
||||
GetRecordingController().ClearRecordingFileNameFormat();
|
||||
}
|
||||
|
||||
void Shuffleboard::AddEventMarker(wpi::StringRef name,
|
||||
wpi::StringRef description,
|
||||
void Shuffleboard::AddEventMarker(std::string_view name,
|
||||
std::string_view description,
|
||||
ShuffleboardEventImportance importance) {
|
||||
GetRecordingController().AddEventMarker(name, description, importance);
|
||||
}
|
||||
|
||||
void Shuffleboard::AddEventMarker(wpi::StringRef name,
|
||||
void Shuffleboard::AddEventMarker(std::string_view name,
|
||||
ShuffleboardEventImportance importance) {
|
||||
AddEventMarker(name, "", importance);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
#include "frc/shuffleboard/ShuffleboardContainer.h"
|
||||
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/shuffleboard/ComplexWidget.h"
|
||||
#include "frc/shuffleboard/ShuffleboardComponent.h"
|
||||
@@ -70,7 +68,7 @@ ComplexWidget& ShuffleboardContainer::Add(std::string_view title,
|
||||
ComplexWidget& ShuffleboardContainer::Add(Sendable& sendable) {
|
||||
auto name = SendableRegistry::GetInstance().GetName(&sendable);
|
||||
if (name.empty()) {
|
||||
wpi::outs() << "Sendable must have a name\n";
|
||||
FRC_ReportError(err::Error, "{}", "Sendable must have a name");
|
||||
}
|
||||
return Add(name, sendable);
|
||||
}
|
||||
@@ -285,7 +283,7 @@ void ShuffleboardContainer::DisableIfActuator() {
|
||||
void ShuffleboardContainer::CheckTitle(std::string_view title) {
|
||||
std::string titleStr{title};
|
||||
if (m_usedTitles.count(titleStr) > 0) {
|
||||
wpi::errs() << "Title is already in use: " << title << "\n";
|
||||
FRC_ReportError(err::Error, "Title is already in use: {}", title);
|
||||
return;
|
||||
}
|
||||
m_usedTitles.insert(titleStr);
|
||||
|
||||
@@ -31,7 +31,7 @@ ShuffleboardInstance::ShuffleboardInstance(nt::NetworkTableInstance ntInstance)
|
||||
|
||||
ShuffleboardInstance::~ShuffleboardInstance() = default;
|
||||
|
||||
frc::ShuffleboardTab& ShuffleboardInstance::GetTab(wpi::StringRef title) {
|
||||
frc::ShuffleboardTab& ShuffleboardInstance::GetTab(std::string_view title) {
|
||||
if (m_impl->tabs.find(title) == m_impl->tabs.end()) {
|
||||
m_impl->tabs.try_emplace(title, ShuffleboardTab(*this, title));
|
||||
m_impl->tabsChanged = true;
|
||||
@@ -77,6 +77,6 @@ void ShuffleboardInstance::SelectTab(int index) {
|
||||
m_impl->rootMetaTable->GetEntry("Selected").ForceSetDouble(index);
|
||||
}
|
||||
|
||||
void ShuffleboardInstance::SelectTab(wpi::StringRef title) {
|
||||
void ShuffleboardInstance::SelectTab(std::string_view title) {
|
||||
m_impl->rootMetaTable->GetEntry("Selected").ForceSetString(title);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
ShuffleboardTab::ShuffleboardTab(ShuffleboardRoot& root, wpi::StringRef title)
|
||||
ShuffleboardTab::ShuffleboardTab(ShuffleboardRoot& root, std::string_view title)
|
||||
: ShuffleboardValue(title), ShuffleboardContainer(title), m_root(root) {}
|
||||
|
||||
ShuffleboardRoot& ShuffleboardTab::GetRoot() {
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
wpi::StringRef WidgetType::GetWidgetName() const {
|
||||
std::string_view WidgetType::GetWidgetName() const {
|
||||
return m_widgetName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user