Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Unified Diff: base/string_util.cc

Issue 19704: Introduce UrlPattern. (Closed)
Patch Set: more feedback Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/string_util.cc
diff --git a/base/string_util.cc b/base/string_util.cc
index 63fec400b64a8b9d2e88752407580d70ee63cfde..a921442d99c443a00de6093aaf51922047eea596 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]);
+ 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();

Powered by Google App Engine
This is Rietveld 408576698