diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/string_util.cc | 14 | ||||
-rw-r--r-- | base/string_util.h | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/base/string_util.cc b/base/string_util.cc index ee0a9a5..c819373 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -1270,8 +1270,8 @@ std::wstring JoinString(const std::vector<std::wstring>& parts, wchar_t sep) { return JoinStringT(parts, sep); } -void SplitStringAlongWhitespace(const std::wstring& str, - std::vector<std::wstring>* result) { +template<typename STR> +void SplitStringAlongWhitespaceT(const STR& str, std::vector<STR>* result) { const size_t length = str.length(); if (!length) return; @@ -1310,6 +1310,16 @@ void SplitStringAlongWhitespace(const std::wstring& str, } } +void SplitStringAlongWhitespace(const std::wstring& str, + std::vector<std::wstring>* result) { + SplitStringAlongWhitespaceT(str, result); +} + +void SplitStringAlongWhitespace(const std::string& str, + std::vector<std::string>* result) { + SplitStringAlongWhitespaceT(str, result); +} + template<class StringType> StringType DoReplaceStringPlaceholders(const StringType& format_string, const std::vector<StringType>& subst, diff --git a/base/string_util.h b/base/string_util.h index c6b9fb1..5bacfcd 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -511,6 +511,8 @@ std::string JoinString(const std::vector<std::string>& parts, char s); // characters is added to result. void SplitStringAlongWhitespace(const std::wstring& str, std::vector<std::wstring>* result); +void SplitStringAlongWhitespace(const std::string& str, + std::vector<std::string>* result); // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively. // Additionally, $$ is replaced by $. The offsets parameter here can |