Port QSettings from QStringRef to QStringView
Task-number: QTBUG-84319 Change-Id: If2b5d8eb78ab5ca78d365f137d9680b1f0646c6b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
0c2508efb2
commit
690abaac0e
@ -303,7 +303,7 @@ QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::F
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void QSettingsPrivate::processChild(QStringRef key, ChildSpec spec, QStringList &result)
|
void QSettingsPrivate::processChild(QStringView key, ChildSpec spec, QStringList &result)
|
||||||
{
|
{
|
||||||
if (spec != AllKeys) {
|
if (spec != AllKeys) {
|
||||||
int slashPos = key.indexOf(QLatin1Char('/'));
|
int slashPos = key.indexOf(QLatin1Char('/'));
|
||||||
@ -478,9 +478,9 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s)
|
|||||||
if (s.startsWith(QLatin1Char('@'))) {
|
if (s.startsWith(QLatin1Char('@'))) {
|
||||||
if (s.endsWith(QLatin1Char(')'))) {
|
if (s.endsWith(QLatin1Char(')'))) {
|
||||||
if (s.startsWith(QLatin1String("@ByteArray("))) {
|
if (s.startsWith(QLatin1String("@ByteArray("))) {
|
||||||
return QVariant(s.midRef(11, s.size() - 12).toLatin1());
|
return QVariant(QStringView{s}.mid(11, s.size() - 12).toLatin1());
|
||||||
} else if (s.startsWith(QLatin1String("@String("))) {
|
} else if (s.startsWith(QLatin1String("@String("))) {
|
||||||
return QVariant(s.midRef(8, s.size() - 9).toString());
|
return QVariant(QStringView{s}.mid(8, s.size() - 9).toString());
|
||||||
} else if (s.startsWith(QLatin1String("@Variant("))
|
} else if (s.startsWith(QLatin1String("@Variant("))
|
||||||
|| s.startsWith(QLatin1String("@DateTime("))) {
|
|| s.startsWith(QLatin1String("@DateTime("))) {
|
||||||
#ifndef QT_NO_DATASTREAM
|
#ifndef QT_NO_DATASTREAM
|
||||||
@ -493,7 +493,7 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s)
|
|||||||
version = QDataStream::Qt_4_0;
|
version = QDataStream::Qt_4_0;
|
||||||
offset = 9;
|
offset = 9;
|
||||||
}
|
}
|
||||||
QByteArray a = s.midRef(offset).toLatin1();
|
QByteArray a = QStringView{s}.mid(offset).toLatin1();
|
||||||
QDataStream stream(&a, QIODevice::ReadOnly);
|
QDataStream stream(&a, QIODevice::ReadOnly);
|
||||||
stream.setVersion(version);
|
stream.setVersion(version);
|
||||||
QVariant result;
|
QVariant result;
|
||||||
@ -1309,14 +1309,14 @@ QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec
|
|||||||
&confFile->originalKeys)->lowerBound( thePrefix);
|
&confFile->originalKeys)->lowerBound( thePrefix);
|
||||||
while (j != confFile->originalKeys.constEnd() && j.key().startsWith(thePrefix)) {
|
while (j != confFile->originalKeys.constEnd() && j.key().startsWith(thePrefix)) {
|
||||||
if (!confFile->removedKeys.contains(j.key()))
|
if (!confFile->removedKeys.contains(j.key()))
|
||||||
processChild(j.key().originalCaseKey().midRef(startPos), spec, result);
|
processChild(QStringView{j.key().originalCaseKey()}.mid(startPos), spec, result);
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
|
|
||||||
j = const_cast<const ParsedSettingsMap *>(
|
j = const_cast<const ParsedSettingsMap *>(
|
||||||
&confFile->addedKeys)->lowerBound(thePrefix);
|
&confFile->addedKeys)->lowerBound(thePrefix);
|
||||||
while (j != confFile->addedKeys.constEnd() && j.key().startsWith(thePrefix)) {
|
while (j != confFile->addedKeys.constEnd() && j.key().startsWith(thePrefix)) {
|
||||||
processChild(j.key().originalCaseKey().midRef(startPos), spec, result);
|
processChild(QStringView{j.key().originalCaseKey()}.mid(startPos), spec, result);
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,11 +413,11 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString &
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ((nextDot = domainName.indexOf(QLatin1Char('.'), curPos)) != -1) {
|
while ((nextDot = domainName.indexOf(QLatin1Char('.'), curPos)) != -1) {
|
||||||
javaPackageName.prepend(domainName.midRef(curPos, nextDot - curPos));
|
javaPackageName.prepend(QStringView{domainName}.mid(curPos, nextDot - curPos));
|
||||||
javaPackageName.prepend(QLatin1Char('.'));
|
javaPackageName.prepend(QLatin1Char('.'));
|
||||||
curPos = nextDot + 1;
|
curPos = nextDot + 1;
|
||||||
}
|
}
|
||||||
javaPackageName.prepend(domainName.midRef(curPos));
|
javaPackageName.prepend(QStringView{domainName}.mid(curPos));
|
||||||
javaPackageName = std::move(javaPackageName).toLower();
|
javaPackageName = std::move(javaPackageName).toLower();
|
||||||
if (curPos == 0)
|
if (curPos == 0)
|
||||||
javaPackageName.prepend(QLatin1String("com."));
|
javaPackageName.prepend(QLatin1String("com."));
|
||||||
@ -509,7 +509,7 @@ QStringList QMacSettingsPrivate::children(const QString &prefix, ChildSpec spec)
|
|||||||
QString currentKey =
|
QString currentKey =
|
||||||
qtKey(static_cast<CFStringRef>(CFArrayGetValueAtIndex(cfarray, k)));
|
qtKey(static_cast<CFStringRef>(CFArrayGetValueAtIndex(cfarray, k)));
|
||||||
if (currentKey.startsWith(prefix))
|
if (currentKey.startsWith(prefix))
|
||||||
processChild(currentKey.midRef(startPos), spec, result);
|
processChild(QStringView{currentKey}.mid(startPos), spec, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ public:
|
|||||||
const QString &organization, const QString &application);
|
const QString &organization, const QString &application);
|
||||||
static QSettingsPrivate *create(const QString &fileName, QSettings::Format format);
|
static QSettingsPrivate *create(const QString &fileName, QSettings::Format format);
|
||||||
|
|
||||||
static void processChild(QStringRef key, ChildSpec spec, QStringList &result);
|
static void processChild(QStringView key, ChildSpec spec, QStringList &result);
|
||||||
|
|
||||||
// Variant streaming functions
|
// Variant streaming functions
|
||||||
static QStringList variantListToStringList(const QVariantList &l);
|
static QStringList variantListToStringList(const QVariantList &l);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user