From beaef85b8d5cb4b0153f87736c56ef25eeec13d4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 6 Dec 2019 12:03:25 +0100 Subject: Add toInt() and friends to QStringView Make the API more symmetric with regards to both QString and QStringRef. Having this available helps making QStringView more of a drop-in replacement for QStringRef. QStringRef is planned to get removed in Qt 6. Change-Id: Ife036c0b55970078f42e1335442ff9ee5f4a2f0d Reviewed-by: Volker Hilsheimer --- src/corelib/text/qstringview.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/corelib/text/qstringview.h') diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index 0ae1772530..2b7863e156 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -320,6 +320,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 Q_CORE_EXPORT float toFloat(bool *ok = nullptr) const; + Q_REQUIRED_RESULT Q_CORE_EXPORT double toDouble(bool *ok = nullptr) const; + Q_REQUIRED_RESULT inline int toWCharArray(wchar_t *array) const; // defined in qstring.h // -- cgit v1.2.3