SerializableDictPtr ConvertDictionary(const string& format, const SerializableDictPtr dict) { if (format == "text") { return TextDict::NewFromDict(*dict.get()); } else if (format == "ocd") { return DartsDict::NewFromDict(*dict.get()); } else { fprintf(stderr, "Unknown dictionary format: %s\n", format.c_str()); exit(2); } return nullptr; }
void ConvertDictionary(const string inputFileName, const string outputFileName, const string formatFrom, const string formatTo) { SerializableDictPtr dictFrom = CreateDictionary(formatFrom); SerializableDictPtr dictTo = CreateDictionary(formatTo); dictFrom->LoadFromFile(inputFileName); dictTo->LoadFromDict(dictFrom.get()); dictTo->SerializeToFile(outputFileName); }