本文整理汇总了C++中QRegularExpressionMatch::captured方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegularExpressionMatch::captured方法的具体用法?C++ QRegularExpressionMatch::captured怎么用?C++ QRegularExpressionMatch::captured使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegularExpressionMatch
的用法示例。
在下文中一共展示了QRegularExpressionMatch::captured方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stdError
void GnuMakeParser::stdError(const QString &line)
{
const QString lne = rightTrimmed(line);
QRegularExpressionMatch match = m_errorInMakefile.match(lne);
if (match.hasMatch()) {
Result res = parseDescription(match.captured(5));
if (res.isFatal)
++m_fatalErrorCount;
if (!m_suppressIssues) {
taskAdded(Task(res.type, res.description,
Utils::FileName::fromUserInput(match.captured(1)) /* filename */,
match.captured(4).toInt(), /* line */
Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)), 1, 0);
}
return;
}
match = m_makeLine.match(lne);
if (match.hasMatch()) {
Result res = parseDescription(match.captured(6));
if (res.isFatal)
++m_fatalErrorCount;
if (!m_suppressIssues) {
Task task = Task(res.type, res.description,
Utils::FileName() /* filename */, -1, /* line */
Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
taskAdded(task, 1, 0);
}
return;
}
IOutputParser::stdError(line);
}
示例2: readUsedCapacity
qint64 reiserfs::readUsedCapacity(const QString& deviceNode) const
{
ExternalCommand cmd(QStringLiteral("debugreiserfs"), { deviceNode });
if (cmd.run(-1) && cmd.exitCode() == 16) {
qint64 blockCount = -1;
QRegularExpression re(QStringLiteral("Count of blocks[^:]+: (\\d+)"));
QRegularExpressionMatch reBlockCount = re.match(cmd.output());
if (reBlockCount.hasMatch())
blockCount = reBlockCount.captured(1).toLongLong();
qint64 blockSize = -1;
re.setPattern(QStringLiteral("Blocksize: (\\d+)"));
QRegularExpressionMatch reBlockSize = re.match(cmd.output());
if (reBlockSize.hasMatch())
blockSize = reBlockSize.captured(1).toLongLong();
qint64 freeBlocks = -1;
re.setPattern(QStringLiteral("Free blocks[^:]+: (\\d+)"));
QRegularExpressionMatch reFreeBlocks = re.match(cmd.output());
if (reFreeBlocks.hasMatch())
freeBlocks = reFreeBlocks.captured(1).toLongLong();
if (blockCount > -1 && blockSize > -1 && freeBlocks > -1)
return (blockCount - freeBlocks) * blockSize;
}
return -1;
}
示例3: re
/**
* @brief Returns a map of parsed markdown urls with their link texts as key
*
* @param text
* @return parsed urls
*/
QMap<QString, QString> QMarkdownTextEdit::parseMarkdownUrlsFromText( QString text )
{
QMap<QString, QString> urlMap;
// match urls like this: [this url](http://mylink)
QRegularExpression re("(\\[.*?\\]\\((.+?://.+?)\\))");
QRegularExpressionMatchIterator i = re.globalMatch( text );
while ( i.hasNext() )
{
QRegularExpressionMatch match = i.next();
QString linkText = match.captured(1);
QString url = match.captured(2);
urlMap[linkText] = url;
}
// match urls like this: <http://mylink>
re = QRegularExpression("(<(.+?://.+?)>)");
i = re.globalMatch( text );
while ( i.hasNext() )
{
QRegularExpressionMatch match = i.next();
QString linkText = match.captured(1);
QString url = match.captured(2);
urlMap[linkText] = url;
}
return urlMap;
}
示例4: updateGotCurrent
void Application::updateGotCurrent() {
if (!updateReply || updateThread) return;
cSetLastUpdateCheck(unixtime());
QRegularExpressionMatch m = QRegularExpression(qsl("^\\s*(\\d+)\\s*:\\s*([\\x21-\\x7f]+)\\s*$")).match(QString::fromUtf8(updateReply->readAll()));
if (m.hasMatch()) {
int32 currentVersion = m.captured(1).toInt();
if (currentVersion > AppVersion) {
updateThread = new QThread();
connect(updateThread, SIGNAL(finished()), updateThread, SLOT(deleteLater()));
updateDownloader = new PsUpdateDownloader(updateThread, m.captured(2));
updateThread->start();
}
}
if (updateReply) updateReply->deleteLater();
updateReply = 0;
if (!updateThread) {
QDir updates(cWorkingDir() + "tupdates");
if (updates.exists()) {
QFileInfoList list = updates.entryInfoList(QDir::Files);
for (QFileInfoList::iterator i = list.begin(), e = list.end(); i != e; ++i) {
if (QRegularExpression("^(tupdate|tmacupd|tlinuxupd|tlinux32upd)\\d+$", QRegularExpression::CaseInsensitiveOption).match(i->fileName()).hasMatch()) {
QFile(i->absoluteFilePath()).remove();
}
}
}
emit updateLatest();
}
startUpdateCheck(true);
App::writeConfig();
}
示例5: re
SteamConfig::Element::Element(QList<QString> *lines) {
QString line;
QRegularExpression re("\"([^\"]*)\"");
QRegularExpressionMatchIterator i;
while (lines->length() > 0) {
line = lines->front();
lines->pop_front();
i = re.globalMatch(line);
if (i.hasNext())
break;
}
if (!lines->length()) // corrupt
return;
QRegularExpressionMatch match = i.next();
name = match.captured(1).toLower();
if (i.hasNext()) { // value is a string
match = i.next();
value = match.captured(1);
value.replace("\\\\", "\\");
}
line = lines->front();
if (line.contains("{")) {
lines->pop_front();
while (true) {
line = lines->front();
if (line.contains("}")) { // empty
lines->pop_front();
return;
}
Element e(lines);
children[e.name] = e;
}
}
}
示例6: fix_self_closing_tags
// Handle the general case
QString GumboInterface::fix_self_closing_tags(const QString &source)
{
QString newsource = source;
QRegularExpression selfclosed("<\\s*([a-zA-Z]+)(\\s*[^>/]*)/\\s*>");
QRegularExpressionMatch match = selfclosed.match(newsource, 0);
while (match.hasMatch()) {
if (match.capturedStart() == -1) {
break;
}
QString tag = match.captured(0);
int sp = match.capturedStart(0);
int n = match.capturedLength(0);
QString name = match.captured(1);
QString atts = match.captured(2);;
atts = atts.trimmed();
if (!atts.isEmpty()) {
atts = " " + atts;
}
int nsp = sp + n;
if (!allowed_void_tags.contains(name)) {
QString newtag = "<" + name + atts + "></" + name + ">";
newsource = newsource.replace(sp,n,newtag);
nsp = sp + newtag.length();
}
match = selfclosed.match(newsource, nsp);
}
return newsource;
}
示例7: version_number
About::About(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
ui.lbHomepageDisplay->setText("<a href=\"" % SIGIL_HOMEPAGE % "\">" % SIGIL_HOMEPAGE % "</a>");
ui.lbLicenseDisplay->setText("<a href=\"" % GNU_LICENSE % "\">" % tr("GNU General Public License v3") % "</a>");
ui.lbBuildTimeDisplay->setText(GetUTCBuildTime().toString("yyyy.MM.dd HH:mm:ss") + " UTC");
ui.lbLoadedQtDisplay->setText(QString(qVersion()));
QRegularExpression version_number(VERSION_NUMBERS);
QRegularExpressionMatch mo = version_number.match(SIGIL_VERSION);
QString version_text = QString("%1.%2.%3")
.arg(mo.captured(1).toInt())
.arg(mo.captured(2).toInt())
.arg(mo.captured(3).toInt());
ui.lbVersionDisplay->setText(version_text);
QString credits = "<h4>" + tr("Maintainer / Lead Developer") + "</h4>" +
"<ul><li>John Schember</li></ul>" +
"<h4>" + tr("Code Contributors") + "</h4>" +
"<ul>" +
"<li>Grant Drake</li>" +
"<li>Dave Heiland</li>" +
"<li>Charles King</li>" +
"<li>Daniel Pavel</li>" +
"<li>Grzegorz Wolszczak</li>" +
"</ul>" +
"<h4>" + tr("Translators") + "</h4>" +
"<ul><li><a href=\"https://www.transifex.net/projects/p/sigil/\">https://www.transifex.net/projects/p/sigil/teams/</a></li></ul>" +
"<h4>" + tr("Original Creator") + "</h4>" +
"<ul><li>Strahinja Marković (" + tr("retired") + ")</li></ul>";
ui.creditsDisplay->setText(credits);
}
示例8: process
void FetchThread::process(QString phost)
{
QUdpSocket *udpSocket ;
udpSocket= new QUdpSocket(0);
udpSocket->bind(QHostAddress::LocalHost, 9999);
udpSocket->waitForConnected(250);
QTcpSocket socket;
socket.connectToHost("localhost", 4949);
socket.waitForConnected(500);
while (socket.waitForReadyRead(250));
QString t_hello = socket.readAll();
qDebug() << "READ: " << t_hello;
socket.write(QString("list\n").toStdString().c_str() );
while (socket.waitForReadyRead(250));
QString buf1 = socket.readAll();
qDebug() << "READ: " << buf1;
QStringList list_probe = buf1.split(QRegExp("\\s+"));
for (int z=0; z< list_probe.size(); z++)
{
QString probe=list_probe.at(z);
QString cmd = QString("fetch ").append(probe).append("\n");
qDebug() << "cmd : " << cmd;
socket.write(cmd.toStdString().c_str() );
while (socket.waitForReadyRead(250));
QString buf2 = socket.readAll();
qDebug() << "Rep fetch :" << buf2 << "\n";
QRegularExpression re("(\\w+).(\\w+) ([0-9.]+)\\n");
QRegularExpressionMatchIterator i = re.globalMatch(buf2);
re.setPatternOptions(QRegularExpression::MultilineOption);
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
QString s_metric = match.captured(1);
QString s_value = match.captured(3);
QString s_mtr = "monit2influxdb,metric="+probe + "_" + s_metric + ",host=" + phost+ " value=" + s_value + " " + QString::number(1000000* QDateTime::currentMSecsSinceEpoch());
qDebug() << "metric: " << s_mtr.toLower();
udpSocket->writeDatagram(s_mtr.toStdString().c_str(), QHostAddress::LocalHost, 9999);
}
udpSocket->close();
}
}
示例9: exp
QTextList *tryReadList(QTextList *list, const QString &line)
{
QTextList *listOut = list;
QRegularExpression exp("^( *)(\\d+\\.|\\*) (.*)$");
QRegularExpressionMatch match = exp.match(line);
if (match.hasMatch())
{
const int indent = match.captured(1).size() / 2 + 1;
const QString contents = match.captured(3);
const bool ordered = match.captured(2) != "*";
QTextListFormat fmt;
fmt.setStyle(ordered ? QTextListFormat::ListDecimal : QTextListFormat::ListDisc);
fmt.setIndent(indent);
if (!listOut || fmt != listOut->format())
{
listOut = cursor.insertList(fmt);
}
else
{
cursor.insertBlock();
}
readInlineText(contents);
listOut->add(cursor.block());
return listOut;
}
else
{
return 0;
}
}
示例10: GetArenaCards
void WebUploader::GetArenaCards(QString &html)
{
//Ejemplo html
//<li><a href='#deck' data-toggle='tab'>Cards: List & Info</a></li>
if(html.contains("<li><a href='#deck' data-toggle='tab'>Cards: List & Info</a></li>"))
{
deckInWeb = true;
emit newWebDeckCardList();
qDebug() << "WebUploader: "<< "Inicio leer deck.";
//Ejemplo html carta
//<li id='374' class='list-group-item' data-name='1' data-cost='3' data-total='1' data-remaining='1' data-any='1'>
//<span style='display: inline-block;'>(3) <a href='http://www.hearthpwn.com/cards/428' onClick='return false;'>Acolyte of Pain</a>
//</span> (<span id='remaining-374' style='font-weight:bold;'>1</span> copy)</li>
QRegularExpression re(
"<li id='\\d+' class='list-group-item' data-name='\\d+' data-cost='\\d+' data-total='(\\d+)' data-remaining='\\d+' data-any='\\d+'>"
"<span style='display: inline-block;'>.*<a href=.*onClick=.*>(.+)</a> "
"</span>.*</li>");
QRegularExpressionMatchIterator reIterator = re.globalMatch(html);
while (reIterator.hasNext())
{
QRegularExpressionMatch match = reIterator.next();
emit newDeckCard(codeFromName(match.captured(2)), match.captured(1).toInt());
}
qDebug() << "WebUploader: "<< "Final leer deck.";
emit sendLog(tr("Web: Active deck read."));
}
}
示例11: stringToFont
QFont stringToFont(const QString& font)
{
QFontDatabase fdb;
QString fontFamily;
int familyIdx=-1;
QStringList allFamilies = fdb.families();
for(int idx=font.indexOf(' '); idx<font.size() && idx>=0; idx=font.indexOf(' ', idx+1)) {
QString testFont = font.left(idx);
if(allFamilies.contains(testFont)) {
fontFamily = testFont;
familyIdx = idx;
}
}
QFont f;
f.setFamily(fontFamily);
QRegularExpression fontRx(QStringLiteral(" (.*) +([0-9]+)$"));
QRegularExpressionMatch match = fontRx.match(font, familyIdx);
if (match.isValid()) {
QString fontStyle = match.captured(1).trimmed();
int fontSize = match.captured(2).toInt();
f.setStyleName(fontStyle);
f.setPointSize(fontSize);
} else {
qWarning() << "Couldn't figure out syle and size" << font;
}
return f;
}
示例12: parse_txt_file
bool parse_txt_file(const QString &inputFile, visitors::map_QStringQString &strings)
{
QFile iFile(inputFile);
iFile.open(QFile::ReadOnly|QFile::Text);
QTextStream txts(&iFile);
txts.setCodec("UTF-8");
const QString rgxp("^(?<id>\\[\\[\\[[A-F0-9]{8}\\]\\]\\])\\s*[\\\",“,”](?<text>.*)[\\\",“,”]$");
QRegularExpression rxp(rgxp);
unsigned int line_counter = 0;
while(!txts.atEnd())
{
QString str = txts.readLine();
QRegularExpressionMatch rm = rxp.match(str);
QString id = rm.captured("id");
QString text = rm.captured("text");
if(id.isEmpty() || text.isEmpty())
{
std::cerr << "Error in line: " << line_counter << " file: " << inputFile.toStdString().c_str() << std::endl;
return false;
}
strings.insert(visitors::map_QStringQString::value_type(id, text));
}
return true;
}
示例13: parseDestinationString
void QgsProcessingUtils::parseDestinationString( QString &destination, QString &providerKey, QString &uri, QString &layerName, QString &format, QMap<QString, QVariant> &options, bool &useWriter, QString &extension )
{
extension.clear();
QRegularExpression splitRx( QStringLiteral( "^(.{3,}?):(.*)$" ) );
QRegularExpressionMatch match = splitRx.match( destination );
if ( match.hasMatch() )
{
providerKey = match.captured( 1 );
if ( providerKey == QStringLiteral( "postgis" ) ) // older processing used "postgis" instead of "postgres"
{
providerKey = QStringLiteral( "postgres" );
}
uri = match.captured( 2 );
if ( providerKey == QLatin1String( "ogr" ) )
{
QgsDataSourceUri dsUri( uri );
if ( !dsUri.database().isEmpty() )
{
if ( !dsUri.table().isEmpty() )
{
layerName = dsUri.table();
options.insert( QStringLiteral( "layerName" ), layerName );
}
uri = dsUri.database();
extension = QFileInfo( uri ).completeSuffix();
format = QgsVectorFileWriter::driverForExtension( extension );
}
else
{
extension = QFileInfo( uri ).completeSuffix();
}
options.insert( QStringLiteral( "update" ), true );
}
useWriter = false;
}
else
{
useWriter = true;
providerKey = QStringLiteral( "ogr" );
QRegularExpression splitRx( QStringLiteral( "^(.*)\\.(.*?)$" ) );
QRegularExpressionMatch match = splitRx.match( destination );
if ( match.hasMatch() )
{
extension = match.captured( 2 );
format = QgsVectorFileWriter::driverForExtension( extension );
}
if ( format.isEmpty() )
{
format = QStringLiteral( "GPKG" );
destination = destination + QStringLiteral( ".gpkg" );
}
options.insert( QStringLiteral( "driverName" ), format );
uri = destination;
}
}
示例14: toInt
int Walltime::toInt( QString const& string )
{
int h,m;
int s = -1;
QRegularExpression re;
QRegularExpressionMatch rem;
// "h+:mm:ss"
re.setPattern("^(\\d+):(\\d+):(\\d+)");
rem = re.match(string);
if( rem.hasMatch() ) {
try {
h = rem.captured(1).toInt();
m = rem.captured(2).toInt();
s = rem.captured(3).toInt();
s+= h*3600 + m*60;
} catch(...) {
s = -1;
}
return s;
}
// "<integer>unit" where unit is d|h|m|s (case insensitive)
re.setPattern("^\\s*(\\d+)\\s*([dhmsDHMS]?)\\s*$");
rem = re.match( string );
if( rem.hasMatch() ) {
QString number = rem.captured(1);
QString unit = rem.captured(2);
try {
s = number.toInt();
if( s<0 ) s = -1;
else if( unit=="d" ) s*=24*3600;
else if( unit=="h" ) s*=3600;
else if( unit=="m" ) s*=60;
else if( unit=="s" ) s*=1;
else s = -1;
} catch(...) {
s = -1;
}
return s;
}
// "h+:mm"
re.setPattern("^\\s*(\\d+):(\\d+)\\s*$");
rem = re.match( string );
if( rem.hasMatch() ) {
try {
h = rem.captured(1).toInt();
m = rem.captured(2).toInt();
s = h*3600 + m*60;
} catch(...) {
s = -1;
}
return s;
}
return -1; //keep the compiler happy
}
示例15: GetUTCBuildTime
QDateTime About::GetUTCBuildTime()
{
QString time_string = QString::fromLatin1(__TIME__);
QString date_string = QString::fromLatin1(__DATE__);
Q_ASSERT(!date_string.isEmpty());
Q_ASSERT(!time_string.isEmpty());
QRegularExpression date_match("(\\w{3})\\s+(\\d+)\\s+(\\d{4})");
QRegularExpressionMatch mo = date_match.match(date_string);
QDate date(mo.captured(3).toInt(), MonthIndexFromString(mo.captured(1)), mo.captured(2).toInt());
return QDateTime(date, QTime::fromString(time_string, "hh:mm:ss")).toUTC();
}