Go to the documentation of this file.
4 #if __has_include(<format>) // C++20
26 #ifdef __cpp_lib_format // C++20 with <format>
27 return QString::fromStdString(std::format(
"{:0{}d}", n, width));
29 return QString(
"%1").arg(n, width, 10, QChar(
'0'));
30 #endif // __cpp_lib_format
33 inline QString
indentSpaces(
unsigned int level,
unsigned int size = 4)
35 return {
static_cast<int>(level * size), QChar(
' ')};
43 return (val) ? QStringLiteral(
"true") : QStringLiteral(
"false");
48 Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive);
55 Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive)
65 #endif // STRINGUTIL_H_
bool naturalSortCompare(const QString &a, const QString &b, Qt::CaseSensitivity caseSensitivity=Qt::CaseSensitive)
naturalCompare as a std::sort compatible function (ignoring the third parameter, which is never used)...
QString indentSpaces(unsigned int level, unsigned int size=4)
MBASE_PUBLIC int naturalCompare(const QString &_a, const QString &_b, Qt::CaseSensitivity caseSensitivity=Qt::CaseSensitive)
This method chops the input a and b into pieces of digits and non-digits (a1.05 becomes a | 1 | .
QString intToPaddedString(int n, int width=2)
Creates a zero padded string representation of an integer.
MBASE_PUBLIC QString formatKBytes(int64_t sizeKB, int prec=1)
MBASE_PUBLIC bool isValidUTF8(const QByteArray &data)
MBASE_PUBLIC QString formatBytes(int64_t sizeB, int prec=1)
QString bool_to_string(bool val)
This is equivalent to QVariant(bool).toString()