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


C++ QRegularExpressionMatch类代码示例

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


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

示例1: stop

void Player::play(QString stationId) {

    stop();
    if( !playList.contains(stationId))
    {
        return;
    }

    HSTREAM stream = BASS_StreamCreateURL(playList.value(stationId).toStdString().c_str(),0,BASS_STREAM_BLOCK|BASS_STREAM_STATUS|BASS_STREAM_AUTOFREE,MyDownload,0);

    BASS_Start();

    if( stream)
    {
        bool buffering = true;
        while(buffering)
        {
            QWORD progress = BASS_StreamGetFilePosition(stream,BASS_FILEPOS_BUFFER)*100/BASS_StreamGetFilePosition(stream,BASS_FILEPOS_END);
            webView()->page()->mainFrame()->evaluateJavaScript(QString("PlayerHud.updateBufforStatus("+ QString::number(progress) +")"));
            if( progress>=100)
            {
                buffering = false;
                webView()->page()->mainFrame()->evaluateJavaScript("PlayerHud.clearBufforStatus()");
            }

        }
        const char *meta=BASS_ChannelGetTags(stream,BASS_TAG_META);
        if( !meta)
        {
            meta = BASS_ChannelGetTags(stream,BASS_TAG_OGG);
        }
        if( meta)
        {
            qDebug() << meta;
            QRegularExpression rx("StreamTitle='(.+)';StreamUrl");
            QRegularExpressionMatch match = rx.match(QString(meta));
            if (match.hasMatch()) {
                qDebug() << match.captured(1);
                webView()->page()->mainFrame()->evaluateJavaScript("setRadiostationTag('"+ match.captured(1) +"')");
            }
        }
        BASS_ChannelPlay(stream,FALSE);
        playStatus = true;

    }
    else
    {
        qDebug() << BASS_ErrorGetCode();
        return;
    }
    return;
}
开发者ID:offtza01,项目名称:netradio,代码行数:52,代码来源:player.cpp

示例2: QRegularExpression

