| 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(const string16& str, | 97 BASE_EXPORT void SplitStringUsingSubstr(const string16& str, |
| 98 const string16& s, | 98 const string16& s, |
| 99 std::vector<string16>* r); | 99 std::vector<string16>* r); |
| 100 BASE_EXPORT void SplitStringUsingSubstr(const std::string& str, | 100 BASE_EXPORT void SplitStringUsingSubstr(const std::string& str, |
| 101 const std::string& s, | 101 const std::string& s, |
| 102 std::vector<std::string>* r); | 102 std::vector<std::string>* r); |
| 103 | 103 |
| 104 // ----------------------------------------------------------------------------- | |
| 105 // Backwards-compat wrappers | |
| 106 // | |
| 107 // New code should use one of the more general variants above. | |
| 108 // TODO(brettw) remove these and convert to the versions above. | |
| 109 | |
| 110 // Splits |str| into a vector of strings delimited by |c|, placing the results | |
| 111 // in |r|. If several instances of |c| are contiguous, or if |str| begins with | |
| 112 // or ends with |c|, then an empty string is inserted. | |
| 113 // | |
| 114 // Every substring is trimmed of any leading or trailing white space. | |
| 115 // NOTE: |c| must be in BMP (Basic Multilingual Plane) | |
| 116 BASE_EXPORT void SplitString(const string16& str, | |
| 117 char16 c, | |
| 118 std::vector<string16>* r); | |
| 119 | |
| 120 // |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which | |
| 121 // the trailing byte of a multi-byte character can be in the ASCII range. | |
| 122 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK. | |
| 123 // Note: |c| must be in the ASCII range. | |
| 124 BASE_EXPORT void SplitString(const std::string& str, | |
| 125 char c, | |
| 126 std::vector<std::string>* r); | |
| 127 | |
| 128 // The same as SplitString, but don't trim white space. | |
| 129 // NOTE: |c| must be in BMP (Basic Multilingual Plane) | |
| 130 BASE_EXPORT void SplitStringDontTrim(StringPiece16 str, | |
| 131 char16 c, | |
| 132 std::vector<string16>* r); | |
| 133 // |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which | |
| 134 // the trailing byte of a multi-byte character can be in the ASCII range. | |
| 135 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK. | |
| 136 // Note: |c| must be in the ASCII range. | |
| 137 BASE_EXPORT void SplitStringDontTrim(StringPiece str, | |
| 138 char c, | |
| 139 std::vector<std::string>* result); | |
| 140 | |
| 141 // WARNING: this uses whitespace as defined by the HTML5 spec (ASCII whitespace | |
| 142 // only). | |
| 143 // | |
| 144 // The difference between this and calling SplitString with the whitespace | |
| 145 // characters as separators is the treatment of the first element when the | |
| 146 // string starts with whitespace. | |
| 147 // | |
| 148 // Input SplitString SplitStringAlongWhitespace | |
| 149 // -------------------------------------------------------- | |
| 150 // " a " "", "a" "a" | |
| 151 BASE_EXPORT void SplitStringAlongWhitespace(const string16& str, | |
| 152 std::vector<string16>* result); | |
| 153 BASE_EXPORT void SplitStringAlongWhitespace(const std::string& str, | |
| 154 std::vector<std::string>* result); | |
| 155 | |
| 156 } // namespace base | 104 } // namespace base |
| 157 | 105 |
| 158 #endif // BASE_STRINGS_STRING_SPLIT_H_ | 106 #endif // BASE_STRINGS_STRING_SPLIT_H_ |
| OLD | NEW |