diff options
author | Dan Albert <danalbert@google.com> | 2015-03-19 13:24:26 -0700 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2015-03-23 10:23:11 -0700 |
commit | 47328c96d91ca71b57b8976df2df1fe51579a955 (patch) | |
tree | 149e519906cb870b960e7e48facd7222a7ec7232 /base/include | |
parent | d69a1c502e11d3be052d9c0bb20f0c7762428925 (diff) | |
download | system_core-47328c96d91ca71b57b8976df2df1fe51579a955.zip system_core-47328c96d91ca71b57b8976df2df1fe51579a955.tar.gz system_core-47328c96d91ca71b57b8976df2df1fe51579a955.tar.bz2 |
Update string Split API.
Return a new vector rather than appending to the parameter.
Delimiters are also a string rather than a character. Split on any
character in the string.
Change-Id: I039b332ace5578590df9e7ca0e8fa3db28db30a3
Diffstat (limited to 'base/include')
-rw-r--r-- | base/include/base/strings.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/base/include/base/strings.h b/base/include/base/strings.h index 5ddfbbd..ab56aad 100644 --- a/base/include/base/strings.h +++ b/base/include/base/strings.h @@ -23,10 +23,15 @@ namespace android { namespace base { -// Splits a string using the given separator character into a vector of strings. -// Empty strings will be omitted. -void Split(const std::string& s, char separator, - std::vector<std::string>* result); +// Splits a string into a vector of strings. +// +// The string is split at each occurence of a character in delimiters. +// +// Empty splits will be omitted. I.e. Split("a,,b", ",") -> {"a", "b"} +// +// The empty string is not a valid delimiter list. +std::vector<std::string> Split(const std::string& s, + const std::string& delimiters); // Trims whitespace off both ends of the given string. std::string Trim(const std::string& s); |