[wpilibc] Use std::string_view instead of Twine (#3380)

Use fmtlib where needed for string formatting into std::string_view.
This commit is contained in:
Peter Johnson
2021-05-26 17:44:18 -07:00
committed by GitHub
parent 50915cb7ed
commit 4e2c3051be
76 changed files with 387 additions and 419 deletions

View File

@@ -13,7 +13,7 @@
using namespace frc;
Subsystem::Subsystem(const wpi::Twine& name) {
Subsystem::Subsystem(std::string_view name) {
SendableRegistry::GetInstance().AddLW(this, name, name);
Scheduler::GetInstance()->RegisterSubsystem(this);
}
@@ -40,12 +40,12 @@ Command* Subsystem::GetDefaultCommand() {
return m_defaultCommand;
}
wpi::StringRef Subsystem::GetDefaultCommandName() {
std::string Subsystem::GetDefaultCommandName() {
Command* defaultCommand = GetDefaultCommand();
if (defaultCommand) {
return SendableRegistry::GetInstance().GetName(defaultCommand);
} else {
return wpi::StringRef();
return {};
}
}
@@ -58,12 +58,12 @@ Command* Subsystem::GetCurrentCommand() const {
return m_currentCommand;
}
wpi::StringRef Subsystem::GetCurrentCommandName() const {
std::string Subsystem::GetCurrentCommandName() const {
Command* currentCommand = GetCurrentCommand();
if (currentCommand) {
return SendableRegistry::GetInstance().GetName(currentCommand);
} else {
return wpi::StringRef();
return {};
}
}
@@ -75,7 +75,7 @@ std::string Subsystem::GetName() const {
return SendableRegistry::GetInstance().GetName(this);
}
void Subsystem::SetName(const wpi::Twine& name) {
void Subsystem::SetName(std::string_view name) {
SendableRegistry::GetInstance().SetName(this, name);
}
@@ -83,20 +83,20 @@ std::string Subsystem::GetSubsystem() const {
return SendableRegistry::GetInstance().GetSubsystem(this);
}
void Subsystem::SetSubsystem(const wpi::Twine& name) {
void Subsystem::SetSubsystem(std::string_view name) {
SendableRegistry::GetInstance().SetSubsystem(this, name);
}
void Subsystem::AddChild(const wpi::Twine& name,
void Subsystem::AddChild(std::string_view name,
std::shared_ptr<Sendable> child) {
AddChild(name, *child);
}
void Subsystem::AddChild(const wpi::Twine& name, Sendable* child) {
void Subsystem::AddChild(std::string_view name, Sendable* child) {
AddChild(name, *child);
}
void Subsystem::AddChild(const wpi::Twine& name, Sendable& child) {
void Subsystem::AddChild(std::string_view name, Sendable& child) {
auto& registry = SendableRegistry::GetInstance();
registry.AddLW(&child, registry.GetSubsystem(this), name);
}