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 #include "base/strings/string_split.h" | 5 #include "base/strings/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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 std::string key; | 100 std::string key; |
101 std::vector<std::string> value; | 101 std::vector<std::string> value; |
102 if (!SplitStringIntoKeyValues(pairs[i], | 102 if (!SplitStringIntoKeyValues(pairs[i], |
103 key_value_delimiter, | 103 key_value_delimiter, |
104 &key, &value)) { | 104 &key, &value)) { |
105 // Don't return here, to allow for keys without associated | 105 // Don't return here, to allow for keys without associated |
106 // values; just record that our split failed. | 106 // values; just record that our split failed. |
107 success = false; | 107 success = false; |
108 } | 108 } |
109 DCHECK_LE(value.size(), 1U); | 109 DCHECK_LE(value.size(), 1U); |
110 kv_pairs->push_back(make_pair(key, value.empty()? "" : value[0])); | 110 kv_pairs->push_back( |
| 111 make_pair(key, value.empty() ? std::string() : value[0])); |
111 } | 112 } |
112 return success; | 113 return success; |
113 } | 114 } |
114 | 115 |
115 template <typename STR> | 116 template <typename STR> |
116 static void SplitStringUsingSubstrT(const STR& str, | 117 static void SplitStringUsingSubstrT(const STR& str, |
117 const STR& s, | 118 const STR& s, |
118 std::vector<STR>* r) { | 119 std::vector<STR>* r) { |
119 r->clear(); | 120 r->clear(); |
120 typename STR::size_type begin_index = 0; | 121 typename STR::size_type begin_index = 0; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 std::vector<string16>* result) { | 211 std::vector<string16>* result) { |
211 SplitStringAlongWhitespaceT(str, result); | 212 SplitStringAlongWhitespaceT(str, result); |
212 } | 213 } |
213 | 214 |
214 void SplitStringAlongWhitespace(const std::string& str, | 215 void SplitStringAlongWhitespace(const std::string& str, |
215 std::vector<std::string>* result) { | 216 std::vector<std::string>* result) { |
216 SplitStringAlongWhitespaceT(str, result); | 217 SplitStringAlongWhitespaceT(str, result); |
217 } | 218 } |
218 | 219 |
219 } // namespace base | 220 } // namespace base |
OLD | NEW |