Ref T338, utility functions / parsing

- nthIndexOf
- measurement unit can be parsed case insensitive
- CSimpleCommandParser::remainingStringAfter from n-th space
- improved frequency parsing
This commit is contained in:
Klaus Basan
2018-09-08 02:11:03 +02:00
parent 3d2d999f7a
commit a9d728f451
7 changed files with 146 additions and 21 deletions

View File

@@ -58,9 +58,10 @@ namespace BlackMisc
QString CSimpleCommandParser::remainingStringAfter(int index) const
{
if (index < 0) { return m_originalLine.trimmed(); }
if (index < 0) { return m_cleanedLine; }
const QString p = this->part(index);
int fi = m_originalLine.indexOf(p, 0, Qt::CaseInsensitive);
const int from = index < 1 ? 0 : nthIndexOf(m_cleanedLine, ' ', index, Qt::CaseInsensitive);
const int fi = m_cleanedLine.indexOf(p, from, Qt::CaseInsensitive);
if (fi < 0) { return ""; }
return m_originalLine.mid(fi).trimmed();
}