VCardPhotoParser() : StructurePrivateParser<VCard::PhotoPrivate, VCard::Photo>(QLatin1String("PHOTO")) { QString *strings[] = { &m_data.extval, &m_data.type }; for (int i = 1, size = sizeof(strings)/sizeof(QString*); i < size; i++) addString(QLatin1String(vcardPhotoTypes[i]), strings[i]); addByteArray(QLatin1String(vcardPhotoTypes[0]), &m_data.binval); }
/** Saves a zip compressed archive in the OpenRaster style. * * \param [in] path File path for output file * \param [in] mimetype The contents of "mimetype" which will be STORED * \param [in] stack The contents of "stack.xml" * \param [in] files File names and contents of the files */ void OraSaver::save( QString path, QString mimetype, QString stack, QList<std::pair<QString,QByteArray>> files ){ //TODO: make wrapper class for zipFile zipFile zf = zipOpen64( path.toLocal8Bit().constData(), 0 ); //Save mimetype without compression addStringFile( zf, "mimetype", mimetype ); //Save stack with compression addStringFile( zf, "stack.xml", stack, true ); //Save all data files for( auto file : files ) addByteArray( zf, file.first, file.second ); //TODO: compress if there are significant savings. Perhaps user defined threshold? zipClose( zf, NULL ); }
bool addStringFile( zipFile &zf, QString name, QString contents, bool compress=false ){ return addByteArray( zf, name, contents.toUtf8(), compress ? 9 : 0 ); }