当前位置: 首页>>代码示例>>C++>>正文


C++ iterator::indexOf方法代码示例

本文整理汇总了C++中qstringlist::iterator::indexOf方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::indexOf方法的具体用法?C++ iterator::indexOf怎么用?C++ iterator::indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qstringlist::iterator的用法示例。


在下文中一共展示了iterator::indexOf方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: outputLong

QStringList::iterator
CLArgsPrivate::hasOutputToken(QString& indexStr)
{
    QString outputLong( QString::fromUtf8("--output") );
    QString outputShort( QString::fromUtf8("-o") );

    for (QStringList::iterator it = args.begin(); it != args.end(); ++it) {
        int indexOf = it->indexOf(outputLong);
        if (indexOf != -1) {
            indexOf += outputLong.size();
            if ( indexOf < it->size() ) {
                indexStr = it->mid(indexOf);
                bool ok;
                indexStr.toInt(&ok);
                if (!ok) {
                    error = 1;
                    std::cout << QObject::tr("Wrong formating for the -o option").toStdString() << std::endl;

                    return args.end();
                }
            } else {
                indexStr = QChar::fromLatin1('1');
            }

            return it;
        } else {
            indexOf = it->indexOf(outputShort);
            if (indexOf != -1) {
                if ( (it->size() > 2) && !it->at(2).isDigit() ) {
                    //This is probably the --onload option
                    return args.end();
                }
                indexOf += outputShort.size();
                if ( indexOf < it->size() ) {
                    indexStr = it->mid(indexOf);
                    bool ok;
                    indexStr.toInt(&ok);
                    if (!ok) {
                        error = 1;
                        std::cout << QObject::tr("Wrong formating for the -o option").toStdString() << std::endl;

                        return args.end();
                    }
                } else {
                    indexStr = QChar::fromLatin1('1');
                }

                return it;
            }
        }
    }

    return args.end();
} // CLArgsPrivate::hasOutputToken
开发者ID:ChristianHeckl,项目名称:Natron,代码行数:54,代码来源:CLArgs.cpp

示例2: validate

QValidator::State ListValidator::validate(QString &text, int &pos) const
{
    Q_ASSERT(inner);

    QStringList strings = text.split(QLatin1Char(','));
    int unusedPos;
    QValidator::State state = Acceptable;
    for (QStringList::iterator i = strings.begin(); i != strings.end(); ++i) {
        QString string = i->trimmed();
        const int position = i->indexOf(string);
        const int size = string.size();
        const QValidator::State current = inner->validate(string, unusedPos);
        i->replace(position, size, string);
        if (current == Invalid) {
            state = Invalid;
            break;
        }
        if (current == Intermediate) {
            if (state == Intermediate) {
                state = Invalid;
                break;
            }
            state = Intermediate;
        }
    }
    text = strings.join(QLatin1Char(','));
    return state;
}
开发者ID:KDE,项目名称:plasma-nm,代码行数:28,代码来源:listvalidator.cpp

示例3: isAlldataTypeValid

bool synaxErrorJudger::isAlldataTypeValid(QStringList &data,  vector<pair<int, size_t>> &dataTypeInfo)
{
	QStringList::iterator it;
	for (it = data.begin(); it != data.end(); ++it) {
		*it = it->trimmed();
		if (*it == "") {
			return false;
		}
		bool ok;
		if (it->indexOf('\'') != -1) { //引号'应该是字符或字符串
			it->remove(0, 1).remove(QRegExp("'$"));
			size_t len = it->size();
			if (len < 1 || len > 255) {
				return false;
			}
			else if (len == 1) {
				dataTypeInfo.push_back(pair<int, size_t>(_CHAR, sizeof(char)));
			}
			else {
				dataTypeInfo.push_back(pair<int, size_t>(_STRING, len * sizeof(char)));
			}
		}
		else if (it->indexOf('.') != -1) { //有小数点且不是字符串,应该是float
			it->toFloat(&ok);
			if (!ok) {
				return false;
			}
			else {
				dataTypeInfo.push_back(pair<int, size_t>(_FLOAT, sizeof(float)));
			}
		}
		else { //剩下的应该是int类型
			it->toInt(&ok);
			if (!ok) {
				return false;
			}
			else {
				dataTypeInfo.push_back(pair<int, size_t>(_INT, sizeof(int)));
			}
		}
	}
	return true;
}
开发者ID:zhoujunpei,项目名称:MINI-SQL,代码行数:43,代码来源:synaxErrorJudger.cpp

