Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: base/string_split.h

Issue 3750001: base: Move SplitString functions into the base namespace and update the callers. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: brett review, reverted changes in o3d due to it's using an old base revision Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/process_util_linux.cc ('k') | base/string_split.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/string16.h" 13 #include "base/string16.h"
14 14
15 // TODO(tfarina): Move the following functions into the namespace and update the 15 namespace base {
16 // callers.
17 //-----------------------------------------------------------------------------
18 16
19 // Splits |str| into a vector of strings delimited by |s|. Append the results 17 // Splits |str| into a vector of strings delimited by |s|. Append the results
20 // into |r| as they appear. If several instances of |s| are contiguous, or if 18 // into |r| as they appear. If several instances of |s| are contiguous, or if
21 // |str| begins with or ends with |s|, then an empty string is inserted. 19 // |str| begins with or ends with |s|, then an empty string is inserted.
22 // 20 //
23 // Every substring is trimmed of any leading or trailing white space. 21 // Every substring is trimmed of any leading or trailing white space.
24 // Where wchar_t is char16 (i.e. Windows), |c| must be in BMP 22 // Where wchar_t is char16 (i.e. Windows), |c| must be in BMP
25 // (Basic Multilingual Plane). Elsewhere (Linux/Mac), wchar_t 23 // (Basic Multilingual Plane). Elsewhere (Linux/Mac), wchar_t
26 // should be a valid Unicode code point (32-bit). 24 // should be a valid Unicode code point (32-bit).
27 void SplitString(const std::wstring& str, 25 void SplitString(const std::wstring& str,
28 wchar_t c, 26 wchar_t c,
29 std::vector<std::wstring>* r); 27 std::vector<std::wstring>* r);
30 // NOTE: |c| must be in BMP (Basic Multilingual Plane) 28 // NOTE: |c| must be in BMP (Basic Multilingual Plane)
31 void SplitString(const string16& str, 29 void SplitString(const string16& str,
32 char16 c, 30 char16 c,
33 std::vector<string16>* r); 31 std::vector<string16>* r);
34 // |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which 32 // |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which
35 // the trailing byte of a multi-byte character can be in the ASCII range. 33 // the trailing byte of a multi-byte character can be in the ASCII range.
36 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK. 34 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK.
37 // Note: |c| must be in the ASCII range. 35 // Note: |c| must be in the ASCII range.
38 void SplitString(const std::string& str, 36 void SplitString(const std::string& str,
39 char c, 37 char c,
40 std::vector<std::string>* r); 38 std::vector<std::string>* r);
41 39
42 namespace base {
43
44 bool SplitStringIntoKeyValues( 40 bool SplitStringIntoKeyValues(
45 const std::string& line, 41 const std::string& line,
46 char key_value_delimiter, 42 char key_value_delimiter,
47 std::string* key, std::vector<std::string>* values); 43 std::string* key, std::vector<std::string>* values);
48 44
49 bool SplitStringIntoKeyValuePairs( 45 bool SplitStringIntoKeyValuePairs(
50 const std::string& line, 46 const std::string& line,
51 char key_value_delimiter, 47 char key_value_delimiter,
52 char key_value_pair_delimiter, 48 char key_value_pair_delimiter,
53 std::vector<std::pair<std::string, std::string> >* kv_pairs); 49 std::vector<std::pair<std::string, std::string> >* kv_pairs);
(...skipping 21 matching lines...) Expand all
75 // the trailing byte of a multi-byte character can be in the ASCII range. 71 // the trailing byte of a multi-byte character can be in the ASCII range.
76 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK. 72 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK.
77 // Note: |c| must be in the ASCII range. 73 // Note: |c| must be in the ASCII range.
78 void SplitStringDontTrim(const std::string& str, 74 void SplitStringDontTrim(const std::string& str,
79 char c, 75 char c,
80 std::vector<std::string>* r); 76 std::vector<std::string>* r);
81 77
82 } // namespace base 78 } // namespace base
83 79
84 #endif // BASE_STRING_SPLIT_H 80 #endif // BASE_STRING_SPLIT_H
OLDNEW
« no previous file with comments | « base/process_util_linux.cc ('k') | base/string_split.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698