| 164 | |
| 165 | template<typename STR> |
| 166 | bool SplitStringIntoKeyValuePairsT(const STR& line, |
| 167 | char key_value_delimiter, |
| 168 | char key_value_pair_delimiter, |
| 169 | std::vector<std::pair<STR, STR> >* key_value_pairs) { |
| 170 | key_value_pairs->clear(); |
| 171 | |
| 172 | std::vector<STR> pairs; |
| 173 | SplitString(line, key_value_pair_delimiter, &pairs); |
| 174 | |
| 175 | bool success = true; |
| 176 | for (size_t i = 0; i < pairs.size(); ++i) { |
| 177 | // Don't add empty pairs into the result. |
| 178 | if (pairs[i].empty()) |
| 179 | continue; |
| 180 | |
| 181 | STR key; |
| 182 | STR value; |
| 183 | if (!SplitStringIntoKeyValueT(pairs[i], key_value_delimiter, &key, &value)) { |
| 184 | // Don't return here, to allow for pairs without associated |
| 185 | // value or key; just record that the split failed. |
| 186 | success = false; |
| 187 | } |
| 188 | key_value_pairs->emplace_back(key, value); |
| 189 | } |
| 190 | return success; |
| 191 | } |
| 192 | |
| 193 | bool SplitStringIntoKeyValuePairs(const std::string& line, |
| 194 | char key_value_delimiter, |
no test coverage detected