diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-08-01 13:35:33 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-08-04 20:21:06 +0200 |
commit | fd681d3e85d944feed76063555d7122383c70f51 (patch) | |
tree | e2cf7e1b4e3624e72d7493a5041e28657411c5d8 /src/corelib/text/qstring.h | |
parent | e995bfc0ea783c15bb173f060099ca24f277c763 (diff) |
Move q{,Utf8, Utf16}Printable to qstring.h
Task-number: QTBUG-99313
Change-Id: I76ef84e4c90ab04a3e04c165ba46800e27ea6122
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/text/qstring.h')
-rw-r--r-- | src/corelib/text/qstring.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index d426b55e76..697233e443 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1532,6 +1532,23 @@ inline const QString &asString(const QString &s) { return s; } inline QString &&asString(QString &&s) { return std::move(s); } } +#ifndef qPrintable +# define qPrintable(string) QtPrivate::asString(string).toLocal8Bit().constData() +#endif + +#ifndef qUtf8Printable +# define qUtf8Printable(string) QtPrivate::asString(string).toUtf8().constData() +#endif + +/* + Wrap QString::utf16() with enough casts to allow passing it + to QString::asprintf("%ls") without warnings. +*/ +#ifndef qUtf16Printable +# define qUtf16Printable(string) \ + static_cast<const wchar_t*>(static_cast<const void*>(QtPrivate::asString(string).utf16())) +#endif + // // QStringView::arg() implementation // |