From 9c02bfdb7330ad282b27017cc9fc71386d5a0e8c Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Tue, 18 Oct 2016 22:40:26 +0300 Subject: [PATCH] QStringRef: add constBegin() and constEnd() These methods were missing in the API. constBegin, constEnd are the more Qt-ish names. Also it makes porting client code from QString to QStringRef easier. Change-Id: I3fce1d206073d26259fe0fa44d0f7ca718504ec3 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 25 +++++++++++++++++++++---- src/corelib/tools/qstring.h | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 942df9e0dd..fd51ce321d 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -8940,7 +8940,7 @@ ownership of it, no memory is freed when instances are destroyed. Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string. - \sa cbegin(), end(), rbegin(), rend() + \sa cbegin(), constBegin(), end(), constEnd(), rbegin(), rend() */ /*! @@ -8949,7 +8949,16 @@ ownership of it, no memory is freed when instances are destroyed. Same as begin(). - \sa begin(), cend(), rbegin(), rend() + \sa begin(), constBegin(), cend(), constEnd(), rbegin(), rend() +*/ + +/*! + \fn QStringRef::const_iterator QStringRef::constBegin() const + \since 5.9 + + Same as begin(). + + \sa begin(), cend(), constEnd(), rbegin(), rend() */ /*! @@ -8959,7 +8968,7 @@ ownership of it, no memory is freed when instances are destroyed. Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary character after the last character in the list. - \sa cbegin(), end(), rbegin(), rend() + \sa cbegin(), constBegin(), end(), constEnd(), rbegin(), rend() */ /*! \fn QStringRef::const_iterator QStringRef::cend() const @@ -8967,7 +8976,15 @@ ownership of it, no memory is freed when instances are destroyed. Same as end(). - \sa end(), cbegin(), rbegin(), rend() + \sa end(), constEnd(), cbegin(), constBegin(), rbegin(), rend() +*/ + +/*! \fn QStringRef::const_iterator QStringRef::constEnd() const + \since 5.9 + + Same as end(). + + \sa end(), cend(), cbegin(), constBegin(), rbegin(), rend() */ /*! diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 8a53a8f5be..8b7528577c 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1473,8 +1473,10 @@ public: inline const_iterator begin() const { return unicode(); } inline const_iterator cbegin() const { return unicode(); } + inline const_iterator constBegin() const { return unicode(); } inline const_iterator end() const { return unicode() + size(); } inline const_iterator cend() const { return unicode() + size(); } + inline const_iterator constEnd() const { return unicode() + size(); } inline const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } inline const_reverse_iterator crbegin() const { return rbegin(); } inline const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }