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

Side by Side Diff: base/strings/string_split.h

Issue 184233009: Extend SplitStringIntoKeyValuePairs unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test handling of newline char. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/strings/string_split_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_STRINGS_STRING_SPLIT_H_ 5 #ifndef BASE_STRINGS_STRING_SPLIT_H_
6 #define BASE_STRINGS_STRING_SPLIT_H_ 6 #define BASE_STRINGS_STRING_SPLIT_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 13 matching lines...) Expand all
24 char16 c, 24 char16 c,
25 std::vector<string16>* r); 25 std::vector<string16>* r);
26 // |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which 26 // |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which
27 // the trailing byte of a multi-byte character can be in the ASCII range. 27 // the trailing byte of a multi-byte character can be in the ASCII range.
28 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK. 28 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK.
29 // Note: |c| must be in the ASCII range. 29 // Note: |c| must be in the ASCII range.
30 BASE_EXPORT void SplitString(const std::string& str, 30 BASE_EXPORT void SplitString(const std::string& str,
31 char c, 31 char c,
32 std::vector<std::string>* r); 32 std::vector<std::string>* r);
33 33
34 BASE_EXPORT bool SplitStringIntoKeyValues(const std::string& line,
35 char key_value_delimiter,
36 std::string* key,
37 std::vector<std::string>* values);
38
39 typedef std::vector<std::pair<std::string, std::string> > StringPairs;; 34 typedef std::vector<std::pair<std::string, std::string> > StringPairs;;
40 35
41 BASE_EXPORT bool SplitStringIntoKeyValuePairs( 36 BASE_EXPORT bool SplitStringIntoKeyValuePairs(
42 const std::string& line, 37 const std::string& line,
43 char key_value_delimiter, 38 char key_value_delimiter,
44 char key_value_pair_delimiter, 39 char key_value_pair_delimiter,
45 StringPairs* key_value_pairs); 40 StringPairs* key_value_pairs);
46 41
47 // The same as SplitString, but use a substring delimiter instead of a char. 42 // The same as SplitString, but use a substring delimiter instead of a char.
48 BASE_EXPORT void SplitStringUsingSubstr(const string16& str, 43 BASE_EXPORT void SplitStringUsingSubstr(const string16& str,
(...skipping 25 matching lines...) Expand all
74 // characters defined by HTML 5). Each contiguous block of non-whitespace 69 // characters defined by HTML 5). Each contiguous block of non-whitespace
75 // characters is added to result. 70 // characters is added to result.
76 BASE_EXPORT void SplitStringAlongWhitespace(const string16& str, 71 BASE_EXPORT void SplitStringAlongWhitespace(const string16& str,
77 std::vector<string16>* result); 72 std::vector<string16>* result);
78 BASE_EXPORT void SplitStringAlongWhitespace(const std::string& str, 73 BASE_EXPORT void SplitStringAlongWhitespace(const std::string& str,
79 std::vector<std::string>* result); 74 std::vector<std::string>* result);
80 75
81 } // namespace base 76 } // namespace base
82 77
83 #endif // BASE_STRINGS_STRING_SPLIT_H_ 78 #endif // BASE_STRINGS_STRING_SPLIT_H_
OLDNEW
« no previous file with comments | « no previous file | base/strings/string_split_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698