mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Use std::string_view and fmtlib across all libraries (#3402)
- Twine, StringRef, Format, and NativeFormatting have been removed - Logging now uses fmtlib style formatting - Nearly all uses of wpi::outs/errs have been replaced with fmt::print() or std::puts()/std::fputs() (for unformatted strings). - A wpi/fmt/raw_ostream.h header has been added to enable fmt::print() with wpi::raw_ostream
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <wpi/StringExtras.h>
|
||||
|
||||
#include "SimDeviceDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
@@ -71,7 +73,7 @@ void SimDeviceData::SetDeviceEnabled(const char* prefix, bool enabled) {
|
||||
bool SimDeviceData::IsDeviceEnabled(const char* name) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
for (const auto& elem : m_prefixEnabled) {
|
||||
if (wpi::StringRef{name}.startswith(elem.first)) {
|
||||
if (wpi::starts_with(name, elem.first)) {
|
||||
return elem.second;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +85,7 @@ HAL_SimDeviceHandle SimDeviceData::CreateDevice(const char* name) {
|
||||
|
||||
// don't create if disabled
|
||||
for (const auto& elem : m_prefixEnabled) {
|
||||
if (wpi::StringRef{name}.startswith(elem.first)) {
|
||||
if (wpi::starts_with(name, elem.first)) {
|
||||
if (elem.second) {
|
||||
break; // enabled
|
||||
}
|
||||
@@ -272,7 +274,7 @@ int32_t SimDeviceData::RegisterDeviceCreatedCallback(
|
||||
// initial notifications
|
||||
if (initialNotify) {
|
||||
for (auto&& device : m_devices) {
|
||||
if (wpi::StringRef{device->name}.startswith(prefix)) {
|
||||
if (wpi::starts_with(device->name, prefix)) {
|
||||
callback(device->name.c_str(), param, device->handle);
|
||||
}
|
||||
}
|
||||
@@ -332,7 +334,7 @@ void SimDeviceData::EnumerateDevices(const char* prefix, void* param,
|
||||
HALSIM_SimDeviceCallback callback) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
for (auto&& device : m_devices) {
|
||||
if (wpi::StringRef{device->name}.startswith(prefix)) {
|
||||
if (wpi::starts_with(device->name, prefix)) {
|
||||
callback(device->name.c_str(), param, device->handle);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user