mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[wpiutil] Change StringExtras split() to template (#7636)
It now calls back a function for each part rather than creating a SmallVector.
This commit is contained in:
@@ -1015,7 +1015,8 @@ void NetworkTablesModel::RebuildTreeImpl(std::vector<TreeNode>* tree,
|
||||
continue;
|
||||
}
|
||||
parts.clear();
|
||||
wpi::split(entry->info.name, parts, '/', -1, false);
|
||||
wpi::split(entry->info.name, '/', -1, false,
|
||||
[&](auto part) { parts.emplace_back(part); });
|
||||
|
||||
// ignore a raw "/" key
|
||||
if (parts.empty()) {
|
||||
|
||||
@@ -68,7 +68,8 @@ void NetworkTablesProvider::DisplayMenu() {
|
||||
wpi::SmallString<64> name;
|
||||
for (auto&& entry : m_viewEntries) {
|
||||
path.clear();
|
||||
wpi::split(entry->name, path, '/', -1, false);
|
||||
wpi::split(entry->name, '/', -1, false,
|
||||
[&](auto name) { path.emplace_back(name); });
|
||||
|
||||
bool fullDepth = true;
|
||||
int depth = 0;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <imgui.h>
|
||||
#include <imgui_stdlib.h>
|
||||
#include <ntcore_cpp.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
|
||||
#include "glass/Context.h"
|
||||
@@ -69,12 +68,10 @@ void NetworkTablesSettings::Thread::Main() {
|
||||
(team = wpi::parse_integer<unsigned int>(serverTeam, 10))) {
|
||||
nt::SetServerTeam(m_inst, team.value(), m_port);
|
||||
} else {
|
||||
wpi::SmallVector<std::string_view, 4> serverNames;
|
||||
std::vector<std::pair<std::string_view, unsigned int>> servers;
|
||||
wpi::split(serverTeam, serverNames, ',', -1, false);
|
||||
for (auto&& serverName : serverNames) {
|
||||
wpi::split(serverTeam, ',', -1, false, [&](auto serverName) {
|
||||
servers.emplace_back(serverName, m_port);
|
||||
}
|
||||
});
|
||||
nt::SetServer(m_inst, servers);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user