本文整理汇总了C++中QLatin1String::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QLatin1String::size方法的具体用法?C++ QLatin1String::size怎么用?C++ QLatin1String::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLatin1String
的用法示例。
在下文中一共展示了QLatin1String::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseIntOption
bool parseIntOption(const QString ¶meter,const QLatin1String &option,
IntType minimumValue, IntType maximumValue, IntType *target)
{
const int valueLength = parameter.size() - option.size() - 1;
if (valueLength < 1 || !parameter.startsWith(option) || parameter.at(option.size()) != QLatin1Char('='))
return false;
bool ok;
const QStringRef valueRef = parameter.rightRef(valueLength);
const int value = valueRef.toInt(&ok);
if (ok) {
if (value >= minimumValue && value <= maximumValue)
*target = static_cast<IntType>(value);
else {
qWarning() << "Value" << value << "for option" << option << "out of range"
<< minimumValue << ".." << maximumValue;
}
} else {
qWarning() << "Invalid value" << valueRef << "for option" << option;
}
return true;
}
示例2: Peer
Telegram::Peer Telegram::Peer::fromString(const QString &string)
{
// Possible schemes: user1234, chat1234, channel1234
if (string.length() < 5) {
return Peer();
}
bool ok = true;
switch (string.at(0).toLatin1()) {
case 'u': // user
if (string.startsWith(c_userPrefix)) {
uint userId = string.midRef(c_userPrefix.size()).toUInt(&ok);
if (ok) {
return Peer::fromUserId(userId);
}
}
break;
case 'c': // chat or channel
if (string.at(3).toLatin1() == 't') {
if (string.startsWith(c_chatPrefix)) {
uint chatId = string.midRef(c_chatPrefix.size()).toUInt(&ok);
if (ok) {
return Peer::fromChatId(chatId);
}
}
} else {
if (string.startsWith(c_channelPrefix)) {
uint channelId = string.midRef(c_channelPrefix.size()).toUInt(&ok);
if (ok) {
return Peer::fromChannelId(channelId);
}
}
}
break;
default:
break;
}
return Peer();
}
示例3: parseBuildTargetOption
void CMakeCbpParser::parseBuildTargetOption()
{
if (attributes().hasAttribute(QLatin1String("output"))) {
m_buildTarget.executable = attributes().value(QLatin1String("output")).toString();
CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit);
if (tool)
m_buildTarget.executable = tool->mapAllPaths(m_kit, m_buildTarget.executable);
} else if (attributes().hasAttribute(QLatin1String("type"))) {
const QStringRef value = attributes().value(QLatin1String("type"));
if (value == QLatin1String("2") || value == QLatin1String("3"))
m_buildTarget.targetType = TargetType(value.toInt());
} else if (attributes().hasAttribute(QLatin1String("working_dir"))) {
m_buildTarget.workingDirectory = attributes().value(QLatin1String("working_dir")).toString();
QFile cmakeSourceInfoFile(m_buildTarget.workingDirectory
+ QStringLiteral("/CMakeFiles/CMakeDirectoryInformation.cmake"));
if (cmakeSourceInfoFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream stream(&cmakeSourceInfoFile);
const QLatin1String searchSource("SET(CMAKE_RELATIVE_PATH_TOP_SOURCE \"");
while (!stream.atEnd()) {
const QString lineTopSource = stream.readLine().trimmed();
if (lineTopSource.startsWith(searchSource)) {
m_buildTarget.sourceDirectory = lineTopSource.mid(searchSource.size());
m_buildTarget.sourceDirectory.chop(2); // cut off ")
break;
}
}
}
if (m_buildTarget.sourceDirectory.isEmpty()) {
QDir dir(m_buildDirectory);
const QString relative = dir.relativeFilePath(m_buildTarget.workingDirectory);
m_buildTarget.sourceDirectory
= FileName::fromString(m_sourceDirectory).appendPath(relative).toString();
}
}
while (!atEnd()) {
readNext();
if (isEndElement())
return;
else if (isStartElement())
parseUnknownElement();
}
}
示例4: if
bool OsmAnd::WorldRegions_P::loadWorldRegions(
QHash< QString, std::shared_ptr<const WorldRegion> >& outRegions,
const IQueryController* const controller) const
{
const std::shared_ptr<QIODevice> ocbfFile(new QFile(owner->ocbfFileName));
if (!ocbfFile->open(QIODevice::ReadOnly))
return false;
const std::shared_ptr<ObfReader> ocbfReader(new ObfReader(ocbfFile));
const auto& obfInfo = ocbfReader->obtainInfo();
if (!obfInfo)
{
ocbfFile->close();
return false;
}
for(const auto& mapSection : constOf(obfInfo->mapSections))
{
// Check if request is aborted
if (controller && controller->isAborted())
{
ocbfFile->close();
return false;
}
bool idsCaptured = false;
uint32_t nameId = std::numeric_limits<uint32_t>::max();
uint32_t idId = std::numeric_limits<uint32_t>::max();
uint32_t downloadNameId = std::numeric_limits<uint32_t>::max();
uint32_t regionPrefixId = std::numeric_limits<uint32_t>::max();
uint32_t regionSuffixId = std::numeric_limits<uint32_t>::max();
const QLatin1String localizedNameTagPrefix("name:");
const auto localizedNameTagPrefixLen = localizedNameTagPrefix.size();
const auto worldRegionsCollector =
[&outRegions, &idsCaptured, &nameId, &idId, &downloadNameId, ®ionPrefixId, ®ionSuffixId, localizedNameTagPrefix, localizedNameTagPrefixLen]
(const std::shared_ptr<const OsmAnd::Model::BinaryMapObject>& worldRegionMapObject) -> bool
{
const auto& rules = worldRegionMapObject->section->encodingDecodingRules;
if (!idsCaptured)
{
nameId = rules->name_encodingRuleId;
QHash< QString, QHash<QString, uint32_t> >::const_iterator citRule;
if ((citRule = rules->encodingRuleIds.constFind(QLatin1String("key_name"))) != rules->encodingRuleIds.cend())
idId = citRule->constBegin().value();
if ((citRule = rules->encodingRuleIds.constFind(QLatin1String("download_name"))) != rules->encodingRuleIds.cend())
downloadNameId = citRule->constBegin().value();
if ((citRule = rules->encodingRuleIds.constFind(QLatin1String("region_prefix"))) != rules->encodingRuleIds.cend())
regionPrefixId = citRule->constBegin().value();
if ((citRule = rules->encodingRuleIds.constFind(QLatin1String("region_suffix"))) != rules->encodingRuleIds.cend())
regionSuffixId = citRule->constBegin().value();
idsCaptured = true;
}
QString name;
QString id;
QString downloadName;
QString regionPrefix;
QString regionSuffix;
QHash<QString, QString> localizedNames;
for(const auto& localizedNameEntry : rangeOf(constOf(worldRegionMapObject->names)))
{
const auto ruleId = localizedNameEntry.key();
if (ruleId == idId)
{
id = localizedNameEntry.value().toLower();
continue;
}
else if (ruleId == nameId)
{
name = localizedNameEntry.value();
continue;
}
else if (ruleId == downloadNameId)
{
downloadName = localizedNameEntry.value().toLower();
continue;
}
else if (ruleId == regionPrefixId)
{
regionPrefix = localizedNameEntry.value().toLower();
continue;
}
else if (ruleId == regionSuffixId)
{
regionSuffix = localizedNameEntry.value().toLower();
continue;
}
const auto& nameTag = rules->decodingRules[localizedNameEntry.key()].tag;
if (!nameTag.startsWith(localizedNameTagPrefix))
continue;
const auto languageId = nameTag.mid(localizedNameTagPrefixLen).toLower();
localizedNames.insert(languageId, localizedNameEntry.value());
}
QString parentId = regionSuffix;
//.........这里部分代码省略.........
示例5: bytesToUtf8
QString bytesToUtf8(QLatin1String bytes) {
return QString::fromUtf8(bytes.data(), bytes.size());
}