本文整理汇总了C++中QStringRef::startsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringRef::startsWith方法的具体用法?C++ QStringRef::startsWith怎么用?C++ QStringRef::startsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringRef
的用法示例。
在下文中一共展示了QStringRef::startsWith方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stripParameterUrl
QString stripParameterUrl(const QString &url, const QString &scheme)
{
QStringRef ref = url.midRef(scheme.length() + 1);
if (ref.startsWith(QLatin1String("//")))
ref = ref.mid(2);
if (ref.endsWith(QLatin1Char('/')))
ref = ref.left(ref.length() - 1);
return ref.toString();
}
示例2: parseNextLine
void QLoggingSettingsParser::parseNextLine(QStringRef line)
{
// Remove whitespace at start and end of line:
line = line.trimmed();
// comment
if (line.startsWith(QLatin1Char(';')))
return;
if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) {
// new section
auto sectionName = line.mid(1, line.size() - 2).trimmed();
m_inRulesSection = sectionName.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0;
return;
}
if (m_inRulesSection) {
int equalPos = line.indexOf(QLatin1Char('='));
if (equalPos != -1) {
if (line.lastIndexOf(QLatin1Char('=')) == equalPos) {
const auto pattern = line.left(equalPos).trimmed();
const auto valueStr = line.mid(equalPos + 1).trimmed();
int value = -1;
if (valueStr == QLatin1String("true"))
value = 1;
else if (valueStr == QLatin1String("false"))
value = 0;
QLoggingRule rule(pattern, (value == 1));
if (rule.flags != 0 && (value != -1))
_rules.append(rule);
else
warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
} else {
warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
}
}
}
}
示例3: visit
bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
{
const QStringRef name = ast->name;
if (name.startsWith("test_")
|| name.startsWith("benchmark_")
|| name.endsWith("_data")
|| specialFunctions.contains(name.toString())) {
const auto sourceLocation = ast->firstSourceLocation();
TestCodeLocationAndType locationAndType;
locationAndType.m_name = m_currentDoc->fileName();
locationAndType.m_line = sourceLocation.startLine;
locationAndType.m_column = sourceLocation.startColumn - 1;
if (specialFunctions.contains(name.toString()))
locationAndType.m_type = TestTreeItem::TestSpecialFunction;
else if (name.endsWith("_data"))
locationAndType.m_type = TestTreeItem::TestDataFunction;
else
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;
m_testFunctions.insert(name.toString(), locationAndType);
}
return false;
}
示例4: parse
/*!
\internal
Parses \a pattern.
Allowed is f.ex.:
qt.core.io.debug FullText, QtDebugMsg
qt.core.* LeftFilter, all types
*.io.warning RightFilter, QtWarningMsg
*.core.* MidFilter
*/
void QLoggingRule::parse(const QStringRef &pattern)
{
QStringRef p;
// strip trailing ".messagetype"
if (pattern.endsWith(QLatin1String(".debug"))) {
p = QStringRef(pattern.string(), pattern.position(),
pattern.length() - 6); // strlen(".debug")
messageType = QtDebugMsg;
} else if (pattern.endsWith(QLatin1String(".info"))) {
p = QStringRef(pattern.string(), pattern.position(),
pattern.length() - 5); // strlen(".info")
messageType = QtInfoMsg;
} else if (pattern.endsWith(QLatin1String(".warning"))) {
p = QStringRef(pattern.string(), pattern.position(),
pattern.length() - 8); // strlen(".warning")
messageType = QtWarningMsg;
} else if (pattern.endsWith(QLatin1String(".critical"))) {
p = QStringRef(pattern.string(), pattern.position(),
pattern.length() - 9); // strlen(".critical")
messageType = QtCriticalMsg;
} else {
p = pattern;
}
if (!p.contains(QLatin1Char('*'))) {
flags = FullText;
} else {
if (p.endsWith(QLatin1Char('*'))) {
flags |= LeftFilter;
p = QStringRef(p.string(), p.position(), p.length() - 1);
}
if (p.startsWith(QLatin1Char('*'))) {
flags |= RightFilter;
p = QStringRef(p.string(), p.position() + 1, p.length() - 1);
}
if (p.contains(QLatin1Char('*'))) // '*' only supported at start/end
flags = 0;
}
category = p.toString();
}
示例5: populateListWidget
bool DialogStartup::populateListWidget(QListWidget* lw,QString configPath) {
QFile xmlFile(configPath);
if (!xmlFile.exists() || (xmlFile.error() != QFile::NoError)) {
qDebug() << "ERROR: Unable to open config file " << configPath;
return false;
}
xmlFile.open(QIODevice::ReadOnly);
QXmlStreamReader reader(&xmlFile);
while (!reader.atEnd()) {
reader.readNext();
if (reader.isStartElement()) {
if (reader.name() == "demos")
while (!reader.atEnd()) {
reader.readNext();
if (reader.isStartElement() && reader.name() == "example") {
QXmlStreamAttributes attrs = reader.attributes();
QStringRef filename = attrs.value("filename");
if (!filename.isEmpty()) {
QStringRef name = attrs.value("name");
QStringRef image = attrs.value("image");
QStringRef args = attrs.value("args");
QStringRef idpocket = attrs.value("idpocket");
QStringRef desc = attrs.value("desc");
QStringRef _connectortype = attrs.value("connectortype");
QStringRef _conngender = attrs.value("conngender");
QListWidgetItem *newItem = new QListWidgetItem;
newItem->setText(name.toString());
newItem->setIcon(QIcon(image.toString()));
newItem->setData(Qt::UserRole,idpocket.toString());
if (!idpocket.startsWith("#"))
lw->addItem( newItem);
// filter on connectors type and gender
// if (!connType.isEmpty() && (_connectortype.indexOf(connType)==-1)) continue;
// qWarning()<<connType<<" found:"<<_connectortype;
// if (!connGender.isEmpty() && (_conngender.indexOf(connGender)==-1)) continue;
// qWarning()<<"included";
}
} else if(reader.isEndElement() && reader.name() == "demos") {
return true;
}
}
}
}
if (reader.hasError()) {
qDebug() << QString("Error parsing %1 on line %2 column %3: \n%4")
.arg(configPath)
.arg(reader.lineNumber())
.arg(reader.columnNumber())
.arg(reader.errorString());
}
return true;
}