OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_STRING_SPLIT_H_ | 5 #ifndef BASE_STRING_SPLIT_H_ |
6 #define BASE_STRING_SPLIT_H_ | 6 #define BASE_STRING_SPLIT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/base_export.h" | 13 #include "base/base_export.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 // Splits |str| into a vector of strings delimited by |s|. Append the results | 18 // Splits |str| into a vector of strings delimited by |c|. Append the results |
19 // into |r| as they appear. If several instances of |s| are contiguous, or if | 19 // into |r| as they appear. If several instances of |c| are contiguous, or if |
20 // |str| begins with or ends with |s|, then an empty string is inserted. | 20 // |str| begins with or ends with |c|, then an empty string is inserted. |
21 // | 21 // |
22 // Every substring is trimmed of any leading or trailing white space. | 22 // Every substring is trimmed of any leading or trailing white space. |
23 // NOTE: |c| must be in BMP (Basic Multilingual Plane) | 23 // NOTE: |c| must be in BMP (Basic Multilingual Plane) |
24 BASE_EXPORT void SplitString(const string16& str, | 24 BASE_EXPORT void SplitString(const string16& str, |
25 char16 c, | 25 char16 c, |
26 std::vector<string16>* r); | 26 std::vector<string16>* r); |
27 // |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which | 27 // |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which |
28 // the trailing byte of a multi-byte character can be in the ASCII range. | 28 // the trailing byte of a multi-byte character can be in the ASCII range. |
29 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK. | 29 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK. |
30 // Note: |c| must be in the ASCII range. | 30 // Note: |c| must be in the ASCII range. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // characters defined by HTML 5). Each contiguous block of non-whitespace | 73 // characters defined by HTML 5). Each contiguous block of non-whitespace |
74 // characters is added to result. | 74 // characters is added to result. |
75 BASE_EXPORT void SplitStringAlongWhitespace(const string16& str, | 75 BASE_EXPORT void SplitStringAlongWhitespace(const string16& str, |
76 std::vector<string16>* result); | 76 std::vector<string16>* result); |
77 BASE_EXPORT void SplitStringAlongWhitespace(const std::string& str, | 77 BASE_EXPORT void SplitStringAlongWhitespace(const std::string& str, |
78 std::vector<std::string>* result); | 78 std::vector<std::string>* result); |
79 | 79 |
80 } // namespace base | 80 } // namespace base |
81 | 81 |
82 #endif // BASE_STRING_SPLIT_H | 82 #endif // BASE_STRING_SPLIT_H |
OLD | NEW |