| 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 // base::KEEP_WHITESPACE, |
| 114 // base::SPLIT_WANT_NONEMPTY)) { |
| 115 // ... |
| 116 BASE_EXPORT std::vector<StringPiece16> SplitStringPieceUsingSubstr( |
| 117 StringPiece16 input, |
| 118 StringPiece16 delimiter, |
| 119 WhitespaceHandling whitespace, |
| 120 SplitResult result_type); |
| 121 BASE_EXPORT std::vector<StringPiece> SplitStringPieceUsingSubstr( |
| 122 StringPiece input, |
| 123 StringPiece delimiter, |
| 124 WhitespaceHandling whitespace, |
| 125 SplitResult result_type); |
| 126 |
| 104 } // namespace base | 127 } // namespace base |
| 105 | 128 |
| 106 #endif // BASE_STRINGS_STRING_SPLIT_H_ | 129 #endif // BASE_STRINGS_STRING_SPLIT_H_ |
| OLD | NEW |