Package &Popt::getPackage(Version &v1, Version &v2) { v1 = v2 = Version::EMPTY_VERSION; Package &p = getPackage(v1, NONE_NEEDED, false); if(!hasMoreArgs()) { // No more args, v1 may be set return p; } if(v1.isEmptyVersion()) { // v1 is empty and we have more arguments, extract v1 from them v1 = getVersion(p, NO_DEFAULT, false); assert(!v1.isEmptyVersion()); if(!hasMoreArgs()) { // No more args, v1 is set, v2 not return p; } } assert(hasMoreArgs()); // We did check this after the above getPackage and getVersion calls. assert(v2.isEmptyVersion()); // Never written to it v2 = getVersion(p, NO_DEFAULT, false); assert(!v2.isEmptyVersion()); return p; }
CmdLineParser::Result CmdLineParser::parse() { TRACE_OBJ bool showHelp = false; while (m_error.isEmpty() && hasMoreArgs()) { const QString &arg = nextArg().toLower(); if (arg == QLatin1String("-collectionfile")) handleCollectionFileOption(); else if (arg == QLatin1String("-showurl")) handleShowUrlOption(); else if (arg == QLatin1String("-enableremotecontrol")) m_enableRemoteControl = true; else if (arg == QLatin1String("-show")) handleShowOption(); else if (arg == QLatin1String("-hide")) handleHideOption(); else if (arg == QLatin1String("-activate")) handleActivateOption(); else if (arg == QLatin1String("-register")) handleRegisterOption(); else if (arg == QLatin1String("-unregister")) handleUnregisterOption(); else if (arg == QLatin1String("-setcurrentfilter")) handleSetCurrentFilterOption(); else if (arg == QLatin1String("-remove-search-index")) m_removeSearchIndex = true; else if (arg == QLatin1String("-rebuild-search-index")) m_rebuildSearchIndex = true; else if (arg == QLatin1String("-help")) showHelp = true; else m_error = tr("Unknown option: %1").arg(arg); } if (!m_error.isEmpty()) { showMessage(m_error + QLatin1String("\n\n\n") + tr(helpMessage), true); return Error; } else if (showHelp) { showMessage(tr(helpMessage), false); return Help; } return Ok; }