Use midRef where possible

parent 68ba7adb
......@@ -108,11 +108,11 @@ void CustomToStringTest::testUuid()
QCOMPARE(structure->childAt(2)->effectiveByteOrder(),
isGUID ? QSysInfo::LittleEndian : QSysInfo::BigEndian);
bool ok;
quint32 val1 = uuidString.mid(1, 8).toUInt(&ok, 16);
quint32 val1 = uuidString.midRef(1, 8).toUInt(&ok, 16);
QVERIFY(ok);
quint16 val2 = uuidString.mid(10, 4).toUShort(&ok, 16);
quint16 val2 = uuidString.midRef(10, 4).toUShort(&ok, 16);
QVERIFY(ok);
quint16 val3 = uuidString.mid(15, 4).toUShort(&ok, 16);
quint16 val3 = uuidString.midRef(15, 4).toUShort(&ok, 16);
QVERIFY(ok);
qDebug() << hex << val1 << val2 << val3;
QCOMPARE(structure->childAt(0)->asPrimitive()->value().value<quint32>(), val1);
......
......@@ -96,7 +96,7 @@ QVariant CharDataInformationMethods::staticDataFromWidget(const QWidget* w)
{
//hex escape:
bool okay;
QString valStr = text.mid(2, 2); //only 2 chars
const QStringRef valStr = text.midRef(2, 2); //only 2 chars
quint8 val = valStr.toInt(&okay, 16);
if (okay)
return val;
......@@ -119,7 +119,7 @@ QVariant CharDataInformationMethods::staticDataFromWidget(const QWidget* w)
{
//octal escape:
bool okay;
QString valStr = text.mid(1, 3); //only 2 chars
const QStringRef valStr = text.midRef(1, 3); //only 2 chars
quint8 val = valStr.toInt(&okay, 8);
if (okay)
return val;
......
......@@ -142,7 +142,7 @@ QPair<AllPrimitiveTypes, QString> EnumDefinition::convertToEnumEntry(const QStri
bool ok = false;
if (valueString.startsWith(QLatin1String("0x")))
{
intValue = valueString.mid(2).toULongLong(&ok, 16);
intValue = valueString.midRef(2).toULongLong(&ok, 16);
}
else
{
......
......@@ -107,13 +107,13 @@ ParsedNumber<int> ParserUtils::intFromString(const QString& str)
int value = 0;
bool okay = false;
if (str.startsWith(QLatin1String("0x")))
value = str.mid(2).toInt(&okay, 16);
value = str.midRef(2).toInt(&okay, 16);
else if (str.startsWith(QLatin1String("-0x")))
{
//special case for minimum possible value
if (str == QLatin1String("-0x80000000"))
return ParsedNumber<int>(-0x80000000, str, true);
value = -str.mid(3).toInt(&okay, 16);
value = -str.midRef(3).toInt(&okay, 16);
}
else
value = str.toInt(&okay, 10);
......@@ -125,7 +125,7 @@ ParsedNumber<uint> ParserUtils::uintFromString(const QString& str)
uint value = 0;
bool okay;
if (str.startsWith(QLatin1String("0x")))
value = str.mid(2).toUInt(&okay, 16);
value = str.midRef(2).toUInt(&okay, 16);
else
value = str.toUInt(&okay, 10);
return ParsedNumber<uint>(value, str, okay);
......@@ -136,7 +136,7 @@ ParsedNumber<quint64> ParserUtils::uint64FromString(const QString& str)
quint64 value = 0;
bool okay;
if (str.startsWith(QLatin1String("0x")))
value = str.mid(2).toULongLong(&okay, 16);
value = str.midRef(2).toULongLong(&okay, 16);
else
value = str.toULongLong(&okay, 10);
return ParsedNumber<quint64>(value, str, okay);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment