Added utility rstrip() to remove whitespace at the right end of a string.

This commit is contained in:
Gerhard Hoffmann 2023-08-18 11:41:16 +02:00
parent 503b7c64f9
commit 385a7b7b00
2 changed files with 10 additions and 0 deletions

View File

@ -77,3 +77,12 @@ QString Utils::getTariffLoadTime(QString fileName) {
return "N/A"; return "N/A";
} }
QString Utils::rstrip(QString const &str) {
int n = str.size() - 1;
for (; n >= 0; --n) {
if (!str.at(n).isSpace()) {
return str.left(n + 1);
}
}
return "";
}

View File

@ -15,6 +15,7 @@ namespace Utils {
void printInfoMsg(QString const &infoMsg); void printInfoMsg(QString const &infoMsg);
void printLineEditInfo(QStringList const &lines); void printLineEditInfo(QStringList const &lines);
QString getTariffLoadTime(QString fileName); QString getTariffLoadTime(QString fileName);
QString rstrip(QString const &str);
} }
#endif // UTILS_H_INCLUDED #endif // UTILS_H_INCLUDED