示例4:

std::vector<size_t> LineEditDialog::getSelectedIndeces(QStringList list)
{
	std::vector<size_t> indexList;
	for (QStringList::iterator it = list.begin(); it != list.end(); ++it)
	{
		QString s = it->mid(5, it->indexOf("  ") - 5);
		indexList.push_back(atoi(s.toStdString().c_str()));
	}
	return indexList;
}
开发者ID:Stefan6,项目名称:ogs,代码行数:10,代码来源:LineEditDialog.cpp

示例5: getAttributeInfo

void synaxErrorJudger::getAttributeInfo(vector<string> &attributeNameList,
	vector<pair<int, size_t>> &dataTypeInfo, set<string> &uniqueAttribute)
{
	int begin = sqlExp.indexOf('(') + 1;
	int end = sqlExp.lastIndexOf(',') - 1;
	QStringList attrList = sqlExp.mid(begin, end - begin + 1).split(',');
	QStringList::iterator it;
	for (it = attrList.begin(); it != attrList.end(); ++it) {
		if (it->trimmed() == "") {
			throw QString("Synax Error: Create statement's format is incorrect.");
		}
		string attributeName = it->section(' ', 0, 0, QString::SectionSkipEmpty).trimmed().toStdString();
		attributeNameList.push_back(attributeName);
		if (it->indexOf("unique") != -1) {
			uniqueAttribute.insert(attributeName);
			it->remove(it->indexOf("unique"), sizeof("unique") - 1);
		}
		it->remove(it->indexOf(attributeName.c_str()), attributeName.size());
		*it = it->trimmed();
		if (*it == "int") {
			dataTypeInfo.push_back(pair<int, size_t>(_INT, sizeof(int)));
		}
		else if (*it == "char") {
			dataTypeInfo.push_back(pair<int, size_t>(_CHAR, sizeof(char)));
		}
		else if (*it == "float") {
			dataTypeInfo.push_back(pair<int, size_t>(_FLOAT, sizeof(float)));
		}
		else { //一定是char(n,因为通过了前面正则表达式的匹配
			it->remove("char").remove('(').remove(')'); //去除括号
			int length = it->trimmed().toInt();
			if (length < 1 || length > 255) {
				throw QString("Synax Error: The length of string is overflow.");
			}
			dataTypeInfo.push_back(pair<int, size_t>(_STRING, sizeof(char) * length));
		}
	}
}
开发者ID:zhoujunpei,项目名称:MINI-SQL,代码行数:38,代码来源:synaxErrorJudger.cpp

示例6: authResult

void GoogleSession::authResult(bool errorFlag)
{
    if (errorFlag)
    {
      qDebug() << "Auth http error" << http->errorString();
      setState(Invalid);
      emit error(AuthenticationFailed, http->errorString());
    }
    else
    {
      QString resp = http->readAll(); 
      //qDebug() << resp;
      QStringList keys = resp.split("\n");
      QHash<QString, QString> keyMap;
      for (QStringList::iterator it = keys.begin(); it!=keys.end(); it++)
      {
        int sep = it->indexOf('=');
        QString key = it->left(sep);
        QString value = it->right(it->length()-sep-1);
        keyMap[key] = value;
        //qDebug() << key << value;
      }
      if (http->lastResponse().statusCode()==200) // OK
      {
        if (keyMap.contains("Auth"))
        {
          authKey = keyMap["Auth"];
          qDebug() << "Authenticated" << authKey;
          setState(Authenticated);
          emit authenticated();
        }
        else
        {
          setState(Invalid);
          emit error(AuthenticationFailed, "No Auth key");
        }
      }
      else
      {
        qDebug() << "ERROR Response header:" << http->lastResponse().statusCode() << http->lastResponse().reasonPhrase();
        qDebug() << "ERROR reason" << keyMap["Error"];
        setState(Invalid);
        emit error(AuthenticationFailed, keyMap["Error"]);
      }
    }
}
开发者ID:muromec,项目名称:gqsync,代码行数:46,代码来源:googlesession.cpp

