本文整理汇总了C++中QRegExp::patternSyntax方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegExp::patternSyntax方法的具体用法?C++ QRegExp::patternSyntax怎么用?C++ QRegExp::patternSyntax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegExp
的用法示例。
在下文中一共展示了QRegExp::patternSyntax方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qx_save
inline void qx_save(Archive & ar, const QRegExp & t, const unsigned int file_version)
{
Q_UNUSED(file_version);
QString sPattern = t.pattern();
int iCaseSensitivity = static_cast<int>(t.caseSensitivity());
int iPatternSyntax = static_cast<int>(t.patternSyntax());
bool bMinimal = t.isMinimal();
ar << boost::serialization::make_nvp("pattern", sPattern);
ar << boost::serialization::make_nvp("caseSensitivity", iCaseSensitivity);
ar << boost::serialization::make_nvp("patternSyntax", iPatternSyntax);
ar << boost::serialization::make_nvp("minimal", bMinimal);
}
示例2: write
void XMLUtility::write(QXmlStreamWriter& writer, const QRegExp& regExp, const QString& name)
{
if (regExp.isEmpty() || !regExp.isValid() || name.length() == 0)
{
return;
}
writer.writeStartElement(name);
writer.writeAttribute("IsMinimal", booleanToString(regExp.isMinimal()));
writer.writeAttribute("CaseSensitive", caseToString(regExp.caseSensitivity()));
writer.writeAttribute("PatternSyntax", getEnumMapper().PatternSyntaxToString(regExp.patternSyntax()));
writer.writeCharacters(regExp.pattern());
writer.writeEndElement();
}
示例3: replace
bool GenericCodeEditor::replace( const QRegExp &expr, const QString &replacement, QTextDocument::FindFlags options )
{
if(expr.isEmpty()) return true;
QTextCursor cursor = textCursor();
if (cursor.hasSelection() && expr.exactMatch(cursor.selectedText()))
{
QString rstr = replacement;
if(expr.patternSyntax() != QRegExp::FixedString)
rstr = resolvedReplacement(rstr, expr);
cursor.insertText(rstr);
}
return find(expr, options);
}
示例4: scope
// Converts a QRegExp to a JS RegExp.
// The conversion is not 100% exact since ECMA regexp and QRegExp
// have different semantics/flags, but we try to do our best.
Heap::RegExpObject::RegExpObject(const QRegExp &re)
{
global = false;
// Convert the pattern to a ECMAScript pattern.
QString pattern = QT_PREPEND_NAMESPACE(qt_regexp_toCanonical)(re.pattern(), re.patternSyntax());
if (re.isMinimal()) {
QString ecmaPattern;
int len = pattern.length();
ecmaPattern.reserve(len);
int i = 0;
const QChar *wc = pattern.unicode();
bool inBracket = false;
while (i < len) {
QChar c = wc[i++];
ecmaPattern += c;
switch (c.unicode()) {
case '?':
case '+':
case '*':
case '}':
if (!inBracket)
ecmaPattern += QLatin1Char('?');
break;
case '\\':
if (i < len)
ecmaPattern += wc[i++];
break;
case '[':
inBracket = true;
break;
case ']':
inBracket = false;
break;
default:
break;
}
}
pattern = ecmaPattern;
}
Scope scope(internalClass->engine);
Scoped<QV4::RegExpObject> o(scope, this);
o->d()->value = QV4::RegExp::create(scope.engine, pattern, re.caseSensitivity() == Qt::CaseInsensitive, false);
o->initProperties();
}
示例5: replaceAll
int GenericCodeEditor::replaceAll( const QRegExp &expr, const QString &replacement, QTextDocument::FindFlags options )
{
mSearchSelections.clear();
updateExtraSelections();
if(expr.isEmpty()) return 0;
int replacements = 0;
bool caps = expr.patternSyntax() != QRegExp::FixedString;
QTextDocument *doc = QPlainTextEdit::document();
QTextBlock block = doc->begin();
QTextCursor cursor;
QTextCursor(doc).beginEditBlock();
while (block.isValid())
{
int blockPos = block.position();
int offset = 0;
while(findInBlock(doc, block, expr, offset, options, cursor))
{
QString rstr = replacement;
if(caps)
rstr = resolvedReplacement(rstr, expr);
cursor.insertText(rstr);
++replacements;
offset = cursor.selectionEnd() - blockPos;
}
block = block.next();
}
QTextCursor(doc).endEditBlock();
return replacements;
}
示例6: identifyWordGroup
QString SyntaxHighlighter::identifyWordGroup(const QString &word, const QChar &lookahead_chr, int idx, int &match_idx, int &match_len)
{
QRegExp expr;
vector<QString>::iterator itr, itr_end;
vector<QRegExp>::iterator itr_exp, itr_exp_end;
vector<QRegExp> *vet_expr=nullptr;
QString group;
bool match=false, part_mach=false;
MultiLineInfo *info=nullptr;
//Try to get the multiline info for the current block
info=getMultiLineInfo(idx, idx, current_block);
/* Case the highlighter is in the middle of a multiline code block,
a different action is executed: check if the current word does not
matches with one of final expresion of the group indicating that the
group highlighting must be interrupted after the current word */
if(info)
{
group=info->group;
//Checking if the word is not a highlight ending for the group
itr_exp=final_exprs[group].begin();
itr_exp_end=final_exprs[group].end();
part_mach=partial_match[group];
while(itr_exp!=itr_exp_end && !match)
{
expr=(*itr_exp);
if(part_mach)
{
match_idx=word.indexOf(expr);
match_len=expr.matchedLength();
match=(match_idx >= 0);
}
else
{
if(expr.patternSyntax()==QRegExp::FixedString)
match=((expr.pattern().compare(word, expr.caseSensitivity())==0));
else
match=expr.exactMatch(word);
if(match)
{
match_idx=0;
match_len=word.length();
}
}
if(match && lookahead_char.count(group) > 0 && lookahead_chr!=lookahead_char.at(group))
match=false;
itr_exp++;
}
/* If the word matches configures a multiline info with the
values retrieved from the regexp matching */
if(match)
{
info->end_col=idx + match_idx + match_len-1;
info->end_block=current_block;
}
else
{
match_idx=0;
match_len=word.length();
}
return(group);
}
else
{
itr=groups_order.begin();
itr_end=groups_order.end();
while(itr!=itr_end && !match)
{
group=(*itr);
vet_expr=&initial_exprs[group];
itr++;
itr_exp=vet_expr->begin();
itr_exp_end=vet_expr->end();
part_mach=partial_match[group];
while(itr_exp!=itr_exp_end && !match)
{
expr=(*itr_exp);
if(part_mach)
{
match_idx=word.indexOf(expr);
match_len=expr.matchedLength();
match=(match_idx >= 0);
}
else
{
if(expr.patternSyntax()==QRegExp::FixedString)
match=((expr.pattern().compare(word, expr.caseSensitivity())==0));
//.........这里部分代码省略.........
示例7: write
void MyMoneyReport::write(QDomElement& e, QDomDocument *doc, bool anonymous) const
{
// No matter what changes, be sure to have a 'type' attribute. Only change
// the major type if it becomes impossible to maintain compatibility with
// older versions of the program as new features are added to the reports.
// Feel free to change the minor type every time a change is made here.
writeBaseXML(*doc, e);
if (anonymous) {
e.setAttribute("name", m_id);
e.setAttribute("comment", QString(m_comment).fill('x'));
} else {
e.setAttribute("name", m_name);
e.setAttribute("comment", m_comment);
}
e.setAttribute("group", m_group);
e.setAttribute("convertcurrency", m_convertCurrency);
e.setAttribute("favorite", m_favorite);
e.setAttribute("tax", m_tax);
e.setAttribute("investments", m_investments);
e.setAttribute("loans", m_loans);
e.setAttribute("rowtype", kRowTypeText[m_rowType]);
e.setAttribute("datelock", kDateLockText[m_dateLock]);
e.setAttribute("includeschedules", m_includeSchedules);
e.setAttribute("columnsaredays", m_columnsAreDays);
e.setAttribute("includestransfers", m_includeTransfers);
if (!m_budgetId.isEmpty())
e.setAttribute("budget", m_budgetId);
e.setAttribute("includesactuals", m_includeBudgetActuals);
e.setAttribute("includeunused", m_includeUnusedAccounts);
e.setAttribute("includesforecast", m_includeForecast);
e.setAttribute("includesprice", m_includePrice);
e.setAttribute("includesaverageprice", m_includeAveragePrice);
e.setAttribute("mixedtime", m_mixedTime);
e.setAttribute("includesmovingaverage", m_includeMovingAverage);
if (m_includeMovingAverage)
e.setAttribute("movingaveragedays", m_movingAverageDays);
if (m_chartType < 0 || m_chartType >= kChartTypeText.size()) {
qDebug("m_chartType out of bounds with %d on report of type %d. Default to none.", m_chartType, m_reportType);
e.setAttribute("charttype", kChartTypeText[0]);
} else {
e.setAttribute("charttype", kChartTypeText[m_chartType]);
}
e.setAttribute("chartdatalabels", m_chartDataLabels);
e.setAttribute("chartgridlines", m_chartGridLines);
e.setAttribute("chartbydefault", m_chartByDefault);
e.setAttribute("chartlinewidth", m_chartLineWidth);
e.setAttribute("skipZero", m_skipZero);
if (m_reportType == ePivotTable) {
e.setAttribute("type", "pivottable 1.15");
e.setAttribute("detail", kDetailLevelText[m_detailLevel]);
e.setAttribute("columntype", kColumnTypeText[m_columnType]);
e.setAttribute("showrowtotals", m_showRowTotals);
} else if (m_reportType == eQueryTable) {
e.setAttribute("type", "querytable 1.14");
QStringList columns;
unsigned qc = m_queryColumns;
unsigned it_qc = eQCbegin;
unsigned index = 1;
while (it_qc != eQCend) {
if (qc & it_qc)
columns += kQueryColumnsText[index];
it_qc *= 2;
index++;
}
e.setAttribute("querycolumns", columns.join(","));
} else if (m_reportType == eInfoTable) {
e.setAttribute("type", "infotable 1.0");
e.setAttribute("detail", kDetailLevelText[m_detailLevel]);
e.setAttribute("showrowtotals", m_showRowTotals);
}
//
// Text Filter
//
QRegExp textfilter;
if (textFilter(textfilter)) {
QDomElement f = doc->createElement("TEXT");
f.setAttribute("pattern", textfilter.pattern());
f.setAttribute("casesensitive", (textfilter.caseSensitivity() == Qt::CaseSensitive) ? 1 : 0);
f.setAttribute("regex", (textfilter.patternSyntax() == QRegExp::Wildcard) ? 1 : 0);
f.setAttribute("inverttext", m_invertText);
e.appendChild(f);
}
//
// Type & State Filters
//
QList<int> typelist;
if (types(typelist) && ! typelist.empty()) {
// iterate over payees, and add each one
QList<int>::const_iterator it_type = typelist.constBegin();
while (it_type != typelist.constEnd()) {
QDomElement p = doc->createElement("TYPE");
p.setAttribute("type", kTypeText[*it_type]);
//.........这里部分代码省略.........