void Template::translate(ITemplateTranslationProvider &provider)
{
	//This regex captures expressions of the form
	//<?= tr("This is a test") ?> and <?= tr("optional %1 parameters %2","bla","blu") ?>
	//The first capture group is the key (untranslated string), the second the optional list of parameters
	const QRegularExpression regexp = QRegularExpression("<\\?=\\s*tr\\(\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"((?:,\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")*)\\s*\\)\\?>");
	//This one is used to extract the parameters using global matching
	const QRegularExpression paramExp = QRegularExpression(",\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"");

	int offset = 0;
	QRegularExpressionMatch match;
	do
	{
		match = regexp.match(*this,offset);

		if(match.hasMatch())
		{
			int start = match.capturedStart(0);
			int len = match.capturedLength(0);
			QString key = match.captured(1);

			//replace escaped double and single quotes
			key.replace("\\\"","\"");
			key.replace("\\'", "'");

			QString translation = provider.getTranslation(key);

			//find out if we have optional parameters
			if(match.capturedLength(2)>0)
			{
				QString params = match.captured(2);
				//extract each optional parameter
				QRegularExpressionMatchIterator it = paramExp.globalMatch(params);
				while(it.hasNext())
				{
					QRegularExpressionMatch paramMatch = it.next();
					QString param = paramMatch.captured(1);

					//replace escaped quotes
					param.replace("\\\"","\"");
					param.replace("\\'", "'");

					//apply the param
					translation = translation.arg(param);
				}
			}

			this->replace(start,len,translation);
			offset = start+translation.length();
		}
	}while(match.hasMatch());
}
开发者ID:PhiTheta,项目名称:stellarium,代码行数:52,代码来源:template.cpp

示例3: QProcess

void AccountsWorker::refreshADDomain()
{
    QProcess *process = new QProcess(this);
    process->start("/opt/pbis/bin/enum-users");

    connect(process, &QProcess::readyReadStandardOutput, this, [=] {
        QRegularExpression re("Name:\\s+(\\w+)");
        QRegularExpressionMatch match = re.match(process->readAll());
        m_userModel->setIsJoinADDomain(match.hasMatch());
    });

    connect(process, static_cast<void (QProcess::*)(int)>(&QProcess::finished), process, &QProcess::deleteLater);
}
开发者ID:linuxdeepin,项目名称:dde-control-center,代码行数:13,代码来源:accountsworker.cpp

示例4: it

Provider *Provider::createForUrl(const QUrl &url, QObject *parent)
{
    QMapIterator<QString, QRegularExpression> it(endpointToUrlSchemes);
    while (it.hasNext()) {
        it.next();
        QRegularExpressionMatch match = it.value().match(url.toString());
        if (match.hasMatch()) {
            return new Provider(it.key(), parent);
        }
    }

    return 0;
}
开发者ID:cloose,项目名称:qoembed,代码行数:13,代码来源:provider.cpp

示例5: parseVersion

static bool parseVersion(const QString &text, int &version)
{
    // The version in Uncrustify is printed like "uncrustify 0.62"
    const QRegularExpression rx(QLatin1String("([0-9]{1})\\.([0-9]{2})"));
    const QRegularExpressionMatch match = rx.match(text);
    if (!match.hasMatch())
        return false;

    const int major = match.captured(1).toInt() * 100;
    const int minor = match.captured(2).toInt();
    version = major + minor;
    return true;
}
开发者ID:Lykurg,项目名称:qt-creator,代码行数:13,代码来源:uncrustifysettings.cpp

示例6: re

void CellReference::init(const QString &cell_str)
{
    // Try this "^'?([A-Za-z0-9._ ]*)'?:?\\$?([A-Z]{1,3})\\$?(\\d+)$"
    static QRegularExpression re(QStringLiteral("^\\$?([A-Z]{1,3})\\$?(\\d+)$"));
    QRegularExpressionMatch match = re.match(cell_str);
    if (match.hasMatch()) {
        const QString col_str = match.captured(1);
        const QString row_str = match.captured(2);
        _row = row_str.toInt();
        _column = col_from_name(col_str);
        // TODO _sheet
    }
}
开发者ID:rue-ryuzaki,项目名称:QtXlsxWriter,代码行数:13,代码来源:xlsxcellreference.cpp

示例7: re

bool QGCAudioWorker::_getMillisecondString(const QString& string, QString& match, int& number) {
    static QRegularExpression re("([0-9]+ms)");
    QRegularExpressionMatchIterator i = re.globalMatch(string);
    while (i.hasNext()) {
        QRegularExpressionMatch qmatch = i.next();
        if (qmatch.hasMatch()) {
            match = qmatch.captured(0);
            number = qmatch.captured(0).replace("ms", "").toInt();
            return true;
        }
    }
    return false;
}
开发者ID:Aperture-Laboratories,项目名称:qgroundcontrol,代码行数:13,代码来源:QGCAudioWorker.cpp

示例8: sFormatPrefix

QStringList CaViewerScanner::getImageSeries(QString sPath, QString sFileName, QString &sRetBaseName)
{
    //  creates list components based on sFilename (eg. .../foo_t0001.tif)
    QStringList slImageSeries;
    //  checks whether the filename matches the format or not
    const QString sFormatPrefix("^(?<name>.+)");
    const QString sFormatNumber("_t(?<num>\\d{4})");
    const QString sFormatSuffix("(?<dotext>\\..{1,3})$");
    const QRegularExpression regexpSeries(sFormatPrefix + sFormatNumber + sFormatSuffix);
    const QRegularExpressionMatch matchSeries = regexpSeries.match(sFileName);
    if(matchSeries.hasMatch())
    {   //  match found (i.e. there are related files in the same folder)
        sRetBaseName = matchSeries.captured("name");

        const QString sExtension = matchSeries.captured("dotext");

        const QDir dir(sPath);
        const QStringList slAllFiles = dir.entryList(QDir::Files, QDir::Name);

        QRegularExpression regexpFileName(QRegularExpression::escape(sRetBaseName) + sFormatNumber
                                          + QRegularExpression::escape(sExtension));
        int nSequence = 0;
        for(int count = 0; count < slAllFiles.size(); ++count)
        {
            QRegularExpressionMatch match = regexpFileName.match(slAllFiles.at(count));
            if(match.hasMatch())
            {
                int fileNum = match.captured("num").toInt();
                if(fileNum != nSequence)
                    return slImageSeries;
                else
                {
                    slImageSeries << slAllFiles.at(count);
                    ++nSequence;
                }
            }
        }
    }
    else
    {   //  no match found
        const QRegularExpression regexpSingle(sFormatPrefix + sFormatSuffix);
        const QRegularExpressionMatch matchSingle = regexpSingle.match(sFileName);
        if(matchSingle.hasMatch())
        {
            sRetBaseName = matchSingle.captured("name");
            slImageSeries << sFileName;
        }
    }

    return slImageSeries;
}
开发者ID:0Tech,项目名称:CaViewer,代码行数:51,代码来源:caviewerscanner.cpp

示例9: while

QString StringUtils::htmlEncode(
    QString text, bool urlAsLinks, bool newlineAsBr) {
  QString s;
  QHash<int,int> linksIndexes; // start of link index -> length of link
  if (urlAsLinks) {
    QRegularExpressionMatchIterator it = linkRe.globalMatch(text);
    while (it.hasNext()) {
      QRegularExpressionMatch match = it.next();
      linksIndexes.insert(match.capturedStart(0), match.capturedLength(0));
    }
  }
  for (int i = 0; i < text.length(); ) {
    if (urlAsLinks && linksIndexes.contains(i)) {
      int l = linksIndexes.value(i);
      QString html = htmlEncode(text.mid(i, l), false), href = html;
      href.replace("\"", "%22");
      s.append("<a href=\"").append(href).append("\">").append(html)
          .append("</a>");
      i += l;
    } else {
      const QChar c = text.at(i);
      switch(c.toLatin1()) {
      case '<':
        s.append("&lt;");
        break;
      case '>':
        s.append("&gt;");
        break;
      case '&':
        s.append("&amp;");
        break;
      case '"':
        s.append("&#34;");
        break;
      case '\'':
        s.append("&#39;");
        break;
      case '\n':
        if (newlineAsBr)
          s.append("<br/>\n");
        else
          s.append(c);
        break;
      default:
        s.append(c);
      }
      ++i;
    }
  }
  return s;
}
开发者ID:g76r,项目名称:libqtssu,代码行数:51,代码来源:stringutils.cpp

示例10: html

QUrl TheHatAndFat::extractStripImageUrl(QByteArray data)
{
    QString html(data);
    QRegularExpression reg("<img[^>]*src=\"(https://thehatandfat.files.wordpress.com/[^\"]*)\"");
    QRegularExpressionMatch match = reg.match(html);

    if (!match.hasMatch()) {
        return QUrl();
    }

    QString src = match.captured(1);

    return QUrl(src);
}
开发者ID:froksen,项目名称:daily-comics,代码行数:14,代码来源:TheHatAndFat.cpp

示例11: html

QUrl FoxTrot::extractStripImageUrl(QByteArray data)
{
    QString html(data);
    QRegularExpression reg("<img[^>]*class=\"strip\".*src=\"([^\"]*)\"");
    QRegularExpressionMatch match = reg.match(html);

    if (!match.hasMatch()) {
        return QUrl();
    }

    QString src = match.captured(1);

    return QUrl(src);
}
开发者ID:froksen,项目名称:daily-comics,代码行数:14,代码来源:FoxTrot.cpp

示例12: html

QUrl Sigmund::extractStripImageUrl(QByteArray data)
{
    QString html(data);
    QRegularExpression reg("<img[^>]*src=(strips/[^ ]*) ");
    QRegularExpressionMatch match = reg.match(html);

    if (!match.hasMatch()) {
        return QUrl();
    }

    QString src = match.captured(1);

    return QUrl("http://www.sigmund.nl/" + src);
}
开发者ID:froksen,项目名称:daily-comics,代码行数:14,代码来源:Sigmund.cpp

示例13: QRegularExpression

bool RawHtmlPostprocessor::isblocklevel(const QString &html)
{
    QRegularExpressionMatch m = QRegularExpression("^\\<\\/?([^ >]+)").match(html);
    if ( m.hasMatch() ) {
        QChar ch = m.captured(1).at(0);
        // SPECIAL_CHARS: !, ?, @, %
        if ( SPECIAL_CHARS.contains(ch) ) {
            //! Comment, php etc...
            return true;
        }
        return util::isBlockLevel(m.captured(1));
    }
    return false;
}
开发者ID:mugwort-rc,项目名称:QMarkdown,代码行数:14,代码来源:RawHtmlPostprocessor.cpp

示例14: foreach

    foreach (OnePartRule rule, onepartrules)
    {
        QRegularExpressionMatchIterator i = rule.pattern.globalMatch(text);

        while (i.hasNext())
        {
            QRegularExpressionMatch match = i.next();
            int length = match.capturedLength();
            if (length == 0)
                continue;
            int start = match.capturedStart();
            setFormat(start, length, rule.format);
        }
    }
开发者ID:cbmeeks,项目名称:PropellerIDE,代码行数:14,代码来源:highlighter.cpp

示例15: html

QUrl ViiviJaWagner::extractStripImageUrl(QByteArray data)
{
    QString html(data);
    QRegularExpression reg("<img[^>]*src=\"(.*/webkuva/[^\"]*)\"");
    QRegularExpressionMatch match = reg.match(html);

    if (!match.hasMatch()) {
        return QUrl();
    }

    QString src = match.captured(1);

    return QUrl(src);
}
开发者ID:froksen,项目名称:daily-comics,代码行数:14,代码来源:ViiviJaWagner.cpp


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