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


C++ QRegExp::capturedTexts方法代码示例

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


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

示例1: regExp

QHash<Profile::Property, QVariant> ProfileCommandParser::parse(const QString& input)
{
    QHash<Profile::Property, QVariant> changes;

    // regular expression to parse profile change requests.
    //
    // format: property=value;property=value ...
    //
    // where 'property' is a word consisting only of characters from A-Z
    // where 'value' is any sequence of characters other than a semi-colon
    //
    static QRegExp regExp("([a-zA-Z]+)=([^;]+)");

    int offset = 0;
    while (regExp.indexIn(input, offset) != -1) {
        if (regExp.capturedTexts().count() == 3) {
            Profile::Property property = Profile::lookupByName(
                                             regExp.capturedTexts().at(1));
            const QString value = regExp.capturedTexts().at(2);
            changes.insert(property, value);
        }

        offset = input.indexOf(';', offset) + 1;
        if (offset == 0)
            break;
    }

    return changes;
}
开发者ID:alstef,项目名称:konsole,代码行数:29,代码来源:Profile.cpp

示例2: treatFuncsInt

/*!
 * \brief treatFuncs treat the last level of recursion: parenthesis
 * \param expr The expression to parse.
 * \param noProblem A reference to a bool set to true if no problem happened, false otherwise.
 * \return The value of the parsed subexpression or 0 in case of error.
 *
 * The expression should not contain operators not nested anymore. The subexpressions within parenthesis will be treated by recalling the level 1 function.
 */
double treatFuncsInt(QString const& expr, bool & noProblem)
{

    noProblem = true;

    QRegExp funcExpInteger = funcExprInteger;
    QRegExp integerExp = integerExpr;
    QRegExp numberExp = numberExpr;

    if (funcExpInteger.exactMatch(expr.trimmed())) {

        int sign = funcExpInteger.capturedTexts()[1].isEmpty() ? 1 : -1;
        QString subExpr = funcExpInteger.capturedTexts()[2];

        double val = treatLevel1Int(subExpr, noProblem);

        if (!noProblem) {
            return 0;
        }

        return sign*val;

    } else if(numberExp.exactMatch(expr.trimmed())) {
        double value = QVariant(expr).toDouble(&noProblem);
        return value;
    }

    noProblem = false;
    return 0;

}
开发者ID:KDE,项目名称:krita,代码行数:39,代码来源:kis_num_parser.cpp

示例3: comment

QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const QString& line)
{
    QString text = line.simplified();

    // comment line: # comment
    static QRegExp comment("\\#.*");
    // title line: keyboard "title"
    static QRegExp title("keyboard\\s+\"(.*)\"");
    // key line: key KeySequence : "output"
    // key line: key KeySequence : command
    static QRegExp key("key\\s+([\\w\\+\\s\\-]+)\\s*:\\s*(\"(.*)\"|\\w+)");

    QList<Token> list;

    if ( text.isEmpty() || comment.exactMatch(text) )
    {
        return list;
    }

    if ( title.exactMatch(text) )
    {
        Token titleToken = { Token::TitleKeyword , QString() };
        Token textToken = { Token::TitleText , title.capturedTexts()[1] };
    
        list << titleToken << textToken;
    }
    else if  ( key.exactMatch(text) )
    {
        Token keyToken = { Token::KeyKeyword , QString() };
        Token sequenceToken = { Token::KeySequence , key.capturedTexts()[1].remove(' ') };

        list << keyToken << sequenceToken;

        if ( key.capturedTexts()[3].isEmpty() )
        {
            // capturedTexts()[2] is a command
            Token commandToken = { Token::Command , key.capturedTexts()[2] };
            list << commandToken;    
        }   
        else
        {
            // capturedTexts()[3] is the output string
           Token outputToken = { Token::OutputText , key.capturedTexts()[3] };
           list << outputToken;
        }     
    }
    else
    {
        kWarning() << "Line in keyboard translator file could not be understood:" << text;
    }

    return list;
}
开发者ID:Maijin,项目名称:konsole,代码行数:53,代码来源:KeyboardTranslator.cpp

示例4: setPath

