summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-04-21 16:30:32 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-04-26 13:46:18 +0200
commit4ba25a092065a6422510a9f4afa4fbbabeda686c (patch)
treeb89e0109e4bddc22f70a872f72cb462305989f50 /src
parent19bfcdaa43f6ac8841942cb545811eab409f1713 (diff)
QStringIterator: port from uint to char32_t
Change-Id: I0ca47b87216478b28e29b0fa1a118ef13b6d7c84 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp8
-rw-r--r--src/corelib/text/qstring.cpp12
-rw-r--r--src/corelib/text/qstringiterator.qdoc16
-rw-r--r--src/corelib/text/qstringiterator_p.h16
4 files changed, 25 insertions, 27 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp
index eb09fb99e2..8085e32787 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp
@@ -62,8 +62,6 @@ QStringIterator i(string); // implicitly converted to QStringView
//! [0]
//! [1]
-// will print 97, 32, 115, 116, etc.;
-// that is, the decimal value of the code points in the Unicode string "a string"
while (i.hasNext())
qDebug() << i.next();
//! [1]
@@ -72,9 +70,9 @@ while (i.hasNext())
{
//! [2]
QStringIterator i(u"𝄞 is the G clef");
-qDebug() << Qt::hex << i.next(); // will print 1d11e (U+1D11E, MUSICAL SYMBOL G CLEF)
-qDebug() << Qt::hex << i.next(); // will print 20 (U+0020, SPACE)
-qDebug() << Qt::hex << i.next(); // will print 69 (U+0069, LATIN SMALL LETTER I)
+qDebug() << Qt::hex << i.next(); // will print '𝄞' (U+1D11E, MUSICAL SYMBOL G CLEF)
+qDebug() << Qt::hex << i.next(); // will print ' ' (U+0020, SPACE)
+qDebug() << Qt::hex << i.next(); // will print 'i' (U+0069, LATIN SMALL LETTER I)
//! [2]
}
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index fa61b5939d..cffcf6575b 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -593,11 +593,11 @@ bool QtPrivate::isLatin1(QStringView s) noexcept
bool QtPrivate::isValidUtf16(QStringView s) noexcept
{
- Q_CONSTEXPR uint InvalidCodePoint = UINT_MAX;
+ Q_CONSTEXPR char32_t InvalidCodePoint = UINT_MAX;
QStringIterator i(s);
while (i.hasNext()) {
- uint c = i.next(InvalidCodePoint);
+ const auto c = i.next(InvalidCodePoint);
if (c == InvalidCodePoint)
return false;
}
@@ -5077,7 +5077,7 @@ bool QString::isUpper() const
QStringIterator it(*this);
while (it.hasNext()) {
- uint uc = it.nextUnchecked();
+ const auto uc = it.nextUnchecked();
if (qGetProp(uc)->cases[QUnicodeTables::UpperCase].diff)
return false;
}
@@ -5103,7 +5103,7 @@ bool QString::isLower() const
QStringIterator it(*this);
while (it.hasNext()) {
- uint uc = it.nextUnchecked();
+ const auto uc = it.nextUnchecked();
if (qGetProp(uc)->cases[QUnicodeTables::LowerCase].diff)
return false;
}
@@ -6546,7 +6546,7 @@ static QString detachAndConvertCase(T &str, QStringIterator it, QUnicodeTables::
QChar *pp = s.begin() + it.index(); // will detach if necessary
do {
- uint uc = it.nextUnchecked();
+ auto uc = it.nextUnchecked();
const auto fold = qGetProp(uc)->cases[which];
signed short caseDiff = fold.diff;
@@ -6594,7 +6594,7 @@ static QString convertCase(T &str, QUnicodeTables::Case which)
QStringIterator it(p, e);
while (it.hasNext()) {
- uint uc = it.nextUnchecked();
+ const auto uc = it.nextUnchecked();
if (qGetProp(uc)->cases[which].diff) {
it.recedeUnchecked();
return detachAndConvertCase(str, it, which);
diff --git a/src/corelib/text/qstringiterator.qdoc b/src/corelib/text/qstringiterator.qdoc
index 9d7c54ce9f..dd84711b12 100644
--- a/src/corelib/text/qstringiterator.qdoc
+++ b/src/corelib/text/qstringiterator.qdoc
@@ -170,7 +170,7 @@
*/
/*!
- \fn uint QStringIterator::peekNextUnchecked() const
+ \fn QStringIterator::peekNextUnchecked() const
Returns the Unicode code point that is immediately after the iterator's current
position. The current position is not changed.
@@ -182,7 +182,7 @@
*/
/*!
- \fn uint QStringIterator::peekNext(uint invalidAs = QChar::ReplacementCharacter) const
+ \fn QStringIterator::peekNext(char32_t invalidAs = QChar::ReplacementCharacter) const
Returns the Unicode code point that is immediately after the iterator's current
position. The current position is not changed.
@@ -198,7 +198,7 @@
*/
/*!
- \fn uint QStringIterator::nextUnchecked()
+ \fn QStringIterator::nextUnchecked()
Advances the iterator's current position by one Unicode code point,
and returns the Unicode code point that gets pointed by the iterator.
@@ -210,7 +210,7 @@
*/
/*!
- \fn uint QStringIterator::next(uint invalidAs = QChar::ReplacementCharacter)
+ \fn QStringIterator::next(char32_t invalidAs = QChar::ReplacementCharacter)
Advances the iterator's current position by one Unicode code point,
and returns the Unicode code point that gets pointed by the iterator.
@@ -258,7 +258,7 @@
*/
/*!
- \fn uint QStringIterator::peekPreviousUnchecked() const
+ \fn QStringIterator::peekPreviousUnchecked() const
Returns the Unicode code point that is immediately before the iterator's current
position. The current position is not changed.
@@ -270,7 +270,7 @@
*/
/*!
- \fn uint QStringIterator::peekPrevious(uint invalidAs = QChar::ReplacementCharacter) const
+ \fn QStringIterator::peekPrevious(char32_t invalidAs = QChar::ReplacementCharacter) const
Returns the Unicode code point that is immediately before the iterator's current
position. The current position is not changed.
@@ -286,7 +286,7 @@
*/
/*!
- \fn uint QStringIterator::previousUnchecked()
+ \fn QStringIterator::previousUnchecked()
Moves the iterator's current position back by one Unicode code point,
and returns the Unicode code point that gets pointed by the iterator.
@@ -298,7 +298,7 @@
*/
/*!
- \fn uint QStringIterator::previous(uint invalidAs = QChar::ReplacementCharacter)
+ \fn QStringIterator::previous(char32_t invalidAs = QChar::ReplacementCharacter)
Moves the iterator's current position back by one Unicode code point,
and returns the Unicode code point that gets pointed by the iterator.
diff --git a/src/corelib/text/qstringiterator_p.h b/src/corelib/text/qstringiterator_p.h
index 219589b6e4..2998d2a423 100644
--- a/src/corelib/text/qstringiterator_p.h
+++ b/src/corelib/text/qstringiterator_p.h
@@ -124,7 +124,7 @@ public:
++pos;
}
- inline uint peekNextUnchecked() const
+ inline char32_t peekNextUnchecked() const
{
Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
@@ -134,7 +134,7 @@ public:
return pos->unicode();
}
- inline uint peekNext(uint invalidAs = QChar::ReplacementCharacter) const
+ inline char32_t peekNext(char32_t invalidAs = QChar::ReplacementCharacter) const
{
Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
@@ -150,7 +150,7 @@ public:
return pos->unicode();
}
- inline uint nextUnchecked()
+ inline char32_t nextUnchecked()
{
Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
@@ -160,7 +160,7 @@ public:
return cur.unicode();
}
- inline uint next(uint invalidAs = QChar::ReplacementCharacter)
+ inline char32_t next(char32_t invalidAs = QChar::ReplacementCharacter)
{
Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
@@ -200,7 +200,7 @@ public:
--pos;
}
- inline uint peekPreviousUnchecked() const
+ inline char32_t peekPreviousUnchecked() const
{
Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
@@ -209,7 +209,7 @@ public:
return pos[-1].unicode();
}
- inline uint peekPrevious(uint invalidAs = QChar::ReplacementCharacter) const
+ inline char32_t peekPrevious(char32_t invalidAs = QChar::ReplacementCharacter) const
{
Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
@@ -225,7 +225,7 @@ public:
return pos[-1].unicode();
}
- inline uint previousUnchecked()
+ inline char32_t previousUnchecked()
{
Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
@@ -235,7 +235,7 @@ public:
return cur.unicode();
}
- inline uint previous(uint invalidAs = QChar::ReplacementCharacter)
+ inline char32_t previous(char32_t invalidAs = QChar::ReplacementCharacter)
{
Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");