diff options
author | Abseil Team <absl-team@google.com> | 2023-12-20 14:06:23 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-12-20 14:07:38 -0800 |
commit | 72d7a159bf04ca26649928f4531d9af5e02e8f28 (patch) | |
tree | 457f1eec516deec77398b8972208d17775045289 /absl/strings/str_split.h | |
parent | 7a1898a04fb3ab83b869e7967ddd7721696490a3 (diff) | |
download | abseil-72d7a159bf04ca26649928f4531d9af5e02e8f28.tar.gz abseil-72d7a159bf04ca26649928f4531d9af5e02e8f28.tar.bz2 abseil-72d7a159bf04ca26649928f4531d9af5e02e8f28.zip |
Added ByAsciiWhitespace to str_split library.
PiperOrigin-RevId: 592653487
Change-Id: Iddd2f484807cb02dd2ee8bba26c22d196be02c88
Diffstat (limited to 'absl/strings/str_split.h')
-rw-r--r-- | absl/strings/str_split.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/absl/strings/str_split.h b/absl/strings/str_split.h index 7bbb68a3..87540278 100644 --- a/absl/strings/str_split.h +++ b/absl/strings/str_split.h @@ -130,6 +130,24 @@ class ByString { const std::string delimiter_; }; +// ByAsciiWhitespace +// +// A sub-string delimiter that splits by ASCII whitespace +// (space, tab, vertical tab, formfeed, linefeed, or carriage return). +// Note: you probably want to use absl::SkipEmpty() as well! +// +// This class is equivalent to ByAnyChar with ASCII whitespace chars. +// +// Example: +// +// std::vector<std::string> v = absl::StrSplit( +// "a b\tc\n d \n", absl::ByAsciiWhitespace(), absl::SkipEmpty()); +// // v[0] == "a", v[1] == "b", v[2] == "c", v[3] == "d" +class ByAsciiWhitespace { + public: + absl::string_view Find(absl::string_view text, size_t pos) const; +}; + // ByChar // // A single character delimiter. `ByChar` is functionally equivalent to a |