示例7: initCdrConf

void Dialog::initCdrConf()
{
    LOG_FUNC(Dialog::initCdrConf);
    QDir dir("./");

    /*C++11 语法
    for(auto fileName : dir.entryList())
    {
        if(fileName.indexOf(".xml") != -1)
            this->lsComboValuesSite.append(fileName);
    }*/
    QStringList list = dir.entryList();
    for(QStringList::iterator iter = list.begin(); iter != list.end(); iter ++)
    {
        if(iter->indexOf(".xml") != -1)
            this->lsComboValuesSite.append(*iter);
    }
}
开发者ID:eriwoon,项目名称:QtCdr,代码行数:18,代码来源:dialog.cpp

示例8: parentRevisionsSync

bool MercurialClient::parentRevisionsSync(const QString &workingDirectory,
                                          const QString &file /* = QString() */,
                                          const QString &revision,
                                          QStringList *parents)
{
    parents->clear();
    QStringList args;
    args << QLatin1String("parents") <<  QLatin1String("-r") <<revision;
    if (!file.isEmpty())
        args << file;
    QByteArray outputData;
    if (!vcsFullySynchronousExec(workingDirectory, args, &outputData))
        return false;
    QString output = QString::fromLocal8Bit(outputData);
    output.remove(QLatin1Char('\r'));
    /* Looks like: \code
changeset:   0:031a48610fba
user: ...
\endcode   */
    // Obtain first line and split by blank-delimited tokens
    VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
    const QStringList lines = output.split(QLatin1Char('\n'));
    if (lines.size() < 1) {
        outputWindow->appendSilently(msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(output)));
        return false;
    }
    QStringList changeSets = lines.front().simplified().split(QLatin1Char(' '));
    if (changeSets.size() < 2) {
        outputWindow->appendSilently(msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(output)));
        return false;
    }
    // Remove revision numbers
    const QChar colon = QLatin1Char(':');
    const QStringList::iterator end = changeSets.end();
    QStringList::iterator it = changeSets.begin();
    for (++it; it != end; ++it) {
        const int colonIndex = it->indexOf(colon);
        if (colonIndex != -1)
            parents->push_back(it->mid(colonIndex + 1));
    }
    return true;
}
开发者ID:anchowee,项目名称:QtCreator,代码行数:42,代码来源:mercurialclient.cpp

示例9: parentRevisionsSync

QStringList MercurialClient::parentRevisionsSync(const QString &workingDirectory,
                                          const QString &file /* = QString() */,
                                          const QString &revision)
{
    QStringList parents;
    QStringList args;
    args << QLatin1String("parents") <<  QLatin1String("-r") <<revision;
    if (!file.isEmpty())
        args << file;
    const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, args);
    if (resp.result != SynchronousProcessResponse::Finished)
        return QStringList();
    /* Looks like: \code
changeset:   0:031a48610fba
user: ...
\endcode   */
    // Obtain first line and split by blank-delimited tokens
    const QStringList lines = resp.stdOut().split(QLatin1Char('\n'));
    if (lines.size() < 1) {
        VcsOutputWindow::appendSilently(msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(resp.stdOut())));
        return QStringList();
    }
    QStringList changeSets = lines.front().simplified().split(QLatin1Char(' '));
    if (changeSets.size() < 2) {
        VcsOutputWindow::appendSilently(msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(resp.stdOut())));
        return QStringList();
    }
    // Remove revision numbers
    const QChar colon = QLatin1Char(':');
    const QStringList::iterator end = changeSets.end();
    QStringList::iterator it = changeSets.begin();
    for (++it; it != end; ++it) {
        const int colonIndex = it->indexOf(colon);
        if (colonIndex != -1)
            parents.push_back(it->mid(colonIndex + 1));
    }
    return parents;
}
开发者ID:kai66673,项目名称:qt-creator,代码行数:38,代码来源:mercurialclient.cpp

示例10: destDir

