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

Side by Side Diff: base/string_split.cc

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/string_split.h ('k') | base/string_util.h » ('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 #include "base/string_split.h" 5 #include "base/string_split.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/third_party/icu/icu_utf.h" 9 #include "base/third_party/icu/icu_utf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 11
12 namespace base {
13
12 template<typename STR> 14 template<typename STR>
13 static void SplitStringT(const STR& str, 15 static void SplitStringT(const STR& str,
14 const typename STR::value_type s, 16 const typename STR::value_type s,
15 bool trim_whitespace, 17 bool trim_whitespace,
16 std::vector<STR>* r) { 18 std::vector<STR>* r) {
17 size_t last = 0; 19 size_t last = 0;
18 size_t i; 20 size_t i;
19 size_t c = str.size(); 21 size_t c = str.size();
20 for (i = 0; i <= c; ++i) { 22 for (i = 0; i <= c; ++i) {
21 if (i == c || str[i] == s) { 23 if (i == c || str[i] == s) {
(...skipping 26 matching lines...) Expand all
48 } 50 }
49 #endif 51 #endif
50 52
51 void SplitString(const std::string& str, 53 void SplitString(const std::string& str,
52 char c, 54 char c,
53 std::vector<std::string>* r) { 55 std::vector<std::string>* r) {
54 DCHECK(c >= 0 && c < 0x7F); 56 DCHECK(c >= 0 && c < 0x7F);
55 SplitStringT(str, c, true, r); 57 SplitStringT(str, c, true, r);
56 } 58 }
57 59
58 namespace base {
59
60 bool SplitStringIntoKeyValues( 60 bool SplitStringIntoKeyValues(
61 const std::string& line, 61 const std::string& line,
62 char key_value_delimiter, 62 char key_value_delimiter,
63 std::string* key, std::vector<std::string>* values) { 63 std::string* key, std::vector<std::string>* values) {
64 key->clear(); 64 key->clear();
65 values->clear(); 65 values->clear();
66 66
67 // Find the key string. 67 // Find the key string.
68 size_t end_key_pos = line.find_first_of(key_value_delimiter); 68 size_t end_key_pos = line.find_first_of(key_value_delimiter);
69 if (end_key_pos == std::string::npos) { 69 if (end_key_pos == std::string::npos) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 void SplitStringDontTrim(const std::string& str, 171 void SplitStringDontTrim(const std::string& str,
172 char c, 172 char c,
173 std::vector<std::string>* r) { 173 std::vector<std::string>* r) {
174 DCHECK(IsStringUTF8(str)); 174 DCHECK(IsStringUTF8(str));
175 DCHECK(c >= 0 && c < 0x7F); 175 DCHECK(c >= 0 && c < 0x7F);
176 SplitStringT(str, c, false, r); 176 SplitStringT(str, c, false, r);
177 } 177 }
178 178
179 } // namespace base 179 } // namespace base
OLDNEW
« no previous file with comments | « base/string_split.h ('k') | base/string_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698