Index: base/strings/string_split.h |
diff --git a/base/strings/string_split.h b/base/strings/string_split.h |
index 2a0c79561b85cca9561bbc80cf8e709e7ed2eace..ec9f24604a6339051f9aa9086b3460c71e983559 100644 |
--- a/base/strings/string_split.h |
+++ b/base/strings/string_split.h |
@@ -101,6 +101,29 @@ BASE_EXPORT void SplitStringUsingSubstr(StringPiece input, |
StringPiece delimiter, |
std::vector<std::string>* result); |
+// Like SplitStringUsingSubstr above except it returns a vector of StringPieces |
+// which reference the original buffer without copying. Although you have to be |
+// careful to keep the original string unmodified, this provides an efficient |
+// way to iterate through tokens in a string. |
+// |
+// To iterate through all newline-separated tokens in an input string: |
+// |
+// for (const auto& cur : |
+// base::SplitStringUsingSubstr(input, "\r\n", |
+// base::KEEP_WHITESPACE, |
+// base::SPLIT_WANT_NONEMPTY)) { |
+// ... |
+BASE_EXPORT std::vector<StringPiece16> SplitStringPieceUsingSubstr( |
+ StringPiece16 input, |
+ StringPiece16 delimiter, |
+ WhitespaceHandling whitespace, |
+ SplitResult result_type); |
+BASE_EXPORT std::vector<StringPiece> SplitStringPieceUsingSubstr( |
+ StringPiece input, |
+ StringPiece delimiter, |
+ WhitespaceHandling whitespace, |
+ SplitResult result_type); |
+ |
} // namespace base |
#endif // BASE_STRINGS_STRING_SPLIT_H_ |