Calamares::JobResult
CreateUserJob::exec()
{
    Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
    QDir destDir( gs->value( "rootMountPoint" ).toString() );

    if ( gs->contains( "sudoersGroup" ) &&
         !gs->value( "sudoersGroup" ).toString().isEmpty() )
    {
        QFileInfo sudoersFi( destDir.absoluteFilePath( "etc/sudoers.d/10-installer" ) );

        if ( !sudoersFi.absoluteDir().exists() )
            return Calamares::JobResult::error( tr( "Sudoers dir is not writable." ) );

        QFile sudoersFile( sudoersFi.absoluteFilePath() );
        if (!sudoersFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
            return Calamares::JobResult::error( tr( "Cannot create sudoers file for writing." ) );

        QString sudoersGroup = gs->value( "sudoersGroup" ).toString();

        QTextStream sudoersOut( &sudoersFile );
        sudoersOut << QString( "%%1 ALL=(ALL) ALL\n" ).arg( sudoersGroup );

        if ( QProcess::execute( "chmod", { "440", sudoersFi.absoluteFilePath() } ) )
            return Calamares::JobResult::error( tr( "Cannot chmod sudoers file." ) );
    }

    QFileInfo groupsFi( destDir.absoluteFilePath( "etc/group" ) );
    QFile groupsFile( groupsFi.absoluteFilePath() );
    if ( !groupsFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
        return Calamares::JobResult::error( tr( "Cannot open groups file for reading." ) );
    QString groupsData = QString::fromLocal8Bit( groupsFile.readAll() );
    QStringList groupsLines = groupsData.split( '\n' );
    for ( QStringList::iterator it = groupsLines.begin();
          it != groupsLines.end(); ++it )
    {
        int indexOfFirstToDrop = it->indexOf( ':' );
        it->truncate( indexOfFirstToDrop );
    }

    foreach ( const QString& group, m_defaultGroups )
        if ( !groupsLines.contains( group ) )
            CalamaresUtils::System::instance()->
                    targetEnvCall( { "groupadd", group } );

    QString defaultGroups = m_defaultGroups.join( ',' );
    if ( m_autologin )
    {
        QString autologinGroup;
        if ( gs->contains( "autologinGroup" ) &&
             !gs->value( "autologinGroup" ).toString().isEmpty() )
            autologinGroup = gs->value( "autologinGroup" ).toString();
        else
            autologinGroup = QStringLiteral( "autologin" );

        CalamaresUtils::System::instance()->targetEnvCall( { "groupadd", autologinGroup } );
        defaultGroups.append( QString( ",%1" ).arg( autologinGroup ) );
    }

    int ec = CalamaresUtils::System::instance()->
             targetEnvCall( { "useradd",
                              "-m",
                              "-s",
                              "/bin/bash",
                              "-U",
                              "-G",
                              defaultGroups,
                              m_userName } );
    if ( ec )
        return Calamares::JobResult::error( tr( "Cannot create user %1." )
                                                .arg( m_userName ),
                                            tr( "useradd terminated with error code %1." )
                                                .arg( ec ) );

    ec = CalamaresUtils::System::instance()->targetEnvCall( { "chfn", "-f", m_fullName, m_userName } );
    if ( ec )
        return Calamares::JobResult::error( tr( "Cannot set full name for user %1." )
                                                .arg( m_userName ),
                                            tr( "chfn terminated with error code %1." )
                                                .arg( ec ) );

    ec = CalamaresUtils::System::instance()->
                      targetEnvCall( { "chown",
                                       "-R",
                                       QString( "%1:%2" ).arg( m_userName )
                                                         .arg( m_userName ),
                                       QString( "/home/%1" ).arg( m_userName ) } );
    if ( ec )
        return Calamares::JobResult::error( tr( "Cannot set home directory ownership for user %1." )
                                                .arg( m_userName ),
                                            tr( "chown terminated with error code %1." )
                                                .arg( ec ) );

    return Calamares::JobResult::ok();
}
开发者ID:AOSC-Dev,项目名称:calamares,代码行数:95,代码来源:CreateUserJob.cpp

示例11: generateCondition

void synaxErrorJudger::generateCondition()
{
	int begin = sqlExp.indexOf("where") + 5;
	int end = sqlExp.indexOf(QRegExp(";$")) - 1;
	QStringList conditions = sqlExp.mid(begin, end - begin + 1).split("and");
	QStringList::iterator it;
	pair<int, size_t> dataType;
	int logicType;
	string rightSide, leftSide;
	for (it = conditions.begin(); it != conditions.end(); ++it) {	
		*it = it->trimmed();
		if (*it == "") {
			throw QString("Synax Error: Conditions' format is incorrect.");
		}
		int begin = 0;
		int end = it->indexOf(QRegExp("[=><]"))-1;
		rightSide = it->mid(begin, end - begin + 1).trimmed().toStdString();
		begin = end + 1;
		end = it->indexOf(QRegExp("[=><]"), begin + 1);
		if (end - begin > 1 || end == -1) { //如果下一个"=",">","<"号出现在较远处
			end = begin; //说明这个逻辑关系是"=",">","<"而非">=", "<=", "<>" 
		}
		logicType = condition::getLogicTypeFromStr(it->mid(begin, end - begin + 1).toStdString());
		if (logicType == _ERROR) {
			throw QString("Synax Error: The logic arithemtic is invalid.");
		}
		bool ok;
		*it = it->mid(end + 1).trimmed();
		if (it->indexOf(QRegExp("^'")) != -1) { //引号'应该是字符或字符串
			it->remove(0, 1).remove(QRegExp("'$"));
			size_t len = it->size();
			pair<int, size_t> dType;
			Api::cManager.getAttributeDataType(*tblName, rightSide, dType);
			if (len < 1 || len > 255 || len > dType.second) {
				throw QString("Synax Error: The length of string is overflow.");
			}
			else if (len == 1) {
				dataType = pair<int, size_t>(_CHAR, sizeof(char));
			}
			else {
				dataType = pair<int, size_t>(_STRING, dType.second * sizeof(char));
			}
		}
		else if (it->indexOf('.') != -1) { //有小数点且不是字符串,应该是float
			it->toFloat(&ok);
			if (!ok) {
				;
			}
			else {
				dataType = pair<int, size_t>(_FLOAT, sizeof(float));
			}
		}
		else { //剩下的应该是int类型
			it->toInt(&ok);
			if (!ok) {
				;
			}
			else {
				dataType = pair<int, size_t>(_INT, sizeof(int));
			}
		}
		leftSide = it->toStdString();
		if (cond == 0) {
			cond = new vector<condition>;
		}
		cond->push_back(condition(rightSide, logicType, dataType, leftSide));
	}
}
开发者ID:zhoujunpei,项目名称:MINI-SQL,代码行数:68,代码来源:synaxErrorJudger.cpp

示例12: save


//.........这里部分代码省略.........
    }

#if 0
//legacy
    if ( _saveSettings.saveObsolete )
#endif
    {
        QList<QString>::const_iterator oit;
        const QStringList& _obsolete=catalog->m_catalogExtraData;
        oit=_obsolete.constBegin();
        if (oit!=_obsolete.constEnd())
        {
            stream << "\n" << (*oit);
            while((++oit)!=_obsolete.constEnd())
                stream << "\n\n" << (*oit);
        }
    }

    int i=m_trailingNewLines+1;
    while (--i>=0)
        stream << '\n';

    return OK;
}

