Added utility rstrip() to remove whitespace at the right end of a string.
This commit is contained in:
parent
503b7c64f9
commit
385a7b7b00
@ -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 "";
|
||||||
|
}
|
||||||
|
1
utils.h
1
utils.h
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user