OLD | NEW |
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" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
70 DLOG(INFO) << "cannot parse key from line: " << line; | 70 DVLOG(1) << "cannot parse key from line: " << line; |
71 return false; // no key | 71 return false; // no key |
72 } | 72 } |
73 key->assign(line, 0, end_key_pos); | 73 key->assign(line, 0, end_key_pos); |
74 | 74 |
75 // Find the values string. | 75 // Find the values string. |
76 std::string remains(line, end_key_pos, line.size() - end_key_pos); | 76 std::string remains(line, end_key_pos, line.size() - end_key_pos); |
77 size_t begin_values_pos = remains.find_first_not_of(key_value_delimiter); | 77 size_t begin_values_pos = remains.find_first_not_of(key_value_delimiter); |
78 if (begin_values_pos == std::string::npos) { | 78 if (begin_values_pos == std::string::npos) { |
79 DLOG(INFO) << "cannot parse value from line: " << line; | 79 DVLOG(1) << "cannot parse value from line: " << line; |
80 return false; // no value | 80 return false; // no value |
81 } | 81 } |
82 std::string values_string(remains, begin_values_pos, | 82 std::string values_string(remains, begin_values_pos, |
83 remains.size() - begin_values_pos); | 83 remains.size() - begin_values_pos); |
84 | 84 |
85 // Construct the values vector. | 85 // Construct the values vector. |
86 values->push_back(values_string); | 86 values->push_back(values_string); |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 void SplitStringDontTrim(const std::string& str, | 163 void SplitStringDontTrim(const std::string& str, |
164 char c, | 164 char c, |
165 std::vector<std::string>* r) { | 165 std::vector<std::string>* r) { |
166 DCHECK(IsStringUTF8(str)); | 166 DCHECK(IsStringUTF8(str)); |
167 DCHECK(c >= 0 && c < 0x7F); | 167 DCHECK(c >= 0 && c < 0x7F); |
168 SplitStringT(str, c, false, r); | 168 SplitStringT(str, c, false, r); |
169 } | 169 } |
170 | 170 |
171 } // namespace base | 171 } // namespace base |
OLD | NEW |