| 200 | } |
| 201 | |
| 202 | void LoadUserDict(const std::string& path, |
| 203 | std::map<std::string, std::vector<std::string> >& entries) { |
| 204 | std::ifstream ifs(path.c_str()); |
| 205 | if (!ifs.is_open()) { |
| 206 | throw std::runtime_error("failed to open user dict: " + path); |
| 207 | } |
| 208 | |
| 209 | std::string line; |
| 210 | size_t line_number = 0; |
| 211 | while (std::getline(ifs, line)) { |
| 212 | ++line_number; |
| 213 | if (IsCommentOrEmpty(line)) { |
| 214 | continue; |
| 215 | } |
| 216 | const std::vector<std::string> tokens = SplitWhitespace(line); |
| 217 | if (tokens.empty()) { |
| 218 | continue; |
| 219 | } |
| 220 | entries[tokens[0]] = ParseUserDictValues(tokens, line_number); |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | void WriteOcd2(const std::map<std::string, std::vector<std::string> >& entries, |
| 225 | const std::string& output_path) { |
no test coverage detected