mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
Ref T415, utility function to parse "ini"-file
This commit is contained in:
@@ -151,7 +151,7 @@ namespace BlackMisc
|
||||
for (int i = 0; i < bytes.size(); i++)
|
||||
{
|
||||
const int b = static_cast<int>(bytes.at(i));
|
||||
h.append(intToHex(b, 2));
|
||||
h += intToHex(b, 2);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
@@ -398,6 +398,24 @@ namespace BlackMisc
|
||||
if (set.isEmpty()) { return QStringLiteral(""); }
|
||||
return set.toList().join(separator);
|
||||
}
|
||||
|
||||
QMap<QString, QString> parseIniValues(const QString &data)
|
||||
{
|
||||
QMap<QString, QString> map;
|
||||
QList<QStringRef> lines = splitLinesRefs(data);
|
||||
for (const QStringRef &l : lines)
|
||||
{
|
||||
if (l.isEmpty()) { continue; }
|
||||
const int i = l.indexOf("=");
|
||||
if (i < 0 || i >= l.length() + 1) { continue; }
|
||||
|
||||
const QString key = l.left(i).trimmed().toString();
|
||||
const QString value = l.mid(i + 1).toString();
|
||||
if (value.isEmpty()) { continue; }
|
||||
map.insert(key, value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
} // ns
|
||||
|
||||
//! \endcond
|
||||
|
||||
Reference in New Issue
Block a user