bool getXmpTagStringBag(Exiv2::XmpData &xmpData, const char *propertyName, QStringList &bag) { bool found = false; Exiv2::XmpKey key(propertyName); Exiv2::XmpData::iterator it = xmpData.findKey(key); if ((it != xmpData.end()) && (it->typeId() == Exiv2::xmpBag)) { found = true; int count = it->count(); bag.reserve(count); if (count == 1) { QString bagValue = QString::fromUtf8(it->toString(0).c_str()); if (bagValue.contains(',')) { LOG_DEBUG << "processing legacy saved keywords"; bag += decomposeKeyword(bagValue); } else { bag.append(bagValue); } } else { for (int i = 0; i < count; i++) { QString bagValue = QString::fromUtf8(it->toString(i).c_str()); bag.append(bagValue); } } } return found; }
bool getXmpLangAltValue(Exiv2::XmpData &xmpData, const char *propertyName, const QString &langAlt, QString &resultValue) { bool anyFound = false; Exiv2::XmpKey key(propertyName); Exiv2::XmpData::iterator it = xmpData.findKey(key); if ((it != xmpData.end()) && (it->typeId() == Exiv2::langAlt)) { const Exiv2::LangAltValue &value = static_cast<const Exiv2::LangAltValue &>(it->value()); QString anyValue; Exiv2::LangAltValue::ValueType::const_iterator it2 = value.value_.begin(); Exiv2::LangAltValue::ValueType::const_iterator end = value.value_.end(); for (; it2 != end; ++it2) { QString lang = QString::fromUtf8(it2->first.c_str()); if (langAlt == lang) { QString text = QString::fromUtf8(it2->second.c_str()).trimmed(); if (!text.isEmpty()) { anyFound = true; resultValue = text.trimmed(); break; } } if (anyValue.isEmpty()) { QString text = QString::fromUtf8(it2->second.c_str()); anyValue = text.trimmed(); } } if (!anyFound && !anyValue.isEmpty()) { anyFound = true; resultValue = anyValue; } } return anyFound; }