本文整理汇总了C++中QStringRef::mid方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringRef::mid方法的具体用法?C++ QStringRef::mid怎么用?C++ QStringRef::mid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringRef
的用法示例。
在下文中一共展示了QStringRef::mid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: while
glm::vec3 XMLReader::ToVec3(const QStringRef &s)
{
glm::vec3 result;
int start_idx;
int end_idx = -1;
for(int i = 0; i < 3; i++){
start_idx = ++end_idx;
while(end_idx < s.length() && s.at(end_idx) != QChar(' '))
{
end_idx++;
}
result[i] = s.mid(start_idx, end_idx - start_idx).toFloat();
}
return result;
}
示例4: metaContent
QString HtmlNoteReader::metaContent(const QString &html, const QString &name)
{
if(html.isEmpty())
return QString();
QString content = html;
QTime time; // avoid forever loop
time.start();
int metaIdx = 0;
int endIdx = 0;
// find the meta elements in the html files and read the uuid
while(metaIdx != -1 && time.elapsed() < 1500)
{
metaIdx = content.indexOf("<meta",endIdx+1);
if(metaIdx==-1)
break;
endIdx = content.indexOf(">",metaIdx+1);
#if QT_VERSION >= 0x040800 // Qt Version > 4.8
QStringRef metaLine = content.midRef(metaIdx,endIdx-metaIdx+1); // e.g. <meta name="qrichtext" content="1" />
#else
QString metaLine = content.mid(metaIdx,endIdx-metaIdx+1); // e.g. <meta name="qrichtext" content="1" />
#endif
if(metaLine.contains(name))
{
int idx = metaLine.lastIndexOf('\"');
int beforeIdx = metaLine.lastIndexOf('\"',idx-1);
if(idx != -1 || beforeIdx != -1)
{
#if QT_VERSION >= 0x040800 // Qt Version > 4.8
return metaLine.toString().mid(beforeIdx +1,(idx-beforeIdx+1) -2); // +1 and -1 to take the content between the " "
#else
return metaLine.mid(beforeIdx +1,(idx-beforeIdx+1) -2); // +1 and -1 to take the content between the " "
#endif
}
}
}
return QString();
}