OLD | NEW |
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 StringPiece16 separators, | 76 StringPiece16 separators, |
77 WhitespaceHandling whitespace, | 77 WhitespaceHandling whitespace, |
78 SplitResult result_type); | 78 SplitResult result_type); |
79 | 79 |
80 using StringPairs = std::vector<std::pair<std::string, std::string>>; | 80 using StringPairs = std::vector<std::pair<std::string, std::string>>; |
81 | 81 |
82 // Splits |line| into key value pairs according to the given delimiters and | 82 // Splits |line| into key value pairs according to the given delimiters and |
83 // removes whitespace leading each key and trailing each value. Returns true | 83 // removes whitespace leading each key and trailing each value. Returns true |
84 // only if each pair has a non-empty key and value. |key_value_pairs| will | 84 // only if each pair has a non-empty key and value. |key_value_pairs| will |
85 // include ("","") pairs for entries without |key_value_delimiter|. | 85 // include ("","") pairs for entries without |key_value_delimiter|. |
86 BASE_EXPORT bool SplitStringIntoKeyValuePairs(const std::string& line, | 86 BASE_EXPORT bool SplitStringIntoKeyValuePairs(StringPiece input, |
87 char key_value_delimiter, | 87 char key_value_delimiter, |
88 char key_value_pair_delimiter, | 88 char key_value_pair_delimiter, |
89 StringPairs* key_value_pairs); | 89 StringPairs* key_value_pairs); |
90 | 90 |
91 // Similar to SplitString, but use a substring delimiter instead of a list of | 91 // Similar to SplitString, but use a substring delimiter instead of a list of |
92 // characters that are all possible delimiters. | 92 // characters that are all possible delimiters. |
93 // | 93 // |
94 // TODO(brettw) this should probably be changed and expanded to provide a | 94 // TODO(brettw) this should probably be changed and expanded to provide a |
95 // mirror of the SplitString[Piece] API above, just with the different | 95 // mirror of the SplitString[Piece] API above, just with the different |
96 // delimiter handling. | 96 // delimiter handling. |
97 BASE_EXPORT void SplitStringUsingSubstr(const string16& str, | 97 BASE_EXPORT void SplitStringUsingSubstr(StringPiece16 input, |
98 const string16& s, | 98 StringPiece16 delimiter, |
99 std::vector<string16>* r); | 99 std::vector<string16>* result); |
100 BASE_EXPORT void SplitStringUsingSubstr(const std::string& str, | 100 BASE_EXPORT void SplitStringUsingSubstr(StringPiece input, |
101 const std::string& s, | 101 StringPiece delimiter, |
102 std::vector<std::string>* r); | 102 std::vector<std::string>* result); |
103 | 103 |
104 } // namespace base | 104 } // namespace base |
105 | 105 |
106 #endif // BASE_STRINGS_STRING_SPLIT_H_ | 106 #endif // BASE_STRINGS_STRING_SPLIT_H_ |
OLD | NEW |