void LocationShared::setPath( const QString &path ) {
	mPath = path.trimmed();
	mPath.replace( '\\', '/' );

	// Clean off any trailing slashes
	while ( mPath.endsWith( '/' ) && mPath.length() > 1 ) {
		mPath.truncate( mPath.length() - 1 );
	}

	// Work out what kind of path this is. Default if no pattern matches, is local.
	if ( gSftpServerRegExp.indexIn( mPath ) > -1 ) {
		mProtocol = Location::Sftp;
		QStringList parts = gSftpServerRegExp.capturedTexts();
		mRemoteUserName = parts[ 2 ];
		mRemoteHostName = parts[ 3 ];
		mRemotePath = parts[ 4 ];

		if ( mRemotePath.length() == 0 ) {
			mRemotePath = "/";
		}
		mRemotePath.replace( QRegExp( "^/~" ), "~" );
	} else if ( gSshServerRegExp.indexIn( mPath ) > -1 ) {
		mProtocol = Location::Ssh;
		QStringList parts = gSshServerRegExp.capturedTexts();
		mRemoteUserName = parts[ 1 ];
		mRemoteHostName = parts[ 2 ];
		mRemotePath = parts[ 3 ];

		if ( mRemotePath.length() == 0 ) {
			mRemotePath = "/";
		}

		if ( mRemoteUserName.endsWith( '*' ) ) {
			mSudo = true;
			mRemoteUserName.truncate( mRemoteUserName.length() - 1 );
		}
	} else if ( mPath.length() == 0 ) {
		mProtocol = Location::Unsaved;
	} else {
		mProtocol = Location::Local;
	}

	// Work out what to label this path...
	int lastSeparatorIndex = mPath.lastIndexOf(
		mProtocol == Location::Ssh || mProtocol == Location::Sftp ? gSshPathSeparators : gLocalPathSeparators );
	mLabel = mPath.mid( lastSeparatorIndex + 1 );
	if ( mPath == "/" ) {
		mLabel = "Root (/)";
	} else if ( mPath.isEmpty() ) {
		mLabel = QString( "New File %1" ).arg( gOpenFileManager.newFileNumber() );
	}
}
开发者ID:PonyEdit,项目名称:PonyEdit,代码行数:52,代码来源:location.cpp

示例5: analyze

void GmacsPreprocessor::analyze(const QStringList &list, const QRegExp &expression)
{
	int size = list.size();
	for (int i = 0; i < size; i++) {
		QString word = list[i];
		int idx = expression.indexIn(word);
		if (word.isEmpty()) continue;
		while (idx >= 0) {
			int length = expression.matchedLength();
			QString w = word.mid(idx, length).trimmed();
			if (!added_words.contains(w)) {
				QStringList texts = expression.capturedTexts();
				if (texts.size() > 1) {
					qDebug() << texts;
					QString type_name = texts[1].trimmed();
					if (type_name == "struct" &&
						texts.size() > 2 && !texts[2].isEmpty()) {
						type_name = texts[2].trimmed();
					}
					qDebug() << type_name;
					added_words << type_name;
					QStringList property = getTypeObjectLines(list, i);
					//traverseTypeObject(list, i);
				}
			}
			idx = expression.indexIn(word, idx + length);
		}
	}
}
开发者ID:goccy,项目名称:gmacs,代码行数:29,代码来源:GmacsPreprocessor.cpp

示例6: match

