Upgrade to C++20 (#4239)

* Use explicit this capture required by C++20
* Use C++20 span
* Replace wpi::numbers with std::numbers
* Fix C++20 clang-tidy warning false positive in fmt
* Remove ciso646 include since C++20 removed that header
* Fix global-buffer-overflow asan warnings in ntcore tests
* Add DIOSetProxy constructor to HAL

* Upgrade MSVC compiler to 2022
* Bump native-utils to 2023.2.7 (changes to std=c++20)

Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
This commit is contained in:
Tyler Veness
2022-10-15 16:33:14 -07:00
committed by GitHub
parent 396143004c
commit fbdc810887
355 changed files with 1659 additions and 2918 deletions

View File

@@ -51,13 +51,13 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
artifact-name: Win64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly --max-workers 1"
outputs: "build/allOutputs"
- os: windows-2019
- os: windows-2022
artifact-name: Win64Release
architecture: x64
build-options: "-PciReleaseOnly --max-workers 1"
@@ -69,7 +69,7 @@ jobs:
build-options: "-Pbuildalldesktop"
task: "build"
outputs: "build/allOutputs"
- os: windows-2019
- os: windows-2022
artifact-name: Win32
architecture: x86
task: ":ntcoreffi:build"

View File

@@ -47,8 +47,8 @@ Using Gradle makes building WPILib very straightforward. It only has a few depen
- On Windows, install the JDK 11 .msi from the link above
- On macOS, install the JDK 11 .pkg from the link above
- C++ compiler
- On Linux, install GCC 8 or greater
- On Windows, install [Visual Studio Community 2022 or 2019](https://visualstudio.microsoft.com/vs/community/) and select the C++ programming language during installation (Gradle can't use the build tools for Visual Studio)
- On Linux, install GCC 11 or greater
- On Windows, install [Visual Studio Community 2022](https://visualstudio.microsoft.com/vs/community/) and select the C++ programming language during installation (Gradle can't use the build tools for Visual Studio)
- On macOS, install the Xcode command-line build tools via `xcode-select --install`
- ARM compiler toolchain
- Run `./gradlew installRoboRioToolchain` after cloning this repository

View File

@@ -34,8 +34,6 @@ popper.js wpinet/src/main/native/resources/popper-*
units wpimath/src/main/native/include/units/
Eigen wpimath/src/main/native/thirdparty/eigen/include/
StackWalker wpiutil/src/main/native/windows/StackWalker.*
TCB span wpiutil/src/main/native/thirdparty/include/wpi/span.h
wpiutil/src/test/native/cpp/span/
GHC filesystem wpiutil/src/main/native/thirdparty/include/wpi/ghc/
Team 254 Library wpilibj/src/main/java/edu/wpi/first/wpilibj/spline/SplineParameterizer.java
wpilibj/src/main/java/edu/wpi/first/wpilibj/trajectory/TrajectoryParameterizer.java

View File

@@ -5,5 +5,5 @@ repositories {
}
}
dependencies {
implementation "edu.wpi.first:native-utils:2023.2.4"
implementation "edu.wpi.first:native-utils:2023.2.7"
}

View File

@@ -381,7 +381,7 @@ Instance::Instance() {
// Listener for video events
m_videoListener = cs::VideoListener{
[=](const cs::VideoEvent& event) {
[=, this](const cs::VideoEvent& event) {
std::scoped_lock lock(m_mutex);
CS_Status status = 0;
switch (event.kind) {
@@ -511,7 +511,7 @@ cs::AxisCamera CameraServer::AddAxisCamera(const std::string& host) {
return AddAxisCamera("Axis Camera", host);
}
cs::AxisCamera CameraServer::AddAxisCamera(wpi::span<const std::string> hosts) {
cs::AxisCamera CameraServer::AddAxisCamera(std::span<const std::string> hosts) {
return AddAxisCamera("Axis Camera", hosts);
}
@@ -543,7 +543,7 @@ cs::AxisCamera CameraServer::AddAxisCamera(std::string_view name,
}
cs::AxisCamera CameraServer::AddAxisCamera(std::string_view name,
wpi::span<const std::string> hosts) {
std::span<const std::string> hosts) {
cs::AxisCamera camera{name, hosts};
StartAutomaticCapture(camera);
auto csShared = GetCameraServerShared();

View File

@@ -6,11 +6,10 @@
#include <stdint.h>
#include <span>
#include <string>
#include <string_view>
#include <wpi/span.h>
#include "cscore.h"
#include "cscore_cv.h"
@@ -110,7 +109,7 @@ class CameraServer {
*
* @param hosts Array of Camera host IPs/DNS names
*/
static cs::AxisCamera AddAxisCamera(wpi::span<const std::string> hosts);
static cs::AxisCamera AddAxisCamera(std::span<const std::string> hosts);
/**
* Adds an Axis IP camera.
@@ -155,7 +154,7 @@ class CameraServer {
* @param hosts Array of Camera host IPs/DNS names
*/
static cs::AxisCamera AddAxisCamera(std::string_view name,
wpi::span<const std::string> hosts);
std::span<const std::string> hosts);
/**
* Adds an Axis IP camera.

View File

@@ -88,7 +88,7 @@ int ConfigurableSourceImpl::CreateProperty(
}
void ConfigurableSourceImpl::SetEnumPropertyChoices(
int property, wpi::span<const std::string> choices, CS_Status* status) {
int property, std::span<const std::string> choices, CS_Status* status) {
std::scoped_lock lock(m_mutex);
auto prop = GetProperty(property);
if (!prop) {

View File

@@ -8,12 +8,11 @@
#include <atomic>
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <vector>
#include <wpi/span.h>
#include "SourceImpl.h"
namespace cs {
@@ -42,7 +41,7 @@ class ConfigurableSourceImpl : public SourceImpl {
int maximum, int step, int defaultValue, int value,
std::function<void(CS_Property property)> onChange);
void SetEnumPropertyChoices(int property,
wpi::span<const std::string> choices,
std::span<const std::string> choices,
CS_Status* status);
private:

View File

@@ -139,7 +139,7 @@ CS_Property CreateSourcePropertyCallback(
}
void SetSourceEnumPropertyChoices(CS_Source source, CS_Property property,
wpi::span<const std::string> choices,
std::span<const std::string> choices,
CS_Status* status) {
auto data = Instance::GetInstance().GetSource(source);
if (!data || (data->kind & SourceMask) == 0) {

View File

@@ -75,7 +75,7 @@ void HttpCameraImpl::MonitorThreadMain() {
std::unique_lock lock(m_mutex);
// sleep for 1 second between checks
m_monitorCond.wait_for(lock, std::chrono::seconds(1),
[=] { return !m_active; });
[=, this] { return !m_active; });
if (!m_active) {
break;
@@ -110,7 +110,8 @@ void HttpCameraImpl::StreamThreadMain() {
m_streamConn->stream->close();
}
// Wait for enable
m_sinkEnabledCond.wait(lock, [=] { return !m_active || IsEnabled(); });
m_sinkEnabledCond.wait(lock,
[=, this] { return !m_active || IsEnabled(); });
if (!m_active) {
return;
}
@@ -329,7 +330,7 @@ void HttpCameraImpl::SettingsThreadMain() {
wpi::HttpRequest req;
{
std::unique_lock lock(m_mutex);
m_settingsCond.wait(lock, [=] {
m_settingsCond.wait(lock, [=, this] {
return !m_active || (m_prefLocation != -1 && !m_settings.empty());
});
if (!m_active) {
@@ -378,7 +379,7 @@ CS_HttpCameraKind HttpCameraImpl::GetKind() const {
return m_kind;
}
bool HttpCameraImpl::SetUrls(wpi::span<const std::string> urls,
bool HttpCameraImpl::SetUrls(std::span<const std::string> urls,
CS_Status* status) {
std::vector<wpi::HttpLocation> locations;
for (const auto& url : urls) {
@@ -572,14 +573,14 @@ CS_Source CreateHttpCamera(std::string_view name, std::string_view url,
break;
}
std::string urlStr{url};
if (!source->SetUrls(wpi::span{&urlStr, 1}, status)) {
if (!source->SetUrls(std::span{&urlStr, 1}, status)) {
return 0;
}
return inst.CreateSource(CS_SOURCE_HTTP, source);
}
CS_Source CreateHttpCamera(std::string_view name,
wpi::span<const std::string> urls,
std::span<const std::string> urls,
CS_HttpCameraKind kind, CS_Status* status) {
auto& inst = Instance::GetInstance();
if (urls.empty()) {
@@ -603,7 +604,7 @@ CS_HttpCameraKind GetHttpCameraKind(CS_Source source, CS_Status* status) {
return static_cast<HttpCameraImpl&>(*data->source).GetKind();
}
void SetHttpCameraUrls(CS_Source source, wpi::span<const std::string> urls,
void SetHttpCameraUrls(CS_Source source, std::span<const std::string> urls,
CS_Status* status) {
if (urls.empty()) {
*status = CS_EMPTY_VALUE;

View File

@@ -9,6 +9,7 @@
#include <functional>
#include <initializer_list>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <thread>
@@ -18,7 +19,6 @@
#include <wpi/StringMap.h>
#include <wpi/condition_variable.h>
#include <wpi/raw_istream.h>
#include <wpi/span.h>
#include <wpinet/HttpUtil.h>
#include "SourceImpl.h"
@@ -55,7 +55,7 @@ class HttpCameraImpl : public SourceImpl {
void NumSinksEnabledChanged() override;
CS_HttpCameraKind GetKind() const;
bool SetUrls(wpi::span<const std::string> urls, CS_Status* status);
bool SetUrls(std::span<const std::string> urls, CS_Status* status);
std::vector<std::string> GetUrls() const;
// Property data

View File

@@ -86,16 +86,16 @@ class Instance {
void DestroySource(CS_Source handle);
void DestroySink(CS_Sink handle);
wpi::span<CS_Source> EnumerateSourceHandles(
std::span<CS_Source> EnumerateSourceHandles(
wpi::SmallVectorImpl<CS_Source>& vec) {
return m_sources.GetAll(vec);
}
wpi::span<CS_Sink> EnumerateSinkHandles(wpi::SmallVectorImpl<CS_Sink>& vec) {
std::span<CS_Sink> EnumerateSinkHandles(wpi::SmallVectorImpl<CS_Sink>& vec) {
return m_sinks.GetAll(vec);
}
wpi::span<CS_Sink> EnumerateSourceSinks(CS_Source source,
std::span<CS_Sink> EnumerateSourceSinks(CS_Source source,
wpi::SmallVectorImpl<CS_Sink>& vec) {
vec.clear();
m_sinks.ForEach([&](CS_Sink sinkHandle, const SinkData& data) {

View File

@@ -27,7 +27,7 @@ int PropertyContainer::GetPropertyIndex(std::string_view name) const {
return ndx;
}
wpi::span<int> PropertyContainer::EnumerateProperties(
std::span<int> PropertyContainer::EnumerateProperties(
wpi::SmallVectorImpl<int>& vec, CS_Status* status) const {
if (!m_properties_cached && !CacheProperties(status)) {
return {};

View File

@@ -8,13 +8,13 @@
#include <atomic>
#include <cstddef>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <vector>
#include <wpi/StringMap.h>
#include <wpi/mutex.h>
#include <wpi/span.h>
#include "PropertyImpl.h"
#include "cscore_cpp.h"
@@ -33,7 +33,7 @@ class PropertyContainer {
virtual ~PropertyContainer() = default;
int GetPropertyIndex(std::string_view name) const;
wpi::span<int> EnumerateProperties(wpi::SmallVectorImpl<int>& vec,
std::span<int> EnumerateProperties(wpi::SmallVectorImpl<int>& vec,
CS_Status* status) const;
CS_PropertyKind GetPropertyKind(int property) const;
std::string_view GetPropertyName(int property,

View File

@@ -76,7 +76,7 @@ Frame SourceImpl::GetCurFrame() {
Frame SourceImpl::GetNextFrame() {
std::unique_lock lock{m_frameMutex};
auto oldTime = m_frame.GetTime();
m_frameCv.wait(lock, [=] { return m_frame.GetTime() != oldTime; });
m_frameCv.wait(lock, [=, this] { return m_frame.GetTime() != oldTime; });
return m_frame;
}
@@ -85,7 +85,7 @@ Frame SourceImpl::GetNextFrame(double timeout) {
auto oldTime = m_frame.GetTime();
if (!m_frameCv.wait_for(
lock, std::chrono::milliseconds(static_cast<int>(timeout * 1000)),
[=] { return m_frame.GetTime() != oldTime; })) {
[=, this] { return m_frame.GetTime() != oldTime; })) {
m_frame = Frame{*this, "timed out getting frame", wpi::Now()};
}
return m_frame;

View File

@@ -6,12 +6,12 @@
#define CSCORE_UNLIMITEDHANDLERESOURCE_H_
#include <memory>
#include <span>
#include <utility>
#include <vector>
#include <wpi/SmallVector.h>
#include <wpi/mutex.h>
#include <wpi/span.h>
namespace cs {
@@ -50,7 +50,7 @@ class UnlimitedHandleResource {
std::shared_ptr<TStruct> Free(THandle handle);
template <typename T>
wpi::span<T> GetAll(wpi::SmallVectorImpl<T>& vec);
std::span<T> GetAll(wpi::SmallVectorImpl<T>& vec);
std::vector<std::shared_ptr<TStruct>> FreeAll();
@@ -151,7 +151,7 @@ UnlimitedHandleResource<THandle, TStruct, typeValue, TMutex>::Free(
template <typename THandle, typename TStruct, int typeValue, typename TMutex>
template <typename T>
inline wpi::span<T>
inline std::span<T>
UnlimitedHandleResource<THandle, TStruct, typeValue, TMutex>::GetAll(
wpi::SmallVectorImpl<T>& vec) {
ForEach([&](THandle handle, const TStruct& data) { vec.push_back(handle); });

View File

@@ -286,7 +286,7 @@ CS_Property GetSourceProperty(CS_Source source, std::string_view name,
return Handle{source, property, Handle::kProperty};
}
wpi::span<CS_Property> EnumerateSourceProperties(
std::span<CS_Property> EnumerateSourceProperties(
CS_Source source, wpi::SmallVectorImpl<CS_Property>& vec,
CS_Status* status) {
auto data = Instance::GetInstance().GetSource(source);
@@ -398,7 +398,7 @@ std::vector<VideoMode> EnumerateSourceVideoModes(CS_Source source,
return data->source->EnumerateVideoModes(status);
}
wpi::span<CS_Sink> EnumerateSourceSinks(CS_Source source,
std::span<CS_Sink> EnumerateSourceSinks(CS_Source source,
wpi::SmallVectorImpl<CS_Sink>& vec,
CS_Status* status) {
auto& inst = Instance::GetInstance();
@@ -583,7 +583,7 @@ CS_Property GetSinkProperty(CS_Sink sink, std::string_view name,
return Handle{sink, property, Handle::kSinkProperty};
}
wpi::span<CS_Property> EnumerateSinkProperties(
std::span<CS_Property> EnumerateSinkProperties(
CS_Sink sink, wpi::SmallVectorImpl<CS_Property>& vec, CS_Status* status) {
auto data = Instance::GetInstance().GetSink(sink);
if (!data) {
@@ -865,12 +865,12 @@ void Shutdown() {
// Utility Functions
//
wpi::span<CS_Source> EnumerateSourceHandles(
std::span<CS_Source> EnumerateSourceHandles(
wpi::SmallVectorImpl<CS_Source>& vec, CS_Status* status) {
return Instance::GetInstance().EnumerateSourceHandles(vec);
}
wpi::span<CS_Sink> EnumerateSinkHandles(wpi::SmallVectorImpl<CS_Sink>& vec,
std::span<CS_Sink> EnumerateSinkHandles(wpi::SmallVectorImpl<CS_Sink>& vec,
CS_Status* status) {
return Instance::GetInstance().EnumerateSinkHandles(vec);
}

View File

@@ -3,12 +3,12 @@
// the WPILib BSD license file in the root directory of this project.
#include <exception>
#include <span>
#include <fmt/format.h>
#include <opencv2/core/core.hpp>
#include <wpi/SmallString.h>
#include <wpi/jni_util.h>
#include <wpi/span.h>
#include "cscore_cpp.h"
#include "cscore_cv.h"
@@ -296,7 +296,7 @@ static jobject MakeJObject(JNIEnv* env, const cs::RawEvent& event) {
}
static jobjectArray MakeJObject(JNIEnv* env,
wpi::span<const cs::RawEvent> arr) {
std::span<const cs::RawEvent> arr) {
jobjectArray jarr = env->NewObjectArray(arr.size(), videoEventCls, nullptr);
if (!jarr) {
return nullptr;

View File

@@ -8,12 +8,12 @@
#include <stdint.h>
#include <functional>
#include <span>
#include <string>
#include <string_view>
#include <vector>
#include <wpi/SmallVector.h>
#include <wpi/span.h>
#include "cscore_c.h"
@@ -203,7 +203,7 @@ CS_Source CreateUsbCameraPath(std::string_view name, std::string_view path,
CS_Source CreateHttpCamera(std::string_view name, std::string_view url,
CS_HttpCameraKind kind, CS_Status* status);
CS_Source CreateHttpCamera(std::string_view name,
wpi::span<const std::string> urls,
std::span<const std::string> urls,
CS_HttpCameraKind kind, CS_Status* status);
CS_Source CreateCvSource(std::string_view name, const VideoMode& mode,
CS_Status* status);
@@ -230,7 +230,7 @@ bool IsSourceConnected(CS_Source source, CS_Status* status);
bool IsSourceEnabled(CS_Source source, CS_Status* status);
CS_Property GetSourceProperty(CS_Source source, std::string_view name,
CS_Status* status);
wpi::span<CS_Property> EnumerateSourceProperties(
std::span<CS_Property> EnumerateSourceProperties(
CS_Source source, wpi::SmallVectorImpl<CS_Property>& vec,
CS_Status* status);
VideoMode GetSourceVideoMode(CS_Source source, CS_Status* status);
@@ -249,7 +249,7 @@ std::string GetSourceConfigJson(CS_Source source, CS_Status* status);
wpi::json GetSourceConfigJsonObject(CS_Source source, CS_Status* status);
std::vector<VideoMode> EnumerateSourceVideoModes(CS_Source source,
CS_Status* status);
wpi::span<CS_Sink> EnumerateSourceSinks(CS_Source source,
std::span<CS_Sink> EnumerateSourceSinks(CS_Source source,
wpi::SmallVectorImpl<CS_Sink>& vec,
CS_Status* status);
CS_Source CopySource(CS_Source source, CS_Status* status);
@@ -285,7 +285,7 @@ UsbCameraInfo GetUsbCameraInfo(CS_Source source, CS_Status* status);
* @{
*/
CS_HttpCameraKind GetHttpCameraKind(CS_Source source, CS_Status* status);
void SetHttpCameraUrls(CS_Source source, wpi::span<const std::string> urls,
void SetHttpCameraUrls(CS_Source source, std::span<const std::string> urls,
CS_Status* status);
std::vector<std::string> GetHttpCameraUrls(CS_Source source, CS_Status* status);
/** @} */
@@ -304,7 +304,7 @@ CS_Property CreateSourceProperty(CS_Source source, std::string_view name,
int step, int defaultValue, int value,
CS_Status* status);
void SetSourceEnumPropertyChoices(CS_Source source, CS_Property property,
wpi::span<const std::string> choices,
std::span<const std::string> choices,
CS_Status* status);
/** @} */
@@ -335,7 +335,7 @@ std::string_view GetSinkDescription(CS_Sink sink,
CS_Status* status);
CS_Property GetSinkProperty(CS_Sink sink, std::string_view name,
CS_Status* status);
wpi::span<CS_Property> EnumerateSinkProperties(
std::span<CS_Property> EnumerateSinkProperties(
CS_Sink sink, wpi::SmallVectorImpl<CS_Property>& vec, CS_Status* status);
void SetSinkSource(CS_Sink sink, CS_Source source, CS_Status* status);
CS_Property GetSinkSourceProperty(CS_Sink sink, std::string_view name,
@@ -430,9 +430,9 @@ void Shutdown();
*/
std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status);
wpi::span<CS_Source> EnumerateSourceHandles(
std::span<CS_Source> EnumerateSourceHandles(
wpi::SmallVectorImpl<CS_Source>& vec, CS_Status* status);
wpi::span<CS_Sink> EnumerateSinkHandles(wpi::SmallVectorImpl<CS_Sink>& vec,
std::span<CS_Sink> EnumerateSinkHandles(wpi::SmallVectorImpl<CS_Sink>& vec,
CS_Status* status);
std::string GetHostname();

View File

@@ -6,13 +6,12 @@
#define CSCORE_CSCORE_OO_H_
#include <initializer_list>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <wpi/span.h>
#include "cscore_cpp.h"
namespace cs {
@@ -516,7 +515,7 @@ class HttpCamera : public VideoCamera {
* @param urls Array of Camera URLs
* @param kind Camera kind (e.g. kAxis)
*/
HttpCamera(std::string_view name, wpi::span<const std::string> urls,
HttpCamera(std::string_view name, std::span<const std::string> urls,
HttpCameraKind kind = kUnknown);
/**
@@ -541,7 +540,7 @@ class HttpCamera : public VideoCamera {
/**
* Change the URLs used to connect to the camera.
*/
void SetUrls(wpi::span<const std::string> urls);
void SetUrls(std::span<const std::string> urls);
/**
* Change the URLs used to connect to the camera.
@@ -560,7 +559,7 @@ class HttpCamera : public VideoCamera {
*/
class AxisCamera : public HttpCamera {
static std::string HostToUrl(std::string_view host);
static std::vector<std::string> HostToUrl(wpi::span<const std::string> hosts);
static std::vector<std::string> HostToUrl(std::span<const std::string> hosts);
template <typename T>
static std::vector<std::string> HostToUrl(std::initializer_list<T> hosts);
@@ -595,7 +594,7 @@ class AxisCamera : public HttpCamera {
* @param name Source name (arbitrary unique identifier)
* @param hosts Array of Camera host IPs/DNS names
*/
AxisCamera(std::string_view name, wpi::span<const std::string> hosts);
AxisCamera(std::string_view name, std::span<const std::string> hosts);
/**
* Create a source for an Axis IP camera.
@@ -696,7 +695,7 @@ class ImageSource : public VideoSource {
* @param choices Choices
*/
void SetEnumPropertyChoices(const VideoProperty& property,
wpi::span<const std::string> choices);
std::span<const std::string> choices);
/**
* Configure enum property choices.

View File

@@ -302,7 +302,7 @@ inline HttpCamera::HttpCamera(std::string_view name, const std::string& url,
: HttpCamera(name, std::string_view{url}, kind) {}
inline HttpCamera::HttpCamera(std::string_view name,
wpi::span<const std::string> urls,
std::span<const std::string> urls,
HttpCameraKind kind) {
m_handle = CreateHttpCamera(
name, urls, static_cast<CS_HttpCameraKind>(static_cast<int>(kind)),
@@ -329,7 +329,7 @@ inline HttpCamera::HttpCameraKind HttpCamera::GetHttpCameraKind() const {
static_cast<int>(::cs::GetHttpCameraKind(m_handle, &m_status)));
}
inline void HttpCamera::SetUrls(wpi::span<const std::string> urls) {
inline void HttpCamera::SetUrls(std::span<const std::string> urls) {
m_status = 0;
::cs::SetHttpCameraUrls(m_handle, urls, &m_status);
}
@@ -351,7 +351,7 @@ inline std::vector<std::string> HttpCamera::GetUrls() const {
}
inline std::vector<std::string> AxisCamera::HostToUrl(
wpi::span<const std::string> hosts) {
std::span<const std::string> hosts) {
std::vector<std::string> rv;
rv.reserve(hosts.size());
for (const auto& host : hosts) {
@@ -381,7 +381,7 @@ inline AxisCamera::AxisCamera(std::string_view name, const std::string& host)
: HttpCamera(name, HostToUrl(std::string_view{host}), kAxis) {}
inline AxisCamera::AxisCamera(std::string_view name,
wpi::span<const std::string> hosts)
std::span<const std::string> hosts)
: HttpCamera(name, HostToUrl(hosts), kAxis) {}
template <typename T>
@@ -452,7 +452,7 @@ inline VideoProperty ImageSource::CreateStringProperty(std::string_view name,
}
inline void ImageSource::SetEnumPropertyChoices(
const VideoProperty& property, wpi::span<const std::string> choices) {
const VideoProperty& property, std::span<const std::string> choices) {
m_status = 0;
SetSourceEnumPropertyChoices(m_handle, property.m_handle, choices, &m_status);
}

View File

@@ -20,7 +20,7 @@
class DataLogThread {
public:
explicit DataLogThread(wpi::log::DataLogReader reader)
: m_reader{std::move(reader)}, m_thread{[=] { ReadMain(); }} {}
: m_reader{std::move(reader)}, m_thread{[=, this] { ReadMain(); }} {}
~DataLogThread();
bool IsDone() const { return m_done; }

View File

@@ -107,7 +107,7 @@ static void RebuildEntryTree() {
// get to leaf
auto nodes = &gEntryTree;
for (auto part : wpi::drop_back(wpi::span{parts.begin(), parts.end()})) {
for (auto part : wpi::drop_back(std::span{parts.begin(), parts.end()})) {
auto it =
std::find_if(nodes->begin(), nodes->end(),
[&](const auto& node) { return node.name == part; });

View File

@@ -90,7 +90,7 @@ size_t File::AsyncRead(void* data, uint32_t len, AsyncId id) {
return rv;
}
size_t File::Write(wpi::span<const uint8_t> data) {
size_t File::Write(std::span<const uint8_t> data) {
auto rv = sftp_write(m_handle, data.data(), data.size());
if (rv < 0) {
throw Exception{m_handle->sftp};

View File

@@ -7,13 +7,12 @@
#include <libssh/libssh.h>
#include <libssh/sftp.h>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <vector>
#include <wpi/span.h>
namespace sftp {
struct Attributes {
@@ -53,7 +52,7 @@ class File {
size_t Read(void* buf, uint32_t count);
AsyncId AsyncReadBegin(uint32_t len) const;
size_t AsyncRead(void* data, uint32_t len, AsyncId id);
size_t Write(wpi::span<const uint8_t> data);
size_t Write(std::span<const uint8_t> data);
void Seek(uint64_t offset);
uint64_t Tell() const;

View File

@@ -57,7 +57,6 @@ doxygen {
if (project.hasProperty('docWarningsAsErrors')) {
// C++20 shims
exclude 'wpi/ghc/filesystem.hpp'
exclude 'wpi/span.h'
// Drake
exclude 'drake/common/**'

View File

@@ -29,7 +29,7 @@ add_library(fieldImages ${field_images_resources_src})
set_target_properties(fieldImages PROPERTIES DEBUG_POSTFIX "d")
set_property(TARGET fieldImages PROPERTY FOLDER "libraries")
target_compile_features(fieldImages PUBLIC cxx_std_17)
target_compile_features(fieldImages PUBLIC cxx_std_20)
if (MSVC)
target_compile_options(fieldImages PUBLIC /bigobj)
endif()

View File

@@ -254,7 +254,7 @@ Storage::Value& Storage::GetValue(std::string_view key) {
} \
\
std::vector<ArrCType>& Storage::Get##CapsName##Array( \
std::string_view key, wpi::span<const ArrCType> defaultVal) { \
std::string_view key, std::span<const ArrCType> defaultVal) { \
auto& valuePtr = m_values[key]; \
bool setValue = false; \
if (!valuePtr) { \

View File

@@ -10,7 +10,7 @@
#include <imgui.h>
#include <imgui_internal.h>
#include <wpi/numbers>
#include <numbers>
#include "glass/Context.h"
#include "glass/DataSource.h"
@@ -54,7 +54,7 @@ void glass::DisplayGyro(GyroModel* m) {
// Draw the spokes at every 5 degrees and a "major" spoke every 45 degrees.
for (int i = -175; i <= 180; i += 5) {
double radians = i * 2 * wpi::numbers::pi / 360.0;
double radians = i * 2 * std::numbers::pi / 360.0;
ImVec2 direction(std::sin(radians), -std::cos(radians));
bool major = i % 45 == 0;
@@ -74,7 +74,7 @@ void glass::DisplayGyro(GyroModel* m) {
draw->AddCircleFilled(center, radius * 0.075, secondaryColor, 50);
double radians = value * 2 * wpi::numbers::pi / 360.0;
double radians = value * 2 * std::numbers::pi / 360.0;
draw->AddLine(
center - ImVec2(1, 0),
center + ImVec2(std::sin(radians), -std::cos(radians)) * radius * 0.95f,

View File

@@ -11,7 +11,7 @@
#include <imgui.h>
#include <imgui_internal.h>
#include <wpi/numbers>
#include <numbers>
#include "glass/Context.h"
#include "glass/DataSource.h"
@@ -55,11 +55,11 @@ void glass::DisplayDrive(DriveModel* m) {
draw->AddTriangleFilled(
arrowPos,
arrowPos + ImRotate(ImVec2(0.0f, 7.5f),
std::cos(angle + wpi::numbers::pi / 4),
std::sin(angle + wpi::numbers::pi / 4)),
std::cos(angle + std::numbers::pi / 4),
std::sin(angle + std::numbers::pi / 4)),
arrowPos + ImRotate(ImVec2(0.0f, 7.5f),
std::cos(angle - wpi::numbers::pi / 4),
std::sin(angle - wpi::numbers::pi / 4)),
std::cos(angle - std::numbers::pi / 4),
std::sin(angle - std::numbers::pi / 4)),
color);
};
@@ -88,30 +88,30 @@ void glass::DisplayDrive(DriveModel* m) {
if (rotation != 0) {
float radius = 60.0f;
double a1 = 0.0;
double a2 = wpi::numbers::pi / 2 * rotation;
double a2 = std::numbers::pi / 2 * rotation;
// PathArcTo requires a_min <= a_max, and rotation can be negative
if (a1 > a2) {
draw->PathArcTo(center, radius, a2, a1, 20);
draw->PathStroke(color, false);
draw->PathArcTo(center, radius, a2 + wpi::numbers::pi,
a1 + wpi::numbers::pi, 20);
draw->PathArcTo(center, radius, a2 + std::numbers::pi,
a1 + std::numbers::pi, 20);
draw->PathStroke(color, false);
} else {
draw->PathArcTo(center, radius, a1, a2, 20);
draw->PathStroke(color, false);
draw->PathArcTo(center, radius, a1 + wpi::numbers::pi,
a2 + wpi::numbers::pi, 20);
draw->PathArcTo(center, radius, a1 + std::numbers::pi,
a2 + std::numbers::pi, 20);
draw->PathStroke(color, false);
}
double adder = rotation < 0 ? wpi::numbers::pi : 0;
double adder = rotation < 0 ? std::numbers::pi : 0;
auto arrowPos =
center + ImVec2(radius * -std::cos(a2), radius * -std::sin(a2));
drawArrow(arrowPos, a2 + adder);
a2 += wpi::numbers::pi;
a2 += std::numbers::pi;
arrowPos = center + ImVec2(radius * -std::cos(a2), radius * -std::sin(a2));
drawArrow(arrowPos, a2 + adder);
}

View File

@@ -93,7 +93,7 @@ class PopupState {
SelectedTargetInfo* GetTarget() { return &m_target; }
FieldObjectModel* GetInsertModel() { return m_insertModel; }
wpi::span<const frc::Pose2d> GetInsertPoses() const { return m_insertPoses; }
std::span<const frc::Pose2d> GetInsertPoses() const { return m_insertPoses; }
void Display(Field2DModel* model, const FieldFrameData& ffd);
@@ -189,7 +189,7 @@ class ObjectInfo {
DisplayOptions GetDisplayOptions() const;
void DisplaySettings();
void DrawLine(ImDrawList* drawList, wpi::span<const ImVec2> points) const;
void DrawLine(ImDrawList* drawList, std::span<const ImVec2> points) const;
void LoadImage();
const gui::Texture& GetTexture() const { return m_texture; }
@@ -617,7 +617,7 @@ void ObjectInfo::DisplaySettings() {
}
void ObjectInfo::DrawLine(ImDrawList* drawList,
wpi::span<const ImVec2> points) const {
std::span<const ImVec2> points) const {
if (points.empty()) {
return;
}

View File

@@ -8,6 +8,7 @@
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <utility>
@@ -15,7 +16,6 @@
#include <wpi/StringMap.h>
#include <wpi/iterator_range.h>
#include <wpi/span.h>
namespace wpi {
class json;
@@ -137,17 +137,17 @@ class Storage {
std::string_view defaultVal = {});
std::vector<int>& GetIntArray(std::string_view key,
wpi::span<const int> defaultVal = {});
std::span<const int> defaultVal = {});
std::vector<int64_t>& GetInt64Array(std::string_view key,
wpi::span<const int64_t> defaultVal = {});
std::span<const int64_t> defaultVal = {});
std::vector<int>& GetBoolArray(std::string_view key,
wpi::span<const int> defaultVal = {});
std::span<const int> defaultVal = {});
std::vector<float>& GetFloatArray(std::string_view key,
wpi::span<const float> defaultVal = {});
std::span<const float> defaultVal = {});
std::vector<double>& GetDoubleArray(std::string_view key,
wpi::span<const double> defaultVal = {});
std::span<const double> defaultVal = {});
std::vector<std::string>& GetStringArray(
std::string_view key, wpi::span<const std::string> defaultVal = {});
std::string_view key, std::span<const std::string> defaultVal = {});
std::vector<std::unique_ptr<Storage>>& GetChildArray(std::string_view key);
Value* FindValue(std::string_view key);

View File

@@ -4,8 +4,9 @@
#pragma once
#include <span>
#include <wpi/function_ref.h>
#include <wpi/span.h>
#include "glass/Model.h"
@@ -27,7 +28,7 @@ class LEDDisplayModel : public glass::Model {
virtual bool IsRunning() = 0;
virtual wpi::span<const Data> GetData(wpi::SmallVectorImpl<Data>& buf) = 0;
virtual std::span<const Data> GetData(wpi::SmallVectorImpl<Data>& buf) = 0;
};
class LEDDisplaysModel : public glass::Model {

View File

@@ -4,6 +4,7 @@
#pragma once
#include <span>
#include <string_view>
#include <frc/geometry/Pose2d.h>
@@ -11,7 +12,6 @@
#include <frc/geometry/Translation2d.h>
#include <imgui.h>
#include <wpi/function_ref.h>
#include <wpi/span.h>
#include "glass/Model.h"
#include "glass/View.h"
@@ -22,8 +22,8 @@ class FieldObjectModel : public Model {
public:
virtual const char* GetName() const = 0;
virtual wpi::span<const frc::Pose2d> GetPoses() = 0;
virtual void SetPoses(wpi::span<const frc::Pose2d> poses) = 0;
virtual std::span<const frc::Pose2d> GetPoses() = 0;
virtual void SetPoses(std::span<const frc::Pose2d> poses) = 0;
virtual void SetPose(size_t i, frc::Pose2d pose) = 0;
virtual void SetPosition(size_t i, frc::Translation2d pos) = 0;
virtual void SetRotation(size_t i, frc::Rotation2d rot) = 0;

View File

@@ -8,8 +8,6 @@
#include <string_view>
#include <vector>
#include <wpi/span.h>
#include "glass/Model.h"
namespace glass {

View File

@@ -32,8 +32,8 @@ class NTField2DModel::ObjectModel : public FieldObjectModel {
bool Exists() override { return m_topic.Exists(); }
bool IsReadOnly() override { return false; }
wpi::span<const frc::Pose2d> GetPoses() override { return m_poses; }
void SetPoses(wpi::span<const frc::Pose2d> poses) override;
std::span<const frc::Pose2d> GetPoses() override { return m_poses; }
void SetPoses(std::span<const frc::Pose2d> poses) override;
void SetPose(size_t i, frc::Pose2d pose) override;
void SetPosition(size_t i, frc::Translation2d pos) override;
void SetRotation(size_t i, frc::Rotation2d rot) override;
@@ -78,7 +78,7 @@ void NTField2DModel::ObjectModel::UpdateNT() {
m_pub.Set(arr);
}
void NTField2DModel::ObjectModel::SetPoses(wpi::span<const frc::Pose2d> poses) {
void NTField2DModel::ObjectModel::SetPoses(std::span<const frc::Pose2d> poses) {
m_poses.assign(poses.begin(), poses.end());
UpdateNT();
}

View File

@@ -9,6 +9,7 @@
#include <cstring>
#include <initializer_list>
#include <memory>
#include <span>
#include <string_view>
#include <vector>
@@ -25,7 +26,6 @@
#include <wpi/StringExtras.h>
#include <wpi/mpack.h>
#include <wpi/raw_ostream.h>
#include <wpi/span.h>
#include "glass/Context.h"
#include "glass/DataSource.h"
@@ -58,7 +58,7 @@ static bool IsVisible(ShowCategory category, bool persistent, bool retained) {
}
}
static std::string BooleanArrayToString(wpi::span<const int> in) {
static std::string BooleanArrayToString(std::span<const int> in) {
std::string rv;
wpi::raw_string_ostream os{rv};
os << '[';
@@ -78,17 +78,17 @@ static std::string BooleanArrayToString(wpi::span<const int> in) {
return rv;
}
static std::string IntegerArrayToString(wpi::span<const int64_t> in) {
static std::string IntegerArrayToString(std::span<const int64_t> in) {
return fmt::format("[{:d}]", fmt::join(in, ","));
}
template <typename T>
static std::string FloatArrayToString(wpi::span<const T> in) {
static std::string FloatArrayToString(std::span<const T> in) {
static_assert(std::is_same_v<T, float> || std::is_same_v<T, double>);
return fmt::format("[{:.6f}]", fmt::join(in, ","));
}
static std::string StringArrayToString(wpi::span<const std::string> in) {
static std::string StringArrayToString(std::span<const std::string> in) {
std::string rv;
wpi::raw_string_ostream os{rv};
os << '[';
@@ -528,7 +528,7 @@ void NetworkTablesModel::RebuildTreeImpl(std::vector<TreeNode>* tree,
// get to leaf
auto nodes = tree;
for (auto part : wpi::drop_back(wpi::span{parts.begin(), parts.end()})) {
for (auto part : wpi::drop_back(std::span{parts.begin(), parts.end()})) {
auto it =
std::find_if(nodes->begin(), nodes->end(),
[&](const auto& node) { return node.name == part; });
@@ -584,7 +584,7 @@ NetworkTablesModel::Entry* NetworkTablesModel::AddEntry(NT_Topic topic) {
}
void NetworkTablesModel::Client::UpdatePublishers(
wpi::span<const uint8_t> data) {
std::span<const uint8_t> data) {
mpack_reader_t r;
mpack_reader_init_data(&r, data);
uint32_t numPub = mpack_expect_array_max(&r, 1000);
@@ -639,7 +639,7 @@ static void DecodeSubscriberOptions(
}
void NetworkTablesModel::Client::UpdateSubscribers(
wpi::span<const uint8_t> data) {
std::span<const uint8_t> data) {
mpack_reader_t r;
mpack_reader_init_data(&r, data);
uint32_t numSub = mpack_expect_array_max(&r, 1000);
@@ -681,7 +681,7 @@ void NetworkTablesModel::Client::UpdateSubscribers(
}
}
void NetworkTablesModel::UpdateClients(wpi::span<const uint8_t> data) {
void NetworkTablesModel::UpdateClients(std::span<const uint8_t> data) {
mpack_reader_t r;
mpack_reader_init_data(&r, data);
uint32_t numClients = mpack_expect_array_max(&r, 100);

View File

@@ -7,6 +7,7 @@
#include <functional>
#include <map>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <utility>
@@ -143,8 +144,8 @@ class NetworkTablesModel : public Model {
std::vector<ClientPublisher> publishers;
std::vector<ClientSubscriber> subscribers;
void UpdatePublishers(wpi::span<const uint8_t> data);
void UpdateSubscribers(wpi::span<const uint8_t> data);
void UpdatePublishers(std::span<const uint8_t> data);
void UpdateSubscribers(std::span<const uint8_t> data);
};
NetworkTablesModel();
@@ -175,7 +176,7 @@ class NetworkTablesModel : public Model {
private:
void RebuildTree();
void RebuildTreeImpl(std::vector<TreeNode>* tree, int category);
void UpdateClients(wpi::span<const uint8_t> data);
void UpdateClients(std::span<const uint8_t> data);
nt::NetworkTableInstance m_inst;
NT_MultiSubscriber m_subscriber;

View File

@@ -23,5 +23,5 @@ add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
target_compile_features(gtest PUBLIC cxx_std_17)
target_compile_features(gtest_main PUBLIC cxx_std_17)
target_compile_features(gtest PUBLIC cxx_std_20)
target_compile_features(gtest_main PUBLIC cxx_std_20)

View File

@@ -257,7 +257,7 @@ Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_getData
std::make_unique<HAL_AddressableLEDData[]>(HAL_kAddressableLEDMaxLength);
int32_t length = HALSIM_GetAddressableLEDData(index, data.get());
return MakeJByteArray(
env, wpi::span(reinterpret_cast<jbyte*>(data.get()), length * 4));
env, std::span(reinterpret_cast<jbyte*>(data.get()), length * 4));
}
/*

View File

@@ -668,7 +668,7 @@ Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_getSimValueEnumDoubleValues
{
int32_t numElems = 0;
const double* elems = HALSIM_GetSimValueEnumDoubleValues(handle, &numElems);
return MakeJDoubleArray(env, wpi::span(elems, numElems));
return MakeJDoubleArray(env, std::span(elems, numElems));
}
/*

View File

@@ -59,7 +59,7 @@ int32_t SpiReadAutoReceiveBufferCallbackStore::performCallback(
}
auto toCallbackArr = MakeJIntArray(
env, wpi::span<const uint32_t>{buffer, static_cast<size_t>(numToRead)});
env, std::span<const uint32_t>{buffer, static_cast<size_t>(numToRead)});
jint ret = env->CallIntMethod(m_call, sim::GetBufferCallback(),
MakeJString(env, name), toCallbackArr,

View File

@@ -8,8 +8,7 @@
#ifdef __cplusplus
#include <initializer_list>
#include <wpi/span.h>
#include <span>
#endif
#include "hal/Types.h"
@@ -832,7 +831,7 @@ class SimDevice {
* @return simulated enum value object
*/
SimEnum CreateEnum(const char* name, int32_t direction,
wpi::span<const char* const> options,
std::span<const char* const> options,
int32_t initialValue) {
return HAL_CreateSimValueEnum(m_handle, name, direction, options.size(),
const_cast<const char**>(options.data()),
@@ -885,8 +884,8 @@ class SimDevice {
* @return simulated enum value object
*/
SimEnum CreateEnumDouble(const char* name, int32_t direction,
wpi::span<const char* const> options,
wpi::span<const double> optionValues,
std::span<const char* const> options,
std::span<const double> optionValues,
int32_t initialValue) {
if (options.size() != optionValues.size()) {
return {};

View File

@@ -18,6 +18,16 @@ namespace hal {
* outside of the UnsafeManipulateDIO callback.
*/
struct DIOSetProxy {
DIOSetProxy(tDIO::tOutputEnable setOutputDirReg,
tDIO::tOutputEnable unsetOutputDirReg,
tDIO::tDO setOutputStateReg, tDIO::tDO unsetOutputStateReg,
tDIO* dio)
: m_setOutputDirReg{setOutputDirReg},
m_unsetOutputDirReg{unsetOutputDirReg},
m_setOutputStateReg{setOutputStateReg},
m_unsetOutputStateReg{unsetOutputStateReg},
m_dio{dio} {}
DIOSetProxy(const DIOSetProxy&) = delete;
DIOSetProxy(DIOSetProxy&&) = delete;
DIOSetProxy& operator=(const DIOSetProxy&) = delete;

View File

@@ -71,4 +71,4 @@ target_link_libraries(imgui PUBLIC gl3w glfw)
target_include_directories(imgui PUBLIC "$<BUILD_INTERFACE:${imgui_srcdir}>" "$<BUILD_INTERFACE:${imgui_srcdir}/misc/cpp>" "$<BUILD_INTERFACE:${implot_srcdir}>" "$<BUILD_INTERFACE:${imgui_srcdir}/backends>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/stb-src>")
set_property(TARGET imgui PROPERTY POSITION_INDEPENDENT_CODE ON)
target_compile_features(imgui PUBLIC cxx_std_17)
target_compile_features(imgui PUBLIC cxx_std_20)

View File

@@ -28,7 +28,7 @@ target_include_directories(ntcore
$<BUILD_INTERFACE:${WPILIB_BINARY_DIR}/ntcore/generated/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/ntcore>)
wpilib_target_warnings(ntcore)
target_compile_features(ntcore PUBLIC cxx_std_17)
target_compile_features(ntcore PUBLIC cxx_std_20)
target_link_libraries(ntcore PUBLIC wpinet wpiutil)
set_property(TARGET ntcore PROPERTY FOLDER "libraries")

View File

@@ -74,7 +74,7 @@ static std::vector<int> FromJavaBooleanArray(JNIEnv* env, jbooleanArray jarr) {
if (!ref) {
return {};
}
wpi::span<const jboolean> elements{ref};
std::span<const jboolean> elements{ref};
size_t len = elements.size();
std::vector<int> arr;
arr.reserve(len);
@@ -118,7 +118,7 @@ static jobject MakeJObject(JNIEnv* env, nt::Timestamped{{ t.TypeName }} value) {
{% endfor %}
{%- for t in types %}
static jobjectArray MakeJObject(JNIEnv* env,
wpi::span<const nt::Timestamped{{ t.TypeName }}> arr) {
std::span<const nt::Timestamped{{ t.TypeName }}> arr) {
jobjectArray jarr =
env->NewObjectArray(arr.size(), timestamped{{ t.TypeName }}Cls, nullptr);
if (!jarr) {
@@ -133,7 +133,7 @@ static jobjectArray MakeJObject(JNIEnv* env,
{% endfor %}
{%- for t in types %}
{%- if t.jni.ToJavaArray == "MakeJObjectArray" %}
static jobjectArray MakeJObjectArray(JNIEnv* env, wpi::span<const {{ t.cpp.ValueType }}> arr) {
static jobjectArray MakeJObjectArray(JNIEnv* env, std::span<const {{ t.cpp.ValueType }}> arr) {
jobjectArray jarr =
env->NewObjectArray(arr.size(), {{ t.jni.jtype }}Cls, nullptr);
if (!jarr) {

View File

@@ -10,7 +10,7 @@
using namespace nt;
template <typename T>
static inline wpi::span<const T> ConvertFromC(const T* arr, size_t size) {
static inline std::span<const T> ConvertFromC(const T* arr, size_t size) {
return {arr, size};
}

View File

@@ -7,11 +7,10 @@
#include <stdint.h>
{{ cpp.INCLUDES }}
#include <span>
#include <string_view>
#include <vector>
#include <wpi/span.h>
#include "networktables/Topic.h"
namespace wpi {
@@ -312,7 +311,7 @@ class {{ TypeName }}Topic final : public Topic {
[[nodiscard]]
SubscriberType Subscribe(
{% if not TypeString %}std::string_view typeString, {% endif %}ParamType defaultValue,
wpi::span<const PubSubOption> options = {});
std::span<const PubSubOption> options = {});
{%- if TypeString %}
/**
* Create a new subscriber to the topic, with specific type string.
@@ -333,7 +332,7 @@ class {{ TypeName }}Topic final : public Topic {
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
wpi::span<const PubSubOption> options = {});
std::span<const PubSubOption> options = {});
{% endif %}
/**
* Create a new publisher to the topic.
@@ -354,7 +353,7 @@ class {{ TypeName }}Topic final : public Topic {
* @return publisher
*/
[[nodiscard]]
PublisherType Publish({% if not TypeString %}std::string_view typeString, {% endif %}wpi::span<const PubSubOption> options = {});
PublisherType Publish({% if not TypeString %}std::string_view typeString, {% endif %}std::span<const PubSubOption> options = {});
/**
* Create a new publisher to the topic, with type string and initial
@@ -376,7 +375,7 @@ class {{ TypeName }}Topic final : public Topic {
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, wpi::span<const PubSubOption> options = {});
const wpi::json& properties, std::span<const PubSubOption> options = {});
/**
* Create a new entry for the topic.
@@ -403,7 +402,7 @@ class {{ TypeName }}Topic final : public Topic {
*/
[[nodiscard]]
EntryType GetEntry({% if not TypeString %}std::string_view typeString, {% endif %}ParamType defaultValue,
wpi::span<const PubSubOption> options = {});
std::span<const PubSubOption> options = {});
{%- if TypeString %}
/**
* Create a new entry for the topic, with specific type string.
@@ -428,7 +427,7 @@ class {{ TypeName }}Topic final : public Topic {
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
wpi::span<const PubSubOption> options = {});
std::span<const PubSubOption> options = {});
{% endif %}
};

View File

@@ -89,7 +89,7 @@ inline void {{ TypeName }}Entry::Unpublish() {
inline {{ TypeName }}Subscriber {{ TypeName }}Topic::Subscribe(
{% if not TypeString %}std::string_view typeString, {% endif %}{{ cpp.ParamType }} defaultValue,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
return {{ TypeName }}Subscriber{
::nt::Subscribe(m_handle, NT_{{ cpp.TYPE_NAME }}, {{ TypeString|default('typeString') }}, options),
defaultValue};
@@ -97,28 +97,28 @@ inline {{ TypeName }}Subscriber {{ TypeName }}Topic::Subscribe(
{%- if TypeString %}
inline {{ TypeName }}Subscriber {{ TypeName }}Topic::SubscribeEx(
std::string_view typeString, {{ cpp.ParamType }} defaultValue,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
return {{ TypeName }}Subscriber{
::nt::Subscribe(m_handle, NT_{{ cpp.TYPE_NAME }}, typeString, options),
defaultValue};
}
{% endif %}
inline {{ TypeName }}Publisher {{ TypeName }}Topic::Publish(
{% if not TypeString %}std::string_view typeString, {% endif %}wpi::span<const PubSubOption> options) {
{% if not TypeString %}std::string_view typeString, {% endif %}std::span<const PubSubOption> options) {
return {{ TypeName }}Publisher{
::nt::Publish(m_handle, NT_{{ cpp.TYPE_NAME }}, {{ TypeString|default('typeString') }}, options)};
}
inline {{ TypeName }}Publisher {{ TypeName }}Topic::PublishEx(
std::string_view typeString,
const wpi::json& properties, wpi::span<const PubSubOption> options) {
const wpi::json& properties, std::span<const PubSubOption> options) {
return {{ TypeName }}Publisher{
::nt::PublishEx(m_handle, NT_{{ cpp.TYPE_NAME }}, typeString, properties, options)};
}
inline {{ TypeName }}Entry {{ TypeName }}Topic::GetEntry(
{% if not TypeString %}std::string_view typeString, {% endif %}{{ cpp.ParamType }} defaultValue,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
return {{ TypeName }}Entry{
::nt::GetEntry(m_handle, NT_{{ cpp.TYPE_NAME }}, {{ TypeString|default('typeString') }}, options),
defaultValue};
@@ -126,7 +126,7 @@ inline {{ TypeName }}Entry {{ TypeName }}Topic::GetEntry(
{%- if TypeString %}
inline {{ TypeName }}Entry {{ TypeName }}Topic::GetEntryEx(
std::string_view typeString, {{ cpp.ParamType }} defaultValue,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
return {{ TypeName }}Entry{
::nt::GetEntry(m_handle, NT_{{ cpp.TYPE_NAME }}, typeString, options),
defaultValue};

View File

@@ -6,13 +6,12 @@
#include <stdint.h>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <wpi/span.h>
#include "ntcore_c.h"
namespace wpi {

View File

@@ -167,11 +167,11 @@
},
"cpp": {
"ValueType": "std::vector<uint8_t>",
"ParamType": "wpi::span<const uint8_t>",
"ParamType": "std::span<const uint8_t>",
"DefaultValueCopy": "defaultValue.begin(), defaultValue.end()",
"TYPE_NAME": "RAW",
"INCLUDES": "#include <utility>",
"SmallRetType": "wpi::span<uint8_t>",
"SmallRetType": "std::span<uint8_t>",
"SmallElemType": "uint8_t"
},
"java": {
@@ -201,11 +201,11 @@
},
"cpp": {
"ValueType": "std::vector<int>",
"ParamType": "wpi::span<const int>",
"ParamType": "std::span<const int>",
"DefaultValueCopy": "defaultValue.begin(), defaultValue.end()",
"TYPE_NAME": "BOOLEAN_ARRAY",
"INCLUDES": "#include <utility>",
"SmallRetType": "wpi::span<int>",
"SmallRetType": "std::span<int>",
"SmallElemType": "int"
},
"java": {
@@ -236,11 +236,11 @@
},
"cpp": {
"ValueType": "std::vector<int64_t>",
"ParamType": "wpi::span<const int64_t>",
"ParamType": "std::span<const int64_t>",
"DefaultValueCopy": "defaultValue.begin(), defaultValue.end()",
"TYPE_NAME": "INTEGER_ARRAY",
"INCLUDES": "#include <utility>",
"SmallRetType": "wpi::span<int64_t>",
"SmallRetType": "std::span<int64_t>",
"SmallElemType": "int64_t"
},
"java": {
@@ -271,11 +271,11 @@
},
"cpp": {
"ValueType": "std::vector<float>",
"ParamType": "wpi::span<const float>",
"ParamType": "std::span<const float>",
"DefaultValueCopy": "defaultValue.begin(), defaultValue.end()",
"TYPE_NAME": "FLOAT_ARRAY",
"INCLUDES": "#include <utility>",
"SmallRetType": "wpi::span<float>",
"SmallRetType": "std::span<float>",
"SmallElemType": "float"
},
"java": {
@@ -306,11 +306,11 @@
},
"cpp": {
"ValueType": "std::vector<double>",
"ParamType": "wpi::span<const double>",
"ParamType": "std::span<const double>",
"DefaultValueCopy": "defaultValue.begin(), defaultValue.end()",
"TYPE_NAME": "DOUBLE_ARRAY",
"INCLUDES": "#include <utility>",
"SmallRetType": "wpi::span<double>",
"SmallRetType": "std::span<double>",
"SmallElemType": "double"
},
"java": {
@@ -341,7 +341,7 @@
},
"cpp": {
"ValueType": "std::vector<std::string>",
"ParamType": "wpi::span<const std::string>",
"ParamType": "std::span<const std::string>",
"DefaultValueCopy": "defaultValue.begin(), defaultValue.end()",
"TYPE_NAME": "STRING_ARRAY",
"INCLUDES": "#include <utility>"

View File

@@ -4,13 +4,12 @@
#pragma once
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <wpi/span.h>
#include "ntcore_cpp.h"
namespace nt {
@@ -20,7 +19,7 @@ class INetworkClient {
virtual ~INetworkClient() = default;
virtual void SetServers(
wpi::span<const std::pair<std::string, unsigned int>> servers) = 0;
std::span<const std::pair<std::string, unsigned int>> servers) = 0;
virtual void StartDSClient(unsigned int port) = 0;
virtual void StopDSClient() = 0;

View File

@@ -98,7 +98,7 @@ struct TopicData {
struct PubSubConfig : public PubSubOptions {
PubSubConfig() = default;
PubSubConfig(NT_Type type, std::string_view typeStr,
wpi::span<const PubSubOption> options)
std::span<const PubSubOption> options)
: PubSubOptions{options}, type{type}, typeStr{typeStr} {}
NT_Type type{NT_UNASSIGNED};
@@ -167,7 +167,7 @@ struct MultiSubscriberData {
static constexpr auto kType = Handle::kMultiSubscriber;
MultiSubscriberData(NT_MultiSubscriber handle,
wpi::span<const std::string_view> prefixes,
std::span<const std::string_view> prefixes,
PubSubOptions options)
: handle{handle}, options{std::move(options)} {
this->options.prefixMatch = true;
@@ -208,7 +208,7 @@ struct TopicListenerData {
eventMask{eventMask & ~NT_TOPIC_NOTIFY_IMMEDIATE} {}
TopicListenerData(NT_TopicListener handle, TopicListenerPollerData* poller,
MultiSubscriberData* multiSubscriber,
wpi::span<const std::string> prefixes,
std::span<const std::string> prefixes,
unsigned int eventMask)
: handle{handle},
poller{poller},
@@ -385,7 +385,7 @@ struct LSImpl {
std::unique_ptr<EntryData> RemoveEntry(NT_Entry entryHandle);
MultiSubscriberData* AddMultiSubscriber(
wpi::span<const std::string_view> prefixes, const PubSubOptions& options);
std::span<const std::string_view> prefixes, const PubSubOptions& options);
std::unique_ptr<MultiSubscriberData> RemoveMultiSubscriber(
NT_MultiSubscriber subHandle);
@@ -403,9 +403,9 @@ struct LSImpl {
unsigned int eventMask);
TopicListenerData* AddTopicListenerImpl(
TopicListenerPollerData* poller,
wpi::span<const std::string_view> prefixes, unsigned int eventMask);
std::span<const std::string_view> prefixes, unsigned int eventMask);
NT_TopicListener AddTopicListener(
wpi::span<const std::string_view> prefixes, unsigned int mask,
std::span<const std::string_view> prefixes, unsigned int mask,
std::function<void(const TopicNotification&)> callback);
NT_TopicListener AddTopicListenerHandle(TopicListenerPollerData* poller,
NT_Handle handle, unsigned int mask);
@@ -1053,7 +1053,7 @@ std::unique_ptr<EntryData> LSImpl::RemoveEntry(NT_Entry entryHandle) {
}
MultiSubscriberData* LSImpl::AddMultiSubscriber(
wpi::span<const std::string_view> prefixes, const PubSubOptions& options) {
std::span<const std::string_view> prefixes, const PubSubOptions& options) {
auto subscriber = m_multiSubscribers.Add(m_inst, prefixes, options);
// subscribe to any already existing topics
for (auto&& topic : m_topics) {
@@ -1158,7 +1158,7 @@ TopicListenerData* LSImpl::AddTopicListenerImpl(TopicListenerPollerData* poller,
}
TopicListenerData* LSImpl::AddTopicListenerImpl(
TopicListenerPollerData* poller, wpi::span<const std::string_view> prefixes,
TopicListenerPollerData* poller, std::span<const std::string_view> prefixes,
unsigned int eventMask) {
// subscribe to make sure topic updates are received
PubSubOptions options;
@@ -1171,7 +1171,7 @@ TopicListenerData* LSImpl::AddTopicListenerImpl(
}
NT_TopicListener LSImpl::AddTopicListener(
wpi::span<const std::string_view> prefixes, unsigned int mask,
std::span<const std::string_view> prefixes, unsigned int mask,
std::function<void(const TopicNotification&)> callback) {
if (!m_topicListenerThread) {
m_topicListenerThread.Start(AddTopicListenerPoller());
@@ -1640,7 +1640,7 @@ static void ForEachTopic(T& topics, std::string_view prefix, unsigned int types,
template <typename T, typename F>
static void ForEachTopic(T& topics, std::string_view prefix,
wpi::span<const std::string_view> types, F func) {
std::span<const std::string_view> types, F func) {
for (auto&& topic : topics) {
if (!topic->Exists()) {
continue;
@@ -1674,7 +1674,7 @@ std::vector<NT_Topic> LocalStorage::GetTopics(std::string_view prefix,
}
std::vector<NT_Topic> LocalStorage::GetTopics(
std::string_view prefix, wpi::span<const std::string_view> types) {
std::string_view prefix, std::span<const std::string_view> types) {
std::scoped_lock lock(m_mutex);
std::vector<NT_Topic> rv;
ForEachTopic(m_impl->m_topics, prefix, types,
@@ -1693,7 +1693,7 @@ std::vector<TopicInfo> LocalStorage::GetTopicInfo(std::string_view prefix,
}
std::vector<TopicInfo> LocalStorage::GetTopicInfo(
std::string_view prefix, wpi::span<const std::string_view> types) {
std::string_view prefix, std::span<const std::string_view> types) {
std::scoped_lock lock(m_mutex);
std::vector<TopicInfo> rv;
ForEachTopic(m_impl->m_topics, prefix, types, [&](TopicData& topic) {
@@ -1845,7 +1845,7 @@ TopicInfo LocalStorage::GetTopicInfo(NT_Topic topicHandle) {
NT_Subscriber LocalStorage::Subscribe(NT_Topic topicHandle, NT_Type type,
std::string_view typeStr,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
std::scoped_lock lock{m_mutex};
// Get the topic
@@ -1865,8 +1865,8 @@ void LocalStorage::Unsubscribe(NT_Subscriber subHandle) {
}
NT_MultiSubscriber LocalStorage::SubscribeMultiple(
wpi::span<const std::string_view> prefixes,
wpi::span<const PubSubOption> options) {
std::span<const std::string_view> prefixes,
std::span<const PubSubOption> options) {
std::scoped_lock lock{m_mutex};
PubSubOptions opts{options};
opts.prefixMatch = true;
@@ -1881,7 +1881,7 @@ void LocalStorage::UnsubscribeMultiple(NT_MultiSubscriber subHandle) {
NT_Publisher LocalStorage::Publish(NT_Topic topicHandle, NT_Type type,
std::string_view typeStr,
const wpi::json& properties,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
std::scoped_lock lock{m_mutex};
// Get the topic
@@ -1923,7 +1923,7 @@ void LocalStorage::Unpublish(NT_Handle pubentryHandle) {
NT_Entry LocalStorage::GetEntry(NT_Topic topicHandle, NT_Type type,
std::string_view typeStr,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
std::scoped_lock lock{m_mutex};
// Get the topic
@@ -2038,7 +2038,7 @@ static T GetAtomicNumber(Value* value, U defaultValue) {
}
template <typename T, typename U>
static T GetAtomicNumberArray(Value* value, wpi::span<const U> defaultValue) {
static T GetAtomicNumberArray(Value* value, std::span<const U> defaultValue) {
if (value && value->type() == NT_INTEGER_ARRAY) {
auto arr = value->GetIntegerArray();
return {value->time(), value->server_time(), {arr.begin(), arr.end()}};
@@ -2055,7 +2055,7 @@ static T GetAtomicNumberArray(Value* value, wpi::span<const U> defaultValue) {
template <typename T, typename U>
static T GetAtomicNumberArray(Value* value, wpi::SmallVectorImpl<U>& buf,
wpi::span<const U> defaultValue) {
std::span<const U> defaultValue) {
if (value && value->type() == NT_INTEGER_ARRAY) {
auto str = value->GetIntegerArray();
buf.assign(str.begin(), str.end());
@@ -2083,7 +2083,7 @@ static T GetAtomicNumberArray(Value* value, wpi::SmallVectorImpl<U>& buf,
} \
\
Timestamped##Name##Array LocalStorage::GetAtomic##Name##Array( \
NT_Handle subentry, wpi::span<const dtype> defaultValue) { \
NT_Handle subentry, std::span<const dtype> defaultValue) { \
std::scoped_lock lock{m_mutex}; \
return GetAtomicNumberArray<Timestamped##Name##Array>( \
m_impl->GetSubEntryValue(subentry), defaultValue); \
@@ -2091,7 +2091,7 @@ static T GetAtomicNumberArray(Value* value, wpi::SmallVectorImpl<U>& buf,
\
Timestamped##Name##ArrayView LocalStorage::GetAtomic##Name##Array( \
NT_Handle subentry, wpi::SmallVectorImpl<dtype>& buf, \
wpi::span<const dtype> defaultValue) { \
std::span<const dtype> defaultValue) { \
std::scoped_lock lock{m_mutex}; \
return GetAtomicNumberArray<Timestamped##Name##ArrayView>( \
m_impl->GetSubEntryValue(subentry), buf, defaultValue); \
@@ -2103,7 +2103,7 @@ GET_ATOMIC_NUMBER(Double, double)
#define GET_ATOMIC_ARRAY(Name, dtype) \
Timestamped##Name LocalStorage::GetAtomic##Name( \
NT_Handle subentry, wpi::span<const dtype> defaultValue) { \
NT_Handle subentry, std::span<const dtype> defaultValue) { \
std::scoped_lock lock{m_mutex}; \
Value* value = m_impl->GetSubEntryValue(subentry); \
if (value && value->Is##Name()) { \
@@ -2121,7 +2121,7 @@ GET_ATOMIC_ARRAY(StringArray, std::string)
#define GET_ATOMIC_SMALL_ARRAY(Name, dtype) \
Timestamped##Name##View LocalStorage::GetAtomic##Name( \
NT_Handle subentry, wpi::SmallVectorImpl<dtype>& buf, \
wpi::span<const dtype> defaultValue) { \
std::span<const dtype> defaultValue) { \
std::scoped_lock lock{m_mutex}; \
Value* value = m_impl->GetSubEntryValue(subentry); \
if (value && value->Is##Name()) { \
@@ -2349,7 +2349,7 @@ int64_t LocalStorage::GetEntryLastChange(NT_Handle subentryHandle) {
}
NT_TopicListener LocalStorage::AddTopicListener(
wpi::span<const std::string_view> prefixes, unsigned int mask,
std::span<const std::string_view> prefixes, unsigned int mask,
std::function<void(const TopicNotification&)> callback) {
std::scoped_lock lock{m_mutex};
return m_impl->AddTopicListener(prefixes, mask, std::move(callback));
@@ -2375,7 +2375,7 @@ void LocalStorage::DestroyTopicListenerPoller(
NT_TopicListener LocalStorage::AddPolledTopicListener(
NT_TopicListenerPoller pollerHandle,
wpi::span<const std::string_view> prefixes, unsigned int mask) {
std::span<const std::string_view> prefixes, unsigned int mask) {
std::scoped_lock lock{m_mutex};
if (auto poller = m_impl->m_topicListenerPollers.Get(pollerHandle)) {
return m_impl->AddTopicListenerImpl(poller, prefixes, mask)->handle;

View File

@@ -8,13 +8,13 @@
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <wpi/mutex.h>
#include <wpi/span.h>
#include "net/NetworkInterface.h"
#include "ntcore_cpp.h"
@@ -50,12 +50,12 @@ class LocalStorage final : public net::ILocalStorage {
std::vector<NT_Topic> GetTopics(std::string_view prefix, unsigned int types);
std::vector<NT_Topic> GetTopics(std::string_view prefix,
wpi::span<const std::string_view> types);
std::span<const std::string_view> types);
std::vector<TopicInfo> GetTopicInfo(std::string_view prefix,
unsigned int types);
std::vector<TopicInfo> GetTopicInfo(std::string_view prefix,
wpi::span<const std::string_view> types);
std::span<const std::string_view> types);
NT_Topic GetTopic(std::string_view name);
@@ -90,24 +90,24 @@ class LocalStorage final : public net::ILocalStorage {
NT_Subscriber Subscribe(NT_Topic topic, NT_Type type,
std::string_view typeStr,
wpi::span<const PubSubOption> options);
std::span<const PubSubOption> options);
void Unsubscribe(NT_Subscriber sub);
NT_MultiSubscriber SubscribeMultiple(
wpi::span<const std::string_view> prefixes,
wpi::span<const PubSubOption> options);
std::span<const std::string_view> prefixes,
std::span<const PubSubOption> options);
void UnsubscribeMultiple(NT_MultiSubscriber subHandle);
NT_Publisher Publish(NT_Topic topic, NT_Type type, std::string_view typeStr,
const wpi::json& properties,
wpi::span<const PubSubOption> options);
std::span<const PubSubOption> options);
void Unpublish(NT_Handle pubentry);
NT_Entry GetEntry(NT_Topic topic, NT_Type type, std::string_view typeStr,
wpi::span<const PubSubOption> options);
std::span<const PubSubOption> options);
void ReleaseEntry(NT_Entry entry);
@@ -126,36 +126,36 @@ class LocalStorage final : public net::ILocalStorage {
TimestampedString GetAtomicString(NT_Handle subentry,
std::string_view defaultValue);
TimestampedRaw GetAtomicRaw(NT_Handle subentry,
wpi::span<const uint8_t> defaultValue);
std::span<const uint8_t> defaultValue);
TimestampedBooleanArray GetAtomicBooleanArray(
NT_Handle subentry, wpi::span<const int> defaultValue);
NT_Handle subentry, std::span<const int> defaultValue);
TimestampedIntegerArray GetAtomicIntegerArray(
NT_Handle subentry, wpi::span<const int64_t> defaultValue);
NT_Handle subentry, std::span<const int64_t> defaultValue);
TimestampedFloatArray GetAtomicFloatArray(
NT_Handle subentry, wpi::span<const float> defaultValue);
NT_Handle subentry, std::span<const float> defaultValue);
TimestampedDoubleArray GetAtomicDoubleArray(
NT_Handle subentry, wpi::span<const double> defaultValue);
NT_Handle subentry, std::span<const double> defaultValue);
TimestampedStringArray GetAtomicStringArray(
NT_Handle subentry, wpi::span<const std::string> defaultValue);
NT_Handle subentry, std::span<const std::string> defaultValue);
TimestampedStringView GetAtomicString(NT_Handle subentry,
wpi::SmallVectorImpl<char>& buf,
std::string_view defaultValue);
TimestampedRawView GetAtomicRaw(NT_Handle subentry,
wpi::SmallVectorImpl<uint8_t>& buf,
wpi::span<const uint8_t> defaultValue);
std::span<const uint8_t> defaultValue);
TimestampedBooleanArrayView GetAtomicBooleanArray(
NT_Handle subentry, wpi::SmallVectorImpl<int>& buf,
wpi::span<const int> defaultValue);
std::span<const int> defaultValue);
TimestampedIntegerArrayView GetAtomicIntegerArray(
NT_Handle subentry, wpi::SmallVectorImpl<int64_t>& buf,
wpi::span<const int64_t> defaultValue);
std::span<const int64_t> defaultValue);
TimestampedFloatArrayView GetAtomicFloatArray(
NT_Handle subentry, wpi::SmallVectorImpl<float>& buf,
wpi::span<const float> defaultValue);
std::span<const float> defaultValue);
TimestampedDoubleArrayView GetAtomicDoubleArray(
NT_Handle subentry, wpi::SmallVectorImpl<double>& buf,
wpi::span<const double> defaultValue);
std::span<const double> defaultValue);
std::vector<Value> ReadQueueValue(NT_Handle subentry);
@@ -193,7 +193,7 @@ class LocalStorage final : public net::ILocalStorage {
//
NT_TopicListener AddTopicListener(
wpi::span<const std::string_view> prefixes, unsigned int mask,
std::span<const std::string_view> prefixes, unsigned int mask,
std::function<void(const TopicNotification&)> callback);
NT_TopicListener AddTopicListener(
NT_Handle handle, unsigned int mask,
@@ -203,7 +203,7 @@ class LocalStorage final : public net::ILocalStorage {
void DestroyTopicListenerPoller(NT_TopicListenerPoller poller);
NT_TopicListener AddPolledTopicListener(
NT_TopicListenerPoller poller, wpi::span<const std::string_view> prefixes,
NT_TopicListenerPoller poller, std::span<const std::string_view> prefixes,
unsigned int mask);
NT_TopicListener AddPolledTopicListener(NT_TopicListenerPoller poller,
NT_Handle handle, unsigned int mask);

View File

@@ -48,7 +48,7 @@ class NCImpl {
virtual ~NCImpl() = default;
// user-facing functions
void SetServers(wpi::span<const std::pair<std::string, unsigned int>> servers,
void SetServers(std::span<const std::pair<std::string, unsigned int>> servers,
unsigned int defaultPort);
void StartDSClient(unsigned int port);
void StopDSClient();
@@ -135,7 +135,7 @@ NCImpl::NCImpl(int inst, std::string_view id, net::ILocalStorage& localStorage,
}
void NCImpl::SetServers(
wpi::span<const std::pair<std::string, unsigned int>> servers,
std::span<const std::pair<std::string, unsigned int>> servers,
unsigned int defaultPort) {
std::vector<std::pair<std::string, unsigned int>> serversCopy;
serversCopy.reserve(servers.size());
@@ -154,7 +154,7 @@ void NCImpl::SetServers(
}
void NCImpl::StartDSClient(unsigned int port) {
m_loopRunner.ExecAsync([=](uv::Loop& loop) {
m_loopRunner.ExecAsync([=, this](uv::Loop& loop) {
if (m_dsClient) {
return;
}
@@ -432,7 +432,7 @@ void NCImpl4::WsConnected(wpi::WebSocket& ws, uv::Tcp& tcp) {
ws.text.connect([this](std::string_view data, bool) {
m_clientImpl->ProcessIncomingText(data);
});
ws.binary.connect([this](wpi::span<const uint8_t> data, bool) {
ws.binary.connect([this](std::span<const uint8_t> data, bool) {
m_clientImpl->ProcessIncomingBinary(data);
});
}
@@ -463,7 +463,7 @@ NetworkClient::~NetworkClient() {
}
void NetworkClient::SetServers(
wpi::span<const std::pair<std::string, unsigned int>> servers) {
std::span<const std::pair<std::string, unsigned int>> servers) {
m_impl->SetServers(servers, NT_DEFAULT_PORT4);
}
@@ -505,7 +505,7 @@ NetworkClient3::~NetworkClient3() {
}
void NetworkClient3::SetServers(
wpi::span<const std::pair<std::string, unsigned int>> servers) {
std::span<const std::pair<std::string, unsigned int>> servers) {
m_impl->SetServers(servers, NT_DEFAULT_PORT3);
}

View File

@@ -5,6 +5,7 @@
#pragma once
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <utility>
@@ -31,7 +32,7 @@ class NetworkClient final : public INetworkClient {
~NetworkClient() final;
void SetServers(
wpi::span<const std::pair<std::string, unsigned int>> servers) final;
std::span<const std::pair<std::string, unsigned int>> servers) final;
void StartDSClient(unsigned int port) final;
void StopDSClient() final;
@@ -52,7 +53,7 @@ class NetworkClient3 final : public INetworkClient {
~NetworkClient3() final;
void SetServers(
wpi::span<const std::pair<std::string, unsigned int>> servers) final;
std::span<const std::pair<std::string, unsigned int>> servers) final;
void StartDSClient(unsigned int port) final;
void StopDSClient() final;

View File

@@ -7,6 +7,7 @@
#include <stdint.h>
#include <atomic>
#include <span>
#include <system_error>
#include <vector>
@@ -256,7 +257,7 @@ void ServerConnection4::ProcessWsUpgrade() {
m_websocket->text.connect([this](std::string_view data, bool) {
m_server.m_serverImpl.ProcessIncomingText(m_clientId, data);
});
m_websocket->binary.connect([this](wpi::span<const uint8_t> data, bool) {
m_websocket->binary.connect([this](std::span<const uint8_t> data, bool) {
m_server.m_serverImpl.ProcessIncomingBinary(m_clientId, data);
});
@@ -327,7 +328,7 @@ NSImpl::NSImpl(std::string_view persistentFilename,
m_localQueue{logger},
m_loop(*m_loopRunner.GetLoop()) {
m_localMsgs.reserve(net::NetworkLoopQueue::kInitialQueueSize);
m_loopRunner.ExecAsync([=](uv::Loop& loop) {
m_loopRunner.ExecAsync([=, this](uv::Loop& loop) {
// connect local storage to server
{
net::ServerStartup startup{m_serverImpl};

View File

@@ -8,7 +8,7 @@
using namespace nt;
nt::PubSubOptions::PubSubOptions(wpi::span<const PubSubOption> options) {
nt::PubSubOptions::PubSubOptions(std::span<const PubSubOption> options) {
for (auto&& option : options) {
switch (option.type) {
case NT_PUBSUB_PERIODIC:

View File

@@ -4,7 +4,7 @@
#pragma once
#include <wpi/span.h>
#include <span>
#include "ntcore_cpp.h"
@@ -14,7 +14,7 @@ namespace nt {
class PubSubOptions {
public:
PubSubOptions() = default;
explicit PubSubOptions(wpi::span<const PubSubOption> options);
explicit PubSubOptions(std::span<const PubSubOption> options);
double periodic = 0.1;
size_t pollStorageSize = 1;

View File

@@ -5,6 +5,7 @@
#include <stdint.h>
#include <cstring>
#include <span>
#include <wpi/MemAlloc.h>
#include <wpi/timestamp.h>
@@ -17,7 +18,7 @@ using namespace nt;
namespace {
struct StringArrayStorage {
explicit StringArrayStorage(wpi::span<const std::string> value)
explicit StringArrayStorage(std::span<const std::string> value)
: strings{value.begin(), value.end()} {
InitNtStrings();
}
@@ -68,7 +69,7 @@ Value::Value(NT_Type type, int64_t time, int64_t serverTime,
}
}
Value Value::MakeBooleanArray(wpi::span<const bool> value, int64_t time) {
Value Value::MakeBooleanArray(std::span<const bool> value, int64_t time) {
Value val{NT_BOOLEAN_ARRAY, time, private_init{}};
auto data = std::make_shared<std::vector<int>>(value.begin(), value.end());
// data->reserve(value.size());
@@ -79,7 +80,7 @@ Value Value::MakeBooleanArray(wpi::span<const bool> value, int64_t time) {
return val;
}
Value Value::MakeBooleanArray(wpi::span<const int> value, int64_t time) {
Value Value::MakeBooleanArray(std::span<const int> value, int64_t time) {
Value val{NT_BOOLEAN_ARRAY, time, private_init{}};
auto data = std::make_shared<std::vector<int>>(value.begin(), value.end());
val.m_val.data.arr_boolean.arr = data->data();
@@ -88,7 +89,7 @@ Value Value::MakeBooleanArray(wpi::span<const int> value, int64_t time) {
return val;
}
Value Value::MakeIntegerArray(wpi::span<const int64_t> value, int64_t time) {
Value Value::MakeIntegerArray(std::span<const int64_t> value, int64_t time) {
Value val{NT_INTEGER_ARRAY, time, private_init{}};
auto data =
std::make_shared<std::vector<int64_t>>(value.begin(), value.end());
@@ -98,7 +99,7 @@ Value Value::MakeIntegerArray(wpi::span<const int64_t> value, int64_t time) {
return val;
}
Value Value::MakeFloatArray(wpi::span<const float> value, int64_t time) {
Value Value::MakeFloatArray(std::span<const float> value, int64_t time) {
Value val{NT_FLOAT_ARRAY, time, private_init{}};
auto data = std::make_shared<std::vector<float>>(value.begin(), value.end());
val.m_val.data.arr_float.arr = data->data();
@@ -107,7 +108,7 @@ Value Value::MakeFloatArray(wpi::span<const float> value, int64_t time) {
return val;
}
Value Value::MakeDoubleArray(wpi::span<const double> value, int64_t time) {
Value Value::MakeDoubleArray(std::span<const double> value, int64_t time) {
Value val{NT_DOUBLE_ARRAY, time, private_init{}};
auto data = std::make_shared<std::vector<double>>(value.begin(), value.end());
val.m_val.data.arr_double.arr = data->data();
@@ -116,7 +117,7 @@ Value Value::MakeDoubleArray(wpi::span<const double> value, int64_t time) {
return val;
}
Value Value::MakeStringArray(wpi::span<const std::string> value, int64_t time) {
Value Value::MakeStringArray(std::span<const std::string> value, int64_t time) {
Value val{NT_STRING_ARRAY, time, private_init{}};
auto data = std::make_shared<StringArrayStorage>(value);
val.m_val.data.arr_string.arr = data->ntStrings.data();
@@ -226,19 +227,19 @@ Value nt::ConvertFromC(const NT_Value& value) {
value.last_change);
case NT_BOOLEAN_ARRAY:
return Value::MakeBooleanArray(
wpi::span(value.data.arr_boolean.arr, value.data.arr_boolean.size),
std::span(value.data.arr_boolean.arr, value.data.arr_boolean.size),
value.last_change);
case NT_INTEGER_ARRAY:
return Value::MakeIntegerArray(
wpi::span(value.data.arr_int.arr, value.data.arr_int.size),
std::span(value.data.arr_int.arr, value.data.arr_int.size),
value.last_change);
case NT_FLOAT_ARRAY:
return Value::MakeFloatArray(
wpi::span(value.data.arr_float.arr, value.data.arr_float.size),
std::span(value.data.arr_float.arr, value.data.arr_float.size),
value.last_change);
case NT_DOUBLE_ARRAY:
return Value::MakeDoubleArray(
wpi::span(value.data.arr_double.arr, value.data.arr_double.size),
std::span(value.data.arr_double.arr, value.data.arr_double.size),
value.last_change);
case NT_STRING_ARRAY: {
std::vector<std::string> v;

View File

@@ -120,7 +120,7 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) {
// Conversions from Java objects to C++
//
static wpi::span<const nt::PubSubOption> FromJavaPubSubOptions(
static std::span<const nt::PubSubOption> FromJavaPubSubOptions(
JNIEnv* env, jintArray optionTypes, jdoubleArray optionValues,
wpi::SmallVectorImpl<nt::PubSubOption>& arr) {
JIntArrayRef types{env, optionTypes};
@@ -281,7 +281,7 @@ static jobject MakeJObject(JNIEnv* env, jobject inst,
static_cast<jint>(notification.flags));
}
static jobjectArray MakeJObject(JNIEnv* env, wpi::span<const nt::Value> arr) {
static jobjectArray MakeJObject(JNIEnv* env, std::span<const nt::Value> arr) {
jobjectArray jarr = env->NewObjectArray(arr.size(), valueCls, nullptr);
if (!jarr) {
return nullptr;
@@ -295,7 +295,7 @@ static jobjectArray MakeJObject(JNIEnv* env, wpi::span<const nt::Value> arr) {
static jobjectArray MakeJObject(
JNIEnv* env, jobject inst,
wpi::span<const nt::ConnectionNotification> arr) {
std::span<const nt::ConnectionNotification> arr) {
jobjectArray jarr =
env->NewObjectArray(arr.size(), connectionNotificationCls, nullptr);
if (!jarr) {
@@ -309,7 +309,7 @@ static jobjectArray MakeJObject(
}
static jobjectArray MakeJObject(JNIEnv* env, jobject inst,
wpi::span<const nt::LogMessage> arr) {
std::span<const nt::LogMessage> arr) {
jobjectArray jarr = env->NewObjectArray(arr.size(), logMessageCls, nullptr);
if (!jarr) {
return nullptr;
@@ -322,7 +322,7 @@ static jobjectArray MakeJObject(JNIEnv* env, jobject inst,
}
static jobjectArray MakeJObject(JNIEnv* env, jobject inst,
wpi::span<const nt::TopicNotification> arr) {
std::span<const nt::TopicNotification> arr) {
jobjectArray jarr =
env->NewObjectArray(arr.size(), topicNotificationCls, nullptr);
if (!jarr) {
@@ -336,7 +336,7 @@ static jobjectArray MakeJObject(JNIEnv* env, jobject inst,
}
static jobjectArray MakeJObject(JNIEnv* env, jobject inst,
wpi::span<const nt::ValueNotification> arr) {
std::span<const nt::ValueNotification> arr) {
jobjectArray jarr =
env->NewObjectArray(arr.size(), valueNotificationCls, nullptr);
if (!jarr) {

View File

@@ -52,9 +52,9 @@ class CImpl : public ServerMessageHandler {
CImpl(uint64_t curTimeMs, int inst, WireConnection& wire, wpi::Logger& logger,
std::function<void(uint32_t repeatMs)> setPeriodic);
void ProcessIncomingBinary(wpi::span<const uint8_t> data);
void ProcessIncomingBinary(std::span<const uint8_t> data);
void HandleLocal(std::vector<ClientMessage>&& msgs);
void SendOutgoing(wpi::span<const ClientMessage> msgs);
void SendOutgoing(std::span<const ClientMessage> msgs);
bool SendControl(uint64_t curTimeMs);
void SendValues(uint64_t curTimeMs);
bool CheckNetworkReady();
@@ -120,7 +120,7 @@ CImpl::CImpl(uint64_t curTimeMs, int inst, WireConnection& wire,
m_setPeriodic(m_periodMs);
}
void CImpl::ProcessIncomingBinary(wpi::span<const uint8_t> data) {
void CImpl::ProcessIncomingBinary(std::span<const uint8_t> data) {
for (;;) {
if (data.empty()) {
break;
@@ -419,7 +419,7 @@ void ClientImpl::ProcessIncomingText(std::string_view data) {
WireDecodeText(data, *m_impl, m_impl->m_logger);
}
void ClientImpl::ProcessIncomingBinary(wpi::span<const uint8_t> data) {
void ClientImpl::ProcessIncomingBinary(std::span<const uint8_t> data) {
m_impl->ProcessIncomingBinary(data);
}
@@ -463,7 +463,7 @@ void ClientStartup::Publish(NT_Publisher pubHandle, NT_Topic topicHandle,
}
void ClientStartup::Subscribe(NT_Subscriber subHandle,
wpi::span<const std::string> prefixes,
std::span<const std::string> prefixes,
const PubSubOptions& options) {
WPI_DEBUG4(m_client.m_impl->m_logger, "StartupSubscribe({})", subHandle);
WireEncodeSubscribe(m_textWriter.Add(), Handle{subHandle}.GetIndex(),

View File

@@ -8,12 +8,11 @@
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <vector>
#include <wpi/span.h>
#include "NetworkInterface.h"
#include "WireConnection.h"
@@ -42,7 +41,7 @@ class ClientImpl {
~ClientImpl();
void ProcessIncomingText(std::string_view data);
void ProcessIncomingBinary(wpi::span<const uint8_t> data);
void ProcessIncomingBinary(std::span<const uint8_t> data);
void HandleLocal(std::vector<ClientMessage>&& msgs);
void SendControl(uint64_t curTimeMs);
@@ -66,7 +65,7 @@ class ClientStartup final : public NetworkStartupInterface {
void Publish(NT_Publisher pubHandle, NT_Topic topicHandle,
std::string_view name, std::string_view typeStr,
const wpi::json& properties, const PubSubOptions& options) final;
void Subscribe(NT_Subscriber subHandle, wpi::span<const std::string> prefixes,
void Subscribe(NT_Subscriber subHandle, std::span<const std::string> prefixes,
const PubSubOptions& options) final;
void SetValue(NT_Publisher pubHandle, const Value& value) final;

View File

@@ -4,11 +4,10 @@
#pragma once
#include <span>
#include <string>
#include <string_view>
#include <wpi/span.h>
#include "ntcore_cpp.h"
namespace wpi {
@@ -45,7 +44,7 @@ class NetworkStartupInterface {
const wpi::json& properties,
const PubSubOptions& options) = 0;
virtual void Subscribe(NT_Subscriber subHandle,
wpi::span<const std::string> topicNames,
std::span<const std::string> topicNames,
const PubSubOptions& options) = 0;
virtual void SetValue(NT_Publisher pubHandle, const Value& value) = 0;
};

View File

@@ -4,6 +4,7 @@
#pragma once
#include <span>
#include <string>
#include <vector>
@@ -37,7 +38,7 @@ class NetworkLoopQueue : public NetworkInterface {
void SetProperties(NT_Topic topicHandle, std::string_view name,
const wpi::json& update) final;
void Subscribe(NT_Subscriber subHandle,
wpi::span<const std::string> topicNames,
std::span<const std::string> topicNames,
const PubSubOptions& options) final;
void Unsubscribe(NT_Subscriber subHandle) final;
void SetValue(NT_Publisher pubHandle, const Value& value) final;

View File

@@ -4,6 +4,7 @@
#pragma once
#include <span>
#include <string>
#include <vector>
@@ -55,7 +56,7 @@ inline void NetworkLoopQueue::SetProperties(NT_Topic topicHandle,
}
inline void NetworkLoopQueue::Subscribe(NT_Subscriber subHandle,
wpi::span<const std::string> topicNames,
std::span<const std::string> topicNames,
const PubSubOptions& options) {
std::scoped_lock lock{m_mutex};
m_queue.emplace_back(ClientMessage{SubscribeMsg{

View File

@@ -91,7 +91,7 @@ class ClientData {
virtual ~ClientData() = default;
virtual void ProcessIncomingText(std::string_view data) = 0;
virtual void ProcessIncomingBinary(wpi::span<const uint8_t> data) = 0;
virtual void ProcessIncomingBinary(std::span<const uint8_t> data) = 0;
enum SendMode { kSendDisabled = 0, kSendAll, kSendNormal, kSendImmNoFlush };
@@ -151,7 +151,7 @@ class ClientData4Base : public ClientData, protected ClientMessageHandler {
void ClientUnpublish(int64_t pubuid) final;
void ClientSetProperties(std::string_view name,
const wpi::json& update) final;
void ClientSubscribe(int64_t subuid, wpi::span<const std::string> topicNames,
void ClientSubscribe(int64_t subuid, std::span<const std::string> topicNames,
const PubSubOptions& options) final;
void ClientUnsubscribe(int64_t subuid) final;
@@ -168,7 +168,7 @@ class ClientDataLocal final : public ClientData4Base {
: ClientData4Base{"", "", true, [](uint32_t) {}, server, id, logger} {}
void ProcessIncomingText(std::string_view data) final {}
void ProcessIncomingBinary(wpi::span<const uint8_t> data) final {}
void ProcessIncomingBinary(std::span<const uint8_t> data) final {}
void SendValue(TopicData* topic, const Value& value, SendMode mode) final;
void SendAnnounce(TopicData* topic, std::optional<int64_t> pubuid) final;
@@ -178,7 +178,7 @@ class ClientDataLocal final : public ClientData4Base {
void SendOutgoing(uint64_t curTimeMs) final {}
void Flush() final {}
void HandleLocal(wpi::span<const ClientMessage> msgs);
void HandleLocal(std::span<const ClientMessage> msgs);
};
class ClientData4 final : public ClientData4Base {
@@ -190,7 +190,7 @@ class ClientData4 final : public ClientData4Base {
m_wire{wire} {}
void ProcessIncomingText(std::string_view data) final;
void ProcessIncomingBinary(wpi::span<const uint8_t> data) final;
void ProcessIncomingBinary(std::span<const uint8_t> data) final;
void SendValue(TopicData* topic, const Value& value, SendMode mode) final;
void SendAnnounce(TopicData* topic, std::optional<int64_t> pubuid) final;
@@ -245,7 +245,7 @@ class ClientData3 final : public ClientData, private net3::MessageHandler3 {
m_decoder{*this} {}
void ProcessIncomingText(std::string_view data) final {}
void ProcessIncomingBinary(wpi::span<const uint8_t> data) final;
void ProcessIncomingBinary(std::span<const uint8_t> data) final;
void SendValue(TopicData* topic, const Value& value, SendMode mode) final;
void SendAnnounce(TopicData* topic, std::optional<int64_t> pubuid) final;
@@ -272,9 +272,9 @@ class ClientData3 final : public ClientData, private net3::MessageHandler3 {
void FlagsUpdate(unsigned int id, unsigned int flags) final;
void EntryDelete(unsigned int id) final;
void ExecuteRpc(unsigned int id, unsigned int uid,
wpi::span<const uint8_t> params) final {}
std::span<const uint8_t> params) final {}
void RpcResponse(unsigned int id, unsigned int uid,
wpi::span<const uint8_t> result) final {}
std::span<const uint8_t> result) final {}
ServerImpl::Connected3Func m_connected;
net3::WireConnection3& m_wire;
@@ -350,7 +350,7 @@ struct PublisherData {
};
struct SubscriberData {
SubscriberData(ClientData* client, wpi::span<const std::string> topicNames,
SubscriberData(ClientData* client, std::span<const std::string> topicNames,
int64_t subuid, const PubSubOptions& options)
: client{client},
topicNames{topicNames.begin(), topicNames.end()},
@@ -362,7 +362,7 @@ struct SubscriberData {
}
}
void Update(wpi::span<const std::string> topicNames_,
void Update(std::span<const std::string> topicNames_,
const PubSubOptions& options_) {
topicNames = {topicNames_.begin(), topicNames_.end()};
options = options_;
@@ -599,7 +599,7 @@ void ClientData4Base::ClientSetProperties(std::string_view name,
}
void ClientData4Base::ClientSubscribe(int64_t subuid,
wpi::span<const std::string> topicNames,
std::span<const std::string> topicNames,
const PubSubOptions& options) {
DEBUG4("ClientSubscribe({}, ({}), {})", m_id, fmt::join(topicNames, ","),
subuid);
@@ -757,7 +757,7 @@ void ClientDataLocal::SendPropertiesUpdate(TopicData* topic,
}
}
void ClientDataLocal::HandleLocal(wpi::span<const ClientMessage> msgs) {
void ClientDataLocal::HandleLocal(std::span<const ClientMessage> msgs) {
DEBUG4("{}", "HandleLocal()");
// just map as a normal client into client=0 calls
for (const auto& elem : msgs) { // NOLINT
@@ -782,7 +782,7 @@ void ClientData4::ProcessIncomingText(std::string_view data) {
WireDecodeText(data, *this, m_logger);
}
void ClientData4::ProcessIncomingBinary(wpi::span<const uint8_t> data) {
void ClientData4::ProcessIncomingBinary(std::span<const uint8_t> data) {
for (;;) {
if (data.empty()) {
break;
@@ -947,7 +947,7 @@ bool ClientData3::TopicData3::UpdateFlags(TopicData* topic) {
return updated;
}
void ClientData3::ProcessIncomingBinary(wpi::span<const uint8_t> data) {
void ClientData3::ProcessIncomingBinary(std::span<const uint8_t> data) {
if (!m_decoder.Execute(&data)) {
m_wire.Disconnect(m_decoder.GetError());
}
@@ -1199,7 +1199,7 @@ void ClientData3::ClientHello(std::string_view self_id,
PubSubOptions options;
options.prefixMatch = true;
sub = std::make_unique<SubscriberData>(
this, wpi::span<const std::string>{{prefix}}, 0, options);
this, std::span<const std::string>{{prefix}}, 0, options);
m_periodMs = std::gcd(m_periodMs, sub->periodMs);
if (m_periodMs < kMinPeriodMs) {
m_periodMs = kMinPeriodMs;
@@ -2253,7 +2253,7 @@ void ServerImpl::SendValues(int clientId, uint64_t curTimeMs) {
client->Flush();
}
void ServerImpl::HandleLocal(wpi::span<const ClientMessage> msgs) {
void ServerImpl::HandleLocal(std::span<const ClientMessage> msgs) {
// just map as a normal client into client=0 calls
m_impl->m_localClient->HandleLocal(msgs);
}
@@ -2278,7 +2278,7 @@ void ServerImpl::ProcessIncomingText(int clientId, std::string_view data) {
}
void ServerImpl::ProcessIncomingBinary(int clientId,
wpi::span<const uint8_t> data) {
std::span<const uint8_t> data) {
m_impl->m_clients[clientId]->ProcessIncomingBinary(data);
}
@@ -2329,7 +2329,7 @@ void ServerStartup::Publish(NT_Publisher pubHandle, NT_Topic topicHandle,
}
void ServerStartup::Subscribe(NT_Subscriber subHandle,
wpi::span<const std::string> topicNames,
std::span<const std::string> topicNames,
const PubSubOptions& options) {
m_server.m_impl->m_localClient->ClientSubscribe(subHandle, topicNames,
options);

View File

@@ -8,12 +8,11 @@
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <vector>
#include <wpi/span.h>
#include "NetworkInterface.h"
#include "net3/WireConnection3.h"
@@ -46,11 +45,11 @@ class ServerImpl final {
void SendControl(uint64_t curTimeMs);
void SendValues(int clientId, uint64_t curTimeMs);
void HandleLocal(wpi::span<const ClientMessage> msgs);
void HandleLocal(std::span<const ClientMessage> msgs);
void SetLocal(LocalInterface* local);
void ProcessIncomingText(int clientId, std::string_view data);
void ProcessIncomingBinary(int clientId, wpi::span<const uint8_t> data);
void ProcessIncomingBinary(int clientId, std::span<const uint8_t> data);
// Returns -1 if cannot add client (e.g. due to duplicate name).
// Caller must ensure WireConnection lifetime lasts until RemoveClient() call.
@@ -83,7 +82,7 @@ class ServerStartup final : public NetworkStartupInterface {
std::string_view name, std::string_view typeStr,
const wpi::json& properties, const PubSubOptions& options) final;
void Subscribe(NT_Subscriber subHandle,
wpi::span<const std::string> topicNames,
std::span<const std::string> topicNames,
const PubSubOptions& options) final;
void SetValue(NT_Publisher pubHandle, const Value& value) final;

View File

@@ -4,6 +4,8 @@
#include "WebSocketConnection.h"
#include <span>
#include <wpi/SpanExtras.h>
#include <wpinet/WebSocket.h>
@@ -37,7 +39,7 @@ void WebSocketConnection::Flush() {
m_ws_frames.reserve(m_frames.size());
for (auto&& frame : m_frames) {
m_ws_frames.emplace_back(frame.opcode,
wpi::span{frame.bufs->begin() + frame.start,
std::span{frame.bufs->begin() + frame.start,
frame.bufs->begin() + frame.end});
}

View File

@@ -418,7 +418,7 @@ void nt::net::WireDecodeText(std::string_view in, ServerMessageHandler& out,
::WireDecodeTextImpl(in, out, logger);
}
bool nt::net::WireDecodeBinary(wpi::span<const uint8_t>* in, int64_t* outId,
bool nt::net::WireDecodeBinary(std::span<const uint8_t>* in, int64_t* outId,
Value* outValue, std::string* error,
int64_t localTimeOffset) {
mpack_reader_t reader;

View File

@@ -7,11 +7,10 @@
#include <stdint.h>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <wpi/span.h>
namespace wpi {
class Logger;
class json;
@@ -35,7 +34,7 @@ class ClientMessageHandler {
virtual void ClientSetProperties(std::string_view name,
const wpi::json& update) = 0;
virtual void ClientSubscribe(int64_t subuid,
wpi::span<const std::string> topicNames,
std::span<const std::string> topicNames,
const PubSubOptions& options) = 0;
virtual void ClientUnsubscribe(int64_t subuid) = 0;
};
@@ -58,7 +57,7 @@ void WireDecodeText(std::string_view in, ServerMessageHandler& out,
wpi::Logger& logger);
// returns true if successfully decoded a message
bool WireDecodeBinary(wpi::span<const uint8_t>* in, int64_t* outId,
bool WireDecodeBinary(std::span<const uint8_t>* in, int64_t* outId,
Value* outValue, std::string* error,
int64_t localTimeOffset);

View File

@@ -56,7 +56,7 @@ void nt::net::WireEncodeSetProperties(wpi::raw_ostream& os,
}
template <typename T>
static void EncodePrefixes(wpi::raw_ostream& os, wpi::span<const T> topicNames,
static void EncodePrefixes(wpi::raw_ostream& os, std::span<const T> topicNames,
wpi::json::serializer& s) {
os << '[';
bool first = true;
@@ -75,7 +75,7 @@ static void EncodePrefixes(wpi::raw_ostream& os, wpi::span<const T> topicNames,
template <typename T>
static void WireEncodeSubscribeImpl(wpi::raw_ostream& os, int64_t subuid,
wpi::span<const T> topicNames,
std::span<const T> topicNames,
const PubSubOptions& options) {
wpi::json::serializer s{os, ' ', 0};
os << "{\"method\":\"" << SubscribeMsg::kMethodStr << "\",\"params\":{";
@@ -114,13 +114,13 @@ static void WireEncodeSubscribeImpl(wpi::raw_ostream& os, int64_t subuid,
}
void nt::net::WireEncodeSubscribe(wpi::raw_ostream& os, int64_t subuid,
wpi::span<const std::string_view> topicNames,
std::span<const std::string_view> topicNames,
const PubSubOptions& options) {
WireEncodeSubscribeImpl(os, subuid, topicNames, options);
}
void nt::net::WireEncodeSubscribe(wpi::raw_ostream& os, int64_t subuid,
wpi::span<const std::string> topicNames,
std::span<const std::string> topicNames,
const PubSubOptions& options) {
WireEncodeSubscribeImpl(os, subuid, topicNames, options);
}

View File

@@ -5,11 +5,10 @@
#pragma once
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <wpi/span.h>
namespace wpi {
class json;
class raw_ostream;
@@ -33,10 +32,10 @@ void WireEncodeUnpublish(wpi::raw_ostream& os, int64_t pubuid);
void WireEncodeSetProperties(wpi::raw_ostream& os, std::string_view name,
const wpi::json& update);
void WireEncodeSubscribe(wpi::raw_ostream& os, int64_t subuid,
wpi::span<const std::string_view> topicNames,
std::span<const std::string_view> topicNames,
const PubSubOptions& options);
void WireEncodeSubscribe(wpi::raw_ostream& os, int64_t subuid,
wpi::span<const std::string> topicNames,
std::span<const std::string> topicNames,
const PubSubOptions& options);
void WireEncodeUnsubscribe(wpi::raw_ostream& os, int64_t subuid);

View File

@@ -89,8 +89,8 @@ class CImpl : public MessageHandler3 {
wpi::Logger& logger,
std::function<void(uint32_t repeatMs)> setPeriodic);
void ProcessIncoming(wpi::span<const uint8_t> data);
void HandleLocal(wpi::span<const net::ClientMessage> msgs);
void ProcessIncoming(std::span<const uint8_t> data);
void HandleLocal(std::span<const net::ClientMessage> msgs);
void SendPeriodic(uint64_t curTimeMs, bool initial);
void SendValue(Writer& out, Entry* entry, const Value& value);
bool CheckNetworkReady();
@@ -119,9 +119,9 @@ class CImpl : public MessageHandler3 {
void FlagsUpdate(unsigned int id, unsigned int flags) final;
void EntryDelete(unsigned int id) final;
void ExecuteRpc(unsigned int id, unsigned int uid,
wpi::span<const uint8_t> params) final {}
std::span<const uint8_t> params) final {}
void RpcResponse(unsigned int id, unsigned int uid,
wpi::span<const uint8_t> result) final {}
std::span<const uint8_t> result) final {}
enum State {
kStateInitial,
@@ -200,14 +200,14 @@ CImpl::CImpl(uint64_t curTimeMs, int inst, WireConnection3& wire,
m_nextKeepAliveTimeMs{curTimeMs + kKeepAliveIntervalMs},
m_decoder{*this} {}
void CImpl::ProcessIncoming(wpi::span<const uint8_t> data) {
void CImpl::ProcessIncoming(std::span<const uint8_t> data) {
DEBUG4("received {} bytes", data.size());
if (!m_decoder.Execute(&data)) {
m_wire.Disconnect(m_decoder.GetError());
}
}
void CImpl::HandleLocal(wpi::span<const net::ClientMessage> msgs) {
void CImpl::HandleLocal(std::span<const net::ClientMessage> msgs) {
for (const auto& elem : msgs) { // NOLINT
// common case is value
if (auto msg = std::get_if<net::ClientValueMsg>(&elem.contents)) {
@@ -624,11 +624,11 @@ void ClientImpl3::Start(std::string_view selfId,
m_impl->m_state = CImpl::kStateHelloSent;
}
void ClientImpl3::ProcessIncoming(wpi::span<const uint8_t> data) {
void ClientImpl3::ProcessIncoming(std::span<const uint8_t> data) {
m_impl->ProcessIncoming(data);
}
void ClientImpl3::HandleLocal(wpi::span<const net::ClientMessage> msgs) {
void ClientImpl3::HandleLocal(std::span<const net::ClientMessage> msgs) {
m_impl->HandleLocal(msgs);
}
@@ -655,7 +655,7 @@ void ClientStartup3::Publish(NT_Publisher pubHandle, NT_Topic topicHandle,
}
void ClientStartup3::Subscribe(NT_Subscriber subHandle,
wpi::span<const std::string> prefixes,
std::span<const std::string> prefixes,
const PubSubOptions& options) {
// NT3 ignores subscribes, so no action required
}

View File

@@ -8,11 +8,10 @@
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <wpi/span.h>
#include "net/NetworkInterface.h"
namespace wpi {
@@ -39,8 +38,8 @@ class ClientImpl3 {
~ClientImpl3();
void Start(std::string_view selfId, std::function<void()> succeeded);
void ProcessIncoming(wpi::span<const uint8_t> data);
void HandleLocal(wpi::span<const net::ClientMessage> msgs);
void ProcessIncoming(std::span<const uint8_t> data);
void HandleLocal(std::span<const net::ClientMessage> msgs);
void SendPeriodic(uint64_t curTimeMs);
@@ -62,7 +61,7 @@ class ClientStartup3 final : public net::NetworkStartupInterface {
void Publish(NT_Publisher pubHandle, NT_Topic topicHandle,
std::string_view name, std::string_view typeStr,
const wpi::json& properties, const PubSubOptions& options) final;
void Subscribe(NT_Subscriber subHandle, wpi::span<const std::string> prefixes,
void Subscribe(NT_Subscriber subHandle, std::span<const std::string> prefixes,
const PubSubOptions& options) final;
void SetValue(NT_Publisher pubHandle, const Value& value) final;

View File

@@ -6,6 +6,7 @@
#include <stdint.h>
#include <span>
#include <string>
#include "networktables/NetworkTableValue.h"
@@ -57,7 +58,7 @@ class Message3 {
// Message data accessors. Callers are responsible for knowing what data is
// actually provided for a particular message.
std::string_view str() const { return m_str; }
wpi::span<const uint8_t> bytes() const {
std::span<const uint8_t> bytes() const {
return {reinterpret_cast<const uint8_t*>(m_str.data()), m_str.size()};
}
const Value& value() const { return m_value; }
@@ -123,7 +124,7 @@ class Message3 {
return msg;
}
static Message3 ExecuteRpc(unsigned int id, unsigned int uid,
wpi::span<const uint8_t> params) {
std::span<const uint8_t> params) {
Message3 msg{kExecuteRpc, {}};
msg.m_str.assign(reinterpret_cast<const char*>(params.data()),
params.size());
@@ -132,7 +133,7 @@ class Message3 {
return msg;
}
static Message3 RpcResponse(unsigned int id, unsigned int uid,
wpi::span<const uint8_t> result) {
std::span<const uint8_t> result) {
Message3 msg{kRpcResponse, {}};
msg.m_str.assign(reinterpret_cast<const char*>(result.data()),
result.size());

View File

@@ -23,10 +23,10 @@ namespace {
class SimpleValueReader {
public:
std::optional<uint16_t> Read16(wpi::span<const uint8_t>* in);
std::optional<uint32_t> Read32(wpi::span<const uint8_t>* in);
std::optional<uint64_t> Read64(wpi::span<const uint8_t>* in);
std::optional<double> ReadDouble(wpi::span<const uint8_t>* in);
std::optional<uint16_t> Read16(std::span<const uint8_t>* in);
std::optional<uint32_t> Read32(std::span<const uint8_t>* in);
std::optional<uint64_t> Read64(std::span<const uint8_t>* in);
std::optional<double> ReadDouble(std::span<const uint8_t>* in);
private:
uint64_t m_value = 0;
@@ -123,7 +123,7 @@ struct WDImpl {
unsigned int m_flags{0};
unsigned int m_seq_num_uid{0};
void Execute(wpi::span<const uint8_t>* in);
void Execute(std::span<const uint8_t>* in);
std::nullopt_t EmitError(std::string_view msg) {
m_state = kError;
@@ -131,22 +131,22 @@ struct WDImpl {
return std::nullopt;
}
std::optional<std::string> ReadString(wpi::span<const uint8_t>* in);
std::optional<std::vector<uint8_t>> ReadRaw(wpi::span<const uint8_t>* in);
std::optional<NT_Type> ReadType(wpi::span<const uint8_t>* in);
std::optional<Value> ReadValue(wpi::span<const uint8_t>* in);
std::optional<std::string> ReadString(std::span<const uint8_t>* in);
std::optional<std::vector<uint8_t>> ReadRaw(std::span<const uint8_t>* in);
std::optional<NT_Type> ReadType(std::span<const uint8_t>* in);
std::optional<Value> ReadValue(std::span<const uint8_t>* in);
};
} // namespace
static uint8_t Read8(wpi::span<const uint8_t>* in) {
static uint8_t Read8(std::span<const uint8_t>* in) {
uint8_t val = in->front();
*in = wpi::drop_front(*in);
return val;
}
std::optional<uint16_t> SimpleValueReader::Read16(
wpi::span<const uint8_t>* in) {
std::span<const uint8_t>* in) {
while (!in->empty()) {
m_value <<= 8;
m_value |= in->front() & 0xff;
@@ -162,7 +162,7 @@ std::optional<uint16_t> SimpleValueReader::Read16(
}
std::optional<uint32_t> SimpleValueReader::Read32(
wpi::span<const uint8_t>* in) {
std::span<const uint8_t>* in) {
while (!in->empty()) {
m_value <<= 8;
m_value |= in->front() & 0xff;
@@ -178,7 +178,7 @@ std::optional<uint32_t> SimpleValueReader::Read32(
}
std::optional<uint64_t> SimpleValueReader::Read64(
wpi::span<const uint8_t>* in) {
std::span<const uint8_t>* in) {
while (!in->empty()) {
m_value <<= 8;
m_value |= in->front() & 0xff;
@@ -194,7 +194,7 @@ std::optional<uint64_t> SimpleValueReader::Read64(
}
std::optional<double> SimpleValueReader::ReadDouble(
wpi::span<const uint8_t>* in) {
std::span<const uint8_t>* in) {
if (auto val = Read64(in)) {
return wpi::BitsToDouble(val.value());
} else {
@@ -202,7 +202,7 @@ std::optional<double> SimpleValueReader::ReadDouble(
}
}
void WDImpl::Execute(wpi::span<const uint8_t>* in) {
void WDImpl::Execute(std::span<const uint8_t>* in) {
while (!in->empty()) {
switch (m_state) {
case kStart: {
@@ -417,7 +417,7 @@ void WDImpl::Execute(wpi::span<const uint8_t>* in) {
}
}
std::optional<std::string> WDImpl::ReadString(wpi::span<const uint8_t>* in) {
std::optional<std::string> WDImpl::ReadString(std::span<const uint8_t>* in) {
// string length
if (!m_stringReader.len) {
if (auto val = m_ulebReader.ReadOne(in)) {
@@ -443,7 +443,7 @@ std::optional<std::string> WDImpl::ReadString(wpi::span<const uint8_t>* in) {
}
std::optional<std::vector<uint8_t>> WDImpl::ReadRaw(
wpi::span<const uint8_t>* in) {
std::span<const uint8_t>* in) {
// string length
if (!m_rawReader.len) {
if (auto val = m_ulebReader.ReadOne(in)) {
@@ -468,7 +468,7 @@ std::optional<std::vector<uint8_t>> WDImpl::ReadRaw(
return std::nullopt;
}
std::optional<NT_Type> WDImpl::ReadType(wpi::span<const uint8_t>* in) {
std::optional<NT_Type> WDImpl::ReadType(std::span<const uint8_t>* in) {
// Convert from byte value to enum
switch (Read8(in)) {
case Message3::kBoolean:
@@ -492,7 +492,7 @@ std::optional<NT_Type> WDImpl::ReadType(wpi::span<const uint8_t>* in) {
}
}
std::optional<Value> WDImpl::ReadValue(wpi::span<const uint8_t>* in) {
std::optional<Value> WDImpl::ReadValue(std::span<const uint8_t>* in) {
while (!in->empty()) {
switch (m_valueReader.type) {
case NT_BOOLEAN:
@@ -586,7 +586,7 @@ WireDecoder3::WireDecoder3(MessageHandler3& out) : m_impl{new Impl{out}} {}
WireDecoder3::~WireDecoder3() = default;
bool WireDecoder3::Execute(wpi::span<const uint8_t>* in) {
bool WireDecoder3::Execute(std::span<const uint8_t>* in) {
m_impl->Execute(in);
return m_impl->m_state != Impl::kError;
}

View File

@@ -7,10 +7,9 @@
#include <stdint.h>
#include <memory>
#include <span>
#include <string>
#include <wpi/span.h>
namespace nt {
class Value;
} // namespace nt
@@ -35,9 +34,9 @@ class MessageHandler3 {
virtual void FlagsUpdate(unsigned int id, unsigned int flags) = 0;
virtual void EntryDelete(unsigned int id) = 0;
virtual void ExecuteRpc(unsigned int id, unsigned int uid,
wpi::span<const uint8_t> params) = 0;
std::span<const uint8_t> params) = 0;
virtual void RpcResponse(unsigned int id, unsigned int uid,
wpi::span<const uint8_t> result) = 0;
std::span<const uint8_t> result) = 0;
};
/* Decodes NT3 protocol into native representation. */
@@ -52,7 +51,7 @@ class WireDecoder3 {
* @param in input data (updated during parse)
* @return false if error occurred
*/
bool Execute(wpi::span<const uint8_t>* in);
bool Execute(std::span<const uint8_t>* in);
void SetError(std::string_view message);
std::string GetError() const;

View File

@@ -8,7 +8,6 @@
#include <wpi/SmallVector.h>
#include <wpi/leb128.h>
#include <wpi/raw_ostream.h>
#include <wpi/span.h>
#include "Message3.h"
@@ -20,12 +19,12 @@ static void Write8(wpi::raw_ostream& os, uint8_t val) {
}
static void Write16(wpi::raw_ostream& os, uint16_t val) {
os << wpi::span<const uint8_t>{{static_cast<uint8_t>((val >> 8) & 0xff),
os << std::span<const uint8_t>{{static_cast<uint8_t>((val >> 8) & 0xff),
static_cast<uint8_t>(val & 0xff)}};
}
static void Write32(wpi::raw_ostream& os, uint32_t val) {
os << wpi::span<const uint8_t>{{static_cast<uint8_t>((val >> 24) & 0xff),
os << std::span<const uint8_t>{{static_cast<uint8_t>((val >> 24) & 0xff),
static_cast<uint8_t>((val >> 16) & 0xff),
static_cast<uint8_t>((val >> 8) & 0xff),
static_cast<uint8_t>(val & 0xff)}};
@@ -34,7 +33,7 @@ static void Write32(wpi::raw_ostream& os, uint32_t val) {
static void WriteDouble(wpi::raw_ostream& os, double val) {
// The highest performance way to do this, albeit non-portable.
uint64_t v = wpi::DoubleToBits(val);
os << wpi::span<const uint8_t>{{static_cast<uint8_t>((v >> 56) & 0xff),
os << std::span<const uint8_t>{{static_cast<uint8_t>((v >> 56) & 0xff),
static_cast<uint8_t>((v >> 48) & 0xff),
static_cast<uint8_t>((v >> 40) & 0xff),
static_cast<uint8_t>((v >> 32) & 0xff),
@@ -49,7 +48,7 @@ static void WriteString(wpi::raw_ostream& os, std::string_view str) {
os << str;
}
static void WriteRaw(wpi::raw_ostream& os, wpi::span<const uint8_t> str) {
static void WriteRaw(wpi::raw_ostream& os, std::span<const uint8_t> str) {
wpi::WriteUleb128(os, str.size());
os << str;
}
@@ -261,7 +260,7 @@ void nt::net3::WireEncodeEntryDelete(wpi::raw_ostream& os, unsigned int id) {
void nt::net3::WireEncodeExecuteRpc(wpi::raw_ostream& os, unsigned int id,
unsigned int uid,
wpi::span<const uint8_t> params) {
std::span<const uint8_t> params) {
Write8(os, Message3::kExecuteRpc);
Write16(os, id);
Write16(os, uid);
@@ -270,7 +269,7 @@ void nt::net3::WireEncodeExecuteRpc(wpi::raw_ostream& os, unsigned int id,
void nt::net3::WireEncodeRpcResponse(wpi::raw_ostream& os, unsigned int id,
unsigned int uid,
wpi::span<const uint8_t> result) {
std::span<const uint8_t> result) {
Write8(os, Message3::kRpcResponse);
Write16(os, id);
Write16(os, uid);

View File

@@ -6,10 +6,9 @@
#include <stdint.h>
#include <span>
#include <string_view>
#include <wpi/span.h>
namespace wpi {
class raw_ostream;
} // namespace wpi
@@ -41,9 +40,9 @@ void WireEncodeFlagsUpdate(wpi::raw_ostream& os, unsigned int id,
unsigned int flags);
void WireEncodeEntryDelete(wpi::raw_ostream& os, unsigned int id);
void WireEncodeExecuteRpc(wpi::raw_ostream& os, unsigned int id,
unsigned int uid, wpi::span<const uint8_t> params);
unsigned int uid, std::span<const uint8_t> params);
void WireEncodeRpcResponse(wpi::raw_ostream& os, unsigned int id,
unsigned int uid, wpi::span<const uint8_t> result);
unsigned int uid, std::span<const uint8_t> result);
bool WireEncode(wpi::raw_ostream& os, const Message3& msg);

View File

@@ -287,62 +287,62 @@ bool NetworkTable::GetBoolean(std::string_view key, bool defaultValue) const {
}
bool NetworkTable::PutBooleanArray(std::string_view key,
wpi::span<const int> value) {
std::span<const int> value) {
return GetEntry(key).SetBooleanArray(value);
}
bool NetworkTable::SetDefaultBooleanArray(std::string_view key,
wpi::span<const int> defaultValue) {
std::span<const int> defaultValue) {
return GetEntry(key).SetDefaultBooleanArray(defaultValue);
}
std::vector<int> NetworkTable::GetBooleanArray(
std::string_view key, wpi::span<const int> defaultValue) const {
std::string_view key, std::span<const int> defaultValue) const {
return GetEntry(key).GetBooleanArray(defaultValue);
}
bool NetworkTable::PutNumberArray(std::string_view key,
wpi::span<const double> value) {
std::span<const double> value) {
return GetEntry(key).SetDoubleArray(value);
}
bool NetworkTable::SetDefaultNumberArray(std::string_view key,
wpi::span<const double> defaultValue) {
std::span<const double> defaultValue) {
return GetEntry(key).SetDefaultDoubleArray(defaultValue);
}
std::vector<double> NetworkTable::GetNumberArray(
std::string_view key, wpi::span<const double> defaultValue) const {
std::string_view key, std::span<const double> defaultValue) const {
return GetEntry(key).GetDoubleArray(defaultValue);
}
bool NetworkTable::PutStringArray(std::string_view key,
wpi::span<const std::string> value) {
std::span<const std::string> value) {
return GetEntry(key).SetStringArray(value);
}
bool NetworkTable::SetDefaultStringArray(
std::string_view key, wpi::span<const std::string> defaultValue) {
std::string_view key, std::span<const std::string> defaultValue) {
return GetEntry(key).SetDefaultStringArray(defaultValue);
}
std::vector<std::string> NetworkTable::GetStringArray(
std::string_view key, wpi::span<const std::string> defaultValue) const {
std::string_view key, std::span<const std::string> defaultValue) const {
return GetEntry(key).GetStringArray(defaultValue);
}
bool NetworkTable::PutRaw(std::string_view key,
wpi::span<const uint8_t> value) {
std::span<const uint8_t> value) {
return GetEntry(key).SetRaw(value);
}
bool NetworkTable::SetDefaultRaw(std::string_view key,
wpi::span<const uint8_t> defaultValue) {
std::span<const uint8_t> defaultValue) {
return GetEntry(key).SetDefaultRaw(defaultValue);
}
std::vector<uint8_t> NetworkTable::GetRaw(
std::string_view key, wpi::span<const uint8_t> defaultValue) const {
std::string_view key, std::span<const uint8_t> defaultValue) const {
return GetEntry(key).GetRaw(defaultValue);
}

View File

@@ -90,7 +90,7 @@ std::shared_ptr<NetworkTable> NetworkTableInstance::GetTable(
}
}
void NetworkTableInstance::SetServer(wpi::span<const std::string_view> servers,
void NetworkTableInstance::SetServer(std::span<const std::string_view> servers,
unsigned int port) {
std::vector<std::pair<std::string_view, unsigned int>> serversArr;
serversArr.reserve(servers.size());

View File

@@ -23,36 +23,36 @@ wpi::json Topic::GetProperties() const {
}
GenericSubscriber Topic::GenericSubscribe(
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
return GenericSubscribe("", options);
}
GenericSubscriber Topic::GenericSubscribe(
std::string_view typeString, wpi::span<const PubSubOption> options) {
std::string_view typeString, std::span<const PubSubOption> options) {
return GenericSubscriber{::nt::Subscribe(
m_handle, ::nt::GetTypeFromString(typeString), typeString, options)};
}
GenericPublisher Topic::GenericPublish(std::string_view typeString,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
return GenericPublisher{::nt::Publish(
m_handle, ::nt::GetTypeFromString(typeString), typeString, options)};
}
GenericPublisher Topic::GenericPublishEx(
std::string_view typeString, const wpi::json& properties,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
return GenericPublisher{::nt::PublishEx(m_handle,
::nt::GetTypeFromString(typeString),
typeString, properties, options)};
}
GenericEntry Topic::GetGenericEntry(wpi::span<const PubSubOption> options) {
GenericEntry Topic::GetGenericEntry(std::span<const PubSubOption> options) {
return GetGenericEntry("", options);
}
GenericEntry Topic::GetGenericEntry(std::string_view typeString,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
return GenericEntry{::nt::GetEntry(
m_handle, ::nt::GetTypeFromString(typeString), typeString, options)};
}

View File

@@ -157,7 +157,7 @@ std::vector<NT_Topic> GetTopics(NT_Inst inst, std::string_view prefix,
}
std::vector<NT_Topic> GetTopics(NT_Inst inst, std::string_view prefix,
wpi::span<const std::string_view> types) {
std::span<const std::string_view> types) {
if (auto ii = InstanceImpl::GetTyped(inst, Handle::kInstance)) {
return ii->localStorage.GetTopics(prefix, types);
} else {
@@ -175,7 +175,7 @@ std::vector<TopicInfo> GetTopicInfo(NT_Inst inst, std::string_view prefix,
}
std::vector<TopicInfo> GetTopicInfo(NT_Inst inst, std::string_view prefix,
wpi::span<const std::string_view> types) {
std::span<const std::string_view> types) {
if (auto ii = InstanceImpl::GetTyped(inst, Handle::kInstance)) {
return ii->localStorage.GetTopicInfo(prefix, types);
} else {
@@ -302,7 +302,7 @@ bool SetTopicProperties(NT_Topic topic, const wpi::json& properties) {
}
NT_Subscriber Subscribe(NT_Topic topic, NT_Type type, std::string_view typeStr,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
if (auto ii = InstanceImpl::GetTyped(topic, Handle::kTopic)) {
return ii->localStorage.Subscribe(topic, type, typeStr, options);
} else {
@@ -317,13 +317,13 @@ void Unsubscribe(NT_Subscriber sub) {
}
NT_Publisher Publish(NT_Topic topic, NT_Type type, std::string_view typeStr,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
return PublishEx(topic, type, typeStr, wpi::json::object(), options);
}
NT_Publisher PublishEx(NT_Topic topic, NT_Type type, std::string_view typeStr,
const wpi::json& properties,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
if (auto ii = InstanceImpl::GetTyped(topic, Handle::kTopic)) {
return ii->localStorage.Publish(topic, type, typeStr, properties, options);
} else {
@@ -338,7 +338,7 @@ void Unpublish(NT_Handle pubentry) {
}
NT_Entry GetEntry(NT_Topic topic, NT_Type type, std::string_view typeStr,
wpi::span<const PubSubOption> options) {
std::span<const PubSubOption> options) {
if (auto ii = InstanceImpl::GetTyped(topic, Handle::kTopic)) {
return ii->localStorage.GetEntry(topic, type, typeStr, options);
} else {
@@ -367,8 +367,8 @@ NT_Topic GetTopicFromHandle(NT_Handle pubsubentry) {
}
NT_MultiSubscriber SubscribeMultiple(NT_Inst inst,
wpi::span<const std::string_view> prefixes,
wpi::span<const PubSubOption> options) {
std::span<const std::string_view> prefixes,
std::span<const PubSubOption> options) {
if (auto ii = InstanceImpl::GetTyped(inst, Handle::kInstance)) {
return ii->localStorage.SubscribeMultiple(prefixes, options);
} else {
@@ -387,7 +387,7 @@ void UnsubscribeMultiple(NT_MultiSubscriber sub) {
*/
NT_TopicListener AddTopicListener(
NT_Inst inst, wpi::span<const std::string_view> prefixes, unsigned int mask,
NT_Inst inst, std::span<const std::string_view> prefixes, unsigned int mask,
std::function<void(const TopicNotification&)> callback) {
if (auto ii = InstanceImpl::GetTyped(inst, Handle::kInstance)) {
return ii->localStorage.AddTopicListener(prefixes, mask,
@@ -422,7 +422,7 @@ void DestroyTopicListenerPoller(NT_TopicListenerPoller poller) {
}
NT_TopicListener AddPolledTopicListener(
NT_TopicListenerPoller poller, wpi::span<const std::string_view> prefixes,
NT_TopicListenerPoller poller, std::span<const std::string_view> prefixes,
unsigned int mask) {
if (auto ii = InstanceImpl::GetTyped(poller, Handle::kTopicListenerPoller)) {
return ii->localStorage.AddPolledTopicListener(poller, prefixes, mask);
@@ -688,7 +688,7 @@ void SetServer(NT_Inst inst, const char* server_name, unsigned int port) {
void SetServer(
NT_Inst inst,
wpi::span<const std::pair<std::string_view, unsigned int>> servers) {
std::span<const std::pair<std::string_view, unsigned int>> servers) {
if (auto ii = InstanceImpl::GetTyped(inst, Handle::kInstance)) {
if (auto client = ii->GetClient()) {
std::vector<std::pair<std::string, unsigned int>> serversCopy;

View File

@@ -7,8 +7,6 @@
#include <functional>
#include <vector>
#include <wpi/span.h>
#include "ntcore_cpp.h"
namespace nt {

View File

@@ -7,8 +7,6 @@
#include <utility>
#include <vector>
#include <wpi/span.h>
#include "networktables/ConnectionListener.h"
#include "networktables/NetworkTableInstance.h"
#include "ntcore_cpp.h"

View File

@@ -6,6 +6,7 @@
#include <stdint.h>
#include <span>
#include <string>
#include <string_view>
#include <utility>
@@ -97,7 +98,7 @@ class GenericSubscriber : public Subscriber {
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
std::vector<uint8_t> GetRaw(wpi::span<const uint8_t> defaultValue) const;
std::vector<uint8_t> GetRaw(std::span<const uint8_t> defaultValue) const;
/**
* Gets the entry's value as a boolean array. If the entry does not exist
@@ -113,7 +114,7 @@ class GenericSubscriber : public Subscriber {
* because std::vector<bool> is special-cased in C++. 0 is false, any
* non-zero value is true.
*/
std::vector<int> GetBooleanArray(wpi::span<const int> defaultValue) const;
std::vector<int> GetBooleanArray(std::span<const int> defaultValue) const;
/**
* Gets the entry's value as a integer array. If the entry does not exist
@@ -126,7 +127,7 @@ class GenericSubscriber : public Subscriber {
* concern, use GetValue() instead.
*/
std::vector<int64_t> GetIntegerArray(
wpi::span<const int64_t> defaultValue) const;
std::span<const int64_t> defaultValue) const;
/**
* Gets the entry's value as a float array. If the entry does not exist
@@ -138,7 +139,7 @@ class GenericSubscriber : public Subscriber {
* @note This makes a copy of the array. If the overhead of this is a
* concern, use GetValue() instead.
*/
std::vector<float> GetFloatArray(wpi::span<const float> defaultValue) const;
std::vector<float> GetFloatArray(std::span<const float> defaultValue) const;
/**
* Gets the entry's value as a double array. If the entry does not exist
@@ -151,7 +152,7 @@ class GenericSubscriber : public Subscriber {
* concern, use GetValue() instead.
*/
std::vector<double> GetDoubleArray(
wpi::span<const double> defaultValue) const;
std::span<const double> defaultValue) const;
/**
* Gets the entry's value as a string array. If the entry does not exist
@@ -164,7 +165,7 @@ class GenericSubscriber : public Subscriber {
* concern, use GetValue() instead.
*/
std::vector<std::string> GetStringArray(
wpi::span<const std::string> defaultValue) const;
std::span<const std::string> defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
@@ -265,7 +266,7 @@ class GenericPublisher : public Publisher {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetRaw(wpi::span<const uint8_t> value, int64_t time = 0);
bool SetRaw(std::span<const uint8_t> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -274,7 +275,7 @@ class GenericPublisher : public Publisher {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetBooleanArray(wpi::span<const bool> value, int64_t time = 0);
bool SetBooleanArray(std::span<const bool> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -283,7 +284,7 @@ class GenericPublisher : public Publisher {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetBooleanArray(wpi::span<const int> value, int64_t time = 0);
bool SetBooleanArray(std::span<const int> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -292,7 +293,7 @@ class GenericPublisher : public Publisher {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetIntegerArray(wpi::span<const int64_t> value, int64_t time = 0);
bool SetIntegerArray(std::span<const int64_t> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -301,7 +302,7 @@ class GenericPublisher : public Publisher {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetFloatArray(wpi::span<const float> value, int64_t time = 0);
bool SetFloatArray(std::span<const float> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -310,7 +311,7 @@ class GenericPublisher : public Publisher {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetDoubleArray(wpi::span<const double> value, int64_t time = 0);
bool SetDoubleArray(std::span<const double> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -319,7 +320,7 @@ class GenericPublisher : public Publisher {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetStringArray(wpi::span<const std::string> value, int64_t time = 0);
bool SetStringArray(std::span<const std::string> value, int64_t time = 0);
/**
* Publish a default value.
@@ -376,7 +377,7 @@ class GenericPublisher : public Publisher {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultRaw(wpi::span<const uint8_t> defaultValue);
bool SetDefaultRaw(std::span<const uint8_t> defaultValue);
/**
* Sets the entry's value if it does not exist.
@@ -384,7 +385,7 @@ class GenericPublisher : public Publisher {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultBooleanArray(wpi::span<const int> defaultValue);
bool SetDefaultBooleanArray(std::span<const int> defaultValue);
/**
* Sets the entry's value if it does not exist.
@@ -392,7 +393,7 @@ class GenericPublisher : public Publisher {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultIntegerArray(wpi::span<const int64_t> defaultValue);
bool SetDefaultIntegerArray(std::span<const int64_t> defaultValue);
/**
* Sets the entry's value if it does not exist.
@@ -400,7 +401,7 @@ class GenericPublisher : public Publisher {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultFloatArray(wpi::span<const float> defaultValue);
bool SetDefaultFloatArray(std::span<const float> defaultValue);
/**
* Sets the entry's value if it does not exist.
@@ -408,7 +409,7 @@ class GenericPublisher : public Publisher {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultDoubleArray(wpi::span<const double> defaultValue);
bool SetDefaultDoubleArray(std::span<const double> defaultValue);
/**
* Sets the entry's value if it does not exist.
@@ -416,7 +417,7 @@ class GenericPublisher : public Publisher {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultStringArray(wpi::span<const std::string> defaultValue);
bool SetDefaultStringArray(std::span<const std::string> defaultValue);
/**
* Get the corresponding topic.

View File

@@ -4,6 +4,7 @@
#pragma once
#include <span>
#include <string>
#include <string_view>
#include <vector>
@@ -43,32 +44,32 @@ inline std::string GenericSubscriber::GetString(
}
inline std::vector<uint8_t> GenericSubscriber::GetRaw(
wpi::span<const uint8_t> defaultValue) const {
std::span<const uint8_t> defaultValue) const {
return ::nt::GetRaw(m_subHandle, defaultValue);
}
inline std::vector<int> GenericSubscriber::GetBooleanArray(
wpi::span<const int> defaultValue) const {
std::span<const int> defaultValue) const {
return ::nt::GetBooleanArray(m_subHandle, defaultValue);
}
inline std::vector<int64_t> GenericSubscriber::GetIntegerArray(
wpi::span<const int64_t> defaultValue) const {
std::span<const int64_t> defaultValue) const {
return ::nt::GetIntegerArray(m_subHandle, defaultValue);
}
inline std::vector<float> GenericSubscriber::GetFloatArray(
wpi::span<const float> defaultValue) const {
std::span<const float> defaultValue) const {
return ::nt::GetFloatArray(m_subHandle, defaultValue);
}
inline std::vector<double> GenericSubscriber::GetDoubleArray(
wpi::span<const double> defaultValue) const {
std::span<const double> defaultValue) const {
return ::nt::GetDoubleArray(m_subHandle, defaultValue);
}
inline std::vector<std::string> GenericSubscriber::GetStringArray(
wpi::span<const std::string> defaultValue) const {
std::span<const std::string> defaultValue) const {
return ::nt::GetStringArray(m_subHandle, defaultValue);
}
@@ -107,37 +108,37 @@ inline bool GenericPublisher::SetString(std::string_view value, int64_t time) {
return nt::SetString(m_pubHandle, value, time);
}
inline bool GenericPublisher::SetRaw(wpi::span<const uint8_t> value,
inline bool GenericPublisher::SetRaw(std::span<const uint8_t> value,
int64_t time) {
return nt::SetRaw(m_pubHandle, value, time);
}
inline bool GenericPublisher::SetBooleanArray(wpi::span<const bool> value,
inline bool GenericPublisher::SetBooleanArray(std::span<const bool> value,
int64_t time) {
return SetEntryValue(m_pubHandle, Value::MakeBooleanArray(value, time));
}
inline bool GenericPublisher::SetBooleanArray(wpi::span<const int> value,
inline bool GenericPublisher::SetBooleanArray(std::span<const int> value,
int64_t time) {
return nt::SetBooleanArray(m_pubHandle, value, time);
}
inline bool GenericPublisher::SetIntegerArray(wpi::span<const int64_t> value,
inline bool GenericPublisher::SetIntegerArray(std::span<const int64_t> value,
int64_t time) {
return nt::SetIntegerArray(m_pubHandle, value, time);
}
inline bool GenericPublisher::SetFloatArray(wpi::span<const float> value,
inline bool GenericPublisher::SetFloatArray(std::span<const float> value,
int64_t time) {
return nt::SetFloatArray(m_pubHandle, value, time);
}
inline bool GenericPublisher::SetDoubleArray(wpi::span<const double> value,
inline bool GenericPublisher::SetDoubleArray(std::span<const double> value,
int64_t time) {
return nt::SetDoubleArray(m_pubHandle, value, time);
}
inline bool GenericPublisher::SetStringArray(wpi::span<const std::string> value,
inline bool GenericPublisher::SetStringArray(std::span<const std::string> value,
int64_t time) {
return nt::SetStringArray(m_pubHandle, value, time);
}
@@ -167,32 +168,32 @@ inline bool GenericPublisher::SetDefaultString(std::string_view defaultValue) {
}
inline bool GenericPublisher::SetDefaultRaw(
wpi::span<const uint8_t> defaultValue) {
std::span<const uint8_t> defaultValue) {
return nt::SetDefaultRaw(m_pubHandle, defaultValue);
}
inline bool GenericPublisher::SetDefaultBooleanArray(
wpi::span<const int> defaultValue) {
std::span<const int> defaultValue) {
return nt::SetDefaultBooleanArray(m_pubHandle, defaultValue);
}
inline bool GenericPublisher::SetDefaultIntegerArray(
wpi::span<const int64_t> defaultValue) {
std::span<const int64_t> defaultValue) {
return nt::SetDefaultIntegerArray(m_pubHandle, defaultValue);
}
inline bool GenericPublisher::SetDefaultFloatArray(
wpi::span<const float> defaultValue) {
std::span<const float> defaultValue) {
return nt::SetDefaultFloatArray(m_pubHandle, defaultValue);
}
inline bool GenericPublisher::SetDefaultDoubleArray(
wpi::span<const double> defaultValue) {
std::span<const double> defaultValue) {
return nt::SetDefaultDoubleArray(m_pubHandle, defaultValue);
}
inline bool GenericPublisher::SetDefaultStringArray(
wpi::span<const std::string> defaultValue) {
std::span<const std::string> defaultValue) {
return nt::SetDefaultStringArray(m_pubHandle, defaultValue);
}

View File

@@ -4,10 +4,9 @@
#pragma once
#include <span>
#include <string_view>
#include <wpi/span.h>
#include "networktables/NetworkTableInstance.h"
#include "ntcore_cpp.h"
@@ -30,8 +29,8 @@ class MultiSubscriber final {
* @param options subscriber options
*/
MultiSubscriber(NetworkTableInstance inst,
wpi::span<const std::string_view> prefixes,
wpi::span<const PubSubOption> options = {});
std::span<const std::string_view> prefixes,
std::span<const PubSubOption> options = {});
MultiSubscriber(const MultiSubscriber&) = delete;
MultiSubscriber& operator=(const MultiSubscriber&) = delete;

View File

@@ -9,8 +9,8 @@
namespace nt {
inline MultiSubscriber::MultiSubscriber(
NetworkTableInstance inst, wpi::span<const std::string_view> prefixes,
wpi::span<const PubSubOption> options)
NetworkTableInstance inst, std::span<const std::string_view> prefixes,
std::span<const PubSubOption> options)
: m_handle{::nt::SubscribeMultiple(inst.GetHandle(), prefixes, options)} {}
inline MultiSubscriber::MultiSubscriber(MultiSubscriber&& rhs)

View File

@@ -6,6 +6,7 @@
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <utility>
@@ -13,7 +14,6 @@
#include <wpi/StringMap.h>
#include <wpi/mutex.h>
#include <wpi/span.h>
#include "networktables/NetworkTableEntry.h"
#include "ntcore_c.h"
@@ -400,7 +400,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::span<const int> value);
bool PutBooleanArray(std::string_view key, std::span<const int> value);
/**
* Gets the current value in the table, setting it if it does not exist.
@@ -410,7 +410,7 @@ class NetworkTable final {
* @return False if the table key exists with a different type
*/
bool SetDefaultBooleanArray(std::string_view key,
wpi::span<const int> defaultValue);
std::span<const int> defaultValue);
/**
* Returns the boolean array the key maps to. If the key does not exist or is
@@ -429,7 +429,7 @@ class NetworkTable final {
* non-zero value is true.
*/
std::vector<int> GetBooleanArray(std::string_view key,
wpi::span<const int> defaultValue) const;
std::span<const int> defaultValue) const;
/**
* Put a number array in the table
@@ -438,7 +438,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::span<const double> value);
bool PutNumberArray(std::string_view key, std::span<const double> value);
/**
* Gets the current value in the table, setting it if it does not exist.
@@ -448,7 +448,7 @@ class NetworkTable final {
* @returns False if the table key exists with a different type
*/
bool SetDefaultNumberArray(std::string_view key,
wpi::span<const double> defaultValue);
std::span<const double> defaultValue);
/**
* Returns the number array the key maps to. If the key does not exist or is
@@ -463,7 +463,7 @@ class NetworkTable final {
* concern, use GetValue() instead.
*/
std::vector<double> GetNumberArray(
std::string_view key, wpi::span<const double> defaultValue) const;
std::string_view key, std::span<const double> defaultValue) const;
/**
* Put a string array in the table
@@ -472,7 +472,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::span<const std::string> value);
bool PutStringArray(std::string_view key, std::span<const std::string> value);
/**
* Gets the current value in the table, setting it if it does not exist.
@@ -482,7 +482,7 @@ class NetworkTable final {
* @returns False if the table key exists with a different type
*/
bool SetDefaultStringArray(std::string_view key,
wpi::span<const std::string> defaultValue);
std::span<const std::string> defaultValue);
/**
* Returns the string array the key maps to. If the key does not exist or is
@@ -497,7 +497,7 @@ class NetworkTable final {
* concern, use GetValue() instead.
*/
std::vector<std::string> GetStringArray(
std::string_view key, wpi::span<const std::string> defaultValue) const;
std::string_view key, std::span<const std::string> defaultValue) const;
/**
* Put a raw value (byte array) in the table
@@ -506,7 +506,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 PutRaw(std::string_view key, wpi::span<const uint8_t> value);
bool PutRaw(std::string_view key, std::span<const uint8_t> value);
/**
* Gets the current value in the table, setting it if it does not exist.
@@ -516,7 +516,7 @@ class NetworkTable final {
* @return False if the table key exists with a different type
*/
bool SetDefaultRaw(std::string_view key,
wpi::span<const uint8_t> defaultValue);
std::span<const uint8_t> defaultValue);
/**
* Returns the raw value (byte array) the key maps to. If the key does not
@@ -531,7 +531,7 @@ class NetworkTable final {
* concern, use GetValue() instead.
*/
std::vector<uint8_t> GetRaw(std::string_view key,
wpi::span<const uint8_t> defaultValue) const;
std::span<const uint8_t> defaultValue) const;
/**
* Put a value in the table

View File

@@ -8,12 +8,12 @@
#include <initializer_list>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <vector>
#include <wpi/deprecated.h>
#include <wpi/span.h>
#include "networktables/NetworkTableType.h"
#include "networktables/NetworkTableValue.h"
@@ -170,7 +170,7 @@ class NetworkTableEntry final {
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
std::vector<uint8_t> GetRaw(wpi::span<const uint8_t> defaultValue) const;
std::vector<uint8_t> GetRaw(std::span<const uint8_t> defaultValue) const;
/**
* Gets the entry's value as a boolean array. If the entry does not exist
@@ -186,7 +186,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::span<const int> defaultValue) const;
std::vector<int> GetBooleanArray(std::span<const int> defaultValue) const;
/**
* Gets the entry's value as a integer array. If the entry does not exist
@@ -199,7 +199,7 @@ class NetworkTableEntry final {
* concern, use GetValue() instead.
*/
std::vector<int64_t> GetIntegerArray(
wpi::span<const int64_t> defaultValue) const;
std::span<const int64_t> defaultValue) const;
/**
* Gets the entry's value as a float array. If the entry does not exist
@@ -211,7 +211,7 @@ class NetworkTableEntry final {
* @note This makes a copy of the array. If the overhead of this is a
* concern, use GetValue() instead.
*/
std::vector<float> GetFloatArray(wpi::span<const float> defaultValue) const;
std::vector<float> GetFloatArray(std::span<const float> defaultValue) const;
/**
* Gets the entry's value as a double array. If the entry does not exist
@@ -224,7 +224,7 @@ class NetworkTableEntry final {
* concern, use GetValue() instead.
*/
std::vector<double> GetDoubleArray(
wpi::span<const double> defaultValue) const;
std::span<const double> defaultValue) const;
/**
* Gets the entry's value as a string array. If the entry does not exist
@@ -237,7 +237,7 @@ class NetworkTableEntry final {
* concern, use GetValue() instead.
*/
std::vector<std::string> GetStringArray(
wpi::span<const std::string> defaultValue) const;
std::span<const std::string> defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
@@ -303,7 +303,7 @@ class NetworkTableEntry final {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultRaw(wpi::span<const uint8_t> defaultValue);
bool SetDefaultRaw(std::span<const uint8_t> defaultValue);
/**
* Sets the entry's value if it does not exist.
@@ -311,7 +311,7 @@ class NetworkTableEntry final {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultBooleanArray(wpi::span<const int> defaultValue);
bool SetDefaultBooleanArray(std::span<const int> defaultValue);
/**
* Sets the entry's value if it does not exist.
@@ -319,7 +319,7 @@ class NetworkTableEntry final {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultIntegerArray(wpi::span<const int64_t> defaultValue);
bool SetDefaultIntegerArray(std::span<const int64_t> defaultValue);
/**
* Sets the entry's value if it does not exist.
@@ -327,7 +327,7 @@ class NetworkTableEntry final {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultFloatArray(wpi::span<const float> defaultValue);
bool SetDefaultFloatArray(std::span<const float> defaultValue);
/**
* Sets the entry's value if it does not exist.
@@ -335,7 +335,7 @@ class NetworkTableEntry final {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultDoubleArray(wpi::span<const double> defaultValue);
bool SetDefaultDoubleArray(std::span<const double> defaultValue);
/**
* Sets the entry's value if it does not exist.
@@ -343,7 +343,7 @@ class NetworkTableEntry final {
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
bool SetDefaultStringArray(wpi::span<const std::string> defaultValue);
bool SetDefaultStringArray(std::span<const std::string> defaultValue);
/**
* Sets the entry's value.
@@ -405,7 +405,7 @@ class NetworkTableEntry final {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetRaw(wpi::span<const uint8_t> value, int64_t time = 0);
bool SetRaw(std::span<const uint8_t> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -414,7 +414,7 @@ class NetworkTableEntry final {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetBooleanArray(wpi::span<const bool> value, int64_t time = 0);
bool SetBooleanArray(std::span<const bool> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -423,7 +423,7 @@ class NetworkTableEntry final {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetBooleanArray(wpi::span<const int> value, int64_t time = 0);
bool SetBooleanArray(std::span<const int> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -432,7 +432,7 @@ class NetworkTableEntry final {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetIntegerArray(wpi::span<const int64_t> value, int64_t time = 0);
bool SetIntegerArray(std::span<const int64_t> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -441,7 +441,7 @@ class NetworkTableEntry final {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetFloatArray(wpi::span<const float> value, int64_t time = 0);
bool SetFloatArray(std::span<const float> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -450,7 +450,7 @@ class NetworkTableEntry final {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetDoubleArray(wpi::span<const double> value, int64_t time = 0);
bool SetDoubleArray(std::span<const double> value, int64_t time = 0);
/**
* Sets the entry's value.
@@ -459,7 +459,7 @@ class NetworkTableEntry final {
* @param time the timestamp to set (0 = nt::Now())
* @return False if the entry exists with a different type
*/
bool SetStringArray(wpi::span<const std::string> value, int64_t time = 0);
bool SetStringArray(std::span<const std::string> value, int64_t time = 0);
/**
* Sets flags.

View File

@@ -70,32 +70,32 @@ inline std::string NetworkTableEntry::GetString(
}
inline std::vector<uint8_t> NetworkTableEntry::GetRaw(
wpi::span<const uint8_t> defaultValue) const {
std::span<const uint8_t> defaultValue) const {
return nt::GetRaw(m_handle, defaultValue);
}
inline std::vector<int> NetworkTableEntry::GetBooleanArray(
wpi::span<const int> defaultValue) const {
std::span<const int> defaultValue) const {
return nt::GetBooleanArray(m_handle, defaultValue);
}
inline std::vector<int64_t> NetworkTableEntry::GetIntegerArray(
wpi::span<const int64_t> defaultValue) const {
std::span<const int64_t> defaultValue) const {
return nt::GetIntegerArray(m_handle, defaultValue);
}
inline std::vector<float> NetworkTableEntry::GetFloatArray(
wpi::span<const float> defaultValue) const {
std::span<const float> defaultValue) const {
return nt::GetFloatArray(m_handle, defaultValue);
}
inline std::vector<double> NetworkTableEntry::GetDoubleArray(
wpi::span<const double> defaultValue) const {
std::span<const double> defaultValue) const {
return nt::GetDoubleArray(m_handle, defaultValue);
}
inline std::vector<std::string> NetworkTableEntry::GetStringArray(
wpi::span<const std::string> defaultValue) const {
std::span<const std::string> defaultValue) const {
return nt::GetStringArray(m_handle, defaultValue);
}
@@ -128,32 +128,32 @@ inline bool NetworkTableEntry::SetDefaultString(std::string_view defaultValue) {
}
inline bool NetworkTableEntry::SetDefaultRaw(
wpi::span<const uint8_t> defaultValue) {
std::span<const uint8_t> defaultValue) {
return nt::SetDefaultRaw(m_handle, defaultValue);
}
inline bool NetworkTableEntry::SetDefaultBooleanArray(
wpi::span<const int> defaultValue) {
std::span<const int> defaultValue) {
return nt::SetDefaultBooleanArray(m_handle, defaultValue);
}
inline bool NetworkTableEntry::SetDefaultIntegerArray(
wpi::span<const int64_t> defaultValue) {
std::span<const int64_t> defaultValue) {
return nt::SetDefaultIntegerArray(m_handle, defaultValue);
}
inline bool NetworkTableEntry::SetDefaultFloatArray(
wpi::span<const float> defaultValue) {
std::span<const float> defaultValue) {
return nt::SetDefaultFloatArray(m_handle, defaultValue);
}
inline bool NetworkTableEntry::SetDefaultDoubleArray(
wpi::span<const double> defaultValue) {
std::span<const double> defaultValue) {
return nt::SetDefaultDoubleArray(m_handle, defaultValue);
}
inline bool NetworkTableEntry::SetDefaultStringArray(
wpi::span<const std::string> defaultValue) {
std::span<const std::string> defaultValue) {
return nt::SetDefaultStringArray(m_handle, defaultValue);
}
@@ -181,38 +181,38 @@ inline bool NetworkTableEntry::SetString(std::string_view value, int64_t time) {
return nt::SetString(m_handle, value, time);
}
inline bool NetworkTableEntry::SetRaw(wpi::span<const uint8_t> value,
inline bool NetworkTableEntry::SetRaw(std::span<const uint8_t> value,
int64_t time) {
return nt::SetRaw(m_handle, value, time);
}
inline bool NetworkTableEntry::SetBooleanArray(wpi::span<const bool> value,
inline bool NetworkTableEntry::SetBooleanArray(std::span<const bool> value,
int64_t time) {
return SetEntryValue(m_handle, Value::MakeBooleanArray(value, time));
}
inline bool NetworkTableEntry::SetBooleanArray(wpi::span<const int> value,
inline bool NetworkTableEntry::SetBooleanArray(std::span<const int> value,
int64_t time) {
return nt::SetBooleanArray(m_handle, value, time);
}
inline bool NetworkTableEntry::SetIntegerArray(wpi::span<const int64_t> value,
inline bool NetworkTableEntry::SetIntegerArray(std::span<const int64_t> value,
int64_t time) {
return nt::SetIntegerArray(m_handle, value, time);
}
inline bool NetworkTableEntry::SetFloatArray(wpi::span<const float> value,
inline bool NetworkTableEntry::SetFloatArray(std::span<const float> value,
int64_t time) {
return nt::SetFloatArray(m_handle, value, time);
}
inline bool NetworkTableEntry::SetDoubleArray(wpi::span<const double> value,
inline bool NetworkTableEntry::SetDoubleArray(std::span<const double> value,
int64_t time) {
return nt::SetDoubleArray(m_handle, value, time);
}
inline bool NetworkTableEntry::SetStringArray(
wpi::span<const std::string> value, int64_t time) {
std::span<const std::string> value, int64_t time) {
return nt::SetStringArray(m_handle, value, time);
}

View File

@@ -6,13 +6,12 @@
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <wpi/span.h>
#include "networktables/NetworkTable.h"
#include "networktables/NetworkTableEntry.h"
#include "ntcore_c.h"
@@ -283,7 +282,7 @@ class NetworkTableInstance final {
* @return Array of topic handles.
*/
std::vector<Topic> GetTopics(std::string_view prefix,
wpi::span<std::string_view> types);
std::span<std::string_view> types);
/**
* Get Topic Information about multiple topics.
@@ -336,7 +335,7 @@ class NetworkTableInstance final {
* @return Array of topic information.
*/
std::vector<TopicInfo> GetTopicInfo(std::string_view prefix,
wpi::span<std::string_view> types);
std::span<std::string_view> types);
/**
* Gets the entry for a key.
@@ -466,7 +465,7 @@ class NetworkTableInstance final {
* @param servers array of server address and port pairs
*/
void SetServer(
wpi::span<const std::pair<std::string_view, unsigned int>> servers);
std::span<const std::pair<std::string_view, unsigned int>> servers);
/**
* Sets server addresses and port for client (without restarting client).
@@ -475,7 +474,7 @@ class NetworkTableInstance final {
* @param servers array of server names
* @param port port to communicate over (0 = default)
*/
void SetServer(wpi::span<const std::string_view> servers,
void SetServer(std::span<const std::string_view> servers,
unsigned int port = 0);
/**

View File

@@ -54,7 +54,7 @@ inline std::vector<Topic> NetworkTableInstance::GetTopics(
}
inline std::vector<Topic> NetworkTableInstance::GetTopics(
std::string_view prefix, wpi::span<std::string_view> types) {
std::string_view prefix, std::span<std::string_view> types) {
auto handles = ::nt::GetTopics(m_handle, prefix, types);
return {handles.begin(), handles.end()};
}
@@ -74,7 +74,7 @@ inline std::vector<TopicInfo> NetworkTableInstance::GetTopicInfo(
}
inline std::vector<TopicInfo> NetworkTableInstance::GetTopicInfo(
std::string_view prefix, wpi::span<std::string_view> types) {
std::string_view prefix, std::span<std::string_view> types) {
return ::nt::GetTopicInfo(m_handle, prefix, types);
}
@@ -132,7 +132,7 @@ inline void NetworkTableInstance::SetServer(const char* server_name,
}
inline void NetworkTableInstance::SetServer(
wpi::span<const std::pair<std::string_view, unsigned int>> servers) {
std::span<const std::pair<std::string_view, unsigned int>> servers) {
::nt::SetServer(m_handle, servers);
}

View File

@@ -9,14 +9,13 @@
#include <cassert>
#include <initializer_list>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <vector>
#include <wpi/span.h>
#include "ntcore_c.h"
namespace nt {
@@ -235,7 +234,7 @@ class Value final {
*
* @return The raw value.
*/
wpi::span<const uint8_t> GetRaw() const {
std::span<const uint8_t> GetRaw() const {
assert(m_val.type == NT_RAW);
return {m_val.data.v_raw.data, m_val.data.v_raw.size};
}
@@ -245,7 +244,7 @@ class Value final {
*
* @return The boolean array value.
*/
wpi::span<const int> GetBooleanArray() const {
std::span<const int> GetBooleanArray() const {
assert(m_val.type == NT_BOOLEAN_ARRAY);
return {m_val.data.arr_boolean.arr, m_val.data.arr_boolean.size};
}
@@ -255,7 +254,7 @@ class Value final {
*
* @return The integer array value.
*/
wpi::span<const int64_t> GetIntegerArray() const {
std::span<const int64_t> GetIntegerArray() const {
assert(m_val.type == NT_INTEGER_ARRAY);
return {m_val.data.arr_int.arr, m_val.data.arr_int.size};
}
@@ -265,7 +264,7 @@ class Value final {
*
* @return The float array value.
*/
wpi::span<const float> GetFloatArray() const {
std::span<const float> GetFloatArray() const {
assert(m_val.type == NT_FLOAT_ARRAY);
return {m_val.data.arr_float.arr, m_val.data.arr_float.size};
}
@@ -275,7 +274,7 @@ class Value final {
*
* @return The double array value.
*/
wpi::span<const double> GetDoubleArray() const {
std::span<const double> GetDoubleArray() const {
assert(m_val.type == NT_DOUBLE_ARRAY);
return {m_val.data.arr_double.arr, m_val.data.arr_double.size};
}
@@ -285,7 +284,7 @@ class Value final {
*
* @return The string array value.
*/
wpi::span<const std::string> GetStringArray() const {
std::span<const std::string> GetStringArray() const {
assert(m_val.type == NT_STRING_ARRAY);
return *static_cast<std::vector<std::string>*>(m_storage.get());
}
@@ -397,7 +396,7 @@ class Value final {
* time)
* @return The entry value
*/
static Value MakeRaw(wpi::span<const uint8_t> value, int64_t time = 0) {
static Value MakeRaw(std::span<const uint8_t> value, int64_t time = 0) {
Value val{NT_RAW, time, private_init{}};
auto data =
std::make_shared<std::vector<uint8_t>>(value.begin(), value.end());
@@ -434,7 +433,7 @@ class Value final {
* time)
* @return The entry value
*/
static Value MakeBooleanArray(wpi::span<const bool> value, int64_t time = 0);
static Value MakeBooleanArray(std::span<const bool> value, int64_t time = 0);
/**
* Creates a boolean array entry value.
@@ -446,7 +445,7 @@ class Value final {
*/
static Value MakeBooleanArray(std::initializer_list<bool> value,
int64_t time = 0) {
return MakeBooleanArray(wpi::span(value.begin(), value.end()), time);
return MakeBooleanArray(std::span(value.begin(), value.end()), time);
}
/**
@@ -457,7 +456,7 @@ class Value final {
* time)
* @return The entry value
*/
static Value MakeBooleanArray(wpi::span<const int> value, int64_t time = 0);
static Value MakeBooleanArray(std::span<const int> value, int64_t time = 0);
/**
* Creates a boolean array entry value.
@@ -469,7 +468,7 @@ class Value final {
*/
static Value MakeBooleanArray(std::initializer_list<int> value,
int64_t time = 0) {
return MakeBooleanArray(wpi::span(value.begin(), value.end()), time);
return MakeBooleanArray(std::span(value.begin(), value.end()), time);
}
/**
@@ -480,7 +479,7 @@ class Value final {
* time)
* @return The entry value
*/
static Value MakeIntegerArray(wpi::span<const int64_t> value,
static Value MakeIntegerArray(std::span<const int64_t> value,
int64_t time = 0);
/**
@@ -493,7 +492,7 @@ class Value final {
*/
static Value MakeIntegerArray(std::initializer_list<int64_t> value,
int64_t time = 0) {
return MakeIntegerArray(wpi::span(value.begin(), value.end()), time);
return MakeIntegerArray(std::span(value.begin(), value.end()), time);
}
/**
@@ -504,7 +503,7 @@ class Value final {
* time)
* @return The entry value
*/
static Value MakeFloatArray(wpi::span<const float> value, int64_t time = 0);
static Value MakeFloatArray(std::span<const float> value, int64_t time = 0);
/**
* Creates a float array entry value.
@@ -516,7 +515,7 @@ class Value final {
*/
static Value MakeFloatArray(std::initializer_list<float> value,
int64_t time = 0) {
return MakeFloatArray(wpi::span(value.begin(), value.end()), time);
return MakeFloatArray(std::span(value.begin(), value.end()), time);
}
/**
@@ -527,7 +526,7 @@ class Value final {
* time)
* @return The entry value
*/
static Value MakeDoubleArray(wpi::span<const double> value, int64_t time = 0);
static Value MakeDoubleArray(std::span<const double> value, int64_t time = 0);
/**
* Creates a double array entry value.
@@ -539,7 +538,7 @@ class Value final {
*/
static Value MakeDoubleArray(std::initializer_list<double> value,
int64_t time = 0) {
return MakeDoubleArray(wpi::span(value.begin(), value.end()), time);
return MakeDoubleArray(std::span(value.begin(), value.end()), time);
}
/**
@@ -550,7 +549,7 @@ class Value final {
* time)
* @return The entry value
*/
static Value MakeStringArray(wpi::span<const std::string> value,
static Value MakeStringArray(std::span<const std::string> value,
int64_t time = 0);
/**
@@ -563,7 +562,7 @@ class Value final {
*/
static Value MakeStringArray(std::initializer_list<std::string> value,
int64_t time = 0) {
return MakeStringArray(wpi::span(value.begin(), value.end()), time);
return MakeStringArray(std::span(value.begin(), value.end()), time);
}
/**

View File

@@ -6,6 +6,7 @@
#include <stdint.h>
#include <span>
#include <string>
#include <string_view>
#include <utility>
@@ -170,7 +171,7 @@ class Topic {
* @return subscriber
*/
[[nodiscard]] GenericSubscriber GenericSubscribe(
wpi::span<const PubSubOption> options = {});
std::span<const PubSubOption> options = {});
/**
* Create a new subscriber to the topic.
@@ -187,7 +188,7 @@ class Topic {
* @return subscriber
*/
[[nodiscard]] GenericSubscriber GenericSubscribe(
std::string_view typeString, wpi::span<const PubSubOption> options = {});
std::string_view typeString, std::span<const PubSubOption> options = {});
/**
* Create a new publisher to the topic.
@@ -206,7 +207,7 @@ class Topic {
* @return publisher
*/
[[nodiscard]] GenericPublisher GenericPublish(
std::string_view typeString, wpi::span<const PubSubOption> options = {});
std::string_view typeString, std::span<const PubSubOption> options = {});
/**
* Create a new publisher to the topic, with type string and initial
@@ -228,7 +229,7 @@ class Topic {
*/
[[nodiscard]] GenericPublisher GenericPublishEx(
std::string_view typeString, const wpi::json& properties,
wpi::span<const PubSubOption> options = {});
std::span<const PubSubOption> options = {});
/**
* Create a new generic entry for the topic.
@@ -249,7 +250,7 @@ class Topic {
* @return entry
*/
[[nodiscard]] GenericEntry GetGenericEntry(
wpi::span<const PubSubOption> options = {});
std::span<const PubSubOption> options = {});
/**
* Create a new generic entry for the topic.
@@ -271,7 +272,7 @@ class Topic {
* @return entry
*/
[[nodiscard]] GenericEntry GetGenericEntry(
std::string_view typeString, wpi::span<const PubSubOption> options = {});
std::string_view typeString, std::span<const PubSubOption> options = {});
/**
* Equality operator. Returns true if both instances refer to the same

View File

@@ -5,11 +5,10 @@
#pragma once
#include <functional>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/span.h>
#include "ntcore_cpp.h"
namespace nt {
@@ -83,7 +82,7 @@ class TopicListener final {
* @param listener Listener function
*/
TopicListener(NetworkTableInstance inst,
wpi::span<const std::string_view> prefixes, unsigned int mask,
std::span<const std::string_view> prefixes, unsigned int mask,
std::function<void(const TopicNotification&)> listener);
/**
@@ -183,7 +182,7 @@ class TopicListenerPoller final {
* @param mask Bitmask of TopicListenerFlags values
* @return Listener handle
*/
NT_TopicListener Add(wpi::span<const std::string_view> prefixes,
NT_TopicListener Add(std::span<const std::string_view> prefixes,
unsigned int mask);
/**

View File

@@ -4,12 +4,11 @@
#pragma once
#include <span>
#include <string_view>
#include <utility>
#include <vector>
#include <wpi/span.h>
#include "networktables/MultiSubscriber.h"
#include "networktables/NetworkTableEntry.h"
#include "networktables/NetworkTableInstance.h"
@@ -20,7 +19,7 @@
namespace nt {
inline TopicListener::TopicListener(
NetworkTableInstance inst, wpi::span<const std::string_view> prefixes,
NetworkTableInstance inst, std::span<const std::string_view> prefixes,
unsigned int mask, std::function<void(const TopicNotification&)> listener)
: m_handle{AddTopicListener(inst.GetHandle(), prefixes, mask, listener)} {}
@@ -81,7 +80,7 @@ inline TopicListenerPoller::~TopicListenerPoller() {
}
inline NT_TopicListener TopicListenerPoller::Add(
wpi::span<const std::string_view> prefixes, unsigned int mask) {
std::span<const std::string_view> prefixes, unsigned int mask) {
return nt::AddPolledTopicListener(m_handle, prefixes, mask);
}

Some files were not shown because too many files have changed in this diff Show More