From 9b0f381f2a6304467ec0dae019b356e1c63c0725 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 15 Mar 2012 12:52:49 +0000 Subject: QRegularExpression: various documentation improvements/fixes Change-Id: I683afb24f888ab6cf3c543fba8cd193a730709af Reviewed-by: Casper van Donderen --- src/corelib/tools/qregularexpression.cpp | 39 +++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 1db78519a3..eaa20b304a 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -135,7 +135,7 @@ QT_BEGIN_NAMESPACE \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 2 - The pattern() function returns the pattern that it's currently set for a + The pattern() function returns the pattern that is currently set for a QRegularExpression object: \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 3 @@ -342,9 +342,9 @@ QT_BEGIN_NAMESPACE string; however, the subpattern \c{def} matches the subject string completely, and therefore a complete match is reported. - In case multiple partial matches are found when matching (but no complete - match), then the QRegularExpressionMatch will report the first one that it - is found. For instance: + If multiple partial matches are found when matching (but no complete + match), then the QRegularExpressionMatch object will report the first one + that is found. For instance: \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 18 @@ -440,7 +440,7 @@ QT_BEGIN_NAMESPACE \section2 Exact matching - QRegExp::exactMatch in Qt 4 served for two purposes: it exactly matched + QRegExp::exactMatch() in Qt 4 served two purposes: it exactly matched a regular expression against a subject string, and it implemented partial matching. In fact, if an exact match was not found, one could still find out how much of the subject string was matched by the regular expression @@ -478,9 +478,20 @@ QT_BEGIN_NAMESPACE matching correctly (that is, like Perl does). In particular, patterns that can match 0 characters (like \c{"a*"}) are problematic. - QRegularExpression::globalMatch implements Perl global match correctly, and + QRegularExpression::globalMatch() implements Perl global match correctly, and the returned iterator can be used to examine each result. + \section2 Unicode properties support + + When using QRegExp, character classes such as \c{\w}, \c{\d}, etc. match + characters with the corresponding Unicode property: for instance, \c{\d} + matches any character with the Unicode Nd (decimal digit) property. + + Those character classes only match ASCII characters by default when using + QRegularExpression: for instance, \c{\d} matches exactly a character in the + \c{0-9} ASCII range. It is possible to change this behaviour by using the + UseUnicodePropertiesOption pattern option. + \section2 Wildcard matching There is no equivalent of wildcard matching in QRegularExpression. @@ -494,11 +505,11 @@ QT_BEGIN_NAMESPACE \section2 Minimal matching - QRegExp::setMinimal implemented minimal matching by simply reversing the + QRegExp::setMinimal() implemented minimal matching by simply reversing the greediness of the quantifiers (QRegExp did not support lazy quantifiers, like \c{*?}, \c{+?}, etc.). QRegularExpression instead does support greedy, lazy and possessive quantifiers. The InvertedGreedinessOption - pattern option can be useful to emulate the effects of QRegExp::setMinimal: + pattern option can be useful to emulate the effects of QRegExp::setMinimal(): if enabled, it inverts the greediness of quantifiers (greedy ones become lazy and vice versa). @@ -675,7 +686,7 @@ QT_BEGIN_NAMESPACE equivalent for this option in Perl regular expressions. \value UseUnicodePropertiesOption - The meaning of the \c{\w}, \c{\d}, etc., character types, as well as + The meaning of the \c{\w}, \c{\d}, etc., character classes, as well as the meaning of their counterparts (\c{\W}, \c{\D}, etc.), is changed from matching ASCII charaters only to matching any character with the corresponding Unicode property. For instance, \c{\d} is changed to @@ -1004,12 +1015,18 @@ class QPcreJitStackPointer Q_DISABLE_COPY(QPcreJitStackPointer); public: + /*! + \internal + */ QPcreJitStackPointer() { // The default JIT stack size in PCRE is 32K, // we allocate from 32K up to 512K. stack = pcre16_jit_stack_alloc(32*1024, 512*1024); } + /*! + \internal + */ ~QPcreJitStackPointer() { if (stack) @@ -1572,8 +1589,8 @@ bool QRegularExpression::operator==(const QRegularExpression &re) const a backslash all characters in \a str, except for the characters in the \c{[A-Z]}, \c{[a-z]} and \c{[0-9]} ranges, as well as the underscore (\c{_}) character. The only difference with Perl is that a literal NUL - inside \a str is escaped with the sequence \c{"\\\\0"} (backslash + - \c{'0'}), instead of \c{"\\\\\\0"} (backslash + \c{NUL}). + inside \a str is escaped with the sequence \c{"\\0"} (backslash + + \c{'0'}), instead of \c{"\\\0"} (backslash + \c{NUL}). */ QString QRegularExpression::escape(const QString &str) { -- cgit v1.2.3 From 389f2a076d3321c285fb9652177ccb3367019e51 Mon Sep 17 00:00:00 2001 From: Wolf-Michael Bolle Date: Thu, 15 Mar 2012 15:56:14 +0100 Subject: Removed move constructor. All C++-2011-specific constructors, operators and methods may be inline only in Qt. Since an implementation in the header file does not seem to be possible for QMimeType without breaking backward compatiblity the move constructor has to disappear altogether. See also the discussion at http://codereview.qt-project.org/#change,19150 Change-Id: If07347a51a1ae5bd4c2d292dac835592ede4b370 Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimetype.cpp | 19 ------------------- src/corelib/mimetypes/qmimetype.h | 2 -- 2 files changed, 21 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp index ebf687bb4b..18ce5e5000 100644 --- a/src/corelib/mimetypes/qmimetype.cpp +++ b/src/corelib/mimetypes/qmimetype.cpp @@ -181,25 +181,6 @@ QMimeType &QMimeType::operator=(const QMimeType &other) return *this; } -#ifdef Q_COMPILER_RVALUE_REFS -/*! - \fn QMimeType::QMimeType(QMimeType &&other); - Constructs this QMimeType object by moving the data of the rvalue reference \a other. - */ -QMimeType::QMimeType(QMimeType &&other) : - d(std::move(other.d)) -{ - DBG() << "name():" << name(); - //DBG() << "aliases():" << aliases(); - //DBG() << "comment():" << comment(); - DBG() << "genericIconName():" << genericIconName(); - DBG() << "iconName():" << iconName(); - DBG() << "globPatterns():" << globPatterns(); - DBG() << "suffixes():" << suffixes(); - DBG() << "preferredSuffix():" << preferredSuffix(); -} -#endif - /*! \fn QMimeType::QMimeType(const QMimeTypePrivate &dd); Assigns the data of the QMimeTypePrivate \a dd to this QMimeType object, and returns a reference to this object. diff --git a/src/corelib/mimetypes/qmimetype.h b/src/corelib/mimetypes/qmimetype.h index 68d17caaba..172973e77a 100644 --- a/src/corelib/mimetypes/qmimetype.h +++ b/src/corelib/mimetypes/qmimetype.h @@ -59,8 +59,6 @@ public: QMimeType(const QMimeType &other); QMimeType &operator=(const QMimeType &other); #ifdef Q_COMPILER_RVALUE_REFS - QMimeType(QMimeType &&other); - QMimeType &operator=(QMimeType &&other) { qSwap(d, other.d); -- cgit v1.2.3 From d823646db3e9f72569717dc656e5b2e4d3ce7709 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 29 Aug 2011 17:49:48 +0200 Subject: containers: add C++11-style c{begin,end}() as alias for const{Begin,End}() C++11 adds cbegin()/cend() functions for the same reason Qt has constBegin()/constEnd(). This patch adds these functions to the Qt containers with the same implementation as constBegin()/constEnd(). It also fixes the return types in the documentation of existing constFind() functions (documentation only). C++11 only adds cbegin()/cend() (and crbegin()/crend(), which Qt doesn't have). In particular, it doesn't add cfind(), so I didn't supply these, even though Qt comes with constFind(). This is a forward-port of https://qt.gitorious.org/qt/qt/merge_requests/1365. Change-Id: Ida086b64246b24e25254eafbcb06c8e33388502b Reviewed-by: Olivier Goffart --- src/corelib/tools/qbytearray.cpp | 12 ++++++++++++ src/corelib/tools/qbytearray.h | 6 ++++++ src/corelib/tools/qhash.cpp | 20 +++++++++++++++++++- src/corelib/tools/qhash.h | 2 ++ src/corelib/tools/qlinkedlist.cpp | 18 ++++++++++++++++++ src/corelib/tools/qlinkedlist.h | 2 ++ src/corelib/tools/qlist.cpp | 18 ++++++++++++++++++ src/corelib/tools/qlist.h | 2 ++ src/corelib/tools/qmap.cpp | 20 +++++++++++++++++++- src/corelib/tools/qmap.h | 2 ++ src/corelib/tools/qset.h | 2 ++ src/corelib/tools/qset.qdoc | 18 ++++++++++++++++++ src/corelib/tools/qstring.cpp | 18 ++++++++++++++++++ src/corelib/tools/qstring.h | 6 ++++++ src/corelib/tools/qvarlengtharray.h | 2 ++ src/corelib/tools/qvarlengtharray.qdoc | 18 ++++++++++++++++++ src/corelib/tools/qvector.cpp | 18 ++++++++++++++++++ src/corelib/tools/qvector.h | 2 ++ 18 files changed, 184 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index b6719c9536..db22a774f4 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -799,6 +799,12 @@ const QConstByteArrayData<1> QByteArray::shared_empty = { { Q_REFCOUNT_INITIALIZ \internal */ +/*! \fn QByteArray::const_iterator QByteArray::cbegin() const + \since 5.0 + + \internal +*/ + /*! \fn QByteArray::const_iterator QByteArray::constBegin() const \internal @@ -814,6 +820,12 @@ const QConstByteArrayData<1> QByteArray::shared_empty = { { Q_REFCOUNT_INITIALIZ \internal */ +/*! \fn QByteArray::const_iterator QByteArray::cend() const + \since 5.0 + + \internal +*/ + /*! \fn QByteArray::const_iterator QByteArray::constEnd() const \internal diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 09c43988fd..7711d7349e 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -358,9 +358,11 @@ public: typedef const_iterator ConstIterator; iterator begin(); const_iterator begin() const; + const_iterator cbegin() const; const_iterator constBegin() const; iterator end(); const_iterator end() const; + const_iterator cend() const; const_iterator constEnd() const; // stl compatibility @@ -492,12 +494,16 @@ inline QByteArray::iterator QByteArray::begin() { detach(); return d->data(); } inline QByteArray::const_iterator QByteArray::begin() const { return d->data(); } +inline QByteArray::const_iterator QByteArray::cbegin() const +{ return d->data(); } inline QByteArray::const_iterator QByteArray::constBegin() const { return d->data(); } inline QByteArray::iterator QByteArray::end() { detach(); return d->data() + d->size; } inline QByteArray::const_iterator QByteArray::end() const { return d->data() + d->size; } +inline QByteArray::const_iterator QByteArray::cend() const +{ return d->data() + d->size; } inline QByteArray::const_iterator QByteArray::constEnd() const { return d->data() + d->size; } inline QByteArray &QByteArray::operator+=(char c) diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index d5703e8b2a..62fc6c5d86 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -1045,6 +1045,15 @@ void QHashData::checkSanity() \overload */ +/*! \fn QHash::const_iterator QHash::cbegin() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the first item + in the hash. + + \sa begin(), cend() +*/ + /*! \fn QHash::const_iterator QHash::constBegin() const Returns a const \l{STL-style iterator} pointing to the first item @@ -1074,6 +1083,15 @@ void QHashData::checkSanity() \sa constBegin(), end() */ +/*! \fn QHash::const_iterator QHash::cend() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the imaginary + item after the last item in the hash. + + \sa cbegin(), end() +*/ + /*! \fn QHash::iterator QHash::erase(iterator pos) Removes the (key, value) pair associated with the iterator \a pos @@ -1114,7 +1132,7 @@ void QHashData::checkSanity() \overload */ -/*! \fn QHash::iterator QHash::constFind(const Key &key) const +/*! \fn QHash::const_iterator QHash::constFind(const Key &key) const \since 4.1 Returns an iterator pointing to the item with the \a key in the diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 9e4007c26e..55fa788543 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -440,9 +440,11 @@ public: // STL style inline iterator begin() { detach(); return iterator(d->firstNode()); } inline const_iterator begin() const { return const_iterator(d->firstNode()); } + inline const_iterator cbegin() const { return const_iterator(d->firstNode()); } inline const_iterator constBegin() const { return const_iterator(d->firstNode()); } inline iterator end() { detach(); return iterator(e); } inline const_iterator end() const { return const_iterator(e); } + inline const_iterator cend() const { return const_iterator(e); } inline const_iterator constEnd() const { return const_iterator(e); } iterator erase(iterator it); diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp index b31ef3e5e9..50f6f447b2 100644 --- a/src/corelib/tools/qlinkedlist.cpp +++ b/src/corelib/tools/qlinkedlist.cpp @@ -330,6 +330,15 @@ const QLinkedListData QLinkedListData::shared_null = { \overload */ +/*! \fn QLinkedList::const_iterator QLinkedList::cbegin() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the first item + in the list. + + \sa begin(), cend() +*/ + /*! \fn QLinkedList::const_iterator QLinkedList::constBegin() const Returns a const \l{STL-style iterator} pointing to the first item @@ -351,6 +360,15 @@ const QLinkedListData QLinkedListData::shared_null = { \overload */ +/*! \fn QLinkedList::const_iterator QLinkedList::cend() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the imaginary + item after the last item in the list. + + \sa cbegin(), end() +*/ + /*! \fn QLinkedList::const_iterator QLinkedList::constEnd() const Returns a const \l{STL-style iterator} pointing to the imaginary diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 2e6d05ac35..2b23fc230c 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -180,9 +180,11 @@ public: // stl style inline iterator begin() { detach(); return e->n; } inline const_iterator begin() const { return e->n; } + inline const_iterator cbegin() const { return e->n; } inline const_iterator constBegin() const { return e->n; } inline iterator end() { detach(); return e; } inline const_iterator end() const { return e; } + inline const_iterator cend() const { return e; } inline const_iterator constEnd() const { return e; } iterator insert(iterator before, const T &t); iterator erase(iterator pos); diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 263045a25d..9b40e2d37a 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -921,6 +921,15 @@ void **QListData::erase(void **xi) \overload */ +/*! \fn QList::const_iterator QList::cbegin() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the first item + in the list. + + \sa begin(), cend() +*/ + /*! \fn QList::const_iterator QList::constBegin() const Returns a const \l{STL-style iterator} pointing to the first item @@ -942,6 +951,15 @@ void **QListData::erase(void **xi) \overload */ +/*! \fn QList::const_iterator QList::cend() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the imaginary + item after the last item in the list. + + \sa cbegin(), end() +*/ + /*! \fn QList::const_iterator QList::constEnd() const Returns a const \l{STL-style iterator} pointing to the imaginary diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index bf6933732c..3d55b3002d 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -262,9 +262,11 @@ public: // stl style inline iterator begin() { detach(); return reinterpret_cast(p.begin()); } inline const_iterator begin() const { return reinterpret_cast(p.begin()); } + inline const_iterator cbegin() const { return reinterpret_cast(p.begin()); } inline const_iterator constBegin() const { return reinterpret_cast(p.begin()); } inline iterator end() { detach(); return reinterpret_cast(p.end()); } inline const_iterator end() const { return reinterpret_cast(p.end()); } + inline const_iterator cend() const { return reinterpret_cast(p.end()); } inline const_iterator constEnd() const { return reinterpret_cast(p.end()); } iterator insert(iterator before, const T &t); iterator erase(iterator pos); diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 103d074941..e0b53fc64e 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -682,6 +682,15 @@ void QMapData::dump() \overload */ +/*! \fn QMap::const_iterator QMap::cbegin() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the first item + in the map. + + \sa begin(), cend() +*/ + /*! \fn QMap::const_iterator QMap::constBegin() const Returns a const \l{STL-style iterator} pointing to the first item @@ -703,6 +712,15 @@ void QMapData::dump() \overload */ +/*! \fn QMap::const_iterator QMap::cend() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the imaginary + item after the last item in the map. + + \sa cbegin(), end() +*/ + /*! \fn QMap::const_iterator QMap::constEnd() const Returns a const \l{STL-style iterator} pointing to the imaginary @@ -744,7 +762,7 @@ void QMapData::dump() \overload */ -/*! \fn QMap::iterator QMap::constFind(const Key &key) const +/*! \fn QMap::const_iterator QMap::constFind(const Key &key) const \since 4.1 Returns an const iterator pointing to the item with key \a key in the diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 515b60bea6..a00f9477f6 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -362,12 +362,14 @@ public: // STL style inline iterator begin() { detach(); return iterator(e->forward[0]); } inline const_iterator begin() const { return const_iterator(e->forward[0]); } + inline const_iterator cbegin() const { return const_iterator(e->forward[0]); } inline const_iterator constBegin() const { return const_iterator(e->forward[0]); } inline iterator end() { detach(); return iterator(e); } inline const_iterator end() const { return const_iterator(e); } + inline const_iterator cend() const { return const_iterator(e); } inline const_iterator constEnd() const { return const_iterator(e); } iterator erase(iterator it); diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 7750cd1147..e85c770d42 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -164,9 +164,11 @@ public: // STL style inline iterator begin() { return q_hash.begin(); } inline const_iterator begin() const { return q_hash.begin(); } + inline const_iterator cbegin() const { return q_hash.begin(); } inline const_iterator constBegin() const { return q_hash.constBegin(); } inline iterator end() { return q_hash.end(); } inline const_iterator end() const { return q_hash.end(); } + inline const_iterator cend() const { return q_hash.end(); } inline const_iterator constEnd() const { return q_hash.constEnd(); } iterator erase(iterator i) { return q_hash.erase(reinterpret_cast(i)); } diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc index b33064e1b8..139b017966 100644 --- a/src/corelib/tools/qset.qdoc +++ b/src/corelib/tools/qset.qdoc @@ -343,6 +343,15 @@ item in the set. */ +/*! \fn QSet::const_iterator QSet::cbegin() const + \since 5.0 + + Returns a const \l{STL-style iterator} positioned at the first + item in the set. + + \sa begin(), cend() +*/ + /*! \fn QSet::const_iterator QSet::constBegin() const Returns a const \l{STL-style iterator} positioned at the first @@ -367,6 +376,15 @@ imaginary item after the last item in the set. */ +/*! \fn QSet::const_iterator QSet::cend() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the imaginary + item after the last item in the set. + + \sa cbegin(), end() +*/ + /*! \fn QSet::const_iterator QSet::constEnd() const Returns a const \l{STL-style iterator} pointing to the imaginary diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 083abcbaad..57990c57ac 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -859,6 +859,15 @@ int QString::grow(int size) \overload begin() */ +/*! \fn QString::const_iterator QString::cbegin() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the first character + in the string. + + \sa begin(), cend() +*/ + /*! \fn QString::const_iterator QString::constBegin() const Returns a const \l{STL-style iterator} pointing to the first character @@ -880,6 +889,15 @@ int QString::grow(int size) \overload end() */ +/*! \fn QString::const_iterator QString::cend() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the imaginary + item after the last item in the list. + + \sa cbegin(), end() +*/ + /*! \fn QString::const_iterator QString::constEnd() const Returns a const \l{STL-style iterator} pointing to the imaginary diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 4d02fbe66d..437e98b662 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -558,9 +558,11 @@ public: typedef const_iterator ConstIterator; iterator begin(); const_iterator begin() const; + const_iterator cbegin() const; const_iterator constBegin() const; iterator end(); const_iterator end() const; + const_iterator cend() const; const_iterator constEnd() const; // STL compatibility @@ -904,12 +906,16 @@ inline QString::iterator QString::begin() { detach(); return reinterpret_cast(d->data()); } inline QString::const_iterator QString::begin() const { return reinterpret_cast(d->data()); } +inline QString::const_iterator QString::cbegin() const +{ return reinterpret_cast(d->data()); } inline QString::const_iterator QString::constBegin() const { return reinterpret_cast(d->data()); } inline QString::iterator QString::end() { detach(); return reinterpret_cast(d->data() + d->size); } inline QString::const_iterator QString::end() const { return reinterpret_cast(d->data() + d->size); } +inline QString::const_iterator QString::cend() const +{ return reinterpret_cast(d->data() + d->size); } inline QString::const_iterator QString::constEnd() const { return reinterpret_cast(d->data() + d->size); } inline bool QString::contains(const QString &s, Qt::CaseSensitivity cs) const diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index a6613a3774..4e042f765e 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -160,9 +160,11 @@ public: inline iterator begin() { return ptr; } inline const_iterator begin() const { return ptr; } + inline const_iterator cbegin() const { return ptr; } inline const_iterator constBegin() const { return ptr; } inline iterator end() { return ptr + s; } inline const_iterator end() const { return ptr + s; } + inline const_iterator cend() const { return ptr + s; } inline const_iterator constEnd() const { return ptr + s; } iterator insert(iterator before, int n, const T &x); inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); } diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index e1dc2bee9a..e92f91aa47 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -451,6 +451,15 @@ \overload */ +/*! \fn QVarLengthArray::const_iterator QVarLengthArray::cbegin() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the first item + in the array. + + \sa begin(), cend() +*/ + /*! \fn QVarLengthArray::const_iterator QVarLengthArray::constBegin() const \since 4.8 @@ -475,6 +484,15 @@ \overload */ +/*! \fn QVarLengthArray::const_iterator QVarLengthArray::cend() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the imaginary + item after the last item in the array. + + \sa cbegin(), end() +*/ + /*! \fn QVarLengthArray::const_iterator QVarLengthArray::constEnd() const \since 4.8 diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp index 75c219bbc9..0f5c2d3cd9 100644 --- a/src/corelib/tools/qvector.cpp +++ b/src/corelib/tools/qvector.cpp @@ -698,6 +698,15 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive \overload */ +/*! \fn QVector::const_iterator QVector::cbegin() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the first item + in the vector. + + \sa begin(), cend() +*/ + /*! \fn QVector::const_iterator QVector::constBegin() const Returns a const \l{STL-style iterator} pointing to the first item @@ -719,6 +728,15 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive \overload */ +/*! \fn QVector::const_iterator QVector::cend() const + \since 5.0 + + Returns a const \l{STL-style iterator} pointing to the imaginary + item after the last item in the vector. + + \sa cbegin(), end() +*/ + /*! \fn QVector::const_iterator QVector::constEnd() const Returns a const \l{STL-style iterator} pointing to the imaginary diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 4230e55ff5..09aabe5d73 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -245,9 +245,11 @@ public: #endif inline iterator begin() { detach(); return p->array; } inline const_iterator begin() const { return p->array; } + inline const_iterator cbegin() const { return p->array; } inline const_iterator constBegin() const { return p->array; } inline iterator end() { detach(); return p->array + d->size; } inline const_iterator end() const { return p->array + d->size; } + inline const_iterator cend() const { return p->array + d->size; } inline const_iterator constEnd() const { return p->array + d->size; } iterator insert(iterator before, int n, const T &x); inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); } -- cgit v1.2.3 From 7f67d0810e6899290b50120ee7a22d0a8a8300ec Mon Sep 17 00:00:00 2001 From: Lincoln Ramsay Date: Fri, 16 Mar 2012 12:08:51 +1000 Subject: Don't reject plugins that have empty meta-data Having an empty Json object ({}) should be valid meta-data but this check means that there needs to be at least one key-value pair or the plugin will be rejected. Change-Id: I578ccc35016af16fd30b3807e796fa63c0282f30 Reviewed-by: Lars Knoll --- src/corelib/plugin/qfactoryloader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index cdc72cf35d..480bc0da74 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -175,8 +175,7 @@ void QFactoryLoader::update() QString iid = library->metaData.value(QLatin1String("IID")).toString(); if (iid == QLatin1String(d->iid.constData(), d->iid.size())) { QJsonObject object = library->metaData.value(QLatin1String("MetaData")).toObject(); - if (!object.isEmpty()) - metaDataOk = true; + metaDataOk = true; QJsonArray k = object.value(QLatin1String("Keys")).toArray(); for (int i = 0; i < k.size(); ++i) { -- cgit v1.2.3 From 78e0ab3342c9b877c55cb74d19fd87c8c9a5385a Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 16 Mar 2012 16:05:09 -0700 Subject: QPointer: update its document and changes-5.0.0 QPointer has been un-deprecated and one behavior which slightly different from Qt4 has been fixed. see SHA: b8773165d76e0d5d46287d92f9d6bdbbd2110180 and SHA: 497622cafe235eadb5dd5056b196d8451ee89071 Change-Id: I4bae2cce3ebfebd8f59b18b5a6a7a7226b8353b9 Reviewed-by: Olivier Goffart Reviewed-by: Lars Knoll Reviewed-by: Casper van Donderen --- src/corelib/kernel/qpointer.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp index f81451d906..e0e14e5b79 100644 --- a/src/corelib/kernel/qpointer.cpp +++ b/src/corelib/kernel/qpointer.cpp @@ -56,7 +56,7 @@ destroyed while you still hold a reference to it. You can safely test the pointer for validity. - Note that Qt 5 introduces two slight changes in behavior when using QPointer. + Note that Qt 5 introduces a slight change in behavior when using QPointer. \list @@ -66,12 +66,6 @@ cleared). Any QPointers tracking a widget will \b NOT be cleared before the QWidget destructor destroys the children for the widget being tracked. - \li When constructing a QSharedPointer to take ownership of an object after a - QPointer is already tracking the object. Previously, the shared pointer - construction would not be affected by the QPointer, but now that QPointer - is implemented using QWeakPoiner, constructing the QSharedPointer will - cause an \c abort(). - \endlist Qt also provides QSharedPointer, an implementation of a reference-counted -- cgit v1.2.3