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

Unified Diff: base/strings/string_split.h

Issue 184233010: Cleanup SplitStringIntoKeyaluePairs implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | base/strings/string_split.cc » ('j') | base/strings/string_split.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/string_split.h
diff --git a/base/strings/string_split.h b/base/strings/string_split.h
index 7c27e4899da06681e2bde9487b17a41586132caa..55d8cb377edfa597c19173b0e1832b3ce478368f 100644
--- a/base/strings/string_split.h
+++ b/base/strings/string_split.h
@@ -23,6 +23,7 @@ namespace base {
BASE_EXPORT void SplitString(const string16& str,
char16 c,
std::vector<string16>* r);
+
// |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which
// the trailing byte of a multi-byte character can be in the ASCII range.
// UTF-8, and other single/multi-byte ASCII-compatible encodings are OK.
@@ -31,18 +32,16 @@ BASE_EXPORT void SplitString(const std::string& str,
char c,
std::vector<std::string>* r);
-BASE_EXPORT bool SplitStringIntoKeyValues(const std::string& line,
Mark Mentovai 2014/03/06 17:55:51 The CL description should say that this is going a
pneubeck (no reviews) 2014/03/07 17:12:11 Done.
- char key_value_delimiter,
- std::string* key,
- std::vector<std::string>* values);
-
-typedef std::vector<std::pair<std::string, std::string> > StringPairs;;
+typedef std::vector<std::pair<std::string, std::string> > StringPairs;
-BASE_EXPORT bool SplitStringIntoKeyValuePairs(
- const std::string& line,
- char key_value_delimiter,
- char key_value_pair_delimiter,
- StringPairs* key_value_pairs);
+// Splits |line| into key value pairs according to the given delimiters and
+// removes whitespace leading each key and trailing each value. Returns true
+// only if each pair has a non-empty key and value. |key_value_pairs| will
+// include ("","") pairs for entries without |key_value_delimiter|.
+BASE_EXPORT bool SplitStringIntoKeyValuePairs(const std::string& line,
+ char key_value_delimiter,
+ char key_value_pair_delimiter,
+ StringPairs* key_value_pairs);
// The same as SplitString, but use a substring delimiter instead of a char.
BASE_EXPORT void SplitStringUsingSubstr(const string16& str,
« no previous file with comments | « no previous file | base/strings/string_split.cc » ('j') | base/strings/string_split.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698