mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Use wpi::span instead of wpi::ArrayRef across all libraries (#3414)
- Remove ArrayRef.h - Add SpanExtras.h for a couple of convenience functions
This commit is contained in:
@@ -12,9 +12,9 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/ArrayRef.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
#include "networktables/TableEntryListener.h"
|
||||
@@ -360,7 +360,7 @@ class NetworkTable final {
|
||||
* std::vector<bool> is special-cased in C++. 0 is false, any
|
||||
* non-zero value is true.
|
||||
*/
|
||||
bool PutBooleanArray(std::string_view key, wpi::ArrayRef<int> value);
|
||||
bool PutBooleanArray(std::string_view key, wpi::span<const int> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -370,7 +370,7 @@ class NetworkTable final {
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultBooleanArray(std::string_view key,
|
||||
wpi::ArrayRef<int> defaultValue);
|
||||
wpi::span<const int> defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the boolean array the key maps to. If the key does not exist or is
|
||||
@@ -389,7 +389,7 @@ class NetworkTable final {
|
||||
* non-zero value is true.
|
||||
*/
|
||||
std::vector<int> GetBooleanArray(std::string_view key,
|
||||
wpi::ArrayRef<int> defaultValue) const;
|
||||
wpi::span<const int> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Put a number array in the table
|
||||
@@ -398,7 +398,7 @@ class NetworkTable final {
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool PutNumberArray(std::string_view key, wpi::ArrayRef<double> value);
|
||||
bool PutNumberArray(std::string_view key, wpi::span<const double> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -408,7 +408,7 @@ class NetworkTable final {
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultNumberArray(std::string_view key,
|
||||
wpi::ArrayRef<double> defaultValue);
|
||||
wpi::span<const double> defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the number array the key maps to. If the key does not exist or is
|
||||
@@ -422,8 +422,8 @@ class NetworkTable final {
|
||||
* @note This makes a copy of the array. If the overhead of this is a
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
std::vector<double> GetNumberArray(std::string_view key,
|
||||
wpi::ArrayRef<double> defaultValue) const;
|
||||
std::vector<double> GetNumberArray(
|
||||
std::string_view key, wpi::span<const double> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Put a string array in the table
|
||||
@@ -432,7 +432,7 @@ class NetworkTable final {
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool PutStringArray(std::string_view key, wpi::ArrayRef<std::string> value);
|
||||
bool PutStringArray(std::string_view key, wpi::span<const std::string> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -442,7 +442,7 @@ class NetworkTable final {
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultStringArray(std::string_view key,
|
||||
wpi::ArrayRef<std::string> defaultValue);
|
||||
wpi::span<const std::string> defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the string array the key maps to. If the key does not exist or is
|
||||
@@ -457,7 +457,7 @@ class NetworkTable final {
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
std::vector<std::string> GetStringArray(
|
||||
std::string_view key, wpi::ArrayRef<std::string> defaultValue) const;
|
||||
std::string_view key, wpi::span<const std::string> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Put a raw value (byte array) in the table
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/NetworkTableValue.h"
|
||||
#include "networktables/RpcCall.h"
|
||||
@@ -166,7 +168,7 @@ class NetworkTableEntry final {
|
||||
* because std::vector<bool> is special-cased in C++. 0 is false, any
|
||||
* non-zero value is true.
|
||||
*/
|
||||
std::vector<int> GetBooleanArray(wpi::ArrayRef<int> defaultValue) const;
|
||||
std::vector<int> GetBooleanArray(wpi::span<const int> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Gets the entry's value as a boolean array. If the entry does not exist
|
||||
@@ -195,7 +197,8 @@ class NetworkTableEntry final {
|
||||
* @note This makes a copy of the array. If the overhead of this is a
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
std::vector<double> GetDoubleArray(wpi::ArrayRef<double> defaultValue) const;
|
||||
std::vector<double> GetDoubleArray(
|
||||
wpi::span<const double> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Gets the entry's value as a double array. If the entry does not exist
|
||||
@@ -221,7 +224,7 @@ class NetworkTableEntry final {
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
std::vector<std::string> GetStringArray(
|
||||
wpi::ArrayRef<std::string> defaultValue) const;
|
||||
wpi::span<const std::string> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Gets the entry's value as a string array. If the entry does not exist
|
||||
@@ -282,7 +285,7 @@ class NetworkTableEntry final {
|
||||
* @param defaultValue the default value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetDefaultBooleanArray(wpi::ArrayRef<int> defaultValue);
|
||||
bool SetDefaultBooleanArray(wpi::span<const int> defaultValue);
|
||||
|
||||
/**
|
||||
* Sets the entry's value if it does not exist.
|
||||
@@ -298,7 +301,7 @@ class NetworkTableEntry final {
|
||||
* @param defaultValue the default value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetDefaultDoubleArray(wpi::ArrayRef<double> defaultValue);
|
||||
bool SetDefaultDoubleArray(wpi::span<const double> defaultValue);
|
||||
|
||||
/**
|
||||
* Sets the entry's value if it does not exist.
|
||||
@@ -314,7 +317,7 @@ class NetworkTableEntry final {
|
||||
* @param defaultValue the default value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetDefaultStringArray(wpi::ArrayRef<std::string> defaultValue);
|
||||
bool SetDefaultStringArray(wpi::span<const std::string> defaultValue);
|
||||
|
||||
/**
|
||||
* Sets the entry's value if it does not exist.
|
||||
@@ -370,7 +373,7 @@ class NetworkTableEntry final {
|
||||
* @param value the value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetBooleanArray(wpi::ArrayRef<bool> value);
|
||||
bool SetBooleanArray(wpi::span<const bool> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value.
|
||||
@@ -386,7 +389,7 @@ class NetworkTableEntry final {
|
||||
* @param value the value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetBooleanArray(wpi::ArrayRef<int> value);
|
||||
bool SetBooleanArray(wpi::span<const int> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value.
|
||||
@@ -402,7 +405,7 @@ class NetworkTableEntry final {
|
||||
* @param value the value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetDoubleArray(wpi::ArrayRef<double> value);
|
||||
bool SetDoubleArray(wpi::span<const double> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value.
|
||||
@@ -418,7 +421,7 @@ class NetworkTableEntry final {
|
||||
* @param value the value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetStringArray(wpi::ArrayRef<std::string> value);
|
||||
bool SetStringArray(wpi::span<const std::string> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value.
|
||||
@@ -474,7 +477,7 @@ class NetworkTableEntry final {
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
void ForceSetBooleanArray(wpi::ArrayRef<bool> value);
|
||||
void ForceSetBooleanArray(wpi::span<const bool> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value. If the value is of different type, the type is
|
||||
@@ -490,7 +493,7 @@ class NetworkTableEntry final {
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
void ForceSetBooleanArray(wpi::ArrayRef<int> value);
|
||||
void ForceSetBooleanArray(wpi::span<const int> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value. If the value is of different type, the type is
|
||||
@@ -506,7 +509,7 @@ class NetworkTableEntry final {
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
void ForceSetDoubleArray(wpi::ArrayRef<double> value);
|
||||
void ForceSetDoubleArray(wpi::span<const double> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value. If the value is of different type, the type is
|
||||
@@ -522,7 +525,7 @@ class NetworkTableEntry final {
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
void ForceSetStringArray(wpi::ArrayRef<std::string> value);
|
||||
void ForceSetStringArray(wpi::span<const std::string> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value. If the value is of different type, the type is
|
||||
|
||||
@@ -86,48 +86,48 @@ inline std::string NetworkTableEntry::GetRaw(
|
||||
}
|
||||
|
||||
inline std::vector<int> NetworkTableEntry::GetBooleanArray(
|
||||
wpi::ArrayRef<int> defaultValue) const {
|
||||
wpi::span<const int> defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_BOOLEAN_ARRAY) {
|
||||
return defaultValue;
|
||||
return {defaultValue.begin(), defaultValue.end()};
|
||||
}
|
||||
return value->GetBooleanArray();
|
||||
auto arr = value->GetBooleanArray();
|
||||
return {arr.begin(), arr.end()};
|
||||
}
|
||||
|
||||
inline std::vector<int> NetworkTableEntry::GetBooleanArray(
|
||||
std::initializer_list<int> defaultValue) const {
|
||||
return GetBooleanArray(
|
||||
wpi::makeArrayRef(defaultValue.begin(), defaultValue.end()));
|
||||
return GetBooleanArray({defaultValue.begin(), defaultValue.end()});
|
||||
}
|
||||
|
||||
inline std::vector<double> NetworkTableEntry::GetDoubleArray(
|
||||
wpi::ArrayRef<double> defaultValue) const {
|
||||
wpi::span<const double> defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_DOUBLE_ARRAY) {
|
||||
return defaultValue;
|
||||
return {defaultValue.begin(), defaultValue.end()};
|
||||
}
|
||||
return value->GetDoubleArray();
|
||||
auto arr = value->GetDoubleArray();
|
||||
return {arr.begin(), arr.end()};
|
||||
}
|
||||
|
||||
inline std::vector<double> NetworkTableEntry::GetDoubleArray(
|
||||
std::initializer_list<double> defaultValue) const {
|
||||
return GetDoubleArray(
|
||||
wpi::makeArrayRef(defaultValue.begin(), defaultValue.end()));
|
||||
return GetDoubleArray({defaultValue.begin(), defaultValue.end()});
|
||||
}
|
||||
|
||||
inline std::vector<std::string> NetworkTableEntry::GetStringArray(
|
||||
wpi::ArrayRef<std::string> defaultValue) const {
|
||||
wpi::span<const std::string> defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_STRING_ARRAY) {
|
||||
return defaultValue;
|
||||
return {defaultValue.begin(), defaultValue.end()};
|
||||
}
|
||||
return value->GetStringArray();
|
||||
auto arr = value->GetStringArray();
|
||||
return {arr.begin(), arr.end()};
|
||||
}
|
||||
|
||||
inline std::vector<std::string> NetworkTableEntry::GetStringArray(
|
||||
std::initializer_list<std::string> defaultValue) const {
|
||||
return GetStringArray(
|
||||
wpi::makeArrayRef(defaultValue.begin(), defaultValue.end()));
|
||||
return GetStringArray({defaultValue.begin(), defaultValue.end()});
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDefaultValue(std::shared_ptr<Value> value) {
|
||||
@@ -151,7 +151,7 @@ inline bool NetworkTableEntry::SetDefaultRaw(std::string_view defaultValue) {
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDefaultBooleanArray(
|
||||
wpi::ArrayRef<int> defaultValue) {
|
||||
wpi::span<const int> defaultValue) {
|
||||
return SetDefaultEntryValue(m_handle, Value::MakeBooleanArray(defaultValue));
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ inline bool NetworkTableEntry::SetDefaultBooleanArray(
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDefaultDoubleArray(
|
||||
wpi::ArrayRef<double> defaultValue) {
|
||||
wpi::span<const double> defaultValue) {
|
||||
return SetDefaultEntryValue(m_handle, Value::MakeDoubleArray(defaultValue));
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ inline bool NetworkTableEntry::SetDefaultDoubleArray(
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDefaultStringArray(
|
||||
wpi::ArrayRef<std::string> defaultValue) {
|
||||
wpi::span<const std::string> defaultValue) {
|
||||
return SetDefaultEntryValue(m_handle, Value::MakeStringArray(defaultValue));
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ inline bool NetworkTableEntry::SetRaw(std::string_view value) {
|
||||
return SetEntryValue(m_handle, Value::MakeRaw(value));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetBooleanArray(wpi::ArrayRef<bool> value) {
|
||||
inline bool NetworkTableEntry::SetBooleanArray(wpi::span<const bool> value) {
|
||||
return SetEntryValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ inline bool NetworkTableEntry::SetBooleanArray(
|
||||
return SetEntryValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetBooleanArray(wpi::ArrayRef<int> value) {
|
||||
inline bool NetworkTableEntry::SetBooleanArray(wpi::span<const int> value) {
|
||||
return SetEntryValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ inline bool NetworkTableEntry::SetBooleanArray(
|
||||
return SetEntryValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDoubleArray(wpi::ArrayRef<double> value) {
|
||||
inline bool NetworkTableEntry::SetDoubleArray(wpi::span<const double> value) {
|
||||
return SetEntryValue(m_handle, Value::MakeDoubleArray(value));
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ inline bool NetworkTableEntry::SetDoubleArray(
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetStringArray(
|
||||
wpi::ArrayRef<std::string> value) {
|
||||
wpi::span<const std::string> value) {
|
||||
return SetEntryValue(m_handle, Value::MakeStringArray(value));
|
||||
}
|
||||
|
||||
@@ -257,7 +257,8 @@ inline void NetworkTableEntry::ForceSetRaw(std::string_view value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeRaw(value));
|
||||
}
|
||||
|
||||
inline void NetworkTableEntry::ForceSetBooleanArray(wpi::ArrayRef<bool> value) {
|
||||
inline void NetworkTableEntry::ForceSetBooleanArray(
|
||||
wpi::span<const bool> value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
@@ -266,7 +267,8 @@ inline void NetworkTableEntry::ForceSetBooleanArray(
|
||||
SetEntryTypeValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
inline void NetworkTableEntry::ForceSetBooleanArray(wpi::ArrayRef<int> value) {
|
||||
inline void NetworkTableEntry::ForceSetBooleanArray(
|
||||
wpi::span<const int> value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
@@ -276,7 +278,7 @@ inline void NetworkTableEntry::ForceSetBooleanArray(
|
||||
}
|
||||
|
||||
inline void NetworkTableEntry::ForceSetDoubleArray(
|
||||
wpi::ArrayRef<double> value) {
|
||||
wpi::span<const double> value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeDoubleArray(value));
|
||||
}
|
||||
|
||||
@@ -286,7 +288,7 @@ inline void NetworkTableEntry::ForceSetDoubleArray(
|
||||
}
|
||||
|
||||
inline void NetworkTableEntry::ForceSetStringArray(
|
||||
wpi::ArrayRef<std::string> value) {
|
||||
wpi::span<const std::string> value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeStringArray(value));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/ArrayRef.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "networktables/NetworkTable.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
@@ -342,7 +342,7 @@ class NetworkTableInstance final {
|
||||
* @param servers array of server name and port pairs
|
||||
*/
|
||||
void StartClient(
|
||||
wpi::ArrayRef<std::pair<std::string_view, unsigned int>> servers);
|
||||
wpi::span<const std::pair<std::string_view, unsigned int>> servers);
|
||||
|
||||
/**
|
||||
* Starts a client using the specified servers and port. The
|
||||
@@ -351,7 +351,7 @@ class NetworkTableInstance final {
|
||||
* @param servers array of server names
|
||||
* @param port port to communicate over
|
||||
*/
|
||||
void StartClient(wpi::ArrayRef<std::string_view> servers,
|
||||
void StartClient(wpi::span<const std::string_view> servers,
|
||||
unsigned int port = kDefaultPort);
|
||||
|
||||
/**
|
||||
@@ -383,7 +383,7 @@ class NetworkTableInstance final {
|
||||
* @param servers array of server name and port pairs
|
||||
*/
|
||||
void SetServer(
|
||||
wpi::ArrayRef<std::pair<std::string_view, unsigned int>> servers);
|
||||
wpi::span<const std::pair<std::string_view, unsigned int>> servers);
|
||||
|
||||
/**
|
||||
* Sets server addresses and port for client (without restarting client).
|
||||
@@ -392,7 +392,7 @@ class NetworkTableInstance final {
|
||||
* @param servers array of server names
|
||||
* @param port port to communicate over
|
||||
*/
|
||||
void SetServer(wpi::ArrayRef<std::string_view> servers,
|
||||
void SetServer(wpi::span<const std::string_view> servers,
|
||||
unsigned int port = kDefaultPort);
|
||||
|
||||
/**
|
||||
|
||||
@@ -117,7 +117,7 @@ inline void NetworkTableInstance::StartClient(const char* server_name,
|
||||
}
|
||||
|
||||
inline void NetworkTableInstance::StartClient(
|
||||
wpi::ArrayRef<std::pair<std::string_view, unsigned int>> servers) {
|
||||
wpi::span<const std::pair<std::string_view, unsigned int>> servers) {
|
||||
::nt::StartClient(m_handle, servers);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ inline void NetworkTableInstance::SetServer(const char* server_name,
|
||||
}
|
||||
|
||||
inline void NetworkTableInstance::SetServer(
|
||||
wpi::ArrayRef<std::pair<std::string_view, unsigned int>> servers) {
|
||||
wpi::span<const std::pair<std::string_view, unsigned int>> servers) {
|
||||
::nt::SetServer(m_handle, servers);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/ArrayRef.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "ntcore_c.h"
|
||||
|
||||
@@ -192,10 +192,9 @@ class Value final {
|
||||
*
|
||||
* @return The boolean array value.
|
||||
*/
|
||||
wpi::ArrayRef<int> GetBooleanArray() const {
|
||||
wpi::span<const int> GetBooleanArray() const {
|
||||
assert(m_val.type == NT_BOOLEAN_ARRAY);
|
||||
return wpi::ArrayRef<int>(m_val.data.arr_boolean.arr,
|
||||
m_val.data.arr_boolean.size);
|
||||
return {m_val.data.arr_boolean.arr, m_val.data.arr_boolean.size};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,10 +202,9 @@ class Value final {
|
||||
*
|
||||
* @return The double array value.
|
||||
*/
|
||||
wpi::ArrayRef<double> GetDoubleArray() const {
|
||||
wpi::span<const double> GetDoubleArray() const {
|
||||
assert(m_val.type == NT_DOUBLE_ARRAY);
|
||||
return wpi::ArrayRef<double>(m_val.data.arr_double.arr,
|
||||
m_val.data.arr_double.size);
|
||||
return {m_val.data.arr_double.arr, m_val.data.arr_double.size};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +212,7 @@ class Value final {
|
||||
*
|
||||
* @return The string array value.
|
||||
*/
|
||||
wpi::ArrayRef<std::string> GetStringArray() const {
|
||||
wpi::span<const std::string> GetStringArray() const {
|
||||
assert(m_val.type == NT_STRING_ARRAY);
|
||||
return m_string_array;
|
||||
}
|
||||
@@ -366,7 +364,7 @@ class Value final {
|
||||
* time)
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeBooleanArray(wpi::ArrayRef<bool> value,
|
||||
static std::shared_ptr<Value> MakeBooleanArray(wpi::span<const bool> value,
|
||||
uint64_t time = 0);
|
||||
|
||||
/**
|
||||
@@ -379,8 +377,7 @@ class Value final {
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeBooleanArray(
|
||||
std::initializer_list<bool> value, uint64_t time = 0) {
|
||||
return MakeBooleanArray(wpi::makeArrayRef(value.begin(), value.end()),
|
||||
time);
|
||||
return MakeBooleanArray(wpi::span(value.begin(), value.end()), time);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,7 +388,7 @@ class Value final {
|
||||
* time)
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeBooleanArray(wpi::ArrayRef<int> value,
|
||||
static std::shared_ptr<Value> MakeBooleanArray(wpi::span<const int> value,
|
||||
uint64_t time = 0);
|
||||
|
||||
/**
|
||||
@@ -404,8 +401,7 @@ class Value final {
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeBooleanArray(
|
||||
std::initializer_list<int> value, uint64_t time = 0) {
|
||||
return MakeBooleanArray(wpi::makeArrayRef(value.begin(), value.end()),
|
||||
time);
|
||||
return MakeBooleanArray(wpi::span(value.begin(), value.end()), time);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,7 +412,7 @@ class Value final {
|
||||
* time)
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeDoubleArray(wpi::ArrayRef<double> value,
|
||||
static std::shared_ptr<Value> MakeDoubleArray(wpi::span<const double> value,
|
||||
uint64_t time = 0);
|
||||
|
||||
/**
|
||||
@@ -429,7 +425,7 @@ class Value final {
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeDoubleArray(
|
||||
std::initializer_list<double> value, uint64_t time = 0) {
|
||||
return MakeDoubleArray(wpi::makeArrayRef(value.begin(), value.end()), time);
|
||||
return MakeDoubleArray(wpi::span(value.begin(), value.end()), time);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,7 +437,7 @@ class Value final {
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeStringArray(
|
||||
wpi::ArrayRef<std::string> value, uint64_t time = 0);
|
||||
wpi::span<const std::string> value, uint64_t time = 0);
|
||||
|
||||
/**
|
||||
* Creates a string array entry value.
|
||||
@@ -453,7 +449,7 @@ class Value final {
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeStringArray(
|
||||
std::initializer_list<std::string> value, uint64_t time = 0) {
|
||||
return MakeStringArray(wpi::makeArrayRef(value.begin(), value.end()), time);
|
||||
return MakeStringArray(wpi::span(value.begin(), value.end()), time);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/ArrayRef.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "networktables/NetworkTableValue.h"
|
||||
|
||||
@@ -955,7 +955,7 @@ bool UnpackRpcDefinition(std::string_view packed, RpcDefinition* def);
|
||||
* @param values array of values to pack
|
||||
* @return Raw packed bytes.
|
||||
*/
|
||||
std::string PackRpcValues(wpi::ArrayRef<std::shared_ptr<Value>> values);
|
||||
std::string PackRpcValues(wpi::span<const std::shared_ptr<Value>> values);
|
||||
|
||||
/**
|
||||
* Unpack RPC values as required for RPC version 1 definition messages.
|
||||
@@ -965,7 +965,7 @@ std::string PackRpcValues(wpi::ArrayRef<std::shared_ptr<Value>> values);
|
||||
* @return Array of values.
|
||||
*/
|
||||
std::vector<std::shared_ptr<Value>> UnpackRpcValues(
|
||||
std::string_view packed, wpi::ArrayRef<NT_Type> types);
|
||||
std::string_view packed, wpi::span<const NT_Type> types);
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -1050,7 +1050,7 @@ void StartClient(NT_Inst inst, const char* server_name, unsigned int port);
|
||||
*/
|
||||
void StartClient(
|
||||
NT_Inst inst,
|
||||
wpi::ArrayRef<std::pair<std::string_view, unsigned int>> servers);
|
||||
wpi::span<const std::pair<std::string_view, unsigned int>> servers);
|
||||
|
||||
/**
|
||||
* Starts a client using commonly known robot addresses for the specified
|
||||
@@ -1087,7 +1087,7 @@ void SetServer(NT_Inst inst, const char* server_name, unsigned int port);
|
||||
*/
|
||||
void SetServer(
|
||||
NT_Inst inst,
|
||||
wpi::ArrayRef<std::pair<std::string_view, unsigned int>> servers);
|
||||
wpi::span<const std::pair<std::string_view, unsigned int>> servers);
|
||||
|
||||
/**
|
||||
* Sets server addresses and port for client (without restarting client).
|
||||
|
||||
Reference in New Issue
Block a user