Segments Conversion::Convert(const Segments& input) const { Segments output; for (const auto& segment : input) { output.AddSegment(Convert(segment)); } return output; }
static DictEntry* ParseKeyValues(const char* buff) { size_t length; const char* pbuff = UTF8Util::FindNextInline(buff, '\t'); if (UTF8Util::IsLineEndingOrFileEnding(*pbuff)) { throw InvalidFormat("Invalid text dictionary"); } length = pbuff - buff; string key = UTF8Util::FromSubstr(buff, length); Segments values; while (!UTF8Util::IsLineEndingOrFileEnding(*pbuff)) { buff = pbuff = UTF8Util::NextChar(pbuff); pbuff = UTF8Util::FindNextInline(buff, ' '); length = pbuff - buff; const string& value = UTF8Util::FromSubstr(buff, length); values.AddSegment(value); } if (values.Length() == 0) { throw InvalidFormat("Invalid text dictionary: No value in an item"); } else if (values.Length() == 1) { return new DictEntry(key, values.At(0)); } else { return new MultiValueDictEntry(key, values); } }