summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstringview.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2019-12-06 12:03:25 +0100
committerLars Knoll <lars.knoll@qt.io>2020-05-29 19:01:58 +0200
commitbeaef85b8d5cb4b0153f87736c56ef25eeec13d4 (patch)
treee3a540958cac590965210896884a469309fcc533 /src/corelib/text/qstringview.h
parentbf03396ad8e69369db0e9ee87aa7bb95e1a431a8 (diff)
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 <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/text/qstringview.h')
-rw-r--r--src/corelib/text/qstringview.h11
1 files changed, 11 insertions, 0 deletions
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
//