summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-01-25 13:22:55 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-02-19 18:16:38 +0000
commit1da975cdc5297ddde584981c4bf301b288ccaca9 (patch)
tree188ad7a00c8f1f8a53f627a59f7664013ce603fc /src/corelib/tools/qstring.h
parent342acf66fe640c72e1a7c8837ba5cdefae06f9c9 (diff)
QLatin1String: add at()/op[]/mid()/right()/left()
QLatin1String can be used as a string-view-like type. When attempting to do so in uic, mid() and at() were found to be missing. Added the others for completeness. Use the new functions in uic, for which they were originally conceived. [ChangeLog][QtCore][QLatin1String] Added at(), operator[](), mid(), right(), left(). Change-Id: I4cfe3e9ed1157dedee754b2012d9678fe72b161e Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/corelib/tools/qstring.h')
-rw-r--r--src/corelib/tools/qstring.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index ddaab1f544..90a56828e2 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -99,6 +99,18 @@ public:
Q_DECL_CONSTEXPR int size() const Q_DECL_NOTHROW { return m_size; }
Q_DECL_CONSTEXPR const char *data() const Q_DECL_NOTHROW { return m_data; }
+ Q_DECL_CONSTEXPR QLatin1Char at(int i) const { return QLatin1Char(m_data[i]); }
+ Q_DECL_CONSTEXPR QLatin1Char operator[](int i) const { return at(i); }
+
+ Q_DECL_CONSTEXPR QLatin1String mid(int pos) const
+ { return QLatin1String(m_data + pos, m_size - pos); }
+ Q_DECL_CONSTEXPR QLatin1String mid(int pos, int n) const
+ { return QLatin1String(m_data + pos, n); }
+ Q_DECL_CONSTEXPR QLatin1String left(int n) const
+ { return QLatin1String(m_data, n); }
+ Q_DECL_CONSTEXPR QLatin1String right(int n) const
+ { return QLatin1String(m_data + m_size - n, n); }
+
inline bool operator==(const QString &s) const Q_DECL_NOTHROW;
inline bool operator!=(const QString &s) const Q_DECL_NOTHROW;
inline bool operator>(const QString &s) const Q_DECL_NOTHROW;