summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-08-06 11:57:31 -0300
committerThiago Macieira <thiago.macieira@intel.com>2014-08-08 00:05:03 +0200
commit6a237a4e766979ff191818cbdab2c5aa1a6f490b (patch)
treeff104c259fba37f1eb2f7d176ad0f5ed3c201f05
parent04ba6fbed900403ef8892820fa93925a8e21f7b1 (diff)
Add some missing STL typedefs and functions to QStringRef and QByteArray
These will be needed in some template code that is to come. Change-Id: I5b93f4320313f7b15a6404de2c98f85485735fda Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
-rw-r--r--src/corelib/tools/qbytearray.cpp16
-rw-r--r--src/corelib/tools/qbytearray.h4
-rw-r--r--src/corelib/tools/qstring.cpp50
-rw-r--r--src/corelib/tools/qstring.h10
4 files changed, 80 insertions, 0 deletions
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()
@@ -8493,6 +8517,32 @@ ownership of it, no memory is freed when instances are destroyed.
*/
/*!
+ \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
Same as unicode().
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