Introduce a variant of rtc::split that returns a vector of string_view

Intended to be compatible with absl::StrSplit, but without the binary
cost of that dependency.

Bug: webrtc:13579
Change-Id: I167726903d74b8d5f299886cfb3e5d60610ddb93
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247185
Reviewed-by: Ali Tofigh <alito@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35780}
This commit is contained in:
Niels Möller
2022-01-24 14:15:03 +01:00
committed by WebRTC LUCI CQ
parent 3a88dd99c7
commit 2d3186e001
6 changed files with 31 additions and 17 deletions

View File

@ -62,7 +62,10 @@ size_t hex_decode_with_delimiter(char* buffer,
std::string join(const std::vector<std::string>& source, char delimiter);
// Splits the source string into multiple fields separated by delimiter,
// with duplicates of delimiter creating empty fields.
// with duplicates of delimiter creating empty fields. Empty input produces a
// single, empty, field.
std::vector<absl::string_view> split(absl::string_view source, char delimiter);
size_t split(absl::string_view source,
char delimiter,
std::vector<std::string>* fields);