| 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 #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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 void SplitString(const string16& str, | 38 void SplitString(const string16& str, |
| 39 char16 c, | 39 char16 c, |
| 40 std::vector<string16>* r) { | 40 std::vector<string16>* r) { |
| 41 DCHECK(CBU16_IS_SINGLE(c)); | 41 DCHECK(CBU16_IS_SINGLE(c)); |
| 42 SplitStringT(str, c, true, r); | 42 SplitStringT(str, c, true, r); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void SplitString(const std::string& str, | 45 void SplitString(const std::string& str, |
| 46 char c, | 46 char c, |
| 47 std::vector<std::string>* r) { | 47 std::vector<std::string>* r) { |
| 48 DCHECK(c >= 0 && c < 0x7F); | 48 #if CHAR_MIN < 0 |
| 49 DCHECK(c >= 0); |
| 50 #endif |
| 51 DCHECK(c < 0x7F); |
| 49 SplitStringT(str, c, true, r); | 52 SplitStringT(str, c, true, r); |
| 50 } | 53 } |
| 51 | 54 |
| 52 bool SplitStringIntoKeyValues( | 55 bool SplitStringIntoKeyValues( |
| 53 const std::string& line, | 56 const std::string& line, |
| 54 char key_value_delimiter, | 57 char key_value_delimiter, |
| 55 std::string* key, std::vector<std::string>* values) { | 58 std::string* key, std::vector<std::string>* values) { |
| 56 key->clear(); | 59 key->clear(); |
| 57 values->clear(); | 60 values->clear(); |
| 58 | 61 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 char16 c, | 152 char16 c, |
| 150 std::vector<string16>* r) { | 153 std::vector<string16>* r) { |
| 151 DCHECK(CBU16_IS_SINGLE(c)); | 154 DCHECK(CBU16_IS_SINGLE(c)); |
| 152 SplitStringT(str, c, false, r); | 155 SplitStringT(str, c, false, r); |
| 153 } | 156 } |
| 154 | 157 |
| 155 void SplitStringDontTrim(const std::string& str, | 158 void SplitStringDontTrim(const std::string& str, |
| 156 char c, | 159 char c, |
| 157 std::vector<std::string>* r) { | 160 std::vector<std::string>* r) { |
| 158 DCHECK(IsStringUTF8(str)); | 161 DCHECK(IsStringUTF8(str)); |
| 159 DCHECK(c >= 0 && c < 0x7F); | 162 #if CHAR_MIN < 0 |
| 163 DCHECK(c >= 0); |
| 164 #endif |
| 165 DCHECK(c < 0x7F); |
| 160 SplitStringT(str, c, false, r); | 166 SplitStringT(str, c, false, r); |
| 161 } | 167 } |
| 162 | 168 |
| 163 template<typename STR> | 169 template<typename STR> |
| 164 void SplitStringAlongWhitespaceT(const STR& str, std::vector<STR>* result) { | 170 void SplitStringAlongWhitespaceT(const STR& str, std::vector<STR>* result) { |
| 165 const size_t length = str.length(); | 171 const size_t length = str.length(); |
| 166 if (!length) | 172 if (!length) |
| 167 return; | 173 return; |
| 168 | 174 |
| 169 bool last_was_ws = false; | 175 bool last_was_ws = false; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 std::vector<string16>* result) { | 210 std::vector<string16>* result) { |
| 205 SplitStringAlongWhitespaceT(str, result); | 211 SplitStringAlongWhitespaceT(str, result); |
| 206 } | 212 } |
| 207 | 213 |
| 208 void SplitStringAlongWhitespace(const std::string& str, | 214 void SplitStringAlongWhitespace(const std::string& str, |
| 209 std::vector<std::string>* result) { | 215 std::vector<std::string>* result) { |
| 210 SplitStringAlongWhitespaceT(str, result); | 216 SplitStringAlongWhitespaceT(str, result); |
| 211 } | 217 } |
| 212 | 218 |
| 213 } // namespace base | 219 } // namespace base |
| OLD | NEW |