| 205 | } |
| 206 | |
| 207 | void RewriteDictNode(JSONValue& node, JSONDocument::AllocatorType& allocator, |
| 208 | const char* target_type) { |
| 209 | if (!node.IsObject()) { |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | if (node.HasMember("type") && node["type"].IsString() && |
| 214 | std::string(node["type"].GetString()) == "group" && node.HasMember("dicts") && |
| 215 | node["dicts"].IsArray()) { |
| 216 | for (auto& child : node["dicts"].GetArray()) { |
| 217 | RewriteDictNode(child, allocator, target_type); |
| 218 | } |
| 219 | return; |
| 220 | } |
| 221 | |
| 222 | if (!node.HasMember("type") || !node["type"].IsString() || |
| 223 | !node.HasMember("file") || !node["file"].IsString()) { |
| 224 | return; |
| 225 | } |
| 226 | |
| 227 | const std::string type = node["type"].GetString(); |
| 228 | const std::string file_name = node["file"].GetString(); |
| 229 | if (type != "ocd2" || !EndsWith(file_name, ".ocd2")) { |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | const std::string text_path = ResolveTextDictionaryPath(file_name); |
| 234 | node["type"].SetString(target_type, allocator); |
| 235 | node["file"].SetString(text_path.c_str(), |
| 236 | static_cast<rapidjson::SizeType>(text_path.size()), |
| 237 | allocator); |
| 238 | } |
| 239 | |
| 240 | void RewriteConfigToText(JSONValue& node, JSONDocument::AllocatorType& allocator, |
| 241 | const char* target_type) { |
no test coverage detected