Chromium Code Reviews| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(StringPiece16 input, | 97 BASE_EXPORT void SplitStringUsingSubstr(StringPiece16 input, |
| 98 StringPiece16 delimiter, | 98 StringPiece16 delimiter, |
| 99 std::vector<string16>* result); | 99 std::vector<string16>* result); |
| 100 BASE_EXPORT void SplitStringUsingSubstr(StringPiece input, | 100 BASE_EXPORT void SplitStringUsingSubstr(StringPiece input, |
| 101 StringPiece delimiter, | 101 StringPiece delimiter, |
| 102 std::vector<std::string>* result); | 102 std::vector<std::string>* result); |
| 103 | 103 |
| 104 // Like SplitStringUsingSubstr above except it returns a vector of StringPieces | |
| 105 // which reference the original buffer without copying. Although you have to be | |
| 106 // careful to keep the original string unmodified, this provides an efficient | |
| 107 // way to iterate through tokens in a string. | |
| 108 // | |
| 109 // To iterate through all newline-separated tokens in an input string: | |
| 110 // | |
| 111 // for (const auto& cur : | |
| 112 // base::SplitStringUsingSubstr(input, "\r\n")) { | |
| 113 // ... | |
| 114 BASE_EXPORT std::vector<StringPiece16> SplitStringPieceUsingSubstr( | |
|
brettw
2015/12/29 22:14:40
I'd like to make this a mirror of SplitString[Piec
| |
| 115 StringPiece16 input, | |
| 116 StringPiece16 delimiter); | |
| 117 BASE_EXPORT std::vector<StringPiece> SplitStringPieceUsingSubstr( | |
| 118 StringPiece input, | |
| 119 StringPiece delimiter); | |
| 120 | |
| 104 } // namespace base | 121 } // namespace base |
| 105 | 122 |
| 106 #endif // BASE_STRINGS_STRING_SPLIT_H_ | 123 #endif // BASE_STRINGS_STRING_SPLIT_H_ |
| OLD | NEW |