mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Use std::string_view and fmtlib across all libraries (#3402)
- Twine, StringRef, Format, and NativeFormatting have been removed - Logging now uses fmtlib style formatting - Nearly all uses of wpi::outs/errs have been replaced with fmt::print() or std::puts()/std::fputs() (for unformatted strings). - A wpi/fmt/raw_ostream.h header has been added to enable fmt::print() with wpi::raw_ostream
This commit is contained in:
@@ -59,7 +59,7 @@ class Mechanism2d : public Sendable, public SendableHelper<Mechanism2d> {
|
||||
* @param y the root y coordinate
|
||||
* @return a new root object, or the existing one with the given name.
|
||||
*/
|
||||
MechanismRoot2d* GetRoot(wpi::StringRef name, double x, double y);
|
||||
MechanismRoot2d* GetRoot(std::string_view name, double x, double y);
|
||||
|
||||
/**
|
||||
* Set the Mechanism2d background color.
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <wpi/StringMap.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
@@ -63,13 +65,14 @@ class MechanismObject2d {
|
||||
template <typename T, typename... Args,
|
||||
typename =
|
||||
std::enable_if_t<std::is_convertible_v<T*, MechanismObject2d*>>>
|
||||
T* Append(wpi::StringRef name, Args&&... args) {
|
||||
T* Append(std::string_view name, Args&&... args) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
auto& obj = m_objects[name];
|
||||
if (obj) {
|
||||
throw std::runtime_error(("MechanismObject names must be unique! `" +
|
||||
name + "` was inserted twice!")
|
||||
.str());
|
||||
throw FRC_MakeError(
|
||||
err::Error,
|
||||
"MechanismObject names must be unique! `{}` was inserted twice!",
|
||||
name);
|
||||
}
|
||||
obj = std::make_unique<T>(name, std::forward<Args>(args)...);
|
||||
T* ex = static_cast<T*>(obj.get());
|
||||
|
||||
@@ -96,7 +96,7 @@ class SendableBuilder {
|
||||
*/
|
||||
virtual void AddStringProperty(
|
||||
std::string_view key, std::function<std::string()> getter,
|
||||
std::function<void(wpi::StringRef)> setter) = 0;
|
||||
std::function<void(std::string_view)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a boolean array property.
|
||||
@@ -140,7 +140,7 @@ class SendableBuilder {
|
||||
*/
|
||||
virtual void AddRawProperty(std::string_view key,
|
||||
std::function<std::string()> getter,
|
||||
std::function<void(wpi::StringRef)> setter) = 0;
|
||||
std::function<void(std::string_view)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a NetworkTableValue property.
|
||||
@@ -162,8 +162,8 @@ class SendableBuilder {
|
||||
*/
|
||||
virtual void AddSmallStringProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::StringRef(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(wpi::StringRef)> setter) = 0;
|
||||
std::function<std::string_view(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(std::string_view)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a boolean array property (SmallVector form).
|
||||
@@ -213,8 +213,8 @@ class SendableBuilder {
|
||||
*/
|
||||
virtual void AddSmallRawProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::StringRef(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(wpi::StringRef)> setter) = 0;
|
||||
std::function<std::string_view(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(std::string_view)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Get the network table.
|
||||
|
||||
@@ -100,7 +100,7 @@ class SendableBuilderImpl : public SendableBuilder {
|
||||
|
||||
void AddStringProperty(std::string_view key,
|
||||
std::function<std::string()> getter,
|
||||
std::function<void(wpi::StringRef)> setter) override;
|
||||
std::function<void(std::string_view)> setter) override;
|
||||
|
||||
void AddBooleanArrayProperty(
|
||||
std::string_view key, std::function<std::vector<int>()> getter,
|
||||
@@ -115,7 +115,7 @@ class SendableBuilderImpl : public SendableBuilder {
|
||||
std::function<void(wpi::ArrayRef<std::string>)> setter) override;
|
||||
|
||||
void AddRawProperty(std::string_view key, std::function<std::string()> getter,
|
||||
std::function<void(wpi::StringRef)> setter) override;
|
||||
std::function<void(std::string_view)> setter) override;
|
||||
|
||||
void AddValueProperty(
|
||||
std::string_view key, std::function<std::shared_ptr<nt::Value>()> getter,
|
||||
@@ -123,8 +123,8 @@ class SendableBuilderImpl : public SendableBuilder {
|
||||
|
||||
void AddSmallStringProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::StringRef(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(wpi::StringRef)> setter) override;
|
||||
std::function<std::string_view(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(std::string_view)> setter) override;
|
||||
|
||||
void AddSmallBooleanArrayProperty(
|
||||
std::string_view key,
|
||||
@@ -146,8 +146,8 @@ class SendableBuilderImpl : public SendableBuilder {
|
||||
|
||||
void AddSmallRawProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::StringRef(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(wpi::StringRef)> setter) override;
|
||||
std::function<std::string_view(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(std::string_view)> setter) override;
|
||||
|
||||
private:
|
||||
struct Property {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
@@ -56,7 +56,7 @@ class SendableChooser : public SendableChooserBase {
|
||||
* @param name the name of the option
|
||||
* @param object the option
|
||||
*/
|
||||
void AddOption(wpi::StringRef name, T object);
|
||||
void AddOption(std::string_view name, T object);
|
||||
|
||||
/**
|
||||
* Add the given object to the list of options and marks it as the default.
|
||||
@@ -67,7 +67,7 @@ class SendableChooser : public SendableChooserBase {
|
||||
* @param name the name of the option
|
||||
* @param object the option
|
||||
*/
|
||||
void SetDefaultOption(wpi::StringRef name, T object);
|
||||
void SetDefaultOption(std::string_view name, T object);
|
||||
|
||||
/**
|
||||
* Adds the given object to the list of options.
|
||||
@@ -75,13 +75,13 @@ class SendableChooser : public SendableChooserBase {
|
||||
* On the SmartDashboard on the desktop, the object will appear as the given
|
||||
* name.
|
||||
*
|
||||
* @deprecated use AddOption(wpi::StringRef name, T object) instead.
|
||||
* @deprecated use AddOption(std::string_view name, T object) instead.
|
||||
*
|
||||
* @param name the name of the option
|
||||
* @param object the option
|
||||
*/
|
||||
WPI_DEPRECATED("use AddOption() instead")
|
||||
void AddObject(wpi::StringRef name, T object) { AddOption(name, object); }
|
||||
void AddObject(std::string_view name, T object) { AddOption(name, object); }
|
||||
|
||||
/**
|
||||
* Add the given object to the list of options and marks it as the default.
|
||||
@@ -89,13 +89,13 @@ class SendableChooser : public SendableChooserBase {
|
||||
* Functionally, this is very close to AddOption() except that it will use
|
||||
* this as the default option if none other is explicitly selected.
|
||||
*
|
||||
* @deprecated use SetDefaultOption(wpi::StringRef name, T object) instead.
|
||||
* @deprecated use SetDefaultOption(std::string_view name, T object) instead.
|
||||
*
|
||||
* @param name the name of the option
|
||||
* @param object the option
|
||||
*/
|
||||
WPI_DEPRECATED("use SetDefaultOption() instead")
|
||||
void AddDefault(wpi::StringRef name, T object) {
|
||||
void AddDefault(std::string_view name, T object) {
|
||||
SetDefaultOption(name, object);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,22 +7,21 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/StringRef.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableChooser.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
template <class T>
|
||||
void SendableChooser<T>::AddOption(wpi::StringRef name, T object) {
|
||||
void SendableChooser<T>::AddOption(std::string_view name, T object) {
|
||||
m_choices[name] = std::move(object);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void SendableChooser<T>::SetDefaultOption(wpi::StringRef name, T object) {
|
||||
void SendableChooser<T>::SetDefaultOption(std::string_view name, T object) {
|
||||
m_defaultChoice = name;
|
||||
AddOption(name, std::move(object));
|
||||
}
|
||||
@@ -53,7 +52,7 @@ void SendableChooser<T>::InitSendable(SendableBuilder& builder) {
|
||||
[=]() {
|
||||
std::vector<std::string> keys;
|
||||
for (const auto& choice : m_choices) {
|
||||
keys.push_back(choice.first());
|
||||
keys.emplace_back(choice.first());
|
||||
}
|
||||
|
||||
// Unlike std::map, wpi::StringMap elements
|
||||
@@ -65,17 +64,17 @@ void SendableChooser<T>::InitSendable(SendableBuilder& builder) {
|
||||
nullptr);
|
||||
builder.AddSmallStringProperty(
|
||||
kDefault,
|
||||
[=](wpi::SmallVectorImpl<char>&) -> wpi::StringRef {
|
||||
[=](wpi::SmallVectorImpl<char>&) -> std::string_view {
|
||||
return m_defaultChoice;
|
||||
},
|
||||
nullptr);
|
||||
builder.AddSmallStringProperty(
|
||||
kActive,
|
||||
[=](wpi::SmallVectorImpl<char>& buf) -> wpi::StringRef {
|
||||
[=](wpi::SmallVectorImpl<char>& buf) -> std::string_view {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
if (m_haveSelected) {
|
||||
buf.assign(m_selected.begin(), m_selected.end());
|
||||
return wpi::StringRef(buf.data(), buf.size());
|
||||
return {buf.data(), buf.size()};
|
||||
} else {
|
||||
return m_defaultChoice;
|
||||
}
|
||||
@@ -85,7 +84,7 @@ void SendableChooser<T>::InitSendable(SendableBuilder& builder) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_activeEntries.emplace_back(builder.GetEntry(kActive));
|
||||
}
|
||||
builder.AddStringProperty(kSelected, nullptr, [=](wpi::StringRef val) {
|
||||
builder.AddStringProperty(kSelected, nullptr, [=](std::string_view val) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_haveSelected = true;
|
||||
m_selected = val;
|
||||
|
||||
@@ -298,8 +298,8 @@ class SendableRegistry {
|
||||
* Data passed to ForeachLiveWindow() callback function
|
||||
*/
|
||||
struct CallbackData {
|
||||
CallbackData(Sendable* sendable_, wpi::StringRef name_,
|
||||
wpi::StringRef subsystem_, Sendable* parent_,
|
||||
CallbackData(Sendable* sendable_, std::string_view name_,
|
||||
std::string_view subsystem_, Sendable* parent_,
|
||||
std::shared_ptr<void>& data_, SendableBuilderImpl& builder_)
|
||||
: sendable(sendable_),
|
||||
name(name_),
|
||||
@@ -309,8 +309,8 @@ class SendableRegistry {
|
||||
builder(builder_) {}
|
||||
|
||||
Sendable* sendable;
|
||||
wpi::StringRef name;
|
||||
wpi::StringRef subsystem;
|
||||
std::string_view name;
|
||||
std::string_view subsystem;
|
||||
Sendable* parent;
|
||||
std::shared_ptr<void>& data;
|
||||
SendableBuilderImpl& builder;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
@@ -27,7 +28,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param key the key to search for
|
||||
* @return true if the table as a value assigned to the given key
|
||||
*/
|
||||
static bool ContainsKey(wpi::StringRef key);
|
||||
static bool ContainsKey(std::string_view key);
|
||||
|
||||
/**
|
||||
* @param types bitmask of types; 0 is treated as a "don't care".
|
||||
@@ -40,7 +41,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
*
|
||||
* @param key the key to make persistent
|
||||
*/
|
||||
static void SetPersistent(wpi::StringRef key);
|
||||
static void SetPersistent(std::string_view key);
|
||||
|
||||
/**
|
||||
* Stop making a key's value persistent through program restarts.
|
||||
@@ -48,7 +49,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
static void ClearPersistent(wpi::StringRef key);
|
||||
static void ClearPersistent(std::string_view key);
|
||||
|
||||
/**
|
||||
* Returns whether the value is persistent through program restarts.
|
||||
@@ -56,7 +57,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
static bool IsPersistent(wpi::StringRef key);
|
||||
static bool IsPersistent(std::string_view key);
|
||||
|
||||
/**
|
||||
* Sets flags on the specified key in this table. The key can
|
||||
@@ -65,7 +66,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param key the key name
|
||||
* @param flags the flags to set (bitmask)
|
||||
*/
|
||||
static void SetFlags(wpi::StringRef key, unsigned int flags);
|
||||
static void SetFlags(std::string_view key, unsigned int flags);
|
||||
|
||||
/**
|
||||
* Clears flags on the specified key in this table. The key can
|
||||
@@ -74,7 +75,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param key the key name
|
||||
* @param flags the flags to clear (bitmask)
|
||||
*/
|
||||
static void ClearFlags(wpi::StringRef key, unsigned int flags);
|
||||
static void ClearFlags(std::string_view key, unsigned int flags);
|
||||
|
||||
/**
|
||||
* Returns the flags for the specified key.
|
||||
@@ -82,14 +83,14 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param key the key name
|
||||
* @return the flags, or 0 if the key is not defined
|
||||
*/
|
||||
static unsigned int GetFlags(wpi::StringRef key);
|
||||
static unsigned int GetFlags(std::string_view key);
|
||||
|
||||
/**
|
||||
* Deletes the specified key in this table.
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
static void Delete(wpi::StringRef key);
|
||||
static void Delete(std::string_view key);
|
||||
|
||||
/**
|
||||
* Returns an NT Entry mapping to the specified key
|
||||
@@ -99,7 +100,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param key the key
|
||||
* @return the entry for the key
|
||||
*/
|
||||
static nt::NetworkTableEntry GetEntry(wpi::StringRef key);
|
||||
static nt::NetworkTableEntry GetEntry(std::string_view key);
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified value in this table.
|
||||
@@ -113,7 +114,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param keyName the key
|
||||
* @param value the value
|
||||
*/
|
||||
static void PutData(wpi::StringRef key, Sendable* data);
|
||||
static void PutData(std::string_view key, Sendable* data);
|
||||
|
||||
/**
|
||||
* Maps the specified key (where the key is the name of the Sendable)
|
||||
@@ -135,7 +136,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param keyName the key
|
||||
* @return the value
|
||||
*/
|
||||
static Sendable* GetData(wpi::StringRef keyName);
|
||||
static Sendable* GetData(std::string_view keyName);
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified value in this table.
|
||||
@@ -147,7 +148,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param value the value
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
static bool PutBoolean(wpi::StringRef keyName, bool value);
|
||||
static bool PutBoolean(std::string_view keyName, bool value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -155,7 +156,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultBoolean(wpi::StringRef key, bool defaultValue);
|
||||
static bool SetDefaultBoolean(std::string_view key, bool defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
@@ -165,7 +166,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param keyName the key
|
||||
* @return the value
|
||||
*/
|
||||
static bool GetBoolean(wpi::StringRef keyName, bool defaultValue);
|
||||
static bool GetBoolean(std::string_view keyName, bool defaultValue);
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified value in this table.
|
||||
@@ -177,7 +178,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param value the value
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
static bool PutNumber(wpi::StringRef keyName, double value);
|
||||
static bool PutNumber(std::string_view keyName, double value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -186,7 +187,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param defaultValue The default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultNumber(wpi::StringRef key, double defaultValue);
|
||||
static bool SetDefaultNumber(std::string_view key, double defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
@@ -196,7 +197,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param keyName the key
|
||||
* @return the value
|
||||
*/
|
||||
static double GetNumber(wpi::StringRef keyName, double defaultValue);
|
||||
static double GetNumber(std::string_view keyName, double defaultValue);
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified value in this table.
|
||||
@@ -208,7 +209,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param value the value
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
static bool PutString(wpi::StringRef keyName, wpi::StringRef value);
|
||||
static bool PutString(std::string_view keyName, std::string_view value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -217,7 +218,8 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultString(wpi::StringRef key, wpi::StringRef defaultValue);
|
||||
static bool SetDefaultString(std::string_view key,
|
||||
std::string_view defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
@@ -227,8 +229,8 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param keyName the key
|
||||
* @return the value
|
||||
*/
|
||||
static std::string GetString(wpi::StringRef keyName,
|
||||
wpi::StringRef defaultValue);
|
||||
static std::string GetString(std::string_view keyName,
|
||||
std::string_view defaultValue);
|
||||
|
||||
/**
|
||||
* Put a boolean array in the table.
|
||||
@@ -241,7 +243,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* std::vector<bool> is special-cased in C++. 0 is false, any
|
||||
* non-zero value is true.
|
||||
*/
|
||||
static bool PutBooleanArray(wpi::StringRef key, wpi::ArrayRef<int> value);
|
||||
static bool PutBooleanArray(std::string_view key, wpi::ArrayRef<int> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -250,7 +252,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultBooleanArray(wpi::StringRef key,
|
||||
static bool SetDefaultBooleanArray(std::string_view key,
|
||||
wpi::ArrayRef<int> defaultValue);
|
||||
|
||||
/**
|
||||
@@ -271,7 +273,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* because std::vector<bool> is special-cased in C++. 0 is false, any
|
||||
* non-zero value is true.
|
||||
*/
|
||||
static std::vector<int> GetBooleanArray(wpi::StringRef key,
|
||||
static std::vector<int> GetBooleanArray(std::string_view key,
|
||||
wpi::ArrayRef<int> defaultValue);
|
||||
|
||||
/**
|
||||
@@ -281,7 +283,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param value The value that will be assigned.
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
static bool PutNumberArray(wpi::StringRef key, wpi::ArrayRef<double> value);
|
||||
static bool PutNumberArray(std::string_view key, wpi::ArrayRef<double> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -290,7 +292,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param defaultValue The default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultNumberArray(wpi::StringRef key,
|
||||
static bool SetDefaultNumberArray(std::string_view key,
|
||||
wpi::ArrayRef<double> defaultValue);
|
||||
|
||||
/**
|
||||
@@ -307,7 +309,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @note This makes a copy of the array. If the overhead of this is a concern,
|
||||
* use GetValue() instead.
|
||||
*/
|
||||
static std::vector<double> GetNumberArray(wpi::StringRef key,
|
||||
static std::vector<double> GetNumberArray(std::string_view key,
|
||||
wpi::ArrayRef<double> defaultValue);
|
||||
|
||||
/**
|
||||
@@ -317,7 +319,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param value The value that will be assigned.
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
static bool PutStringArray(wpi::StringRef key,
|
||||
static bool PutStringArray(std::string_view key,
|
||||
wpi::ArrayRef<std::string> value);
|
||||
|
||||
/**
|
||||
@@ -327,7 +329,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param defaultValue The default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultStringArray(wpi::StringRef key,
|
||||
static bool SetDefaultStringArray(std::string_view key,
|
||||
wpi::ArrayRef<std::string> defaultValue);
|
||||
|
||||
/**
|
||||
@@ -345,7 +347,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* use GetValue() instead.
|
||||
*/
|
||||
static std::vector<std::string> GetStringArray(
|
||||
wpi::StringRef key, wpi::ArrayRef<std::string> defaultValue);
|
||||
std::string_view key, wpi::ArrayRef<std::string> defaultValue);
|
||||
|
||||
/**
|
||||
* Put a raw value (byte array) in the table.
|
||||
@@ -354,7 +356,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param value The value that will be assigned.
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
static bool PutRaw(wpi::StringRef key, wpi::StringRef value);
|
||||
static bool PutRaw(std::string_view key, std::string_view value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -363,7 +365,8 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param defaultValue The default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultRaw(wpi::StringRef key, wpi::StringRef defaultValue);
|
||||
static bool SetDefaultRaw(std::string_view key,
|
||||
std::string_view defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the raw value (byte array) the key maps to.
|
||||
@@ -379,7 +382,8 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @note This makes a copy of the raw contents. If the overhead of this is a
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
static std::string GetRaw(wpi::StringRef key, wpi::StringRef defaultValue);
|
||||
static std::string GetRaw(std::string_view key,
|
||||
std::string_view defaultValue);
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified complex value (such as an array) in
|
||||
@@ -392,7 +396,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param value the value
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
static bool PutValue(wpi::StringRef keyName,
|
||||
static bool PutValue(std::string_view keyName,
|
||||
std::shared_ptr<nt::Value> value);
|
||||
|
||||
/**
|
||||
@@ -402,7 +406,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param defaultValue The default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultValue(wpi::StringRef key,
|
||||
static bool SetDefaultValue(std::string_view key,
|
||||
std::shared_ptr<nt::Value> defaultValue);
|
||||
|
||||
/**
|
||||
@@ -412,7 +416,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param keyName the key
|
||||
* @param value the object to retrieve the value into
|
||||
*/
|
||||
static std::shared_ptr<nt::Value> GetValue(wpi::StringRef keyName);
|
||||
static std::shared_ptr<nt::Value> GetValue(std::string_view keyName);
|
||||
|
||||
/**
|
||||
* Posts a task from a listener to the ListenerExecutor, so that it can be run
|
||||
|
||||
Reference in New Issue
Block a user