mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpiutil] StringExtras: Add substr() (#3742)
Unlike std::string and std::string_view, this substr() allows a start greater than the length of the string, in which case an empty string is returned. This matches llvm::StringRef behavior.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "AvahiClient.h"
|
||||
#include "wpi/SmallString.h"
|
||||
#include "wpi/StringExtras.h"
|
||||
#include "wpi/mutex.h"
|
||||
|
||||
using namespace wpi;
|
||||
@@ -61,8 +62,9 @@ static void ResolveCallback(AvahiServiceResolver* r, AvahiIfIndex interface,
|
||||
// Todo make this just do key
|
||||
continue;
|
||||
}
|
||||
std::string_view key = value.substr(0, splitIndex);
|
||||
value = value.substr(splitIndex + 1, value.size() - splitIndex - 1);
|
||||
std::string_view key = wpi::substr(value, 0, splitIndex);
|
||||
value =
|
||||
wpi::substr(value, splitIndex + 1, value.size() - splitIndex - 1);
|
||||
data.txt.emplace_back(std::pair<std::string, std::string>{key, value});
|
||||
}
|
||||
wpi::SmallString<256> outputHostName;
|
||||
|
||||
Reference in New Issue
Block a user