diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp index d68ccc1dfa..654ba58037 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp @@ -30,7 +30,7 @@ wpi::SmallSet CommandBase::GetRequirements() const { return m_requirements; } -void CommandBase::SetName(const wpi::Twine& name) { +void CommandBase::SetName(std::string_view name) { frc::SendableRegistry::GetInstance().SetName(this, name); } @@ -42,7 +42,7 @@ std::string CommandBase::GetSubsystem() const { return frc::SendableRegistry::GetInstance().GetSubsystem(this); } -void CommandBase::SetSubsystem(const wpi::Twine& subsystem) { +void CommandBase::SetSubsystem(std::string_view subsystem) { frc::SendableRegistry::GetInstance().SetSubsystem(this, subsystem); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/PrintCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/PrintCommand.cpp index a9909ab772..af711aadc1 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/PrintCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/PrintCommand.cpp @@ -8,9 +8,9 @@ using namespace frc2; -PrintCommand::PrintCommand(const wpi::Twine& message) - : CommandHelper{[str = message.str()] { wpi::outs() << str << "\n"; }, {}} { -} +PrintCommand::PrintCommand(std::string_view message) + : CommandHelper{ + [str = std::string(message)] { wpi::outs() << str << "\n"; }, {}} {} bool PrintCommand::RunsWhenDisabled() const { return true; diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp index 65f3467437..c19a22e5c4 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp @@ -51,7 +51,7 @@ std::string SubsystemBase::GetName() const { return frc::SendableRegistry::GetInstance().GetName(this); } -void SubsystemBase::SetName(const wpi::Twine& name) { +void SubsystemBase::SetName(std::string_view name) { frc::SendableRegistry::GetInstance().SetName(this, name); } @@ -59,7 +59,7 @@ std::string SubsystemBase::GetSubsystem() const { return frc::SendableRegistry::GetInstance().GetSubsystem(this); } -void SubsystemBase::SetSubsystem(const wpi::Twine& name) { +void SubsystemBase::SetSubsystem(std::string_view name) { frc::SendableRegistry::GetInstance().SetSubsystem(this, name); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitCommand.cpp index f2eef1cdbc..0727602e43 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitCommand.cpp @@ -4,11 +4,13 @@ #include "frc2/command/WaitCommand.h" +#include + using namespace frc2; WaitCommand::WaitCommand(units::second_t duration) : m_duration{duration} { auto durationStr = std::to_string(duration.to()); - SetName(wpi::Twine(GetName()) + ": " + wpi::Twine(durationStr) + " seconds"); + SetName(fmt::format("{}: {} seconds", GetName(), durationStr)); } void WaitCommand::Initialize() { diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/NetworkButton.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/button/NetworkButton.cpp index 9b7288f51f..3886c625d0 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/NetworkButton.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/button/NetworkButton.cpp @@ -12,9 +12,9 @@ NetworkButton::NetworkButton(nt::NetworkTableEntry entry) }) {} NetworkButton::NetworkButton(std::shared_ptr table, - const wpi::Twine& field) + std::string_view field) : NetworkButton(table->GetEntry(field)) {} -NetworkButton::NetworkButton(const wpi::Twine& table, const wpi::Twine& field) +NetworkButton::NetworkButton(std::string_view table, std::string_view field) : NetworkButton(nt::NetworkTableInstance::GetDefault().GetTable(table), field) {} diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h index 68530742bf..b37f3df417 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h @@ -6,12 +6,12 @@ #include #include +#include #include #include #include #include -#include #include "frc2/command/Command.h" @@ -46,7 +46,7 @@ class CommandBase : public Command, * * @param name name */ - void SetName(const wpi::Twine& name); + void SetName(std::string_view name); /** * Gets the name of this Command. @@ -67,7 +67,7 @@ class CommandBase : public Command, * * @param subsystem subsystem name */ - void SetSubsystem(const wpi::Twine& subsystem); + void SetSubsystem(std::string_view subsystem); void InitSendable(frc::SendableBuilder& builder) override; diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/PrintCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/PrintCommand.h index 3312200168..536e77f46f 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/PrintCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/PrintCommand.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include "frc2/command/CommandHelper.h" #include "frc2/command/InstantCommand.h" @@ -20,7 +20,7 @@ class PrintCommand : public CommandHelper { * * @param message the message to print */ - explicit PrintCommand(const wpi::Twine& message); + explicit PrintCommand(std::string_view message); PrintCommand(PrintCommand&& other) = default; diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h b/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h index 90fcd55045..06ea69e4a4 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include @@ -34,7 +35,7 @@ class SubsystemBase : public Subsystem, * * @param name name */ - void SetName(const wpi::Twine& name); + void SetName(std::string_view name); /** * Gets the subsystem name of this Subsystem. @@ -48,7 +49,7 @@ class SubsystemBase : public Subsystem, * * @param subsystem subsystem name */ - void SetSubsystem(const wpi::Twine& name); + void SetSubsystem(std::string_view name); /** * Associate a Sendable with this Subsystem. diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/button/NetworkButton.h b/wpilibNewCommands/src/main/native/include/frc2/command/button/NetworkButton.h index f0d9ca21f3..a33702c621 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/button/NetworkButton.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/button/NetworkButton.h @@ -5,10 +5,10 @@ #pragma once #include +#include #include #include -#include #include "Button.h" @@ -32,7 +32,7 @@ class NetworkButton : public Button { * @param field The field that is the value. */ NetworkButton(std::shared_ptr table, - const wpi::Twine& field); + std::string_view field); /** * Creates a NetworkButton that commands can be bound to. @@ -40,6 +40,6 @@ class NetworkButton : public Button { * @param table The table where the networktable value is located. * @param field The field that is the value. */ - NetworkButton(const wpi::Twine& table, const wpi::Twine& field); + NetworkButton(std::string_view table, std::string_view field); }; } // namespace frc2 diff --git a/wpilibOldCommands/src/main/native/cpp/buttons/NetworkButton.cpp b/wpilibOldCommands/src/main/native/cpp/buttons/NetworkButton.cpp index f1be1ad6ee..f5694a14f0 100644 --- a/wpilibOldCommands/src/main/native/cpp/buttons/NetworkButton.cpp +++ b/wpilibOldCommands/src/main/native/cpp/buttons/NetworkButton.cpp @@ -9,13 +9,12 @@ using namespace frc; -NetworkButton::NetworkButton(const wpi::Twine& tableName, - const wpi::Twine& field) +NetworkButton::NetworkButton(std::string_view tableName, std::string_view field) : NetworkButton(nt::NetworkTableInstance::GetDefault().GetTable(tableName), field) {} NetworkButton::NetworkButton(std::shared_ptr table, - const wpi::Twine& field) + std::string_view field) : m_entry(table->GetEntry(field)) {} bool NetworkButton::Get() { diff --git a/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp b/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp index 1d58b68fba..ab7449ed47 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp @@ -21,7 +21,7 @@ int Command::m_commandCounter = 0; Command::Command() : Command("", -1.0) {} -Command::Command(const wpi::Twine& name) : Command(name, -1.0) {} +Command::Command(std::string_view name) : Command(name, -1.0) {} Command::Command(double timeout) : Command("", timeout) {} @@ -29,7 +29,7 @@ Command::Command(Subsystem& subsystem) : Command("", -1.0) { Requires(&subsystem); } -Command::Command(const wpi::Twine& name, double timeout) { +Command::Command(std::string_view name, double timeout) { // We use -1.0 to indicate no timeout. if (timeout < 0.0 && timeout != -1.0) { throw FRC_MakeError(err::ParameterOutOfRange, "timeout {} < 0.0", timeout); @@ -38,16 +38,15 @@ Command::Command(const wpi::Twine& name, double timeout) { m_timeout = timeout; // If name contains an empty string - if (name.isTriviallyEmpty() || - (name.isSingleStringRef() && name.getSingleStringRef().empty())) { + if (name.empty()) { SendableRegistry::GetInstance().Add( - this, "Command_" + wpi::Twine(typeid(*this).name())); + this, fmt::format("Command_{}", typeid(*this).name())); } else { SendableRegistry::GetInstance().Add(this, name); } } -Command::Command(const wpi::Twine& name, Subsystem& subsystem) +Command::Command(std::string_view name, Subsystem& subsystem) : Command(name, -1.0) { Requires(&subsystem); } @@ -56,7 +55,7 @@ Command::Command(double timeout, Subsystem& subsystem) : Command("", timeout) { Requires(&subsystem); } -Command::Command(const wpi::Twine& name, double timeout, Subsystem& subsystem) +Command::Command(std::string_view name, double timeout, Subsystem& subsystem) : Command(name, timeout) { Requires(&subsystem); } @@ -183,7 +182,7 @@ bool Command::IsTimedOut() const { return m_timeout != -1 && TimeSinceInitialized() >= m_timeout; } -bool Command::AssertUnlocked(const std::string& message) { +bool Command::AssertUnlocked(std::string_view message) { if (m_locked) { throw FRC_MakeError( err::CommandIllegalUse, @@ -277,7 +276,7 @@ std::string Command::GetName() const { return SendableRegistry::GetInstance().GetName(this); } -void Command::SetName(const wpi::Twine& name) { +void Command::SetName(std::string_view name) { SendableRegistry::GetInstance().SetName(this, name); } @@ -285,7 +284,7 @@ std::string Command::GetSubsystem() const { return SendableRegistry::GetInstance().GetSubsystem(this); } -void Command::SetSubsystem(const wpi::Twine& name) { +void Command::SetSubsystem(std::string_view name) { SendableRegistry::GetInstance().SetSubsystem(this, name); } diff --git a/wpilibOldCommands/src/main/native/cpp/commands/CommandGroup.cpp b/wpilibOldCommands/src/main/native/cpp/commands/CommandGroup.cpp index 6c512e52c5..03bee24006 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/CommandGroup.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/CommandGroup.cpp @@ -8,7 +8,7 @@ using namespace frc; -CommandGroup::CommandGroup(const wpi::Twine& name) : Command(name) {} +CommandGroup::CommandGroup(std::string_view name) : Command(name) {} void CommandGroup::AddSequential(Command* command) { if (!command) { diff --git a/wpilibOldCommands/src/main/native/cpp/commands/ConditionalCommand.cpp b/wpilibOldCommands/src/main/native/cpp/commands/ConditionalCommand.cpp index 5b507d7f2f..e2867b5c8e 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/ConditionalCommand.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/ConditionalCommand.cpp @@ -28,7 +28,7 @@ ConditionalCommand::ConditionalCommand(Command* onTrue, Command* onFalse) { RequireAll(*this, onTrue, onFalse); } -ConditionalCommand::ConditionalCommand(const wpi::Twine& name, Command* onTrue, +ConditionalCommand::ConditionalCommand(std::string_view name, Command* onTrue, Command* onFalse) : Command(name) { m_onTrue = onTrue; diff --git a/wpilibOldCommands/src/main/native/cpp/commands/InstantCommand.cpp b/wpilibOldCommands/src/main/native/cpp/commands/InstantCommand.cpp index ea8f720bf3..d8f3309cc0 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/InstantCommand.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/InstantCommand.cpp @@ -8,11 +8,11 @@ using namespace frc; -InstantCommand::InstantCommand(const wpi::Twine& name) : Command(name) {} +InstantCommand::InstantCommand(std::string_view name) : Command(name) {} InstantCommand::InstantCommand(Subsystem& subsystem) : Command(subsystem) {} -InstantCommand::InstantCommand(const wpi::Twine& name, Subsystem& subsystem) +InstantCommand::InstantCommand(std::string_view name, Subsystem& subsystem) : Command(name, subsystem) {} InstantCommand::InstantCommand(std::function func) @@ -23,13 +23,13 @@ InstantCommand::InstantCommand(Subsystem& subsystem, std::function func) m_func = func; } -InstantCommand::InstantCommand(const wpi::Twine& name, +InstantCommand::InstantCommand(std::string_view name, std::function func) : InstantCommand(name) { m_func = func; } -InstantCommand::InstantCommand(const wpi::Twine& name, Subsystem& subsystem, +InstantCommand::InstantCommand(std::string_view name, Subsystem& subsystem, std::function func) : InstantCommand(name, subsystem) { m_func = func; diff --git a/wpilibOldCommands/src/main/native/cpp/commands/PIDCommand.cpp b/wpilibOldCommands/src/main/native/cpp/commands/PIDCommand.cpp index 25c3ed6ad9..152149e9cd 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/PIDCommand.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/PIDCommand.cpp @@ -8,7 +8,7 @@ using namespace frc; -PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d, +PIDCommand::PIDCommand(std::string_view name, double p, double i, double d, double f, double period) : Command(name) { m_controller = std::make_shared(p, i, d, this, this, period); @@ -19,12 +19,12 @@ PIDCommand::PIDCommand(double p, double i, double d, double f, double period) { std::make_shared(p, i, d, f, this, this, period); } -PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d) +PIDCommand::PIDCommand(std::string_view name, double p, double i, double d) : Command(name) { m_controller = std::make_shared(p, i, d, this, this); } -PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d, +PIDCommand::PIDCommand(std::string_view name, double p, double i, double d, double period) : Command(name) { m_controller = std::make_shared(p, i, d, this, this, period); @@ -38,7 +38,7 @@ PIDCommand::PIDCommand(double p, double i, double d, double period) { m_controller = std::make_shared(p, i, d, this, this, period); } -PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d, +PIDCommand::PIDCommand(std::string_view name, double p, double i, double d, double f, double period, Subsystem& subsystem) : Command(name, subsystem) { m_controller = std::make_shared(p, i, d, this, this, period); @@ -51,13 +51,13 @@ PIDCommand::PIDCommand(double p, double i, double d, double f, double period, std::make_shared(p, i, d, f, this, this, period); } -PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d, +PIDCommand::PIDCommand(std::string_view name, double p, double i, double d, Subsystem& subsystem) : Command(name, subsystem) { m_controller = std::make_shared(p, i, d, this, this); } -PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d, +PIDCommand::PIDCommand(std::string_view name, double p, double i, double d, double period, Subsystem& subsystem) : Command(name, subsystem) { m_controller = std::make_shared(p, i, d, this, this, period); diff --git a/wpilibOldCommands/src/main/native/cpp/commands/PIDSubsystem.cpp b/wpilibOldCommands/src/main/native/cpp/commands/PIDSubsystem.cpp index 02765da897..f76288b46c 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/PIDSubsystem.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/PIDSubsystem.cpp @@ -8,20 +8,20 @@ using namespace frc; -PIDSubsystem::PIDSubsystem(const wpi::Twine& name, double p, double i, double d) +PIDSubsystem::PIDSubsystem(std::string_view name, double p, double i, double d) : Subsystem(name) { m_controller = std::make_shared(p, i, d, this, this); AddChild("PIDController", m_controller); } -PIDSubsystem::PIDSubsystem(const wpi::Twine& name, double p, double i, double d, +PIDSubsystem::PIDSubsystem(std::string_view name, double p, double i, double d, double f) : Subsystem(name) { m_controller = std::make_shared(p, i, d, f, this, this); AddChild("PIDController", m_controller); } -PIDSubsystem::PIDSubsystem(const wpi::Twine& name, double p, double i, double d, +PIDSubsystem::PIDSubsystem(std::string_view name, double p, double i, double d, double f, double period) : Subsystem(name) { m_controller = diff --git a/wpilibOldCommands/src/main/native/cpp/commands/PrintCommand.cpp b/wpilibOldCommands/src/main/native/cpp/commands/PrintCommand.cpp index 6f2a58b33b..3589feea2d 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/PrintCommand.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/PrintCommand.cpp @@ -4,13 +4,14 @@ #include "frc/commands/PrintCommand.h" +#include #include using namespace frc; -PrintCommand::PrintCommand(const wpi::Twine& message) - : InstantCommand("Print \"" + message + wpi::Twine('"')) { - m_message = message.str(); +PrintCommand::PrintCommand(std::string_view message) + : InstantCommand(fmt::format("Print \"{}\"", message)) { + m_message = message; } void PrintCommand::Initialize() { diff --git a/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp b/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp index 27074abe68..ffb02788f3 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp @@ -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 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); } diff --git a/wpilibOldCommands/src/main/native/cpp/commands/TimedCommand.cpp b/wpilibOldCommands/src/main/native/cpp/commands/TimedCommand.cpp index 5a91068982..922e1553f6 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/TimedCommand.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/TimedCommand.cpp @@ -6,12 +6,12 @@ using namespace frc; -TimedCommand::TimedCommand(const wpi::Twine& name, double timeout) +TimedCommand::TimedCommand(std::string_view name, double timeout) : Command(name, timeout) {} TimedCommand::TimedCommand(double timeout) : Command(timeout) {} -TimedCommand::TimedCommand(const wpi::Twine& name, double timeout, +TimedCommand::TimedCommand(std::string_view name, double timeout, Subsystem& subsystem) : Command(name, timeout, subsystem) {} diff --git a/wpilibOldCommands/src/main/native/cpp/commands/WaitCommand.cpp b/wpilibOldCommands/src/main/native/cpp/commands/WaitCommand.cpp index d537736ad6..90aba8e4ce 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/WaitCommand.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/WaitCommand.cpp @@ -4,10 +4,12 @@ #include "frc/commands/WaitCommand.h" +#include + using namespace frc; WaitCommand::WaitCommand(double timeout) - : TimedCommand("Wait(" + std::to_string(timeout) + ")", timeout) {} + : TimedCommand(fmt::format("Wait({})", timeout), timeout) {} -WaitCommand::WaitCommand(const wpi::Twine& name, double timeout) +WaitCommand::WaitCommand(std::string_view name, double timeout) : TimedCommand(name, timeout) {} diff --git a/wpilibOldCommands/src/main/native/cpp/commands/WaitForChildren.cpp b/wpilibOldCommands/src/main/native/cpp/commands/WaitForChildren.cpp index 7898f01470..70d1a64b08 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/WaitForChildren.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/WaitForChildren.cpp @@ -11,7 +11,7 @@ using namespace frc; WaitForChildren::WaitForChildren(double timeout) : Command("WaitForChildren", timeout) {} -WaitForChildren::WaitForChildren(const wpi::Twine& name, double timeout) +WaitForChildren::WaitForChildren(std::string_view name, double timeout) : Command(name, timeout) {} bool WaitForChildren::IsFinished() { diff --git a/wpilibOldCommands/src/main/native/cpp/commands/WaitUntilCommand.cpp b/wpilibOldCommands/src/main/native/cpp/commands/WaitUntilCommand.cpp index 338d128a73..8fd2e33620 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/WaitUntilCommand.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/WaitUntilCommand.cpp @@ -13,7 +13,7 @@ WaitUntilCommand::WaitUntilCommand(double time) m_time = time; } -WaitUntilCommand::WaitUntilCommand(const wpi::Twine& name, double time) +WaitUntilCommand::WaitUntilCommand(std::string_view name, double time) : Command(name, time) { m_time = time; } diff --git a/wpilibOldCommands/src/main/native/include/frc/buttons/NetworkButton.h b/wpilibOldCommands/src/main/native/include/frc/buttons/NetworkButton.h index 7a2a27c1f2..3c468df72c 100644 --- a/wpilibOldCommands/src/main/native/include/frc/buttons/NetworkButton.h +++ b/wpilibOldCommands/src/main/native/include/frc/buttons/NetworkButton.h @@ -5,10 +5,10 @@ #pragma once #include +#include #include #include -#include #include "frc/buttons/Button.h" @@ -16,9 +16,9 @@ namespace frc { class NetworkButton : public Button { public: - NetworkButton(const wpi::Twine& tableName, const wpi::Twine& field); + NetworkButton(std::string_view tableName, std::string_view field); NetworkButton(std::shared_ptr table, - const wpi::Twine& field); + std::string_view field); ~NetworkButton() override = default; NetworkButton(NetworkButton&&) = default; diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/Command.h b/wpilibOldCommands/src/main/native/include/frc/commands/Command.h index 3863f85836..21929acbce 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/Command.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/Command.h @@ -6,9 +6,9 @@ #include #include +#include #include -#include #include "frc/commands/Subsystem.h" #include "frc/smartdashboard/Sendable.h" @@ -59,7 +59,7 @@ class Command : public Sendable, public SendableHelper { * * @param name the name for this command */ - explicit Command(const wpi::Twine& name); + explicit Command(std::string_view name); /** * Creates a new command with the given timeout and a default name. @@ -83,7 +83,7 @@ class Command : public Sendable, public SendableHelper { * @param timeout the time (in seconds) before this command "times out" * @see IsTimedOut() */ - Command(const wpi::Twine& name, double timeout); + Command(std::string_view name, double timeout); /** * Creates a new command with the given name and timeout. @@ -91,7 +91,7 @@ class Command : public Sendable, public SendableHelper { * @param name the name of the command * @param subsystem the subsystem that the command requires */ - Command(const wpi::Twine& name, Subsystem& subsystem); + Command(std::string_view name, Subsystem& subsystem); /** * Creates a new command with the given name and timeout. @@ -108,7 +108,7 @@ class Command : public Sendable, public SendableHelper { * @param timeout the time (in seconds) before this command "times out" * @param subsystem the subsystem that the command requires @see IsTimedOut() */ - Command(const wpi::Twine& name, double timeout, Subsystem& subsystem); + Command(std::string_view name, double timeout, Subsystem& subsystem); ~Command() override = default; @@ -293,7 +293,7 @@ class Command : public Sendable, public SendableHelper { * message) * @return True if assert passed, false if assert failed. */ - bool AssertUnlocked(const std::string& message); + bool AssertUnlocked(std::string_view message); /** * Sets the parent of this command. No actual change is made to the group. @@ -395,7 +395,7 @@ class Command : public Sendable, public SendableHelper { * * @param name name */ - void SetName(const wpi::Twine& name); + void SetName(std::string_view name); /** * Gets the subsystem name of this Command. @@ -409,7 +409,7 @@ class Command : public Sendable, public SendableHelper { * * @param subsystem subsystem name */ - void SetSubsystem(const wpi::Twine& subsystem); + void SetSubsystem(std::string_view subsystem); private: /** diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/CommandGroup.h b/wpilibOldCommands/src/main/native/include/frc/commands/CommandGroup.h index 2f34946bea..70fb7a49c9 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/CommandGroup.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/CommandGroup.h @@ -4,10 +4,9 @@ #pragma once +#include #include -#include - #include "frc/commands/Command.h" #include "frc/commands/CommandGroupEntry.h" @@ -39,7 +38,7 @@ class CommandGroup : public Command { * * @param name The name for this command group */ - explicit CommandGroup(const wpi::Twine& name); + explicit CommandGroup(std::string_view name); ~CommandGroup() override = default; diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/ConditionalCommand.h b/wpilibOldCommands/src/main/native/include/frc/commands/ConditionalCommand.h index 7c28dd3731..19d6d755fd 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/ConditionalCommand.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/ConditionalCommand.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include "frc/commands/Command.h" @@ -46,7 +46,7 @@ class ConditionalCommand : public Command { * @param onTrue The Command to execute if Condition() returns true * @param onFalse The Command to execute if Condition() returns false */ - ConditionalCommand(const wpi::Twine& name, Command* onTrue, + ConditionalCommand(std::string_view name, Command* onTrue, Command* onFalse = nullptr); ~ConditionalCommand() override = default; diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/InstantCommand.h b/wpilibOldCommands/src/main/native/include/frc/commands/InstantCommand.h index 90b895245c..d16b34e582 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/InstantCommand.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/InstantCommand.h @@ -5,8 +5,7 @@ #pragma once #include - -#include +#include #include "frc/commands/Command.h" #include "frc/commands/Subsystem.h" @@ -25,7 +24,7 @@ class InstantCommand : public Command { * * @param name The name for this command */ - explicit InstantCommand(const wpi::Twine& name); + explicit InstantCommand(std::string_view name); /** * Creates a new InstantCommand with the given requirement. @@ -40,7 +39,7 @@ class InstantCommand : public Command { * @param name The name for this command * @param subsystem The subsystem that the command requires */ - InstantCommand(const wpi::Twine& name, Subsystem& subsystem); + InstantCommand(std::string_view name, Subsystem& subsystem); /** * Create a command that calls the given function when run. @@ -63,7 +62,7 @@ class InstantCommand : public Command { * @param name The name of the command. * @param func The function to run when Initialize() is run. */ - InstantCommand(const wpi::Twine& name, std::function func); + InstantCommand(std::string_view name, std::function func); /** * Create a command that calls the given function when run. @@ -72,7 +71,7 @@ class InstantCommand : public Command { * @param subsystem The subsystems that this command runs on. * @param func The function to run when Initialize() is run. */ - InstantCommand(const wpi::Twine& name, Subsystem& subsystem, + InstantCommand(std::string_view name, Subsystem& subsystem, std::function func); InstantCommand() = default; diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/PIDCommand.h b/wpilibOldCommands/src/main/native/include/frc/commands/PIDCommand.h index 52e00d2c76..257b67f052 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/PIDCommand.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/PIDCommand.h @@ -5,8 +5,7 @@ #pragma once #include - -#include +#include #include "frc/PIDController.h" #include "frc/PIDOutput.h" @@ -17,19 +16,19 @@ namespace frc { class PIDCommand : public Command, public PIDOutput, public PIDSource { public: - PIDCommand(const wpi::Twine& name, double p, double i, double d); - PIDCommand(const wpi::Twine& name, double p, double i, double d, + PIDCommand(std::string_view name, double p, double i, double d); + PIDCommand(std::string_view name, double p, double i, double d, double period); - PIDCommand(const wpi::Twine& name, double p, double i, double d, double f, + PIDCommand(std::string_view name, double p, double i, double d, double f, double period); PIDCommand(double p, double i, double d); PIDCommand(double p, double i, double d, double period); PIDCommand(double p, double i, double d, double f, double period); - PIDCommand(const wpi::Twine& name, double p, double i, double d, + PIDCommand(std::string_view name, double p, double i, double d, Subsystem& subsystem); - PIDCommand(const wpi::Twine& name, double p, double i, double d, - double period, Subsystem& subsystem); - PIDCommand(const wpi::Twine& name, double p, double i, double d, double f, + PIDCommand(std::string_view name, double p, double i, double d, double period, + Subsystem& subsystem); + PIDCommand(std::string_view name, double p, double i, double d, double f, double period, Subsystem& subsystem); PIDCommand(double p, double i, double d, Subsystem& subsystem); PIDCommand(double p, double i, double d, double period, Subsystem& subsystem); diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/PIDSubsystem.h b/wpilibOldCommands/src/main/native/include/frc/commands/PIDSubsystem.h index 456f8e1fe0..6339c26999 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/PIDSubsystem.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/PIDSubsystem.h @@ -5,8 +5,7 @@ #pragma once #include - -#include +#include #include "frc/PIDController.h" #include "frc/PIDOutput.h" @@ -34,7 +33,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource { * @param i the integral value * @param d the derivative value */ - PIDSubsystem(const wpi::Twine& name, double p, double i, double d); + PIDSubsystem(std::string_view name, double p, double i, double d); /** * Instantiates a PIDSubsystem that will use the given P, I, D, and F values. @@ -45,7 +44,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource { * @param d the derivative value * @param f the feedforward value */ - PIDSubsystem(const wpi::Twine& name, double p, double i, double d, double f); + PIDSubsystem(std::string_view name, double p, double i, double d, double f); /** * Instantiates a PIDSubsystem that will use the given P, I, D, and F values. @@ -60,7 +59,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource { * @param f the feedfoward value * @param period the time (in seconds) between calculations */ - PIDSubsystem(const wpi::Twine& name, double p, double i, double d, double f, + PIDSubsystem(std::string_view name, double p, double i, double d, double f, double period); /** diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/PrintCommand.h b/wpilibOldCommands/src/main/native/include/frc/commands/PrintCommand.h index 4a48647f3c..01d0d4bbb1 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/PrintCommand.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/PrintCommand.h @@ -5,8 +5,7 @@ #pragma once #include - -#include +#include #include "frc/commands/InstantCommand.h" @@ -14,7 +13,7 @@ namespace frc { class PrintCommand : public InstantCommand { public: - explicit PrintCommand(const wpi::Twine& message); + explicit PrintCommand(std::string_view message); ~PrintCommand() override = default; PrintCommand(PrintCommand&&) = default; diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/Subsystem.h b/wpilibOldCommands/src/main/native/include/frc/commands/Subsystem.h index fe3a997861..71c9ce4cf2 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/Subsystem.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/Subsystem.h @@ -6,9 +6,7 @@ #include #include - -#include -#include +#include #include "frc/smartdashboard/Sendable.h" #include "frc/smartdashboard/SendableHelper.h" @@ -26,7 +24,7 @@ class Subsystem : public Sendable, public SendableHelper { * * @param name the name of the subsystem */ - explicit Subsystem(const wpi::Twine& name); + explicit Subsystem(std::string_view name); Subsystem(Subsystem&&) = default; Subsystem& operator=(Subsystem&&) = default; @@ -54,7 +52,7 @@ class Subsystem : public Sendable, public SendableHelper { * * @return the default command name */ - wpi::StringRef GetDefaultCommandName(); + std::string GetDefaultCommandName(); /** * Sets the current command. @@ -75,7 +73,7 @@ class Subsystem : public Sendable, public SendableHelper { * * @return the current command name */ - wpi::StringRef GetCurrentCommandName() const; + std::string GetCurrentCommandName() const; /** * When the run method of the scheduler is called this method will be called. @@ -106,7 +104,7 @@ class Subsystem : public Sendable, public SendableHelper { * * @param name name */ - void SetName(const wpi::Twine& name); + void SetName(std::string_view name); /** * Gets the subsystem name of this Subsystem. @@ -120,7 +118,7 @@ class Subsystem : public Sendable, public SendableHelper { * * @param subsystem subsystem name */ - void SetSubsystem(const wpi::Twine& subsystem); + void SetSubsystem(std::string_view subsystem); /** * Associate a Sendable with this Subsystem. @@ -129,7 +127,7 @@ class Subsystem : public Sendable, public SendableHelper { * @param name name to give child * @param child sendable */ - void AddChild(const wpi::Twine& name, std::shared_ptr child); + void AddChild(std::string_view name, std::shared_ptr child); /** * Associate a Sendable with this Subsystem. @@ -138,7 +136,7 @@ class Subsystem : public Sendable, public SendableHelper { * @param name name to give child * @param child sendable */ - void AddChild(const wpi::Twine& name, Sendable* child); + void AddChild(std::string_view name, Sendable* child); /** * Associate a Sendable with this Subsystem. @@ -147,7 +145,7 @@ class Subsystem : public Sendable, public SendableHelper { * @param name name to give child * @param child sendable */ - void AddChild(const wpi::Twine& name, Sendable& child); + void AddChild(std::string_view name, Sendable& child); /** * Associate a {@link Sendable} with this Subsystem. diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/TimedCommand.h b/wpilibOldCommands/src/main/native/include/frc/commands/TimedCommand.h index 710cf93a22..725de3095f 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/TimedCommand.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/TimedCommand.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include "frc/commands/Command.h" @@ -23,7 +23,7 @@ class TimedCommand : public Command { * @param name the name of the command * @param timeout the time (in seconds) before this command "times out" */ - TimedCommand(const wpi::Twine& name, double timeout); + TimedCommand(std::string_view name, double timeout); /** * Creates a new WaitCommand with the given timeout. @@ -39,7 +39,7 @@ class TimedCommand : public Command { * @param timeout the time (in seconds) before this command "times out" * @param subsystem the subsystem that the command requires */ - TimedCommand(const wpi::Twine& name, double timeout, Subsystem& subsystem); + TimedCommand(std::string_view name, double timeout, Subsystem& subsystem); /** * Creates a new WaitCommand with the given timeout. diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/WaitCommand.h b/wpilibOldCommands/src/main/native/include/frc/commands/WaitCommand.h index d1ca7997c1..890cfd6332 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/WaitCommand.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/WaitCommand.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include "frc/commands/TimedCommand.h" @@ -25,7 +25,7 @@ class WaitCommand : public TimedCommand { * * @param timeout the time (in seconds) before this command "times out" */ - WaitCommand(const wpi::Twine& name, double timeout); + WaitCommand(std::string_view name, double timeout); ~WaitCommand() override = default; diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/WaitForChildren.h b/wpilibOldCommands/src/main/native/include/frc/commands/WaitForChildren.h index 87334ec82b..fcf330c4d1 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/WaitForChildren.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/WaitForChildren.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include "frc/commands/Command.h" @@ -13,7 +13,7 @@ namespace frc { class WaitForChildren : public Command { public: explicit WaitForChildren(double timeout); - WaitForChildren(const wpi::Twine& name, double timeout); + WaitForChildren(std::string_view name, double timeout); ~WaitForChildren() override = default; WaitForChildren(WaitForChildren&&) = default; diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/WaitUntilCommand.h b/wpilibOldCommands/src/main/native/include/frc/commands/WaitUntilCommand.h index 46c3fc4c01..fbf61f1e5d 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/WaitUntilCommand.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/WaitUntilCommand.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include "frc/commands/Command.h" @@ -22,7 +22,7 @@ class WaitUntilCommand : public Command { */ explicit WaitUntilCommand(double time); - WaitUntilCommand(const wpi::Twine& name, double time); + WaitUntilCommand(std::string_view name, double time); ~WaitUntilCommand() override = default; diff --git a/wpilibc/src/main/native/cpp/DriverStation.cpp b/wpilibc/src/main/native/cpp/DriverStation.cpp index babc702570..d71e44a895 100644 --- a/wpilibc/src/main/native/cpp/DriverStation.cpp +++ b/wpilibc/src/main/native/cpp/DriverStation.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -26,7 +27,7 @@ template class MatchDataSenderEntry { public: MatchDataSenderEntry(const std::shared_ptr& table, - const wpi::Twine& key, const T& initialVal) { + std::string_view key, const T& initialVal) { static_assert(std::is_same_v || std::is_same_v || std::is_same_v, "Invalid type for MatchDataSenderEntry - must be " @@ -56,7 +57,7 @@ class MatchDataSenderEntry { void SetValue(bool val) { ntEntry.SetBoolean(val); } void SetValue(double val) { ntEntry.SetDouble(val); } - void SetValue(const wpi::Twine& val) { ntEntry.SetString(val); } + void SetValue(std::string_view val) { ntEntry.SetString(val); } }; class MatchDataSender { diff --git a/wpilibc/src/main/native/cpp/Notifier.cpp b/wpilibc/src/main/native/cpp/Notifier.cpp index 4094e42dbd..9b25c091d5 100644 --- a/wpilibc/src/main/native/cpp/Notifier.cpp +++ b/wpilibc/src/main/native/cpp/Notifier.cpp @@ -6,10 +6,10 @@ #include +#include #include #include #include -#include #include "frc/Errors.h" #include "frc/Timer.h" @@ -138,11 +138,12 @@ Notifier& Notifier::operator=(Notifier&& rhs) { return *this; } -void Notifier::SetName(const wpi::Twine& name) { - wpi::SmallString<64> nameBuf; +void Notifier::SetName(std::string_view name) { + fmt::memory_buffer buf; + fmt::format_to(buf, "{}", name); + buf.push_back('\0'); // null terminate int32_t status = 0; - HAL_SetNotifierName(m_notifier, - name.toNullTerminatedStringRef(nameBuf).data(), &status); + HAL_SetNotifierName(m_notifier, buf.data(), &status); } void Notifier::SetHandler(std::function handler) { diff --git a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp index b410100afb..ed7296020f 100644 --- a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp +++ b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp @@ -4,6 +4,7 @@ #include "frc/PowerDistributionPanel.h" +#include #include #include #include @@ -99,7 +100,7 @@ void PowerDistributionPanel::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("PowerDistributionPanel"); for (int i = 0; i < SensorUtil::kPDPChannels; ++i) { builder.AddDoubleProperty( - "Chan" + wpi::Twine(i), [=]() { return GetCurrent(i); }, nullptr); + fmt::format("Chan{}", i), [=]() { return GetCurrent(i); }, nullptr); } builder.AddDoubleProperty( "Voltage", [=]() { return GetVoltage(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/ScopedTracer.cpp b/wpilibc/src/main/native/cpp/ScopedTracer.cpp index 4b8e1bd726..3c8fc80745 100644 --- a/wpilibc/src/main/native/cpp/ScopedTracer.cpp +++ b/wpilibc/src/main/native/cpp/ScopedTracer.cpp @@ -8,8 +8,8 @@ using namespace frc; -ScopedTracer::ScopedTracer(wpi::Twine name, wpi::raw_ostream& os) - : m_name(name.str()), m_os(os) { +ScopedTracer::ScopedTracer(std::string_view name, wpi::raw_ostream& os) + : m_name(name), m_os(os) { m_tracer.ResetTimer(); } diff --git a/wpilibc/src/main/native/cpp/SerialPort.cpp b/wpilibc/src/main/native/cpp/SerialPort.cpp index 5cbe6e311a..4f517051bf 100644 --- a/wpilibc/src/main/native/cpp/SerialPort.cpp +++ b/wpilibc/src/main/native/cpp/SerialPort.cpp @@ -42,16 +42,14 @@ SerialPort::SerialPort(int baudRate, Port port, int dataBits, static_cast(port) + 1); } -SerialPort::SerialPort(int baudRate, const wpi::Twine& portName, Port port, +SerialPort::SerialPort(int baudRate, std::string_view portName, Port port, int dataBits, SerialPort::Parity parity, SerialPort::StopBits stopBits) { int32_t status = 0; - wpi::SmallVector buf; - const char* portNameC = portName.toNullTerminatedStringRef(buf).data(); - - m_portHandle = HAL_InitializeSerialPortDirect( - static_cast(port), portNameC, &status); + m_portHandle = + HAL_InitializeSerialPortDirect(static_cast(port), + std::string(portName).c_str(), &status); FRC_CheckErrorStatus(status, "Port {}", port); HAL_SetSerialBaudRate(m_portHandle, baudRate, &status); FRC_CheckErrorStatus(status, "SetSerialBaudRate {}", baudRate); @@ -113,10 +111,10 @@ int SerialPort::Read(char* buffer, int count) { } int SerialPort::Write(const char* buffer, int count) { - return Write(wpi::StringRef(buffer, static_cast(count))); + return Write(std::string_view(buffer, static_cast(count))); } -int SerialPort::Write(wpi::StringRef buffer) { +int SerialPort::Write(std::string_view buffer) { int32_t status = 0; int retVal = HAL_WriteSerial(m_portHandle, buffer.data(), buffer.size(), &status); diff --git a/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp b/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp index 98a03b8ca5..081c2cac5c 100644 --- a/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp +++ b/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp @@ -15,8 +15,6 @@ using namespace frc; -using wpi::Twine; - struct LiveWindow::Impl { Impl(); diff --git a/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp b/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp index 9e1dca818b..b36fda65c1 100644 --- a/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp +++ b/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp @@ -42,7 +42,7 @@ int PWMMotorController::GetChannel() const { return m_pwm.GetChannel(); } -PWMMotorController::PWMMotorController(const wpi::Twine& name, int channel) +PWMMotorController::PWMMotorController(std::string_view name, int channel) : m_pwm(channel, false) { SendableRegistry::GetInstance().AddLW(this, name, channel); } diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ComplexWidget.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ComplexWidget.cpp index 09b4c82881..1153c0df2b 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ComplexWidget.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ComplexWidget.cpp @@ -9,7 +9,7 @@ using namespace frc; ComplexWidget::ComplexWidget(ShuffleboardContainer& parent, - const wpi::Twine& title, Sendable& sendable) + std::string_view title, Sendable& sendable) : ShuffleboardValue(title), ShuffleboardWidget(parent, title), m_sendable(sendable) {} diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardComponentBase.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardComponentBase.cpp index cd45c56578..940f6ab90e 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardComponentBase.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardComponentBase.cpp @@ -4,21 +4,15 @@ #include "frc/shuffleboard/ShuffleboardComponentBase.h" -#include - using namespace frc; ShuffleboardComponentBase::ShuffleboardComponentBase( - ShuffleboardContainer& parent, const wpi::Twine& title, - const wpi::Twine& type) - : ShuffleboardValue(title), m_parent(parent) { - wpi::SmallVector storage; - m_type = type.toStringRef(storage); -} + ShuffleboardContainer& parent, std::string_view title, + std::string_view type) + : ShuffleboardValue(title), m_parent(parent), m_type(type) {} -void ShuffleboardComponentBase::SetType(const wpi::Twine& type) { - wpi::SmallVector storage; - m_type = type.toStringRef(storage); +void ShuffleboardComponentBase::SetType(std::string_view type) { + m_type = type; m_metadataDirty = true; } diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp index 1304a88af4..d1d49b889c 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp @@ -4,7 +4,6 @@ #include "frc/shuffleboard/ShuffleboardContainer.h" -#include #include #include "frc/Errors.h" @@ -22,7 +21,7 @@ static constexpr const char* GetStringFromBuiltInLayout(BuiltInLayouts layout) { return layoutStrings[static_cast(layout)]; } -ShuffleboardContainer::ShuffleboardContainer(const wpi::Twine& title) +ShuffleboardContainer::ShuffleboardContainer(std::string_view title) : ShuffleboardValue(title) {} const std::vector>& @@ -30,40 +29,36 @@ ShuffleboardContainer::GetComponents() const { return m_components; } -ShuffleboardLayout& ShuffleboardContainer::GetLayout(const wpi::Twine& title, +ShuffleboardLayout& ShuffleboardContainer::GetLayout(std::string_view title, BuiltInLayouts type) { return GetLayout(title, GetStringFromBuiltInLayout(type)); } -ShuffleboardLayout& ShuffleboardContainer::GetLayout(const wpi::Twine& title, +ShuffleboardLayout& ShuffleboardContainer::GetLayout(std::string_view title, const LayoutType& type) { return GetLayout(title, type.GetLayoutName()); } -ShuffleboardLayout& ShuffleboardContainer::GetLayout(const wpi::Twine& title, - const wpi::Twine& type) { - wpi::SmallVector storage; - auto titleRef = title.toStringRef(storage); - if (m_layouts.count(titleRef) == 0) { - auto layout = std::make_unique(*this, titleRef, type); +ShuffleboardLayout& ShuffleboardContainer::GetLayout(std::string_view title, + std::string_view type) { + if (m_layouts.count(title) == 0) { + auto layout = std::make_unique(*this, title, type); auto ptr = layout.get(); m_components.emplace_back(std::move(layout)); - m_layouts.insert(std::make_pair(titleRef, ptr)); + m_layouts.insert(std::make_pair(title, ptr)); } - return *m_layouts[titleRef]; + return *m_layouts[title]; } -ShuffleboardLayout& ShuffleboardContainer::GetLayout(const wpi::Twine& title) { - wpi::SmallVector storage; - auto titleRef = title.toStringRef(storage); - if (m_layouts.count(titleRef) == 0) { +ShuffleboardLayout& ShuffleboardContainer::GetLayout(std::string_view title) { + if (m_layouts.count(title) == 0) { throw FRC_MakeError(err::InvalidParameter, - "No layout with title {} has been defined", titleRef); + "No layout with title {} has been defined", title); } - return *m_layouts[titleRef]; + return *m_layouts[title]; } -ComplexWidget& ShuffleboardContainer::Add(const wpi::Twine& title, +ComplexWidget& ShuffleboardContainer::Add(std::string_view title, Sendable& sendable) { CheckTitle(title); auto widget = std::make_unique(*this, title, sendable); @@ -81,7 +76,7 @@ ComplexWidget& ShuffleboardContainer::Add(Sendable& sendable) { } SimpleWidget& ShuffleboardContainer::Add( - const wpi::Twine& title, std::shared_ptr defaultValue) { + std::string_view title, std::shared_ptr defaultValue) { CheckTitle(title); auto widget = std::make_unique(*this, title); @@ -91,48 +86,48 @@ SimpleWidget& ShuffleboardContainer::Add( return *ptr; } -SimpleWidget& ShuffleboardContainer::Add(const wpi::Twine& title, +SimpleWidget& ShuffleboardContainer::Add(std::string_view title, bool defaultValue) { return Add(title, nt::Value::MakeBoolean(defaultValue)); } -SimpleWidget& ShuffleboardContainer::Add(const wpi::Twine& title, +SimpleWidget& ShuffleboardContainer::Add(std::string_view title, double defaultValue) { return Add(title, nt::Value::MakeDouble(defaultValue)); } -SimpleWidget& ShuffleboardContainer::Add(const wpi::Twine& title, +SimpleWidget& ShuffleboardContainer::Add(std::string_view title, int defaultValue) { return Add(title, nt::Value::MakeDouble(defaultValue)); } -SimpleWidget& ShuffleboardContainer::Add(const wpi::Twine& title, - const wpi::Twine& defaultValue) { +SimpleWidget& ShuffleboardContainer::Add(std::string_view title, + std::string_view defaultValue) { return Add(title, nt::Value::MakeString(defaultValue)); } -SimpleWidget& ShuffleboardContainer::Add(const wpi::Twine& title, +SimpleWidget& ShuffleboardContainer::Add(std::string_view title, const char* defaultValue) { return Add(title, nt::Value::MakeString(defaultValue)); } -SimpleWidget& ShuffleboardContainer::Add(const wpi::Twine& title, +SimpleWidget& ShuffleboardContainer::Add(std::string_view title, wpi::ArrayRef defaultValue) { return Add(title, nt::Value::MakeBooleanArray(defaultValue)); } -SimpleWidget& ShuffleboardContainer::Add(const wpi::Twine& title, +SimpleWidget& ShuffleboardContainer::Add(std::string_view title, wpi::ArrayRef defaultValue) { return Add(title, nt::Value::MakeDoubleArray(defaultValue)); } SimpleWidget& ShuffleboardContainer::Add( - const wpi::Twine& title, wpi::ArrayRef defaultValue) { + std::string_view title, wpi::ArrayRef defaultValue) { return Add(title, nt::Value::MakeStringArray(defaultValue)); } SuppliedValueWidget& ShuffleboardContainer::AddString( - const wpi::Twine& title, std::function supplier) { + std::string_view title, std::function supplier) { static auto setter = [](nt::NetworkTableEntry entry, std::string value) { entry.SetString(value); }; @@ -146,7 +141,7 @@ SuppliedValueWidget& ShuffleboardContainer::AddString( } SuppliedValueWidget& ShuffleboardContainer::AddNumber( - const wpi::Twine& title, std::function supplier) { + std::string_view title, std::function supplier) { static auto setter = [](nt::NetworkTableEntry entry, double value) { entry.SetDouble(value); }; @@ -160,7 +155,7 @@ SuppliedValueWidget& ShuffleboardContainer::AddNumber( } SuppliedValueWidget& ShuffleboardContainer::AddBoolean( - const wpi::Twine& title, std::function supplier) { + std::string_view title, std::function supplier) { static auto setter = [](nt::NetworkTableEntry entry, bool value) { entry.SetBoolean(value); }; @@ -175,7 +170,7 @@ SuppliedValueWidget& ShuffleboardContainer::AddBoolean( SuppliedValueWidget>& ShuffleboardContainer::AddStringArray( - const wpi::Twine& title, + std::string_view title, std::function()> supplier) { static auto setter = [](nt::NetworkTableEntry entry, std::vector value) { @@ -191,7 +186,7 @@ ShuffleboardContainer::AddStringArray( } SuppliedValueWidget>& ShuffleboardContainer::AddNumberArray( - const wpi::Twine& title, std::function()> supplier) { + std::string_view title, std::function()> supplier) { static auto setter = [](nt::NetworkTableEntry entry, std::vector value) { entry.SetDoubleArray(value); @@ -206,7 +201,7 @@ SuppliedValueWidget>& ShuffleboardContainer::AddNumberArray( } SuppliedValueWidget>& ShuffleboardContainer::AddBooleanArray( - const wpi::Twine& title, std::function()> supplier) { + std::string_view title, std::function()> supplier) { static auto setter = [](nt::NetworkTableEntry entry, std::vector value) { entry.SetBooleanArray(value); }; @@ -219,14 +214,14 @@ SuppliedValueWidget>& ShuffleboardContainer::AddBooleanArray( return *ptr; } -SuppliedValueWidget& ShuffleboardContainer::AddRaw( - const wpi::Twine& title, std::function supplier) { - static auto setter = [](nt::NetworkTableEntry entry, wpi::StringRef value) { +SuppliedValueWidget& ShuffleboardContainer::AddRaw( + std::string_view title, std::function supplier) { + static auto setter = [](nt::NetworkTableEntry entry, std::string_view value) { entry.SetRaw(value); }; CheckTitle(title); - auto widget = std::make_unique>( + auto widget = std::make_unique>( *this, title, supplier, setter); auto ptr = widget.get(); m_components.emplace_back(std::move(widget)); @@ -234,44 +229,44 @@ SuppliedValueWidget& ShuffleboardContainer::AddRaw( } SimpleWidget& ShuffleboardContainer::AddPersistent( - const wpi::Twine& title, std::shared_ptr defaultValue) { + std::string_view title, std::shared_ptr defaultValue) { auto& widget = Add(title, defaultValue); widget.GetEntry().SetPersistent(); return widget; } -SimpleWidget& ShuffleboardContainer::AddPersistent(const wpi::Twine& title, +SimpleWidget& ShuffleboardContainer::AddPersistent(std::string_view title, bool defaultValue) { return AddPersistent(title, nt::Value::MakeBoolean(defaultValue)); } -SimpleWidget& ShuffleboardContainer::AddPersistent(const wpi::Twine& title, +SimpleWidget& ShuffleboardContainer::AddPersistent(std::string_view title, double defaultValue) { return AddPersistent(title, nt::Value::MakeDouble(defaultValue)); } -SimpleWidget& ShuffleboardContainer::AddPersistent(const wpi::Twine& title, +SimpleWidget& ShuffleboardContainer::AddPersistent(std::string_view title, int defaultValue) { return AddPersistent(title, nt::Value::MakeDouble(defaultValue)); } SimpleWidget& ShuffleboardContainer::AddPersistent( - const wpi::Twine& title, const wpi::Twine& defaultValue) { + std::string_view title, std::string_view defaultValue) { return AddPersistent(title, nt::Value::MakeString(defaultValue)); } SimpleWidget& ShuffleboardContainer::AddPersistent( - const wpi::Twine& title, wpi::ArrayRef defaultValue) { + std::string_view title, wpi::ArrayRef defaultValue) { return AddPersistent(title, nt::Value::MakeBooleanArray(defaultValue)); } SimpleWidget& ShuffleboardContainer::AddPersistent( - const wpi::Twine& title, wpi::ArrayRef defaultValue) { + std::string_view title, wpi::ArrayRef defaultValue) { return AddPersistent(title, nt::Value::MakeDoubleArray(defaultValue)); } SimpleWidget& ShuffleboardContainer::AddPersistent( - const wpi::Twine& title, wpi::ArrayRef defaultValue) { + std::string_view title, wpi::ArrayRef defaultValue) { return AddPersistent(title, nt::Value::MakeStringArray(defaultValue)); } @@ -287,12 +282,11 @@ void ShuffleboardContainer::DisableIfActuator() { } } -void ShuffleboardContainer::CheckTitle(const wpi::Twine& title) { - wpi::SmallVector storage; - auto titleRef = title.toStringRef(storage); - if (m_usedTitles.count(titleRef) > 0) { +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"; return; } - m_usedTitles.insert(titleRef); + m_usedTitles.insert(titleStr); } diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardLayout.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardLayout.cpp index 2f64df2ed7..c4c933ec6f 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardLayout.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardLayout.cpp @@ -7,8 +7,8 @@ using namespace frc; ShuffleboardLayout::ShuffleboardLayout(ShuffleboardContainer& parent, - const wpi::Twine& title, - const wpi::Twine& type) + std::string_view title, + std::string_view type) : ShuffleboardValue(title), ShuffleboardComponent(parent, title, type), ShuffleboardContainer(title) { diff --git a/wpilibc/src/main/native/cpp/shuffleboard/SimpleWidget.cpp b/wpilibc/src/main/native/cpp/shuffleboard/SimpleWidget.cpp index 0eca07d88d..390c9c4992 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/SimpleWidget.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/SimpleWidget.cpp @@ -11,7 +11,7 @@ using namespace frc; SimpleWidget::SimpleWidget(ShuffleboardContainer& parent, - const wpi::Twine& title) + std::string_view title) : ShuffleboardValue(title), ShuffleboardWidget(parent, title), m_entry() {} nt::NetworkTableEntry SimpleWidget::GetEntry() { diff --git a/wpilibc/src/main/native/cpp/smartdashboard/Field2d.cpp b/wpilibc/src/main/native/cpp/smartdashboard/Field2d.cpp index 14d14ee7b2..13123b6fa4 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/Field2d.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/Field2d.cpp @@ -46,16 +46,15 @@ Pose2d Field2d::GetRobotPose() const { return m_objects[0]->GetPose(); } -FieldObject2d* Field2d::GetObject(const wpi::Twine& name) { +FieldObject2d* Field2d::GetObject(std::string_view name) { std::scoped_lock lock(m_mutex); - std::string nameStr = name.str(); for (auto&& obj : m_objects) { - if (obj->m_name == nameStr) { + if (obj->m_name == name) { return obj.get(); } } - m_objects.emplace_back(std::make_unique( - std::move(nameStr), FieldObject2d::private_init{})); + m_objects.emplace_back( + std::make_unique(name, FieldObject2d::private_init{})); auto obj = m_objects.back().get(); if (m_table) { obj->m_entry = m_table->GetEntry(obj->m_name); diff --git a/wpilibc/src/main/native/cpp/smartdashboard/MechanismLigament2d.cpp b/wpilibc/src/main/native/cpp/smartdashboard/MechanismLigament2d.cpp index ef8dfc6bec..870cfb51f4 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/MechanismLigament2d.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/MechanismLigament2d.cpp @@ -8,7 +8,7 @@ using namespace frc; -MechanismLigament2d::MechanismLigament2d(const wpi::Twine& name, double length, +MechanismLigament2d::MechanismLigament2d(std::string_view name, double length, units::degree_t angle, double lineWeight, const frc::Color8Bit& color) diff --git a/wpilibc/src/main/native/cpp/smartdashboard/MechanismObject2d.cpp b/wpilibc/src/main/native/cpp/smartdashboard/MechanismObject2d.cpp index f1a1cce864..15d24a38c1 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/MechanismObject2d.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/MechanismObject2d.cpp @@ -6,8 +6,7 @@ using namespace frc; -MechanismObject2d::MechanismObject2d(const wpi::Twine& name) - : m_name{name.str()} {} +MechanismObject2d::MechanismObject2d(std::string_view name) : m_name{name} {} const std::string& MechanismObject2d::GetName() const { return m_name; diff --git a/wpilibc/src/main/native/cpp/smartdashboard/MechanismRoot2d.cpp b/wpilibc/src/main/native/cpp/smartdashboard/MechanismRoot2d.cpp index f91c34696a..0e0c12ce58 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/MechanismRoot2d.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/MechanismRoot2d.cpp @@ -12,9 +12,9 @@ using namespace frc; static constexpr char kPosition[] = "pos"; -MechanismRoot2d::MechanismRoot2d(const wpi::Twine& name, double x, double y, +MechanismRoot2d::MechanismRoot2d(std::string_view name, double x, double y, const private_init&) - : MechanismObject2d(name.str()), m_x{x}, m_y{y} {} + : MechanismObject2d(name), m_x{x}, m_y{y} {} void MechanismRoot2d::SetPosition(double x, double y) { std::scoped_lock lock(m_mutex); diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp index c98cda9fb5..e41a6f0a96 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp @@ -76,7 +76,7 @@ void SendableBuilderImpl::ClearProperties() { m_properties.clear(); } -void SendableBuilderImpl::SetSmartDashboardType(const wpi::Twine& type) { +void SendableBuilderImpl::SetSmartDashboardType(std::string_view type) { m_table->GetEntry(".type").SetString(type); } @@ -93,11 +93,11 @@ void SendableBuilderImpl::SetUpdateTable(std::function func) { m_updateTables.emplace_back(std::move(func)); } -nt::NetworkTableEntry SendableBuilderImpl::GetEntry(const wpi::Twine& key) { +nt::NetworkTableEntry SendableBuilderImpl::GetEntry(std::string_view key) { return m_table->GetEntry(key); } -void SendableBuilderImpl::AddBooleanProperty(const wpi::Twine& key, +void SendableBuilderImpl::AddBooleanProperty(std::string_view key, std::function getter, std::function setter) { m_properties.emplace_back(*m_table, key); @@ -124,7 +124,7 @@ void SendableBuilderImpl::AddBooleanProperty(const wpi::Twine& key, } void SendableBuilderImpl::AddDoubleProperty( - const wpi::Twine& key, std::function getter, + std::string_view key, std::function getter, std::function setter) { m_properties.emplace_back(*m_table, key); if (getter) { @@ -150,7 +150,7 @@ void SendableBuilderImpl::AddDoubleProperty( } void SendableBuilderImpl::AddStringProperty( - const wpi::Twine& key, std::function getter, + std::string_view key, std::function getter, std::function setter) { m_properties.emplace_back(*m_table, key); if (getter) { @@ -176,7 +176,7 @@ void SendableBuilderImpl::AddStringProperty( } void SendableBuilderImpl::AddBooleanArrayProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { @@ -202,7 +202,7 @@ void SendableBuilderImpl::AddBooleanArrayProperty( } void SendableBuilderImpl::AddDoubleArrayProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { @@ -228,7 +228,7 @@ void SendableBuilderImpl::AddDoubleArrayProperty( } void SendableBuilderImpl::AddStringArrayProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { @@ -254,7 +254,7 @@ void SendableBuilderImpl::AddStringArrayProperty( } void SendableBuilderImpl::AddRawProperty( - const wpi::Twine& key, std::function getter, + std::string_view key, std::function getter, std::function setter) { m_properties.emplace_back(*m_table, key); if (getter) { @@ -280,7 +280,7 @@ void SendableBuilderImpl::AddRawProperty( } void SendableBuilderImpl::AddValueProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) { m_properties.emplace_back(*m_table, key); if (getter) { @@ -302,7 +302,7 @@ void SendableBuilderImpl::AddValueProperty( } void SendableBuilderImpl::AddSmallStringProperty( - const wpi::Twine& key, + std::string_view key, std::function& buf)> getter, std::function setter) { m_properties.emplace_back(*m_table, key); @@ -330,7 +330,7 @@ void SendableBuilderImpl::AddSmallStringProperty( } void SendableBuilderImpl::AddSmallBooleanArrayProperty( - const wpi::Twine& key, + std::string_view key, std::function(wpi::SmallVectorImpl& buf)> getter, std::function)> setter) { m_properties.emplace_back(*m_table, key); @@ -358,7 +358,7 @@ void SendableBuilderImpl::AddSmallBooleanArrayProperty( } void SendableBuilderImpl::AddSmallDoubleArrayProperty( - const wpi::Twine& key, + std::string_view key, std::function(wpi::SmallVectorImpl& buf)> getter, std::function)> setter) { @@ -387,7 +387,7 @@ void SendableBuilderImpl::AddSmallDoubleArrayProperty( } void SendableBuilderImpl::AddSmallStringArrayProperty( - const wpi::Twine& key, + std::string_view key, std::function< wpi::ArrayRef(wpi::SmallVectorImpl& buf)> getter, @@ -417,7 +417,7 @@ void SendableBuilderImpl::AddSmallStringArrayProperty( } void SendableBuilderImpl::AddSmallRawProperty( - const wpi::Twine& key, + std::string_view key, std::function& buf)> getter, std::function setter) { m_properties.emplace_back(*m_table, key); diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp index 15cc985bf5..1d6b03798e 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp @@ -6,6 +6,7 @@ #include +#include #include #include #include @@ -26,16 +27,12 @@ struct SendableRegistry::Impl { bool liveWindow = false; wpi::SmallVector, 2> data; - void SetName(const wpi::Twine& moduleType, int channel) { - name = - (moduleType + wpi::Twine('[') + wpi::Twine(channel) + wpi::Twine(']')) - .str(); + void SetName(std::string_view moduleType, int channel) { + name = fmt::format("{}[{}]", moduleType, channel); } - void SetName(const wpi::Twine& moduleType, int moduleNumber, int channel) { - name = (moduleType + wpi::Twine('[') + wpi::Twine(moduleNumber) + - wpi::Twine(',') + wpi::Twine(channel) + wpi::Twine(']')) - .str(); + void SetName(std::string_view moduleType, int moduleNumber, int channel) { + name = fmt::format("{}[{},{}]", moduleType, moduleNumber, channel); } }; @@ -66,14 +63,14 @@ SendableRegistry& SendableRegistry::GetInstance() { return instance; } -void SendableRegistry::Add(Sendable* sendable, const wpi::Twine& name) { +void SendableRegistry::Add(Sendable* sendable, std::string_view name) { std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); comp.sendable = sendable; - comp.name = name.str(); + comp.name = name; } -void SendableRegistry::Add(Sendable* sendable, const wpi::Twine& moduleType, +void SendableRegistry::Add(Sendable* sendable, std::string_view moduleType, int channel) { std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); @@ -81,7 +78,7 @@ void SendableRegistry::Add(Sendable* sendable, const wpi::Twine& moduleType, comp.SetName(moduleType, channel); } -void SendableRegistry::Add(Sendable* sendable, const wpi::Twine& moduleType, +void SendableRegistry::Add(Sendable* sendable, std::string_view moduleType, int moduleNumber, int channel) { std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); @@ -89,24 +86,24 @@ void SendableRegistry::Add(Sendable* sendable, const wpi::Twine& moduleType, comp.SetName(moduleType, moduleNumber, channel); } -void SendableRegistry::Add(Sendable* sendable, const wpi::Twine& subsystem, - const wpi::Twine& name) { +void SendableRegistry::Add(Sendable* sendable, std::string_view subsystem, + std::string_view name) { std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); comp.sendable = sendable; - comp.name = name.str(); - comp.subsystem = subsystem.str(); + comp.name = name; + comp.subsystem = subsystem; } -void SendableRegistry::AddLW(Sendable* sendable, const wpi::Twine& name) { +void SendableRegistry::AddLW(Sendable* sendable, std::string_view name) { std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); comp.sendable = sendable; comp.liveWindow = true; - comp.name = name.str(); + comp.name = name; } -void SendableRegistry::AddLW(Sendable* sendable, const wpi::Twine& moduleType, +void SendableRegistry::AddLW(Sendable* sendable, std::string_view moduleType, int channel) { std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); @@ -115,7 +112,7 @@ void SendableRegistry::AddLW(Sendable* sendable, const wpi::Twine& moduleType, comp.SetName(moduleType, channel); } -void SendableRegistry::AddLW(Sendable* sendable, const wpi::Twine& moduleType, +void SendableRegistry::AddLW(Sendable* sendable, std::string_view moduleType, int moduleNumber, int channel) { std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); @@ -124,14 +121,14 @@ void SendableRegistry::AddLW(Sendable* sendable, const wpi::Twine& moduleType, comp.SetName(moduleType, moduleNumber, channel); } -void SendableRegistry::AddLW(Sendable* sendable, const wpi::Twine& subsystem, - const wpi::Twine& name) { +void SendableRegistry::AddLW(Sendable* sendable, std::string_view subsystem, + std::string_view name) { std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); comp.sendable = sendable; comp.liveWindow = true; - comp.name = name.str(); - comp.subsystem = subsystem.str(); + comp.name = name; + comp.subsystem = subsystem; } void SendableRegistry::AddChild(Sendable* parent, Sendable* child) { @@ -204,17 +201,17 @@ std::string SendableRegistry::GetName(const Sendable* sendable) const { return m_impl->components[it->getSecond() - 1]->name; } -void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& name) { +void SendableRegistry::SetName(Sendable* sendable, std::string_view name) { std::scoped_lock lock(m_impl->mutex); auto it = m_impl->componentMap.find(sendable); if (it == m_impl->componentMap.end() || !m_impl->components[it->getSecond() - 1]) { return; } - m_impl->components[it->getSecond() - 1]->name = name.str(); + m_impl->components[it->getSecond() - 1]->name = name; } -void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& moduleType, +void SendableRegistry::SetName(Sendable* sendable, std::string_view moduleType, int channel) { std::scoped_lock lock(m_impl->mutex); auto it = m_impl->componentMap.find(sendable); @@ -225,7 +222,7 @@ void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& moduleType, m_impl->components[it->getSecond() - 1]->SetName(moduleType, channel); } -void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& moduleType, +void SendableRegistry::SetName(Sendable* sendable, std::string_view moduleType, int moduleNumber, int channel) { std::scoped_lock lock(m_impl->mutex); auto it = m_impl->componentMap.find(sendable); @@ -237,8 +234,8 @@ void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& moduleType, channel); } -void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& subsystem, - const wpi::Twine& name) { +void SendableRegistry::SetName(Sendable* sendable, std::string_view subsystem, + std::string_view name) { std::scoped_lock lock(m_impl->mutex); auto it = m_impl->componentMap.find(sendable); if (it == m_impl->componentMap.end() || @@ -246,8 +243,8 @@ void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& subsystem, return; } auto& comp = *m_impl->components[it->getSecond() - 1]; - comp.name = name.str(); - comp.subsystem = subsystem.str(); + comp.name = name; + comp.subsystem = subsystem; } std::string SendableRegistry::GetSubsystem(const Sendable* sendable) const { @@ -261,14 +258,14 @@ std::string SendableRegistry::GetSubsystem(const Sendable* sendable) const { } void SendableRegistry::SetSubsystem(Sendable* sendable, - const wpi::Twine& subsystem) { + std::string_view subsystem) { std::scoped_lock lock(m_impl->mutex); auto it = m_impl->componentMap.find(sendable); if (it == m_impl->componentMap.end() || !m_impl->components[it->getSecond() - 1]) { return; } - m_impl->components[it->getSecond() - 1]->subsystem = subsystem.str(); + m_impl->components[it->getSecond() - 1]->subsystem = subsystem; } int SendableRegistry::GetDataHandle() { diff --git a/wpilibc/src/main/native/include/frc/Notifier.h b/wpilibc/src/main/native/include/frc/Notifier.h index fee783b937..2e219d0ff5 100644 --- a/wpilibc/src/main/native/include/frc/Notifier.h +++ b/wpilibc/src/main/native/include/frc/Notifier.h @@ -8,13 +8,13 @@ #include #include +#include #include #include #include #include #include -#include #include #include @@ -71,7 +71,7 @@ class Notifier { * * @param name Name */ - void SetName(const wpi::Twine& name); + void SetName(std::string_view name); /** * Change the handler function. diff --git a/wpilibc/src/main/native/include/frc/ScopedTracer.h b/wpilibc/src/main/native/include/frc/ScopedTracer.h index 8a893a2820..e7006161ee 100644 --- a/wpilibc/src/main/native/include/frc/ScopedTracer.h +++ b/wpilibc/src/main/native/include/frc/ScopedTracer.h @@ -5,9 +5,7 @@ #pragma once #include - -#include -#include +#include #include "frc/Tracer.h" @@ -31,7 +29,7 @@ class ScopedTracer { * @param name The name of the epoch. * @param os A reference to the raw_ostream to print data to. */ - ScopedTracer(wpi::Twine name, wpi::raw_ostream& os); + ScopedTracer(std::string_view name, wpi::raw_ostream& os); ~ScopedTracer(); ScopedTracer(const ScopedTracer&) = delete; diff --git a/wpilibc/src/main/native/include/frc/SerialPort.h b/wpilibc/src/main/native/include/frc/SerialPort.h index b11cb64dd7..4f8f0b3685 100644 --- a/wpilibc/src/main/native/include/frc/SerialPort.h +++ b/wpilibc/src/main/native/include/frc/SerialPort.h @@ -5,10 +5,9 @@ #pragma once #include +#include #include -#include -#include #include namespace frc { @@ -82,7 +81,7 @@ class SerialPort { * @param stopBits The number of stop bits to use as defined by the enum * StopBits. */ - SerialPort(int baudRate, const wpi::Twine& portName, Port port = kOnboard, + SerialPort(int baudRate, std::string_view portName, Port port = kOnboard, int dataBits = 8, Parity parity = kParity_None, StopBits stopBits = kStopBits_One); @@ -148,7 +147,7 @@ class SerialPort { * @param buffer StringRef to the buffer to read the bytes from. * @return The number of bytes actually written into the port. */ - int Write(wpi::StringRef buffer); + int Write(std::string_view buffer); /** * Configure the timeout of the serial port. diff --git a/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h b/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h index 1228351ed6..5cb493a69e 100644 --- a/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h +++ b/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h @@ -5,8 +5,7 @@ #pragma once #include - -#include +#include #include "frc/MotorSafety.h" #include "frc/PWM.h" @@ -66,7 +65,7 @@ class PWMMotorController : public MotorController, * @param channel The PWM channel that the controller is attached to. 0-9 are * on-board, 10-19 are on the MXP port */ - PWMMotorController(const wpi::Twine& name, int channel); + PWMMotorController(std::string_view name, int channel); void InitSendable(SendableBuilder& builder) override; diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ComplexWidget.h b/wpilibc/src/main/native/include/frc/shuffleboard/ComplexWidget.h index 6e7f54657c..90dbf4f80e 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ComplexWidget.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ComplexWidget.h @@ -5,9 +5,9 @@ #pragma once #include +#include #include -#include #include "frc/shuffleboard/ShuffleboardWidget.h" #include "frc/smartdashboard/SendableBuilder.h" @@ -24,7 +24,7 @@ class ShuffleboardContainer; */ class ComplexWidget final : public ShuffleboardWidget { public: - ComplexWidget(ShuffleboardContainer& parent, const wpi::Twine& title, + ComplexWidget(ShuffleboardContainer& parent, std::string_view title, Sendable& sendable); void EnableIfActuator() override; diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h index 1108810d3f..4414bc20a9 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h @@ -6,11 +6,11 @@ #include #include +#include #include #include #include -#include #include "frc/shuffleboard/ShuffleboardComponentBase.h" @@ -26,8 +26,8 @@ class ShuffleboardContainer; template class ShuffleboardComponent : public ShuffleboardComponentBase { public: - ShuffleboardComponent(ShuffleboardContainer& parent, const wpi::Twine& title, - const wpi::Twine& type = ""); + ShuffleboardComponent(ShuffleboardContainer& parent, std::string_view title, + std::string_view type = ""); ~ShuffleboardComponent() override = default; diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.inc b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.inc index a5a318b722..9750d4ad40 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.inc +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.inc @@ -6,6 +6,7 @@ #include #include +#include #include "frc/shuffleboard/ShuffleboardComponent.h" @@ -13,8 +14,8 @@ namespace frc { template ShuffleboardComponent::ShuffleboardComponent( - ShuffleboardContainer& parent, const wpi::Twine& title, - const wpi::Twine& type) + ShuffleboardContainer& parent, std::string_view title, + std::string_view type) : ShuffleboardValue(title), ShuffleboardComponentBase(parent, title, type) {} diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponentBase.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponentBase.h index 0b906246d1..7055c5ece7 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponentBase.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponentBase.h @@ -6,11 +6,11 @@ #include #include +#include #include #include #include -#include #include "frc/shuffleboard/ShuffleboardValue.h" @@ -24,12 +24,11 @@ class ShuffleboardContainer; class ShuffleboardComponentBase : public virtual ShuffleboardValue { public: ShuffleboardComponentBase(ShuffleboardContainer& parent, - const wpi::Twine& title, - const wpi::Twine& type = ""); + std::string_view title, std::string_view type = ""); ~ShuffleboardComponentBase() override = default; - void SetType(const wpi::Twine& type); + void SetType(std::string_view type); void BuildMetadata(std::shared_ptr metaTable); diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h index 33b9fe713f..e0f7b467b2 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -14,7 +15,6 @@ #include #include #include -#include #include "frc/shuffleboard/BuiltInLayouts.h" #include "frc/shuffleboard/LayoutType.h" @@ -38,7 +38,7 @@ class SimpleWidget; */ class ShuffleboardContainer : public virtual ShuffleboardValue { public: - explicit ShuffleboardContainer(const wpi::Twine& title); + explicit ShuffleboardContainer(std::string_view title); ShuffleboardContainer(ShuffleboardContainer&& rhs) = default; @@ -58,7 +58,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @param layoutType the type of the layout, eg "List" or "Grid" * @return the layout */ - ShuffleboardLayout& GetLayout(const wpi::Twine& title, BuiltInLayouts type); + ShuffleboardLayout& GetLayout(std::string_view title, BuiltInLayouts type); /** * Gets the layout with the given type and title, creating it if it does not @@ -68,8 +68,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @param layoutType the type of the layout, eg "List" or "Grid" * @return the layout */ - ShuffleboardLayout& GetLayout(const wpi::Twine& title, - const LayoutType& type); + ShuffleboardLayout& GetLayout(std::string_view title, const LayoutType& type); /** * Gets the layout with the given type and title, creating it if it does not @@ -84,8 +83,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return the layout * @see #GetLayout(String, LayoutType) */ - ShuffleboardLayout& GetLayout(const wpi::Twine& title, - const wpi::Twine& type); + ShuffleboardLayout& GetLayout(std::string_view title, std::string_view type); /** * Gets the already-defined layout in this container with the given title. @@ -102,7 +100,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return the layout with the given title * @throws if no layout has yet been defined with the given title */ - ShuffleboardLayout& GetLayout(const wpi::Twine& title); + ShuffleboardLayout& GetLayout(std::string_view title); /** * Adds a widget to this container to display the given sendable. @@ -113,7 +111,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @throws IllegalArgumentException if a widget already exists in this * container with the given title */ - ComplexWidget& Add(const wpi::Twine& title, Sendable& sendable); + ComplexWidget& Add(std::string_view title, Sendable& sendable); /** * Adds a widget to this container to display the given video stream. @@ -124,7 +122,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @throws IllegalArgumentException if a widget already exists in this * container with the given title */ - ComplexWidget& Add(const wpi::Twine& title, const cs::VideoSource& video); + ComplexWidget& Add(std::string_view title, const cs::VideoSource& video); /** * Adds a widget to this container to display the given sendable. @@ -157,7 +155,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * container with the given title * @see #addPersistent(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& Add(const wpi::Twine& title, + SimpleWidget& Add(std::string_view title, std::shared_ptr defaultValue); /** @@ -170,7 +168,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * container with the given title * @see #addPersistent(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& Add(const wpi::Twine& title, bool defaultValue); + SimpleWidget& Add(std::string_view title, bool defaultValue); /** * Adds a widget to this container to display the given data. @@ -182,7 +180,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * container with the given title * @see #addPersistent(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& Add(const wpi::Twine& title, double defaultValue); + SimpleWidget& Add(std::string_view title, double defaultValue); /** * Adds a widget to this container to display the given data. @@ -194,7 +192,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * container with the given title * @see #addPersistent(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& Add(const wpi::Twine& title, int defaultValue); + SimpleWidget& Add(std::string_view title, int defaultValue); /** * Adds a widget to this container to display the given data. @@ -206,7 +204,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * container with the given title * @see #addPersistent(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& Add(const wpi::Twine& title, const wpi::Twine& defaultValue); + SimpleWidget& Add(std::string_view title, std::string_view defaultValue); /** * Adds a widget to this container to display the given data. @@ -218,7 +216,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * container with the given title * @see #addPersistent(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& Add(const wpi::Twine& title, const char* defaultValue); + SimpleWidget& Add(std::string_view title, const char* defaultValue); /** * Adds a widget to this container to display the given data. @@ -230,7 +228,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * container with the given title * @see #addPersistent(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& Add(const wpi::Twine& title, wpi::ArrayRef defaultValue); + SimpleWidget& Add(std::string_view title, wpi::ArrayRef defaultValue); /** * Adds a widget to this container to display the given data. @@ -242,8 +240,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * container with the given title * @see #addPersistent(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& Add(const wpi::Twine& title, - wpi::ArrayRef defaultValue); + SimpleWidget& Add(std::string_view title, wpi::ArrayRef defaultValue); /** * Adds a widget to this container to display the given data. @@ -255,7 +252,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * container with the given title * @see #addPersistent(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& Add(const wpi::Twine& title, + SimpleWidget& Add(std::string_view title, wpi::ArrayRef defaultValue); /** @@ -269,7 +266,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display data */ SuppliedValueWidget& AddString( - const wpi::Twine& title, std::function supplier); + std::string_view title, std::function supplier); /** * Adds a widget to this container. The widget will display the data provided @@ -281,7 +278,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @param valueSupplier the supplier for values * @return a widget to display data */ - SuppliedValueWidget& AddNumber(const wpi::Twine& title, + SuppliedValueWidget& AddNumber(std::string_view title, std::function supplier); /** @@ -294,7 +291,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @param valueSupplier the supplier for values * @return a widget to display data */ - SuppliedValueWidget& AddBoolean(const wpi::Twine& title, + SuppliedValueWidget& AddBoolean(std::string_view title, std::function supplier); /** @@ -308,7 +305,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display data */ SuppliedValueWidget>& AddStringArray( - const wpi::Twine& title, + std::string_view title, std::function()> supplier); /** @@ -322,7 +319,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display data */ SuppliedValueWidget>& AddNumberArray( - const wpi::Twine& title, std::function()> supplier); + std::string_view title, std::function()> supplier); /** * Adds a widget to this container. The widget will display the data provided @@ -335,7 +332,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display data */ SuppliedValueWidget>& AddBooleanArray( - const wpi::Twine& title, std::function()> supplier); + std::string_view title, std::function()> supplier); /** * Adds a widget to this container. The widget will display the data provided @@ -347,8 +344,8 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @param valueSupplier the supplier for values * @return a widget to display data */ - SuppliedValueWidget& AddRaw( - const wpi::Twine& title, std::function supplier); + SuppliedValueWidget& AddRaw( + std::string_view title, std::function supplier); /** * Adds a widget to this container to display a simple piece of data. @@ -362,7 +359,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display the sendable data * @see #add(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& AddPersistent(const wpi::Twine& title, + SimpleWidget& AddPersistent(std::string_view title, std::shared_ptr defaultValue); /** @@ -377,7 +374,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display the sendable data * @see #add(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& AddPersistent(const wpi::Twine& title, bool defaultValue); + SimpleWidget& AddPersistent(std::string_view title, bool defaultValue); /** * Adds a widget to this container to display a simple piece of data. @@ -391,7 +388,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display the sendable data * @see #add(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& AddPersistent(const wpi::Twine& title, double defaultValue); + SimpleWidget& AddPersistent(std::string_view title, double defaultValue); /** * Adds a widget to this container to display a simple piece of data. @@ -405,7 +402,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display the sendable data * @see #add(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& AddPersistent(const wpi::Twine& title, int defaultValue); + SimpleWidget& AddPersistent(std::string_view title, int defaultValue); /** * Adds a widget to this container to display a simple piece of data. @@ -419,8 +416,8 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display the sendable data * @see #add(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& AddPersistent(const wpi::Twine& title, - const wpi::Twine& defaultValue); + SimpleWidget& AddPersistent(std::string_view title, + std::string_view defaultValue); /** * Adds a widget to this container to display a simple piece of data. @@ -434,7 +431,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display the sendable data * @see #add(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& AddPersistent(const wpi::Twine& title, + SimpleWidget& AddPersistent(std::string_view title, wpi::ArrayRef defaultValue); /** @@ -449,7 +446,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display the sendable data * @see #add(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& AddPersistent(const wpi::Twine& title, + SimpleWidget& AddPersistent(std::string_view title, wpi::ArrayRef defaultValue); /** @@ -464,7 +461,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @return a widget to display the sendable data * @see #add(String, Object) add(String title, Object defaultValue) */ - SimpleWidget& AddPersistent(const wpi::Twine& title, + SimpleWidget& AddPersistent(std::string_view title, wpi::ArrayRef defaultValue); void EnableIfActuator() override; @@ -484,7 +481,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * * @return True if title isn't in use; false otherwise. */ - void CheckTitle(const wpi::Twine& title); + void CheckTitle(std::string_view title); friend class SimpleWidget; }; @@ -505,7 +502,7 @@ inline frc::ComplexWidget& frc::ShuffleboardContainer::Add( } inline frc::ComplexWidget& frc::ShuffleboardContainer::Add( - const wpi::Twine& title, const cs::VideoSource& video) { + std::string_view title, const cs::VideoSource& video) { return Add(title, frc::SendableCameraWrapper::Wrap(video)); } #endif diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardLayout.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardLayout.h index be6eea79e2..fe9e102be8 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardLayout.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardLayout.h @@ -5,9 +5,9 @@ #pragma once #include +#include #include -#include #include "frc/shuffleboard/ShuffleboardComponent.h" #include "frc/shuffleboard/ShuffleboardContainer.h" @@ -26,8 +26,8 @@ namespace frc { class ShuffleboardLayout : public ShuffleboardComponent, public ShuffleboardContainer { public: - ShuffleboardLayout(ShuffleboardContainer& parent, const wpi::Twine& name, - const wpi::Twine& type); + ShuffleboardLayout(ShuffleboardContainer& parent, std::string_view name, + std::string_view type); void BuildInto(std::shared_ptr parentTable, std::shared_ptr metaTable) override; diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardValue.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardValue.h index 4b5bcb7c47..301d123399 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardValue.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardValue.h @@ -6,26 +6,22 @@ #include #include +#include #include -#include -#include namespace frc { class ShuffleboardValue { public: - explicit ShuffleboardValue(const wpi::Twine& title) { - wpi::SmallVector storage; - m_title = title.toStringRef(storage); - } + explicit ShuffleboardValue(std::string_view title) : m_title(title) {} virtual ~ShuffleboardValue() = default; /** * Gets the title of this Shuffleboard value. */ - wpi::StringRef GetTitle() const { return m_title; } + const std::string& GetTitle() const { return m_title; } /** * Builds the entries for this value. diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h index 76180d6865..6134fa3c7d 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include "frc/shuffleboard/BuiltInWidgets.h" #include "frc/shuffleboard/ShuffleboardComponent.h" @@ -28,7 +28,7 @@ const char* GetStringForWidgetType(BuiltInWidgets type); template class ShuffleboardWidget : public ShuffleboardComponent { public: - ShuffleboardWidget(ShuffleboardContainer& parent, const wpi::Twine& title) + ShuffleboardWidget(ShuffleboardContainer& parent, std::string_view title) : ShuffleboardValue(title), ShuffleboardComponent(parent, title) {} @@ -66,7 +66,7 @@ class ShuffleboardWidget : public ShuffleboardComponent { * @param widgetType the type of the widget used to display the data * @return this widget object */ - Derived& WithWidget(const wpi::Twine& widgetType) { + Derived& WithWidget(std::string_view widgetType) { this->SetType(widgetType); return *static_cast(this); } diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/SimpleWidget.h b/wpilibc/src/main/native/include/frc/shuffleboard/SimpleWidget.h index 194f77a23e..746b7d6b3d 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/SimpleWidget.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/SimpleWidget.h @@ -5,10 +5,10 @@ #pragma once #include +#include #include #include -#include #include "frc/shuffleboard/ShuffleboardWidget.h" @@ -22,7 +22,7 @@ class ShuffleboardContainer; */ class SimpleWidget final : public ShuffleboardWidget { public: - SimpleWidget(ShuffleboardContainer& parent, const wpi::Twine& title); + SimpleWidget(ShuffleboardContainer& parent, std::string_view title); /** * Gets the NetworkTable entry that contains the data for this widget. diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/SuppliedValueWidget.h b/wpilibc/src/main/native/include/frc/shuffleboard/SuppliedValueWidget.h index bd35c81d48..c087250b4e 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/SuppliedValueWidget.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/SuppliedValueWidget.h @@ -6,10 +6,10 @@ #include #include +#include #include #include -#include #include "frc/shuffleboard/ShuffleboardComponent.h" #include "frc/shuffleboard/ShuffleboardComponent.inc" @@ -22,7 +22,7 @@ class ShuffleboardContainer; template class SuppliedValueWidget : public ShuffleboardWidget > { public: - SuppliedValueWidget(ShuffleboardContainer& parent, const wpi::Twine& title, + SuppliedValueWidget(ShuffleboardContainer& parent, std::string_view title, std::function supplier, std::function setter) : ShuffleboardValue(title), diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/Field2d.h b/wpilibc/src/main/native/include/frc/smartdashboard/Field2d.h index bb406dbb15..d718a11c5c 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/Field2d.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/Field2d.h @@ -5,12 +5,12 @@ #pragma once #include +#include #include #include #include #include -#include #include #include "frc/geometry/Pose2d.h" @@ -76,7 +76,7 @@ class Field2d : public Sendable, public SendableHelper { * * @return Field object */ - FieldObject2d* GetObject(const wpi::Twine& name); + FieldObject2d* GetObject(std::string_view name); /** * Get the robot object. diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/FieldObject2d.h b/wpilibc/src/main/native/include/frc/smartdashboard/FieldObject2d.h index eb3625181c..69cce223d2 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/FieldObject2d.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/FieldObject2d.h @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -31,8 +32,7 @@ class FieldObject2d { struct private_init {}; public: - FieldObject2d(std::string&& name, const private_init&) - : m_name{std::move(name)} {} + FieldObject2d(std::string_view name, const private_init&) : m_name{name} {} FieldObject2d(FieldObject2d&& rhs); FieldObject2d& operator=(FieldObject2d&& rhs); diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/MechanismLigament2d.h b/wpilibc/src/main/native/include/frc/smartdashboard/MechanismLigament2d.h index e2a89d6510..85d50674a2 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/MechanismLigament2d.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/MechanismLigament2d.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include @@ -21,7 +22,7 @@ namespace frc { */ class MechanismLigament2d : public MechanismObject2d { public: - MechanismLigament2d(const wpi::Twine& name, double length, + MechanismLigament2d(std::string_view name, double length, units::degree_t angle, double lineWidth = 6, const frc::Color8Bit& color = {235, 137, 52}); diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/MechanismObject2d.h b/wpilibc/src/main/native/include/frc/smartdashboard/MechanismObject2d.h index e71e7697e6..3821f617c2 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/MechanismObject2d.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/MechanismObject2d.h @@ -7,12 +7,12 @@ #include #include #include +#include #include #include #include #include -#include namespace frc { @@ -30,7 +30,7 @@ class MechanismObject2d { friend class Mechanism2d; protected: - explicit MechanismObject2d(const wpi::Twine& name); + explicit MechanismObject2d(std::string_view name); /** * Update all entries with new ones from a new table. diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/MechanismRoot2d.h b/wpilibc/src/main/native/include/frc/smartdashboard/MechanismRoot2d.h index 0d97a60792..6b03e133b2 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/MechanismRoot2d.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/MechanismRoot2d.h @@ -5,9 +5,9 @@ #pragma once #include +#include #include -#include #include "MechanismObject2d.h" @@ -24,7 +24,7 @@ class MechanismRoot2d : private MechanismObject2d { struct private_init {}; public: - MechanismRoot2d(const wpi::Twine& name, double x, double y, + MechanismRoot2d(std::string_view name, double x, double y, const private_init&); /** diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilder.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilder.h index 2ff5a23bd6..432854f1b4 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilder.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilder.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -14,7 +15,6 @@ #include #include #include -#include namespace frc { @@ -28,7 +28,7 @@ class SendableBuilder { * * @param type data type */ - virtual void SetSmartDashboardType(const wpi::Twine& type) = 0; + virtual void SetSmartDashboardType(std::string_view type) = 0; /** * Set a flag indicating if this sendable should be treated as an actuator. @@ -63,7 +63,7 @@ class SendableBuilder { * @param key property name * @return Network table entry */ - virtual nt::NetworkTableEntry GetEntry(const wpi::Twine& key) = 0; + virtual nt::NetworkTableEntry GetEntry(std::string_view key) = 0; /** * Add a boolean property. @@ -72,7 +72,7 @@ class SendableBuilder { * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ - virtual void AddBooleanProperty(const wpi::Twine& key, + virtual void AddBooleanProperty(std::string_view key, std::function getter, std::function setter) = 0; @@ -83,7 +83,7 @@ class SendableBuilder { * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ - virtual void AddDoubleProperty(const wpi::Twine& key, + virtual void AddDoubleProperty(std::string_view key, std::function getter, std::function setter) = 0; @@ -95,7 +95,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddStringProperty( - const wpi::Twine& key, std::function getter, + std::string_view key, std::function getter, std::function setter) = 0; /** @@ -106,7 +106,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddBooleanArrayProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) = 0; /** @@ -117,7 +117,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddDoubleArrayProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) = 0; /** @@ -128,7 +128,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddStringArrayProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) = 0; /** @@ -138,7 +138,7 @@ class SendableBuilder { * @param getter getter function (returns current value) * @param setter setter function (sets new value) */ - virtual void AddRawProperty(const wpi::Twine& key, + virtual void AddRawProperty(std::string_view key, std::function getter, std::function setter) = 0; @@ -150,7 +150,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddValueProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) = 0; /** @@ -161,7 +161,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddSmallStringProperty( - const wpi::Twine& key, + std::string_view key, std::function& buf)> getter, std::function setter) = 0; @@ -173,7 +173,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddSmallBooleanArrayProperty( - const wpi::Twine& key, + std::string_view key, std::function(wpi::SmallVectorImpl& buf)> getter, std::function)> setter) = 0; @@ -185,7 +185,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddSmallDoubleArrayProperty( - const wpi::Twine& key, + std::string_view key, std::function(wpi::SmallVectorImpl& buf)> getter, std::function)> setter) = 0; @@ -198,7 +198,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddSmallStringArrayProperty( - const wpi::Twine& key, + std::string_view key, std::function< wpi::ArrayRef(wpi::SmallVectorImpl& buf)> getter, @@ -212,7 +212,7 @@ class SendableBuilder { * @param setter setter function (sets new value) */ virtual void AddSmallRawProperty( - const wpi::Twine& key, + std::string_view key, std::function& buf)> getter, std::function setter) = 0; diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h index 087227761b..34eeb668ab 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -15,7 +16,6 @@ #include #include #include -#include #include "frc/smartdashboard/SendableBuilder.h" @@ -86,73 +86,72 @@ class SendableBuilderImpl : public SendableBuilder { */ void ClearProperties(); - void SetSmartDashboardType(const wpi::Twine& type) override; + void SetSmartDashboardType(std::string_view type) override; void SetActuator(bool value) override; void SetSafeState(std::function func) override; void SetUpdateTable(std::function func) override; - nt::NetworkTableEntry GetEntry(const wpi::Twine& key) override; + nt::NetworkTableEntry GetEntry(std::string_view key) override; - void AddBooleanProperty(const wpi::Twine& key, std::function getter, + void AddBooleanProperty(std::string_view key, std::function getter, std::function setter) override; - void AddDoubleProperty(const wpi::Twine& key, std::function getter, + void AddDoubleProperty(std::string_view key, std::function getter, std::function setter) override; - void AddStringProperty(const wpi::Twine& key, + void AddStringProperty(std::string_view key, std::function getter, std::function setter) override; void AddBooleanArrayProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) override; void AddDoubleArrayProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) override; void AddStringArrayProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) override; - void AddRawProperty(const wpi::Twine& key, - std::function getter, + void AddRawProperty(std::string_view key, std::function getter, std::function setter) override; void AddValueProperty( - const wpi::Twine& key, std::function()> getter, + std::string_view key, std::function()> getter, std::function)> setter) override; void AddSmallStringProperty( - const wpi::Twine& key, + std::string_view key, std::function& buf)> getter, std::function setter) override; void AddSmallBooleanArrayProperty( - const wpi::Twine& key, + std::string_view key, std::function(wpi::SmallVectorImpl& buf)> getter, std::function)> setter) override; void AddSmallDoubleArrayProperty( - const wpi::Twine& key, + std::string_view key, std::function(wpi::SmallVectorImpl& buf)> getter, std::function)> setter) override; void AddSmallStringArrayProperty( - const wpi::Twine& key, + std::string_view key, std::function< wpi::ArrayRef(wpi::SmallVectorImpl& buf)> getter, std::function)> setter) override; void AddSmallRawProperty( - const wpi::Twine& key, + std::string_view key, std::function& buf)> getter, std::function setter) override; private: struct Property { - Property(nt::NetworkTable& table, const wpi::Twine& key) + Property(nt::NetworkTable& table, std::string_view key) : entry(table.GetEntry(key)) {} Property(const Property&) = delete; diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h index 4735dd4f99..44b628a0a2 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h @@ -6,8 +6,8 @@ #include #include +#include -#include #include #include "frc/smartdashboard/SendableRegistry.h" @@ -61,7 +61,7 @@ class SendableHelper { * @param name name */ WPI_DEPRECATED("use SendableRegistry::SetName()") - void SetName(const wpi::Twine& name) { + void SetName(std::string_view name) { SendableRegistry::GetInstance().SetName(static_cast(this), name); } @@ -74,7 +74,7 @@ class SendableHelper { * @param name device name */ WPI_DEPRECATED("use SendableRegistry::SetName()") - void SetName(const wpi::Twine& subsystem, const wpi::Twine& name) { + void SetName(std::string_view subsystem, std::string_view name) { SendableRegistry::GetInstance().SetName(static_cast(this), subsystem, name); } @@ -100,7 +100,7 @@ class SendableHelper { * @param subsystem subsystem name */ WPI_DEPRECATED("use SendableRegistry::SetSubsystem()") - void SetSubsystem(const wpi::Twine& subsystem) { + void SetSubsystem(std::string_view subsystem) { SendableRegistry::GetInstance().SetSubsystem(static_cast(this), subsystem); } @@ -142,7 +142,7 @@ class SendableHelper { * @param channel The channel number the device is plugged into */ WPI_DEPRECATED("use SendableRegistry::SetName()") - void SetName(const wpi::Twine& moduleType, int channel) { + void SetName(std::string_view moduleType, int channel) { SendableRegistry::GetInstance().SetName(static_cast(this), moduleType, channel); } @@ -159,7 +159,7 @@ class SendableHelper { * PWM) */ WPI_DEPRECATED("use SendableRegistry::SetName()") - void SetName(const wpi::Twine& moduleType, int moduleNumber, int channel) { + void SetName(std::string_view moduleType, int moduleNumber, int channel) { SendableRegistry::GetInstance().SetName(static_cast(this), moduleType, moduleNumber, channel); } diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableRegistry.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableRegistry.h index e24c1934d2..b1c9b35f32 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableRegistry.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableRegistry.h @@ -6,10 +6,10 @@ #include #include +#include #include #include -#include namespace frc { @@ -41,7 +41,7 @@ class SendableRegistry { * @param sendable object to add * @param name component name */ - void Add(Sendable* sendable, const wpi::Twine& name); + void Add(Sendable* sendable, std::string_view name); /** * Adds an object to the registry. @@ -51,7 +51,7 @@ class SendableRegistry { * the value * @param channel The channel number the device is plugged into */ - void Add(Sendable* sendable, const wpi::Twine& moduleType, int channel); + void Add(Sendable* sendable, std::string_view moduleType, int channel); /** * Adds an object to the registry. @@ -62,7 +62,7 @@ class SendableRegistry { * @param moduleNumber The number of the particular module type * @param channel The channel number the device is plugged into */ - void Add(Sendable* sendable, const wpi::Twine& moduleType, int moduleNumber, + void Add(Sendable* sendable, std::string_view moduleType, int moduleNumber, int channel); /** @@ -72,8 +72,8 @@ class SendableRegistry { * @param subsystem subsystem name * @param name component name */ - void Add(Sendable* sendable, const wpi::Twine& subsystem, - const wpi::Twine& name); + void Add(Sendable* sendable, std::string_view subsystem, + std::string_view name); /** * Adds an object to the registry and LiveWindow. @@ -81,7 +81,7 @@ class SendableRegistry { * @param sendable object to add * @param name component name */ - void AddLW(Sendable* sendable, const wpi::Twine& name); + void AddLW(Sendable* sendable, std::string_view name); /** * Adds an object to the registry and LiveWindow. @@ -91,7 +91,7 @@ class SendableRegistry { * the value * @param channel The channel number the device is plugged into */ - void AddLW(Sendable* sendable, const wpi::Twine& moduleType, int channel); + void AddLW(Sendable* sendable, std::string_view moduleType, int channel); /** * Adds an object to the registry and LiveWindow. @@ -102,7 +102,7 @@ class SendableRegistry { * @param moduleNumber The number of the particular module type * @param channel The channel number the device is plugged into */ - void AddLW(Sendable* sendable, const wpi::Twine& moduleType, int moduleNumber, + void AddLW(Sendable* sendable, std::string_view moduleType, int moduleNumber, int channel); /** @@ -112,8 +112,8 @@ class SendableRegistry { * @param subsystem subsystem name * @param name component name */ - void AddLW(Sendable* sendable, const wpi::Twine& subsystem, - const wpi::Twine& name); + void AddLW(Sendable* sendable, std::string_view subsystem, + std::string_view name); /** * Adds a child object to an object. Adds the child object to the registry @@ -171,7 +171,7 @@ class SendableRegistry { * @param sendable object * @param name name */ - void SetName(Sendable* sendable, const wpi::Twine& name); + void SetName(Sendable* sendable, std::string_view name); /** * Sets the name of an object with a channel number. @@ -181,7 +181,7 @@ class SendableRegistry { * the value * @param channel The channel number the device is plugged into */ - void SetName(Sendable* sendable, const wpi::Twine& moduleType, int channel); + void SetName(Sendable* sendable, std::string_view moduleType, int channel); /** * Sets the name of an object with a module and channel number. @@ -192,7 +192,7 @@ class SendableRegistry { * @param moduleNumber The number of the particular module type * @param channel The channel number the device is plugged into */ - void SetName(Sendable* sendable, const wpi::Twine& moduleType, + void SetName(Sendable* sendable, std::string_view moduleType, int moduleNumber, int channel); /** @@ -202,8 +202,8 @@ class SendableRegistry { * @param subsystem subsystem name * @param name device name */ - void SetName(Sendable* sendable, const wpi::Twine& subsystem, - const wpi::Twine& name); + void SetName(Sendable* sendable, std::string_view subsystem, + std::string_view name); /** * Gets the subsystem name of an object. @@ -219,7 +219,7 @@ class SendableRegistry { * @param sendable object * @param subsystem subsystem name */ - void SetSubsystem(Sendable* sendable, const wpi::Twine& subsystem); + void SetSubsystem(Sendable* sendable, std::string_view subsystem); /** * Gets a unique handle for setting/getting data with SetData() and GetData().