void AnalyzeTask::parseFileInfo(QXmlStreamReader &xmlStream, AudioFileModel &audioFile) { QSet<MI_trackType_t> tracksProcessed; MI_trackType_t trackType; while (findNextElement(QLatin1String("Track"), xmlStream)) { const QString typeString = findAttribute(QLatin1String("Type"), xmlStream.attributes()); if ((trackType = m_trackTypes.value(typeString.toLower(), MI_trackType_t(-1))) != MI_trackType_t(-1)) { if (!tracksProcessed.contains(trackType)) { tracksProcessed << trackType; parseTrackInfo(xmlStream, trackType, audioFile); } else { qWarning("Skipping non-primary '%s' track!", MUTILS_UTF8(typeString)); xmlStream.skipCurrentElement(); } } else { qWarning("Skipping unsupported '%s' track!", MUTILS_UTF8(typeString)); xmlStream.skipCurrentElement(); } } }
void findNextElement(vector<int> S, vector<vector<int> > &result, vector<int>oneS, int index, int length) { while(index<length) { oneS.push_back(S[index]); result.push_back(oneS); findNextElement(S, result, oneS, index+1, length); oneS.pop_back(); index++; } }
vector<vector<int> > subsets(vector<int> &S) { // Start typing your C/C++ solution below // DO NOT write int main() function int length = S.size(); vector<vector<int> > result; sort(S.begin(), S.end()); vector<int> oneS; result.push_back(oneS); for(int i=0; i<length; i++) { oneS.push_back(S[i]); result.push_back(oneS); findNextElement(S, result, oneS, i+1, length); oneS.pop_back(); } return result; }
const AudioFileModel& AnalyzeTask::parseMediaInfo(const QByteArray &data, AudioFileModel &audioFile) { QXmlStreamReader xmlStream(data); bool firstMediaFile = true; if (findNextElement(QLatin1String("MediaInfo"), xmlStream)) { const QString versionXml = findAttribute(QLatin1String("Version"), xmlStream.attributes()); if (versionXml.isEmpty() || (!checkVersionStr(versionXml, 2U, 0U))) { qWarning("Invalid file format version property: \"%s\"", MUTILS_UTF8(versionXml)); return audioFile; } if (findNextElement(QLatin1String("CreatingLibrary"), xmlStream)) { const QString versionLib = findAttribute(QLatin1String("Version"), xmlStream.attributes()); const QString identifier = xmlStream.readElementText(QXmlStreamReader::SkipChildElements).simplified(); if (!STRICMP(identifier, QLatin1String("MediaInfoLib"))) { qWarning("Invalid library identiofier property: \"%s\"", MUTILS_UTF8(identifier)); return audioFile; } if (!versionLib.isEmpty()) { if (m_mediaInfoVer != UINT_MAX) { const quint32 mediaInfoVer = (m_mediaInfoVer > 9999U) ? m_mediaInfoVer / 10U : m_mediaInfoVer; if (!checkVersionStr(versionLib, mediaInfoVer / 100U, mediaInfoVer % 100U)) { qWarning("Invalid library version property: \"%s\"", MUTILS_UTF8(versionLib)); return audioFile; } } } else { qWarning("Library version property not found!"); return audioFile; } while (findNextElement(QLatin1String("Media"), xmlStream)) { if (firstMediaFile || audioFile.techInfo().containerType().isEmpty() || audioFile.techInfo().audioType().isEmpty()) { firstMediaFile = false; parseFileInfo(xmlStream, audioFile); } else { qWarning("Skipping non-primary file!"); xmlStream.skipCurrentElement(); } } } } if (!(audioFile.techInfo().containerType().isEmpty() || audioFile.techInfo().audioType().isEmpty())) { if (audioFile.metaInfo().title().isEmpty()) { QString baseName = QFileInfo(audioFile.filePath()).fileName(); int index; if ((index = baseName.lastIndexOf(".")) >= 0) { baseName = baseName.left(index); } baseName = baseName.replace("_", " ").simplified(); if ((index = baseName.lastIndexOf(" - ")) >= 0) { baseName = baseName.mid(index + 3).trimmed(); } audioFile.metaInfo().setTitle(baseName); } if ((audioFile.techInfo().audioType().compare("PCM", Qt::CaseInsensitive) == 0) && (audioFile.techInfo().audioProfile().compare("Float", Qt::CaseInsensitive) == 0)) { if (audioFile.techInfo().audioBitdepth() == 32) audioFile.techInfo().setAudioBitdepth(AudioFileModel::BITDEPTH_IEEE_FLOAT32); } } else { qWarning("Audio file format could *not* be recognized!"); } return audioFile; }