From 6a237a4e766979ff191818cbdab2c5aa1a6f490b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 6 Aug 2014 11:57:31 -0300 Subject: Add some missing STL typedefs and functions to QStringRef and QByteArray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These will be needed in some template code that is to come. Change-Id: I5b93f4320313f7b15a6404de2c98f85485735fda Reviewed-by: Olivier Goffart Reviewed-by: Marc Mutz Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qbytearray.cpp | 16 +++++++++++++ src/corelib/tools/qbytearray.h | 4 ++++ src/corelib/tools/qstring.cpp | 50 ++++++++++++++++++++++++++++++++++++++++ src/corelib/tools/qstring.h | 10 ++++++++ 4 files changed, 80 insertions(+) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 10fc3dea2d..088a7c1769 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -4425,6 +4425,14 @@ QByteArray QByteArray::toPercentEncoding(const QByteArray &exclude, const QByteA \internal */ +/*! \typedef QByteArray::size_type + \internal +*/ + +/*! \typedef QByteArray::difference_type + \internal +*/ + /*! \typedef QByteArray::const_reference \internal */ @@ -4433,6 +4441,14 @@ QByteArray QByteArray::toPercentEncoding(const QByteArray &exclude, const QByteA \internal */ +/*! \typedef QByteArray::const_pointer + \internal +*/ + +/*! \typedef QByteArray::pointer + \internal +*/ + /*! \typedef QByteArray::value_type \internal */ diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index b5af305233..ba7fdbb10a 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -389,8 +389,12 @@ public: const_iterator constEnd() const; // stl compatibility + typedef int size_type; + typedef qptrdiff difference_type; typedef const char & const_reference; typedef char & reference; + typedef char *pointer; + typedef const char *const_pointer; typedef char value_type; void push_back(char c); void push_back(const char *c); diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 8b23f33735..87c5e65fe0 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -8370,6 +8370,30 @@ QDataStream &operator>>(QDataStream &in, QString &str) \sa {Implicitly Shared Classes} */ +/*! + \typedef QStringRef::size_type + \internal +*/ + +/*! + \typedef QStringRef::value_type + \internal +*/ + +/*! + \typedef QStringRef::const_pointer + \internal +*/ + +/*! + \typedef QStringRef::const_reference + \internal +*/ + +/*! + \typedef QStringRef::const_iterator + \internal +*/ /*! \fn QStringRef::QStringRef() @@ -8492,6 +8516,32 @@ ownership of it, no memory is freed when instances are destroyed. Same as unicode(). */ +/*! + \fn const QChar *QStringRef::begin() const + + Same as unicode(). +*/ + +/*! + \fn const QChar *QStringRef::cbegin() const + + Same as unicode(). +*/ + +/*! + \fn const QChar *QStringRef::end() const + + Returns a pointer to one character past the last one in this string. + (It is the same as \c {unicode() + size()}.) +*/ + +/*! + \fn const QChar *QStringRef::cend() const + + Returns a pointer to one character past the last one in this string. + (It is the same as \c {unicode() + size()}.) +*/ + /*! \fn const QChar *QStringRef::constData() const diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 349588911b..dfb98ffaa2 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1264,6 +1264,12 @@ class Q_CORE_EXPORT QStringRef { int m_position; int m_size; public: + typedef QString::size_type size_type; + typedef QString::value_type value_type; + typedef QString::const_iterator const_iterator; + typedef QString::const_pointer const_pointer; + typedef QString::const_reference const_reference; + // ### Qt 6: make this constructor constexpr, after the destructor is made trivial inline QStringRef():m_string(0), m_position(0), m_size(0){} inline QStringRef(const QString *string, int position, int size); @@ -1333,6 +1339,10 @@ public: } inline const QChar *data() const { return unicode(); } inline const QChar *constData() const { return unicode(); } + inline const QChar *begin() const { return unicode(); } + inline const QChar *cbegin() const { return unicode(); } + inline const QChar *end() const { return unicode() + size(); } + inline const QChar *cend() const { return unicode() + size(); } #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED QByteArray toAscii() const Q_REQUIRED_RESULT -- cgit v1.2.3