QByteArrayList Class

The QByteArrayList class provides a list of byte arrays. More...

Header: #include <QByteArrayList>
qmake: QT += core
Since: Qt 5.3
Inherits: QList<QByteArray>.

Note: All functions in this class are reentrant.

Public Functions

QByteArrayList()
QByteArrayList(const QByteArray & ba)
QByteArrayList(const QByteArrayList & other)
QByteArrayList(const QList<QByteArray> & other)
QByteArrayList(std::initializer_list<QByteArray> args)
QByteArray join() const
QByteArray join(const QByteArray & separator) const
QByteArray join(char separator) const
QByteArrayList & operator<<(const QByteArray & ba)
QByteArrayList & operator<<(const QByteArrayList & other)
  • 70 public functions inherited from QList

Related Non-Members

typedef QByteArrayListIterator
typedef QMutableByteArrayListIterator
QByteArrayList operator+(const QByteArrayList & list1, const QByteArrayList & list2)
QByteArrayList & operator+=(QByteArrayList & list1, const QByteArrayList & list2)
QDataStream & operator<<(QDataStream & out, const QByteArrayList & list)
QDataStream & operator>>(QDataStream & in, QByteArrayList & list)

Additional Inherited Members

  • 3 static public members inherited from QList

Detailed Description

The QByteArrayList class provides a list of byte arrays.

QByteArrayList inherits from QList<QByteArray>. Like QList, QByteArrayList is implicitly shared. It provides fast index-based access as well as fast insertions and removals. Passing string lists as value parameters is both fast and safe.

All of QList's functionality also applies to QByteArrayList. For example, you can use isEmpty() to test whether the list is empty, and you can call functions like append(), prepend(), insert(), replace(), removeAll(), removeAt(), removeFirst(), removeLast(), and removeOne() to modify a QByteArrayList. In addition, QByteArrayList provides several join() methods for concatenating the list into a single QByteArray.

The purpose of QByteArrayList is quite different from that of QStringList. Whereas QStringList has many methods for manipulation of elements within the list, QByteArrayList does not. Normally, QStringList should be used whenever working with a list of printable strings. QByteArrayList should be used to handle and efficiently join large blobs of binary data, as when sequentially receiving serialized data through a QIODevice.

See also QByteArray and QStringList.

Member Function Documentation

QByteArrayList::QByteArrayList()

Constructs an empty byte array list.

QByteArrayList::QByteArrayList(const QByteArray & ba)

Constructs a byte array list that contains the given byte array, ba. Longer lists are easily created like this:

    QByteArrayList longerList = (QByteArrayList() << ba1 << ba2 << ba3);

See also append().

QByteArrayList::QByteArrayList(const QByteArrayList & other)

Constructs a copy of the other byte array list.

This operation takes constant time because QByteArrayList is implicitly shared, making the process of returning a QByteArrayList from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time.

See also operator=().

QByteArrayList::QByteArrayList(const QList<QByteArray> & other)

Constructs a copy of other.

This operation takes constant time, because QByteArrayList is implicitly shared. This makes returning a QByteArrayList from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time.

See also operator=().

QByteArrayList::QByteArrayList(std::initializer_list<QByteArray> args)

Construct a list from a std::initializer_list given by args.

This constructor is only enabled if the compiler supports C++11 initializer lists.

QByteArray QByteArrayList::join() const

Joins all the byte arrays into a single byte array.

QByteArray QByteArrayList::join(const QByteArray & separator) const

Joins all the byte arrays into a single byte array with each element separated by the given separator.

QByteArray QByteArrayList::join(char separator) const

Joins all the byte arrays into a single byte array with each element separated by the given separator.

QByteArrayList & QByteArrayList::operator<<(const QByteArray & ba)

Appends the given byte array, ba, to this byte array list and returns a reference to the byte array list.

See also append().

QByteArrayList & QByteArrayList::operator<<(const QByteArrayList & other)

This is an overloaded function.

Appends the other byte array list to the byte array list and returns a reference to the latter byte array list.

Related Non-Members

typedef QByteArrayListIterator

The QByteArrayListIterator type definition provides a Java-style const iterator for QByteArrayList.

QByteArrayList provides both Java-style iterators and STL-style iterators. The Java-style const iterator is simply a type definition for QListIterator<QByteArray>.

See also QMutableByteArrayListIterator and QByteArrayList::const_iterator.

typedef QMutableByteArrayListIterator

The QByteArrayListIterator type definition provides a Java-style non-const iterator for QByteArrayList.

QByteArrayList provides both Java-style iterators and STL-style iterators. The Java-style non-const iterator is simply a type definition for QMutableListIterator<QByteArray>.

See also QByteArrayListIterator and QByteArrayList::iterator.

QByteArrayList operator+(const QByteArrayList & list1, const QByteArrayList & list2)

Returns a byte array list that is the concatenation of list1 and list2.

QByteArrayList & operator+=(QByteArrayList & list1, const QByteArrayList & list2)

Appends list2 to list1 and returns a reference to list1.

QDataStream & operator<<(QDataStream & out, const QByteArrayList & list)

Writes the given byte array list to the specified out stream.

See also Serializing Qt Data Types.

QDataStream & operator>>(QDataStream & in, QByteArrayList & list)

Reads a byte array list from the given in stream into the specified list.

See also Serializing Qt Data Types.