Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qbytearraylist.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// Copyright (C) 2014 by Southwest Research Institute (R)
3
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
// Qt-Security score:significant reason:default
5
6
#
include
<
qbytearraylist
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
/*! \typedef QByteArrayListIterator
11
\relates QByteArrayList
12
13
The QByteArrayListIterator type definition provides a Java-style const
14
iterator for QByteArrayList.
15
16
QByteArrayList provides both \l{Java-style iterators} and
17
\l{STL-style iterators}. The Java-style const iterator is simply
18
a type definition for QListIterator<QByteArray>.
19
20
\sa QMutableByteArrayListIterator, QByteArrayList::const_iterator
21
*/
22
23
/*! \typedef QMutableByteArrayListIterator
24
\relates QByteArrayList
25
26
The QByteArrayListIterator type definition provides a Java-style
27
non-const iterator for QByteArrayList.
28
29
QByteArrayList provides both \l{Java-style iterators} and
30
\l{STL-style iterators}. The Java-style non-const iterator is
31
simply a type definition for QMutableListIterator<QByteArray>.
32
33
\sa QByteArrayListIterator, QByteArrayList::iterator
34
*/
35
36
/*!
37
\class QByteArrayList
38
\inmodule QtCore
39
\since 5.4
40
\meta qdoc-suppress-inheritance true
41
\brief The QByteArrayList class provides a list of byte arrays.
42
43
\ingroup tools
44
\ingroup shared
45
\ingroup string-processing
46
47
\reentrant
48
49
QByteArrayList is actually just a QList<QByteArray>. It is documented as a
50
full class just for simplicity of documenting the member methods that exist
51
only in QList<QByteArray>.
52
53
All of QList's functionality also applies to QByteArrayList. For example, you
54
can use isEmpty() to test whether the list is empty, and you can call
55
functions like append(), prepend(), insert(), replace(), removeAll(),
56
removeAt(), removeFirst(), removeLast(), and removeOne() to modify a
57
QByteArrayList. In addition, QByteArrayList provides several join()
58
methods for concatenating the list into a single QByteArray.
59
60
The purpose of QByteArrayList is quite different from that of QStringList.
61
Whereas QStringList has many methods for manipulation of elements within
62
the list, QByteArrayList does not.
63
Normally, QStringList should be used whenever working with a list of printable
64
strings. QByteArrayList should be used to handle and efficiently join large blobs
65
of binary data, as when sequentially receiving serialized data through a
66
QIODevice.
67
68
\sa QByteArray, QStringList
69
*/
70
71
/*!
72
\fn QByteArray QByteArrayList::join(const QByteArray &separator) const
73
74
Joins all the byte arrays into a single byte array with each
75
element separated by the given \a separator.
76
*/
77
78
/*!
79
\fn QByteArray QByteArrayList::join(QByteArrayView separator) const
80
\since 6.3
81
82
Joins all the byte arrays into a single byte array with each
83
element separated by the given \a separator, if any.
84
*/
85
86
/*!
87
\fn QByteArray QByteArrayList::join(char separator) const
88
89
Joins all the byte arrays into a single byte array with each
90
element separated by the given \a separator.
91
*/
92
93
static
qsizetype
QByteArrayList_joinedSize
(
const
QByteArrayList *that, qsizetype seplen)
94
{
95
qsizetype totalLength = 0;
96
const
qsizetype size = that->size();
97
98
for
(qsizetype i = 0; i < size; ++i)
99
totalLength += that->at(i).size();
100
101
if
(size > 0)
102
totalLength += seplen * (size - 1);
103
104
return
totalLength;
105
}
106
107
QByteArray
QtPrivate
::QByteArrayList_join(
const
QByteArrayList *that,
const
char
*sep, qsizetype seplen)
108
{
109
QByteArray res;
110
if
(
const
qsizetype joinedSize = QByteArrayList_joinedSize(that, seplen))
111
res.reserve(joinedSize);
// don't call reserve(0) - it allocates one byte for the NUL
112
const
qsizetype size = that->size();
113
for
(qsizetype i = 0; i < size; ++i) {
114
if
(i)
115
res.append(sep, seplen);
116
res += that->at(i);
117
}
118
return
res;
119
}
120
121
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
QtPrivate
Definition
qalloc.h:29
QByteArrayList_joinedSize
static qsizetype QByteArrayList_joinedSize(const QByteArrayList *that, qsizetype seplen)
Definition
qbytearraylist.cpp:93
qtbase
src
corelib
text
qbytearraylist.cpp
Generated on
for Qt by
1.16.1