summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qalgorithms.qdoc52
-rw-r--r--src/corelib/tools/qarraydata.cpp2
-rw-r--r--src/corelib/tools/qarraydata.h2
-rw-r--r--src/corelib/tools/qbitarray.cpp34
-rw-r--r--src/corelib/tools/qbytearray.cpp125
-rw-r--r--src/corelib/tools/qcache.qdoc6
-rw-r--r--src/corelib/tools/qchar.cpp272
-rw-r--r--src/corelib/tools/qchar.h22
-rw-r--r--src/corelib/tools/qdatetime.cpp56
-rw-r--r--src/corelib/tools/qeasingcurve.cpp186
-rw-r--r--src/corelib/tools/qelapsedtimer.cpp6
-rw-r--r--src/corelib/tools/qelapsedtimer_generic.cpp4
-rw-r--r--src/corelib/tools/qhash.cpp57
-rw-r--r--src/corelib/tools/qhash.h28
-rw-r--r--src/corelib/tools/qiterator.qdoc104
-rw-r--r--src/corelib/tools/qlinkedlist.cpp40
-rw-r--r--src/corelib/tools/qlist.cpp58
-rw-r--r--src/corelib/tools/qlocale.cpp475
-rw-r--r--src/corelib/tools/qlocale.h21
-rw-r--r--src/corelib/tools/qlocale.qdoc8
-rw-r--r--src/corelib/tools/qlocale_data_p.h2
-rw-r--r--src/corelib/tools/qlocale_p.h126
-rw-r--r--src/corelib/tools/qlocale_unix.cpp2
-rw-r--r--src/corelib/tools/qmap.cpp60
-rw-r--r--src/corelib/tools/qpair.qdoc12
-rw-r--r--src/corelib/tools/qpoint.cpp42
-rw-r--r--src/corelib/tools/qpoint.h52
-rw-r--r--src/corelib/tools/qqueue.cpp2
-rw-r--r--src/corelib/tools/qrect.cpp16
-rw-r--r--src/corelib/tools/qrect.h212
-rw-r--r--src/corelib/tools/qregexp.cpp68
-rw-r--r--src/corelib/tools/qregexp.h6
-rw-r--r--src/corelib/tools/qregularexpression.cpp64
-rw-r--r--src/corelib/tools/qscopedpointer.cpp12
-rw-r--r--src/corelib/tools/qset.qdoc30
-rw-r--r--src/corelib/tools/qshareddata.cpp18
-rw-r--r--src/corelib/tools/qsimd.cpp278
-rw-r--r--src/corelib/tools/qsimd_p.h5
-rw-r--r--src/corelib/tools/qsize.cpp24
-rw-r--r--src/corelib/tools/qsize.h74
-rw-r--r--src/corelib/tools/qstack.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp307
-rw-r--r--src/corelib/tools/qstring.h53
-rw-r--r--src/corelib/tools/qstringbuilder.cpp2
-rw-r--r--src/corelib/tools/qstringlist.cpp38
-rw-r--r--src/corelib/tools/qtimeline.cpp2
-rw-r--r--src/corelib/tools/qunicodetables.cpp60
-rw-r--r--src/corelib/tools/qunicodetables_p.h4
-rw-r--r--src/corelib/tools/qvarlengtharray.h3
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc8
-rw-r--r--src/corelib/tools/qvector.cpp36
51 files changed, 1616 insertions, 1562 deletions
diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc
index 5a4a278ad0..28fd9881d6 100644
--- a/src/corelib/tools/qalgorithms.qdoc
+++ b/src/corelib/tools/qalgorithms.qdoc
@@ -60,14 +60,14 @@
a particular value. If you need that functionality, you can use
qFill():
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 0
+ \snippet code/doc_src_qalgorithms.cpp 0
qFill() takes a begin iterator, an end iterator, and a value.
In the example above, we pass \c list.begin() and \c list.end()
as the begin and end iterators, but this doesn't have to be
the case:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 1
+ \snippet code/doc_src_qalgorithms.cpp 1
Different algorithms can have different requirements for the
iterators they accept. For example, qFill() accepts two
@@ -98,13 +98,13 @@
name_table array and return the corresponding Unicode value from
the \c value_table if the entity is recognized:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 2
+ \snippet code/doc_src_qalgorithms.cpp 2
This kind of code is for advanced users only; for most
applications, a QMap- or QHash-based approach would work just as
well:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 3
+ \snippet code/doc_src_qalgorithms.cpp 3
\section1 Types of Iterators
@@ -185,7 +185,7 @@
position \a begin2 + 1; and so on.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 4
+ \snippet code/doc_src_qalgorithms.cpp 4
\sa qCopyBackward(), {input iterators}, {output iterators}
*/
@@ -201,7 +201,7 @@
at position \a end2 - 2; and so on.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 5
+ \snippet code/doc_src_qalgorithms.cpp 5
\sa qCopy(), {bidirectional iterators}
*/
@@ -214,7 +214,7 @@
items compare equal; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 6
+ \snippet code/doc_src_qalgorithms.cpp 6
This function requires the item type (in the example above,
QString) to implement \c operator==().
@@ -228,7 +228,7 @@
Fills the range [\a begin, \a end) with \a value.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 7
+ \snippet code/doc_src_qalgorithms.cpp 7
\sa qCopy(), {forward iterators}
*/
@@ -249,7 +249,7 @@
value isn't found.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 8
+ \snippet code/doc_src_qalgorithms.cpp 8
This function requires the item type (in the example above,
QString) to implement \c operator==().
@@ -278,7 +278,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 9
+ \snippet code/doc_src_qalgorithms.cpp 9
This function requires the item type (in the example above,
\c int) to implement \c operator==().
@@ -302,7 +302,7 @@ of \a value in the variable passed as a reference in argument \a n.
Exchanges the values of variables \a var1 and \a var2.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 10
+ \snippet code/doc_src_qalgorithms.cpp 10
*/
/*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end)
@@ -312,7 +312,7 @@ of \a value in the variable passed as a reference in argument \a n.
using the quicksort algorithm.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 11
+ \snippet code/doc_src_qalgorithms.cpp 11
The sort algorithm is efficient on large data sets. It operates
in \l {linear-logarithmic time}, O(\e{n} log \e{n}).
@@ -338,13 +338,13 @@ of \a value in the variable passed as a reference in argument \a n.
For example, here's how to sort the strings in a QStringList
in case-insensitive alphabetical order:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 12
+ \snippet code/doc_src_qalgorithms.cpp 12
To sort values in reverse order, pass
\l{qGreater()}{qGreater<T>()} as the \a lessThan parameter. For
example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 13
+ \snippet code/doc_src_qalgorithms.cpp 13
If neither of the two items is "less than" the other, the items are
taken to be equal. It is then undefined which one of the two
@@ -356,7 +356,7 @@ of \a value in the variable passed as a reference in argument \a n.
following code shows how to sort a list of strings case
insensitively using QMap:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 14
+ \snippet code/doc_src_qalgorithms.cpp 14
\sa QMap
*/
@@ -382,7 +382,7 @@ of \a value in the variable passed as a reference in argument \a n.
property is often useful when sorting user-visible data.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 15
+ \snippet code/doc_src_qalgorithms.cpp 15
The sort algorithm is efficient on large data sets. It operates
in \l {linear-logarithmic time}, O(\e{n} log \e{n}).
@@ -405,7 +405,7 @@ of \a value in the variable passed as a reference in argument \a n.
For example, here's how to sort the strings in a QStringList
in case-insensitive alphabetical order:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 16
+ \snippet code/doc_src_qalgorithms.cpp 16
Note that earlier versions of Qt allowed using a lessThan function that took its
arguments by non-const reference. From 4.3 and on this is no longer possible,
@@ -415,7 +415,7 @@ of \a value in the variable passed as a reference in argument \a n.
\l{qGreater()}{qGreater<T>()} as the \a lessThan parameter. For
example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 17
+ \snippet code/doc_src_qalgorithms.cpp 17
If neither of the two items is "less than" the other, the items are
taken to be equal. The item that appeared before the other in the
@@ -444,7 +444,7 @@ of \a value in the variable passed as a reference in argument \a n.
ascending order; see qSort().
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 18
+ \snippet code/doc_src_qalgorithms.cpp 18
This function requires the item type (in the example above,
\c{int}) to implement \c operator<().
@@ -452,7 +452,7 @@ of \a value in the variable passed as a reference in argument \a n.
qLowerBound() can be used in conjunction with qUpperBound() to
iterate over all occurrences of the same value:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 19
+ \snippet code/doc_src_qalgorithms.cpp 19
\sa qUpperBound(), qBinaryFind()
*/
@@ -494,7 +494,7 @@ of \a value in the variable passed as a reference in argument \a n.
ascending order; see qSort().
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 20
+ \snippet code/doc_src_qalgorithms.cpp 20
This function requires the item type (in the example above,
\c{int}) to implement \c operator<().
@@ -502,7 +502,7 @@ of \a value in the variable passed as a reference in argument \a n.
qUpperBound() can be used in conjunction with qLowerBound() to
iterate over all occurrences of the same value:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 21
+ \snippet code/doc_src_qalgorithms.cpp 21
\sa qLowerBound(), qBinaryFind()
*/
@@ -545,7 +545,7 @@ of \a value in the variable passed as a reference in argument \a n.
finer control.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 22
+ \snippet code/doc_src_qalgorithms.cpp 22
This function requires the item type (in the example above,
QString) to implement \c operator<().
@@ -587,7 +587,7 @@ of \a value in the variable passed as a reference in argument \a n.
example, \c{QWidget *}).
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 23
+ \snippet code/doc_src_qalgorithms.cpp 23
Notice that qDeleteAll() doesn't remove the items from the
container; it merely calls \c delete on them. In the example
@@ -618,7 +618,7 @@ of \a value in the variable passed as a reference in argument \a n.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 24
+ \snippet code/doc_src_qalgorithms.cpp 24
\sa {qGreater()}{qGreater<T>()}
*/
@@ -631,7 +631,7 @@ of \a value in the variable passed as a reference in argument \a n.
Example:
- \snippet doc/src/snippets/code/doc_src_qalgorithms.cpp 25
+ \snippet code/doc_src_qalgorithms.cpp 25
\sa {qLess()}{qLess<T>()}
*/
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp
index f1b88d5051..328d39cde9 100644
--- a/src/corelib/tools/qarraydata.cpp
+++ b/src/corelib/tools/qarraydata.cpp
@@ -82,7 +82,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
// Allocate additional space if array is growing
if (options & Grow)
- capacity = qAllocMore(objectSize * capacity, headerSize) / objectSize;
+ capacity = qAllocMore(objectSize * capacity, headerSize) / int(objectSize);
size_t allocSize = headerSize + objectSize * capacity;
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 78fbc9cf32..4d79c92cec 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -169,7 +169,7 @@ struct QTypedArrayData
result->offset = reinterpret_cast<const char *>(data)
- reinterpret_cast<const char *>(result);
- result->size = n;
+ result->size = int(n);
}
return result;
}
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp
index 4cb08a7310..0e74e15a27 100644
--- a/src/corelib/tools/qbitarray.cpp
+++ b/src/corelib/tools/qbitarray.cpp
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
The following code constructs a QBitArray containing 200 bits
initialized to false (0):
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 0
+ \snippet code/src_corelib_tools_qbitarray.cpp 0
To initialize the bits to true, either pass \c true as second
argument to the constructor, or call fill() later on.
@@ -75,13 +75,13 @@ QT_BEGIN_NAMESPACE
bit that can be used on the left side of an assignment. For
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 1
+ \snippet code/src_corelib_tools_qbitarray.cpp 1
For technical reasons, it is more efficient to use testBit() and
setBit() to access bits in the array than operator[](). For
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 2
+ \snippet code/src_corelib_tools_qbitarray.cpp 2
QBitArray supports \c{&} (\link operator&() AND\endlink), \c{|}
(\link operator|() OR\endlink), \c{^} (\link operator^()
@@ -90,7 +90,7 @@ QT_BEGIN_NAMESPACE
as the built-in C++ bitwise operators of the same name. For
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 3
+ \snippet code/src_corelib_tools_qbitarray.cpp 3
For historical reasons, QBitArray distinguishes between a null
bit array and an empty bit array. A \e null bit array is a bit
@@ -99,7 +99,7 @@ QT_BEGIN_NAMESPACE
array is always empty, but an empty bit array isn't necessarily
null:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 4
+ \snippet code/src_corelib_tools_qbitarray.cpp 4
All functions except isNull() treat null bit arrays the same as
empty bit arrays; for example, QBitArray() compares equal to
@@ -228,7 +228,7 @@ void QBitArray::resize(int size)
Returns true if this bit array is null; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 5
+ \snippet code/src_corelib_tools_qbitarray.cpp 5
Qt makes a distinction between null bit arrays and empty bit
arrays for historical reasons. For most applications, what
@@ -245,7 +245,7 @@ void QBitArray::resize(int size)
the bit array is resized to \a size beforehand.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 6
+ \snippet code/src_corelib_tools_qbitarray.cpp 6
\sa resize()
*/
@@ -372,7 +372,7 @@ void QBitArray::fill(bool value, int begin, int end)
\a i < size()).
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 7
+ \snippet code/src_corelib_tools_qbitarray.cpp 7
The return value is of type QBitRef, a helper class for QBitArray.
When you get an object of type QBitRef, you can assign to
@@ -451,7 +451,7 @@ void QBitArray::fill(bool value, int begin, int end)
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 8
+ \snippet code/src_corelib_tools_qbitarray.cpp 8
\sa operator&(), operator|=(), operator^=(), operator~()
*/
@@ -480,7 +480,7 @@ QBitArray &QBitArray::operator&=(const QBitArray &other)
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 9
+ \snippet code/src_corelib_tools_qbitarray.cpp 9
\sa operator|(), operator&=(), operator^=(), operator~()
*/
@@ -506,7 +506,7 @@ QBitArray &QBitArray::operator|=(const QBitArray &other)
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 10
+ \snippet code/src_corelib_tools_qbitarray.cpp 10
\sa operator^(), operator&=(), operator|=(), operator~()
*/
@@ -527,7 +527,7 @@ QBitArray &QBitArray::operator^=(const QBitArray &other)
array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 11
+ \snippet code/src_corelib_tools_qbitarray.cpp 11
\sa operator&(), operator|(), operator^()
*/
@@ -559,7 +559,7 @@ QBitArray QBitArray::operator~() const
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 12
+ \snippet code/src_corelib_tools_qbitarray.cpp 12
\sa QBitArray::operator&=(), operator|(), operator^()
*/
@@ -582,7 +582,7 @@ QBitArray operator&(const QBitArray &a1, const QBitArray &a2)
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 13
+ \snippet code/src_corelib_tools_qbitarray.cpp 13
\sa QBitArray::operator|=(), operator&(), operator^()
*/
@@ -605,7 +605,7 @@ QBitArray operator|(const QBitArray &a1, const QBitArray &a2)
taken to be 0.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbitarray.cpp 14
+ \snippet code/src_corelib_tools_qbitarray.cpp 14
\sa QBitArray::operator^=(), operator&(), operator|()
*/
@@ -668,7 +668,7 @@ QBitArray operator^(const QBitArray &a1, const QBitArray &a2)
Writes bit array \a ba to stream \a out.
- \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+ \sa {Serializing Qt Data Types}{Format of the QDataStream operators}
*/
QDataStream &operator<<(QDataStream &out, const QBitArray &ba)
@@ -685,7 +685,7 @@ QDataStream &operator<<(QDataStream &out, const QBitArray &ba)
Reads a bit array into \a ba from stream \a in.
- \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+ \sa {Serializing Qt Data Types}{Format of the QDataStream operators}
*/
QDataStream &operator>>(QDataStream &in, QBitArray &ba)
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 31cf65b78d..b67d655a9d 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -131,7 +131,7 @@ char *qstrcpy(char *dst, const char *src)
if (!src)
return 0;
#if defined(_MSC_VER) && _MSC_VER >= 1400
- int len = strlen(src);
+ const int len = int(strlen(src));
// This is actually not secure!!! It will be fixed
// properly in a later release!
if (len >= 0 && strcpy_s(dst, len+1, src) == 0)
@@ -648,7 +648,7 @@ static inline char qToLower(char c)
char *} to its constructor. For example, the following code
creates a byte array of size 5 containing the data "Hello":
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 0
+ \snippet code/src_corelib_tools_qbytearray.cpp 0
Although the size() is 5, the byte array also maintains an extra
'\\0' character at the end so that if a function is used that
@@ -668,11 +668,11 @@ static inline char qToLower(char c)
arrays, operator[]() returns a reference to a byte that can be
used on the left side of an assignment. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 1
+ \snippet code/src_corelib_tools_qbytearray.cpp 1
For read-only access, an alternative syntax is to use at():
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 2
+ \snippet code/src_corelib_tools_qbytearray.cpp 2
at() can be faster than operator[](), because it never causes a
\l{deep copy} to occur.
@@ -700,7 +700,7 @@ static inline char qToLower(char c)
the byte data: append(), prepend(), insert(), replace(), and
remove(). For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 3
+ \snippet code/src_corelib_tools_qbytearray.cpp 3
The replace() and remove() functions' first two arguments are the
position from which to start erasing and the number of bytes that
@@ -728,7 +728,7 @@ static inline char qToLower(char c)
For example, here's a typical loop that finds all occurrences of a
particular substring:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 4
+ \snippet code/src_corelib_tools_qbytearray.cpp 4
If you simply want to check whether a QByteArray contains a
particular character or substring, use contains(). If you want to
@@ -752,7 +752,7 @@ static inline char qToLower(char c)
array is always empty, but an empty byte array isn't necessarily
null:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 5
+ \snippet code/src_corelib_tools_qbytearray.cpp 5
All functions except isNull() treat null byte arrays the same as
empty byte arrays. For example, data() returns a pointer to a
@@ -914,12 +914,13 @@ QByteArray &QByteArray::operator=(const char *str)
} else if (!*str) {
x = Data::allocate(0);
} else {
- int len = strlen(str);
- if (d->ref.isShared() || uint(len) + 1u > d->alloc
- || (len < d->size && uint(len) + 1u < uint(d->alloc >> 1)))
- reallocData(uint(len) + 1u, d->detachFlags());
+ const int len = int(strlen(str));
+ const uint fullLen = len + 1;
+ if (d->ref.isShared() || fullLen > d->alloc
+ || (len < d->size && fullLen < uint(d->alloc >> 1)))
+ reallocData(fullLen, d->detachFlags());
x = d;
- memcpy(x->data(), str, uint(len) + 1u); // include null terminator
+ memcpy(x->data(), str, fullLen); // include null terminator
x->size = len;
}
x->ref.ref();
@@ -949,7 +950,7 @@ QByteArray &QByteArray::operator=(const char *str)
automaticall unless the \l{deep copy} is created.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 6
+ \snippet code/src_corelib_tools_qbytearray.cpp 6
\sa isEmpty(), resize()
*/
@@ -959,7 +960,7 @@ QByteArray &QByteArray::operator=(const char *str)
Returns true if the byte array has size 0; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 7
+ \snippet code/src_corelib_tools_qbytearray.cpp 7
\sa size()
*/
@@ -1046,7 +1047,7 @@ QByteArray &QByteArray::operator=(const char *str)
'\\0' terminator.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 8
+ \snippet code/src_corelib_tools_qbytearray.cpp 8
The pointer remains valid as long as the byte array isn't
reallocated or destroyed. For read-only access, constData() is
@@ -1059,11 +1060,11 @@ QByteArray &QByteArray::operator=(const char *str)
data(), but it will corrupt the heap and cause a crash because it
does not allocate a byte for the '\\0' at the end:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 46
+ \snippet code/src_corelib_tools_qbytearray.cpp 46
This one allocates the correct amount of space:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 47
+ \snippet code/src_corelib_tools_qbytearray.cpp 47
Note: A QByteArray can store any byte values including '\\0's,
but most functions that take \c{char *} arguments assume that the
@@ -1129,7 +1130,7 @@ QByteArray &QByteArray::operator=(const char *str)
place.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 9
+ \snippet code/src_corelib_tools_qbytearray.cpp 9
The return value is of type QByteRef, a helper class for
QByteArray. When you get an object of type QByteRef, you can use
@@ -1188,7 +1189,7 @@ QByteArray &QByteArray::operator=(const char *str)
If \a pos is beyond the end of the array, nothing happens.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 10
+ \snippet code/src_corelib_tools_qbytearray.cpp 10
\sa chop(), resize(), left()
*/
@@ -1206,7 +1207,7 @@ void QByteArray::truncate(int pos)
array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 11
+ \snippet code/src_corelib_tools_qbytearray.cpp 11
\sa truncate(), resize(), left()
*/
@@ -1224,7 +1225,7 @@ void QByteArray::chop(int n)
returns a reference to this byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 12
+ \snippet code/src_corelib_tools_qbytearray.cpp 12
Note: QByteArray is an \l{implicitly shared} class. Consequently,
if \e this is an empty QByteArray, then \e this will just share
@@ -1284,7 +1285,7 @@ void QByteArray::chop(int n)
Returns true if this byte array is null; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 13
+ \snippet code/src_corelib_tools_qbytearray.cpp 13
Qt makes a distinction between null byte arrays and empty byte
arrays for historical reasons. For most applications, what
@@ -1322,7 +1323,7 @@ QByteArray::QByteArray(const char *data, int size)
d = Data::sharedNull();
} else {
if (size < 0)
- size = strlen(data);
+ size = int(strlen(data));
if (!size) {
d = Data::allocate(0);
} else {
@@ -1428,7 +1429,7 @@ void QByteArray::resize(int size)
size \a size beforehand.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 14
+ \snippet code/src_corelib_tools_qbytearray.cpp 14
\sa resize()
*/
@@ -1493,7 +1494,7 @@ QByteArray QByteArray::nulTerminated() const
reference to this byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 15
+ \snippet code/src_corelib_tools_qbytearray.cpp 15
This is the same as insert(0, \a ba).
@@ -1573,7 +1574,7 @@ QByteArray &QByteArray::prepend(char ch)
Appends the byte array \a ba onto the end of this byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 16
+ \snippet code/src_corelib_tools_qbytearray.cpp 16
This is the same as insert(size(), \a ba).
@@ -1631,7 +1632,7 @@ QByteArray &QByteArray::append(const QByteArray &ba)
QByteArray& QByteArray::append(const char *str)
{
if (str) {
- int len = strlen(str);
+ const int len = int(strlen(str));
if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc)
reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow);
memcpy(d->data() + d->size, str, len + 1); // include null terminator
@@ -1710,7 +1711,7 @@ static inline QByteArray &qbytearray_insert(QByteArray *ba,
reference to this byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 17
+ \snippet code/src_corelib_tools_qbytearray.cpp 17
\sa append(), prepend(), replace(), remove()
*/
@@ -1793,7 +1794,7 @@ QByteArray &QByteArray::insert(int i, char ch)
array is truncated at position \a pos.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 18
+ \snippet code/src_corelib_tools_qbytearray.cpp 18
\sa insert(), replace()
*/
@@ -1817,7 +1818,7 @@ QByteArray &QByteArray::remove(int pos, int len)
array \a after, and returns a reference to this byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 19
+ \snippet code/src_corelib_tools_qbytearray.cpp 19
\sa insert(), remove()
*/
@@ -1855,7 +1856,7 @@ QByteArray &QByteArray::replace(int pos, int len, const char *after)
\overload
Replaces \a len bytes from index position \a pos with \a alen bytes
- from the string \a after. \a after is allowed to have '\0' characters.
+ from the string \a after. \a after is allowed to have '\\0' characters.
\since 4.7
*/
@@ -1881,7 +1882,7 @@ QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen)
byte array \a after.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 20
+ \snippet code/src_corelib_tools_qbytearray.cpp 20
*/
QByteArray &QByteArray::replace(const QByteArray &before, const QByteArray &after)
@@ -2214,7 +2215,7 @@ QByteArray QByteArray::repeated(int times) const
position \a from. Returns -1 if \a ba could not be found.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 21
+ \snippet code/src_corelib_tools_qbytearray.cpp 21
\sa lastIndexOf(), contains(), count()
*/
@@ -2284,7 +2285,7 @@ int QByteArray::indexOf(const char *c, int from) const
position \a from. Returns -1 if \a ch could not be found.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 22
+ \snippet code/src_corelib_tools_qbytearray.cpp 22
\sa lastIndexOf(), contains()
*/
@@ -2346,7 +2347,7 @@ static int lastIndexOfHelper(const char *haystack, int l, const char *needle, in
starts at the last byte. Returns -1 if \a ba could not be found.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 23
+ \snippet code/src_corelib_tools_qbytearray.cpp 23
\sa indexOf(), contains(), count()
*/
@@ -2406,7 +2407,7 @@ int QByteArray::lastIndexOf(const char *str, int from) const
last (size() - 1) byte. Returns -1 if \a ch could not be found.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 24
+ \snippet code/src_corelib_tools_qbytearray.cpp 24
\sa indexOf(), contains()
*/
@@ -2493,7 +2494,7 @@ int QByteArray::count(char ch) const
otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 25
+ \snippet code/src_corelib_tools_qbytearray.cpp 25
\sa endsWith(), left()
*/
@@ -2515,7 +2516,7 @@ bool QByteArray::startsWith(const char *str) const
{
if (!str || !*str)
return true;
- int len = strlen(str);
+ const int len = int(strlen(str));
if (d->size < len)
return false;
return qstrncmp(d->data(), str, len) == 0;
@@ -2538,7 +2539,7 @@ bool QByteArray::startsWith(char ch) const
otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 26
+ \snippet code/src_corelib_tools_qbytearray.cpp 26
\sa startsWith(), right()
*/
@@ -2560,7 +2561,7 @@ bool QByteArray::endsWith(const char *str) const
{
if (!str || !*str)
return true;
- int len = strlen(str);
+ const int len = int(strlen(str));
if (d->size < len)
return false;
return qstrncmp(d->data() + d->size - len, str, len) == 0;
@@ -2586,7 +2587,7 @@ bool QByteArray::endsWith(char ch) const
size().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 27
+ \snippet code/src_corelib_tools_qbytearray.cpp 27
\sa right(), mid(), startsWith(), truncate()
*/
@@ -2608,7 +2609,7 @@ QByteArray QByteArray::left(int len) const
size().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 28
+ \snippet code/src_corelib_tools_qbytearray.cpp 28
\sa endsWith(), left(), mid()
*/
@@ -2631,7 +2632,7 @@ QByteArray QByteArray::right(int len) const
pos until the end of the byte array.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 29
+ \snippet code/src_corelib_tools_qbytearray.cpp 29
\sa left(), right()
*/
@@ -2658,7 +2659,7 @@ QByteArray QByteArray::mid(int pos, int len) const
interpreted as a Latin-1 encoded string.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 30
+ \snippet code/src_corelib_tools_qbytearray.cpp 30
\sa toUpper(), {8-bit Character Comparisons}
*/
@@ -2680,7 +2681,7 @@ QByteArray QByteArray::toLower() const
interpreted as a Latin-1 encoded string.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 31
+ \snippet code/src_corelib_tools_qbytearray.cpp 31
\sa toLower(), {8-bit Character Comparisons}
*/
@@ -3090,7 +3091,7 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba)
characters '\\t', '\\n', '\\v', '\\f', '\\r', and ' '.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 32
+ \snippet code/src_corelib_tools_qbytearray.cpp 32
\sa trimmed()
*/
@@ -3128,7 +3129,7 @@ QByteArray QByteArray::simplified() const
characters '\\t', '\\n', '\\v', '\\f', '\\r', and ' '.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 33
+ \snippet code/src_corelib_tools_qbytearray.cpp 33
Unlike simplified(), trimmed() leaves internal whitespace alone.
@@ -3170,7 +3171,7 @@ QByteArray QByteArray::trimmed() const
after position \a width are removed, and the copy is returned.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 34
+ \snippet code/src_corelib_tools_qbytearray.cpp 34
\sa rightJustified()
*/
@@ -3207,7 +3208,7 @@ QByteArray QByteArray::leftJustified(int width, char fill, bool truncate) const
position \a width.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 35
+ \snippet code/src_corelib_tools_qbytearray.cpp 35
\sa leftJustified()
*/
@@ -3314,7 +3315,7 @@ qulonglong QByteArray::toULongLong(bool *ok, int base) const
If \a ok is not 0: if a conversion error occurs, *\a{ok} is set to
false; otherwise *\a{ok} is set to true.
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 36
+ \snippet code/src_corelib_tools_qbytearray.cpp 36
\note The conversion of the number is performed in the default C locale,
irrespective of the user's locale.
@@ -3380,7 +3381,7 @@ uint QByteArray::toUInt(bool *ok, int base) const
If \a ok is not 0: if a conversion error occurs, *\a{ok} is set to
false; otherwise *\a{ok} is set to true.
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 37
+ \snippet code/src_corelib_tools_qbytearray.cpp 37
\note The conversion of the number is performed in the default C locale,
irrespective of the user's locale.
@@ -3501,7 +3502,7 @@ ushort QByteArray::toUShort(bool *ok, int base) const
If \a ok is not 0: if a conversion error occurs, *\a{ok} is set to
false; otherwise *\a{ok} is set to true.
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 38
+ \snippet code/src_corelib_tools_qbytearray.cpp 38
\note The conversion of the number is performed in the default C locale,
irrespective of the user's locale.
@@ -3536,7 +3537,7 @@ float QByteArray::toFloat(bool *ok) const
/*!
Returns a copy of the byte array, encoded as Base64.
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 39
+ \snippet code/src_corelib_tools_qbytearray.cpp 39
The algorithm used to encode Base64-encoded data is defined in \l{RFC 2045}.
@@ -3588,7 +3589,7 @@ QByteArray QByteArray::toBase64() const
be any value between 2 and 36.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 40
+ \snippet code/src_corelib_tools_qbytearray.cpp 40
\note The format of the number is not localized; the default C locale
is used irrespective of the user's locale.
@@ -3632,7 +3633,7 @@ QByteArray &QByteArray::setNum(qlonglong n, int base)
}
#endif
QLocale locale(QLocale::C);
- *this = locale.d()->longLongToString(n, -1, base).toLatin1();
+ *this = locale.d->longLongToString(n, -1, base).toLatin1();
return *this;
}
@@ -3651,7 +3652,7 @@ QByteArray &QByteArray::setNum(qulonglong n, int base)
}
#endif
QLocale locale(QLocale::C);
- *this = locale.d()->unsLongLongToString(n, -1, base).toLatin1();
+ *this = locale.d->unsLongLongToString(n, -1, base).toLatin1();
return *this;
}
@@ -3710,7 +3711,7 @@ QByteArray &QByteArray::setNum(double n, char f, int prec)
}
QLocale locale(QLocale::C);
- *this = locale.d()->doubleToString(n, prec, form, -1, flags).toLatin1();
+ *this = locale.d->doubleToString(n, prec, form, -1, flags).toLatin1();
return *this;
}
@@ -3734,7 +3735,7 @@ QByteArray &QByteArray::setNum(double n, char f, int prec)
any value between 2 and 36.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 41
+ \snippet code/src_corelib_tools_qbytearray.cpp 41
\note The format of the number is not localized; the default C locale
is used irrespective of the user's locale.
@@ -3806,7 +3807,7 @@ QByteArray QByteArray::number(qulonglong n, int base)
decimal point. With 'g' and 'G', \a prec is the maximum number of
significant digits (trailing zeroes are omitted).
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 42
+ \snippet code/src_corelib_tools_qbytearray.cpp 42
\note The format of the number is not localized; the default C locale
is used irrespective of the user's locale.
@@ -3843,7 +3844,7 @@ QByteArray QByteArray::number(double n, char f, int prec)
Here is an example of how to read data using a QDataStream on raw
data in memory without copying the raw data into a QByteArray:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 43
+ \snippet code/src_corelib_tools_qbytearray.cpp 43
\warning A byte array created with fromRawData() is \e not
null-terminated, unless the raw data contains a 0 character at
@@ -3908,7 +3909,7 @@ QByteArray &QByteArray::setRawData(const char *data, uint size)
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 44
+ \snippet code/src_corelib_tools_qbytearray.cpp 44
The algorithm used to decode Base64-encoded data is defined in \l{RFC 2045}.
@@ -3960,7 +3961,7 @@ QByteArray QByteArray::fromBase64(const QByteArray &base64)
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 45
+ \snippet code/src_corelib_tools_qbytearray.cpp 45
\sa toHex()
*/
diff --git a/src/corelib/tools/qcache.qdoc b/src/corelib/tools/qcache.qdoc
index 80d47ff703..86eec28e4b 100644
--- a/src/corelib/tools/qcache.qdoc
+++ b/src/corelib/tools/qcache.qdoc
@@ -39,11 +39,11 @@
definition of a cache that stores objects of type Employee
associated with an integer key:
- \snippet doc/src/snippets/code/doc_src_qcache.cpp 0
+ \snippet code/doc_src_qcache.cpp 0
Here's how to insert an object in the cache:
- \snippet doc/src/snippets/code/doc_src_qcache.cpp 1
+ \snippet code/doc_src_qcache.cpp 1
The advantage of using QCache over some other key-based data
structure (such as QMap or QHash) is that QCache automatically
@@ -59,7 +59,7 @@
By default, QCache's maxCost() is 100. You can specify a
different value in the QCache constructor:
- \snippet doc/src/snippets/code/doc_src_qcache.cpp 2
+ \snippet code/doc_src_qcache.cpp 2
Each time you call insert(), you can specify a cost as third
argument (after the key and a pointer to the object to insert).
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index ef229fc0fc..b83170cb46 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -108,8 +108,8 @@ QT_BEGIN_NAMESPACE
The classification functions include functions like those in the
standard C++ header \<cctype\> (formerly \<ctype.h\>), but
- operating on the full range of Unicode characters. They all
- return true if the character is a certain type of character;
+ operating on the full range of Unicode characters, not just for the ASCII
+ range. They all return true if the character is a certain type of character;
otherwise they return false. These classification functions are
isNull() (returns true if the character is '\\0'), isPrint()
(true if the character is any sort of printable character,
@@ -118,7 +118,9 @@ QT_BEGIN_NAMESPACE
sort of numeric character, not just 0-9), isLetterOrNumber(), and
isDigit() (decimal digits). All of these are wrappers around
category() which return the Unicode-defined category of each
- character.
+ character. Some of these also calculate the derived properties
+ (i.e. isSpace() returns true if the character is of category
+ Separator_* or an exceptional code point from Other_Control category).
QChar also provides direction(), which indicates the "natural"
writing direction of this character. The joining() function
@@ -153,6 +155,9 @@ QT_BEGIN_NAMESPACE
to construct a QChar from an 8-bit \c char, and you will need to
call toAscii() or toLatin1() to get the 8-bit value back.
+ For more information see
+ \l{http://www.unicode.org/ucd/}{"About the Unicode Character Database"}.
+
\sa Unicode, QString, QLatin1Char
*/
@@ -473,7 +478,7 @@ QT_BEGIN_NAMESPACE
/*!
Returns true if the character is a printable character; otherwise
- returns false. This is any character not of category Cc or Cn.
+ returns false. This is any character not of category Other_*.
Note that this gives no indication of whether the character is
available in a particular font.
@@ -481,6 +486,9 @@ QT_BEGIN_NAMESPACE
bool QChar::isPrint() const
{
const int test = FLAG(Other_Control) |
+ FLAG(Other_Format) |
+ FLAG(Other_Surrogate) |
+ FLAG(Other_PrivateUse) |
FLAG(Other_NotAssigned);
return !(FLAG(qGetProp(ucs)->category) & test);
}
@@ -699,12 +707,10 @@ bool QChar::isSymbol() const
*/
/*!
+ \fn int QChar::digitValue() const
+
Returns the numeric value of the digit, or -1 if the character is not a digit.
*/
-int QChar::digitValue() const
-{
- return qGetProp(ucs)->digitValue;
-}
/*!
\overload
@@ -729,12 +735,10 @@ int QChar::digitValue(uint ucs4)
}
/*!
+ \fn QChar::Category QChar::category() const
+
Returns the character's category.
*/
-QChar::Category QChar::category() const
-{
- return (QChar::Category) qGetProp(ucs)->category;
-}
/*!
\overload
@@ -758,12 +762,10 @@ QChar::Category QChar::category(ushort ucs2)
/*!
+ \fn QChar::Direction QChar::direction() const
+
Returns the character's direction.
*/
-QChar::Direction QChar::direction() const
-{
- return (QChar::Direction) qGetProp(ucs)->direction;
-}
/*!
\overload
@@ -786,13 +788,11 @@ QChar::Direction QChar::direction(ushort ucs2)
}
/*!
+ \fn QChar::Joining QChar::joining() const
+
Returns information about the joining properties of the character
(needed for certain languages such as Arabic).
*/
-QChar::Joining QChar::joining() const
-{
- return (QChar::Joining) qGetProp(ucs)->joining;
-}
/*!
\overload
@@ -857,15 +857,13 @@ bool QChar::hasMirrored() const
*/
/*!
+ \fn QChar QChar::mirroredChar() const
+
Returns the mirrored character if this character is a mirrored
character; otherwise returns the character itself.
\sa hasMirrored()
*/
-QChar QChar::mirroredChar() const
-{
- return ucs + qGetProp(ucs)->mirrorDiff;
-}
/*!
\overload
@@ -894,27 +892,26 @@ ushort QChar::mirroredChar(ushort ucs2)
}
+// constants for Hangul (de)composition, see UAX #15
enum {
Hangul_SBase = 0xac00,
Hangul_LBase = 0x1100,
Hangul_VBase = 0x1161,
Hangul_TBase = 0x11a7,
- Hangul_SCount = 11172,
Hangul_LCount = 19,
Hangul_VCount = 21,
Hangul_TCount = 28,
- Hangul_NCount = 21*28
+ Hangul_NCount = Hangul_VCount * Hangul_TCount,
+ Hangul_SCount = Hangul_LCount * Hangul_NCount
};
// buffer has to have a length of 3. It's needed for Hangul decomposition
static const unsigned short * QT_FASTCALL decompositionHelper
(uint ucs4, int *length, int *tag, unsigned short *buffer)
{
- *length = 0;
- if (ucs4 > UNICODE_LAST_CODEPOINT)
- return 0;
if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount) {
- int SIndex = ucs4 - Hangul_SBase;
+ // compute Hangul syllable decomposition as per UAX #15
+ const uint SIndex = ucs4 - Hangul_SBase;
buffer[0] = Hangul_LBase + SIndex / Hangul_NCount; // L
buffer[1] = Hangul_VBase + (SIndex % Hangul_NCount) / Hangul_TCount; // V
buffer[2] = Hangul_TBase + SIndex % Hangul_TCount; // T
@@ -924,8 +921,12 @@ static const unsigned short * QT_FASTCALL decompositionHelper
}
const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4);
- if (index == 0xffff)
+ if (index == 0xffff) {
+ *length = 0;
+ *tag = QChar::NoDecomposition;
return 0;
+ }
+
const unsigned short *decomposition = uc_decomposition_map+index;
*tag = (*decomposition) & 0xff;
*length = (*decomposition) >> 8;
@@ -952,7 +953,7 @@ QString QChar::decomposition(uint ucs4)
int length;
int tag;
const unsigned short *d = decompositionHelper(ucs4, &length, &tag, buffer);
- return QString::fromUtf16(d, length);
+ return QString(reinterpret_cast<const QChar *>(d), length);
}
/*!
@@ -971,8 +972,8 @@ QChar::Decomposition QChar::decompositionTag() const
*/
QChar::Decomposition QChar::decompositionTag(uint ucs4)
{
- if (ucs4 > UNICODE_LAST_CODEPOINT)
- return QChar::NoDecomposition;
+ if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount)
+ return QChar::Canonical;
const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4);
if (index == 0xffff)
return QChar::NoDecomposition;
@@ -980,6 +981,8 @@ QChar::Decomposition QChar::decompositionTag(uint ucs4)
}
/*!
+ \fn unsigned char QChar::combiningClass() const
+
Returns the combining class for the character as defined in the
Unicode standard. This is mainly useful as a positioning hint for
marks attached to a base character.
@@ -987,10 +990,6 @@ QChar::Decomposition QChar::decompositionTag(uint ucs4)
The Qt text rendering engine uses this information to correctly
position non-spacing marks around a base character.
*/
-unsigned char QChar::combiningClass() const
-{
- return (unsigned char) qGetProp(ucs)->combiningClass;
-}
/*!
\overload
@@ -1015,12 +1014,10 @@ unsigned char QChar::combiningClass(ushort ucs2)
}
/*!
+ \fn QChar::UnicodeVersion QChar::unicodeVersion() const
+
Returns the Unicode version that introduced this character.
*/
-QChar::UnicodeVersion QChar::unicodeVersion() const
-{
- return (QChar::UnicodeVersion) qGetProp(ucs)->unicodeVersion;
-}
/*!
\overload
@@ -1052,17 +1049,61 @@ QChar::UnicodeVersion QChar::currentUnicodeVersion()
return UNICODE_DATA_VERSION;
}
+
+template <typename T>
+static inline T toLowerCase_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (p->lowerCaseSpecial) {
+ const ushort *specialCase = specialCaseMap + p->lowerCaseDiff;
+ if (*specialCase == 1)
+ return specialCase[1];
+ }
+ return uc + p->lowerCaseDiff;
+}
+
+template <typename T>
+static inline T toUpperCase_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (p->upperCaseSpecial) {
+ const ushort *specialCase = specialCaseMap + p->upperCaseDiff;
+ if (*specialCase == 1)
+ return specialCase[1];
+ }
+ return uc + p->upperCaseDiff;
+}
+
+template <typename T>
+static inline T toTitleCase_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (p->titleCaseSpecial) {
+ const ushort *specialCase = specialCaseMap + p->titleCaseDiff;
+ if (*specialCase == 1)
+ return specialCase[1];
+ }
+ return uc + p->titleCaseDiff;
+}
+
+template <typename T>
+static inline T toCaseFolded_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (p->caseFoldSpecial) {
+ const ushort *specialCase = specialCaseMap + p->caseFoldDiff;
+ if (*specialCase == 1)
+ return specialCase[1];
+ }
+ return uc + p->caseFoldDiff;
+}
+
/*!
+ \fn QChar QChar::toLower() const
+
Returns the lowercase equivalent if the character is uppercase or titlecase;
otherwise returns the character itself.
*/
-QChar QChar::toLower() const
-{
- const QUnicodeTables::Properties *p = qGetProp(ucs);
- if (!p->lowerCaseSpecial)
- return ucs + p->lowerCaseDiff;
- return ucs;
-}
/*!
\overload
@@ -1074,10 +1115,7 @@ uint QChar::toLower(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- const QUnicodeTables::Properties *p = qGetProp(ucs4);
- if (!p->lowerCaseSpecial)
- return ucs4 + p->lowerCaseDiff;
- return ucs4;
+ return toLowerCase_helper<uint>(ucs4);
}
/*!
@@ -1088,23 +1126,15 @@ uint QChar::toLower(uint ucs4)
*/
ushort QChar::toLower(ushort ucs2)
{
- const QUnicodeTables::Properties *p = qGetProp(ucs2);
- if (!p->lowerCaseSpecial)
- return ucs2 + p->lowerCaseDiff;
- return ucs2;
+ return toLowerCase_helper<ushort>(ucs2);
}
/*!
+ \fn QChar QChar::toUpper() const
+
Returns the uppercase equivalent if the character is lowercase or titlecase;
otherwise returns the character itself.
*/
-QChar QChar::toUpper() const
-{
- const QUnicodeTables::Properties *p = qGetProp(ucs);
- if (!p->upperCaseSpecial)
- return ucs + p->upperCaseDiff;
- return ucs;
-}
/*!
\overload
@@ -1116,10 +1146,7 @@ uint QChar::toUpper(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- const QUnicodeTables::Properties *p = qGetProp(ucs4);
- if (!p->upperCaseSpecial)
- return ucs4 + p->upperCaseDiff;
- return ucs4;
+ return toUpperCase_helper<uint>(ucs4);
}
/*!
@@ -1130,23 +1157,15 @@ uint QChar::toUpper(uint ucs4)
*/
ushort QChar::toUpper(ushort ucs2)
{
- const QUnicodeTables::Properties *p = qGetProp(ucs2);
- if (!p->upperCaseSpecial)
- return ucs2 + p->upperCaseDiff;
- return ucs2;
+ return toUpperCase_helper<ushort>(ucs2);
}
/*!
+ \fn QChar QChar::toTitleCase() const
+
Returns the title case equivalent if the character is lowercase or uppercase;
otherwise returns the character itself.
*/
-QChar QChar::toTitleCase() const
-{
- const QUnicodeTables::Properties *p = qGetProp(ucs);
- if (!p->titleCaseSpecial)
- return ucs + p->titleCaseDiff;
- return ucs;
-}
/*!
\overload
@@ -1158,10 +1177,7 @@ uint QChar::toTitleCase(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- const QUnicodeTables::Properties *p = qGetProp(ucs4);
- if (!p->titleCaseSpecial)
- return ucs4 + p->titleCaseDiff;
- return ucs4;
+ return toTitleCase_helper<uint>(ucs4);
}
/*!
@@ -1172,19 +1188,15 @@ uint QChar::toTitleCase(uint ucs4)
*/
ushort QChar::toTitleCase(ushort ucs2)
{
- const QUnicodeTables::Properties *p = qGetProp(ucs2);
- if (!p->titleCaseSpecial)
- return ucs2 + p->titleCaseDiff;
- return ucs2;
+ return toTitleCase_helper<ushort>(ucs2);
}
-
static inline uint foldCase(const ushort *ch, const ushort *start)
{
uint c = *ch;
if (QChar(c).isLowSurrogate() && ch > start && QChar(*(ch - 1)).isHighSurrogate())
c = QChar::surrogateToUcs4(*(ch - 1), c);
- return *ch + qGetProp(c)->caseFoldDiff;
+ return toCaseFolded_helper<uint>(c);
}
static inline uint foldCase(uint ch, uint &last)
@@ -1193,22 +1205,20 @@ static inline uint foldCase(uint ch, uint &last)
if (QChar(c).isLowSurrogate() && QChar(last).isHighSurrogate())
c = QChar::surrogateToUcs4(last, c);
last = ch;
- return ch + qGetProp(c)->caseFoldDiff;
+ return toCaseFolded_helper<uint>(c);
}
static inline ushort foldCase(ushort ch)
{
- return ch + qGetProp(ch)->caseFoldDiff;
+ return toCaseFolded_helper<ushort>(ch);
}
/*!
- Returns the case folded equivalent of the character. For most Unicode characters this
- is the same as toLowerCase().
+ \fn QChar QChar::toCaseFolded() const
+
+ Returns the case folded equivalent of the character.
+ For most Unicode characters this is the same as toLowerCase().
*/
-QChar QChar::toCaseFolded() const
-{
- return ucs + qGetProp(ucs)->caseFoldDiff;
-}
/*!
\overload
@@ -1219,7 +1229,7 @@ uint QChar::toCaseFolded(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- return ucs4 + qGetProp(ucs4)->caseFoldDiff;
+ return toCaseFolded_helper<uint>(ucs4);
}
/*!
@@ -1229,7 +1239,7 @@ uint QChar::toCaseFolded(uint ucs4)
*/
ushort QChar::toCaseFolded(ushort ucs2)
{
- return ucs2 + qGetProp(ucs2)->caseFoldDiff;
+ return toCaseFolded_helper<ushort>(ucs2);
}
/*!
@@ -1391,6 +1401,8 @@ QDataStream &operator>>(QDataStream &in, QChar &chr)
static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, int from)
{
+ int length;
+ int tag;
unsigned short buffer[3];
QString &s = *str;
@@ -1406,18 +1418,18 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion
ucs4 = QChar::surrogateToUcs4(high, ucs4);
}
}
+
const QChar::UnicodeVersion v = QChar::unicodeVersion(ucs4);
if (v > version || v == QChar::Unicode_Unassigned)
continue;
- int length;
- int tag;
+
const unsigned short *d = decompositionHelper(ucs4, &length, &tag, buffer);
if (!d || (canonical && tag != QChar::Canonical))
continue;
int pos = uc - utf16;
s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, reinterpret_cast<const QChar *>(d), length);
- // since the insert invalidates the pointers and we do decomposition recursive
+ // since the replace invalidates the pointers and we do decomposition recursive
utf16 = reinterpret_cast<unsigned short *>(s.data());
uc = utf16 + pos + length;
}
@@ -1436,20 +1448,22 @@ inline bool operator<(const UCS2Pair &ligature, ushort u1)
static ushort ligatureHelper(ushort u1, ushort u2)
{
- // hangul L-V pair
- int LIndex = u1 - Hangul_LBase;
- if (0 <= LIndex && LIndex < Hangul_LCount) {
- int VIndex = u2 - Hangul_VBase;
- if (0 <= VIndex && VIndex < Hangul_VCount)
- return Hangul_SBase + (LIndex * Hangul_VCount + VIndex) * Hangul_TCount;
- }
-
- // hangul LV-T pair
- int SIndex = u1 - Hangul_SBase;
- if (0 <= SIndex && SIndex < Hangul_SCount && (SIndex % Hangul_TCount) == 0) {
- int TIndex = u2 - Hangul_TBase;
- if (0 <= TIndex && TIndex <= Hangul_TCount)
- return u1 + TIndex;
+ if (u1 >= Hangul_LBase && u1 <= Hangul_SBase + Hangul_SCount) {
+ // compute Hangul syllable composition as per UAX #15
+ // hangul L-V pair
+ const uint LIndex = u1 - Hangul_LBase;
+ if (LIndex < Hangul_LCount) {
+ const uint VIndex = u2 - Hangul_VBase;
+ if (VIndex < Hangul_VCount)
+ return Hangul_SBase + (LIndex * Hangul_VCount + VIndex) * Hangul_TCount;
+ }
+ // hangul LV-T pair
+ const uint SIndex = u1 - Hangul_SBase;
+ if (SIndex < Hangul_SCount && (SIndex % Hangul_TCount) == 0) {
+ const uint TIndex = u2 - Hangul_TBase;
+ if (TIndex <= Hangul_TCount)
+ return u1 + TIndex;
+ }
}
const unsigned short index = GET_LIGATURE_INDEX(u2);
@@ -1516,10 +1530,14 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
{
QString &s = *str;
const int l = s.length()-1;
+
+ uint u1, u2;
+ ushort c1, c2;
+
int pos = from;
while (pos < l) {
int p2 = pos+1;
- uint u1 = s.at(pos).unicode();
+ u1 = s.at(pos).unicode();
if (QChar(u1).isHighSurrogate()) {
ushort low = s.at(p2).unicode();
if (QChar(low).isLowSurrogate()) {
@@ -1529,7 +1547,10 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
++p2;
}
}
- uint u2 = s.at(p2).unicode();
+ c1 = 0;
+
+ advance:
+ u2 = s.at(p2).unicode();
if (QChar(u2).isHighSurrogate() && p2 < l) {
ushort low = s.at(p2+1).unicode();
if (QChar(low).isLowSurrogate()) {
@@ -1538,7 +1559,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
}
}
- ushort c2 = 0;
+ c2 = 0;
{
const QUnicodeTables::Properties *p = qGetProp(u2);
if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
@@ -1549,8 +1570,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
continue;
}
- ushort c1 = 0;
- {
+ if (c1 == 0) {
const QUnicodeTables::Properties *p = qGetProp(u1);
if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
c1 = p->combiningClass;
@@ -1580,6 +1600,16 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
++pos;
if (QChar::requiresSurrogates(u1))
++pos;
+
+ u1 = u2;
+ c1 = c2; // != 0
+ p2 = pos + 1;
+ if (QChar::requiresSurrogates(u1))
+ ++p2;
+ if (p2 > l)
+ break;
+
+ goto advance;
}
}
}
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index 9f2ca7ae9e..5d9402ae0c 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -203,23 +203,23 @@ public:
};
// ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO
- Category category() const;
- Direction direction() const;
- Joining joining() const;
+ inline Category category() const { return QChar::category(ucs); }
+ inline Direction direction() const { return QChar::direction(ucs); }
+ inline Joining joining() const { return QChar::joining(ucs); }
bool hasMirrored() const;
- unsigned char combiningClass() const;
+ inline unsigned char combiningClass() const { return QChar::combiningClass(ucs); }
- QChar mirroredChar() const;
+ inline QChar mirroredChar() const { return QChar::mirroredChar(ucs); }
QString decomposition() const;
Decomposition decompositionTag() const;
- int digitValue() const;
- QChar toLower() const;
- QChar toUpper() const;
- QChar toTitleCase() const;
- QChar toCaseFolded() const;
+ inline int digitValue() const { return QChar::digitValue(ucs); }
+ inline QChar toLower() const { return QChar::toLower(ucs); }
+ inline QChar toUpper() const { return QChar::toUpper(ucs); }
+ inline QChar toTitleCase() const { return QChar::toTitleCase(ucs); }
+ inline QChar toCaseFolded() const { return QChar::toCaseFolded(ucs); }
- UnicodeVersion unicodeVersion() const;
+ inline UnicodeVersion unicodeVersion() const { return QChar::unicodeVersion(ucs); }
inline char toAscii() const;
inline char toLatin1() const;
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index fa5eed4f86..630deccadd 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -824,7 +824,7 @@ QString QDate::toString(Qt::DateFormat f) const
range 0 to 9999. This restriction may apply to locale-aware
formats as well, depending on the locale settings.
- \sa QDateTime::toString() QTime::toString()
+ \sa QDateTime::toString(), QTime::toString()
*/
QString QDate::toString(const QString& format) const
@@ -836,7 +836,7 @@ QString QDate::toString(const QString& format) const
#endif //QT_NO_DATESTRING
/*!
- \fn bool setYMD(int y, int m, int d)
+ \fn bool QDate::setYMD(int y, int m, int d)
\deprecated in 5.0, use setDate() instead.
@@ -906,7 +906,7 @@ void QDate::getDate(int *year, int *month, int *day)
Returns a null date if the current date is invalid or the new date is
out-of-range.
- \sa addMonths() addYears() daysTo()
+ \sa addMonths(), addYears(), daysTo()
*/
QDate QDate::addDays(qint64 ndays) const
@@ -938,7 +938,7 @@ QDate QDate::addDays(qint64 ndays) const
resulting month/year, this function will return a date that is the
latest valid date.
- \sa addDays() addYears()
+ \sa addDays(), addYears()
*/
QDate QDate::addMonths(int nmonths) const
@@ -1029,7 +1029,7 @@ QDate QDate::addYears(int nyears) const
Returns 0 if either date is invalid.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 0
+ \snippet code/src_corelib_tools_qdatetime.cpp 0
\sa addDays()
*/
@@ -1217,7 +1217,7 @@ QDate QDate::fromString(const QString& s, Qt::DateFormat f)
of characters that are enclosed in single quotes will also be
treated as text and will not be used as an expression. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 1
+ \snippet code/src_corelib_tools_qdatetime.cpp 1
If the format is not satisfied, an invalid QDate is returned. The
expressions that don't expect leading zeroes (d, M) will be
@@ -1227,7 +1227,7 @@ QDate QDate::fromString(const QString& s, Qt::DateFormat f)
string could have meant January 30 but the M will grab two
digits, resulting in an invalid date:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 2
+ \snippet code/src_corelib_tools_qdatetime.cpp 2
For any field that is not represented in the format the following
defaults are used:
@@ -1241,7 +1241,7 @@ QDate QDate::fromString(const QString& s, Qt::DateFormat f)
The following examples demonstrate the default values:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 3
+ \snippet code/src_corelib_tools_qdatetime.cpp 3
\sa QDateTime::fromString(), QTime::fromString(), QDate::toString(),
QDateTime::toString(), QTime::toString()
@@ -1269,7 +1269,7 @@ QDate QDate::fromString(const QString &string, const QString &format)
day) is valid; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 4
+ \snippet code/src_corelib_tools_qdatetime.cpp 4
\sa isNull(), setDate()
*/
@@ -1300,7 +1300,7 @@ bool QDate::isLeapYear(int y)
return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
}
-/*! \fn static QDate QDate::fromJulianDay(int jd)
+/*! \fn static QDate QDate::fromJulianDay(qint64 jd)
Converts the Julian day \a jd to a QDate.
@@ -1582,7 +1582,7 @@ QString QTime::toString(Qt::DateFormat format) const
If the datetime is invalid, an empty string will be returned.
If \a format is empty, the default format "hh:mm:ss" is used.
- \sa QDate::toString() QDateTime::toString()
+ \sa QDate::toString(), QDateTime::toString()
*/
QString QTime::toString(const QString& format) const
{
@@ -1623,7 +1623,7 @@ bool QTime::setHMS(int h, int m, int s, int ms)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 5
+ \snippet code/src_corelib_tools_qdatetime.cpp 5
\sa addMSecs(), secsTo(), QDateTime::addSecs()
*/
@@ -1845,7 +1845,7 @@ QTime QTime::fromString(const QString& s, Qt::DateFormat f)
of characters that are enclosed in single quotes will also be
treated as text and not be used as an expression.
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 6
+ \snippet code/src_corelib_tools_qdatetime.cpp 6
If the format is not satisfied an invalid QTime is returned.
Expressions that do not expect leading zeroes to be given (h, m, s
@@ -1855,15 +1855,15 @@ QTime QTime::fromString(const QString& s, Qt::DateFormat f)
could have meant 00:07:10, but the m will grab two digits, resulting
in an invalid time:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 7
+ \snippet code/src_corelib_tools_qdatetime.cpp 7
Any field that is not represented in the format will be set to zero.
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 8
+ \snippet code/src_corelib_tools_qdatetime.cpp 8
- \sa QDateTime::fromString() QDate::fromString() QDate::toString()
- QDateTime::toString() QTime::toString()
+ \sa QDateTime::fromString(), QDate::fromString(), QDate::toString(),
+ QDateTime::toString(), QTime::toString()
*/
QTime QTime::fromString(const QString &string, const QString &format)
@@ -1894,7 +1894,7 @@ QTime QTime::fromString(const QString &string, const QString &format)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 9
+ \snippet code/src_corelib_tools_qdatetime.cpp 9
*/
bool QTime::isValid(int h, int m, int s, int ms)
@@ -1906,7 +1906,7 @@ bool QTime::isValid(int h, int m, int s, int ms)
/*!
Sets this time to the current time. This is practical for timing:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 10
+ \snippet code/src_corelib_tools_qdatetime.cpp 10
\sa restart(), elapsed(), currentTime()
*/
@@ -2077,7 +2077,7 @@ int QTime::elapsed() const
time zone before 1970, even if the system's time zone database
supports that information.
- \sa QDate QTime QDateTimeEdit
+ \sa QDate, QTime, QDateTimeEdit
*/
/*!
@@ -2432,7 +2432,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
range 0 to 9999. This restriction may apply to locale-aware
formats as well, depending on the locale settings.
- \sa QDate::toString() QTime::toString() Qt::DateFormat
+ \sa QDate::toString(), QTime::toString(), Qt::DateFormat
*/
QString QDateTime::toString(Qt::DateFormat f) const
@@ -2574,7 +2574,7 @@ QString QDateTime::toString(Qt::DateFormat f) const
If the datetime is invalid, an empty string will be returned.
- \sa QDate::toString() QTime::toString()
+ \sa QDate::toString(), QTime::toString()
*/
QString QDateTime::toString(const QString& format) const
{
@@ -2718,7 +2718,7 @@ qint64 QDateTime::daysTo(const QDateTime &other) const
Returns 0 if either time is invalid.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 11
+ \snippet code/src_corelib_tools_qdatetime.cpp 11
\sa addSecs(), daysTo(), QTime::secsTo()
*/
@@ -3420,7 +3420,7 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f)
of characters that are enclosed in singlequotes will also be
treated as text and not be used as an expression.
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 12
+ \snippet code/src_corelib_tools_qdatetime.cpp 12
If the format is not satisfied an invalid QDateTime is returned.
The expressions that don't have leading zeroes (d, M, h, m, s, z) will be
@@ -3428,7 +3428,7 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f)
put them outside the range and/or leave too few digits for other
sections.
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 13
+ \snippet code/src_corelib_tools_qdatetime.cpp 13
This could have meant 1 January 00:30.00 but the M will grab
two digits.
@@ -3448,10 +3448,10 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f)
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qdatetime.cpp 14
+ \snippet code/src_corelib_tools_qdatetime.cpp 14
- \sa QDate::fromString() QTime::fromString() QDate::toString()
- QDateTime::toString() QTime::toString()
+ \sa QDate::fromString(), QTime::fromString(), QDate::toString(),
+ QDateTime::toString(), QTime::toString()
*/
QDateTime QDateTime::fromString(const QString &string, const QString &format)
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 81778f908f..e237b81cfa 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -55,7 +55,7 @@
\class QEasingCurve
\since 4.6
\ingroup animation
- \brief The QEasingCurve class provides easing curves for controlling animation.
+ \captionief The QEasingCurve class provides easing curves for controlling animation.
Easing curves describe a function that controls how the speed of the interpolation
between 0 and 1 should be. Easing curves allow transitions from
@@ -112,183 +112,173 @@
The type of easing curve.
- \value Linear \inlineimage qeasingcurve-linear.png
- \br
- Easing curve for a linear (t) function:
+ \value Linear \image qeasingcurve-linear.png
+ \caption Easing curve for a linear (t) function:
velocity is constant.
- \value InQuad \inlineimage qeasingcurve-inquad.png
- \br
- Easing curve for a quadratic (t^2) function:
+ \value InQuad \image qeasingcurve-inquad.png
+ \caption Easing curve for a quadratic (t^2) function:
accelerating from zero velocity.
- \value OutQuad \inlineimage qeasingcurve-outquad.png
- \br
- Easing curve for a quadratic (t^2) function:
+ \value OutQuad \image qeasingcurve-outquad.png
+ \caption Easing curve for a quadratic (t^2) function:
decelerating to zero velocity.
- \value InOutQuad \inlineimage qeasingcurve-inoutquad.png
- \br
- Easing curve for a quadratic (t^2) function:
+ \value InOutQuad \image qeasingcurve-inoutquad.png
+ \caption Easing curve for a quadratic (t^2) function:
acceleration until halfway, then deceleration.
- \value OutInQuad \inlineimage qeasingcurve-outinquad.png
- \br
- Easing curve for a quadratic (t^2) function:
+ \value OutInQuad \image qeasingcurve-outinquad.png
+ \caption Easing curve for a quadratic (t^2) function:
deceleration until halfway, then acceleration.
- \value InCubic \inlineimage qeasingcurve-incubic.png
- \br
- Easing curve for a cubic (t^3) function:
+ \value InCubic \image qeasingcurve-incubic.png
+ \caption Easing curve for a cubic (t^3) function:
accelerating from zero velocity.
- \value OutCubic \inlineimage qeasingcurve-outcubic.png
- \br
- Easing curve for a cubic (t^3) function:
+ \value OutCubic \image qeasingcurve-outcubic.png
+ \caption Easing curve for a cubic (t^3) function:
decelerating to zero velocity.
- \value InOutCubic \inlineimage qeasingcurve-inoutcubic.png
- \br
- Easing curve for a cubic (t^3) function:
+ \value InOutCubic \image qeasingcurve-inoutcubic.png
+ \caption Easing curve for a cubic (t^3) function:
acceleration until halfway, then deceleration.
- \value OutInCubic \inlineimage qeasingcurve-outincubic.png
- \br
- Easing curve for a cubic (t^3) function:
+ \value OutInCubic \image qeasingcurve-outincubic.png
+ \caption Easing curve for a cubic (t^3) function:
deceleration until halfway, then acceleration.
- \value InQuart \inlineimage qeasingcurve-inquart.png
- \br
- Easing curve for a quartic (t^4) function:
+ \value InQuart \image qeasingcurve-inquart.png
+ \caption Easing curve for a quartic (t^4) function:
accelerating from zero velocity.
- \value OutQuart \inlineimage qeasingcurve-outquart.png
- \br
+ \value OutQuart \image qeasingcurve-outquart.png
+ \caption
Easing curve for a quartic (t^4) function:
decelerating to zero velocity.
- \value InOutQuart \inlineimage qeasingcurve-inoutquart.png
- \br
+ \value InOutQuart \image qeasingcurve-inoutquart.png
+ \caption
Easing curve for a quartic (t^4) function:
acceleration until halfway, then deceleration.
- \value OutInQuart \inlineimage qeasingcurve-outinquart.png
- \br
+ \value OutInQuart \image qeasingcurve-outinquart.png
+ \caption
Easing curve for a quartic (t^4) function:
deceleration until halfway, then acceleration.
- \value InQuint \inlineimage qeasingcurve-inquint.png
- \br
+ \value InQuint \image qeasingcurve-inquint.png
+ \caption
Easing curve for a quintic (t^5) easing
in: accelerating from zero velocity.
- \value OutQuint \inlineimage qeasingcurve-outquint.png
- \br
+ \value OutQuint \image qeasingcurve-outquint.png
+ \caption
Easing curve for a quintic (t^5) function:
decelerating to zero velocity.
- \value InOutQuint \inlineimage qeasingcurve-inoutquint.png
- \br
+ \value InOutQuint \image qeasingcurve-inoutquint.png
+ \caption
Easing curve for a quintic (t^5) function:
acceleration until halfway, then deceleration.
- \value OutInQuint \inlineimage qeasingcurve-outinquint.png
- \br
+ \value OutInQuint \image qeasingcurve-outinquint.png
+ \caption
Easing curve for a quintic (t^5) function:
deceleration until halfway, then acceleration.
- \value InSine \inlineimage qeasingcurve-insine.png
- \br
+ \value InSine \image qeasingcurve-insine.png
+ \caption
Easing curve for a sinusoidal (sin(t)) function:
accelerating from zero velocity.
- \value OutSine \inlineimage qeasingcurve-outsine.png
- \br
+ \value OutSine \image qeasingcurve-outsine.png
+ \caption
Easing curve for a sinusoidal (sin(t)) function:
decelerating from zero velocity.
- \value InOutSine \inlineimage qeasingcurve-inoutsine.png
- \br
+ \value InOutSine \image qeasingcurve-inoutsine.png
+ \caption
Easing curve for a sinusoidal (sin(t)) function:
acceleration until halfway, then deceleration.
- \value OutInSine \inlineimage qeasingcurve-outinsine.png
- \br
+ \value OutInSine \image qeasingcurve-outinsine.png
+ \caption
Easing curve for a sinusoidal (sin(t)) function:
deceleration until halfway, then acceleration.
- \value InExpo \inlineimage qeasingcurve-inexpo.png
- \br
+ \value InExpo \image qeasingcurve-inexpo.png
+ \caption
Easing curve for an exponential (2^t) function:
accelerating from zero velocity.
- \value OutExpo \inlineimage qeasingcurve-outexpo.png
- \br
+ \value OutExpo \image qeasingcurve-outexpo.png
+ \caption
Easing curve for an exponential (2^t) function:
decelerating from zero velocity.
- \value InOutExpo \inlineimage qeasingcurve-inoutexpo.png
- \br
+ \value InOutExpo \image qeasingcurve-inoutexpo.png
+ \caption
Easing curve for an exponential (2^t) function:
acceleration until halfway, then deceleration.
- \value OutInExpo \inlineimage qeasingcurve-outinexpo.png
- \br
+ \value OutInExpo \image qeasingcurve-outinexpo.png
+ \caption
Easing curve for an exponential (2^t) function:
deceleration until halfway, then acceleration.
- \value InCirc \inlineimage qeasingcurve-incirc.png
- \br
+ \value InCirc \image qeasingcurve-incirc.png
+ \caption
Easing curve for a circular (sqrt(1-t^2)) function:
accelerating from zero velocity.
- \value OutCirc \inlineimage qeasingcurve-outcirc.png
- \br
+ \value OutCirc \image qeasingcurve-outcirc.png
+ \caption
Easing curve for a circular (sqrt(1-t^2)) function:
decelerating from zero velocity.
- \value InOutCirc \inlineimage qeasingcurve-inoutcirc.png
- \br
+ \value InOutCirc \image qeasingcurve-inoutcirc.png
+ \caption
Easing curve for a circular (sqrt(1-t^2)) function:
acceleration until halfway, then deceleration.
- \value OutInCirc \inlineimage qeasingcurve-outincirc.png
- \br
+ \value OutInCirc \image qeasingcurve-outincirc.png
+ \caption
Easing curve for a circular (sqrt(1-t^2)) function:
deceleration until halfway, then acceleration.
- \value InElastic \inlineimage qeasingcurve-inelastic.png
- \br
+ \value InElastic \image qeasingcurve-inelastic.png
+ \caption
Easing curve for an elastic
(exponentially decaying sine wave) function:
accelerating from zero velocity. The peak amplitude
can be set with the \e amplitude parameter, and the
period of decay by the \e period parameter.
- \value OutElastic \inlineimage qeasingcurve-outelastic.png
- \br
+ \value OutElastic \image qeasingcurve-outelastic.png
+ \caption
Easing curve for an elastic
(exponentially decaying sine wave) function:
decelerating from zero velocity. The peak amplitude
can be set with the \e amplitude parameter, and the
period of decay by the \e period parameter.
- \value InOutElastic \inlineimage qeasingcurve-inoutelastic.png
- \br
+ \value InOutElastic \image qeasingcurve-inoutelastic.png
+ \caption
Easing curve for an elastic
(exponentially decaying sine wave) function:
acceleration until halfway, then deceleration.
- \value OutInElastic \inlineimage qeasingcurve-outinelastic.png
- \br
+ \value OutInElastic \image qeasingcurve-outinelastic.png
+ \caption
Easing curve for an elastic
(exponentially decaying sine wave) function:
deceleration until halfway, then acceleration.
- \value InBack \inlineimage qeasingcurve-inback.png
- \br
+ \value InBack \image qeasingcurve-inback.png
+ \caption
Easing curve for a back (overshooting
cubic function: (s+1)*t^3 - s*t^2) easing in:
accelerating from zero velocity.
- \value OutBack \inlineimage qeasingcurve-outback.png
- \br
+ \value OutBack \image qeasingcurve-outback.png
+ \caption
Easing curve for a back (overshooting
cubic function: (s+1)*t^3 - s*t^2) easing out:
decelerating to zero velocity.
- \value InOutBack \inlineimage qeasingcurve-inoutback.png
- \br
+ \value InOutBack \image qeasingcurve-inoutback.png
+ \caption
Easing curve for a back (overshooting
cubic function: (s+1)*t^3 - s*t^2) easing in/out:
acceleration until halfway, then deceleration.
- \value OutInBack \inlineimage qeasingcurve-outinback.png
- \br
+ \value OutInBack \image qeasingcurve-outinback.png
+ \caption
Easing curve for a back (overshooting
cubic easing: (s+1)*t^3 - s*t^2) easing out/in:
deceleration until halfway, then acceleration.
- \value InBounce \inlineimage qeasingcurve-inbounce.png
- \br
+ \value InBounce \image qeasingcurve-inbounce.png
+ \caption
Easing curve for a bounce (exponentially
decaying parabolic bounce) function: accelerating
from zero velocity.
- \value OutBounce \inlineimage qeasingcurve-outbounce.png
- \br
+ \value OutBounce \image qeasingcurve-outbounce.png
+ \caption
Easing curve for a bounce (exponentially
decaying parabolic bounce) function: decelerating
from zero velocity.
- \value InOutBounce \inlineimage qeasingcurve-inoutbounce.png
- \br
+ \value InOutBounce \image qeasingcurve-inoutbounce.png
+ \caption
Easing curve for a bounce (exponentially
decaying parabolic bounce) function easing in/out:
acceleration until halfway, then deceleration.
- \value OutInBounce \inlineimage qeasingcurve-outinbounce.png
- \br
+ \value OutInBounce \image qeasingcurve-outinbounce.png
+ \caption
Easing curve for a bounce (exponentially
decaying parabolic bounce) function easing out/in:
deceleration until halfway, then acceleration.
@@ -312,7 +302,7 @@
This is a typedef for a pointer to a function with the following
signature:
- \snippet doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp 0
+ \snippet code/src_corelib_tools_qeasingcurve.cpp 0
*/
#include "qeasingcurve.h"
@@ -349,7 +339,7 @@ struct TCBPoint {
TCBPoint() {}
TCBPoint(QPointF point, qreal t, qreal c, qreal b) : _point(point), _t(t), _c(c), _b(b) {}
- bool operator==(const TCBPoint& other)
+ bool operator==(const TCBPoint &other) const
{
return _point == other._point &&
qFuzzyCompare(_t, other._t) &&
@@ -373,7 +363,7 @@ public:
virtual ~QEasingCurveFunction() {}
virtual qreal value(qreal t);
virtual QEasingCurveFunction *copy() const;
- bool operator==(const QEasingCurveFunction& other);
+ bool operator==(const QEasingCurveFunction &other) const;
Type _t;
qreal _p;
@@ -397,7 +387,7 @@ QEasingCurveFunction *QEasingCurveFunction::copy() const
return rv;
}
-bool QEasingCurveFunction::operator==(const QEasingCurveFunction& other)
+bool QEasingCurveFunction::operator==(const QEasingCurveFunction &other) const
{
return _t == other._t &&
qFuzzyCompare(_p, other._p) &&
@@ -1467,7 +1457,7 @@ QDataStream &operator<<(QDataStream &stream, const QEasingCurve &easing)
/*!
\fn QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing)
- \relates QQuaternion
+ \relates QEasingCurve
Reads an easing curve from the given \a stream into the given \a
easing curve and returns a reference to the stream.
diff --git a/src/corelib/tools/qelapsedtimer.cpp b/src/corelib/tools/qelapsedtimer.cpp
index e8f2ce174e..76b0d796f0 100644
--- a/src/corelib/tools/qelapsedtimer.cpp
+++ b/src/corelib/tools/qelapsedtimer.cpp
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
spent in a slow operation. The simplest example of such a case is for
debugging purposes, as in the following example:
- \snippet doc/src/snippets/qelapsedtimer/main.cpp 0
+ \snippet qelapsedtimer/main.cpp 0
In this example, the timer is started by a call to start() and the
elapsed timer is calculated by the elapsed() function.
@@ -76,14 +76,14 @@ QT_BEGIN_NAMESPACE
subclasses are good examples of such need. In that case, the code could
be as follows:
- \snippet doc/src/snippets/qelapsedtimer/main.cpp 1
+ \snippet qelapsedtimer/main.cpp 1
Another use-case is to execute a certain operation for a specific
timeslice. For this, QElapsedTimer provides the hasExpired() convenience
function, which can be used to determine if a certain number of
milliseconds has already elapsed:
- \snippet doc/src/snippets/qelapsedtimer/main.cpp 2
+ \snippet qelapsedtimer/main.cpp 2
\section1 Reference clocks
diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/tools/qelapsedtimer_generic.cpp
index 05214f0698..a20b6b5662 100644
--- a/src/corelib/tools/qelapsedtimer_generic.cpp
+++ b/src/corelib/tools/qelapsedtimer_generic.cpp
@@ -70,7 +70,7 @@ bool QElapsedTimer::isMonotonic()
Starts this timer. Once started, a timer value can be checked with elapsed() or msecsSinceReference().
Normally, a timer is started just before a lengthy operation, such as:
- \snippet doc/src/snippets/qelapsedtimer/main.cpp 0
+ \snippet qelapsedtimer/main.cpp 0
Also, starting a timer makes it valid again.
@@ -91,7 +91,7 @@ void QElapsedTimer::start()
parameter to a slow operation (for example, an iteration count) so that
this operation takes at least 250 milliseconds:
- \snippet doc/src/snippets/qelapsedtimer/main.cpp 3
+ \snippet qelapsedtimer/main.cpp 3
\sa start(), invalidate(), elapsed()
*/
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 20202a4896..10dcff92c7 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -369,7 +369,6 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),
QT_RETHROW;
}
- dup->h = oldNode->h;
*nextNode = dup;
nextNode = &dup->next;
oldNode = oldNode->next;
@@ -694,21 +693,21 @@ void QHashData::checkSanity()
\endlist
Here's an example QHash with QString keys and \c int values:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 0
+ \snippet code/src_corelib_tools_qhash.cpp 0
To insert a (key, value) pair into the hash, you can use operator[]():
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 1
+ \snippet code/src_corelib_tools_qhash.cpp 1
This inserts the following three (key, value) pairs into the
QHash: ("one", 1), ("three", 3), and ("seven", 7). Another way to
insert items into the hash is to use insert():
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 2
+ \snippet code/src_corelib_tools_qhash.cpp 2
To look up a value, use operator[]() or value():
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 3
+ \snippet code/src_corelib_tools_qhash.cpp 3
If there is no item with the specified key in the hash, these
functions return a \l{default-constructed value}.
@@ -716,12 +715,12 @@ void QHashData::checkSanity()
If you want to check whether the hash contains a particular key,
use contains():
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 4
+ \snippet code/src_corelib_tools_qhash.cpp 4
There is also a value() overload that uses its second argument as
a default value if there is no item with the specified key:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 5
+ \snippet code/src_corelib_tools_qhash.cpp 5
In general, we recommend that you use contains() and value()
rather than operator[]() for looking up a key in a hash. The
@@ -730,7 +729,7 @@ void QHashData::checkSanity()
const). For example, the following code snippet will create 1000
items in memory:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 6
+ \snippet code/src_corelib_tools_qhash.cpp 6
To avoid this problem, replace \c hash[i] with \c hash.value(i)
in the code above.
@@ -751,11 +750,11 @@ void QHashData::checkSanity()
QHash::iterator). Here's how to iterate over a QHash<QString,
int> using a Java-style iterator:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 7
+ \snippet code/src_corelib_tools_qhash.cpp 7
Here's the same code, but using an STL-style iterator:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 8
+ \snippet code/src_corelib_tools_qhash.cpp 8
QHash is unordered, so an iterator's sequence cannot be assumed
to be predictable. If ordering by key is required, use a QMap.
@@ -764,7 +763,7 @@ void QHashData::checkSanity()
insert() with a key that already exists in the QHash, the
previous value is erased. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 9
+ \snippet code/src_corelib_tools_qhash.cpp 9
However, you can store multiple values per key by using
insertMulti() instead of insert() (or using the convenience
@@ -772,19 +771,19 @@ void QHashData::checkSanity()
the values for a single key, you can use values(const Key &key),
which returns a QList<T>:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 10
+ \snippet code/src_corelib_tools_qhash.cpp 10
The items that share the same key are available from most
recently to least recently inserted. A more efficient approach is
to call find() to get the iterator for the first item with a key
and iterate from there:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 11
+ \snippet code/src_corelib_tools_qhash.cpp 11
If you only need to extract the values from a hash (not the keys),
you can also use \l{foreach}:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 12
+ \snippet code/src_corelib_tools_qhash.cpp 12
Items can be removed from the hash in several ways. One way is to
call remove(); this will remove any item with the given key.
@@ -975,7 +974,7 @@ void QHashData::checkSanity()
This function is useful for code that needs to build a huge hash
and wants to avoid repeated reallocation. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 14
+ \snippet code/src_corelib_tools_qhash.cpp 14
Ideally, \a size should be slightly more than the maximum number
of items expected in the hash. \a size doesn't have to be prime,
@@ -1284,7 +1283,7 @@ void QHashData::checkSanity()
be called while iterating, and won't affect the order of items in
the hash. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 15
+ \snippet code/src_corelib_tools_qhash.cpp 15
\sa remove(), take(), find()
*/
@@ -1303,7 +1302,7 @@ void QHashData::checkSanity()
the iterator. For example, here's some code that iterates over all
the items with the same key:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 16
+ \snippet code/src_corelib_tools_qhash.cpp 16
\sa value(), values(), QMultiHash::find()
*/
@@ -1460,7 +1459,7 @@ void QHashData::checkSanity()
start iterating. Here's a typical loop that prints all the (key,
value) pairs stored in a hash:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 17
+ \snippet code/src_corelib_tools_qhash.cpp 17
Unlike QMap, which orders its items by key, QHash stores its
items in an arbitrary order. The only guarantee is that items that
@@ -1473,22 +1472,22 @@ void QHashData::checkSanity()
Here's an example that increments every value stored in the QHash
by 2:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 18
+ \snippet code/src_corelib_tools_qhash.cpp 18
Here's an example that removes all the items whose key is a
string that starts with an underscore character:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 19
+ \snippet code/src_corelib_tools_qhash.cpp 19
The call to QHash::erase() removes the item pointed to by the
iterator from the hash, and returns an iterator to the next item.
Here's another way of removing an item while iterating:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 20
+ \snippet code/src_corelib_tools_qhash.cpp 20
It might be tempting to write code like this:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 21
+ \snippet code/src_corelib_tools_qhash.cpp 21
However, this will potentially crash in \c{++i}, because \c i is
a dangling iterator after the call to erase().
@@ -1514,7 +1513,7 @@ void QHashData::checkSanity()
called on an uninitialized iterator. Use operator=() to assign a
value to it before using it.
- \sa QHash::begin() QHash::end()
+ \sa QHash::begin(), QHash::end()
*/
/*! \fn QHash::iterator::iterator(void *node)
@@ -1540,7 +1539,7 @@ void QHashData::checkSanity()
You can change the value of an item by using value() on
the left side of an assignment, for example:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 22
+ \snippet code/src_corelib_tools_qhash.cpp 22
\sa key(), operator*()
*/
@@ -1684,7 +1683,7 @@ void QHashData::checkSanity()
QHash::find() before you can start iterating. Here's a typical
loop that prints all the (key, value) pairs stored in a hash:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 23
+ \snippet code/src_corelib_tools_qhash.cpp 23
Unlike QMap, which orders its items by key, QHash stores its
items in an arbitrary order. The only guarantee is that items that
@@ -1710,7 +1709,7 @@ void QHashData::checkSanity()
called on an uninitialized iterator. Use operator=() to assign a
value to it before using it.
- \sa QHash::constBegin() QHash::constEnd()
+ \sa QHash::constBegin(), QHash::constEnd()
*/
/*! \fn QHash::const_iterator::const_iterator(void *node)
@@ -1897,7 +1896,7 @@ void QHashData::checkSanity()
operator+=().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 24
+ \snippet code/src_corelib_tools_qhash.cpp 24
Unlike QHash, QMultiHash provides no operator[]. Use value() or
replace() if you want to access the most recently inserted item
@@ -1906,7 +1905,7 @@ void QHashData::checkSanity()
If you want to retrieve all the values for a single key, you can
use values(const Key &key), which returns a QList<T>:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 25
+ \snippet code/src_corelib_tools_qhash.cpp 25
The items that share the same key are available from most
recently to least recently inserted.
@@ -1915,7 +1914,7 @@ void QHashData::checkSanity()
the STL-style iterator for the first item with a key and iterate from
there:
- \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 26
+ \snippet code/src_corelib_tools_qhash.cpp 26
QMultiHash's key and value data types must be \l{assignable data
types}. You cannot, for example, store a QWidget as a value;
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index fe6a8dfad1..d196e6e376 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -197,27 +197,29 @@ inline bool operator==(const QHashDummyValue & /* v1 */, const QHashDummyValue &
Q_DECLARE_TYPEINFO(QHashDummyValue, Q_MOVABLE_TYPE | Q_DUMMY_TYPE);
template <class Key, class T>
-struct QHashDummyNode
+struct QHashNode
{
- QHashDummyNode *next;
+ QHashNode *next;
uint h;
Key key;
+ T value;
- inline QHashDummyNode(const Key &key0) : key(key0) {}
+ inline QHashNode(const Key &key0, const T &value0, uint hash, QHashNode *n)
+ : next(n), h(hash), key(key0), value(value0) {}
+ inline bool same_key(uint h0, const Key &key0) { return h0 == h && key0 == key; }
};
template <class Key, class T>
-struct QHashNode
+struct QHashDummyNode
{
- QHashNode *next;
+ QHashNode<Key, T> *next;
uint h;
Key key;
- T value;
- inline QHashNode(const Key &key0, const T &value0) : key(key0), value(value0) {}
- inline bool same_key(uint h0, const Key &key0) { return h0 == h && key0 == key; }
+ inline QHashDummyNode(const Key &key0, uint hash, QHashNode<Key, T> *n) : next(n), h(hash), key(key0) {}
};
+
#if 0
// ###
// The introduction of the QHash random seed breaks this optimization, as it
@@ -519,9 +521,9 @@ Q_INLINE_TEMPLATE void QHash<Key, T>::duplicateNode(QHashData::Node *node, void
{
Node *concreteNode = concrete(node);
if (QTypeInfo<T>::isDummy) {
- (void) new (newNode) DummyNode(concreteNode->key);
+ (void) new (newNode) DummyNode(concreteNode->key, concreteNode->h, 0);
} else {
- (void) new (newNode) Node(concreteNode->key, concreteNode->value);
+ (void) new (newNode) Node(concreteNode->key, concreteNode->value, concreteNode->h, 0);
}
}
@@ -532,13 +534,11 @@ QHash<Key, T>::createNode(uint ah, const Key &akey, const T &avalue, Node **anex
Node *node;
if (QTypeInfo<T>::isDummy) {
- node = reinterpret_cast<Node *>(new (d->allocateNode(alignOfDummyNode())) DummyNode(akey));
+ node = reinterpret_cast<Node *>(new (d->allocateNode(alignOfDummyNode())) DummyNode(akey, ah, *anextNode));
} else {
- node = new (d->allocateNode(alignOfNode())) Node(akey, avalue);
+ node = new (d->allocateNode(alignOfNode())) Node(akey, avalue, ah, *anextNode);
}
- node->h = ah;
- node->next = *anextNode;
*anextNode = node;
++d->size;
return node;
diff --git a/src/corelib/tools/qiterator.qdoc b/src/corelib/tools/qiterator.qdoc
index e19a751755..508664ec45 100644
--- a/src/corelib/tools/qiterator.qdoc
+++ b/src/corelib/tools/qiterator.qdoc
@@ -50,7 +50,7 @@
the list (before the first item). Here's how to iterate over all
the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 0
+ \snippet code/doc_src_qiterator.cpp 0
The next() function returns the next item in the list and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -61,11 +61,11 @@
position between the second and third item, and returns the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 1
+ \snippet code/doc_src_qiterator.cpp 1
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -98,7 +98,7 @@
beginning of the list (before the first item). Here's how to
iterate over all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 2
+ \snippet code/doc_src_qiterator.cpp 2
The next() function returns the next item in the list and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -109,11 +109,11 @@
position between the second and third item, and returns the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 3
+ \snippet code/doc_src_qiterator.cpp 3
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -150,7 +150,7 @@
of the vector (before the first item). Here's how to iterate over
all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 4
+ \snippet code/doc_src_qiterator.cpp 4
The next() function returns the next item in the vector and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -161,11 +161,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 5
+ \snippet code/doc_src_qiterator.cpp 5
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -197,7 +197,7 @@
the first item). Here's how to iterate over all the elements
sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 6
+ \snippet code/doc_src_qiterator.cpp 6
The next() function returns the next item in the set and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -208,11 +208,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 7
+ \snippet code/doc_src_qiterator.cpp 7
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -251,7 +251,7 @@
of the list (before the first item). Here's how to iterate over
all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 8
+ \snippet code/doc_src_qiterator.cpp 8
The next() function returns the next item in the list and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -262,11 +262,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 9
+ \snippet code/doc_src_qiterator.cpp 9
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -277,7 +277,7 @@
insert().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 10
+ \snippet code/doc_src_qiterator.cpp 10
The example traverses a list, replacing negative numbers with
their absolute values, and eliminating zeroes.
@@ -312,7 +312,7 @@
beginning of the list (before the first item). Here's how to
iterate over all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 11
+ \snippet code/doc_src_qiterator.cpp 11
The next() function returns the next item in the list and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -323,11 +323,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 12
+ \snippet code/doc_src_qiterator.cpp 12
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -338,7 +338,7 @@
insert().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 13
+ \snippet code/doc_src_qiterator.cpp 13
The example traverses a list, replacing negative numbers with
their absolute values, and eliminating zeroes.
@@ -378,7 +378,7 @@
beginning of the list (before the first item). Here's how to
iterate over all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 14
+ \snippet code/doc_src_qiterator.cpp 14
The next() function returns the next item in the vector and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -389,11 +389,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 15
+ \snippet code/doc_src_qiterator.cpp 15
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop.
@@ -404,7 +404,7 @@
insert().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 16
+ \snippet code/doc_src_qiterator.cpp 16
The example traverses a vector, replacing negative numbers with
their absolute values, and eliminating zeroes.
@@ -440,7 +440,7 @@
of the set (before the first item). Here's how to iterate over
all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 17
+ \snippet code/doc_src_qiterator.cpp 17
The next() function returns the next item in the set and
advances the iterator. Unlike STL-style iterators, Java-style
@@ -451,11 +451,11 @@
position between the second and third item, returning the second
item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 18
+ \snippet code/doc_src_qiterator.cpp 18
If you want to remove items as you iterate over the set, use
remove().
@@ -755,7 +755,7 @@
traversal functions (next(), previous(), findNext(), findPrevious()).
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 19
+ \snippet code/doc_src_qiterator.cpp 19
\sa insert(), setValue()
*/
@@ -766,7 +766,7 @@
traversal functions (next(), previous(), findNext(), findPrevious()).
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 20
+ \snippet code/doc_src_qiterator.cpp 20
\sa insert(), setValue()
*/
@@ -777,7 +777,7 @@
traversal functions (next(), previous(), findNext(), findPrevious()).
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 21
+ \snippet code/doc_src_qiterator.cpp 21
\sa insert(), setValue()
*/
@@ -788,7 +788,7 @@
traversal functions (next(), previous(), findNext(), findPrevious()).
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 22
+ \snippet code/doc_src_qiterator.cpp 22
\sa value()
*/
@@ -802,7 +802,7 @@
findPrevious().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 23
+ \snippet code/doc_src_qiterator.cpp 23
\sa value(), remove(), insert()
*/
@@ -816,7 +816,7 @@
findPrevious().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 24
+ \snippet code/doc_src_qiterator.cpp 24
\sa value(), remove(), insert()
*/
@@ -830,7 +830,7 @@
findPrevious().
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 25
+ \snippet code/doc_src_qiterator.cpp 25
\sa value(), remove(), insert()
*/
@@ -889,7 +889,7 @@
the map (before the first item). Here's how to iterate over all
the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 26
+ \snippet code/doc_src_qiterator.cpp 26
The next() function returns the next item in the map and
advances the iterator. The key() and value() functions return the
@@ -902,16 +902,16 @@
next() advances the iterator to the position between the second
and third item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 27
+ \snippet code/doc_src_qiterator.cpp 27
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop. For example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 28
+ \snippet code/doc_src_qiterator.cpp 28
Multiple iterators can be used on the same map. If the map is
modified while a QMapIterator is active, the QMapIterator will
@@ -941,7 +941,7 @@
the hash (before the first item). Here's how to iterate over all
the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 29
+ \snippet code/doc_src_qiterator.cpp 29
The next() function returns the next item in the hash and
advances the iterator. The key() and value() functions return the
@@ -954,16 +954,16 @@
next() advances the iterator to the position between the second
and third item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 30
+ \snippet code/doc_src_qiterator.cpp 30
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop. For example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 31
+ \snippet code/doc_src_qiterator.cpp 31
Multiple iterators can be used on the same hash. If the hash is
modified while a QHashIterator is active, the QHashIterator will
@@ -994,7 +994,7 @@
of the map (before the first item). Here's how to iterate over
all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 32
+ \snippet code/doc_src_qiterator.cpp 32
The next() function returns the next item in the map and
advances the iterator. The key() and value() functions return the
@@ -1007,16 +1007,16 @@
next() advances the iterator to the position between the second
and third item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 33
+ \snippet code/doc_src_qiterator.cpp 33
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop. For example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 34
+ \snippet code/doc_src_qiterator.cpp 34
If you want to remove items as you iterate over the map, use
remove(). If you want to modify the value of an item, use
@@ -1024,7 +1024,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 35
+ \snippet code/doc_src_qiterator.cpp 35
The example removes all (key, value) pairs where the key and the
value are the same.
@@ -1059,7 +1059,7 @@
of the hash (before the first item). Here's how to iterate over
all the elements sequentially:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 36
+ \snippet code/doc_src_qiterator.cpp 36
The next() function returns the next item in the hash and
advances the iterator. The key() and value() functions return the
@@ -1072,16 +1072,16 @@
next() advances the iterator to the position between the second
and third item; and so on.
- \img javaiterators1.png
+ \image javaiterators1.png
Here's how to iterate over the elements in reverse order:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 37
+ \snippet code/doc_src_qiterator.cpp 37
If you want to find all occurrences of a particular value, use
findNext() or findPrevious() in a loop. For example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 38
+ \snippet code/doc_src_qiterator.cpp 38
If you want to remove items as you iterate over the hash, use
remove(). If you want to modify the value of an item, use
@@ -1089,7 +1089,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qiterator.cpp 39
+ \snippet code/doc_src_qiterator.cpp 39
The example removes all (key, value) pairs where the key and the
value are the same.
diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp
index 1502f70d56..3682818099 100644
--- a/src/corelib/tools/qlinkedlist.cpp
+++ b/src/corelib/tools/qlinkedlist.cpp
@@ -81,13 +81,13 @@ const QLinkedListData QLinkedListData::shared_null = {
Here's an example of a QLinkedList that stores integers and a
QLinkedList that stores QTime values:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 0
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 0
QLinkedList stores a list of items. The default constructor
creates an empty list. To insert items into the list, you can use
operator<<():
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 1
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 1
If you want to get the first or last item in a linked list, use
first() or last(). If you want to remove an item from either end
@@ -99,7 +99,7 @@ const QLinkedListData QLinkedListData::shared_null = {
list and do something with it. For this, QLinkedList provides
takeFirst() and takeLast(). Here's a loop that removes the items
from a list one at a time and calls \c delete on them:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 2
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 2
QLinkedList's value type must be an \l {assignable data type}. This
covers most data types that are commonly used, but the compiler
@@ -230,7 +230,7 @@ const QLinkedListData QLinkedListData::shared_null = {
Inserts \a value at the end of the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 3
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 3
This is the same as list.insert(end(), \a value).
@@ -242,7 +242,7 @@ const QLinkedListData QLinkedListData::shared_null = {
Inserts \a value at the beginning of the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 4
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 4
This is the same as list.insert(begin(), \a value).
@@ -254,7 +254,7 @@ const QLinkedListData QLinkedListData::shared_null = {
Removes all occurrences of \a value in the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 5
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 5
This function requires the value type to have an implementation of
\c operator==().
@@ -270,7 +270,7 @@ const QLinkedListData QLinkedListData::shared_null = {
success; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 6
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 6
This function requires the value type to have an implementation of
\c operator==().
@@ -635,35 +635,35 @@ const QLinkedListData QLinkedListData::shared_null = {
QLinkedList::insert() before you can start iterating. Here's a
typical loop that prints all the items stored in a list:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 7
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 7
STL-style iterators can be used as arguments to \l{generic
algorithms}. For example, here's how to find an item in the list
using the qFind() algorithm:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 8
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 8
Let's see a few examples of things we can do with a
QLinkedList::iterator that we cannot do with a QLinkedList::const_iterator.
Here's an example that increments every value stored in a
QLinkedList\<int\> by 2:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 9
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 9
Here's an example that removes all the items that start with an
underscore character in a QLinkedList\<QString\>:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 10
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 10
The call to QLinkedList::erase() removes the item pointed to by
the iterator from the list, and returns an iterator to the next
item. Here's another way of removing an item while iterating:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 11
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 11
It might be tempting to write code like this:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 12
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 12
However, this will potentially crash in \c{++i}, because \c i is
a dangling iterator after the call to erase().
@@ -686,7 +686,7 @@ const QLinkedListData QLinkedListData::shared_null = {
on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
- \sa QLinkedList::begin() QLinkedList::end()
+ \sa QLinkedList::begin(), QLinkedList::end()
*/
/*! \fn QLinkedList::iterator::iterator(Node *node)
@@ -736,7 +736,7 @@ const QLinkedListData QLinkedListData::shared_null = {
You can change the value of an item by using operator*() on the
left side of an assignment, for example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 13
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 13
\sa operator->()
*/
@@ -868,13 +868,13 @@ const QLinkedListData QLinkedListData::shared_null = {
QLinkedList::insert() before you can start iterating. Here's a
typical loop that prints all the items stored in a list:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 14
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 14
STL-style iterators can be used as arguments to \l{generic
algorithms}. For example, here's how to find an item in the list
using the qFind() algorithm:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 15
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 15
Multiple iterators can be used on the same list. If you add items
to the list, existing iterators will remain valid. If you remove
@@ -892,7 +892,7 @@ const QLinkedListData QLinkedListData::shared_null = {
on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
- \sa QLinkedList::constBegin() QLinkedList::constEnd()
+ \sa QLinkedList::constBegin(), QLinkedList::constEnd()
*/
/*! \fn QLinkedList::const_iterator::const_iterator(Node *node)
@@ -1082,7 +1082,7 @@ const QLinkedListData QLinkedListData::shared_null = {
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 16
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 16
\sa toStdList()
*/
@@ -1094,7 +1094,7 @@ const QLinkedListData QLinkedListData::shared_null = {
Returns a std::list object with the data contained in this
QLinkedList. Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 17
+ \snippet code/src_corelib_tools_qlinkedlist.cpp 17
\sa fromStdList()
*/
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index c87b3e7d24..b3514d35ef 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -375,7 +375,7 @@ void **QListData::erase(void **xi)
Here's an example of a QList that stores integers and
a QList that stores QDate values:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 0
+ \snippet code/src_corelib_tools_qlistdata.cpp 0
Qt includes a QStringList class that inherits QList\<QString\>
and adds a few convenience functions, such as QStringList::join()
@@ -386,7 +386,7 @@ void **QListData::erase(void **xi)
empty list. To insert items into the list, you can use
operator<<():
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 1
+ \snippet code/src_corelib_tools_qlistdata.cpp 1
QList provides these basic functions to add, move, and remove
items: insert(), replace(), removeAt(), move(), and swap(). In
@@ -398,13 +398,13 @@ void **QListData::erase(void **xi)
non-const lists, operator[]() returns a reference to the item and
can be used on the left side of an assignment:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 2
+ \snippet code/src_corelib_tools_qlistdata.cpp 2
Because QList is implemented as an array of pointers, this
operation is very fast (\l{constant time}). For read-only access,
an alternative syntax is to use at():
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 3
+ \snippet code/src_corelib_tools_qlistdata.cpp 3
at() can be faster than operator[](), because it never causes a
\l{deep copy} to occur.
@@ -414,7 +414,7 @@ void **QListData::erase(void **xi)
and takeLast(). Here's a loop that removes the items from a list
one at a time and calls \c delete on them:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 4
+ \snippet code/src_corelib_tools_qlistdata.cpp 4
Inserting and removing items at either ends of the list is very
fast (\l{constant time} in most cases), because QList
@@ -427,7 +427,7 @@ void **QListData::erase(void **xi)
backward. Both return the index of a matching item if they find
it; otherwise, they return -1. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 5
+ \snippet code/src_corelib_tools_qlistdata.cpp 5
If you simply want to check whether a list contains a particular
value, use contains(). If you want to find out how many times a
@@ -652,7 +652,7 @@ void **QListData::erase(void **xi)
Inserts \a value at the end of the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 6
+ \snippet code/src_corelib_tools_qlistdata.cpp 6
This is the same as list.insert(size(), \a value).
@@ -680,7 +680,7 @@ void **QListData::erase(void **xi)
Inserts \a value at the beginning of the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 7
+ \snippet code/src_corelib_tools_qlistdata.cpp 7
This is the same as list.insert(0, \a value).
@@ -698,7 +698,7 @@ void **QListData::erase(void **xi)
value is appended to the list.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 8
+ \snippet code/src_corelib_tools_qlistdata.cpp 8
\sa append(), prepend(), replace(), removeAt()
*/
@@ -729,7 +729,7 @@ void **QListData::erase(void **xi)
number of entries removed.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 9
+ \snippet code/src_corelib_tools_qlistdata.cpp 9
This function requires the value type to have an implementation of
\c operator==().
@@ -745,7 +745,7 @@ void **QListData::erase(void **xi)
true on success; otherwise returns false.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 10
+ \snippet code/src_corelib_tools_qlistdata.cpp 10
This function requires the value type to have an implementation of
\c operator==().
@@ -805,7 +805,7 @@ void **QListData::erase(void **xi)
Moves the item at index position \a from to index position \a to.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 11
+ \snippet code/src_corelib_tools_qlistdata.cpp 11
This is the same as insert(\a{to}, takeAt(\a{from})).This function
assumes that both \a from and \a to are at least 0 but less than
@@ -823,7 +823,7 @@ void **QListData::erase(void **xi)
\a i and \a j are at least 0 and less than size().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 12
+ \snippet code/src_corelib_tools_qlistdata.cpp 12
\sa move()
*/
@@ -835,7 +835,7 @@ void **QListData::erase(void **xi)
-1 if no item matched.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 13
+ \snippet code/src_corelib_tools_qlistdata.cpp 13
This function requires the value type to have an implementation of
\c operator==().
@@ -855,7 +855,7 @@ void **QListData::erase(void **xi)
Returns -1 if no item matched.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 14
+ \snippet code/src_corelib_tools_qlistdata.cpp 14
This function requires the value type to have an implementation of
\c operator==().
@@ -1237,14 +1237,14 @@ void **QListData::erase(void **xi)
start iterating. Here's a typical loop that prints all the items
stored in a list:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 15
+ \snippet code/src_corelib_tools_qlistdata.cpp 15
Let's see a few examples of things we can do with a
QList::iterator that we cannot do with a QList::const_iterator.
Here's an example that increments every value stored in a
QList\<int\> by 2:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 16
+ \snippet code/src_corelib_tools_qlistdata.cpp 16
Most QList functions accept an integer index rather than an
iterator. For that reason, iterators are rarely useful in
@@ -1254,7 +1254,7 @@ void **QListData::erase(void **xi)
For example, here's how to delete all the widgets stored in a
QList\<QWidget *\>:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 17
+ \snippet code/src_corelib_tools_qlistdata.cpp 17
Multiple iterators can be used on the same list. However, be
aware that any non-const function call performed on the QList
@@ -1299,7 +1299,7 @@ void **QListData::erase(void **xi)
on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
- \sa QList::begin() QList::end()
+ \sa QList::begin(), QList::end()
*/
/*! \fn QList::iterator::iterator(Node *node)
@@ -1319,7 +1319,7 @@ void **QListData::erase(void **xi)
You can change the value of an item by using operator*() on the
left side of an assignment, for example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 18
+ \snippet code/src_corelib_tools_qlistdata.cpp 18
\sa operator->()
*/
@@ -1493,7 +1493,7 @@ void **QListData::erase(void **xi)
QList::insert() before you can start iterating. Here's a typical
loop that prints all the items stored in a list:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 19
+ \snippet code/src_corelib_tools_qlistdata.cpp 19
Most QList functions accept an integer index rather than an
iterator. For that reason, iterators are rarely useful in
@@ -1503,7 +1503,7 @@ void **QListData::erase(void **xi)
For example, here's how to delete all the widgets stored in a
QList\<QWidget *\>:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 20
+ \snippet code/src_corelib_tools_qlistdata.cpp 20
Multiple iterators can be used on the same list. However, be
aware that any non-const function call performed on the QList
@@ -1522,7 +1522,7 @@ void **QListData::erase(void **xi)
on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
- \sa QList::constBegin() QList::constEnd()
+ \sa QList::constBegin(), QList::constEnd()
*/
/*! \typedef QList::const_iterator::iterator_category
@@ -1738,7 +1738,7 @@ void **QListData::erase(void **xi)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 21
+ \snippet code/src_corelib_tools_qlistdata.cpp 21
\sa fromSet(), toVector(), QVector::toList()
*/
@@ -1749,7 +1749,7 @@ void **QListData::erase(void **xi)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 22
+ \snippet code/src_corelib_tools_qlistdata.cpp 22
\sa toSet(), fromVector(), QVector::fromList()
*/
@@ -1761,7 +1761,7 @@ void **QListData::erase(void **xi)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 23
+ \snippet code/src_corelib_tools_qlistdata.cpp 23
\sa fromVector(), toSet(), QSet::toList(), qSort()
*/
@@ -1774,7 +1774,7 @@ void **QListData::erase(void **xi)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 24
+ \snippet code/src_corelib_tools_qlistdata.cpp 24
\sa toVector(), fromSet(), QSet::fromList()
*/
@@ -1786,7 +1786,7 @@ void **QListData::erase(void **xi)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 25
+ \snippet code/src_corelib_tools_qlistdata.cpp 25
\sa toStdList(), QVector::fromStdVector()
*/
@@ -1796,7 +1796,7 @@ void **QListData::erase(void **xi)
Returns a std::list object with the data contained in this QList.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 26
+ \snippet code/src_corelib_tools_qlistdata.cpp 26
\sa fromStdList(), QVector::toStdVector()
*/
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index b9f199e50e..88667f7fbd 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -78,8 +78,8 @@ public:
};
Q_GLOBAL_STATIC(QSystemLocaleSingleton, QSystemLocale_globalSystemLocale)
-static QLocalePrivate *system_lp = 0;
-Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate)
+static QLocaleData *system_data = 0;
+Q_GLOBAL_STATIC(QLocaleData, globalLocaleData)
#endif
#ifdef QT_USE_ICU
@@ -157,12 +157,12 @@ QLocale::Country QLocalePrivate::codeToCountry(const QString &code)
QString QLocalePrivate::languageCode() const
{
- if (m_language_id == QLocale::AnyLanguage)
+ if (m_data->m_language_id == QLocale::AnyLanguage)
return QString();
- if (m_language_id == QLocale::C)
+ if (m_data->m_language_id == QLocale::C)
return QLatin1String("C");
- const unsigned char *c = language_code_list + 3*(uint(m_language_id));
+ const unsigned char *c = language_code_list + 3*(uint(m_data->m_language_id));
QString code(c[2] == 0 ? 2 : 3, Qt::Uninitialized);
@@ -176,18 +176,18 @@ QString QLocalePrivate::languageCode() const
QString QLocalePrivate::scriptCode() const
{
- if (m_script_id == QLocale::AnyScript || m_script_id > QLocale::LastScript)
+ if (m_data->m_script_id == QLocale::AnyScript || m_data->m_script_id > QLocale::LastScript)
return QString();
- const unsigned char *c = script_code_list + 4*(uint(m_script_id));
+ const unsigned char *c = script_code_list + 4*(uint(m_data->m_script_id));
return QString::fromLatin1((const char *)c, 4);
}
QString QLocalePrivate::countryCode() const
{
- if (m_country_id == QLocale::AnyCountry)
+ if (m_data->m_country_id == QLocale::AnyCountry)
return QString();
- const unsigned char *c = country_code_list + 3*(uint(m_country_id));
+ const unsigned char *c = country_code_list + 3*(uint(m_data->m_country_id));
QString code(c[2] == 0 ? 2 : 3, Qt::Uninitialized);
@@ -201,15 +201,15 @@ QString QLocalePrivate::countryCode() const
QString QLocalePrivate::bcp47Name() const
{
- if (m_language_id == QLocale::AnyLanguage)
+ if (m_data->m_language_id == QLocale::AnyLanguage)
return QString();
- if (m_language_id == QLocale::C)
+ if (m_data->m_language_id == QLocale::C)
return QLatin1String("C");
- const unsigned char *lang = language_code_list + 3*(uint(m_language_id));
+ const unsigned char *lang = language_code_list + 3*(uint(m_data->m_language_id));
const unsigned char *script =
- (m_script_id != QLocale::AnyScript ? script_code_list + 4*(uint(m_script_id)) : 0);
+ (m_data->m_script_id != QLocale::AnyScript ? script_code_list + 4*(uint(m_data->m_script_id)) : 0);
const unsigned char *country =
- (m_country_id != QLocale::AnyCountry ? country_code_list + 3*(uint(m_country_id)) : 0);
+ (m_data->m_country_id != QLocale::AnyCountry ? country_code_list + 3*(uint(m_data->m_country_id)) : 0);
char len = (lang[2] != 0 ? 3 : 2) + (script ? 4+1 : 0) + (country ? (country[2] != 0 ? 3 : 2)+1 : 0);
QString name(len, Qt::Uninitialized);
QChar *uc = name.data();
@@ -234,7 +234,7 @@ QString QLocalePrivate::bcp47Name() const
return name;
}
-const QLocalePrivate *QLocalePrivate::findLocale(QLocale::Language language, QLocale::Script script, QLocale::Country country)
+const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script, QLocale::Country country)
{
const unsigned language_id = language;
const unsigned script_id = script;
@@ -242,33 +242,33 @@ const QLocalePrivate *QLocalePrivate::findLocale(QLocale::Language language, QLo
uint idx = locale_index[language_id];
- const QLocalePrivate *d = locale_data + idx;
+ const QLocaleData *data = locale_data + idx;
if (idx == 0) // default language has no associated country
- return d;
+ return data;
if (script == QLocale::AnyScript && country == QLocale::AnyCountry)
- return d;
+ return data;
- Q_ASSERT(d->languageId() == language_id);
+ Q_ASSERT(data->m_language_id == language_id);
if (country == QLocale::AnyCountry) {
- while (d->m_language_id == language_id && d->m_script_id != script_id)
- ++d;
- if (d->m_language_id == language_id && d->m_script_id == script_id)
- return d;
+ while (data->m_language_id == language_id && data->m_script_id != script_id)
+ ++data;
+ if (data->m_language_id == language_id && data->m_script_id == script_id)
+ return data;
} else if (script == QLocale::AnyScript) {
- while (d->m_language_id == language_id) {
- if (d->m_script_id == script_id && d->m_country_id == country_id)
- return d;
- ++d;
+ while (data->m_language_id == language_id) {
+ if (data->m_script_id == script_id && data->m_country_id == country_id)
+ return data;
+ ++data;
}
} else {
// both script and country are explicitly specified
- while (d->m_language_id == language_id) {
- if (d->m_script_id == script_id && d->m_country_id == country_id)
- return d;
- ++d;
+ while (data->m_language_id == language_id) {
+ if (data->m_script_id == script_id && data->m_country_id == country_id)
+ return data;
+ ++data;
}
}
@@ -370,14 +370,14 @@ void QLocalePrivate::getLangAndCountry(const QString &name, QLocale::Language &l
cntry = QLocalePrivate::codeToCountry(cntry_code);
}
-static const QLocalePrivate *findLocale(const QString &name)
+static const QLocaleData *findLocaleData(const QString &name)
{
QLocale::Language lang;
QLocale::Script script;
QLocale::Country cntry;
QLocalePrivate::getLangAndCountry(name, lang, script, cntry);
- return QLocalePrivate::findLocale(lang, script, cntry);
+ return QLocaleData::findLocaleData(lang, script, cntry);
}
QString qt_readEscapedFormatString(const QString &format, int *idx)
@@ -423,7 +423,7 @@ int qt_repeatCount(const QString &s, int i)
return j - i;
}
-static const QLocalePrivate *default_lp = 0;
+static const QLocaleData *default_data = 0;
static uint default_number_options = 0;
#ifndef QT_NO_SYSTEMLOCALE
@@ -443,8 +443,8 @@ QSystemLocale::QSystemLocale()
delete _systemLocale;
_systemLocale = this;
- if (system_lp)
- system_lp->m_language_id = 0;
+ if (system_data)
+ system_data->m_language_id = 0;
}
/*! \internal */
@@ -459,8 +459,8 @@ QSystemLocale::~QSystemLocale()
if (_systemLocale == this) {
_systemLocale = 0;
- if (system_lp)
- system_lp->m_language_id = 0;
+ if (system_data)
+ system_data->m_language_id = 0;
}
}
@@ -474,74 +474,74 @@ static const QSystemLocale *systemLocale()
void QLocalePrivate::updateSystemPrivate()
{
const QSystemLocale *sys_locale = systemLocale();
- if (!system_lp)
- system_lp = globalLocalePrivate();
+ if (!system_data)
+ system_data = globalLocaleData();
// tell the object that the system locale has changed.
sys_locale->query(QSystemLocale::LocaleChanged, QVariant());
- *system_lp = *sys_locale->fallbackLocale().d();
+ *system_data = *sys_locale->fallbackLocale().d->m_data;
QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant());
if (!res.isNull()) {
- system_lp->m_language_id = res.toInt();
- system_lp->m_script_id = QLocale::AnyScript; // default for compatibility
+ system_data->m_language_id = res.toInt();
+ system_data->m_script_id = QLocale::AnyScript; // default for compatibility
}
res = sys_locale->query(QSystemLocale::CountryId, QVariant());
if (!res.isNull()) {
- system_lp->m_country_id = res.toInt();
- system_lp->m_script_id = QLocale::AnyScript; // default for compatibility
+ system_data->m_country_id = res.toInt();
+ system_data->m_script_id = QLocale::AnyScript; // default for compatibility
}
res = sys_locale->query(QSystemLocale::ScriptId, QVariant());
if (!res.isNull())
- system_lp->m_script_id = res.toInt();
+ system_data->m_script_id = res.toInt();
res = sys_locale->query(QSystemLocale::DecimalPoint, QVariant());
if (!res.isNull())
- system_lp->m_decimal = res.toString().at(0).unicode();
+ system_data->m_decimal = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::GroupSeparator, QVariant());
if (!res.isNull())
- system_lp->m_group = res.toString().at(0).unicode();
+ system_data->m_group = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::ZeroDigit, QVariant());
if (!res.isNull())
- system_lp->m_zero = res.toString().at(0).unicode();
+ system_data->m_zero = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::NegativeSign, QVariant());
if (!res.isNull())
- system_lp->m_minus = res.toString().at(0).unicode();
+ system_data->m_minus = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::PositiveSign, QVariant());
if (!res.isNull())
- system_lp->m_plus = res.toString().at(0).unicode();
+ system_data->m_plus = res.toString().at(0).unicode();
#ifdef QT_USE_ICU
- if (!default_lp)
- qt_initIcu(system_lp->bcp47Name());
+ if (!default_data)
+ qt_initIcu(sys_locale->fallbackLocale().bcp47Name());
#endif
}
#endif
-static const QLocalePrivate *systemPrivate()
+static const QLocaleData *systemData()
{
#ifndef QT_NO_SYSTEMLOCALE
// copy over the information from the fallback locale and modify
- if (!system_lp || system_lp->m_language_id == 0)
+ if (!system_data || system_data->m_language_id == 0)
QLocalePrivate::updateSystemPrivate();
- return system_lp;
+ return system_data;
#else
return locale_data;
#endif
}
-static const QLocalePrivate *defaultPrivate()
+static const QLocaleData *defaultData()
{
- if (!default_lp)
- default_lp = systemPrivate();
- return default_lp;
+ if (!default_data)
+ default_data = systemData();
+ return default_data;
}
static QString getLocaleListData(const ushort *data, int size, int index)
@@ -585,14 +585,14 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l)
#endif // QT_NO_DATASTREAM
-static const int locale_data_size = sizeof(locale_data)/sizeof(QLocalePrivate) - 1;
+static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1;
-static const QLocalePrivate *dataPointerHelper(quint16 index)
+static const QLocaleData *dataPointerHelper(quint16 index)
{
#ifndef QT_NO_SYSTEMLOCALE
Q_ASSERT(index <= locale_data_size);
if (index == locale_data_size)
- return system_lp;
+ return system_data;
#else
Q_ASSERT(index < locale_data_size);
#endif
@@ -600,12 +600,12 @@ static const QLocalePrivate *dataPointerHelper(quint16 index)
return &locale_data[index];
}
-static quint16 localePrivateIndex(const QLocalePrivate *p)
+static quint16 localeDataIndex(const QLocaleData *p)
{
#ifndef QT_NO_SYSTEMLOCALE
Q_ASSERT((p >= locale_data && p - locale_data < locale_data_size)
- || (p != 0 && p == system_lp));
- quint16 index = p == system_lp ? locale_data_size : p - locale_data;
+ || (p != 0 && p == system_data));
+ quint16 index = p == system_data ? locale_data_size : p - locale_data;
#else
Q_ASSERT(p >= locale_data && p - locale_data < locale_data_size);
quint16 index = p - locale_data;
@@ -644,10 +644,11 @@ static quint16 localePrivateIndex(const QLocalePrivate *p)
*/
QLocale::QLocale(const QString &name)
- : v(0)
+ : d(new QLocalePrivate())
{
- p.numberOptions = 0;
- p.index = localePrivateIndex(findLocale(name));
+ d->m_numberOptions = 0;
+ d->m_index = localeDataIndex(findLocaleData(name));
+ d->m_data = dataPointerHelper(d->m_index);
}
/*!
@@ -659,10 +660,11 @@ QLocale::QLocale(const QString &name)
*/
QLocale::QLocale()
- : v(0)
+ : d(new QLocalePrivate())
{
- p.numberOptions = default_number_options;
- p.index = localePrivateIndex(defaultPrivate());
+ d->m_numberOptions = default_number_options;
+ d->m_index = localeDataIndex(defaultData());
+ d->m_data = dataPointerHelper(d->m_index);
}
/*!
@@ -681,22 +683,23 @@ QLocale::QLocale()
The language and country that are actually used can be queried
using language() and country().
- \sa setDefault() language() country()
+ \sa setDefault(), language(), country()
*/
QLocale::QLocale(Language language, Country country)
- : v(0)
+ : d(new QLocalePrivate())
{
- const QLocalePrivate *d = QLocalePrivate::findLocale(language, QLocale::AnyScript, country);
+ const QLocaleData *data = QLocaleData::findLocaleData(language, QLocale::AnyScript, country);
// If not found, should default to system
- if (d->languageId() == QLocale::C && language != QLocale::C) {
- p.numberOptions = default_number_options;
- p.index = localePrivateIndex(defaultPrivate());
+ if (data->m_language_id == QLocale::C && language != QLocale::C) {
+ d->m_numberOptions = default_number_options;
+ d->m_index = localeDataIndex(defaultData());
} else {
- p.numberOptions = 0;
- p.index = localePrivateIndex(d);
+ d->m_numberOptions = 0;
+ d->m_index = localeDataIndex(data);
}
+ d->m_data = dataPointerHelper(d->m_index);
}
\
/*!
@@ -720,22 +723,23 @@ QLocale::QLocale(Language language, Country country)
The language, script and country that are actually used can be queried
using language(), script() and country().
- \sa setDefault() language() script() country()
+ \sa setDefault(), language(), script(), country()
*/
QLocale::QLocale(Language language, Script script, Country country)
- : v(0)
+ : d(new QLocalePrivate())
{
- const QLocalePrivate *d = QLocalePrivate::findLocale(language, script, country);
+ const QLocaleData *data = QLocaleData::findLocaleData(language, script, country);
// If not found, should default to system
- if (d->languageId() == QLocale::C && language != QLocale::C) {
- p.numberOptions = default_number_options;
- p.index = localePrivateIndex(defaultPrivate());
+ if (data->m_language_id == QLocale::C && language != QLocale::C) {
+ d->m_numberOptions = default_number_options;
+ d->m_index = localeDataIndex(defaultData());
} else {
- p.numberOptions = 0;
- p.index = localePrivateIndex(d);
+ d->m_numberOptions = 0;
+ d->m_index = localeDataIndex(data);
}
+ d->m_data = dataPointerHelper(d->m_index);
}
/*!
@@ -744,12 +748,15 @@ QLocale::QLocale(Language language, Script script, Country country)
QLocale::QLocale(const QLocale &other)
{
- v = other.v;
+ d = other.d;
}
-const QLocalePrivate *QLocale::d() const
+/*!
+ Destructor
+*/
+
+QLocale::~QLocale()
{
- return dataPointerHelper(p.index);
}
/*!
@@ -759,18 +766,18 @@ const QLocalePrivate *QLocale::d() const
QLocale &QLocale::operator=(const QLocale &other)
{
- v = other.v;
+ d = other.d;
return *this;
}
bool QLocale::operator==(const QLocale &other) const
{
- return d() == other.d() && numberOptions() == other.numberOptions();
+ return d->m_data == other.d->m_data && d->m_numberOptions == other.d->m_numberOptions;
}
bool QLocale::operator!=(const QLocale &other) const
{
- return d() != other.d() || numberOptions() != other.numberOptions();
+ return d->m_data != other.d->m_data || d->m_numberOptions != other.d->m_numberOptions;
}
/*!
@@ -781,7 +788,7 @@ bool QLocale::operator!=(const QLocale &other) const
*/
void QLocale::setNumberOptions(NumberOptions options)
{
- p.numberOptions = options;
+ d->m_numberOptions = options;
}
/*!
@@ -794,7 +801,7 @@ void QLocale::setNumberOptions(NumberOptions options)
*/
QLocale::NumberOptions QLocale::numberOptions() const
{
- return static_cast<NumberOption>(p.numberOptions);
+ return static_cast<NumberOption>(d->m_numberOptions);
}
/*!
@@ -816,7 +823,7 @@ QString QLocale::quoteString(const QString &str, QuotationStyle style) const
QString QLocale::quoteString(const QStringRef &str, QuotationStyle style) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res;
if (style == QLocale::AlternateQuotation)
res = systemLocale()->query(QSystemLocale::StringToAlternateQuotation, QVariant::fromValue(str));
@@ -828,9 +835,9 @@ QString QLocale::quoteString(const QStringRef &str, QuotationStyle style) const
#endif
if (style == QLocale::StandardQuotation)
- return QChar(d()->m_quotation_start) % str % QChar(d()->m_quotation_end);
+ return QChar(d->m_data->m_quotation_start) % str % QChar(d->m_data->m_quotation_end);
else
- return QChar(d()->m_alternate_quotation_start) % str % QChar(d()->m_alternate_quotation_end);
+ return QChar(d->m_data->m_alternate_quotation_start) % str % QChar(d->m_data->m_alternate_quotation_end);
}
/*!
@@ -842,7 +849,7 @@ QString QLocale::quoteString(const QStringRef &str, QuotationStyle style) const
QString QLocale::createSeparatedList(const QStringList &list) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res;
res = systemLocale()->query(QSystemLocale::ListToSeparatedString, QVariant::fromValue(list));
@@ -855,12 +862,12 @@ QString QLocale::createSeparatedList(const QStringList &list) const
if (size == 1) {
return list.at(0);
} else if (size == 2) {
- QString format = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_two_idx, d()->m_list_pattern_part_two_size);
+ QString format = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_two_idx, d->m_data->m_list_pattern_part_two_size);
return format.arg(list.at(0), list.at(1));
} else if (size > 2) {
- QString formatStart = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_start_idx, d()->m_list_pattern_part_start_size);
- QString formatMid = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_mid_idx, d()->m_list_pattern_part_mid_size);
- QString formatEnd = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_end_idx, d()->m_list_pattern_part_end_size);
+ QString formatStart = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_start_idx, d->m_data->m_list_pattern_part_start_size);
+ QString formatMid = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_mid_idx, d->m_data->m_list_pattern_part_mid_size);
+ QString formatEnd = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_end_idx, d->m_data->m_list_pattern_part_end_size);
QString result = formatStart.arg(list.at(0), list.at(1));
for (int i = 2; i < size - 1; ++i)
result = formatMid.arg(result, list.at(i));
@@ -883,12 +890,12 @@ QString QLocale::createSeparatedList(const QStringList &list) const
should be set at application startup, before any non-GUI threads
are created.
- \sa system() c()
+ \sa system(), c()
*/
void QLocale::setDefault(const QLocale &locale)
{
- default_lp = locale.d();
+ default_data = locale.d->m_data;
default_number_options = locale.numberOptions();
#ifdef QT_USE_ICU
@@ -903,7 +910,7 @@ void QLocale::setDefault(const QLocale &locale)
*/
QLocale::Language QLocale::language() const
{
- return Language(d()->languageId());
+ return Language(d->languageId());
}
/*!
@@ -915,7 +922,7 @@ QLocale::Language QLocale::language() const
*/
QLocale::Script QLocale::script() const
{
- return Script(d()->m_script_id);
+ return Script(d->m_data->m_script_id);
}
/*!
@@ -925,7 +932,7 @@ QLocale::Script QLocale::script() const
*/
QLocale::Country QLocale::country() const
{
- return Country(d()->countryId());
+ return Country(d->countryId());
}
/*!
@@ -945,7 +952,7 @@ QString QLocale::name() const
{
Language l = language();
- QString result = d()->languageCode();
+ QString result = d->languageCode();
if (l == C)
return result;
@@ -955,7 +962,7 @@ QString QLocale::name() const
return result;
result.append(QLatin1Char('_'));
- result.append(d()->countryCode());
+ result.append(d->countryCode());
return result;
}
@@ -976,7 +983,7 @@ QString QLocale::name() const
*/
QString QLocale::bcp47Name() const
{
- return d()->bcp47Name();
+ return d->bcp47Name();
}
/*!
@@ -1132,11 +1139,11 @@ uint QLocale::toUInt(const QString &s, bool *ok) const
qlonglong QLocale::toLongLong(const QString &s, bool *ok) const
{
QLocalePrivate::GroupSeparatorMode mode
- = p.numberOptions & RejectGroupSeparator
+ = d->m_numberOptions & RejectGroupSeparator
? QLocalePrivate::FailOnGroupSeparators
: QLocalePrivate::ParseGroupSeparators;
- return d()->stringToLongLong(s, 10, ok, mode);
+ return d->stringToLongLong(s, 10, ok, mode);
}
/*!
@@ -1156,11 +1163,11 @@ qlonglong QLocale::toLongLong(const QString &s, bool *ok) const
qulonglong QLocale::toULongLong(const QString &s, bool *ok) const
{
QLocalePrivate::GroupSeparatorMode mode
- = p.numberOptions & RejectGroupSeparator
+ = d->m_numberOptions & RejectGroupSeparator
? QLocalePrivate::FailOnGroupSeparators
: QLocalePrivate::ParseGroupSeparators;
- return d()->stringToUnsLongLong(s, 10, ok, mode);
+ return d->stringToUnsLongLong(s, 10, ok, mode);
}
/*!
@@ -1202,7 +1209,7 @@ float QLocale::toFloat(const QString &s, bool *ok) const
the "C" locale if the string cannot be interpreted in this
locale.
- \snippet doc/src/snippets/code/src_corelib_tools_qlocale.cpp 3
+ \snippet code/src_corelib_tools_qlocale.cpp 3
Notice that the last conversion returns 1234.0, because '.' is the
thousands group separator in the German locale.
@@ -1215,11 +1222,11 @@ float QLocale::toFloat(const QString &s, bool *ok) const
double QLocale::toDouble(const QString &s, bool *ok) const
{
QLocalePrivate::GroupSeparatorMode mode
- = p.numberOptions & RejectGroupSeparator
+ = d->m_numberOptions & RejectGroupSeparator
? QLocalePrivate::FailOnGroupSeparators
: QLocalePrivate::ParseGroupSeparators;
- return d()->stringToDouble(s, ok, mode);
+ return d->stringToDouble(s, ok, mode);
}
/*!
@@ -1230,11 +1237,11 @@ double QLocale::toDouble(const QString &s, bool *ok) const
QString QLocale::toString(qlonglong i) const
{
- int flags = p.numberOptions & OmitGroupSeparator
+ int flags = d->m_numberOptions & OmitGroupSeparator
? 0
: QLocalePrivate::ThousandsGroup;
- return d()->longLongToString(i, -1, 10, -1, flags);
+ return d->longLongToString(i, -1, 10, -1, flags);
}
/*!
@@ -1245,11 +1252,11 @@ QString QLocale::toString(qlonglong i) const
QString QLocale::toString(qulonglong i) const
{
- int flags = p.numberOptions & OmitGroupSeparator
+ int flags = d->m_numberOptions & OmitGroupSeparator
? 0
: QLocalePrivate::ThousandsGroup;
- return d()->unsLongLongToString(i, -1, 10, -1, flags);
+ return d->unsLongLongToString(i, -1, 10, -1, flags);
}
/*!
@@ -1260,7 +1267,7 @@ QString QLocale::toString(qulonglong i) const
QString QLocale::toString(const QDate &date, const QString &format) const
{
- return d()->dateTimeToString(format, &date, 0, this);
+ return d->dateTimeToString(format, &date, 0, this);
}
/*!
@@ -1274,7 +1281,7 @@ QString QLocale::toString(const QDate &date, FormatType format) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateToStringLong : QSystemLocale::DateToStringShort,
date);
@@ -1338,7 +1345,7 @@ static QString timeZone()
*/
QString QLocale::toString(const QTime &time, const QString &format) const
{
- return d()->dateTimeToString(format, 0, &time, this);
+ return d->dateTimeToString(format, 0, &time, this);
}
/*!
@@ -1353,7 +1360,7 @@ QString QLocale::toString(const QDateTime &dateTime, const QString &format) cons
{
const QDate dt = dateTime.date();
const QTime tm = dateTime.time();
- return d()->dateTimeToString(format, &dt, &tm, this);
+ return d->dateTimeToString(format, &dt, &tm, this);
}
/*!
@@ -1369,7 +1376,7 @@ QString QLocale::toString(const QDateTime &dateTime, FormatType format) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateTimeToStringLong
: QSystemLocale::DateTimeToStringShort,
@@ -1395,7 +1402,7 @@ QString QLocale::toString(const QTime &time, FormatType format) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::TimeToStringLong : QSystemLocale::TimeToStringShort,
time);
@@ -1422,7 +1429,7 @@ QString QLocale::toString(const QTime &time, FormatType format) const
QString QLocale::dateFormat(FormatType format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateFormatLong : QSystemLocale::DateFormatShort,
QVariant());
@@ -1434,12 +1441,12 @@ QString QLocale::dateFormat(FormatType format) const
quint32 idx, size;
switch (format) {
case LongFormat:
- idx = d()->m_long_date_format_idx;
- size = d()->m_long_date_format_size;
+ idx = d->m_data->m_long_date_format_idx;
+ size = d->m_data->m_long_date_format_size;
break;
default:
- idx = d()->m_short_date_format_idx;
- size = d()->m_short_date_format_size;
+ idx = d->m_data->m_short_date_format_idx;
+ size = d->m_data->m_short_date_format_size;
break;
}
return getLocaleData(date_format_data + idx, size);
@@ -1459,7 +1466,7 @@ QString QLocale::dateFormat(FormatType format) const
QString QLocale::timeFormat(FormatType format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::TimeFormatLong : QSystemLocale::TimeFormatShort,
QVariant());
@@ -1471,12 +1478,12 @@ QString QLocale::timeFormat(FormatType format) const
quint32 idx, size;
switch (format) {
case LongFormat:
- idx = d()->m_long_time_format_idx;
- size = d()->m_long_time_format_size;
+ idx = d->m_data->m_long_time_format_idx;
+ size = d->m_data->m_long_time_format_size;
break;
default:
- idx = d()->m_short_time_format_idx;
- size = d()->m_short_time_format_size;
+ idx = d->m_data->m_short_time_format_idx;
+ size = d->m_data->m_short_time_format_size;
break;
}
return getLocaleData(time_format_data + idx, size);
@@ -1496,7 +1503,7 @@ QString QLocale::timeFormat(FormatType format) const
QString QLocale::dateTimeFormat(FormatType format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(format == LongFormat
? QSystemLocale::DateTimeFormatLong
: QSystemLocale::DateTimeFormatShort,
@@ -1664,7 +1671,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format) cons
*/
QChar QLocale::decimalPoint() const
{
- return d()->decimal();
+ return d->decimal();
}
/*!
@@ -1674,7 +1681,7 @@ QChar QLocale::decimalPoint() const
*/
QChar QLocale::groupSeparator() const
{
- return d()->group();
+ return d->group();
}
/*!
@@ -1684,7 +1691,7 @@ QChar QLocale::groupSeparator() const
*/
QChar QLocale::percent() const
{
- return d()->percent();
+ return d->percent();
}
/*!
@@ -1694,7 +1701,7 @@ QChar QLocale::percent() const
*/
QChar QLocale::zeroDigit() const
{
- return d()->zero();
+ return d->zero();
}
/*!
@@ -1704,7 +1711,7 @@ QChar QLocale::zeroDigit() const
*/
QChar QLocale::negativeSign() const
{
- return d()->minus();
+ return d->minus();
}
/*!
@@ -1714,7 +1721,7 @@ QChar QLocale::negativeSign() const
*/
QChar QLocale::positiveSign() const
{
- return d()->plus();
+ return d->plus();
}
/*!
@@ -1724,7 +1731,7 @@ QChar QLocale::positiveSign() const
*/
QChar QLocale::exponential() const
{
- return d()->exponential();
+ return d->exponential();
}
static bool qIsUpper(char c)
@@ -1771,9 +1778,9 @@ QString QLocale::toString(double i, char f, int prec) const
break;
}
- if (!(p.numberOptions & OmitGroupSeparator))
+ if (!(d->m_numberOptions & OmitGroupSeparator))
flags |= QLocalePrivate::ThousandsGroup;
- return d()->doubleToString(i, prec, form, -1, flags);
+ return d->doubleToString(i, prec, form, -1, flags);
}
/*!
@@ -1796,7 +1803,8 @@ QString QLocale::toString(double i, char f, int prec) const
QLocale QLocale::system()
{
QLocale result(C);
- result.p.index = localePrivateIndex(systemPrivate());
+ result.d->m_index = localeDataIndex(systemData());
+ result.d->m_data = dataPointerHelper(result.d->m_index);
return result;
}
@@ -1819,17 +1827,18 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language,
return QList<QLocale>();
QList<QLocale> result;
- const QLocalePrivate *d = locale_data;
+ const QLocaleData *data = locale_data;
if (language == QLocale::AnyLanguage && script == QLocale::AnyScript && country == QLocale::AnyCountry)
result.reserve(locale_data_size);
if (language != QLocale::C)
- d += locale_index[language];
- while ( (d != locale_data + locale_data_size)
- && (language == QLocale::AnyLanguage || d->m_language_id == uint(language))) {
+ data += locale_index[language];
+ while ( (data != locale_data + locale_data_size)
+ && (language == QLocale::AnyLanguage || data->m_language_id == uint(language))) {
QLocale locale(QLocale::C);
- locale.p.index = localePrivateIndex(d);
+ locale.d->m_index = localeDataIndex(data);
+ locale.d->m_data = dataPointerHelper(locale.d->m_index);
result.append(locale);
- ++d;
+ ++data;
}
return result;
}
@@ -1856,11 +1865,11 @@ QList<QLocale::Country> QLocale::countriesForLanguage(Language language)
return result;
}
- const QLocalePrivate *d = locale_data + idx;
+ const QLocaleData *data = locale_data + idx;
- while (d->languageId() == language_id) {
- result << static_cast<Country>(d->countryId());
- ++d;
+ while (data->m_language_id == language_id) {
+ result << static_cast<Country>(data->m_country_id);
+ ++data;
}
return result;
@@ -1880,7 +1889,7 @@ QString QLocale::monthName(int month, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort,
month);
@@ -1892,16 +1901,16 @@ QString QLocale::monthName(int month, FormatType type) const
quint32 idx, size;
switch (type) {
case QLocale::LongFormat:
- idx = d()->m_long_month_names_idx;
- size = d()->m_long_month_names_size;
+ idx = d->m_data->m_long_month_names_idx;
+ size = d->m_data->m_long_month_names_size;
break;
case QLocale::ShortFormat:
- idx = d()->m_short_month_names_idx;
- size = d()->m_short_month_names_size;
+ idx = d->m_data->m_short_month_names_idx;
+ size = d->m_data->m_short_month_names_size;
break;
case QLocale::NarrowFormat:
- idx = d()->m_narrow_month_names_idx;
- size = d()->m_narrow_month_names_size;
+ idx = d->m_data->m_narrow_month_names_idx;
+ size = d->m_data->m_narrow_month_names_size;
break;
default:
return QString();
@@ -1926,7 +1935,7 @@ QString QLocale::standaloneMonthName(int month, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort,
month);
@@ -1938,16 +1947,16 @@ QString QLocale::standaloneMonthName(int month, FormatType type) const
quint32 idx, size;
switch (type) {
case QLocale::LongFormat:
- idx = d()->m_standalone_long_month_names_idx;
- size = d()->m_standalone_long_month_names_size;
+ idx = d->m_data->m_standalone_long_month_names_idx;
+ size = d->m_data->m_standalone_long_month_names_size;
break;
case QLocale::ShortFormat:
- idx = d()->m_standalone_short_month_names_idx;
- size = d()->m_standalone_short_month_names_size;
+ idx = d->m_data->m_standalone_short_month_names_idx;
+ size = d->m_data->m_standalone_short_month_names_size;
break;
case QLocale::NarrowFormat:
- idx = d()->m_standalone_narrow_month_names_idx;
- size = d()->m_standalone_narrow_month_names_size;
+ idx = d->m_data->m_standalone_narrow_month_names_idx;
+ size = d->m_data->m_standalone_narrow_month_names_size;
break;
default:
return QString();
@@ -1973,7 +1982,7 @@ QString QLocale::dayName(int day, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort,
day);
@@ -1987,16 +1996,16 @@ QString QLocale::dayName(int day, FormatType type) const
quint32 idx, size;
switch (type) {
case QLocale::LongFormat:
- idx = d()->m_long_day_names_idx;
- size = d()->m_long_day_names_size;
+ idx = d->m_data->m_long_day_names_idx;
+ size = d->m_data->m_long_day_names_size;
break;
case QLocale::ShortFormat:
- idx = d()->m_short_day_names_idx;
- size = d()->m_short_day_names_size;
+ idx = d->m_data->m_short_day_names_idx;
+ size = d->m_data->m_short_day_names_size;
break;
case QLocale::NarrowFormat:
- idx = d()->m_narrow_day_names_idx;
- size = d()->m_narrow_day_names_size;
+ idx = d->m_data->m_narrow_day_names_idx;
+ size = d->m_data->m_narrow_day_names_size;
break;
default:
return QString();
@@ -2022,7 +2031,7 @@ QString QLocale::standaloneDayName(int day, FormatType type) const
return QString();
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort,
day);
@@ -2036,16 +2045,16 @@ QString QLocale::standaloneDayName(int day, FormatType type) const
quint32 idx, size;
switch (type) {
case QLocale::LongFormat:
- idx = d()->m_standalone_long_day_names_idx;
- size = d()->m_standalone_long_day_names_size;
+ idx = d->m_data->m_standalone_long_day_names_idx;
+ size = d->m_data->m_standalone_long_day_names_size;
break;
case QLocale::ShortFormat:
- idx = d()->m_standalone_short_day_names_idx;
- size = d()->m_standalone_short_day_names_size;
+ idx = d->m_data->m_standalone_short_day_names_idx;
+ size = d->m_data->m_standalone_short_day_names_size;
break;
case QLocale::NarrowFormat:
- idx = d()->m_standalone_narrow_day_names_idx;
- size = d()->m_standalone_narrow_day_names_size;
+ idx = d->m_data->m_standalone_narrow_day_names_idx;
+ size = d->m_data->m_standalone_narrow_day_names_size;
break;
default:
return QString();
@@ -2064,20 +2073,20 @@ QString QLocale::standaloneDayName(int day, FormatType type) const
Qt::DayOfWeek QLocale::firstDayOfWeek() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::FirstDayOfWeek, QVariant());
if (!res.isNull())
return static_cast<Qt::DayOfWeek>(res.toUInt());
}
#endif
- return static_cast<Qt::DayOfWeek>(d()->m_first_day_of_week);
+ return static_cast<Qt::DayOfWeek>(d->m_data->m_first_day_of_week);
}
QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const
{
for (int i = 0; i < ImperialMeasurementSystemsCount; ++i) {
- if (ImperialMeasurementSystems[i].languageId == m_language_id
- && ImperialMeasurementSystems[i].countryId == m_country_id) {
+ if (ImperialMeasurementSystems[i].languageId == m_data->m_language_id
+ && ImperialMeasurementSystems[i].countryId == m_data->m_country_id) {
return ImperialMeasurementSystems[i].system;
}
}
@@ -2092,15 +2101,15 @@ QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const
QList<Qt::DayOfWeek> QLocale::weekdays() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::Weekdays, QVariant());
if (!res.isNull())
return static_cast<QList<Qt::DayOfWeek> >(res.value<QList<Qt::DayOfWeek> >());
}
#endif
QList<Qt::DayOfWeek> weekdays;
- quint16 weekendStart = d()->m_weekend_start;
- quint16 weekendEnd = d()->m_weekend_end;
+ quint16 weekendStart = d->m_data->m_weekend_start;
+ quint16 weekendEnd = d->m_data->m_weekend_end;
for (int day = Qt::Monday; day <= Qt::Sunday; day++) {
if ((weekendEnd >= weekendStart && (day < weekendStart || day > weekendEnd)) ||
(weekendEnd < weekendStart && (day > weekendEnd && day < weekendStart)))
@@ -2117,14 +2126,14 @@ QList<Qt::DayOfWeek> QLocale::weekdays() const
QLocale::MeasurementSystem QLocale::measurementSystem() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::MeasurementSystem, QVariant());
if (!res.isNull())
return MeasurementSystem(res.toInt());
}
#endif
- return d()->measurementSystem();
+ return d->measurementSystem();
}
/*!
@@ -2193,13 +2202,13 @@ QString QLocale::toLower(const QString &str) const
QString QLocale::amText() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::AMText, QVariant());
if (!res.isNull())
return res.toString();
}
#endif
- return getLocaleData(am_data + d()->m_am_idx, d()->m_am_size);
+ return getLocaleData(am_data + d->m_data->m_am_idx, d->m_data->m_am_size);
}
/*!
@@ -2213,13 +2222,13 @@ QString QLocale::amText() const
QString QLocale::pmText() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::PMText, QVariant());
if (!res.isNull())
return res.toString();
}
#endif
- return getLocaleData(pm_data + d()->m_pm_idx, d()->m_pm_size);
+ return getLocaleData(pm_data + d->m_data->m_pm_idx, d->m_data->m_pm_size);
}
@@ -3098,7 +3107,7 @@ qulonglong QLocalePrivate::bytearrayToUnsLongLong(const char *num, int base, boo
QString QLocale::currencySymbol(QLocale::CurrencySymbolFormat format) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::CurrencySymbol, format);
if (!res.isNull())
return res.toString();
@@ -3107,20 +3116,20 @@ QString QLocale::currencySymbol(QLocale::CurrencySymbolFormat format) const
quint32 idx, size;
switch (format) {
case CurrencySymbol:
- idx = d()->m_currency_symbol_idx;
- size = d()->m_currency_symbol_size;
+ idx = d->m_data->m_currency_symbol_idx;
+ size = d->m_data->m_currency_symbol_size;
return getLocaleData(currency_symbol_data + idx, size);
case CurrencyDisplayName:
- idx = d()->m_currency_display_name_idx;
- size = d()->m_currency_display_name_size;
+ idx = d->m_data->m_currency_display_name_idx;
+ size = d->m_data->m_currency_display_name_size;
return getLocaleListData(currency_display_name_data + idx, size, 0);
case CurrencyIsoCode: {
int len = 0;
- const QLocalePrivate *d = this->d();
+ const QLocaleData *data = this->d->m_data;
for (; len < 3; ++len)
- if (!d->m_currency_iso_code[len])
+ if (!data->m_currency_iso_code[len])
break;
- return len ? QString::fromLatin1(d->m_currency_iso_code, len) : QString();
+ return len ? QString::fromLatin1(data->m_currency_iso_code, len) : QString();
}
}
return QString();
@@ -3137,19 +3146,19 @@ QString QLocale::currencySymbol(QLocale::CurrencySymbolFormat format) const
QString QLocale::toCurrencyString(qlonglong value, const QString &symbol) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QSystemLocale::CurrencyToStringArgument arg(value, symbol);
QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
if (!res.isNull())
return res.toString();
}
#endif
- const QLocalePrivate *d = this->d();
- quint8 idx = d->m_currency_format_idx;
- quint8 size = d->m_currency_format_size;
- if (d->m_currency_negative_format_size && value < 0) {
- idx = d->m_currency_negative_format_idx;
- size = d->m_currency_negative_format_size;
+ const QLocalePrivate *d = this->d;
+ quint8 idx = d->m_data->m_currency_format_idx;
+ quint8 size = d->m_data->m_currency_format_size;
+ if (d->m_data->m_currency_negative_format_size && value < 0) {
+ idx = d->m_data->m_currency_negative_format_idx;
+ size = d->m_data->m_currency_negative_format_size;
value = -value;
}
QString str = d->longLongToString(value);
@@ -3167,16 +3176,16 @@ QString QLocale::toCurrencyString(qlonglong value, const QString &symbol) const
QString QLocale::toCurrencyString(qulonglong value, const QString &symbol) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QSystemLocale::CurrencyToStringArgument arg(value, symbol);
QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
if (!res.isNull())
return res.toString();
}
#endif
- const QLocalePrivate *d = this->d();
- quint8 idx = d->m_currency_format_idx;
- quint8 size = d->m_currency_format_size;
+ const QLocaleData *data = this->d->m_data;
+ quint8 idx = data->m_currency_format_idx;
+ quint8 size = data->m_currency_format_size;
QString str = d->unsLongLongToString(value);
QString sym = symbol.isNull() ? currencySymbol() : symbol;
if (sym.isEmpty())
@@ -3192,22 +3201,22 @@ QString QLocale::toCurrencyString(qulonglong value, const QString &symbol) const
QString QLocale::toCurrencyString(double value, const QString &symbol) const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QSystemLocale::CurrencyToStringArgument arg(value, symbol);
QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg));
if (!res.isNull())
return res.toString();
}
#endif
- const QLocalePrivate *d = this->d();
- quint8 idx = d->m_currency_format_idx;
- quint8 size = d->m_currency_format_size;
- if (d->m_currency_negative_format_size && value < 0) {
- idx = d->m_currency_negative_format_idx;
- size = d->m_currency_negative_format_size;
+ const QLocaleData *data = this->d->m_data;
+ quint8 idx = data->m_currency_format_idx;
+ quint8 size = data->m_currency_format_size;
+ if (data->m_currency_negative_format_size && value < 0) {
+ idx = data->m_currency_negative_format_idx;
+ size = data->m_currency_negative_format_size;
value = -value;
}
- QString str = d->doubleToString(value, d->m_currency_digits,
+ QString str = d->doubleToString(value, d->m_data->m_currency_digits,
QLocalePrivate::DFDecimal);
QString sym = symbol.isNull() ? currencySymbol() : symbol;
if (sym.isEmpty())
@@ -3235,7 +3244,7 @@ QString QLocale::toCurrencyString(double value, const QString &symbol) const
QStringList QLocale::uiLanguages() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::UILanguages, QVariant());
if (!res.isNull()) {
QStringList result = res.toStringList();
@@ -3258,13 +3267,13 @@ QStringList QLocale::uiLanguages() const
QString QLocale::nativeLanguageName() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::NativeLanguageName, QVariant());
if (!res.isNull())
return res.toString();
}
#endif
- return getLocaleData(endonyms_data + d()->m_language_endonym_idx, d()->m_language_endonym_size);
+ return getLocaleData(endonyms_data + d->m_data->m_language_endonym_idx, d->m_data->m_language_endonym_size);
}
/*!
@@ -3278,13 +3287,13 @@ QString QLocale::nativeLanguageName() const
QString QLocale::nativeCountryName() const
{
#ifndef QT_NO_SYSTEMLOCALE
- if (d() == systemPrivate()) {
+ if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(QSystemLocale::NativeCountryName, QVariant());
if (!res.isNull())
return res.toString();
}
#endif
- return getLocaleData(endonyms_data + d()->m_country_endonym_idx, d()->m_country_endonym_size);
+ return getLocaleData(endonyms_data + d->m_data->m_country_endonym_idx, d->m_data->m_country_endonym_size);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index bdb5ae026c..a014b6b7b5 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -45,6 +45,7 @@
#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
#include <QtCore/qobjectdefs.h>
+#include <QtCore/qshareddata.h>
QT_BEGIN_HEADER
@@ -59,9 +60,8 @@ class QVariant;
class QTextStream;
class QTextStreamPrivate;
-class QLocale;
+class QLocalePrivate;
-struct QLocalePrivate;
class Q_CORE_EXPORT QLocale
{
Q_GADGET
@@ -590,6 +590,7 @@ public:
QLocale(Language language, Country country = AnyCountry);
QLocale(Language language, Script script, Country country);
QLocale(const QLocale &other);
+ ~QLocale();
QLocale &operator=(const QLocale &other);
@@ -700,20 +701,10 @@ public:
QString quoteString(const QStringRef &str, QuotationStyle style = StandardQuotation) const;
QString createSeparatedList(const QStringList &strl) const;
-//private: // this should be private, but can't be
- struct Data {
- quint16 index;
- quint16 numberOptions;
- };
+
private:
- friend struct QLocalePrivate;
- // ### We now use this field to pack an index into locale_data and NumberOptions.
- // ### Qt 5: change to a QLocaleData *d; uint numberOptions.
- union {
- void *v;
- Data p;
- };
- const QLocalePrivate *d() const;
+ friend class QLocalePrivate;
+ QSharedDataPointer<QLocalePrivate> d;
};
Q_DECLARE_TYPEINFO(QLocale, Q_MOVABLE_TYPE);
Q_DECLARE_OPERATORS_FOR_FLAGS(QLocale::NumberOptions)
diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc
index 32822c2e6e..ed80984de3 100644
--- a/src/corelib/tools/qlocale.qdoc
+++ b/src/corelib/tools/qlocale.qdoc
@@ -42,7 +42,7 @@
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qlocale.cpp 0
+ \snippet code/src_corelib_tools_qlocale.cpp 0
QLocale supports the concept of a default locale, which is
determined from the system's locale settings at application
@@ -63,7 +63,7 @@
The following example illustrates how to use QLocale directly:
- \snippet doc/src/snippets/code/src_corelib_tools_qlocale.cpp 1
+ \snippet code/src_corelib_tools_qlocale.cpp 1
When a language/country pair is specified in the constructor, one
of three things can happen:
@@ -83,7 +83,7 @@
An alternative method for constructing a QLocale object is by
specifying the locale name.
- \snippet doc/src/snippets/code/src_corelib_tools_qlocale.cpp 2
+ \snippet code/src_corelib_tools_qlocale.cpp 2
This constructor converts the locale name to a language/country
pair; it does not use the system locale database.
@@ -662,7 +662,7 @@
will fail if they encounter group separators in their input. The default
is to accept numbers containing correctly placed group separators.
- \sa setNumberOptions() numberOptions()
+ \sa setNumberOptions(), numberOptions()
*/
/*!
diff --git a/src/corelib/tools/qlocale_data_p.h b/src/corelib/tools/qlocale_data_p.h
index aa63bb75ec..ffade8fcda 100644
--- a/src/corelib/tools/qlocale_data_p.h
+++ b/src/corelib/tools/qlocale_data_p.h
@@ -306,7 +306,7 @@ static const quint16 locale_index[] = {
0 // trailing 0
};
-static const QLocalePrivate locale_data[] = {
+static const QLocaleData locale_data[] = {
// lang script terr dec group list prcnt zero minus plus exp quotStart quotEnd altQuotStart altQuotEnd lpStart lpMid lpEnd lpTwo sDtFmt lDtFmt sTmFmt lTmFmt ssMonth slMonth sMonth lMonth sDays lDays am,len pm,len
{ 1, 0, 0, 46, 44, 59, 37, 48, 45, 43, 101, 34, 34, 39, 39, 0,6 , 0,6 , 0,6 , 0,6 , 0,10 , 10,17 , 0,8 , 8,10 , 0,48 , 48,86 , 134,24 , 0,48 , 48,86 , 158,27 , 0,28 , 28,57 , 85,14 , 0,28 , 28,57 , 99,14 , 0,2 , 0,2 , {0,0,0}, 0,0 , 0,7 , 0,4 , 4,0 , 0,0 , 0,0 , 2, 1, 1, 6, 7 }, // C/AnyScript/AnyCountry
{ 3, 0, 69, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 27,8 , 35,18 , 18,7 , 25,12 , 185,48 , 233,111 , 134,24 , 185,48 , 233,111 , 134,24 , 113,28 , 141,55 , 85,14 , 113,28 , 141,55 , 85,14 , 2,2 , 2,2 , {69,84,66}, 0,2 , 7,24 , 4,4 , 4,0 , 0,6 , 6,10 , 2, 1, 6, 6, 7 }, // Afan/AnyScript/Ethiopia
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index 377a60881f..673135587b 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -126,20 +126,71 @@ private:
};
#endif
-struct Q_CORE_EXPORT QLocalePrivate
+struct QLocaleData
{
public:
- QChar decimal() const { return QChar(m_decimal); }
- QChar group() const { return QChar(m_group); }
- QChar list() const { return QChar(m_list); }
- QChar percent() const { return QChar(m_percent); }
- QChar zero() const { return QChar(m_zero); }
- QChar plus() const { return QChar(m_plus); }
- QChar minus() const { return QChar(m_minus); }
- QChar exponential() const { return QChar(m_exponential); }
-
- quint16 languageId() const { return m_language_id; }
- quint16 countryId() const { return m_country_id; }
+ static const QLocaleData *findLocaleData(QLocale::Language language,
+ QLocale::Script script,
+ QLocale::Country country);
+
+ quint16 m_language_id, m_script_id, m_country_id;
+
+ quint16 m_decimal, m_group, m_list, m_percent, m_zero, m_minus, m_plus, m_exponential;
+ quint16 m_quotation_start, m_quotation_end;
+ quint16 m_alternate_quotation_start, m_alternate_quotation_end;
+
+ quint16 m_list_pattern_part_start_idx, m_list_pattern_part_start_size;
+ quint16 m_list_pattern_part_mid_idx, m_list_pattern_part_mid_size;
+ quint16 m_list_pattern_part_end_idx, m_list_pattern_part_end_size;
+ quint16 m_list_pattern_part_two_idx, m_list_pattern_part_two_size;
+ quint16 m_short_date_format_idx, m_short_date_format_size;
+ quint16 m_long_date_format_idx, m_long_date_format_size;
+ quint16 m_short_time_format_idx, m_short_time_format_size;
+ quint16 m_long_time_format_idx, m_long_time_format_size;
+ quint16 m_standalone_short_month_names_idx, m_standalone_short_month_names_size;
+ quint16 m_standalone_long_month_names_idx, m_standalone_long_month_names_size;
+ quint16 m_standalone_narrow_month_names_idx, m_standalone_narrow_month_names_size;
+ quint16 m_short_month_names_idx, m_short_month_names_size;
+ quint16 m_long_month_names_idx, m_long_month_names_size;
+ quint16 m_narrow_month_names_idx, m_narrow_month_names_size;
+ quint16 m_standalone_short_day_names_idx, m_standalone_short_day_names_size;
+ quint16 m_standalone_long_day_names_idx, m_standalone_long_day_names_size;
+ quint16 m_standalone_narrow_day_names_idx, m_standalone_narrow_day_names_size;
+ quint16 m_short_day_names_idx, m_short_day_names_size;
+ quint16 m_long_day_names_idx, m_long_day_names_size;
+ quint16 m_narrow_day_names_idx, m_narrow_day_names_size;
+ quint16 m_am_idx, m_am_size;
+ quint16 m_pm_idx, m_pm_size;
+ char m_currency_iso_code[3];
+ quint16 m_currency_symbol_idx, m_currency_symbol_size;
+ quint16 m_currency_display_name_idx, m_currency_display_name_size;
+ quint8 m_currency_format_idx, m_currency_format_size;
+ quint8 m_currency_negative_format_idx, m_currency_negative_format_size;
+ quint16 m_language_endonym_idx, m_language_endonym_size;
+ quint16 m_country_endonym_idx, m_country_endonym_size;
+ quint16 m_currency_digits : 2;
+ quint16 m_currency_rounding : 3;
+ quint16 m_first_day_of_week : 3;
+ quint16 m_weekend_start : 3;
+ quint16 m_weekend_end : 3;
+};
+
+class Q_CORE_EXPORT QLocalePrivate : public QSharedData
+{
+public:
+ QLocalePrivate() : m_index(0), m_numberOptions(0), m_data(0) {}
+
+ QChar decimal() const { return QChar(m_data->m_decimal); }
+ QChar group() const { return QChar(m_data->m_group); }
+ QChar list() const { return QChar(m_data->m_list); }
+ QChar percent() const { return QChar(m_data->m_percent); }
+ QChar zero() const { return QChar(m_data->m_zero); }
+ QChar plus() const { return QChar(m_data->m_plus); }
+ QChar minus() const { return QChar(m_data->m_minus); }
+ QChar exponential() const { return QChar(m_data->m_exponential); }
+
+ quint16 languageId() const { return m_data->m_language_id; }
+ quint16 countryId() const { return m_data->m_country_id; }
QString bcp47Name() const;
@@ -152,10 +203,6 @@ public:
static QLocale::Country codeToCountry(const QString &code);
static void getLangAndCountry(const QString &name, QLocale::Language &lang,
QLocale::Script &script, QLocale::Country &cntry);
- static const QLocalePrivate *findLocale(QLocale::Language language,
- QLocale::Script script,
- QLocale::Country country);
-
QLocale::MeasurementSystem measurementSystem() const;
@@ -238,48 +285,11 @@ public:
QString dateTimeToString(const QString &format, const QDate *date, const QTime *time,
const QLocale *q) const;
- quint16 m_language_id, m_script_id, m_country_id;
-
- quint16 m_decimal, m_group, m_list, m_percent,
- m_zero, m_minus, m_plus, m_exponential;
- quint16 m_quotation_start, m_quotation_end;
- quint16 m_alternate_quotation_start, m_alternate_quotation_end;
-
- quint16 m_list_pattern_part_start_idx, m_list_pattern_part_start_size;
- quint16 m_list_pattern_part_mid_idx, m_list_pattern_part_mid_size;
- quint16 m_list_pattern_part_end_idx, m_list_pattern_part_end_size;
- quint16 m_list_pattern_part_two_idx, m_list_pattern_part_two_size;
- quint16 m_short_date_format_idx, m_short_date_format_size;
- quint16 m_long_date_format_idx, m_long_date_format_size;
- quint16 m_short_time_format_idx, m_short_time_format_size;
- quint16 m_long_time_format_idx, m_long_time_format_size;
- quint16 m_standalone_short_month_names_idx, m_standalone_short_month_names_size;
- quint16 m_standalone_long_month_names_idx, m_standalone_long_month_names_size;
- quint16 m_standalone_narrow_month_names_idx, m_standalone_narrow_month_names_size;
- quint16 m_short_month_names_idx, m_short_month_names_size;
- quint16 m_long_month_names_idx, m_long_month_names_size;
- quint16 m_narrow_month_names_idx, m_narrow_month_names_size;
- quint16 m_standalone_short_day_names_idx, m_standalone_short_day_names_size;
- quint16 m_standalone_long_day_names_idx, m_standalone_long_day_names_size;
- quint16 m_standalone_narrow_day_names_idx, m_standalone_narrow_day_names_size;
- quint16 m_short_day_names_idx, m_short_day_names_size;
- quint16 m_long_day_names_idx, m_long_day_names_size;
- quint16 m_narrow_day_names_idx, m_narrow_day_names_size;
- quint16 m_am_idx, m_am_size;
- quint16 m_pm_idx, m_pm_size;
- char m_currency_iso_code[3];
- quint16 m_currency_symbol_idx, m_currency_symbol_size;
- quint16 m_currency_display_name_idx, m_currency_display_name_size;
- quint8 m_currency_format_idx, m_currency_format_size;
- quint8 m_currency_negative_format_idx, m_currency_negative_format_size;
- quint16 m_language_endonym_idx, m_language_endonym_size;
- quint16 m_country_endonym_idx, m_country_endonym_size;
- quint16 m_currency_digits : 2;
- quint16 m_currency_rounding : 3;
- quint16 m_first_day_of_week : 3;
- quint16 m_weekend_start : 3;
- quint16 m_weekend_end : 3;
-
+private:
+ friend class QLocale;
+ quint16 m_index;
+ quint16 m_numberOptions;
+ const QLocaleData *m_data;
};
inline char QLocalePrivate::digitToCLocale(QChar in) const
diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp
index e88c511ae9..5f7a9da95d 100644
--- a/src/corelib/tools/qlocale_unix.cpp
+++ b/src/corelib/tools/qlocale_unix.cpp
@@ -244,6 +244,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
return lc_messages.createSeparatedList(in.value<QStringList>());
case LocaleChanged:
Q_ASSERT(false);
+ case LanguageId:
+ return lc_messages.language();
default:
break;
}
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 90521d343c..8002e7c1f0 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -388,21 +388,21 @@ void QMapDataBase::freeData(QMapDataBase *d)
\endlist
Here's an example QMap with QString keys and \c int values:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 0
+ \snippet code/src_corelib_tools_qmap.cpp 0
To insert a (key, value) pair into the map, you can use operator[]():
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 1
+ \snippet code/src_corelib_tools_qmap.cpp 1
This inserts the following three (key, value) pairs into the
QMap: ("one", 1), ("three", 3), and ("seven", 7). Another way to
insert items into the map is to use insert():
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 2
+ \snippet code/src_corelib_tools_qmap.cpp 2
To look up a value, use operator[]() or value():
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 3
+ \snippet code/src_corelib_tools_qmap.cpp 3
If there is no item with the specified key in the map, these
functions return a \l{default-constructed value}.
@@ -410,12 +410,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
If you want to check whether the map contains a certain key, use
contains():
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 4
+ \snippet code/src_corelib_tools_qmap.cpp 4
There is also a value() overload that uses its second argument as
a default value if there is no item with the specified key:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 5
+ \snippet code/src_corelib_tools_qmap.cpp 5
In general, we recommend that you use contains() and value()
rather than operator[]() for looking up a key in a map. The
@@ -424,7 +424,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
const). For example, the following code snippet will create 1000
items in memory:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 6
+ \snippet code/src_corelib_tools_qmap.cpp 6
To avoid this problem, replace \c map[i] with \c map.value(i)
in the code above.
@@ -436,11 +436,11 @@ void QMapDataBase::freeData(QMapDataBase *d)
QMap::iterator). Here's how to iterate over a QMap<QString, int>
using a Java-style iterator:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 7
+ \snippet code/src_corelib_tools_qmap.cpp 7
Here's the same code, but using an STL-style iterator this time:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 8
+ \snippet code/src_corelib_tools_qmap.cpp 8
The items are traversed in ascending key order.
@@ -448,7 +448,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
insert() with a key that already exists in the QMap, the
previous value will be erased. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 9
+ \snippet code/src_corelib_tools_qmap.cpp 9
However, you can store multiple values per key by using
insertMulti() instead of insert() (or using the convenience
@@ -456,19 +456,19 @@ void QMapDataBase::freeData(QMapDataBase *d)
single key, you can use values(const Key &key), which returns a
QList<T>:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 10
+ \snippet code/src_corelib_tools_qmap.cpp 10
The items that share the same key are available from most
recently to least recently inserted. Another approach is to call
find() to get the STL-style iterator for the first item with a
key and iterate from there:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 11
+ \snippet code/src_corelib_tools_qmap.cpp 11
If you only need to extract the values from a map (not the keys),
you can also use \l{foreach}:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 12
+ \snippet code/src_corelib_tools_qmap.cpp 12
Items can be removed from the map in several ways. One way is to
call remove(); this will remove any item with the given key.
@@ -484,7 +484,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
< y} nor \c{y < x} is true.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 13
+ \snippet code/src_corelib_tools_qmap.cpp 13
In the example, we start by comparing the employees' names. If
they're equal, we compare their dates of birth to break the tie.
@@ -881,7 +881,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
the iterator. For example, here's some code that iterates over all
the items with the same key:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 14
+ \snippet code/src_corelib_tools_qmap.cpp 14
\sa constFind(), value(), values(), lowerBound(), upperBound(), QMultiMap::find()
*/
@@ -911,7 +911,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
key.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 15
+ \snippet code/src_corelib_tools_qmap.cpp 15
If the map contains multiple items with key \a key, this
function returns an iterator that points to the most recently
@@ -919,7 +919,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
the iterator. For example, here's some code that iterates over all
the items with the same key:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 16
+ \snippet code/src_corelib_tools_qmap.cpp 16
\sa qLowerBound(), upperBound(), find()
*/
@@ -937,7 +937,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
nearest item with a greater key.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 17
+ \snippet code/src_corelib_tools_qmap.cpp 17
\sa qUpperBound(), lowerBound(), find()
*/
@@ -1042,7 +1042,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
start iterating. Here's a typical loop that prints all the (key,
value) pairs stored in a map:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 18
+ \snippet code/src_corelib_tools_qmap.cpp 18
Unlike QHash, which stores its items in an arbitrary order, QMap
stores its items ordered by key. Items that share the same key
@@ -1055,22 +1055,22 @@ void QMapDataBase::freeData(QMapDataBase *d)
Here's an example that increments every value stored in the QMap
by 2:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 19
+ \snippet code/src_corelib_tools_qmap.cpp 19
Here's an example that removes all the items whose key is a
string that starts with an underscore character:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 20
+ \snippet code/src_corelib_tools_qmap.cpp 20
The call to QMap::erase() removes the item pointed to by the
iterator from the map, and returns an iterator to the next item.
Here's another way of removing an item while iterating:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 21
+ \snippet code/src_corelib_tools_qmap.cpp 21
It might be tempting to write code like this:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 22
+ \snippet code/src_corelib_tools_qmap.cpp 22
However, this will potentially crash in \c{++i}, because \c i is
a dangling iterator after the call to erase().
@@ -1122,7 +1122,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
called on an uninitialized iterator. Use operator=() to assign a
value to it before using it.
- \sa QMap::begin() QMap::end()
+ \sa QMap::begin(), QMap::end()
*/
/*! \fn QMap::iterator::iterator(QMapData::Node *node)
@@ -1148,7 +1148,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
You can change the value of an item by using value() on
the left side of an assignment, for example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 23
+ \snippet code/src_corelib_tools_qmap.cpp 23
\sa key(), operator*()
*/
@@ -1289,7 +1289,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
QMap::find() before you can start iterating. Here's a typical
loop that prints all the (key, value) pairs stored in a map:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 24
+ \snippet code/src_corelib_tools_qmap.cpp 24
Unlike QHash, which stores its items in an arbitrary order, QMap
stores its items ordered by key. Items that share the same key
@@ -1344,7 +1344,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
called on an uninitialized iterator. Use operator=() to assign a
value to it before using it.
- \sa QMap::constBegin() QMap::constEnd()
+ \sa QMap::constBegin(), QMap::constEnd()
*/
/*! \fn QMap::const_iterator::const_iterator(QMapData::Node *node)
@@ -1530,7 +1530,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
operator+=().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 25
+ \snippet code/src_corelib_tools_qmap.cpp 25
Unlike QMap, QMultiMap provides no operator[]. Use value() or
replace() if you want to access the most recently inserted item
@@ -1539,7 +1539,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
If you want to retrieve all the values for a single key, you can
use values(const Key &key), which returns a QList<T>:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 26
+ \snippet code/src_corelib_tools_qmap.cpp 26
The items that share the same key are available from most
recently to least recently inserted.
@@ -1548,7 +1548,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
the iterator for the first item with a key and iterate from
there:
- \snippet doc/src/snippets/code/src_corelib_tools_qmap.cpp 27
+ \snippet code/src_corelib_tools_qmap.cpp 27
QMultiMap's key and value data types must be \l{assignable data
types}. This covers most data types you are likely to encounter,
diff --git a/src/corelib/tools/qpair.qdoc b/src/corelib/tools/qpair.qdoc
index fdf1eafc23..ddaf82497e 100644
--- a/src/corelib/tools/qpair.qdoc
+++ b/src/corelib/tools/qpair.qdoc
@@ -40,12 +40,12 @@
Here's an example of a QPair that stores one QString and one \c
double value:
- \snippet doc/src/snippets/code/doc_src_qpair.cpp 0
+ \snippet code/doc_src_qpair.cpp 0
The components are accessible as public data members called \l
first and \l second. For example:
- \snippet doc/src/snippets/code/doc_src_qpair.cpp 1
+ \snippet code/doc_src_qpair.cpp 1
QPair's template data types (T1 and T2) must be \l{assignable
data types}. You cannot, for example, store a QWidget as a value;
@@ -95,12 +95,6 @@
\sa qMakePair()
*/
-/*!
- \fn QPair<T1, T2> &QPair::operator=(const QPair<T1, T2> &other)
-
- Assigns \a other to this pair.
-*/
-
/*! \fn bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
\relates QPair
@@ -186,7 +180,7 @@
Returns a QPair\<T1, T2\> that contains \a value1 and \a value2.
Example:
- \snippet doc/src/snippets/code/doc_src_qpair.cpp 2
+ \snippet code/doc_src_qpair.cpp 2
This is equivalent to QPair<T1, T2>(\a value1, \a value2), but
usually requires less typing.
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp
index ecbe9deb9f..edc103f0b2 100644
--- a/src/corelib/tools/qpoint.cpp
+++ b/src/corelib/tools/qpoint.cpp
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
Given a point \e p, the following statements are all equivalent:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 0
+ \snippet code/src_corelib_tools_qpoint.cpp 0
A QPoint object can also be used as a vector: Addition and
subtraction are defined as for vectors (each component is added
@@ -126,7 +126,7 @@ QT_BEGIN_NAMESPACE
Sets the x coordinate of this point to the given \a x coordinate.
- \sa x() setY()
+ \sa x(), setY()
*/
/*!
@@ -134,7 +134,7 @@ QT_BEGIN_NAMESPACE
Sets the y coordinate of this point to the given \a y coordinate.
- \sa y() setX()
+ \sa y(), setX()
*/
@@ -145,9 +145,9 @@ QT_BEGIN_NAMESPACE
Using a reference makes it possible to directly manipulate x. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 1
+ \snippet code/src_corelib_tools_qpoint.cpp 1
- \sa x() setX()
+ \sa x(), setX()
*/
/*!
@@ -158,7 +158,7 @@ QT_BEGIN_NAMESPACE
Using a reference makes it possible to directly manipulate y. For
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 2
+ \snippet code/src_corelib_tools_qpoint.cpp 2
\sa y(), setY()
*/
@@ -170,7 +170,7 @@ QT_BEGIN_NAMESPACE
Adds the given \a point to this point and returns a reference to
this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 3
+ \snippet code/src_corelib_tools_qpoint.cpp 3
\sa operator-=()
*/
@@ -181,7 +181,7 @@ QT_BEGIN_NAMESPACE
Subtracts the given \a point from this point and returns a
reference to this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 4
+ \snippet code/src_corelib_tools_qpoint.cpp 4
\sa operator+=()
*/
@@ -204,7 +204,7 @@ QT_BEGIN_NAMESPACE
Multiplies this point's coordinates by the given \a factor, and
returns a reference to this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 5
+ \snippet code/src_corelib_tools_qpoint.cpp 5
Note that the result is rounded to the nearest integer as points are held as
integers. Use QPointF for floating point accuracy.
@@ -331,7 +331,7 @@ QT_BEGIN_NAMESPACE
Divides both x and y by the given \a divisor, and returns a reference to this
point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 6
+ \snippet code/src_corelib_tools_qpoint.cpp 6
Note that the result is rounded to the nearest integer as points are held as
integers. Use QPointF for floating point accuracy.
@@ -408,12 +408,12 @@ QDataStream &operator>>(QDataStream &s, QPoint &p)
traditionally known as the "Manhattan length" of the vector from
the origin to the point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 7
+ \snippet code/src_corelib_tools_qpoint.cpp 7
This is a useful, and quick to calculate, approximation to the
true length:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 8
+ \snippet code/src_corelib_tools_qpoint.cpp 8
The tradition of "Manhattan length" arises because such distances
apply to travelers who can only travel on a rectangular grid, like
@@ -451,7 +451,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Given a point \e p, the following statements are all equivalent:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 9
+ \snippet code/src_corelib_tools_qpoint.cpp 9
A QPointF object can also be used as a vector: Addition and
subtraction are defined as for vectors (each component is added
@@ -534,7 +534,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Sets the x coordinate of this point to the given \a x coordinate.
- \sa x() setY()
+ \sa x(), setY()
*/
/*!
@@ -552,7 +552,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Using a reference makes it possible to directly manipulate x. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 10
+ \snippet code/src_corelib_tools_qpoint.cpp 10
\sa x(), setX()
*/
@@ -564,9 +564,9 @@ QDebug operator<<(QDebug d, const QPointF &p)
Using a reference makes it possible to directly manipulate y. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 11
+ \snippet code/src_corelib_tools_qpoint.cpp 11
- \sa y() setY()
+ \sa y(), setY()
*/
/*!
@@ -575,7 +575,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Adds the given \a point to this point and returns a reference to
this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 12
+ \snippet code/src_corelib_tools_qpoint.cpp 12
\sa operator-=()
*/
@@ -586,7 +586,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Subtracts the given \a point from this point and returns a reference
to this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 13
+ \snippet code/src_corelib_tools_qpoint.cpp 13
\sa operator+=()
*/
@@ -597,7 +597,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Multiplies this point's coordinates by the given \a factor, and
returns a reference to this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 14
+ \snippet code/src_corelib_tools_qpoint.cpp 14
\sa operator/=()
*/
@@ -608,7 +608,7 @@ QDebug operator<<(QDebug d, const QPointF &p)
Divides both x and y by the given \a divisor, and returns a reference
to this point. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qpoint.cpp 15
+ \snippet code/src_corelib_tools_qpoint.cpp 15
\sa operator*=()
*/
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index 0eb22807e8..3b986cd81e 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -55,26 +55,26 @@ public:
Q_DECL_CONSTEXPR QPoint();
Q_DECL_CONSTEXPR QPoint(int xpos, int ypos);
- Q_DECL_CONSTEXPR bool isNull() const;
+ Q_DECL_CONSTEXPR inline bool isNull() const;
- Q_DECL_CONSTEXPR int x() const;
- Q_DECL_CONSTEXPR int y() const;
- void setX(int x);
- void setY(int y);
+ Q_DECL_CONSTEXPR inline int x() const;
+ Q_DECL_CONSTEXPR inline int y() const;
+ inline void setX(int x);
+ inline void setY(int y);
- Q_DECL_CONSTEXPR int manhattanLength() const;
+ Q_DECL_CONSTEXPR inline int manhattanLength() const;
- int &rx();
- int &ry();
+ inline int &rx();
+ inline int &ry();
- QPoint &operator+=(const QPoint &p);
- QPoint &operator-=(const QPoint &p);
+ inline QPoint &operator+=(const QPoint &p);
+ inline QPoint &operator-=(const QPoint &p);
- QPoint &operator*=(float c);
- QPoint &operator*=(double c);
- QPoint &operator*=(int c);
+ inline QPoint &operator*=(float c);
+ inline QPoint &operator*=(double c);
+ inline QPoint &operator*=(int c);
- QPoint &operator/=(qreal c);
+ inline QPoint &operator/=(qreal c);
friend Q_DECL_CONSTEXPR inline bool operator==(const QPoint &, const QPoint &);
friend Q_DECL_CONSTEXPR inline bool operator!=(const QPoint &, const QPoint &);
@@ -212,22 +212,22 @@ public:
Q_DECL_CONSTEXPR QPointF(const QPoint &p);
Q_DECL_CONSTEXPR QPointF(qreal xpos, qreal ypos);
- Q_DECL_CONSTEXPR qreal manhattanLength() const;
+ Q_DECL_CONSTEXPR inline qreal manhattanLength() const;
- bool isNull() const;
+ inline bool isNull() const;
- Q_DECL_CONSTEXPR qreal x() const;
- Q_DECL_CONSTEXPR qreal y() const;
- void setX(qreal x);
- void setY(qreal y);
+ Q_DECL_CONSTEXPR inline qreal x() const;
+ Q_DECL_CONSTEXPR inline qreal y() const;
+ inline void setX(qreal x);
+ inline void setY(qreal y);
- qreal &rx();
- qreal &ry();
+ inline qreal &rx();
+ inline qreal &ry();
- QPointF &operator+=(const QPointF &p);
- QPointF &operator-=(const QPointF &p);
- QPointF &operator*=(qreal c);
- QPointF &operator/=(qreal c);
+ inline QPointF &operator+=(const QPointF &p);
+ inline QPointF &operator-=(const QPointF &p);
+ inline QPointF &operator*=(qreal c);
+ inline QPointF &operator/=(qreal c);
friend Q_DECL_CONSTEXPR inline bool operator==(const QPointF &, const QPointF &);
friend Q_DECL_CONSTEXPR inline bool operator!=(const QPointF &, const QPointF &);
diff --git a/src/corelib/tools/qqueue.cpp b/src/corelib/tools/qqueue.cpp
index 06d996a542..c5aa4c6bad 100644
--- a/src/corelib/tools/qqueue.cpp
+++ b/src/corelib/tools/qqueue.cpp
@@ -57,7 +57,7 @@
the head item without removing it.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qqueue.cpp 0
+ \snippet code/src_corelib_tools_qqueue.cpp 0
The example will output 1, 2, 3 in that order.
diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp
index aeab97803d..8c1eea8df7 100644
--- a/src/corelib/tools/qrect.cpp
+++ b/src/corelib/tools/qrect.cpp
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
height integers, or from a QPoint and a QSize. The following code
creates two identical rectangles.
- \snippet doc/src/snippets/code/src_corelib_tools_qrect.cpp 0
+ \snippet code/src_corelib_tools_qrect.cpp 0
There is a third constructor that creates a QRect using the
top-left and bottom-right coordinates, but we recommend that you
@@ -640,16 +640,6 @@ QRect QRect::normalized() const
\sa center()
*/
-void QRect::moveCenter(const QPoint &p)
-{
- int w = x2 - x1;
- int h = y2 - y1;
- x1 = p.x() - w/2;
- y1 = p.y() - h/2;
- x2 = x1 + w;
- y2 = y1 + h;
-}
-
/*!
\fn void QRect::moveTo(int x, int y)
@@ -1243,7 +1233,7 @@ QDebug operator<<(QDebug dbg, const QRect &r) {
height integers, or from a QPoint and a QSize. The following code
creates two identical rectangles.
- \snippet doc/src/snippets/code/src_corelib_tools_qrect.cpp 1
+ \snippet code/src_corelib_tools_qrect.cpp 1
There is also a third constructor creating a QRectF from a QRect,
and a corresponding toRect() function that returns a QRect object
@@ -1791,7 +1781,7 @@ QRectF QRectF::normalized() const
\a y1), and the coordinates of its bottom-right corner to (\a x2,
\a y2).
- \sa getCoords() setRect()
+ \sa getCoords(), setRect()
*/
/*!
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index 4bf10061ab..ff318dbe6f 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -62,81 +62,81 @@ public:
Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QSize &size);
Q_DECL_CONSTEXPR QRect(int left, int top, int width, int height);
- Q_DECL_CONSTEXPR bool isNull() const;
- Q_DECL_CONSTEXPR bool isEmpty() const;
- Q_DECL_CONSTEXPR bool isValid() const;
-
- Q_DECL_CONSTEXPR int left() const;
- Q_DECL_CONSTEXPR int top() const;
- Q_DECL_CONSTEXPR int right() const;
- Q_DECL_CONSTEXPR int bottom() const;
+ Q_DECL_CONSTEXPR inline bool isNull() const;
+ Q_DECL_CONSTEXPR inline bool isEmpty() const;
+ Q_DECL_CONSTEXPR inline bool isValid() const;
+
+ Q_DECL_CONSTEXPR inline int left() const;
+ Q_DECL_CONSTEXPR inline int top() const;
+ Q_DECL_CONSTEXPR inline int right() const;
+ Q_DECL_CONSTEXPR inline int bottom() const;
QRect normalized() const;
- Q_DECL_CONSTEXPR int x() const;
- Q_DECL_CONSTEXPR int y() const;
- void setLeft(int pos);
- void setTop(int pos);
- void setRight(int pos);
- void setBottom(int pos);
- void setX(int x);
- void setY(int y);
-
- void setTopLeft(const QPoint &p);
- void setBottomRight(const QPoint &p);
- void setTopRight(const QPoint &p);
- void setBottomLeft(const QPoint &p);
-
- Q_DECL_CONSTEXPR QPoint topLeft() const;
- Q_DECL_CONSTEXPR QPoint bottomRight() const;
- Q_DECL_CONSTEXPR QPoint topRight() const;
- Q_DECL_CONSTEXPR QPoint bottomLeft() const;
- Q_DECL_CONSTEXPR QPoint center() const;
-
- void moveLeft(int pos);
- void moveTop(int pos);
- void moveRight(int pos);
- void moveBottom(int pos);
- void moveTopLeft(const QPoint &p);
- void moveBottomRight(const QPoint &p);
- void moveTopRight(const QPoint &p);
- void moveBottomLeft(const QPoint &p);
- void moveCenter(const QPoint &p);
+ Q_DECL_CONSTEXPR inline int x() const;
+ Q_DECL_CONSTEXPR inline int y() const;
+ inline void setLeft(int pos);
+ inline void setTop(int pos);
+ inline void setRight(int pos);
+ inline void setBottom(int pos);
+ inline void setX(int x);
+ inline void setY(int y);
+
+ inline void setTopLeft(const QPoint &p);
+ inline void setBottomRight(const QPoint &p);
+ inline void setTopRight(const QPoint &p);
+ inline void setBottomLeft(const QPoint &p);
+
+ Q_DECL_CONSTEXPR inline QPoint topLeft() const;
+ Q_DECL_CONSTEXPR inline QPoint bottomRight() const;
+ Q_DECL_CONSTEXPR inline QPoint topRight() const;
+ Q_DECL_CONSTEXPR inline QPoint bottomLeft() const;
+ Q_DECL_CONSTEXPR inline QPoint center() const;
+
+ inline void moveLeft(int pos);
+ inline void moveTop(int pos);
+ inline void moveRight(int pos);
+ inline void moveBottom(int pos);
+ inline void moveTopLeft(const QPoint &p);
+ inline void moveBottomRight(const QPoint &p);
+ inline void moveTopRight(const QPoint &p);
+ inline void moveBottomLeft(const QPoint &p);
+ inline void moveCenter(const QPoint &p);
inline void translate(int dx, int dy);
inline void translate(const QPoint &p);
Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const;
Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const;
- void moveTo(int x, int t);
- void moveTo(const QPoint &p);
+ inline void moveTo(int x, int t);
+ inline void moveTo(const QPoint &p);
- void setRect(int x, int y, int w, int h);
+ inline void setRect(int x, int y, int w, int h);
inline void getRect(int *x, int *y, int *w, int *h) const;
- void setCoords(int x1, int y1, int x2, int y2);
+ inline void setCoords(int x1, int y1, int x2, int y2);
inline void getCoords(int *x1, int *y1, int *x2, int *y2) const;
inline void adjust(int x1, int y1, int x2, int y2);
Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const;
- Q_DECL_CONSTEXPR QSize size() const;
- Q_DECL_CONSTEXPR int width() const;
- Q_DECL_CONSTEXPR int height() const;
- void setWidth(int w);
- void setHeight(int h);
- void setSize(const QSize &s);
+ Q_DECL_CONSTEXPR inline QSize size() const;
+ Q_DECL_CONSTEXPR inline int width() const;
+ Q_DECL_CONSTEXPR inline int height() const;
+ inline void setWidth(int w);
+ inline void setHeight(int h);
+ inline void setSize(const QSize &s);
QRect operator|(const QRect &r) const;
QRect operator&(const QRect &r) const;
- QRect& operator|=(const QRect &r);
- QRect& operator&=(const QRect &r);
+ inline QRect& operator|=(const QRect &r);
+ inline QRect& operator&=(const QRect &r);
- bool contains(const QPoint &p, bool proper=false) const;
- bool contains(int x, int y) const; // inline methods, _don't_ merge these
- bool contains(int x, int y, bool proper) const;
bool contains(const QRect &r, bool proper = false) const;
- QRect united(const QRect &other) const;
- QRect intersected(const QRect &other) const;
+ bool contains(const QPoint &p, bool proper=false) const;
+ inline bool contains(int x, int y) const;
+ inline bool contains(int x, int y, bool proper) const;
+ inline QRect united(const QRect &other) const;
+ inline QRect intersected(const QRect &other) const;
bool intersects(const QRect &r) const;
#if QT_DEPRECATED_SINCE(5, 0)
@@ -144,8 +144,8 @@ public:
QT_DEPRECATED QRect intersect(const QRect &r) const { return intersected(r); }
#endif
- friend Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator==(const QRect &, const QRect &);
- friend Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator!=(const QRect &, const QRect &);
+ friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &);
+ friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &);
private:
int x1;
@@ -155,8 +155,8 @@ private:
};
Q_DECLARE_TYPEINFO(QRect, Q_MOVABLE_TYPE);
-Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator==(const QRect &, const QRect &);
-Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator!=(const QRect &, const QRect &);
+Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &);
+Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &);
/*****************************************************************************
@@ -341,6 +341,16 @@ inline void QRect::moveBottomLeft(const QPoint &p)
moveBottom(p.y());
}
+inline void QRect::moveCenter(const QPoint &p)
+{
+ int w = x2 - x1;
+ int h = y2 - y1;
+ x1 = p.x() - w/2;
+ y1 = p.y() - h/2;
+ x2 = x1 + w;
+ y2 = y1 + h;
+}
+
inline void QRect::getRect(int *ax, int *ay, int *aw, int *ah) const
{
*ax = x1;
@@ -452,9 +462,9 @@ public:
Q_DECL_CONSTEXPR QRectF(qreal left, qreal top, qreal width, qreal height);
Q_DECL_CONSTEXPR QRectF(const QRect &rect);
- Q_DECL_CONSTEXPR bool isNull() const;
- Q_DECL_CONSTEXPR bool isEmpty() const;
- Q_DECL_CONSTEXPR bool isValid() const;
+ Q_DECL_CONSTEXPR inline bool isNull() const;
+ Q_DECL_CONSTEXPR inline bool isEmpty() const;
+ Q_DECL_CONSTEXPR inline bool isValid() const;
QRectF normalized() const;
Q_DECL_CONSTEXPR inline qreal left() const { return xp; }
@@ -477,56 +487,56 @@ public:
Q_DECL_CONSTEXPR inline QPointF bottomLeft() const { return QPointF(xp, yp+h); }
Q_DECL_CONSTEXPR inline QPointF center() const;
- void setTopLeft(const QPointF &p);
- void setBottomRight(const QPointF &p);
- void setTopRight(const QPointF &p);
- void setBottomLeft(const QPointF &p);
+ inline void setTopLeft(const QPointF &p);
+ inline void setBottomRight(const QPointF &p);
+ inline void setTopRight(const QPointF &p);
+ inline void setBottomLeft(const QPointF &p);
- void moveLeft(qreal pos);
- void moveTop(qreal pos);
- void moveRight(qreal pos);
- void moveBottom(qreal pos);
- void moveTopLeft(const QPointF &p);
- void moveBottomRight(const QPointF &p);
- void moveTopRight(const QPointF &p);
- void moveBottomLeft(const QPointF &p);
- void moveCenter(const QPointF &p);
+ inline void moveLeft(qreal pos);
+ inline void moveTop(qreal pos);
+ inline void moveRight(qreal pos);
+ inline void moveBottom(qreal pos);
+ inline void moveTopLeft(const QPointF &p);
+ inline void moveBottomRight(const QPointF &p);
+ inline void moveTopRight(const QPointF &p);
+ inline void moveBottomLeft(const QPointF &p);
+ inline void moveCenter(const QPointF &p);
- void translate(qreal dx, qreal dy);
- void translate(const QPointF &p);
+ inline void translate(qreal dx, qreal dy);
+ inline void translate(const QPointF &p);
- Q_DECL_CONSTEXPR QRectF translated(qreal dx, qreal dy) const;
- Q_DECL_CONSTEXPR QRectF translated(const QPointF &p) const;
+ Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const;
+ Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const;
- void moveTo(qreal x, qreal t);
- void moveTo(const QPointF &p);
+ inline void moveTo(qreal x, qreal t);
+ inline void moveTo(const QPointF &p);
- void setRect(qreal x, qreal y, qreal w, qreal h);
- void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const;
+ inline void setRect(qreal x, qreal y, qreal w, qreal h);
+ inline void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const;
- void setCoords(qreal x1, qreal y1, qreal x2, qreal y2);
- void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const;
+ inline void setCoords(qreal x1, qreal y1, qreal x2, qreal y2);
+ inline void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const;
inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2);
Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const;
- Q_DECL_CONSTEXPR QSizeF size() const;
- Q_DECL_CONSTEXPR qreal width() const;
- Q_DECL_CONSTEXPR qreal height() const;
- void setWidth(qreal w);
- void setHeight(qreal h);
- void setSize(const QSizeF &s);
+ Q_DECL_CONSTEXPR inline QSizeF size() const;
+ Q_DECL_CONSTEXPR inline qreal width() const;
+ Q_DECL_CONSTEXPR inline qreal height() const;
+ inline void setWidth(qreal w);
+ inline void setHeight(qreal h);
+ inline void setSize(const QSizeF &s);
QRectF operator|(const QRectF &r) const;
QRectF operator&(const QRectF &r) const;
- QRectF& operator|=(const QRectF &r);
- QRectF& operator&=(const QRectF &r);
+ inline QRectF& operator|=(const QRectF &r);
+ inline QRectF& operator&=(const QRectF &r);
- bool contains(const QPointF &p) const;
- bool contains(qreal x, qreal y) const;
bool contains(const QRectF &r) const;
- QRectF united(const QRectF &other) const;
- QRectF intersected(const QRectF &other) const;
+ bool contains(const QPointF &p) const;
+ inline bool contains(qreal x, qreal y) const;
+ inline QRectF united(const QRectF &other) const;
+ inline QRectF intersected(const QRectF &other) const;
bool intersects(const QRectF &r) const;
#if QT_DEPRECATED_SINCE(5, 0)
@@ -534,10 +544,10 @@ public:
QT_DEPRECATED QRectF intersect(const QRectF &r) const { return intersected(r); }
#endif
- friend Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator==(const QRectF &, const QRectF &);
- friend Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator!=(const QRectF &, const QRectF &);
+ friend Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &);
+ friend Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &);
- Q_DECL_CONSTEXPR QRect toRect() const;
+ Q_DECL_CONSTEXPR inline QRect toRect() const;
QRect toAlignedRect() const;
private:
@@ -548,8 +558,8 @@ private:
};
Q_DECLARE_TYPEINFO(QRectF, Q_MOVABLE_TYPE);
-Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator==(const QRectF &, const QRectF &);
-Q_CORE_EXPORT_INLINE Q_DECL_CONSTEXPR bool operator!=(const QRectF &, const QRectF &);
+Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &);
+Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &);
/*****************************************************************************
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 1db0fcf44c..e2167c5999 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -437,7 +437,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
When the number of matches cannot be determined in advance, a
common idiom is to use cap() in a loop. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 0
+ \snippet code/src_corelib_tools_qregexp.cpp 0
\target assertions
\section1 Assertions
@@ -532,7 +532,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
To test a string against a wildcard expression, use exactMatch().
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 1
+ \snippet code/src_corelib_tools_qregexp.cpp 1
\target perl-users
\section1 Notes for Perl Users
@@ -555,7 +555,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
applied to all the quantifiers in the pattern. For example, to
match the Perl regexp \b{ro+?m} requires:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 2
+ \snippet code/src_corelib_tools_qregexp.cpp 2
The equivalent of Perl's \c{/i} option is
setCaseSensitivity(Qt::CaseInsensitive).
@@ -584,7 +584,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
the other hand, C++'s rules for literal strings can be used to
achieve the same:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 3
+ \snippet code/src_corelib_tools_qregexp.cpp 3
Both zero-width positive and zero-width negative lookahead
assertions (?=pattern) and (?!pattern) are supported with the same
@@ -603,12 +603,12 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
\target code-examples
\section1 Code Examples
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 4
+ \snippet code/src_corelib_tools_qregexp.cpp 4
The third string matches '\underline{6}'. This is a simple validation
regexp for integers in the range 0 to 99.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 5
+ \snippet code/src_corelib_tools_qregexp.cpp 5
The second string matches '\underline{This_is-OK}'. We've used the
character set abbreviation '\\S' (non-whitespace) and the anchors
@@ -618,25 +618,25 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
'letter' or 'correspondence' but only match whole words i.e. not
'email'
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 6
+ \snippet code/src_corelib_tools_qregexp.cpp 6
The second string matches "Please write the \underline{letter}". The
word 'letter' is also captured (because of the parentheses). We
can see what text we've captured like this:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 7
+ \snippet code/src_corelib_tools_qregexp.cpp 7
This will capture the text from the first set of capturing
parentheses (counting capturing left parentheses from left to
right). The parentheses are counted from 1 since cap(0) is the
whole matched regexp (equivalent to '&' in most regexp engines).
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 8
+ \snippet code/src_corelib_tools_qregexp.cpp 8
Here we've passed the QRegExp to QString's replace() function to
replace the matched text with new text.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 9
+ \snippet code/src_corelib_tools_qregexp.cpp 9
We've used the indexIn() function to repeatedly match the regexp in
the string. Note that instead of moving forward by one character
@@ -650,7 +650,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
One common use of regexps is to split lines of delimited data into
their component fields.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 10
+ \snippet code/src_corelib_tools_qregexp.cpp 10
In this example our input lines have the format company name, web
address and country. Unfortunately the regexp is rather long and
@@ -660,13 +660,13 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
QString::split() function can take a separator string or regexp
as an argument and split a string accordingly.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 11
+ \snippet code/src_corelib_tools_qregexp.cpp 11
Here field[0] is the company, field[1] the web address and so on.
To imitate the matching of a shell we can use wildcard mode.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 12
+ \snippet code/src_corelib_tools_qregexp.cpp 12
Wildcard matching can be convenient because of its simplicity, but
any wildcard regexp can be defined using full regexps, e.g.
@@ -4204,7 +4204,6 @@ void QRegExp::setMinimal(bool minimal)
priv->minimal = minimal;
}
-// ### Qt 5: make non-const
/*!
Returns true if \a str is matched exactly by this regular
expression; otherwise returns false. You can determine how much of
@@ -4220,12 +4219,9 @@ void QRegExp::setMinimal(bool minimal)
bluebell, \c blutak and \c lightblue, exactMatch() returns false
and matchedLength() will return 4, 3 and 0 respectively.
- Although const, this function sets matchedLength(),
- capturedTexts(), and pos().
-
\sa indexIn(), lastIndexIn()
*/
-bool QRegExp::exactMatch(const QString &str) const
+bool QRegExp::exactMatch(const QString &str)
{
prepareEngineForMatch(priv, str);
priv->matchState.match(str.unicode(), str.length(), 0, priv->minimal, true, 0);
@@ -4238,7 +4234,6 @@ bool QRegExp::exactMatch(const QString &str) const
}
}
-// ### Qt 5: make non-const
/*!
Attempts to find a match in \a str from position \a offset (0 by
default). If \a offset is -1, the search starts at the last
@@ -4255,10 +4250,7 @@ bool QRegExp::exactMatch(const QString &str) const
QString::replace().
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 13
-
- Although const, this function sets matchedLength(),
- capturedTexts() and pos().
+ \snippet code/src_corelib_tools_qregexp.cpp 13
If the QRegExp is a wildcard expression (see setPatternSyntax())
and want to test a string against the whole wildcard expression,
@@ -4267,7 +4259,7 @@ bool QRegExp::exactMatch(const QString &str) const
\sa lastIndexIn(), exactMatch()
*/
-int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const
+int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode)
{
prepareEngineForMatch(priv, str);
if (offset < 0)
@@ -4277,7 +4269,6 @@ int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const
return priv->matchState.captured[0];
}
-// ### Qt 5: make non-const
/*!
Attempts to find a match backwards in \a str from position \a
offset. If \a offset is -1 (the default), the search starts at the
@@ -4289,16 +4280,13 @@ int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const
The \a caretMode parameter can be used to instruct whether \b{^}
should match at index 0 or at \a offset.
- Although const, this function sets matchedLength(),
- capturedTexts() and pos().
-
\warning Searching backwards is much slower than searching
forwards.
\sa indexIn(), exactMatch()
*/
-int QRegExp::lastIndexIn(const QString &str, int offset, CaretMode caretMode) const
+int QRegExp::lastIndexIn(const QString &str, int offset, CaretMode caretMode)
{
prepareEngineForMatch(priv, str);
if (offset < 0)
@@ -4332,14 +4320,6 @@ int QRegExp::matchedLength() const
#ifndef QT_NO_REGEXP_CAPTURE
/*!
- \fn int QRegExp::numCaptures() const
- \obsolete
- Returns the number of captures contained in the regular expression.
-
- \sa captureCount()
- */
-
-/*!
\since 4.6
Returns the number of captures contained in the regular expression.
*/
@@ -4357,17 +4337,17 @@ int QRegExp::captureCount() const
(capturing) subexpression of the regexp.
For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 14
+ \snippet code/src_corelib_tools_qregexp.cpp 14
The above example also captures elements that may be present but
which we have no interest in. This problem can be solved by using
non-capturing parentheses:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 15
+ \snippet code/src_corelib_tools_qregexp.cpp 15
Note that if you want to iterate over the list, you should iterate
over a copy, e.g.
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 16
+ \snippet code/src_corelib_tools_qregexp.cpp 16
Some regexps can match an indeterminate number of times. For
example if the input string is "Offsets: 12 14 99 231 7" and the
@@ -4420,7 +4400,7 @@ QStringList QRegExp::capturedTexts()
match has index 0 and the parenthesized subexpressions have
indexes starting from 1 (excluding non-capturing parentheses).
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 17
+ \snippet code/src_corelib_tools_qregexp.cpp 17
The order of elements matched by cap() is as follows. The first
element, cap(0), is the entire matching string. Each subsequent
@@ -4449,7 +4429,7 @@ QString QRegExp::cap(int nth)
of the whole match.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 18
+ \snippet code/src_corelib_tools_qregexp.cpp 18
For zero-length matches, pos() always returns -1. (For example, if
cap(4) would return an empty string, pos(4) returns -1.) This is
@@ -4504,11 +4484,11 @@ QString QRegExp::errorString()
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 19
+ \snippet code/src_corelib_tools_qregexp.cpp 19
This function is useful to construct regexp patterns dynamically:
- \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 20
+ \snippet code/src_corelib_tools_qregexp.cpp 20
\sa setPatternSyntax()
*/
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index 0455e1603e..234bb624e4 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -93,10 +93,10 @@ public:
bool isMinimal() const;
void setMinimal(bool minimal);
- bool exactMatch(const QString &str) const;
+ bool exactMatch(const QString &str);
- int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero) const;
- int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero) const;
+ int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero);
+ int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero);
int matchedLength() const;
#ifndef QT_NO_REGEXP_CAPTURE
int captureCount() const;
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 393b2bbb7d..ff423901e8 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -122,23 +122,23 @@ QT_BEGIN_NAMESPACE
You can set the pattern string by passing a string to the QRegularExpression
constructor:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 0
+ \snippet code/src_corelib_tools_qregularexpression.cpp 0
This sets the pattern string to \c{a pattern}. You can also use the
setPattern() function to set a pattern on an existing QRegularExpression
object:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 1
+ \snippet code/src_corelib_tools_qregularexpression.cpp 1
Note that due to C++ literal strings rules, you must escape all backslashes
inside the pattern string with another backslash:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 2
+ \snippet code/src_corelib_tools_qregularexpression.cpp 2
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
+ \snippet code/src_corelib_tools_qregularexpression.cpp 3
\section1 Pattern options
@@ -149,17 +149,17 @@ QT_BEGIN_NAMESPACE
You can set the options by passing them to the QRegularExpression
constructor, as in:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 4
+ \snippet code/src_corelib_tools_qregularexpression.cpp 4
Alternatively, you can use the setPatternOptions() function on an existing
QRegularExpressionObject:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 5
+ \snippet code/src_corelib_tools_qregularexpression.cpp 5
It is possible to get the pattern options currently set on a
QRegularExpression object by using the patternOptions() function:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 6
+ \snippet code/src_corelib_tools_qregularexpression.cpp 6
Please refer to the QRegularExpression::PatternOption enum documentation for
more information about each pattern option.
@@ -187,20 +187,20 @@ QT_BEGIN_NAMESPACE
QRegularExpressionMatch object that can be used to inspect the results of
the match. For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 7
+ \snippet code/src_corelib_tools_qregularexpression.cpp 7
If a match is successful, the (implicit) capturing group number 0 can be
used to retrieve the substring matched by the entire pattern (see also the
section about \l{extracting captured substrings}):
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 8
+ \snippet code/src_corelib_tools_qregularexpression.cpp 8
It's also possible to start a match at an arbitrary offset inside the
subject string by passing the offset as an argument of the
match() function. In the following example \c{"12 abc"}
is not matched because the match is started at offset 1:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 9
+ \snippet code/src_corelib_tools_qregularexpression.cpp 9
\target extracting captured substrings
\section2 Extracting captured substrings
@@ -210,7 +210,7 @@ QT_BEGIN_NAMESPACE
\l{QRegularExpressionMatch::}{captured()} function will return the string
captured by the n-th capturing group:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 10
+ \snippet code/src_corelib_tools_qregularexpression.cpp 10
Capturing groups in the pattern are numbered starting from 1, and the
implicit capturing group 0 is used to capture the substring that matched
@@ -221,12 +221,12 @@ QT_BEGIN_NAMESPACE
\l{QRegularExpressionMatch::}{capturedStart()} and the
\l{QRegularExpressionMatch::}{capturedEnd()} functions:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 11
+ \snippet code/src_corelib_tools_qregularexpression.cpp 11
All of these functions have an overload taking a QString as a parameter
in order to extract \e{named} captured substrings. For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 12
+ \snippet code/src_corelib_tools_qregularexpression.cpp 12
\target global matching
\section1 Global matching
@@ -240,7 +240,7 @@ QT_BEGIN_NAMESPACE
which is a Java-like forward iterator that can be used to iterate over the
results. For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 13
+ \snippet code/src_corelib_tools_qregularexpression.cpp 13
Since it's a Java-like iterator, the QRegularExpressionMatchIterator will
point immediately before the first result. Every result is returned as a
@@ -250,7 +250,7 @@ QT_BEGIN_NAMESPACE
\l{QRegularExpressionMatchIterator::}{next()} will return the next result
and advance the iterator. Continuing from the previous example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 14
+ \snippet code/src_corelib_tools_qregularexpression.cpp 14
You can also use \l{QRegularExpressionMatchIterator::}{peekNext()} to get
the next result without advancing the iterator.
@@ -326,17 +326,17 @@ QT_BEGIN_NAMESPACE
This behaviour is implemented by the PartialPreferCompleteMatch match type.
For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 15
+ \snippet code/src_corelib_tools_qregularexpression.cpp 15
If matching the same regular expression against the subject string leads to
a complete match, it is reported as usual:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 16
+ \snippet code/src_corelib_tools_qregularexpression.cpp 16
Another example with a different pattern, showing the behaviour of
preferring a complete match over a partial one:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 17
+ \snippet code/src_corelib_tools_qregularexpression.cpp 17
In this case, the subpattern \c{abc\\w+X} partially matches the subject
string; however, the subpattern \c{def} matches the subject string
@@ -346,7 +346,7 @@ QT_BEGIN_NAMESPACE
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
+ \snippet code/src_corelib_tools_qregularexpression.cpp 18
\section2 Incremental/multi-segment matching
@@ -369,13 +369,13 @@ QT_BEGIN_NAMESPACE
as soon as it is found, and other match alternatives are not tried
(even if they could lead to a complete match). For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 19
+ \snippet code/src_corelib_tools_qregularexpression.cpp 19
This happens because when matching the first branch of the alternation
operator a partial match is found, and therefore matching stops, without
trying the second branch. Another example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 20
+ \snippet code/src_corelib_tools_qregularexpression.cpp 20
This shows what could seem a counterintuitve behaviour of quantifiers:
since \c{?} is greedy, then the engine tries first to continue the match
@@ -383,7 +383,7 @@ QT_BEGIN_NAMESPACE
subject string, and therefore a partial match is reported. This is
even more surprising in the following example:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 21
+ \snippet code/src_corelib_tools_qregularexpression.cpp 21
It's easy to understand this behaviour if we remember that the engine
expects the subject string to be only a substring of the whole text we're
@@ -404,13 +404,13 @@ QT_BEGIN_NAMESPACE
syntax errors in the pattern string. The isValid() function will return
true if the regular expression is valid, or false otherwise:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 22
+ \snippet code/src_corelib_tools_qregularexpression.cpp 22
You can get more information about the specific error by calling the
errorString() function; moreover, the patternErrorOffset() function
will return the offset inside the pattern string
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 23
+ \snippet code/src_corelib_tools_qregularexpression.cpp 23
If a match is attempted with an invalid QRegularExpression, then the
returned QRegularExpressionMatch object will be invalid as well (that is,
@@ -455,19 +455,19 @@ QT_BEGIN_NAMESPACE
putting the pattern between the \c{^} and the \c{$} anchors is enough
in most cases:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 24
+ \snippet code/src_corelib_tools_qregularexpression.cpp 24
However, remember that the \c{$} anchor not only matches at the end of the
string, but also at a newline character right before the end of the string;
that is, the previous pattern matches against the string "this pattern must
- match exactly\n". Also, the behaviour of both the \c{^} and the \c{$}
+ match exactly\\n". Also, the behaviour of both the \c{^} and the \c{$}
anchors changes if the MultiLineOption is set either explicitely (as a
pattern option) or implicitly (as a directive inside the pattern string).
Therefore, in the most general case, you should wrap the pattern between
the \c{\A} and the \c{\z} anchors:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 25
+ \snippet code/src_corelib_tools_qregularexpression.cpp 25
Note the usage of the non-capturing group in order to preserve the meaning
of the branch operator inside the pattern.
@@ -566,7 +566,7 @@ QT_BEGIN_NAMESPACE
returns each substring captured, either by the capturing group's index or
by its name:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 29
+ \snippet code/src_corelib_tools_qregularexpression.cpp 29
For each captured substring it is possible to query its starting and ending
offsets in the subject string by calling the capturedStart() and the
@@ -616,7 +616,7 @@ QT_BEGIN_NAMESPACE
For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 30
+ \snippet code/src_corelib_tools_qregularexpression.cpp 30
Moreover, QRegularExpressionMatchIterator offers a peekNext() function
to get the next result \e{without} advancing the iterator.
@@ -1590,11 +1590,11 @@ bool QRegularExpression::operator==(const QRegularExpression &re) const
meaning when used as a regular expression pattern string, and returns
the escaped string. For instance:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 26
+ \snippet code/src_corelib_tools_qregularexpression.cpp 26
This is very convenient in order to build patterns from arbitrary strings:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 27
+ \snippet code/src_corelib_tools_qregularexpression.cpp 27
\note This function implements Perl's quotemeta algorithm and escapes with
a backslash all characters in \a str, except for the characters in the
@@ -1721,7 +1721,7 @@ QRegularExpression::MatchOptions QRegularExpressionMatch::matchOptions() const
including the implicit capturing group 0. This can be used to extract all
the substrings that were captured:
- \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 28
+ \snippet code/src_corelib_tools_qregularexpression.cpp 28
Note that some of the capturing groups with an index less than
lastCapturedIndex() could have not matched, and therefore captured nothing.
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 5ecca89229..bf2cac453b 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -61,12 +61,12 @@ QT_BEGIN_NAMESPACE
Consider this function which does heap allocations, and have various exit points:
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 0
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 0
It's encumbered by the manual delete calls. With QScopedPointer, the code
can be simplified to:
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 1
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 1
The code the compiler generates for QScopedPointer is the same as when
writing it manually. Code that makes use of \a delete are candidates for
@@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
The const qualification on a regular C++ pointer can also be expressed with
a QScopedPointer:
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 2
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 2
\section1 Custom cleanup handlers
@@ -99,7 +99,7 @@ QT_BEGIN_NAMESPACE
You can pass your own classes as handlers, provided that they have a public
static function \c{void cleanup(T *pointer)}.
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 5
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 5
\section1 Forward Declared Pointers
@@ -111,7 +111,7 @@ QT_BEGIN_NAMESPACE
points to a forward declared class must have non-inline constructors,
destructors and assignment operators:
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 4
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 4
Otherwise, the compiler output a warning about not being able to destruct
\c MyPrivateClass.
@@ -168,7 +168,7 @@ QT_BEGIN_NAMESPACE
Returns \c true if this object is not \c null. This function is suitable
for use in \tt if-constructs, like:
- \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 3
+ \snippet code/src_corelib_tools_qscopedpointer.cpp 3
\sa isNull()
*/
diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc
index b03cce884d..51d9caad70 100644
--- a/src/corelib/tools/qset.qdoc
+++ b/src/corelib/tools/qset.qdoc
@@ -40,19 +40,19 @@
Here's an example QSet with QString values:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 0
+ \snippet code/doc_src_qset.cpp 0
To insert a value into the set, use insert():
- \snippet doc/src/snippets/code/doc_src_qset.cpp 1
+ \snippet code/doc_src_qset.cpp 1
Another way to insert items into the set is to use operator<<():
- \snippet doc/src/snippets/code/doc_src_qset.cpp 2
+ \snippet code/doc_src_qset.cpp 2
To test whether an item belongs to the set or not, use contains():
- \snippet doc/src/snippets/code/doc_src_qset.cpp 3
+ \snippet code/doc_src_qset.cpp 3
If you want to navigate through all the values stored in a QSet,
you can use an iterator. QSet supports both \l{Java-style
@@ -60,18 +60,18 @@
iterators} (QSet::iterator and QSet::const_iterator). Here's how
to iterate over a QSet<QWidget *> using a Java-style iterator:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 4
+ \snippet code/doc_src_qset.cpp 4
Here's the same code, but using an STL-style iterator:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 5
+ \snippet code/doc_src_qset.cpp 5
QSet is unordered, so an iterator's sequence cannot be assumed to
be predictable. If ordering by key is required, use a QMap.
To navigate through a QSet, you can also use \l{foreach}:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 6
+ \snippet code/doc_src_qset.cpp 6
Items can be removed from the set using remove(). There is also a
clear() function that removes all items.
@@ -194,7 +194,7 @@
This function is useful for code that needs to build a huge set
and wants to avoid repeated reallocation. For example:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 7
+ \snippet code/doc_src_qset.cpp 7
Ideally, \a size should be slightly more than the maximum number
of elements expected in the set. \a size doesn't have to be prime,
@@ -618,18 +618,18 @@
start iterating. Here's a typical loop that prints all the items
stored in a set:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 8
+ \snippet code/doc_src_qset.cpp 8
Here's a loop that removes certain items (all those that start
with 'J') from a set while iterating:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 9
+ \snippet code/doc_src_qset.cpp 9
STL-style iterators can be used as arguments to \l{generic
algorithms}. For example, here's how to find an item in the set
using the qFind() algorithm:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 10
+ \snippet code/doc_src_qset.cpp 10
Multiple iterators can be used on the same set. However, you may
not attempt to modify the container while iterating on it.
@@ -661,13 +661,13 @@
start iterating. Here's a typical loop that prints all the items
stored in a set:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 11
+ \snippet code/doc_src_qset.cpp 11
STL-style iterators can be used as arguments to \l{generic
algorithms}. For example, here's how to find an item in the set
using the qFind() algorithm:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 12
+ \snippet code/doc_src_qset.cpp 12
Multiple iterators can be used on the same set. However, you may
not attempt to modify the container while iterating on it.
@@ -901,7 +901,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 13
+ \snippet code/doc_src_qset.cpp 13
\sa fromList(), QList::fromSet(), qSort()
*/
@@ -926,7 +926,7 @@
Example:
- \snippet doc/src/snippets/code/doc_src_qset.cpp 14
+ \snippet code/doc_src_qset.cpp 14
\sa toList(), QList::toSet()
*/
diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp
index ffc8ac601d..4c33bebd7b 100644
--- a/src/corelib/tools/qshareddata.cpp
+++ b/src/corelib/tools/qshareddata.cpp
@@ -99,7 +99,7 @@ QT_BEGIN_NAMESPACE
implicitly shared \c Employee class. In the header file we define the
two classes \c Employee and \c EmployeeData.
- \snippet doc/src/snippets/sharedemployee/employee.h 0
+ \snippet sharedemployee/employee.h 0
In class \c Employee, note the single data member, a \e {d pointer}
of type \c {QSharedDataPointer<EmployeeData>}. All accesses of
@@ -121,14 +121,14 @@ QT_BEGIN_NAMESPACE
straightforward. Both create a new instance of \c EmployeeData
and assign it to the \e{d pointer} .
- \snippet doc/src/snippets/sharedemployee/employee.h 1
+ \snippet sharedemployee/employee.h 1
\codeline
- \snippet doc/src/snippets/sharedemployee/employee.h 2
+ \snippet sharedemployee/employee.h 2
Note that class \c Employee also has a trivial copy constructor
defined, which is not strictly required in this case.
- \snippet doc/src/snippets/sharedemployee/employee.h 7
+ \snippet sharedemployee/employee.h 7
The copy constructor is not strictly required here, because class \c
EmployeeData is included in the same file as class \c Employee
@@ -162,9 +162,9 @@ QT_BEGIN_NAMESPACE
detach() to ensure that the function operates on its own copy of the
data.
- \snippet doc/src/snippets/sharedemployee/employee.h 3
+ \snippet sharedemployee/employee.h 3
\codeline
- \snippet doc/src/snippets/sharedemployee/employee.h 4
+ \snippet sharedemployee/employee.h 4
Note that if detach() is called more than once in a member function
due to multiple dereferences of the \e {d pointer}, detach() will
@@ -180,9 +180,9 @@ QT_BEGIN_NAMESPACE
In \c Employee's \e const member functions, dereferencing the \e {d
pointer} does \e not cause detach() to be called.
- \snippet doc/src/snippets/sharedemployee/employee.h 5
+ \snippet sharedemployee/employee.h 5
\codeline
- \snippet doc/src/snippets/sharedemployee/employee.h 6
+ \snippet sharedemployee/employee.h 6
Notice that there is no need to implement a copy constructor or an
assignment operator for the \c Employee class, because the copy
@@ -199,7 +199,7 @@ QT_BEGIN_NAMESPACE
Consider a simple example that creates two instances of the
implicitly shared \c Employee class.
- \snippet doc/src/snippets/sharedemployee/main.cpp 0
+ \snippet sharedemployee/main.cpp 0
After the second employee e2 is created and e1 is assigned to it,
both \c e1 and \c e2 refer to Albrecht Durer, employee 1001. Both \c
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index fb6219273f..ac21e5beb9 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Intel Corporation.
** Contact: http://www.qt-project.org/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -46,9 +47,12 @@
#if defined(Q_OS_WIN)
# if defined(Q_OS_WINCE)
# include <qt_windows.h>
+# include <cmnintrin.h>
# endif
# if !defined(Q_CC_GNU)
-# include <intrin.h>
+# ifndef Q_OS_WINCE
+# include <intrin.h>
+# endif
# endif
#elif defined(Q_OS_LINUX) && defined(__arm__)
#include "private/qcore_unix_p.h"
@@ -98,7 +102,7 @@ static inline uint detectProcessorFeatures()
return features;
}
-#elif defined(__arm__) || defined(__arm) || defined(QT_HAVE_IWMMXT) || defined(QT_HAVE_NEON)
+#elif defined(Q_PROCESSOR_ARM) || defined(QT_HAVE_IWMMXT) || defined(QT_HAVE_NEON)
static inline uint detectProcessorFeatures()
{
uint features = 0;
@@ -142,17 +146,22 @@ static inline uint detectProcessorFeatures()
return features;
}
-#elif defined(__i386__) || defined(_M_IX86)
-static inline uint detectProcessorFeatures()
-{
- uint features = 0;
+#elif defined(Q_PROCESSOR_X86)
- unsigned int extended_result = 0;
- unsigned int feature_result = 0;
- uint result = 0;
- /* see p. 118 of amd64 instruction set manual Vol3 */
+#ifdef Q_PROCESSOR_X86_32
+# define PICreg "%%ebx"
+#else
+# define PICreg "%%rbx"
+#endif
+
+static int maxBasicCpuidSupported()
+{
#if defined(Q_CC_GNU)
- long cpuid_supported, tmp1;
+ qintptr tmp1;
+
+# ifdef Q_PROCESSOR_X86_32
+ // check if the CPUID instruction is supported
+ long cpuid_supported;
asm ("pushf\n"
"pop %0\n"
"mov %0, %1\n"
@@ -164,146 +173,141 @@ static inline uint detectProcessorFeatures()
"xor %1, %0\n" // %eax is now 0 if CPUID is not supported
: "=a" (cpuid_supported), "=r" (tmp1)
);
- if (cpuid_supported) {
- asm ("xchg %%ebx, %2\n"
- "cpuid\n"
- "xchg %%ebx, %2\n"
- : "=&c" (feature_result), "=d" (result), "=&r" (tmp1)
- : "a" (1));
-
- asm ("xchg %%ebx, %1\n"
- "cpuid\n"
- "cmp $0x80000000, %%eax\n"
- "jnbe 1f\n"
- "xor %0, %0\n"
- "jmp 2f\n"
- "1:\n"
- "mov $0x80000001, %%eax\n"
- "cpuid\n"
- "2:\n"
- "xchg %%ebx, %1\n"
- : "=&d" (extended_result), "=&r" (tmp1)
- : "a" (0x80000000)
- : "%ecx"
- );
- }
+ if (!cpuid_supported)
+ return 0;
+# endif
-#elif defined (Q_OS_WIN)
- _asm {
- push eax
- push ebx
- push ecx
- push edx
- pushfd
- pop eax
- mov ebx, eax
- xor eax, 00200000h
- push eax
- popfd
- pushfd
- pop eax
- mov edx, 0
- xor eax, ebx
- jz skip
-
- mov eax, 1
- cpuid
- mov result, edx
- mov feature_result, ecx
- skip:
- pop edx
- pop ecx
- pop ebx
- pop eax
- }
+ int result;
+ asm ("xchg " PICreg", %1\n"
+ "cpuid\n"
+ "xchg " PICreg", %1\n"
+ : "=&a" (result), "=&r" (tmp1)
+ : "0" (0)
+ : "ecx", "edx");
+ return result;
+#elif defined(Q_OS_WIN)
+ // Use the __cpuid function; if the CPUID instruction isn't supported, it will return 0
+ int info[4];
+ __cpuid(info, 0);
+ return info[0];
+#else
+ return 0;
+#endif
+}
- _asm {
- push eax
- push ebx
- push ecx
- push edx
- pushfd
- pop eax
- mov ebx, eax
- xor eax, 00200000h
- push eax
- popfd
- pushfd
- pop eax
- mov edx, 0
- xor eax, ebx
- jz skip2
-
- mov eax, 80000000h
- cpuid
- cmp eax, 80000000h
- jbe skip2
- mov eax, 80000001h
- cpuid
- mov extended_result, edx
- skip2:
- pop edx
- pop ecx
- pop ebx
- pop eax
- }
+static void cpuidFeatures01(uint &ecx, uint &edx)
+{
+#if defined(Q_CC_GNU)
+ qintptr tmp1;
+ asm ("xchg " PICreg", %2\n"
+ "cpuid\n"
+ "xchg " PICreg", %2\n"
+ : "=&c" (ecx), "=&d" (edx), "=&r" (tmp1)
+ : "a" (1));
+#elif defined(Q_OS_WIN)
+ int info[4];
+ __cpuid(info, 1);
+ ecx = info[2];
+ edx = info[3];
#endif
+}
+static void cpuidFeatures07_00(uint &ebx)
+{
+#if defined(Q_CC_GNU)
+ quintptr rbx; // in case it's 64-bit
+ asm ("xchg " PICreg", %0\n"
+ "cpuid\n"
+ "xchg " PICreg", %0\n"
+ : "=&r" (rbx)
+ : "a" (7), "c" (0)
+ : "%edx");
+ ebx = rbx;
+#elif defined(Q_OS_WIN)
+ int info[4];
+ __cpuidex(info, 7, 0);
+ ebx = info[1];
+#endif
+}
- // result now contains the standard feature bits
- if (result & (1u << 26))
- features |= SSE2;
- if (feature_result & (1u))
- features |= SSE3;
- if (feature_result & (1u << 9))
- features |= SSSE3;
- if (feature_result & (1u << 19))
- features |= SSE4_1;
- if (feature_result & (1u << 20))
- features |= SSE4_2;
- if (feature_result & (1u << 28))
- features |= AVX;
+#ifdef Q_OS_WIN
+namespace QtXgetbvHack {
+ inline quint64 _xgetbv(int) { return 0; }
+}
+using namespace QtXgetbvHack;
+#endif
- return features;
+static void xgetbv(int in, uint &eax, uint &edx)
+{
+#ifdef Q_OS_WIN
+ quint64 result = _xgetbv(in);
+ eax = result;
+ edx = result >> 32;
+#elif defined(Q_CC_GNU)
+ asm (".byte 0x0F, 0x01, 0xD0" // xgetbv instruction
+ : "=a" (eax), "=d" (edx)
+ : "c" (in));
+#endif
}
-#elif defined(__x86_64) || defined(Q_OS_WIN64)
static inline uint detectProcessorFeatures()
{
- uint features = SSE2;
- uint feature_result = 0;
-
-#if defined (Q_OS_WIN64)
- {
- int info[4];
- __cpuid(info, 1);
- feature_result = info[2];
- }
-#elif defined(Q_CC_GNU)
- quint64 tmp;
- asm ("xchg %%rbx, %1\n"
- "cpuid\n"
- "xchg %%rbx, %1\n"
- : "=&c" (feature_result), "=&r" (tmp)
- : "a" (1)
- : "%edx"
- );
+ uint features = 0;
+ int cpuidLevel = maxBasicCpuidSupported();
+ if (cpuidLevel < 1)
+ return 0;
+
+ uint cpuid01ECX = 0, cpuid01EDX = 0;
+ cpuidFeatures01(cpuid01ECX, cpuid01EDX);
+#if defined(Q_PROCESSOR_X86_32)
+ // x86 might not have SSE2 support
+ if (cpuid01EDX & (1u << 26))
+ features |= SSE2;
+#else
+ // x86-64 or x32
+ features = SSE2;
#endif
- if (feature_result & (1u))
+ // common part between 32- and 64-bit
+ if (cpuid01ECX & (1u))
features |= SSE3;
- if (feature_result & (1u << 9))
+ if (cpuid01ECX & (1u << 9))
features |= SSSE3;
- if (feature_result & (1u << 19))
+ if (cpuid01ECX & (1u << 19))
features |= SSE4_1;
- if (feature_result & (1u << 20))
+ if (cpuid01ECX & (1u << 20))
features |= SSE4_2;
- if (feature_result & (1u << 28))
- features |= AVX;
+ if (cpuid01ECX & (1u << 25))
+ features |= 0; // AES, enable if needed
+
+ uint xgetbvA = 0, xgetbvD = 0;
+ if (cpuid01ECX & (1u << 27)) {
+ // XGETBV enabled
+ xgetbv(0, xgetbvA, xgetbvD);
+ }
+
+ uint cpuid0700EBX = 0;
+ if (cpuidLevel >= 7)
+ cpuidFeatures07_00(cpuid0700EBX);
+
+ if ((xgetbvA & 6) == 6) {
+ // support for YMM and XMM registers is enabled
+ if (cpuid01ECX & (1u << 28))
+ features |= AVX;
+
+ if (cpuid0700EBX & (1u << 5))
+ features |= AVX2;
+ }
+
+ if (cpuid0700EBX & (1u << 4))
+ features |= HLE; // Hardware Lock Ellision
+ if (cpuid0700EBX & (1u << 11))
+ features |= RTM; // Restricted Transactional Memory
return features;
}
+
#else
static inline uint detectProcessorFeatures()
{
@@ -322,6 +326,9 @@ static inline uint detectProcessorFeatures()
sse4.1
sse4.2
avx
+ avx2
+ hle
+ rtm
*/
// begin generated
@@ -334,11 +341,14 @@ static const char features_string[] =
" sse4.1\0"
" sse4.2\0"
" avx\0"
+ " avx2\0"
+ " hle\0"
+ " rtm\0"
"\0";
static const int features_indices[] = {
0, 8, 14, 20, 26, 33, 41, 49,
- -1
+ 54, 60, 65, -1
};
// end generated
@@ -384,8 +394,12 @@ static const uint minFeature = None
#else
int ffs(int i)
{
+#ifndef Q_OS_WINCE
unsigned long result;
return _BitScanForward(&result, i) ? result : 0;
+#else
+ return 0;
+#endif
}
#endif
#endif // Q_OS_WIN
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 88ac7597e2..6374e20135 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -129,7 +129,10 @@ enum CPUFeatures {
SSSE3 = 0x10,
SSE4_1 = 0x20,
SSE4_2 = 0x40,
- AVX = 0x80
+ AVX = 0x80,
+ AVX2 = 0x100,
+ HLE = 0x200,
+ RTM = 0x400
};
Q_CORE_EXPORT uint qDetectCPUFeatures();
diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp
index b276d2d2e0..b4b99d26ff 100644
--- a/src/corelib/tools/qsize.cpp
+++ b/src/corelib/tools/qsize.cpp
@@ -194,7 +194,7 @@ void QSize::transpose()
\endlist
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 0
+ \snippet code/src_corelib_tools_qsize.cpp 0
\sa setWidth(), setHeight(), scaled()
*/
@@ -252,7 +252,7 @@ QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const
Using a reference makes it possible to manipulate the width
directly. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 1
+ \snippet code/src_corelib_tools_qsize.cpp 1
\sa rheight(), setWidth()
*/
@@ -265,7 +265,7 @@ QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const
Using a reference makes it possible to manipulate the height
directly. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 2
+ \snippet code/src_corelib_tools_qsize.cpp 2
\sa rwidth(), setHeight()
*/
@@ -276,7 +276,7 @@ QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const
Adds the given \a size to \e this size, and returns a reference to
this size. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 3
+ \snippet code/src_corelib_tools_qsize.cpp 3
*/
/*!
@@ -285,7 +285,7 @@ QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const
Subtracts the given \a size from \e this size, and returns a
reference to this size. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 4
+ \snippet code/src_corelib_tools_qsize.cpp 4
*/
/*!
@@ -622,7 +622,7 @@ void QSizeF::transpose()
\endlist
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 5
+ \snippet code/src_corelib_tools_qsize.cpp 5
\sa setWidth(), setHeight(), scaled()
*/
@@ -636,11 +636,11 @@ void QSizeF::transpose()
*/
/*!
- \fn QSizeF QSizeF::scaled(int width, int height, Qt::AspectRatioMode mode) const
+ \fn QSizeF QSizeF::scaled(qreal width, qreal height, Qt::AspectRatioMode mode) const
\since 5.0
Returns a size scaled to a rectangle with the given \a width and
- \a height, according to the specified \mode.
+ \a height, according to the specified \a mode.
\sa scale()
*/
@@ -679,7 +679,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const
Using a reference makes it possible to manipulate the width
directly. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 6
+ \snippet code/src_corelib_tools_qsize.cpp 6
\sa rheight(), setWidth()
*/
@@ -692,7 +692,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const
Using a reference makes it possible to manipulate the height
directly. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 7
+ \snippet code/src_corelib_tools_qsize.cpp 7
\sa rwidth(), setHeight()
*/
@@ -703,7 +703,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const
Adds the given \a size to this size and returns a reference to
this size. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 8
+ \snippet code/src_corelib_tools_qsize.cpp 8
*/
/*!
@@ -712,7 +712,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const
Subtracts the given \a size from this size and returns a reference
to this size. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qsize.cpp 9
+ \snippet code/src_corelib_tools_qsize.cpp 9
*/
/*!
diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h
index 88af9e876b..0f8ef24acf 100644
--- a/src/corelib/tools/qsize.h
+++ b/src/corelib/tools/qsize.h
@@ -55,32 +55,32 @@ public:
Q_DECL_CONSTEXPR QSize();
Q_DECL_CONSTEXPR QSize(int w, int h);
- Q_DECL_CONSTEXPR bool isNull() const;
- Q_DECL_CONSTEXPR bool isEmpty() const;
- Q_DECL_CONSTEXPR bool isValid() const;
-
- Q_DECL_CONSTEXPR int width() const;
- Q_DECL_CONSTEXPR int height() const;
- void setWidth(int w);
- void setHeight(int h);
+ Q_DECL_CONSTEXPR inline bool isNull() const;
+ Q_DECL_CONSTEXPR inline bool isEmpty() const;
+ Q_DECL_CONSTEXPR inline bool isValid() const;
+
+ Q_DECL_CONSTEXPR inline int width() const;
+ Q_DECL_CONSTEXPR inline int height() const;
+ inline void setWidth(int w);
+ inline void setHeight(int h);
void transpose();
- Q_DECL_CONSTEXPR QSize transposed() const;
+ Q_DECL_CONSTEXPR inline QSize transposed() const;
- void scale(int w, int h, Qt::AspectRatioMode mode);
- void scale(const QSize &s, Qt::AspectRatioMode mode);
+ inline void scale(int w, int h, Qt::AspectRatioMode mode);
+ inline void scale(const QSize &s, Qt::AspectRatioMode mode);
QSize scaled(int w, int h, Qt::AspectRatioMode mode) const;
QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const;
- Q_DECL_CONSTEXPR QSize expandedTo(const QSize &) const;
- Q_DECL_CONSTEXPR QSize boundedTo(const QSize &) const;
+ Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const;
+ Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const;
- int &rwidth();
- int &rheight();
+ inline int &rwidth();
+ inline int &rheight();
- QSize &operator+=(const QSize &);
- QSize &operator-=(const QSize &);
- QSize &operator*=(qreal c);
- QSize &operator/=(qreal c);
+ inline QSize &operator+=(const QSize &);
+ inline QSize &operator-=(const QSize &);
+ inline QSize &operator*=(qreal c);
+ inline QSize &operator/=(qreal c);
friend inline Q_DECL_CONSTEXPR bool operator==(const QSize &, const QSize &);
friend inline Q_DECL_CONSTEXPR bool operator!=(const QSize &, const QSize &);
@@ -215,32 +215,32 @@ public:
Q_DECL_CONSTEXPR QSizeF(const QSize &sz);
Q_DECL_CONSTEXPR QSizeF(qreal w, qreal h);
- bool isNull() const;
- Q_DECL_CONSTEXPR bool isEmpty() const;
- Q_DECL_CONSTEXPR bool isValid() const;
+ inline bool isNull() const;
+ Q_DECL_CONSTEXPR inline bool isEmpty() const;
+ Q_DECL_CONSTEXPR inline bool isValid() const;
- Q_DECL_CONSTEXPR qreal width() const;
- Q_DECL_CONSTEXPR qreal height() const;
- void setWidth(qreal w);
- void setHeight(qreal h);
+ Q_DECL_CONSTEXPR inline qreal width() const;
+ Q_DECL_CONSTEXPR inline qreal height() const;
+ inline void setWidth(qreal w);
+ inline void setHeight(qreal h);
void transpose();
- Q_DECL_CONSTEXPR QSizeF transposed() const;
+ Q_DECL_CONSTEXPR inline QSizeF transposed() const;
- void scale(qreal w, qreal h, Qt::AspectRatioMode mode);
- void scale(const QSizeF &s, Qt::AspectRatioMode mode);
+ inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode);
+ inline void scale(const QSizeF &s, Qt::AspectRatioMode mode);
QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const;
QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const;
- Q_DECL_CONSTEXPR QSizeF expandedTo(const QSizeF &) const;
- Q_DECL_CONSTEXPR QSizeF boundedTo(const QSizeF &) const;
+ Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const;
+ Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const;
- qreal &rwidth();
- qreal &rheight();
+ inline qreal &rwidth();
+ inline qreal &rheight();
- QSizeF &operator+=(const QSizeF &);
- QSizeF &operator-=(const QSizeF &);
- QSizeF &operator*=(qreal c);
- QSizeF &operator/=(qreal c);
+ inline QSizeF &operator+=(const QSizeF &);
+ inline QSizeF &operator-=(const QSizeF &);
+ inline QSizeF &operator*=(qreal c);
+ inline QSizeF &operator/=(qreal c);
friend Q_DECL_CONSTEXPR inline bool operator==(const QSizeF &, const QSizeF &);
friend Q_DECL_CONSTEXPR inline bool operator!=(const QSizeF &, const QSizeF &);
diff --git a/src/corelib/tools/qstack.cpp b/src/corelib/tools/qstack.cpp
index 888fbfa0b4..359705887e 100644
--- a/src/corelib/tools/qstack.cpp
+++ b/src/corelib/tools/qstack.cpp
@@ -58,7 +58,7 @@
Example:
- \snippet doc/src/snippets/qstack/main.cpp 0
+ \snippet qstack/main.cpp 0
The example will output 3, 2, 1 in that order.
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index ed0c493c7a..04626742bd 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -421,7 +421,7 @@ const QString::Null QString::null = { };
Most of the QChar member functions also exist in QCharRef.
However, they are not explicitly documented here.
- \sa QString::operator[]() QString::at() QChar
+ \sa QString::operator[](), QString::at(), QChar
*/
/*!
@@ -467,7 +467,7 @@ const QString::Null QString::null = { };
*} to its constructor. For example, the following code creates a
QString of size 5 containing the data "Hello":
- \snippet doc/src/snippets/qstring/main.cpp 0
+ \snippet qstring/main.cpp 0
QString converts the \c{const char *} data into Unicode using the
fromAscii() function. fromAscii() treats ordinals above 128 as Latin-1
@@ -480,7 +480,7 @@ const QString::Null QString::null = { };
You can also provide string data as an array of \l{QChar}s:
- \snippet doc/src/snippets/qstring/main.cpp 1
+ \snippet qstring/main.cpp 1
QString makes a deep copy of the QChar data, so you can modify it
later without experiencing side effects. (If for performance
@@ -495,12 +495,12 @@ const QString::Null QString::null = { };
character that can be used on the left side of an assignment. For
example:
- \snippet doc/src/snippets/qstring/main.cpp 2
+ \snippet qstring/main.cpp 2
For read-only access, an alternative syntax is to use the at()
function:
- \snippet doc/src/snippets/qstring/main.cpp 3
+ \snippet qstring/main.cpp 3
The at() function can be faster than \l operator[](), because it
never causes a \l{deep copy} to occur. Alternatively, use the
@@ -519,7 +519,7 @@ const QString::Null QString::null = { };
usage. For example, if you want to compare a QString with a string
literal, you can write code like this and it will work as expected:
- \snippet doc/src/snippets/qstring/main.cpp 4
+ \snippet qstring/main.cpp 4
You can also pass string literals to functions that take QStrings
as arguments, invoking the QString(const char *)
@@ -534,7 +534,7 @@ const QString::Null QString::null = { };
character data: append(), prepend(), insert(), replace(), and
remove(). For example:
- \snippet doc/src/snippets/qstring/main.cpp 5
+ \snippet qstring/main.cpp 5
If you are building a QString gradually and know in advance
approximately how many characters the QString will contain, you
@@ -563,7 +563,7 @@ const QString::Null QString::null = { };
they return -1. For example, here's a typical loop that finds all
occurrences of a particular substring:
- \snippet doc/src/snippets/qstring/main.cpp 6
+ \snippet qstring/main.cpp 6
QString provides many functions for converting numbers into
strings and strings into numbers. See the arg() functions, the
@@ -642,14 +642,14 @@ const QString::Null QString::null = { };
application is to add the following entry to your
\l{qmake Project Files}{qmake project file}:
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 0
+ \snippet code/src_corelib_tools_qstring.cpp 0
You then need to explicitly call fromAscii(), fromLatin1(),
fromUtf8(), or fromLocal8Bit() to construct a QString from an
8-bit string, or use the lightweight QLatin1String class, for
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 1
+ \snippet code/src_corelib_tools_qstring.cpp 1
Similarly, you must call toAscii(), toLatin1(), toUtf8(), or
toLocal8Bit() explicitly to convert the QString to an 8-bit
@@ -666,7 +666,7 @@ const QString::Null QString::null = { };
\l{implicitly shared}, QStrings may be treated like \c{int}s or
other basic types. For example:
- \snippet doc/src/snippets/qstring/main.cpp 7
+ \snippet qstring/main.cpp 7
The \c result variable, is a normal variable allocated on the
stack. When \c return is called, and because we're returning by
@@ -685,7 +685,7 @@ const QString::Null QString::null = { };
string with size 0. A null string is always empty, but an empty
string isn't necessarily null:
- \snippet doc/src/snippets/qstring/main.cpp 8
+ \snippet qstring/main.cpp 8
All functions except isNull() treat null strings the same as empty
strings. For example, toAscii().constData() returns a pointer to a
@@ -732,7 +732,7 @@ const QString::Null QString::null = { };
complex string from multiple substrings. You will often write code
like this:
- \snippet doc/src/snippets/qstring/stringbuilder.cpp 0
+ \snippet qstring/stringbuilder.cpp 0
There is nothing wrong with either of these string constructions,
but there are a few hidden inefficiencies. Beginning with Qt 4.6,
@@ -770,13 +770,13 @@ const QString::Null QString::null = { };
\c{QStringBuilder} wherever you want to use it, and use the
\c{'%'} operator instead of \c{'+'} when concatenating strings:
- \snippet doc/src/snippets/qstring/stringbuilder.cpp 5
+ \snippet qstring/stringbuilder.cpp 5
A more global approach which is the most convenient but
not entirely source compatible, is to this define in your
.pro file:
- \snippet doc/src/snippets/qstring/stringbuilder.cpp 3
+ \snippet qstring/stringbuilder.cpp 3
and the \c{'+'} will automatically be performed as the
\c{QStringBuilder} \c{'%'} everywhere.
@@ -1175,12 +1175,12 @@ QString::QString(QChar ch)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 45
+ \snippet qstring/main.cpp 45
If you want to append a certain number of identical characters to
the string, use \l operator+=() as follows rather than resize():
- \snippet doc/src/snippets/qstring/main.cpp 46
+ \snippet qstring/main.cpp 46
If you want to expand the string so that it reaches a certain
width and fill the new positions with a particular character, use
@@ -1188,7 +1188,7 @@ QString::QString(QChar ch)
If \a size is negative, it is equivalent to passing zero.
- \snippet doc/src/snippets/qstring/main.cpp 47
+ \snippet qstring/main.cpp 47
\sa truncate(), reserve()
*/
@@ -1253,7 +1253,7 @@ void QString::resize(int size)
we're fairly sure that size is large enough to make a call to
reserve() worthwhile:
- \snippet doc/src/snippets/qstring/main.cpp 44
+ \snippet qstring/main.cpp 44
\sa squeeze(), capacity()
*/
@@ -1394,7 +1394,7 @@ QString &QString::operator=(QChar ch)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 26
+ \snippet qstring/main.cpp 26
If the given \a position is greater than size(), the array is
first extended using resize().
@@ -1478,11 +1478,11 @@ QString& QString::insert(int i, QChar ch)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 9
+ \snippet qstring/main.cpp 9
This is the same as using the insert() function:
- \snippet doc/src/snippets/qstring/main.cpp 10
+ \snippet qstring/main.cpp 10
The append() function is typically very fast (\l{constant time}),
because QString preallocates extra space at the end of the string
@@ -1574,7 +1574,7 @@ QString &QString::append(QChar ch)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 36
+ \snippet qstring/main.cpp 36
\sa append(), insert()
*/
@@ -1629,7 +1629,7 @@ QString &QString::append(QChar ch)
position + \a n is beyond the end of the string, the string is
truncated at the specified \a position.
- \snippet doc/src/snippets/qstring/main.cpp 37
+ \snippet qstring/main.cpp 37
\sa insert(), replace()
*/
@@ -1680,7 +1680,7 @@ QString &QString::remove(const QString &str, Qt::CaseSensitivity cs)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 38
+ \snippet qstring/main.cpp 38
This is the same as \c replace(ch, "", cs).
@@ -1713,7 +1713,7 @@ QString &QString::remove(QChar ch, Qt::CaseSensitivity cs)
Removes every occurrence of the regular expression \a rx in the
string, and returns a reference to the string. For example:
- \snippet doc/src/snippets/qstring/main.cpp 39
+ \snippet qstring/main.cpp 39
\sa indexOf(), lastIndexOf(), replace()
*/
@@ -1725,7 +1725,7 @@ QString &QString::remove(QChar ch, Qt::CaseSensitivity cs)
Removes every occurrence of the regular expression \a re in the
string, and returns a reference to the string. For example:
- \snippet doc/src/snippets/qstring/main.cpp 96
+ \snippet qstring/main.cpp 96
\sa indexOf(), lastIndexOf(), replace()
*/
@@ -1738,7 +1738,7 @@ QString &QString::remove(QChar ch, Qt::CaseSensitivity cs)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 40
+ \snippet qstring/main.cpp 40
\sa insert(), remove()
*/
@@ -1789,13 +1789,13 @@ QString &QString::replace(int pos, int len, QChar after)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 41
+ \snippet qstring/main.cpp 41
\note The replacement text is not rescanned after it is inserted.
Example:
- \snippet doc/src/snippets/qstring/main.cpp 86
+ \snippet qstring/main.cpp 86
*/
QString &QString::replace(const QString &before, const QString &after, Qt::CaseSensitivity cs)
{
@@ -2214,7 +2214,7 @@ bool QString::operator<(const QLatin1String &other) const
\overload operator<()
The \a other byte array is converted to a QString using the
- fromAscii() function. If any NUL characters ('\0') are embedded
+ fromAscii() function. If any NUL characters ('\\0') are embedded
in the byte array, they will be included in the transformation.
You can disable this operator by defining \c
@@ -2236,8 +2236,7 @@ bool QString::operator<(const QLatin1String &other) const
go through QObject::tr(), for example.
*/
-/*! \fn bool operator<=(const QString &s1, const QString &s2)
- \relates QString
+/*! \fn bool QString::operator<=(const QString &s1, const QString &s2)
Returns true if string \a s1 is lexically less than or equal to
string \a s2; otherwise returns false.
@@ -2258,7 +2257,7 @@ bool QString::operator<(const QLatin1String &other) const
\overload operator<=()
The \a other byte array is converted to a QString using the
- fromAscii() function. If any NUL characters ('\0') are embedded
+ fromAscii() function. If any NUL characters ('\\0') are embedded
in the byte array, they will be included in the transformation.
You can disable this operator by defining \c
@@ -2280,8 +2279,7 @@ bool QString::operator<(const QLatin1String &other) const
go through QObject::tr(), for example.
*/
-/*! \fn bool operator>(const QString &s1, const QString &s2)
- \relates QString
+/*! \fn bool QString::operator>(const QString &s1, const QString &s2)
Returns true if string \a s1 is lexically greater than string \a
s2; otherwise returns false.
@@ -2318,7 +2316,7 @@ bool QString::operator>(const QLatin1String &other) const
\overload operator>()
The \a other byte array is converted to a QString using the
- fromAscii() function. If any NUL characters ('\0') are embedded
+ fromAscii() function. If any NUL characters ('\\0') are embedded
in the byte array, they will be included in the transformation.
You can disable this operator by defining \c
@@ -2362,7 +2360,7 @@ bool QString::operator>(const QLatin1String &other) const
\overload operator>=()
The \a other byte array is converted to a QString using the
- fromAscii() function. If any NUL characters ('\0') are embedded in
+ fromAscii() function. If any NUL characters ('\\0') are embedded in
the byte array, they will be included in the transformation.
You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII
@@ -2406,7 +2404,7 @@ bool QString::operator>(const QLatin1String &other) const
\overload operator!=()
The \a other byte array is converted to a QString using the
- fromAscii() function. If any NUL characters ('\0') are embedded
+ fromAscii() function. If any NUL characters ('\\0') are embedded
in the byte array, they will be included in the transformation.
You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII
@@ -2438,7 +2436,7 @@ bool QString::operator>(const QLatin1String &other) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 24
+ \snippet qstring/main.cpp 24
If \a from is -1, the search starts at the last character; if it is
-2, at the next to last character and so on.
@@ -2461,7 +2459,7 @@ int QString::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 24
+ \snippet qstring/main.cpp 24
If \a from is -1, the search starts at the last character; if it is
-2, at the next to last character and so on.
@@ -2636,7 +2634,7 @@ static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *nee
Example:
- \snippet doc/src/snippets/qstring/main.cpp 29
+ \snippet qstring/main.cpp 29
\sa indexOf(), contains(), count()
*/
@@ -2675,7 +2673,7 @@ int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) c
Example:
- \snippet doc/src/snippets/qstring/main.cpp 29
+ \snippet qstring/main.cpp 29
\sa indexOf(), contains(), count()
*/
@@ -2765,13 +2763,13 @@ struct QStringCapture
string with \a after. Returns a reference to the string. For
example:
- \snippet doc/src/snippets/qstring/main.cpp 42
+ \snippet qstring/main.cpp 42
For regular expressions containing \l{capturing parentheses},
occurrences of \b{\\1}, \b{\\2}, ..., in \a after are replaced
with \a{rx}.cap(1), cap(2), ...
- \snippet doc/src/snippets/qstring/main.cpp 43
+ \snippet qstring/main.cpp 43
\sa indexOf(), lastIndexOf(), remove(), QRegExp::cap()
*/
@@ -2923,13 +2921,13 @@ QString& QString::replace(const QRegExp &rx, const QString &after)
string with \a after. Returns a reference to the string. For
example:
- \snippet doc/src/snippets/qstring/main.cpp 87
+ \snippet qstring/main.cpp 87
For regular expressions containing capturing groups,
- occurrences of \bold{\\1}, \bold{\\2}, ..., in \a after are replaced
+ occurrences of \b{\\1}, \b{\\2}, ..., in \a after are replaced
with the string captured by the corresponding capturing group.
- \snippet doc/src/snippets/qstring/main.cpp 88
+ \snippet qstring/main.cpp 88
\sa indexOf(), lastIndexOf(), remove(), QRegularExpression, QRegularExpressionMatch
*/
@@ -3097,7 +3095,7 @@ int QString::count(const QStringRef &str, Qt::CaseSensitivity cs) const
case sensitive; otherwise the search is case insensitive.
Example:
- \snippet doc/src/snippets/qstring/main.cpp 17
+ \snippet qstring/main.cpp 17
\sa indexOf(), count()
*/
@@ -3151,7 +3149,7 @@ int QString::count(const QStringRef &str, Qt::CaseSensitivity cs) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 25
+ \snippet qstring/main.cpp 25
*/
int QString::indexOf(const QRegExp& rx, int from) const
{
@@ -3172,7 +3170,7 @@ int QString::indexOf(const QRegExp& rx, int from) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 25
+ \snippet qstring/main.cpp 25
*/
int QString::indexOf(QRegExp& rx, int from) const
{
@@ -3188,7 +3186,7 @@ int QString::indexOf(QRegExp& rx, int from) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 30
+ \snippet qstring/main.cpp 30
*/
int QString::lastIndexOf(const QRegExp& rx, int from) const
{
@@ -3209,7 +3207,7 @@ int QString::lastIndexOf(const QRegExp& rx, int from) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 30
+ \snippet qstring/main.cpp 30
*/
int QString::lastIndexOf(QRegExp& rx, int from) const
{
@@ -3225,7 +3223,7 @@ int QString::lastIndexOf(QRegExp& rx, int from) const
This function counts overlapping matches, so in the example
below, there are four instances of "ana" or "ama":
- \snippet doc/src/snippets/qstring/main.cpp 18
+ \snippet qstring/main.cpp 18
*/
int QString::count(const QRegExp& rx) const
@@ -3256,7 +3254,7 @@ int QString::count(const QRegExp& rx) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 93
+ \snippet qstring/main.cpp 93
*/
int QString::indexOf(const QRegularExpression& re, int from) const
{
@@ -3282,7 +3280,7 @@ int QString::indexOf(const QRegularExpression& re, int from) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 94
+ \snippet qstring/main.cpp 94
*/
int QString::lastIndexOf(const QRegularExpression &re, int from) const
{
@@ -3333,7 +3331,7 @@ bool QString::contains(const QRegularExpression &re) const
This function counts overlapping matches, so in the example
below, there are four instances of "ana" or "ama":
- \snippet doc/src/snippets/qstring/main.cpp 95
+ \snippet qstring/main.cpp 95
*/
int QString::count(const QRegularExpression &re) const
{
@@ -3408,13 +3406,13 @@ int QString::count(const QRegularExpression &re) const
to skip empty fields and how to deal with leading and trailing
separators; see \l{SectionFlags}.
- \snippet doc/src/snippets/qstring/main.cpp 52
+ \snippet qstring/main.cpp 52
If \a start or \a end is negative, we count fields from the right
of the string, the right-most field being -1, the one from
right-most field being -2, and so on.
- \snippet doc/src/snippets/qstring/main.cpp 53
+ \snippet qstring/main.cpp 53
\sa split()
*/
@@ -3422,8 +3420,8 @@ int QString::count(const QRegularExpression &re) const
/*!
\overload section()
- \snippet doc/src/snippets/qstring/main.cpp 51
- \snippet doc/src/snippets/qstring/main.cpp 54
+ \snippet qstring/main.cpp 51
+ \snippet qstring/main.cpp 54
\sa split()
*/
@@ -3532,12 +3530,12 @@ static QString extractSections(const QList<qt_section_chunk> &sections,
This string is treated as a sequence of fields separated by the
regular expression, \a reg.
- \snippet doc/src/snippets/qstring/main.cpp 55
+ \snippet qstring/main.cpp 55
\warning Using this QRegExp version is much more expensive than
the overloaded string and character versions.
- \sa split() simplified()
+ \sa split(), simplified()
*/
QString QString::section(const QRegExp &reg, int start, int end, SectionFlags flags) const
{
@@ -3572,12 +3570,12 @@ QString QString::section(const QRegExp &reg, int start, int end, SectionFlags fl
This string is treated as a sequence of fields separated by the
regular expression, \a re.
- \snippet doc/src/snippets/qstring/main.cpp 89
+ \snippet qstring/main.cpp 89
\warning Using this QRegularExpression version is much more expensive than
the overloaded string and character versions.
- \sa split() simplified()
+ \sa split(), simplified()
*/
QString QString::section(const QRegularExpression &re, int start, int end, SectionFlags flags) const
{
@@ -3618,7 +3616,7 @@ QString QString::section(const QRegularExpression &re, int start, int end, Secti
The entire string is returned if \a n is greater than size() or
less than zero.
- \snippet doc/src/snippets/qstring/main.cpp 31
+ \snippet qstring/main.cpp 31
\sa right(), mid(), startsWith()
*/
@@ -3636,7 +3634,7 @@ QString QString::left(int n) const
The entire string is returned if \a n is greater than size() or
less than zero.
- \snippet doc/src/snippets/qstring/main.cpp 48
+ \snippet qstring/main.cpp 48
\sa left(), mid(), endsWith()
*/
@@ -3659,7 +3657,7 @@ QString QString::right(int n) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 34
+ \snippet qstring/main.cpp 34
\sa left(), right()
*/
@@ -3690,7 +3688,7 @@ QString QString::mid(int position, int n) const
If \a cs is Qt::CaseSensitive (default), the search is
case sensitive; otherwise the search is case insensitive.
- \snippet doc/src/snippets/qstring/main.cpp 65
+ \snippet qstring/main.cpp 65
\sa endsWith()
*/
@@ -3746,7 +3744,7 @@ bool QString::startsWith(const QStringRef &s, Qt::CaseSensitivity cs) const
If \a cs is Qt::CaseSensitive (default), the search is case
sensitive; otherwise the search is case insensitive.
- \snippet doc/src/snippets/qstring/main.cpp 20
+ \snippet qstring/main.cpp 20
\sa startsWith()
*/
@@ -4248,7 +4246,7 @@ QString& QString::setUnicode(const QChar *unicode, int size)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 57
+ \snippet qstring/main.cpp 57
\sa trimmed()
*/
@@ -4338,7 +4336,7 @@ QString QString::simplified() const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 82
+ \snippet qstring/main.cpp 82
Unlike simplified(), trimmed() leaves internal whitespace alone.
@@ -4386,7 +4384,7 @@ QString QString::trimmed() const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 85
+ \snippet qstring/main.cpp 85
The return value is of type QCharRef, a helper class for QString.
When you get an object of type QCharRef, you can use it as if it
@@ -4425,7 +4423,7 @@ modifiable reference. Equivalent to \c at(position).
Example:
- \snippet doc/src/snippets/qstring/main.cpp 83
+ \snippet qstring/main.cpp 83
If \a position is negative, it is equivalent to passing zero.
@@ -4445,7 +4443,7 @@ void QString::truncate(int pos)
If \a n is greater than size(), the result is an empty string.
Example:
- \snippet doc/src/snippets/qstring/main.cpp 15
+ \snippet qstring/main.cpp 15
If you want to remove characters from the \e beginning of the
string, use remove() instead.
@@ -4465,7 +4463,7 @@ void QString::chop(int n)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 21
+ \snippet qstring/main.cpp 21
\sa resize()
*/
@@ -4504,7 +4502,7 @@ QString& QString::fill(QChar ch, int size)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 58
+ \snippet qstring/main.cpp 58
\sa isEmpty(), resize()
*/
@@ -4515,7 +4513,7 @@ QString& QString::fill(QChar ch, int size)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 28
+ \snippet qstring/main.cpp 28
Qt makes a distinction between null strings and empty strings for
historical reasons. For most applications, what matters is
@@ -4532,7 +4530,7 @@ QString& QString::fill(QChar ch, int size)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 27
+ \snippet qstring/main.cpp 27
\sa size()
*/
@@ -4544,7 +4542,7 @@ QString& QString::fill(QChar ch, int size)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 84
+ \snippet qstring/main.cpp 84
This operation is typically very fast (\l{constant time}),
because QString preallocates extra space at the end of the string
@@ -4566,7 +4564,7 @@ QString& QString::fill(QChar ch, int size)
\overload operator+=()
Appends the byte array \a ba to this string. The byte array is converted
- to Unicode using the fromAscii() function. If any NUL characters ('\0')
+ to Unicode using the fromAscii() function. If any NUL characters ('\\0')
are embedded in the \a ba byte array, they will be included in the
transformation.
@@ -4773,7 +4771,7 @@ QString& QString::fill(QChar ch, int size)
a human would expect. Consider sorting user-visible strings with
localeAwareCompare().
- \snippet doc/src/snippets/qstring/main.cpp 16
+ \snippet qstring/main.cpp 16
\sa operator==(), operator<(), operator>()
*/
@@ -5057,13 +5055,13 @@ const ushort *QString::utf16() const
If \a truncate is false and the size() of the string is more than
\a width, then the returned string is a copy of the string.
- \snippet doc/src/snippets/qstring/main.cpp 32
+ \snippet qstring/main.cpp 32
If \a truncate is true and the size() of the string is more than
\a width, then any characters in a copy of the string after
position \a width are removed, and the copy is returned.
- \snippet doc/src/snippets/qstring/main.cpp 33
+ \snippet qstring/main.cpp 33
\sa rightJustified()
*/
@@ -5093,7 +5091,7 @@ QString QString::leftJustified(int width, QChar fill, bool truncate) const
Returns a string of size() \a width that contains the \a fill
character followed by the string. For example:
- \snippet doc/src/snippets/qstring/main.cpp 49
+ \snippet qstring/main.cpp 49
If \a truncate is false and the size() of the string is more than
\a width, then the returned string is a copy of the string.
@@ -5102,7 +5100,7 @@ QString QString::leftJustified(int width, QChar fill, bool truncate) const
\a width, then the resulting string is truncated at position \a
width.
- \snippet doc/src/snippets/qstring/main.cpp 50
+ \snippet qstring/main.cpp 50
\sa leftJustified()
*/
@@ -5131,7 +5129,7 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const
/*!
Returns a lowercase copy of the string.
- \snippet doc/src/snippets/qstring/main.cpp 75
+ \snippet qstring/main.cpp 75
The case conversion will always happen in the 'C' locale. For locale dependent
case folding use QLocale::toLower()
@@ -5233,7 +5231,20 @@ QString QString::toCaseFolded() const
prop = qGetProp(*p);
}
if (prop->caseFoldSpecial) {
+ const ushort *specialCase = specialCaseMap + prop->caseFoldDiff;
+ ushort length = *specialCase++;
+#if 0
+ int pos = pp - s.d->data;
+ s.resize(s.d->size + length - 1);
+ pp = s.d->data + pos;
+ while (length--)
+ *pp++ = *specialCase++;
+#else
//### we currently don't support full case foldings
+ Q_ASSERT(length == 1);
+ Q_UNUSED(length)
+ *pp++ = *specialCase;
+#endif
} else {
*pp++ = *p + prop->caseFoldDiff;
}
@@ -5254,7 +5265,7 @@ QString QString::toCaseFolded() const
/*!
Returns an uppercase copy of the string.
- \snippet doc/src/snippets/qstring/main.cpp 81
+ \snippet qstring/main.cpp 81
The case conversion will always happen in the 'C' locale. For locale dependent
case folding use QLocale::toUpper()
@@ -5337,14 +5348,14 @@ QString QString::toUpper() const
\c{long long}). If you need those, use the standard snprintf()
function instead:
- \snippet doc/src/snippets/qstring/main.cpp 63
+ \snippet qstring/main.cpp 63
\warning We do not recommend using QString::sprintf() in new Qt
code. Instead, consider using QTextStream or arg(), both of
which support Unicode strings seamlessly and are type-safe.
Here's an example that uses QTextStream:
- \snippet doc/src/snippets/qstring/main.cpp 64
+ \snippet qstring/main.cpp 64
For \l {QObject::tr()}{translations}, especially if the strings
contains more than one escape sequence, you should consider using
@@ -5552,7 +5563,7 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
case lm_t: i = va_arg(ap, int); break;
default: i = 0; break;
}
- subst = locale.d()->longLongToString(i, precision, 10, width, flags);
+ subst = locale.d->longLongToString(i, precision, 10, width, flags);
++c;
break;
}
@@ -5584,7 +5595,7 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
base = 16; break;
default: break;
}
- subst = locale.d()->unsLongLongToString(u, precision, base, width, flags);
+ subst = locale.d->unsLongLongToString(u, precision, base, width, flags);
++c;
break;
}
@@ -5613,7 +5624,7 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
case 'g': form = QLocalePrivate::DFSignificantDigits; break;
default: break;
}
- subst = locale.d()->doubleToString(d, precision, form, width, flags);
+ subst = locale.d->doubleToString(d, precision, form, width, flags);
++c;
break;
}
@@ -5647,7 +5658,7 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
quint64 i = reinterpret_cast<unsigned long>(arg);
#endif
flags |= QLocalePrivate::Alternate;
- subst = locale.d()->unsLongLongToString(i, precision, 16, width, flags);
+ subst = locale.d->unsLongLongToString(i, precision, 16, width, flags);
++c;
break;
}
@@ -5717,7 +5728,7 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 74
+ \snippet qstring/main.cpp 74
\sa number(), toULongLong(), toInt(), QLocale::toLongLong()
*/
@@ -5732,7 +5743,7 @@ qint64 QString::toLongLong(bool *ok, int base) const
#endif
QLocale c_locale(QLocale::C);
- return c_locale.d()->stringToLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);
+ return c_locale.d->stringToLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);
}
/*!
@@ -5752,7 +5763,7 @@ qint64 QString::toLongLong(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 79
+ \snippet qstring/main.cpp 79
\sa number(), toLongLong(), QLocale::toULongLong()
*/
@@ -5767,7 +5778,7 @@ quint64 QString::toULongLong(bool *ok, int base) const
#endif
QLocale c_locale(QLocale::C);
- return c_locale.d()->stringToUnsLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);
+ return c_locale.d->stringToUnsLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);
}
/*!
@@ -5789,7 +5800,7 @@ quint64 QString::toULongLong(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 73
+ \snippet qstring/main.cpp 73
\sa number(), toULong(), toInt(), QLocale::toLong()
*/
@@ -5824,7 +5835,7 @@ long QString::toLong(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 78
+ \snippet qstring/main.cpp 78
\sa number(), QLocale::toULong()
*/
@@ -5858,7 +5869,7 @@ ulong QString::toULong(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 72
+ \snippet qstring/main.cpp 72
\sa number(), toUInt(), toDouble(), QLocale::toInt()
*/
@@ -5891,7 +5902,7 @@ int QString::toInt(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 77
+ \snippet qstring/main.cpp 77
\sa number(), toInt(), QLocale::toUInt()
*/
@@ -5924,7 +5935,7 @@ uint QString::toUInt(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 76
+ \snippet qstring/main.cpp 76
\sa number(), toUShort(), toInt(), QLocale::toShort()
*/
@@ -5957,7 +5968,7 @@ short QString::toShort(bool *ok, int base) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 80
+ \snippet qstring/main.cpp 80
\sa number(), toShort(), QLocale::toUShort()
*/
@@ -5982,31 +5993,31 @@ ushort QString::toUShort(bool *ok, int base) const
If a conversion error occurs, \c{*}\a{ok} is set to false;
otherwise \c{*}\a{ok} is set to true.
- \snippet doc/src/snippets/qstring/main.cpp 66
+ \snippet qstring/main.cpp 66
Various string formats for floating point numbers can be converted
to double values:
- \snippet doc/src/snippets/qstring/main.cpp 67
+ \snippet qstring/main.cpp 67
The string conversion will always happen in the 'C' locale. For locale
dependent conversion use QLocale::toDouble()
- \snippet doc/src/snippets/qstring/main.cpp 68
+ \snippet qstring/main.cpp 68
For historic reasons, this function does not handle
thousands group separators. If you need to convert such numbers,
use QLocale::toDouble().
- \snippet doc/src/snippets/qstring/main.cpp 69
+ \snippet qstring/main.cpp 69
- \sa number() QLocale::setDefault() QLocale::toDouble() trimmed()
+ \sa number(), QLocale::setDefault(), QLocale::toDouble(), trimmed()
*/
double QString::toDouble(bool *ok) const
{
QLocale c_locale(QLocale::C);
- return c_locale.d()->stringToDouble(*this, ok, QLocalePrivate::FailOnGroupSeparators);
+ return c_locale.d->stringToDouble(*this, ok, QLocalePrivate::FailOnGroupSeparators);
}
/*!
@@ -6020,7 +6031,7 @@ double QString::toDouble(bool *ok) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 71
+ \snippet qstring/main.cpp 71
\sa number(), toDouble(), toInt(), QLocale::toFloat()
*/
@@ -6049,7 +6060,7 @@ float QString::toFloat(bool *ok) const
The base is 10 by default and must be between 2 and 36. For bases
other than 10, \a n is treated as an unsigned integer.
- \snippet doc/src/snippets/qstring/main.cpp 56
+ \snippet qstring/main.cpp 56
The formatting always uses QLocale::C, i.e., English/UnitedStates.
To get a localized string representation of a number, use
@@ -6083,7 +6094,7 @@ QString &QString::setNum(qlonglong n, int base)
}
#endif
QLocale locale(QLocale::C);
- *this = locale.d()->longLongToString(n, -1, base);
+ *this = locale.d->longLongToString(n, -1, base);
return *this;
}
@@ -6099,7 +6110,7 @@ QString &QString::setNum(qulonglong n, int base)
}
#endif
QLocale locale(QLocale::C);
- *this = locale.d()->unsLongLongToString(n, -1, base);
+ *this = locale.d->unsLongLongToString(n, -1, base);
return *this;
}
@@ -6156,7 +6167,7 @@ QString &QString::setNum(double n, char f, int prec)
}
QLocale locale(QLocale::C);
- *this = locale.d()->doubleToString(n, prec, form, -1, flags);
+ *this = locale.d->doubleToString(n, prec, form, -1, flags);
return *this;
}
@@ -6188,7 +6199,7 @@ QString &QString::setNum(double n, char f, int prec)
To get a localized string representation of a number, use
QLocale::toString() with the appropriate locale.
- \snippet doc/src/snippets/qstring/main.cpp 35
+ \snippet qstring/main.cpp 35
\sa setNum()
*/
@@ -6286,7 +6297,7 @@ QString QString::number(double n, char f, int prec)
Example:
- \snippet doc/src/snippets/qstring/main.cpp 62
+ \snippet qstring/main.cpp 62
\sa QStringList::join(), section()
*/
@@ -6337,18 +6348,18 @@ QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivit
Here's an example where we extract the words in a sentence
using one or more whitespace characters as the separator:
- \snippet doc/src/snippets/qstring/main.cpp 59
+ \snippet qstring/main.cpp 59
Here's a similar example, but this time we use any sequence of
non-word characters as the separator:
- \snippet doc/src/snippets/qstring/main.cpp 60
+ \snippet qstring/main.cpp 60
Here's a third example where we use a zero-length assertion,
\b{\\b} (word boundary), to split the string into an
alternating sequence of non-word and word tokens:
- \snippet doc/src/snippets/qstring/main.cpp 61
+ \snippet qstring/main.cpp 61
\sa QStringList::join(), section()
*/
@@ -6386,18 +6397,18 @@ QStringList QString::split(const QRegExp &rx, SplitBehavior behavior) const
Here's an example where we extract the words in a sentence
using one or more whitespace characters as the separator:
- \snippet doc/src/snippets/qstring/main.cpp 90
+ \snippet qstring/main.cpp 90
Here's a similar example, but this time we use any sequence of
non-word characters as the separator:
- \snippet doc/src/snippets/qstring/main.cpp 91
+ \snippet qstring/main.cpp 91
Here's a third example where we use a zero-length assertion,
- \bold{\\b} (word boundary), to split the string into an
+ \b{\\b} (word boundary), to split the string into an
alternating sequence of non-word and word tokens:
- \snippet doc/src/snippets/qstring/main.cpp 92
+ \snippet qstring/main.cpp 92
\sa QStringList::join(), section()
*/
@@ -6738,7 +6749,7 @@ static QString replaceArgEscapes(const QString &s, const ArgEscapeData &d, int f
This example shows how we might create a \c status string for
reporting progress while processing a list of files:
- \snippet doc/src/snippets/qstring/main.cpp 11
+ \snippet qstring/main.cpp 11
First, \c arg(i) replaces \c %1. Then \c arg(total) replaces \c
%2. Finally, \c arg(fileName) replaces \c %3.
@@ -6774,7 +6785,7 @@ QString QString::arg(const QString &a, int fieldWidth, QChar fillChar) const
strings \a a1 and \a a2 are replaced in one pass. This can make a
difference if \a a1 contains e.g. \c{%1}:
- \snippet doc/src/snippets/qstring/main.cpp 13
+ \snippet qstring/main.cpp 13
*/
/*!
@@ -6861,8 +6872,8 @@ QString QString::arg(const QString &a, int fieldWidth, QChar fillChar) const
locale was specified, the "C" locale is used. The 'L' flag is
ignored if \a base is not 10.
- \snippet doc/src/snippets/qstring/main.cpp 12
- \snippet doc/src/snippets/qstring/main.cpp 14
+ \snippet qstring/main.cpp 12
+ \snippet qstring/main.cpp 14
If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is
used. For negative numbers, zero padding might appear before the
@@ -6898,8 +6909,8 @@ QString QString::arg(const QString &a, int fieldWidth, QChar fillChar) const
using QLocale::setDefault(). The 'L' flag is ignored if \a base is
not 10.
- \snippet doc/src/snippets/qstring/main.cpp 12
- \snippet doc/src/snippets/qstring/main.cpp 14
+ \snippet qstring/main.cpp 12
+ \snippet qstring/main.cpp 14
If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is
used. For negative numbers, zero padding might appear before the
@@ -6954,14 +6965,14 @@ QString QString::arg(qlonglong a, int fieldWidth, int base, QChar fillChar) cons
QString arg;
if (d.occurrences > d.locale_occurrences)
- arg = QLocale::c().d()->longLongToString(a, -1, base, fieldWidth, flags);
+ arg = QLocale::c().d->longLongToString(a, -1, base, fieldWidth, flags);
QString locale_arg;
if (d.locale_occurrences > 0) {
QLocale locale;
if (!locale.numberOptions() & QLocale::OmitGroupSeparator)
flags |= QLocalePrivate::ThousandsGroup;
- locale_arg = locale.d()->longLongToString(a, -1, base, fieldWidth, flags);
+ locale_arg = locale.d->longLongToString(a, -1, base, fieldWidth, flags);
}
return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);
@@ -6998,14 +7009,14 @@ QString QString::arg(qulonglong a, int fieldWidth, int base, QChar fillChar) con
QString arg;
if (d.occurrences > d.locale_occurrences)
- arg = QLocale::c().d()->unsLongLongToString(a, -1, base, fieldWidth, flags);
+ arg = QLocale::c().d->unsLongLongToString(a, -1, base, fieldWidth, flags);
QString locale_arg;
if (d.locale_occurrences > 0) {
QLocale locale;
if (!locale.numberOptions() & QLocale::OmitGroupSeparator)
flags |= QLocalePrivate::ThousandsGroup;
- locale_arg = locale.d()->unsLongLongToString(a, -1, base, fieldWidth, flags);
+ locale_arg = locale.d->unsLongLongToString(a, -1, base, fieldWidth, flags);
}
return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);
@@ -7082,7 +7093,7 @@ QString QString::arg(char a, int fieldWidth, QChar fillChar) const
value produces right-aligned text; a negative value produces
left-aligned text.
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 2
+ \snippet code/src_corelib_tools_qstring.cpp 2
The '%' can be followed by an 'L', in which case the sequence is
replaced with a localized representation of \a a. The conversion
@@ -7132,7 +7143,7 @@ QString QString::arg(double a, int fieldWidth, char fmt, int prec, QChar fillCha
QString arg;
if (d.occurrences > d.locale_occurrences)
- arg = QLocale::c().d()->doubleToString(a, prec, form, fieldWidth, flags);
+ arg = QLocale::c().d->doubleToString(a, prec, form, fieldWidth, flags);
QString locale_arg;
if (d.locale_occurrences > 0) {
@@ -7140,7 +7151,7 @@ QString QString::arg(double a, int fieldWidth, char fmt, int prec, QChar fillCha
if (!locale.numberOptions() & QLocale::OmitGroupSeparator)
flags |= QLocalePrivate::ThousandsGroup;
- locale_arg = locale.d()->doubleToString(a, prec, form, fieldWidth, flags);
+ locale_arg = locale.d->doubleToString(a, prec, form, fieldWidth, flags);
}
return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);
@@ -7278,7 +7289,7 @@ bool QString::isRightToLeft() const
Example:
- \snippet doc/src/snippets/qstring/main.cpp 19
+ \snippet qstring/main.cpp 19
Note that the pointer remains valid only as long as the string is
not modified by other means. For read-only access, constData() is
@@ -7366,8 +7377,8 @@ bool QString::isRightToLeft() const
Here's an example of how we can use a QRegExp on raw data in
memory without requiring to copy the data into a QString:
- \snippet doc/src/snippets/qstring/main.cpp 22
- \snippet doc/src/snippets/qstring/main.cpp 23
+ \snippet qstring/main.cpp 22
+ \snippet qstring/main.cpp 23
\warning A string created with fromRawData() is \e not
'\\0'-terminated, unless the raw data contains a '\\0' character
@@ -7438,11 +7449,11 @@ QString &QString::setRawData(const QChar *unicode, int size)
the \c{const char *} data. For example, assuming \c str is a
QString,
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 3
+ \snippet code/src_corelib_tools_qstring.cpp 3
is much faster than
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 4
+ \snippet code/src_corelib_tools_qstring.cpp 4
because it doesn't construct four temporary QString objects and
make a deep copy of the character data.
@@ -7454,7 +7465,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
just a very thin wrapper around a \c{const char *}. Using
QLatin1String, the example code above becomes
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 5
+ \snippet code/src_corelib_tools_qstring.cpp 5
This is a bit longer to type, but it provides exactly the same
benefits as the first version of the code, and is faster than
@@ -7464,7 +7475,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
QLatin1String can be used everywhere a QString is expected. For
example:
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 6
+ \snippet code/src_corelib_tools_qstring.cpp 6
\sa QString, QLatin1Char, QStringLiteral
*/
@@ -8332,7 +8343,7 @@ QString &QString::append(const QStringRef &str)
If \a n is greater than size() or less than zero, a reference to the entire
string is returned.
- \snippet doc/src/snippets/qstring/main.cpp leftRef
+ \snippet qstring/main.cpp leftRef
\sa left(), rightRef(), midRef(), startsWith()
*/
@@ -8352,7 +8363,7 @@ QStringRef QString::leftRef(int n) const
If \a n is greater than size() or less than zero, a reference to the entire
string is returned.
- \snippet doc/src/snippets/qstring/main.cpp rightRef
+ \snippet qstring/main.cpp rightRef
\sa right(), leftRef(), midRef(), endsWith()
*/
@@ -8379,7 +8390,7 @@ QStringRef QString::rightRef(int n) const
Example:
- \snippet doc/src/snippets/qstring/main.cpp midRef
+ \snippet qstring/main.cpp midRef
\sa mid(), leftRef(), rightRef()
*/
@@ -9123,7 +9134,7 @@ QVector<uint> QStringRef::toUcs4() const
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qstring.cpp 7
+ \snippet code/src_corelib_tools_qstring.cpp 7
*/
QString QString::toHtmlEscaped() const
{
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 9fcd203a3f..bbfb31aef3 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -448,10 +448,14 @@ public:
{
return fromLocal8Bit_helper(str, (str && size == -1) ? int(strlen(str)) : size);
}
- static inline QString fromAscii(const QByteArray &str) { return fromAscii(str.data(), str.size()); }
- static inline QString fromLatin1(const QByteArray &str) { return fromLatin1(str.data(), str.size()); }
- static inline QString fromUtf8(const QByteArray &str) { return fromUtf8(str.data(), str.size()); }
- static inline QString fromLocal8Bit(const QByteArray &str) { return fromLocal8Bit(str.data(), str.size()); }
+ static inline QString fromAscii(const QByteArray &str)
+ { return fromAscii(str.data(), qstrnlen(str.constData(), str.size())); }
+ static inline QString fromLatin1(const QByteArray &str)
+ { return fromLatin1(str.data(), qstrnlen(str.constData(), str.size())); }
+ static inline QString fromUtf8(const QByteArray &str)
+ { return fromUtf8(str.data(), qstrnlen(str.constData(), str.size())); }
+ static inline QString fromLocal8Bit(const QByteArray &str)
+ { return fromLocal8Bit(str.data(), qstrnlen(str.constData(), str.size())); }
static QString fromUtf16(const ushort *, int size = -1);
static QString fromUcs4(const uint *, int size = -1);
static QString fromRawData(const QChar *, int size);
@@ -572,13 +576,13 @@ public:
inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &s) const;
inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &s) const;
inline QT_ASCII_CAST_WARN bool operator<(const QByteArray &s) const
- { return *this < QString::fromAscii(s.constData(), s.size()); }
+ { return *this < QString::fromAscii(s); }
inline QT_ASCII_CAST_WARN bool operator>(const QByteArray &s) const
- { return *this > QString::fromAscii(s.constData(), s.size()); }
+ { return *this > QString::fromAscii(s); }
inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &s) const
- { return *this <= QString::fromAscii(s.constData(), s.size()); }
+ { return *this <= QString::fromAscii(s); }
inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &s) const
- { return *this >= QString::fromAscii(s.constData(), s.size()); }
+ { return *this >= QString::fromAscii(s); }
#endif
typedef QChar *iterator;
@@ -689,17 +693,30 @@ public:
{ return s >= *this; }
inline QT_ASCII_CAST_WARN bool operator==(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) == *this; }
+ { return QString::fromAscii(s) == *this; }
inline QT_ASCII_CAST_WARN bool operator!=(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) != *this; }
+ { return QString::fromAscii(s) != *this; }
inline QT_ASCII_CAST_WARN bool operator<(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) > *this; }
+ { return QString::fromAscii(s) > *this; }
inline QT_ASCII_CAST_WARN bool operator>(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) < *this; }
+ { return QString::fromAscii(s) < *this; }
inline QT_ASCII_CAST_WARN bool operator<=(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) >= *this; }
+ { return QString::fromAscii(s) >= *this; }
inline QT_ASCII_CAST_WARN bool operator>=(const char *s) const
- { return QString::fromAscii(s, s ? int(strlen(s)) : -1) <= *this; }
+ { return QString::fromAscii(s) <= *this; }
+
+ inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &s) const
+ { return QString::fromAscii(s) == *this; }
+ inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &s) const
+ { return QString::fromAscii(s) != *this; }
+ inline QT_ASCII_CAST_WARN bool operator<(const QByteArray &s) const
+ { return QString::fromAscii(s) > *this; }
+ inline QT_ASCII_CAST_WARN bool operator>(const QByteArray &s) const
+ { return QString::fromAscii(s) < *this; }
+ inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &s) const
+ { return QString::fromAscii(s) >= *this; }
+ inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &s) const
+ { return QString::fromAscii(s) <= *this; }
private:
int m_size;
const char *m_data;
@@ -1016,14 +1033,14 @@ inline bool operator>=(const QLatin1String &s1, const QLatin1String &s2)
inline bool QString::operator==(const QByteArray &s) const
-{ return qStringComparisonHelper(*this, s.constData()); }
+{ return qStringComparisonHelper(*this, s); }
inline bool QString::operator!=(const QByteArray &s) const
-{ return !qStringComparisonHelper(*this, s.constData()); }
+{ return !qStringComparisonHelper(*this, s); }
inline bool QByteArray::operator==(const QString &s) const
-{ return qStringComparisonHelper(s, constData()); }
+{ return qStringComparisonHelper(s, *this); }
inline bool QByteArray::operator!=(const QString &s) const
-{ return !qStringComparisonHelper(s, constData()); }
+{ return !qStringComparisonHelper(s, *this); }
inline bool QByteArray::operator<(const QString &s) const
{ return QString::fromAscii(constData(), size()) < s; }
inline bool QByteArray::operator>(const QString &s) const
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index 6999972172..a044cca3c9 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -95,7 +95,7 @@ QT_BEGIN_NAMESPACE
\c QChar, \c QCharRef, \c QLatin1Char, and \c char.
*/
-/*! \fn QByteArray QStringBuilder::toLatin1() const
+/* \fn QByteArray QStringBuilder::toLatin1() const
Returns a Latin-1 representation of the string as a QByteArray. The
returned byte array is undefined if the string contains non-Latin1
characters.
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp
index bfe2c5ec2d..c25d326b9d 100644
--- a/src/corelib/tools/qstringlist.cpp
+++ b/src/corelib/tools/qstringlist.cpp
@@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE
{QList::operator+=()}{operator+=()} and \l
{QStringList::operator<<()}{operator<<()} functions. For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 0
+ \snippet qstringlist/main.cpp 0
\section1 Iterating over the strings
@@ -111,15 +111,15 @@ QT_BEGIN_NAMESPACE
Indexing:
- \snippet doc/src/snippets/qstringlist/main.cpp 1
+ \snippet qstringlist/main.cpp 1
Java-style iterator:
- \snippet doc/src/snippets/qstringlist/main.cpp 2
+ \snippet qstringlist/main.cpp 2
STL-style iterator:
- \snippet doc/src/snippets/qstringlist/main.cpp 3
+ \snippet qstringlist/main.cpp 3
The QStringListIterator class is simply a type definition for
QListIterator<QString>. QStringList also provide the
@@ -133,12 +133,12 @@ QT_BEGIN_NAMESPACE
string list into a single string (with an optional separator)
using the join() function. For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 4
+ \snippet qstringlist/main.cpp 4
To break up a string into a string list, use the QString::split()
function:
- \snippet doc/src/snippets/qstringlist/main.cpp 6
+ \snippet qstringlist/main.cpp 6
The argument to split can be a single character, a string, or a
QRegExp.
@@ -152,7 +152,7 @@ QT_BEGIN_NAMESPACE
contain a particular substring (or match a particular regular
expression):
- \snippet doc/src/snippets/qstringlist/main.cpp 7
+ \snippet qstringlist/main.cpp 7
The contains() function tells you whether the list contains a
given string, while the indexOf() function returns the index of
@@ -163,7 +163,7 @@ QT_BEGIN_NAMESPACE
Finally, the replaceInStrings() function calls QString::replace()
on each string in the string list in turn. For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 8
+ \snippet qstringlist/main.cpp 8
\sa QString
*/
@@ -180,7 +180,7 @@ QT_BEGIN_NAMESPACE
Constructs a string list that contains the given string, \a
str. Longer lists are easily created like this:
- \snippet doc/src/snippets/qstringlist/main.cpp 9
+ \snippet qstringlist/main.cpp 9
\sa append()
*/
@@ -255,13 +255,13 @@ void QtPrivate::QStringList_sort(QStringList *that, Qt::CaseSensitivity cs)
comparison is case sensitive; otherwise the comparison is case
insensitive.
- \snippet doc/src/snippets/qstringlist/main.cpp 5
- \snippet doc/src/snippets/qstringlist/main.cpp 10
+ \snippet qstringlist/main.cpp 5
+ \snippet qstringlist/main.cpp 10
This is equivalent to
- \snippet doc/src/snippets/qstringlist/main.cpp 11
- \snippet doc/src/snippets/qstringlist/main.cpp 12
+ \snippet qstringlist/main.cpp 11
+ \snippet qstringlist/main.cpp 12
\sa contains()
*/
@@ -348,8 +348,8 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegula
For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 5
- \snippet doc/src/snippets/qstringlist/main.cpp 13
+ \snippet qstringlist/main.cpp 5
+ \snippet qstringlist/main.cpp 13
\sa QString::replace()
*/
@@ -372,8 +372,8 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QString &b
For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 5
- \snippet doc/src/snippets/qstringlist/main.cpp 14
+ \snippet qstringlist/main.cpp 5
+ \snippet qstringlist/main.cpp 14
For regular expressions that contain \l{capturing parentheses},
occurrences of \b{\\1}, \b{\\2}, ..., in \a after are
@@ -381,8 +381,8 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QString &b
For example:
- \snippet doc/src/snippets/qstringlist/main.cpp 5
- \snippet doc/src/snippets/qstringlist/main.cpp 15
+ \snippet qstringlist/main.cpp 5
+ \snippet qstringlist/main.cpp 15
*/
void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &rx, const QString &after)
{
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp
index f0d8c248b4..0c1ed4de84 100644
--- a/src/corelib/tools/qtimeline.cpp
+++ b/src/corelib/tools/qtimeline.cpp
@@ -182,7 +182,7 @@ void QTimeLinePrivate::setCurrentTime(int msecs)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qtimeline.cpp 0
+ \snippet code/src_corelib_tools_qtimeline.cpp 0
You can also use QTimeLine with the
\l{Graphics View}{Graphics View framework} for
diff --git a/src/corelib/tools/qunicodetables.cpp b/src/corelib/tools/qunicodetables.cpp
index 9504e7168e..ea61d2090d 100644
--- a/src/corelib/tools/qunicodetables.cpp
+++ b/src/corelib/tools/qunicodetables.cpp
@@ -41,8 +41,12 @@
/* This file is autogenerated from the Unicode 5.0 database. Do not edit */
+#include "qunicodetables_p.h"
+
QT_BEGIN_NAMESPACE
+namespace QUnicodeTables {
+
static const unsigned short uc_property_trie[] = {
// 0 - 0x11000
@@ -3422,9 +3426,9 @@ static const unsigned short uc_property_trie[] = {
: (uc_property_trie[uc_property_trie[((ucs4 - 0x11000)>>8) + 0x880] + (ucs4 & 0xff)]))
#define GET_PROP_INDEX_UCS2(ucs2) \
-(uc_property_trie[uc_property_trie[ucs2>>5] + (ucs2 & 0x1f)])
+ (uc_property_trie[uc_property_trie[ucs2>>5] + (ucs2 & 0x1f)])
-static const QUnicodeTables::Properties uc_properties[] = {
+static const Properties uc_properties[] = {
{ 9, 19, 18, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0 },
{ 9, 15, 8, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3 },
{ 9, 30, 7, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1 },
@@ -4319,38 +4323,37 @@ static const QUnicodeTables::Properties uc_properties[] = {
{ 3, 10, 2, 0, 0, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7 },
{ 13, 11, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 18, 12, 0, 0, 0, -1, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 },
- { 12, 11, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 12, 11, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
-static inline const QUnicodeTables::Properties *qGetProp(uint ucs4)
+static inline const Properties *qGetProp(uint ucs4)
{
- int index = GET_PROP_INDEX(ucs4);
+ const int index = GET_PROP_INDEX(ucs4);
return uc_properties + index;
}
-static inline const QUnicodeTables::Properties *qGetProp(ushort ucs2)
+static inline const Properties *qGetProp(ushort ucs2)
{
- int index = GET_PROP_INDEX_UCS2(ucs2);
+ const int index = GET_PROP_INDEX_UCS2(ucs2);
return uc_properties + index;
}
-Q_CORE_EXPORT const QUnicodeTables::Properties * QT_FASTCALL QUnicodeTables::properties(uint ucs4)
+Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4)
{
- int index = GET_PROP_INDEX(ucs4);
- return uc_properties + index;
+ return qGetProp(ucs4);
}
-Q_CORE_EXPORT const QUnicodeTables::Properties * QT_FASTCALL QUnicodeTables::properties(ushort ucs2)
+Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2)
{
- int index = GET_PROP_INDEX_UCS2(ucs2);
- return uc_properties + index;
+ return qGetProp(ucs2);
}
-Q_CORE_EXPORT QUnicodeTables::LineBreakClass QT_FASTCALL QUnicodeTables::lineBreakClass(uint ucs4)
+Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4)
{
- return (QUnicodeTables::LineBreakClass)qGetProp(ucs4)->line_break_class;
+ return (LineBreakClass)qGetProp(ucs4)->line_break_class;
}
+
static const ushort specialCaseMap[] = {
0x0, // placeholder
0x2, 0x53, 0x73,
@@ -4449,7 +4452,7 @@ static const ushort specialCaseMap[] = {
0x3, 0x3a9, 0x342, 0x345,
0x3, 0x3a9, 0x342, 0x399
};
-#define SPECIAL_CASE_MAX_LEN 3
+
static const unsigned short uc_decomposition_trie[] = {
// 0 - 0x3400
@@ -5893,7 +5896,7 @@ static const unsigned short uc_decomposition_trie[] = {
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+ 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
};
#define GET_DECOMPOSITION_INDEX(ucs4) \
@@ -5904,7 +5907,6 @@ static const unsigned short uc_decomposition_trie[] = {
: 0xffff))
static const unsigned short uc_decomposition_map[] = {
-
0x103, 0x20, 0x210, 0x20, 0x308, 0x109, 0x61, 0x210,
0x20, 0x304, 0x109, 0x32, 0x109, 0x33, 0x210, 0x20,
0x301, 0x110, 0x3bc, 0x210, 0x20, 0x327, 0x109, 0x31,
@@ -7608,7 +7610,7 @@ static const unsigned short uc_decomposition_map[] = {
0xdd05, 0x201, 0xd868, 0xde0e, 0x201, 0xd868, 0xde91, 0x101,
0x9ebb, 0x101, 0x4d56, 0x101, 0x9ef9, 0x101, 0x9efe, 0x101,
0x9f05, 0x101, 0x9f0f, 0x101, 0x9f16, 0x101, 0x9f3b, 0x201,
- 0xd869, 0xde00,
+ 0xd869, 0xde00
};
static const unsigned short uc_ligature_trie[] = {
@@ -7766,13 +7768,13 @@ static const unsigned short uc_ligature_trie[] = {
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0x700, 0x761, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+ 0xffff, 0x700, 0x761, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
};
-#define GET_LIGATURE_INDEX(u2) (u2 < 0x3100 ? uc_ligature_trie[uc_ligature_trie[u2>>5] + (u2 & 0x1f)] : 0xffff);
+#define GET_LIGATURE_INDEX(u2) \
+ (u2 < 0x3100 ? uc_ligature_trie[uc_ligature_trie[u2>>5] + (u2 & 0x1f)] : 0xffff);
static const unsigned short uc_ligature_map[] = {
-
0x54, 0x41, 0xc0, 0x45, 0xc8, 0x49, 0xcc, 0x4e,
0x1f8, 0x4f, 0xd2, 0x55, 0xd9, 0x57, 0x1e80, 0x59,
0x1ef2, 0x61, 0xe0, 0x65, 0xe8, 0x69, 0xec, 0x6e,
@@ -8011,9 +8013,10 @@ static const unsigned short uc_ligature_map[] = {
0x30f7, 0x30f0, 0x30f8, 0x30f1, 0x30f9, 0x30f2, 0x30fa, 0x30fd,
0x30fe, 0xa, 0x306f, 0x3071, 0x3072, 0x3074, 0x3075, 0x3077,
0x3078, 0x307a, 0x307b, 0x307d, 0x30cf, 0x30d1, 0x30d2, 0x30d4,
- 0x30d5, 0x30d7, 0x30d8, 0x30da, 0x30db, 0x30dd,
+ 0x30d5, 0x30d7, 0x30d8, 0x30da, 0x30db, 0x30dd
};
+
struct NormalizationCorrection {
uint ucs4;
uint old_mapping;
@@ -8032,11 +8035,10 @@ static const NormalizationCorrection uc_normalization_corrections[] = {
enum { NumNormalizationCorrections = 6 };
enum { NormalizationCorrectionsVersionMax = 7 };
+
enum { UnicodeBlockCount = 512 }; // number of unicode blocks
enum { UnicodeBlockSize = 128 }; // size of each block
-namespace QUnicodeTables {
-
static const unsigned char uc_scripts[] = {
Common, /* U+0000-007f */
Common, /* U+0080-00ff */
@@ -9471,9 +9473,7 @@ static const unsigned char uc_scripts[] = {
Common, Common, Common, Common, Common, Common, Common, Common
};
-} // namespace QUnicodeTables
-
-Q_CORE_EXPORT int QT_FASTCALL QUnicodeTables::script(uint ucs4)
+Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
{
if (ucs4 > 0xffff)
return Common;
@@ -9485,4 +9485,8 @@ Q_CORE_EXPORT int QT_FASTCALL QUnicodeTables::script(uint ucs4)
return script;
}
+} // namespace QUnicodeTables
+
+using namespace QUnicodeTables;
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h
index 0b8115035c..50afebdd9c 100644
--- a/src/corelib/tools/qunicodetables_p.h
+++ b/src/corelib/tools/qunicodetables_p.h
@@ -76,7 +76,7 @@ namespace QUnicodeTables {
ushort lowerCaseSpecial : 1;
ushort upperCaseSpecial : 1;
ushort titleCaseSpecial : 1;
- ushort caseFoldSpecial : 1; /* currently unused */
+ ushort caseFoldSpecial : 1;
signed short mirrorDiff : 16;
signed short lowerCaseDiff : 16;
signed short upperCaseDiff : 16;
@@ -217,7 +217,7 @@ namespace QUnicodeTables {
};
- Q_CORE_EXPORT QUnicodeTables::LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4);
+ Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4);
inline int lineBreakClass(QChar ch)
{ return lineBreakClass(ch.unicode()); }
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 639d2463fd..58b26be4a9 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -180,8 +180,7 @@ private:
int s; // size
T *ptr; // data
union {
- // ### Qt 5: Use 'Prealloc * sizeof(T)' as array size
- char array[sizeof(qint64) * (((Prealloc * sizeof(T)) / sizeof(qint64)) + 1)];
+ char array[Prealloc * sizeof(T)];
qint64 q_for_alignment_1;
double q_for_alignment_2;
};
diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc
index e92f91aa47..748126012b 100644
--- a/src/corelib/tools/qvarlengtharray.qdoc
+++ b/src/corelib/tools/qvarlengtharray.qdoc
@@ -35,12 +35,12 @@
The C++ language doesn't support variable-length arrays on the stack.
For example, the following code won't compile:
- \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 0
+ \snippet code/doc_src_qvarlengtharray.cpp 0
The alternative is to allocate the array on the heap (with
\c{new}):
- \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 1
+ \snippet code/doc_src_qvarlengtharray.cpp 1
However, if myfunc() is called very frequently from the
application's inner loop, heap allocation can be a major source
@@ -53,7 +53,7 @@
it is much faster than heap allocation.
Example:
- \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 2
+ \snippet code/doc_src_qvarlengtharray.cpp 2
In the example above, QVarLengthArray will preallocate 1024
elements on the stack and use them unless \c{n + 1} is greater
@@ -260,7 +260,7 @@
be used to access and modify the items in the array.
Example:
- \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 3
+ \snippet code/doc_src_qvarlengtharray.cpp 3
The pointer remains valid as long as the array isn't reallocated.
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index 0026338047..20501f98ff 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -119,20 +119,20 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Here's an example of a QVector that stores integers and a QVector
that stores QString values:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 0
+ \snippet code/src_corelib_tools_qvector.cpp 0
QVector stores a vector (or array) of items. Typically, vectors
are created with an initial size. For example, the following code
constructs a QVector with 200 elements:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 1
+ \snippet code/src_corelib_tools_qvector.cpp 1
The elements are automatically initialized with a
\l{default-constructed value}. If you want to initialize the
vector with a different value, pass that value as the second
argument to the constructor:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 2
+ \snippet code/src_corelib_tools_qvector.cpp 2
You can also call fill() at any time to fill the vector with a
value.
@@ -142,11 +142,11 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
non-const vectors, operator[]() returns a reference to the item
that can be used on the left side of an assignment:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 3
+ \snippet code/src_corelib_tools_qvector.cpp 3
For read-only access, an alternative syntax is to use at():
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 4
+ \snippet code/src_corelib_tools_qvector.cpp 4
at() can be faster than operator[](), because it never causes a
\l{deep copy} to occur.
@@ -164,7 +164,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
backward. Both return the index of the matching item if they found
one; otherwise, they return -1. For example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 5
+ \snippet code/src_corelib_tools_qvector.cpp 5
If you simply want to check whether a vector contains a
particular value, use contains(). If you want to find out how
@@ -411,7 +411,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
can be used to access and modify the items in the vector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 6
+ \snippet code/src_corelib_tools_qvector.cpp 6
The pointer remains valid as long as the vector isn't
reallocated.
@@ -482,7 +482,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Inserts \a value at the end of the vector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 7
+ \snippet code/src_corelib_tools_qvector.cpp 7
This is the same as calling resize(size() + 1) and assigning \a
value to the new last element in the vector.
@@ -499,7 +499,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Inserts \a value at the beginning of the vector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 8
+ \snippet code/src_corelib_tools_qvector.cpp 8
This is the same as vector.insert(0, \a value).
@@ -519,7 +519,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
value is appended to the vector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 9
+ \snippet code/src_corelib_tools_qvector.cpp 9
For large vectors, this operation can be slow (\l{linear time}),
because it requires moving all the items at indexes \a i and
@@ -538,7 +538,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
vector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 10
+ \snippet code/src_corelib_tools_qvector.cpp 10
*/
/*! \fn QVector::iterator QVector::insert(iterator before, const T &value)
@@ -592,7 +592,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
size beforehand.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 11
+ \snippet code/src_corelib_tools_qvector.cpp 11
\sa resize()
*/
@@ -604,7 +604,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Returns -1 if no item matched.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 12
+ \snippet code/src_corelib_tools_qvector.cpp 12
This function requires the value type to have an implementation of
\c operator==().
@@ -620,7 +620,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
last item. Returns -1 if no item matched.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 13
+ \snippet code/src_corelib_tools_qvector.cpp 13
This function requires the value type to have an implementation of
\c operator==().
@@ -966,7 +966,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 14
+ \snippet code/src_corelib_tools_qvector.cpp 14
\sa fromList(), QList::fromVector()
*/
@@ -977,7 +977,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 15
+ \snippet code/src_corelib_tools_qvector.cpp 15
\sa toList(), QList::toVector()
*/
@@ -989,7 +989,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 16
+ \snippet code/src_corelib_tools_qvector.cpp 16
\sa toStdVector(), QList::fromStdList()
*/
@@ -999,7 +999,7 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
Returns a std::vector object with the data contained in this QVector.
Example:
- \snippet doc/src/snippets/code/src_corelib_tools_qvector.cpp 17
+ \snippet code/src_corelib_tools_qvector.cpp 17
\sa fromStdVector(), QList::toStdList()
*/