diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-09-23 12:30:44 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-10-12 11:25:15 +0200 |
commit | e0785253dfb3ace32e3626bcb03211bfaa4cd4e0 (patch) | |
tree | 22cd567a935f402eac261d439adc5e89500b9bb6 /src/corelib/text/qstringview.h | |
parent | 84b53a4514c62ab06034de555ed03e41ab718dfc (diff) |
Add toInt() and friends to QStringView
The implementations are not trimmed for efficiency, but as a porting
help for Qt 6. Because of that, they simply use the methods available
in QString.
Task-number: QTBUG-86516
Change-Id: I39ea04a6c96ca43f3a88a9be4e63a5dea4a4e479
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/corelib/text/qstringview.h')
-rw-r--r-- | src/corelib/text/qstringview.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index 72ddd91968..e599e5a8c2 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -310,6 +310,17 @@ public: Q_REQUIRED_RESULT bool isValidUtf16() const noexcept { return QtPrivate::isValidUtf16(*this); } + Q_REQUIRED_RESULT inline short toShort(bool *ok = nullptr, int base = 10) const; + Q_REQUIRED_RESULT inline ushort toUShort(bool *ok = nullptr, int base = 10) const; + Q_REQUIRED_RESULT inline int toInt(bool *ok = nullptr, int base = 10) const; + Q_REQUIRED_RESULT inline uint toUInt(bool *ok = nullptr, int base = 10) const; + Q_REQUIRED_RESULT inline long toLong(bool *ok = nullptr, int base = 10) const; + Q_REQUIRED_RESULT inline ulong toULong(bool *ok = nullptr, int base = 10) const; + Q_REQUIRED_RESULT inline qlonglong toLongLong(bool *ok = nullptr, int base = 10) const; + Q_REQUIRED_RESULT inline qulonglong toULongLong(bool *ok = nullptr, int base = 10) const; + Q_REQUIRED_RESULT inline float toFloat(bool *ok = nullptr) const; + Q_REQUIRED_RESULT inline double toDouble(bool *ok = nullptr) const; + Q_REQUIRED_RESULT inline int toWCharArray(wchar_t *array) const; // defined in qstring.h // |