本文整理汇总了C++中QStringRef::endsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringRef::endsWith方法的具体用法?C++ QStringRef::endsWith怎么用?C++ QStringRef::endsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringRef
的用法示例。
在下文中一共展示了QStringRef::endsWith方法的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: 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();
}
示例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: getResultThumbLetter
QString ItemBase::getResultThumbLetter() const {
QVector<QStringRef> parts = _result->_url.splitRef('/');
if (!parts.isEmpty()) {
QStringRef domain = parts.at(0);
if (parts.size() > 2 && domain.endsWith(':') && parts.at(1).isEmpty()) { // http:// and others
domain = parts.at(2);
}
parts = domain.split('@').back().split('.');
if (parts.size() > 1) {
return parts.at(parts.size() - 2).at(0).toUpper();
}
}
if (!_result->_title.isEmpty()) {
return _result->_title.at(0).toUpper();
}
return QString();
}
示例5: 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());
}
}
}
}