diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-02 04:09:58 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-02 04:09:58 +0000 |
commit | 0b7c092f7f5b196fd9085f1ab796a0c9ac9473a6 (patch) | |
tree | 53272fae82210fbf553bb3a1a0256fba5b851368 /base/string_util.cc | |
parent | b112a4cc460212188d353b995a055f6e14029ba3 (diff) | |
download | chromium_src-0b7c092f7f5b196fd9085f1ab796a0c9ac9473a6.zip chromium_src-0b7c092f7f5b196fd9085f1ab796a0c9ac9473a6.tar.gz chromium_src-0b7c092f7f5b196fd9085f1ab796a0c9ac9473a6.tar.bz2 |
Introduce UrlPattern. This is basically me resuming work on
issue 14106, but as it is a complete rewrite, I have started
a new issue.
I also added supporting JoinString() and ReplaceAll()
utility functions.
Review URL: http://codereview.chromium.org/19704
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9031 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.cc')
-rw-r--r-- | base/string_util.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/base/string_util.cc b/base/string_util.cc index 63fec40..4ba8c4b 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -1140,6 +1140,31 @@ void SplitStringDontTrim(const std::string& str, SplitStringT(str, s, false, r); } +template<typename STR> +static STR JoinStringT(const std::vector<STR>& parts, + typename STR::value_type sep) { + if (parts.size() == 0) return STR(); + + STR result(parts[0]); + typename std::vector<STR>::const_iterator iter = parts.begin(); + ++iter; + + for (; iter != parts.end(); ++iter) { + result += sep; + result += *iter; + } + + return result; +} + +std::string JoinString(const std::vector<std::string>& parts, char sep) { + return JoinStringT(parts, sep); +} + +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) { const size_t length = str.length(); |