/*! * Encodes the \a property and writes it to the device. */ void QVCard30Writer::encodeVersitProperty(const QVersitProperty& property) { QVersitProperty modifiedProperty(property); QString name = mPropertyNameMappings.value(property.name(),property.name()); modifiedProperty.setName(name); encodeGroupsAndName(modifiedProperty); QVariant variant(modifiedProperty.variantValue()); if (variant.type() == QVariant::ByteArray) { modifiedProperty.insertParameter(QLatin1String("ENCODING"), QLatin1String("b")); } encodeParameters(modifiedProperty.parameters()); writeString(QLatin1String(":")); QString renderedValue; QByteArray renderedBytes; if (variant.canConvert<QVersitDocument>()) { QVersitDocument embeddedDocument = variant.value<QVersitDocument>(); QByteArray data; QBuffer buffer(&data); buffer.open(QIODevice::WriteOnly); QVCard30Writer subWriter(mType); subWriter.setCodec(mCodec); subWriter.setDevice(&buffer); subWriter.encodeVersitDocument(embeddedDocument); QString documentString(mCodec->toUnicode(data)); backSlashEscape(&documentString); renderedValue = documentString; } else if (variant.type() == QVariant::String) { renderedValue = variant.toString(); if (property.valueType() != QVersitProperty::PreformattedType) { backSlashEscape(&renderedValue); } } else if (variant.type() == QVariant::StringList) { // We need to backslash escape and concatenate the values in the list QStringList values = property.variantValue().toStringList(); QString separator; if (property.valueType() == QVersitProperty::CompoundType) { separator = QLatin1String(";"); } else { if (property.valueType() != QVersitProperty::ListType) { qWarning("Variant value is a QStringList but the property's value type is neither " "CompoundType or ListType"); } // Assume it's a ListType separator = QLatin1String(","); } bool first = true; foreach (QString value, values) { if (!(value.isEmpty() && property.valueType() == QVersitProperty::ListType)) { if (!first) { renderedValue += separator; } backSlashEscape(&value); renderedValue += value; first = false; } } } else if (variant.type() == QVariant::ByteArray) {
void BuildIndex(feature::DataHeader const & header, TFeaturesVector const & features, TWriter & writer, string const & tmpFilePrefix) { LOG(LINFO, ("Building scale index.")); uint64_t indexSize; { SubWriter<TWriter> subWriter(writer); covering::IndexScales(header, features, subWriter, tmpFilePrefix); indexSize = subWriter.Size(); } LOG(LINFO, ("Built scale index. Size =", indexSize)); }