本文整理汇总了C++中QRegExp::caseSensitivity方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegExp::caseSensitivity方法的具体用法?C++ QRegExp::caseSensitivity怎么用?C++ QRegExp::caseSensitivity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegExp
的用法示例。
在下文中一共展示了QRegExp::caseSensitivity方法的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: 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();
}
示例4: newRegExp
void RegExp::newRegExp(QScriptValueImpl *result, const QRegExp &rx, int flags)
{
Q_ASSERT(!(flags & IgnoreCase) || (rx.caseSensitivity() == Qt::CaseInsensitive));
newRegExp_helper(result, rx, flags);
}
示例5: 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));
//.........这里部分代码省略.........
示例6: 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]);
//.........这里部分代码省略.........
示例7: searchReplaceFunction
QScriptValue searchReplaceFunction(QScriptContext *context, QScriptEngine *engine, bool replace){
QEditor *editor = qobject_cast<QEditor*>(context->thisObject().toQObject());
//read arguments
SCRIPT_REQUIRE(editor, "invalid object");
SCRIPT_REQUIRE(!replace || context->argumentCount()>=2, "at least two arguments are required");
SCRIPT_REQUIRE(context->argumentCount()>=1, "at least one argument is required");
SCRIPT_REQUIRE(context->argumentCount()<=4, "too many arguments");
SCRIPT_REQUIRE(context->argument(0).isString()||context->argument(0).isRegExp(), "first argument must be a string or regexp");
QDocumentSearch::Options flags = QDocumentSearch::Silent;
bool global = false, caseInsensitive = false;
QString searchFor;
if (context->argument(0).isRegExp()) {
flags |= QDocumentSearch::RegExp;
QRegExp r = context->argument(0).toRegExp();
searchFor = r.pattern();
caseInsensitive = r.caseSensitivity() == Qt::CaseInsensitive;
Q_ASSERT(caseInsensitive == context->argument(0).property("ignoreCase").toBool()); //check assumption about javascript core
global = context->argument(0).property("global").toBool();
} else searchFor = context->argument(0).toString();
QScriptValue handler;
QDocumentCursor scope = editor->document()->cursor(0,0,editor->document()->lineCount(),0);
int handlerCount = 0;
for (int i=1; i<context->argumentCount();i++)
if (context->argument(i).isString() || context->argument(i).isFunction()) handlerCount++;
SCRIPT_REQUIRE(handlerCount <= (replace?2:1), "too many string or function arguments");
for (int i=1; i<context->argumentCount();i++) {
QScriptValue a = context->argument(i);
if (a.isFunction()) {
SCRIPT_REQUIRE(!handler.isValid(), "Multiple callbacks");
handler = a;
} else if (a.isString()) {
if (!replace || handlerCount > 1) {
QString s = a.toString().toLower();
global = s.contains("g");
caseInsensitive = s.contains("i");
if (s.contains("w")) flags |= QDocumentSearch::WholeWords;
} else {
SCRIPT_REQUIRE(!handler.isValid(), "Multiple callbacks");
handler = a;
}
handlerCount--;
} else if (a.isNumber()) flags |= QDocumentSearch::Options((int)a.toNumber());
else if (a.isObject()) scope = cursorFromValue(a);
else SCRIPT_REQUIRE(false, "Invalid argument");
}
SCRIPT_REQUIRE(handler.isValid() || !replace, "No callback given");
if (!caseInsensitive) flags |= QDocumentSearch::CaseSensitive;
//search/replace
QDocumentSearch search(editor, searchFor, flags);
search.setScope(scope);
if (replace && handler.isString()) {
search.setReplaceText(handler.toString());
search.setOption(QDocumentSearch::Replace,true);
return search.next(false, global, false, false);
}
if (!handler.isValid())
return search.next(false,global,true,false);
int count=0;
while (search.next(false, false, true, false) && search.cursor().isValid()) {
count++;
QDocumentCursor temp = search.cursor();
QScriptValue cb = handler.call(QScriptValue(), QScriptValueList() << engine->newQObject(&temp));
if (replace && cb.isValid()){
QDocumentCursor tmp = search.cursor();
tmp.replaceSelectedText(cb.toString());
search.setCursor(tmp.selectionEnd());
}
if (!global) break;
}
return count;
}