QSObject QSStringClass::match( QSEnv *env )
{
    QString s = env->thisValue().sVal();
    QSObject arg0 = env->arg(0);
    if ( arg0.objectType() == env->regexpClass() ) {
	QRegExp *reg = QSRegExpClass::regExp(&arg0);

	int spos = reg->search(s);
	if (spos == -1) // No match
	    return env->createUndefined();

	if (QSRegExpClass::isGlobal(&arg0)) {
	    QSArray lst(env);
	    int index = 0;
	    while (spos>=0) {
		lst.put(QString::number(index++), env->createString(reg->cap()));
		spos = reg->search(s, spos+1);
	    }
	    if (index == 1)  // only one element, return it
		return lst.get(QString::number(0));
	    return lst;
	} else {
	    return env->createString(reg->cap());
	}
	env->regexpClass()->lastCaptures = reg->capturedTexts();
	QString mstr = reg->cap();
	if ( mstr.isNull() )
	// ### return an array, with the matches
	return env->createString( mstr );
    }
    return env->createUndefined();
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:32,代码来源:qsstring_object.cpp

示例7: extractCpuInfoLine

QString extractCpuInfoLine(int processorNumber, const QString &regExpStr)
{
    if (processorNumber == -1) {
        return QString();
    }

    QFile cpuInfoFile("/proc/cpuinfo");
    if (!cpuInfoFile.open(QIODevice::ReadOnly)) {
        return QString();
    }
    QStringList cpuInfo = QString(cpuInfoFile.readAll()).split('\n', QString::SkipEmptyParts);
    cpuInfoFile.close();

    const QRegExp processorRegExp("processor\\s+:\\s+(\\d+)");
    const QRegExp regExp(regExpStr);

    int line = 0;
    while (line < cpuInfo.size()) {
        if (processorRegExp.exactMatch(cpuInfo.at(line))) {
            int recordProcNum = processorRegExp.capturedTexts()[1].toInt();
            if (recordProcNum == processorNumber) {
                ++line;
                while (line < cpuInfo.size()) {
                    if (regExp.exactMatch(cpuInfo.at(line))) {
                        return regExp.capturedTexts()[1];
                    }
                    ++line;
                }
            }
        }
        ++line;
    }

    return QString();
}
开发者ID:gustavosbarreto,项目名称:libqsolid,代码行数:35,代码来源:cpuinfo.cpp

示例8: pattern

const Card *Card::Parse(const QString &str){
    if(str.startsWith(QChar('@'))){
        // skill card
        static QRegExp pattern("@(\\w+)=(.+)");
        pattern.indexIn(str);
        QStringList texts = pattern.capturedTexts();
        QString card_name = texts.at(1);
        QStringList subcard_ids;
        QString subcard_str = texts.at(2);
        if(subcard_str != ".")
           subcard_ids = subcard_str.split("+");
        SkillCard *card = Sanguosha->cloneSkillCard(card_name);

        if(card == NULL)
            return NULL;

        foreach(QString subcard_id, subcard_ids)
            card->addSubcard(subcard_id.toInt());

        // skill name
        QString skill_name = card_name.remove("Card").toLower();
        card->setSkillName(skill_name);

        return card;        
    }else if(str.startsWith(QChar('$'))){
        QString copy = str;
        copy.remove(QChar('$'));
        QStringList card_strs = copy.split("+");
        DummyCard *dummy = new DummyCard;
        foreach(QString card_str, card_strs){
            dummy->addSubcard(card_str.toInt());
        }
开发者ID:upidea,项目名称:QSanguosha,代码行数:32,代码来源:card.cpp

示例9: userJoin

/*!
    \details An user join this channel
    \param l is the string from Irc server
*/
void IrcChannel::userJoin(QString l)
{
    //  :[email protected] JOIN :#testmonkeystudio
    QRegExp r (":([^!]+).*\\sJOIN\\s:([^ ]+)");
    if(r.exactMatch(l))
    {
        QStringList t = r.capturedTexts();
        if(t.at(2).toLower() == name())
        {
            if(userName() != t.at(1))
            {
                QListWidgetItem *newItem = new QListWidgetItem;
                newItem->setText(t.at(1));
                mMemberList->addItem(newItem);

                mTextEdit->appendHtml("<font color=\"#00ff00\">* "  + t.at(1) + " has joined " + name()  + "</font>");
            }
            else 
            {
                // this user is me :)
                mTextEdit->appendHtml("<font color=\"#ff0000\">Now talking in " + name() + "</font>");
            }

        }
    }
}
开发者ID:pasnox,项目名称:monkeystudio2,代码行数:30,代码来源:IrcChannel.cpp

示例10: fileTypeChanged

void MediaBrowser::fileTypeChanged(int selectedIndex)
{
	QString type = m_filterBox->itemData(selectedIndex).toString();

	static QRegExp parse2("(\\*\\.\\w+)\\s*");

	QString list = type;

	m_currentTypeFilterList.clear();
	int pos=0;
	int count=0;
	while(pos>=0)
	{
		pos = parse2.indexIn(list,pos);
		if(pos>=0)
		{
			pos += parse2.matchedLength();
			m_currentTypeFilterList.append(parse2.capturedTexts().at(1));
			count ++;
		}
	}

// 		if(count == 0)
// 		{
// 			qDebug() << "MediaBrowser::fileTypeChanged: parse2 didnt match:"<<list;
// 		}
// 		else
// 		{
// 			qDebug() << "MediaBrowser::fileTypeChanged: parse2 matched:"<<m_currentTypeFilterList;
// 		}

	// re-apply the filters to the file model
	filterChanged(m_searchBox->text());

}
开发者ID:dtbinh,项目名称:dviz,代码行数:35,代码来源:MediaBrowser.cpp

示例11: fetchValue

QSObject QSRegExpClass::fetchValue( const QSObject *objPtr,
				    const QSMember &mem ) const
{
    if ( mem.type() != QSMember::Custom )
	return QSWritableClass::fetchValue( objPtr, mem );

    QRegExp *re = regExp( objPtr );
    switch ( mem.index() ) {
    case Valid:
	return createBoolean( re->isValid() );
    case Empty:
	return createBoolean( re->isEmpty() );
    case MLength:
	return createNumber( re->matchedLength() );
    case Source:
	return createString( source(objPtr) );
    case Global:
	return createBoolean( isGlobal(objPtr) );
    case IgnoreCase:
	return createBoolean( isIgnoreCase(objPtr) );
    case CTexts: {
 	QSArray array( env() );
 	QStringList ct = re->capturedTexts();
 	QStringList::ConstIterator it = ct.begin();
 	int i = 0;
 	for ( ; it != ct.end(); ++it, ++i )
 	    array.put( QString::number( i ), createString( *it ) );
	array.put( QString::fromLatin1("length"), createNumber( i ) );
 	return array;
    }
    default:
	return createUndefined();
    }
}
开发者ID:AliYousuf,项目名称:pdfedit-ng-,代码行数:34,代码来源:qsregexp_object.cpp

示例12: info

bool blogapp::Post::onLoad(const QString &fullfilename)
{
  if (id.isEmpty())
    return true;

  QRegExp r = QRegExp("^(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)?_(.+)\\.txt$");

  if (!r.exactMatch(id)) {
    // see if its just a basic text file then
    QRegExp txt = QRegExp("^(.+)\\.txt$");
    if (txt.exactMatch(id)) {
      QFileInfo info(fullfilename);
      QDate mod(info.lastModified().date());
      year = mod.year();
      month = mod.month();
      day = mod.day();
      QStringList l = r.capturedTexts();
      title = l[1];
      return true;
    }
    return false;
  }

  QStringList l = r.capturedTexts();
  bool ok;

  assert(l.size() == 5);

  year = l[1].toInt(&ok);
  if (!ok)
    return false;
  month = l[2].toInt(&ok);
  if (!ok)
    return false;
  day = 1;
  if (!l[3].isEmpty()) {
    day = l[3].toInt(&ok);
    if (!ok)
      return false;
  }

  title = l[l.size()-1];
  
  return true;
}
开发者ID:ademko,项目名称:wexus2,代码行数:45,代码来源:Post.cpp

示例13: GetStringFromRX

	static QString GetStringFromRX (const QString& pattern, const QString& contents)
	{
		QString result;
		QRegExp rx (pattern);
		if (rx.indexIn (contents) != -1)
			result = rx.capturedTexts ().at (1);
		else
			qWarning () << Q_FUNC_INFO
				<< "nothing captured for pattern"
				<< rx.pattern ();
		return result;
	}
开发者ID:Zereal,项目名称:leechcraft,代码行数:12,代码来源:vkontakteruplayer.cpp

示例14: rx

QList<int> SweetDisplayStandby::getVirtualKey(QKeySequence keySequence)
{
    QList<int> keys;
    if ( !keySequence.toString().size() )
    {
        return keys;
    }

    QString sequenceString = keySequence.toString();
    QRegExp rx("\\+");
    QStringList query = sequenceString.split(rx);
    uint modifiers=0;
    int i = 0, vk =-1;
    for (; i <query.length()-1; i++ )
    {
        if( query[i] == "Ctrl" )
        {
            modifiers |= MOD_CONTROL;
        }
        else if( query[i] == "Alt" )
        {
            modifiers |= MOD_ALT;
        }
        else if( query[i] == "Shift" )
        {
            modifiers |= MOD_SHIFT;
        }
        else if( query[i] == "Meta" )
        {
            modifiers |= MOD_WIN;
        }
    }
    QString lastKey = query[i];


    QRegExp frx ( "^F(\\d+)$"); // F group keys
    QRegExp drx ( "^(\\d)$"); //digits
    QRegExp lrx ( "^([A-Z])$"); //capital letters
    frx.indexIn(lastKey);
    drx.indexIn(lastKey);
    lrx.indexIn(lastKey);
    if (frx.capturedTexts()[1].length())
    {
        vk += VK_F1 + frx.capturedTexts()[1].toInt();
    }
    else if (drx.capturedTexts()[1].length())
    {
        QChar c = drx.capturedTexts()[1][0];
        vk = c.toLatin1();
    }
    else if (lrx.capturedTexts()[1].length())
    {
        QChar c = lrx.capturedTexts()[1][0];
        vk = c.toLatin1();
    }
    keys.append(modifiers);
    keys.append(vk);
    return keys;
}
开发者ID:Vavooon,项目名称:SweetDisplayStandby,代码行数:59,代码来源:sweetdisplaystandby.cpp

示例15: fromStrImpl

bool QtnPropertyQRectBase::fromStrImpl(const QString& str)
{
    static QRegExp parserRect("^\\s*QRect\\s*\\(([^\\)]+)\\)\\s*$", Qt::CaseInsensitive);
    static QRegExp parserParams("^\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$", Qt::CaseInsensitive);

    if (!parserRect.exactMatch(str))
        return false;

    QStringList params = parserRect.capturedTexts();
    if (params.size() != 2)
        return false;

    if (!parserParams.exactMatch(params[1]))
        return false;

    params = parserParams.capturedTexts();
    if (params.size() != 5)
        return false;

    bool ok = false;
    int left = params[1].toInt(&ok);
    if (!ok)
        return false;

    int top = params[2].toInt(&ok);
    if (!ok)
        return false;

    int width = params[3].toInt(&ok);
    if (!ok)
        return false;

    int height = params[4].toInt(&ok);
    if (!ok)
        return false;

    setValue(QRect(left, top, width, height));
    return true;
}
开发者ID:kmkolasinski,项目名称:QtnProperty,代码行数:39,代码来源:PropertyQRect.cpp


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