bool QVCardRestoreHandler::propertyProcessed( const QVersitProperty& property, QList<QContactDetail>* updatedDetails) { bool success = false; QString group; if (!property.groups().isEmpty()) group = property.groups().first(); if (property.name() == PropertyName) { if (property.groups().size() != 1) return false; QMultiHash<QString, QString> parameters = property.parameters(); QContactDetail::DetailType detailType = QContactDetail::DetailType(parameters.value(DetailTypeParameter).toUInt()); QString fieldName = parameters.value(FieldParameter); // Find a detail previously seen with the same definitionName, which was generated from // a property from the same group QContactDetail detail(detailType); foreach (const QContactDetail& previousDetail, mDetailGroupMap.detailsInGroup(group)) { if (previousDetail.type() == detailType) { detail = previousDetail; } } // If not found, it's a new empty detail with the definitionName set. detail.setValue(fieldName.toInt(), deserializeValue(property)); // Replace the equivalent detail in updatedDetails with the new one QMutableListIterator<QContactDetail> it(*updatedDetails); while (it.hasNext()) { if (it.next().key() == detail.key()) { it.remove(); break; } } updatedDetails->append(detail); success = true; } if (!group.isEmpty()) { // Keep track of which details were generated from which Versit groups foreach (const QContactDetail& detail, *updatedDetails) { mDetailGroupMap.insert(group, detail); } }
static IDefRecordElement * deserializeElement(MemoryBuffer & source) { byte kind; source.read(kind); switch (kind) { case DEKnone: return NULL; case DEKrecord: { size32_t maxSize; unsigned numChildren; source.read(maxSize).read(numChildren); Owned<IDefRecordBuilder> builder = createDErecord(maxSize); for (unsigned i=0; i < numChildren; i++) builder->addChildOwn(deserializeElement(source)); return builder->close(); } case DEKifblock: { Owned<IValue> value = deserializeValue(source); Owned<IDefRecordElement> field = deserializeElement(source); Owned<IDefRecordElement> record = deserializeElement(source); return createDEifblock(field, value, record); } case DEKfield: { _ATOM name = deserializeAtom(source); Owned<ITypeInfo> type = deserializeType(source); Owned<IDefRecordElement> record = deserializeElement(source); size32_t maxSize; source.read(maxSize); return createDEfield(name, type, record, maxSize); } default: throwUnexpected(); } }
AmfString AmfString::deserialize(v8::const_iterator& it, v8::const_iterator end, SerializationContext& ctx) { if (it == end || *it++ != AMF_STRING) throw std::invalid_argument("AmfString: Invalid type marker"); return AmfString(deserializeValue(it, end, ctx)); }