void GettextExportPlugin::writeComment( QTextStream& stream, const QString& comment ) const
{
    if( !comment.isEmpty() )
    {
        // We must check that each comment line really starts with a #, to avoid syntax errors
        int pos = 0;
        for(;;)
        {
            const int newpos = comment.indexOf( '\n', pos, Qt::CaseInsensitive );
            if ( newpos == pos )
            {
                ++pos;
                stream << '\n';
                continue;
            }
            const QString& span ((newpos==-1 ) ? comment.mid(pos) : comment.mid(pos, newpos-pos) );

            const int len = span.length();
            QString spaces; // Stored leading spaces
            for ( int i = 0 ; i < len ; ++i )
            {
                const QChar& ch = span[ i ];
                if ( ch == '#' )
                {
                    stream << spaces << span.mid( i );
                    break;
                }
                else if ( ch == ' ' || ch == '\t' )
                {
                    // We have a leading white space character, so store it temporary
                    spaces += ch;
                }
                else
                {
                    // Not leading white space and not a # character. so consider that the # character was missing at first position.
                    stream << "# " << spaces << span.mid( i );
                    break;
                }
            }
            stream << '\n';
开发者ID:ShermanHuang,项目名称:kdesdk,代码行数:66,代码来源:gettextexport.cpp


注:本文中的qstringlist::iterator::indexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。