Struct qt_core::QByteArray

source ·
#[repr(C)]
pub struct QByteArray { /* private fields */ }
Expand description

The QByteArray class provides an array of bytes.

C++ class: QByteArray.

C++ documentation:

The QByteArray class provides an array of bytes.

QByteArray can be used to store both raw bytes (including '\0's) and traditional 8-bit '\0'-terminated strings. Using QByteArray is much more convenient than using const char *. Behind the scenes, it always ensures that the data is followed by a '\0' terminator, and uses implicit sharing (copy-on-write) to reduce memory usage and avoid needless copying of data.

In addition to QByteArray, Qt also provides the QString class to store string data. For most purposes, QString is the class you want to use. It stores 16-bit Unicode characters, making it easy to store non-ASCII/non-Latin-1 characters in your application. Furthermore, QString is used throughout in the Qt API. The two main cases where QByteArray is appropriate are when you need to store raw binary data, and when memory conservation is critical (e.g., with Qt for Embedded Linux).

One way to initialize a QByteArray is simply to pass a const char * to its constructor. For example, the following code creates a byte array of size 5 containing the data "Hello":

QByteArray ba(“Hello”);

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 asks for a pointer to the underlying data (e.g. a call to data()), the data pointed to is guaranteed to be '\0'-terminated.

QByteArray makes a deep copy of the const char * data, so you can modify it later without experiencing side effects. (If for performance reasons you don't want to take a deep copy of the character data, use QByteArray::fromRawData() instead.)

Another approach is to set the size of the array using resize() and to initialize the data byte per byte. QByteArray uses 0-based indexes, just like C++ arrays. To access the byte at a particular index position, you can use operator[](). On non-const byte arrays, operator[]() returns a reference to a byte that can be used on the left side of an assignment. For example:

QByteArray ba; ba.resize(5); ba[0] = 0x3c; ba[1] = 0xb8; ba[2] = 0x64; ba[3] = 0x18; ba[4] = 0xca;

For read-only access, an alternative syntax is to use at():

for (int i = 0; i < ba.size(); ++i) { if (ba.at(i) >= ‘a’ && ba.at(i) <= ‘f’) cout << “Found character in range [a-f]” << endl; }

at() can be faster than operator[](), because it never causes a deep copy to occur.

To extract many bytes at a time, use left(), right(), or mid().

A QByteArray can embed '\0' bytes. The size() function always returns the size of the whole array, including embedded '\0' bytes, but excluding the terminating '\0' added by QByteArray. For example:

QByteArray ba1(“ca\0r\0t”); ba1.size(); // Returns 2. ba1.constData(); // Returns “ca” with terminating \0.

QByteArray ba2(“ca\0r\0t”, 3); ba2.size(); // Returns 3. ba2.constData(); // Returns “ca\0” with terminating \0.

QByteArray ba3(“ca\0r\0t”, 4); ba3.size(); // Returns 4. ba3.constData(); // Returns “ca\0r” with terminating \0.

const char cart[] = {‘c’, ‘a’, ‘\0’, ‘r’, ‘\0’, ‘t’}; QByteArray ba4(QByteArray::fromRawData(cart, 6)); ba4.size(); // Returns 6. ba4.constData(); // Returns “ca\0r\0t” without terminating \0.

If you want to obtain the length of the data up to and excluding the first '\0' character, call qstrlen() on the byte array.

After a call to resize(), newly allocated bytes have undefined values. To set all the bytes to a particular value, call fill().

To obtain a pointer to the actual character data, call data() or constData(). These functions return a pointer to the beginning of the data. The pointer is guaranteed to remain valid until a non-const function is called on the QByteArray. It is also guaranteed that the data ends with a '\0' byte unless the QByteArray was created from a raw data. This '\0' byte is automatically provided by QByteArray and is not counted in size().

QByteArray provides the following basic functions for modifying the byte data: append(), prepend(), insert(), replace(), and remove(). For example:

QByteArray x(“and”); x.prepend(“rock “); // x == “rock and” x.append(“ roll“); // x == “rock and roll” x.replace(5, 3, “&”); // x == “rock & roll”

The replace() and remove() functions' first two arguments are the position from which to start erasing and the number of bytes that should be erased.

When you append() data to a non-empty array, the array will be reallocated and the new data copied to it. You can avoid this behavior by calling reserve(), which preallocates a certain amount of memory. You can also call capacity() to find out how much memory QByteArray actually allocated. Data appended to an empty array is not copied.

A frequent requirement is to remove whitespace characters from a byte array ('\n', '\t', ' ', etc.). If you want to remove whitespace from both ends of a QByteArray, use trimmed(). If you want to remove whitespace from both ends and replace multiple consecutive whitespaces with a single space character within the byte array, use simplified().

If you want to find all occurrences of a particular character or substring in a QByteArray, use indexOf() or lastIndexOf(). The former searches forward starting from a given index position, the latter searches backward. Both return the index position of the character or substring if they find it; otherwise, they return -1. For example, here's a typical loop that finds all occurrences of a particular substring:

QByteArray ba(“We must be <b>bold</b>, very <b>bold</b>”); int j = 0; while ((j = ba.indexOf(“<b>”, j)) != -1) { cout << “Found <b> tag at index position “ << j << endl; ++j; }

If you simply want to check whether a QByteArray contains a particular character or substring, use contains(). If you want to find out how many times a particular character or substring occurs in the byte array, use count(). If you want to replace all occurrences of a particular value with another, use one of the two-parameter replace() overloads.

QByteArrays can be compared using overloaded operators such as operator<(), operator<=(), operator==(), operator>=(), and so on. The comparison is based exclusively on the numeric values of the characters and is very fast, but is not what a human would expect. QString::localeAwareCompare() is a better choice for sorting user-interface strings.

For historical reasons, QByteArray distinguishes between a null byte array and an empty byte array. A null byte array is a byte array that is initialized using QByteArray's default constructor or by passing (const char *)0 to the constructor. An empty byte array is any byte array with size 0. A null byte array is always empty, but an empty byte array isn't necessarily null:

QByteArray().isNull(); // returns true QByteArray().isEmpty(); // returns true

QByteArray(“”).isNull(); // returns false QByteArray(“”).isEmpty(); // returns true

QByteArray(“abc”).isNull(); // returns false QByteArray(“abc”).isEmpty(); // returns false

All functions except isNull() treat null byte arrays the same as empty byte arrays. For example, data() returns a pointer to a '\0' character for a null byte array (not a null pointer), and QByteArray() compares equal to QByteArray(""). We recommend that you always use isEmpty() and avoid isNull().

Implementations§

source§

impl QByteArray

source

pub unsafe fn from_slice(slice: &[u8]) -> CppBox<QByteArray>

Creates a QByteArray containing bytes from slice.

QByteArray makes a deep copy of the data.

source§

impl QByteArray

source

pub unsafe fn add_assign_char(&self, c: c_char) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::operator+=(char c).

C++ documentation:

This is an overloaded function.

Appends the character ch onto the end of this byte array and returns a reference to this byte array.

source

pub unsafe fn add_assign_char2(&self, s: *const c_char) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::operator+=(const char* s).

C++ documentation:

This is an overloaded function.

Appends the string str onto the end of this byte array and returns a reference to this byte array.

source

pub unsafe fn add_assign_q_byte_array( &self, a: impl CastInto<Ref<QByteArray>> ) -> Ref<QByteArray>

Appends the byte array ba onto the end of this byte array and returns a reference to this byte array.

Calls C++ function: QByteArray& QByteArray::operator+=(const QByteArray& a).

C++ documentation:

Appends the byte array ba onto the end of this byte array and returns a reference to this byte array.

Example:

QByteArray x(“free”); QByteArray y(“dom”); x += y; // x == “freedom”

Note: QByteArray is an implicitly shared class. Consequently, if you append to an empty byte array, then the byte array will just share the data held in ba. In this case, no copying of data is done, taking constant time. If a shared instance is modified, it will be copied (copy-on-write), taking linear time.

If the byte array being appended to is not empty, a deep copy of the data is performed, taking linear time.

This operation typically does not suffer from allocation overhead, because QByteArray preallocates extra space at the end of the data so that it may grow without reallocating for each append operation.

See also append() and prepend().

source

pub unsafe fn add_assign_q_string( &self, s: impl CastInto<Ref<QString>> ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::operator+=(const QString& s).

C++ documentation:

This is an overloaded function.

Appends the string str onto the end of this byte array and returns a reference to this byte array. The Unicode data is converted into 8-bit characters using QString::toUtf8().

You can disable this function by defining QT_NO_CAST_TO_ASCII when you compile your applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to convert the data to const char *.

source

pub unsafe fn append_char(&self, c: c_char) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::append(char c).

C++ documentation:

This is an overloaded function.

Appends the character ch to this byte array.

source

pub unsafe fn append_int_char(&self, count: c_int, c: c_char) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::append(int count, char c).

C++ documentation:

This is an overloaded function.

Appends count copies of character ch to this byte array and returns a reference to this byte array.

If count is negative or zero nothing is appended to the byte array.

This function was introduced in Qt 5.7.

source

pub unsafe fn append_char2(&self, s: *const c_char) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::append(const char* s).

C++ documentation:

This is an overloaded function.

Appends the string str to this byte array.

source

pub unsafe fn append_char_int( &self, s: *const c_char, len: c_int ) -> Ref<QByteArray>

This function overloads append().

Calls C++ function: QByteArray& QByteArray::append(const char* s, int len).

C++ documentation:

This function overloads append().

Appends the first len characters of the string str to this byte array and returns a reference to this byte array.

If len is negative, the length of the string will be determined automatically using qstrlen(). If len is zero or str is null, nothing is appended to the byte array. Ensure that len is not longer than str.

source

pub unsafe fn append_q_byte_array( &self, a: impl CastInto<Ref<QByteArray>> ) -> Ref<QByteArray>

Appends the byte array ba onto the end of this byte array.

Calls C++ function: QByteArray& QByteArray::append(const QByteArray& a).

C++ documentation:

Appends the byte array ba onto the end of this byte array.

Example:

QByteArray x(“free”); QByteArray y(“dom”); x.append(y); // x == “freedom”

This is the same as insert(size(), ba).

Note: QByteArray is an implicitly shared class. Consequently, if you append to an empty byte array, then the byte array will just share the data held in ba. In this case, no copying of data is done, taking constant time. If a shared instance is modified, it will be copied (copy-on-write), taking linear time.

If the byte array being appended to is not empty, a deep copy of the data is performed, taking linear time.

This operation typically does not suffer from allocation overhead, because QByteArray preallocates extra space at the end of the data so that it may grow without reallocating for each append operation.

See also operator+=(), prepend(), and insert().

source

pub unsafe fn append_q_string( &self, s: impl CastInto<Ref<QString>> ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::append(const QString& s).

C++ documentation:

This is an overloaded function.

Appends the string str to this byte array. The Unicode data is converted into 8-bit characters using QString::toUtf8().

You can disable this function by defining QT_NO_CAST_TO_ASCII when you compile your applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to convert the data to const char *.

source

pub unsafe fn at(&self, i: c_int) -> c_char

Returns the character at index position i in the byte array.

Calls C++ function: char QByteArray::at(int i) const.

C++ documentation:

Returns the character at index position i in the byte array.

i must be a valid index position in the byte array (i.e., 0 <= i < size()).

See also operator[]().

source

pub unsafe fn back(&self) -> c_char

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the last character in the byte array. Same as at(size() - 1).

Calls C++ function: char QByteArray::back() const.

C++ documentation:

Returns the last character in the byte array. Same as at(size() - 1).

This function is provided for STL compatibility.

Warning: Calling this function on an empty byte array constitutes undefined behavior.

This function was introduced in Qt 5.10.

See also front(), at(), and operator[]().

source

pub unsafe fn back_mut(&self) -> CppBox<QByteRef>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a reference to the last character in the byte array. Same as operator[](size() - 1).

Calls C++ function: QByteRef QByteArray::back().

C++ documentation:

Returns a reference to the last character in the byte array. Same as operator[](size() - 1).

This function is provided for STL compatibility.

Warning: Calling this function on an empty byte array constitutes undefined behavior.

This function was introduced in Qt 5.10.

See also front(), at(), and operator[]().

source

pub unsafe fn begin_mut(&self) -> *mut c_char

Returns an STL-style iterator pointing to the first character in the byte-array.

Calls C++ function: char* QByteArray::begin().

C++ documentation:

Returns an STL-style iterator pointing to the first character in the byte-array.

See also constBegin() and end().

source

pub unsafe fn begin(&self) -> *const c_char

This function overloads begin().

Calls C++ function: const char* QByteArray::begin() const.

C++ documentation:

This function overloads begin().

source

pub unsafe fn capacity(&self) -> c_int

Returns the maximum number of bytes that can be stored in the byte array without forcing a reallocation.

Calls C++ function: int QByteArray::capacity() const.

C++ documentation:

Returns the maximum number of bytes that can be stored in the byte array without forcing a reallocation.

The sole purpose of this function is to provide a means of fine tuning QByteArray's memory usage. In general, you will rarely ever need to call this function. If you want to know how many bytes are in the byte array, call size().

See also reserve() and squeeze().

source

pub unsafe fn cbegin(&self) -> *const c_char

Returns a const STL-style iterator pointing to the first character in the byte-array.

Calls C++ function: const char* QByteArray::cbegin() const.

C++ documentation:

Returns a const STL-style iterator pointing to the first character in the byte-array.

This function was introduced in Qt 5.0.

See also begin() and cend().

source

pub unsafe fn cend(&self) -> *const c_char

Returns a const STL-style iterator pointing to the imaginary character after the last character in the list.

Calls C++ function: const char* QByteArray::cend() const.

C++ documentation:

Returns a const STL-style iterator pointing to the imaginary character after the last character in the list.

This function was introduced in Qt 5.0.

See also cbegin() and end().

source

pub unsafe fn chop(&self, n: c_int)

Removes n bytes from the end of the byte array.

Calls C++ function: void QByteArray::chop(int n).

C++ documentation:

Removes n bytes from the end of the byte array.

If n is greater than size(), the result is an empty byte array.

Example:

QByteArray ba(“STARTTLS\r\n”); ba.chop(2); // ba == “STARTTLS”

See also truncate(), resize(), and left().

source

pub unsafe fn chopped(&self, len: c_int) -> CppBox<QByteArray>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a byte array that contains the leftmost size() - len bytes of this byte array.

Calls C++ function: QByteArray QByteArray::chopped(int len) const.

C++ documentation:

Returns a byte array that contains the leftmost size() - len bytes of this byte array.

Note: The behavior is undefined if len is negative or greater than size().

This function was introduced in Qt 5.10.

See also endsWith(), left(), right(), mid(), chop(), and truncate().

source

pub unsafe fn clear(&self)

Clears the contents of the byte array and makes it null.

Calls C++ function: void QByteArray::clear().

C++ documentation:

Clears the contents of the byte array and makes it null.

See also resize() and isNull().

source

pub unsafe fn compare_char_case_sensitivity( &self, c: *const c_char, cs: CaseSensitivity ) -> c_int

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns an integer less than, equal to, or greater than zero depending on whether this QByteArray sorts before, at the same position, or after the string pointed to by c. The comparison is performed according to case sensitivity cs.

Calls C++ function: int QByteArray::compare(const char* c, Qt::CaseSensitivity cs = …) const.

C++ documentation:

Returns an integer less than, equal to, or greater than zero depending on whether this QByteArray sorts before, at the same position, or after the string pointed to by c. The comparison is performed according to case sensitivity cs.

This function was introduced in Qt 5.12.

See also operator==.

source

pub unsafe fn compare_q_byte_array_case_sensitivity( &self, a: impl CastInto<Ref<QByteArray>>, cs: CaseSensitivity ) -> c_int

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: int QByteArray::compare(const QByteArray& a, Qt::CaseSensitivity cs = …) const.

C++ documentation:

This is an overloaded function.

Returns an integer less than, equal to, or greater than zero depending on whether this QByteArray sorts before, at the same position, or after the QByteArray a. The comparison is performed according to case sensitivity cs.

This function was introduced in Qt 5.12.

See also operator==.

source

pub unsafe fn compare_char(&self, c: *const c_char) -> c_int

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns an integer less than, equal to, or greater than zero depending on whether this QByteArray sorts before, at the same position, or after the string pointed to by c. The comparison is performed according to case sensitivity cs.

Calls C++ function: int QByteArray::compare(const char* c) const.

C++ documentation:

Returns an integer less than, equal to, or greater than zero depending on whether this QByteArray sorts before, at the same position, or after the string pointed to by c. The comparison is performed according to case sensitivity cs.

This function was introduced in Qt 5.12.

See also operator==.

source

pub unsafe fn compare_q_byte_array( &self, a: impl CastInto<Ref<QByteArray>> ) -> c_int

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: int QByteArray::compare(const QByteArray& a) const.

C++ documentation:

This is an overloaded function.

Returns an integer less than, equal to, or greater than zero depending on whether this QByteArray sorts before, at the same position, or after the QByteArray a. The comparison is performed according to case sensitivity cs.

This function was introduced in Qt 5.12.

See also operator==.

source

pub unsafe fn const_begin(&self) -> *const c_char

Returns a const STL-style iterator pointing to the first character in the byte-array.

Calls C++ function: const char* QByteArray::constBegin() const.

C++ documentation:

Returns a const STL-style iterator pointing to the first character in the byte-array.

See also begin() and constEnd().

source

pub unsafe fn const_data(&self) -> *const c_char

Returns a pointer to the data stored in the byte array. The pointer can be used to access the bytes that compose the array. The data is '\0'-terminated unless the QByteArray object was created from raw data. The pointer remains valid as long as the byte array isn't reallocated or destroyed.

Calls C++ function: const char* QByteArray::constData() const.

C++ documentation:

Returns a pointer to the data stored in the byte array. The pointer can be used to access the bytes that compose the array. The data is ‘\0’-terminated unless the QByteArray object was created from raw data. The pointer remains valid as long as the byte array isn’t reallocated or destroyed.

This function is mostly useful to pass a byte array to a function that accepts a const char *.

Note: A QByteArray can store any byte values including '\0's, but most functions that take char * arguments assume that the data ends at the first '\0' they encounter.

See also data(), operator[](), and fromRawData().

source

pub unsafe fn const_end(&self) -> *const c_char

Returns a const STL-style iterator pointing to the imaginary character after the last character in the list.

Calls C++ function: const char* QByteArray::constEnd() const.

C++ documentation:

Returns a const STL-style iterator pointing to the imaginary character after the last character in the list.

See also constBegin() and end().

source

pub unsafe fn contains_char(&self, c: c_char) -> bool

This is an overloaded function.

Calls C++ function: bool QByteArray::contains(char c) const.

C++ documentation:

This is an overloaded function.

Returns true if the byte array contains the character ch; otherwise returns false.

source

pub unsafe fn contains_char2(&self, a: *const c_char) -> bool

This is an overloaded function.

Calls C++ function: bool QByteArray::contains(const char* a) const.

C++ documentation:

This is an overloaded function.

Returns true if the byte array contains the string str; otherwise returns false.

source

pub unsafe fn contains_q_byte_array( &self, a: impl CastInto<Ref<QByteArray>> ) -> bool

Returns true if the byte array contains an occurrence of the byte array ba; otherwise returns false.

Calls C++ function: bool QByteArray::contains(const QByteArray& a) const.

C++ documentation:

Returns true if the byte array contains an occurrence of the byte array ba; otherwise returns false.

See also indexOf() and count().

source

pub unsafe fn copy_from_q_byte_array( &self, arg1: impl CastInto<Ref<QByteArray>> ) -> Ref<QByteArray>

Assigns other to this byte array and returns a reference to this byte array.

Calls C++ function: QByteArray& QByteArray::operator=(const QByteArray& arg1).

C++ documentation:

Assigns other to this byte array and returns a reference to this byte array.

source

pub unsafe fn copy_from_char(&self, str: *const c_char) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::operator=(const char* str).

C++ documentation:

This is an overloaded function.

Assigns str to this byte array.

source

pub unsafe fn count_char(&self, c: c_char) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::count(char c) const.

C++ documentation:

This is an overloaded function.

Returns the number of occurrences of character ch in the byte array.

See also contains() and indexOf().

source

pub unsafe fn count_char2(&self, a: *const c_char) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::count(const char* a) const.

C++ documentation:

This is an overloaded function.

Returns the number of (potentially overlapping) occurrences of string str in the byte array.

source

pub unsafe fn count_q_byte_array( &self, a: impl CastInto<Ref<QByteArray>> ) -> c_int

Returns the number of (potentially overlapping) occurrences of byte array ba in this byte array.

Calls C++ function: int QByteArray::count(const QByteArray& a) const.

C++ documentation:

Returns the number of (potentially overlapping) occurrences of byte array ba in this byte array.

See also contains() and indexOf().

source

pub unsafe fn count(&self) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::count() const.

C++ documentation:

This is an overloaded function.

Same as size().

source

pub unsafe fn data_mut(&self) -> *mut c_char

Returns a pointer to the data stored in the byte array. The pointer can be used to access and modify the bytes that compose the array. The data is '\0'-terminated, i.e. the number of bytes in the returned character string is size() + 1 for the '\0' terminator.

Calls C++ function: char* QByteArray::data().

C++ documentation:

Returns a pointer to the data stored in the byte array. The pointer can be used to access and modify the bytes that compose the array. The data is ‘\0’-terminated, i.e. the number of bytes in the returned character string is size() + 1 for the ‘\0’ terminator.

Example:

QByteArray ba(“Hello world”); char data = ba.data(); while (data) { cout << “[” << *data << “]” << endl; ++data; }

The pointer remains valid as long as the byte array isn't reallocated or destroyed. For read-only access, constData() is faster because it never causes a deep copy to occur.

This function is mostly useful to pass a byte array to a function that accepts a const char *.

The following example makes a copy of the char* returned by data(), but it will corrupt the heap and cause a crash because it does not allocate a byte for the '\0' at the end:

QString tmp = “test”; QByteArray text = tmp.toLocal8Bit(); char *data = new char[text.size()]; strcpy(data, text.data()); delete [] data;

This one allocates the correct amount of space:

QString tmp = “test”; QByteArray text = tmp.toLocal8Bit(); char *data = new char[text.size() + 1]; strcpy(data, text.data()); delete [] data;

Note: A QByteArray can store any byte values including '\0's, but most functions that take char * arguments assume that the data ends at the first '\0' they encounter.

See also constData() and operator[]().

source

pub unsafe fn data(&self) -> *const c_char

This is an overloaded function.

Calls C++ function: const char* QByteArray::data() const.

C++ documentation:

This is an overloaded function.

source

pub unsafe fn detach(&self)

Calls C++ function: void QByteArray::detach().

source

pub unsafe fn end_mut(&self) -> *mut c_char

Returns an STL-style iterator pointing to the imaginary character after the last character in the byte-array.

Calls C++ function: char* QByteArray::end().

C++ documentation:

Returns an STL-style iterator pointing to the imaginary character after the last character in the byte-array.

See also begin() and constEnd().

source

pub unsafe fn end(&self) -> *const c_char

This function overloads end().

Calls C++ function: const char* QByteArray::end() const.

C++ documentation:

This function overloads end().

source

pub unsafe fn ends_with_q_byte_array( &self, a: impl CastInto<Ref<QByteArray>> ) -> bool

Returns true if this byte array ends with byte array ba; otherwise returns false.

Calls C++ function: bool QByteArray::endsWith(const QByteArray& a) const.

C++ documentation:

Returns true if this byte array ends with byte array ba; otherwise returns false.

Example:

QByteArray url(“http://qt-project.org/doc/qt-5.0/qtdoc/index.html”); if (url.endsWith(“.html”)) ...

See also startsWith() and right().

source

pub unsafe fn ends_with_char(&self, c: c_char) -> bool

This is an overloaded function.

Calls C++ function: bool QByteArray::endsWith(char c) const.

C++ documentation:

This is an overloaded function.

Returns true if this byte array ends with character ch; otherwise returns false.

source

pub unsafe fn ends_with_char2(&self, c: *const c_char) -> bool

This is an overloaded function.

Calls C++ function: bool QByteArray::endsWith(const char* c) const.

C++ documentation:

This is an overloaded function.

Returns true if this byte array ends with string str; otherwise returns false.

source

pub unsafe fn fill_2a(&self, c: c_char, size: c_int) -> Ref<QByteArray>

Sets every byte in the byte array to character ch. If size is different from -1 (the default), the byte array is resized to size size beforehand.

Calls C++ function: QByteArray& QByteArray::fill(char c, int size = …).

C++ documentation:

Sets every byte in the byte array to character ch. If size is different from -1 (the default), the byte array is resized to size size beforehand.

Example:

QByteArray ba(“Istambul”); ba.fill(‘o’); // ba == “oooooooo”

ba.fill(‘X’, 2); // ba == “XX”

See also resize().

source

pub unsafe fn fill_1a(&self, c: c_char) -> Ref<QByteArray>

Sets every byte in the byte array to character ch. If size is different from -1 (the default), the byte array is resized to size size beforehand.

Calls C++ function: QByteArray& QByteArray::fill(char c).

C++ documentation:

Sets every byte in the byte array to character ch. If size is different from -1 (the default), the byte array is resized to size size beforehand.

Example:

QByteArray ba(“Istambul”); ba.fill(‘o’); // ba == “oooooooo”

ba.fill(‘X’, 2); // ba == “XX”

See also resize().

source

pub unsafe fn from_base64_2a( base64: impl CastInto<Ref<QByteArray>>, options: QFlags<Base64Option> ) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QByteArray::fromBase64(const QByteArray& base64, QFlags<QByteArray::Base64Option> options).

C++ documentation:

This is an overloaded function.

Returns a decoded copy of the Base64 array base64, using the alphabet defined by options. Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters.

For example:

QByteArray::fromBase64(“PHA+SGVsbG8/PC9wPg==”, QByteArray::Base64Encoding); // returns “<p>Hello?</p>” QByteArray::fromBase64(“PHA-SGVsbG8_PC9wPg==”, QByteArray::Base64UrlEncoding); // returns “<p>Hello?</p>”

The algorithm used to decode Base64-encoded data is defined in RFC 4648.

This function was introduced in Qt 5.2.

See also toBase64().

source

pub unsafe fn from_base64_1a( base64: impl CastInto<Ref<QByteArray>> ) -> CppBox<QByteArray>

Returns a decoded copy of the Base64 array base64. Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters.

Calls C++ function: static QByteArray QByteArray::fromBase64(const QByteArray& base64).

C++ documentation:

Returns a decoded copy of the Base64 array base64. Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters.

For example:

QByteArray text = QByteArray::fromBase64(“UXQgaXMgZ3JlYXQh”); text.data(); // returns “Qt is great!”

The algorithm used to decode Base64-encoded data is defined in RFC 4648.

See also toBase64().

source

pub unsafe fn from_hex( hex_encoded: impl CastInto<Ref<QByteArray>> ) -> CppBox<QByteArray>

Returns a decoded copy of the hex encoded array hexEncoded. Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters.

Calls C++ function: static QByteArray QByteArray::fromHex(const QByteArray& hexEncoded).

C++ documentation:

Returns a decoded copy of the hex encoded array hexEncoded. Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters.

For example:

QByteArray text = QByteArray::fromHex(“517420697320677265617421”); text.data(); // returns “Qt is great!”

See also toHex().

source

pub unsafe fn from_percent_encoding_2a( pct_encoded: impl CastInto<Ref<QByteArray>>, percent: c_char ) -> CppBox<QByteArray>

Returns a decoded copy of the URI/URL-style percent-encoded input. The percent parameter allows you to replace the '%' character for another (for instance, '_' or '=').

Calls C++ function: static QByteArray QByteArray::fromPercentEncoding(const QByteArray& pctEncoded, char percent = …).

C++ documentation:

Returns a decoded copy of the URI/URL-style percent-encoded input. The percent parameter allows you to replace the ‘%’ character for another (for instance, ‘_’ or ‘=’).

For example:

QByteArray text = QByteArray::fromPercentEncoding(“Qt%20is%20great%33”); text.data(); // returns “Qt is great!”

Note: Given invalid input (such as a string containing the sequence "%G5", which is not a valid hexadecimal number) the output will be invalid as well. As an example: the sequence "%G5" could be decoded to 'W'.

This function was introduced in Qt 4.4.

See also toPercentEncoding() and QUrl::fromPercentEncoding().

source

pub unsafe fn from_percent_encoding_1a( pct_encoded: impl CastInto<Ref<QByteArray>> ) -> CppBox<QByteArray>

Returns a decoded copy of the URI/URL-style percent-encoded input. The percent parameter allows you to replace the '%' character for another (for instance, '_' or '=').

Calls C++ function: static QByteArray QByteArray::fromPercentEncoding(const QByteArray& pctEncoded).

C++ documentation:

Returns a decoded copy of the URI/URL-style percent-encoded input. The percent parameter allows you to replace the ‘%’ character for another (for instance, ‘_’ or ‘=’).

For example:

QByteArray text = QByteArray::fromPercentEncoding(“Qt%20is%20great%33”); text.data(); // returns “Qt is great!”

Note: Given invalid input (such as a string containing the sequence "%G5", which is not a valid hexadecimal number) the output will be invalid as well. As an example: the sequence "%G5" could be decoded to 'W'.

This function was introduced in Qt 4.4.

See also toPercentEncoding() and QUrl::fromPercentEncoding().

source

pub unsafe fn from_raw_data( arg1: *const c_char, size: c_int ) -> CppBox<QByteArray>

Constructs a QByteArray that uses the first size bytes of the data array. The bytes are not copied. The QByteArray will contain the data pointer. The caller guarantees that data will not be deleted or modified as long as this QByteArray and any copies of it exist that have not been modified. In other words, because QByteArray is an implicitly shared class and the instance returned by this function contains the data pointer, the caller must not delete data or modify it directly as long as the returned QByteArray and any copies exist. However, QByteArray does not take ownership of data, so the QByteArray destructor will never delete the raw data, even when the last QByteArray referring to data is destroyed.

Calls C++ function: static QByteArray QByteArray::fromRawData(const char* arg1, int size).

C++ documentation:

Constructs a QByteArray that uses the first size bytes of the data array. The bytes are not copied. The QByteArray will contain the data pointer. The caller guarantees that data will not be deleted or modified as long as this QByteArray and any copies of it exist that have not been modified. In other words, because QByteArray is an implicitly shared class and the instance returned by this function contains the data pointer, the caller must not delete data or modify it directly as long as the returned QByteArray and any copies exist. However, QByteArray does not take ownership of data, so the QByteArray destructor will never delete the raw data, even when the last QByteArray referring to data is destroyed.

A subsequent attempt to modify the contents of the returned QByteArray or any copy made from it will cause it to create a deep copy of the data array before doing the modification. This ensures that the raw data array itself will never be modified by QByteArray.

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:

static const char mydata[] = { 0x00, 0x00, 0x03, 0x84, 0x78, 0x9c, 0x3b, 0x76, 0xec, 0x18, 0xc3, 0x31, 0x0a, 0xf1, 0xcc, 0x99, ... 0x6d, 0x5b };

QByteArray data = QByteArray::fromRawData(mydata, sizeof(mydata)); QDataStream in(&data, QIODevice::ReadOnly); ...

Warning: A byte array created with fromRawData() is not null-terminated, unless the raw data contains a 0 character at position size. While that does not matter for QDataStream or functions like indexOf(), passing the byte array to a function accepting a const char * expected to be '\0'-terminated will fail.

See also setRawData(), data(), and constData().

source

pub unsafe fn front(&self) -> c_char

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the first character in the byte array. Same as at(0).

Calls C++ function: char QByteArray::front() const.

C++ documentation:

Returns the first character in the byte array. Same as at(0).

This function is provided for STL compatibility.

Warning: Calling this function on an empty byte array constitutes undefined behavior.

This function was introduced in Qt 5.10.

See also back(), at(), and operator[]().

source

pub unsafe fn front_mut(&self) -> CppBox<QByteRef>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a reference to the first character in the byte array. Same as operator[](0).

Calls C++ function: QByteRef QByteArray::front().

C++ documentation:

Returns a reference to the first character in the byte array. Same as operator.

This function is provided for STL compatibility.

Warning: Calling this function on an empty byte array constitutes undefined behavior.

This function was introduced in Qt 5.10.

See also back(), at(), and operator[]().

source

pub unsafe fn index_int(&self, i: c_int) -> c_char

This is an overloaded function.

Calls C++ function: char QByteArray::operator[](int i) const.

C++ documentation:

This is an overloaded function.

Same as at(i).

source

pub unsafe fn index_uint(&self, i: c_uint) -> c_char

This is an overloaded function.

Calls C++ function: char QByteArray::operator[](unsigned int i) const.

C++ documentation:

This is an overloaded function.

source

pub unsafe fn index_int_mut(&self, i: c_int) -> CppBox<QByteRef>

Returns the byte at index position i as a modifiable reference.

Calls C++ function: QByteRef QByteArray::operator[](int i).

C++ documentation:

Returns the byte at index position i as a modifiable reference.

If an assignment is made beyond the end of the byte array, the array is extended with resize() before the assignment takes place.

Example:

QByteArray ba; for (int i = 0; i < 10; ++i) ba[i] = ‘A’ + i; // ba == “ABCDEFGHIJ”

The return value is of type QByteRef, a helper class for QByteArray. When you get an object of type QByteRef, you can use it as if it were a char &. If you assign to it, the assignment will apply to the character in the QByteArray from which you got the reference.

See also at().

source

pub unsafe fn index_uint_mut(&self, i: c_uint) -> CppBox<QByteRef>

This is an overloaded function.

Calls C++ function: QByteRef QByteArray::operator[](unsigned int i).

C++ documentation:

This is an overloaded function.

source

pub unsafe fn index_of_char_int(&self, c: c_char, from: c_int) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::indexOf(char c, int from = …) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the first occurrence of the character ch in the byte array, searching forward from index position from. Returns -1 if ch could not be found.

Example:

QByteArray ba(“ABCBA”); ba.indexOf(“B”); // returns 1 ba.indexOf(“B”, 1); // returns 1 ba.indexOf(“B”, 2); // returns 3 ba.indexOf(“X”); // returns -1

See also lastIndexOf() and contains().

source

pub unsafe fn index_of_char_int2(&self, c: *const c_char, from: c_int) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::indexOf(const char* c, int from = …) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the first occurrence of the string str in the byte array, searching forward from index position from. Returns -1 if str could not be found.

source

pub unsafe fn index_of_q_byte_array_int( &self, a: impl CastInto<Ref<QByteArray>>, from: c_int ) -> c_int

Returns the index position of the first occurrence of the byte array ba in this byte array, searching forward from index position from. Returns -1 if ba could not be found.

Calls C++ function: int QByteArray::indexOf(const QByteArray& a, int from = …) const.

C++ documentation:

Returns the index position of the first occurrence of the byte array ba in this byte array, searching forward from index position from. Returns -1 if ba could not be found.

Example:

QByteArray x(“sticky question”); QByteArray y(“sti”); x.indexOf(y); // returns 0 x.indexOf(y, 1); // returns 10 x.indexOf(y, 10); // returns 10 x.indexOf(y, 11); // returns -1

See also lastIndexOf(), contains(), and count().

source

pub unsafe fn index_of_q_string_int( &self, s: impl CastInto<Ref<QString>>, from: c_int ) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::indexOf(const QString& s, int from = …) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the first occurrence of the string str in the byte array, searching forward from index position from. Returns -1 if str could not be found.

The Unicode data is converted into 8-bit characters using QString::toUtf8().

You can disable this function by defining QT_NO_CAST_TO_ASCII when you compile your applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to convert the data to const char *.

source

pub unsafe fn index_of_char(&self, c: c_char) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::indexOf(char c) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the first occurrence of the character ch in the byte array, searching forward from index position from. Returns -1 if ch could not be found.

Example:

QByteArray ba(“ABCBA”); ba.indexOf(“B”); // returns 1 ba.indexOf(“B”, 1); // returns 1 ba.indexOf(“B”, 2); // returns 3 ba.indexOf(“X”); // returns -1

See also lastIndexOf() and contains().

source

pub unsafe fn index_of_char2(&self, c: *const c_char) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::indexOf(const char* c) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the first occurrence of the string str in the byte array, searching forward from index position from. Returns -1 if str could not be found.

source

pub unsafe fn index_of_q_byte_array( &self, a: impl CastInto<Ref<QByteArray>> ) -> c_int

Returns the index position of the first occurrence of the byte array ba in this byte array, searching forward from index position from. Returns -1 if ba could not be found.

Calls C++ function: int QByteArray::indexOf(const QByteArray& a) const.

C++ documentation:

Returns the index position of the first occurrence of the byte array ba in this byte array, searching forward from index position from. Returns -1 if ba could not be found.

Example:

QByteArray x(“sticky question”); QByteArray y(“sti”); x.indexOf(y); // returns 0 x.indexOf(y, 1); // returns 10 x.indexOf(y, 10); // returns 10 x.indexOf(y, 11); // returns -1

See also lastIndexOf(), contains(), and count().

source

pub unsafe fn index_of_q_string(&self, s: impl CastInto<Ref<QString>>) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::indexOf(const QString& s) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the first occurrence of the string str in the byte array, searching forward from index position from. Returns -1 if str could not be found.

The Unicode data is converted into 8-bit characters using QString::toUtf8().

You can disable this function by defining QT_NO_CAST_TO_ASCII when you compile your applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to convert the data to const char *.

source

pub unsafe fn insert_int_char(&self, i: c_int, c: c_char) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::insert(int i, char c).

C++ documentation:

This is an overloaded function.

Inserts character ch at index position i in the byte array. If i is greater than size(), the array is first extended using resize().

source

pub unsafe fn insert_2_int_char( &self, i: c_int, count: c_int, c: c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::insert(int i, int count, char c).

C++ documentation:

This is an overloaded function.

Inserts count copies of character ch at index position i in the byte array.

If i is greater than size(), the array is first extended using resize().

This function was introduced in Qt 5.7.

source

pub unsafe fn insert_int_char2( &self, i: c_int, s: *const c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::insert(int i, const char* s).

C++ documentation:

This is an overloaded function.

Inserts the string str at position i in the byte array.

If i is greater than size(), the array is first extended using resize().

source

pub unsafe fn insert_int_char_int( &self, i: c_int, s: *const c_char, len: c_int ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::insert(int i, const char* s, int len).

C++ documentation:

This is an overloaded function.

Inserts len bytes of the string str at position i in the byte array.

If i is greater than size(), the array is first extended using resize().

This function was introduced in Qt 4.6.

source

pub unsafe fn insert_int_q_byte_array( &self, i: c_int, a: impl CastInto<Ref<QByteArray>> ) -> Ref<QByteArray>

Inserts the byte array ba at index position i and returns a reference to this byte array.

Calls C++ function: QByteArray& QByteArray::insert(int i, const QByteArray& a).

C++ documentation:

Inserts the byte array ba at index position i and returns a reference to this byte array.

Example:

QByteArray ba(“Meal”); ba.insert(1, QByteArray(“ontr”)); // ba == “Montreal”

See also append(), prepend(), replace(), and remove().

source

pub unsafe fn insert_int_q_string( &self, i: c_int, s: impl CastInto<Ref<QString>> ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::insert(int i, const QString& s).

C++ documentation:

This is an overloaded function.

Inserts the string str at index position i in the byte array. The Unicode data is converted into 8-bit characters using QString::toUtf8().

If i is greater than size(), the array is first extended using resize().

You can disable this function by defining QT_NO_CAST_TO_ASCII when you compile your applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to convert the data to const char *.

source

pub unsafe fn is_detached(&self) -> bool

Calls C++ function: bool QByteArray::isDetached() const.

source

pub unsafe fn is_empty(&self) -> bool

Returns true if the byte array has size 0; otherwise returns false.

Calls C++ function: bool QByteArray::isEmpty() const.

C++ documentation:

Returns true if the byte array has size 0; otherwise returns false.

Example:

QByteArray().isEmpty(); // returns true QByteArray(“”).isEmpty(); // returns true QByteArray(“abc”).isEmpty(); // returns false

See also size().

source

pub unsafe fn is_lower(&self) -> bool

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns true if this byte array contains only lowercase letters, otherwise returns false. The byte array is interpreted as a Latin-1 encoded string.

Calls C++ function: bool QByteArray::isLower() const.

C++ documentation:

Returns true if this byte array contains only lowercase letters, otherwise returns false. The byte array is interpreted as a Latin-1 encoded string.

This function was introduced in Qt 5.12.

See also isUpper() and toLower().

source

pub unsafe fn is_null(&self) -> bool

Returns true if this byte array is null; otherwise returns false.

Calls C++ function: bool QByteArray::isNull() const.

C++ documentation:

Returns true if this byte array is null; otherwise returns false.

Example:

QByteArray().isNull(); // returns true QByteArray(“”).isNull(); // returns false QByteArray(“abc”).isNull(); // returns false

Qt makes a distinction between null byte arrays and empty byte arrays for historical reasons. For most applications, what matters is whether or not a byte array contains any data, and this can be determined using isEmpty().

See also isEmpty().

source

pub unsafe fn is_shared_with( &self, other: impl CastInto<Ref<QByteArray>> ) -> bool

Calls C++ function: bool QByteArray::isSharedWith(const QByteArray& other) const.

source

pub unsafe fn is_upper(&self) -> bool

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns true if this byte array contains only uppercase letters, otherwise returns false. The byte array is interpreted as a Latin-1 encoded string.

Calls C++ function: bool QByteArray::isUpper() const.

C++ documentation:

Returns true if this byte array contains only uppercase letters, otherwise returns false. The byte array is interpreted as a Latin-1 encoded string.

This function was introduced in Qt 5.12.

See also isLower() and toUpper().

source

pub unsafe fn last_index_of_char_int(&self, c: c_char, from: c_int) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::lastIndexOf(char c, int from = …) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last (size() - 1) byte. Returns -1 if ch could not be found.

Example:

QByteArray ba(“ABCBA”); ba.lastIndexOf(“B”); // returns 3 ba.lastIndexOf(“B”, 3); // returns 3 ba.lastIndexOf(“B”, 2); // returns 1 ba.lastIndexOf(“X”); // returns -1

See also indexOf() and contains().

source

pub unsafe fn last_index_of_char_int2( &self, c: *const c_char, from: c_int ) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::lastIndexOf(const char* c, int from = …) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the last occurrence of the string str in the byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last (size() - 1) byte. Returns -1 if str could not be found.

source

pub unsafe fn last_index_of_q_byte_array_int( &self, a: impl CastInto<Ref<QByteArray>>, from: c_int ) -> c_int

Returns the index position of the last occurrence of the byte array ba in this byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last byte. Returns -1 if ba could not be found.

Calls C++ function: int QByteArray::lastIndexOf(const QByteArray& a, int from = …) const.

C++ documentation:

Returns the index position of the last occurrence of the byte array ba in this byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last byte. Returns -1 if ba could not be found.

Example:

QByteArray x(“crazy azimuths”); QByteArray y(“az”); x.lastIndexOf(y); // returns 6 x.lastIndexOf(y, 6); // returns 6 x.lastIndexOf(y, 5); // returns 2 x.lastIndexOf(y, 1); // returns -1

See also indexOf(), contains(), and count().

source

pub unsafe fn last_index_of_q_string_int( &self, s: impl CastInto<Ref<QString>>, from: c_int ) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::lastIndexOf(const QString& s, int from = …) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the last occurrence of the string str in the byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last (size() - 1) byte. Returns -1 if str could not be found.

The Unicode data is converted into 8-bit characters using QString::toUtf8().

You can disable this function by defining QT_NO_CAST_TO_ASCII when you compile your applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to convert the data to const char *.

source

pub unsafe fn last_index_of_char(&self, c: c_char) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::lastIndexOf(char c) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last (size() - 1) byte. Returns -1 if ch could not be found.

Example:

QByteArray ba(“ABCBA”); ba.lastIndexOf(“B”); // returns 3 ba.lastIndexOf(“B”, 3); // returns 3 ba.lastIndexOf(“B”, 2); // returns 1 ba.lastIndexOf(“X”); // returns -1

See also indexOf() and contains().

source

pub unsafe fn last_index_of_char2(&self, c: *const c_char) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::lastIndexOf(const char* c) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the last occurrence of the string str in the byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last (size() - 1) byte. Returns -1 if str could not be found.

source

pub unsafe fn last_index_of_q_byte_array( &self, a: impl CastInto<Ref<QByteArray>> ) -> c_int

Returns the index position of the last occurrence of the byte array ba in this byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last byte. Returns -1 if ba could not be found.

Calls C++ function: int QByteArray::lastIndexOf(const QByteArray& a) const.

C++ documentation:

Returns the index position of the last occurrence of the byte array ba in this byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last byte. Returns -1 if ba could not be found.

Example:

QByteArray x(“crazy azimuths”); QByteArray y(“az”); x.lastIndexOf(y); // returns 6 x.lastIndexOf(y, 6); // returns 6 x.lastIndexOf(y, 5); // returns 2 x.lastIndexOf(y, 1); // returns -1

See also indexOf(), contains(), and count().

source

pub unsafe fn last_index_of_q_string( &self, s: impl CastInto<Ref<QString>> ) -> c_int

This is an overloaded function.

Calls C++ function: int QByteArray::lastIndexOf(const QString& s) const.

C++ documentation:

This is an overloaded function.

Returns the index position of the last occurrence of the string str in the byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last (size() - 1) byte. Returns -1 if str could not be found.

The Unicode data is converted into 8-bit characters using QString::toUtf8().

You can disable this function by defining QT_NO_CAST_TO_ASCII when you compile your applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to convert the data to const char *.

source

pub unsafe fn left(&self, len: c_int) -> CppBox<QByteArray>

Returns a byte array that contains the leftmost len bytes of this byte array.

Calls C++ function: QByteArray QByteArray::left(int len) const.

C++ documentation:

Returns a byte array that contains the leftmost len bytes of this byte array.

The entire byte array is returned if len is greater than size().

Example:

QByteArray x(“Pineapple”); QByteArray y = x.left(4); // y == “Pine”

See also right(), mid(), startsWith(), and truncate().

source

pub unsafe fn left_justified_3a( &self, width: c_int, fill: c_char, truncate: bool ) -> CppBox<QByteArray>

Returns a byte array of size width that contains this byte array padded by the fill character.

Calls C++ function: QByteArray QByteArray::leftJustified(int width, char fill = …, bool truncate = …) const.

C++ documentation:

Returns a byte array of size width that contains this byte array padded by the fill character.

If truncate is false and the size() of the byte array is more than width, then the returned byte array is a copy of this byte array.

If truncate is true and the size() of the byte array is more than width, then any bytes in a copy of the byte array after position width are removed, and the copy is returned.

Example:

QByteArray x(“apple”); QByteArray y = x.leftJustified(8, ‘.’); // y == “apple…”

See also rightJustified().

source

pub unsafe fn left_justified_2a( &self, width: c_int, fill: c_char ) -> CppBox<QByteArray>

Returns a byte array of size width that contains this byte array padded by the fill character.

Calls C++ function: QByteArray QByteArray::leftJustified(int width, char fill = …) const.

C++ documentation:

Returns a byte array of size width that contains this byte array padded by the fill character.

If truncate is false and the size() of the byte array is more than width, then the returned byte array is a copy of this byte array.

If truncate is true and the size() of the byte array is more than width, then any bytes in a copy of the byte array after position width are removed, and the copy is returned.

Example:

QByteArray x(“apple”); QByteArray y = x.leftJustified(8, ‘.’); // y == “apple…”

See also rightJustified().

source

pub unsafe fn left_justified_1a(&self, width: c_int) -> CppBox<QByteArray>

Returns a byte array of size width that contains this byte array padded by the fill character.

Calls C++ function: QByteArray QByteArray::leftJustified(int width) const.

C++ documentation:

Returns a byte array of size width that contains this byte array padded by the fill character.

If truncate is false and the size() of the byte array is more than width, then the returned byte array is a copy of this byte array.

If truncate is true and the size() of the byte array is more than width, then any bytes in a copy of the byte array after position width are removed, and the copy is returned.

Example:

QByteArray x(“apple”); QByteArray y = x.leftJustified(8, ‘.’); // y == “apple…”

See also rightJustified().

source

pub unsafe fn length(&self) -> c_int

Same as size().

Calls C++ function: int QByteArray::length() const.

C++ documentation:

Same as size().

source

pub unsafe fn mid_2a(&self, index: c_int, len: c_int) -> CppBox<QByteArray>

Returns a byte array containing len bytes from this byte array, starting at position pos.

Calls C++ function: QByteArray QByteArray::mid(int index, int len = …) const.

C++ documentation:

Returns a byte array containing len bytes from this byte array, starting at position pos.

If len is -1 (the default), or pos + len >= size(), returns a byte array containing all bytes starting at position pos until the end of the byte array.

Example:

QByteArray x(“Five pineapples”); QByteArray y = x.mid(5, 4); // y == “pine” QByteArray z = x.mid(5); // z == “pineapples”

See also left() and right().

source

pub unsafe fn mid_1a(&self, index: c_int) -> CppBox<QByteArray>

Returns a byte array containing len bytes from this byte array, starting at position pos.

Calls C++ function: QByteArray QByteArray::mid(int index) const.

C++ documentation:

Returns a byte array containing len bytes from this byte array, starting at position pos.

If len is -1 (the default), or pos + len >= size(), returns a byte array containing all bytes starting at position pos until the end of the byte array.

Example:

QByteArray x(“Five pineapples”); QByteArray y = x.mid(5, 4); // y == “pine” QByteArray z = x.mid(5); // z == “pineapples”

See also left() and right().

source

pub unsafe fn new() -> CppBox<QByteArray>

Constructs an empty byte array.

Calls C++ function: [constructor] void QByteArray::QByteArray().

C++ documentation:

Constructs an empty byte array.

See also isEmpty().

source

pub unsafe fn from_char_int( arg1: *const c_char, size: c_int ) -> CppBox<QByteArray>

Constructs a byte array containing the first size bytes of array data.

Calls C++ function: [constructor] void QByteArray::QByteArray(const char* arg1, int size = …).

C++ documentation:

Constructs a byte array containing the first size bytes of array data.

If data is 0, a null byte array is constructed.

If size is negative, data is assumed to point to a nul-terminated string and its length is determined dynamically. The terminating nul-character is not considered part of the byte array.

QByteArray makes a deep copy of the string data.

See also fromRawData().

source

pub unsafe fn from_int_char(size: c_int, c: c_char) -> CppBox<QByteArray>

Constructs a byte array of size size with every byte set to character ch.

Calls C++ function: [constructor] void QByteArray::QByteArray(int size, char c).

C++ documentation:

Constructs a byte array of size size with every byte set to character ch.

See also fill().

source

pub unsafe fn from_char(arg1: *const c_char) -> CppBox<QByteArray>

Constructs a byte array containing the first size bytes of array data.

Calls C++ function: [constructor] void QByteArray::QByteArray(const char* arg1).

C++ documentation:

Constructs a byte array containing the first size bytes of array data.

If data is 0, a null byte array is constructed.

If size is negative, data is assumed to point to a nul-terminated string and its length is determined dynamically. The terminating nul-character is not considered part of the byte array.

QByteArray makes a deep copy of the string data.

See also fromRawData().

source

pub unsafe fn new_copy( arg1: impl CastInto<Ref<QByteArray>> ) -> CppBox<QByteArray>

Constructs a copy of other.

Calls C++ function: [constructor] void QByteArray::QByteArray(const QByteArray& arg1).

C++ documentation:

Constructs a copy of other.

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

See also operator=().

source

pub unsafe fn number_2_int(arg1: c_int, base: c_int) -> CppBox<QByteArray>

Returns a byte array containing the string equivalent of the number n to base base (10 by default). The base can be any value between 2 and 36.

Calls C++ function: static QByteArray QByteArray::number(int arg1, int base = …).

C++ documentation:

Returns a byte array containing the string equivalent of the number n to base base (10 by default). The base can be any value between 2 and 36.

Example:

int n = 63; QByteArray::number(n); // returns “63” QByteArray::number(n, 16); // returns “3f” QByteArray::number(n, 16).toUpper(); // returns “3F”

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also setNum() and toInt().

source

pub unsafe fn number_uint_int(arg1: c_uint, base: c_int) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QByteArray::number(unsigned int arg1, int base = …).

C++ documentation:

This is an overloaded function.

See also toUInt().

source

pub unsafe fn number_i64_int(arg1: i64, base: c_int) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QByteArray::number(qlonglong arg1, int base = …).

C++ documentation:

This is an overloaded function.

See also toLongLong().

source

pub unsafe fn number_u64_int(arg1: u64, base: c_int) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QByteArray::number(qulonglong arg1, int base = …).

C++ documentation:

This is an overloaded function.

See also toULongLong().

source

pub unsafe fn number_double_char_int( arg1: c_double, f: c_char, prec: c_int ) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QByteArray::number(double arg1, char f = …, int prec = …).

C++ documentation:

This is an overloaded function.

Returns a byte array that contains the printed value of n, formatted in format f with precision prec.

Argument n is formatted according to the f format specified, which is g by default, and can be any of the following:

FormatMeaning
eformat as [-]9.9e[+|-]999
Eformat as [-]9.9E[+|-]999
fformat as [-]9.9
guse e or f format, whichever is the most concise
Guse E or f format, whichever is the most concise

With 'e', 'E', and 'f', prec is the number of digits after the decimal point. With 'g' and 'G', prec is the maximum number of significant digits (trailing zeroes are omitted).

QByteArray ba = QByteArray::number(12.3456, ‘E’, 3); // ba == 1.235E+01

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also toDouble().

source

pub unsafe fn number_int(arg1: c_int) -> CppBox<QByteArray>

Returns a byte array containing the string equivalent of the number n to base base (10 by default). The base can be any value between 2 and 36.

Calls C++ function: static QByteArray QByteArray::number(int arg1).

C++ documentation:

Returns a byte array containing the string equivalent of the number n to base base (10 by default). The base can be any value between 2 and 36.

Example:

int n = 63; QByteArray::number(n); // returns “63” QByteArray::number(n, 16); // returns “3f” QByteArray::number(n, 16).toUpper(); // returns “3F”

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also setNum() and toInt().

source

pub unsafe fn number_uint(arg1: c_uint) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QByteArray::number(unsigned int arg1).

C++ documentation:

This is an overloaded function.

See also toUInt().

source

pub unsafe fn number_i64(arg1: i64) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QByteArray::number(qlonglong arg1).

C++ documentation:

This is an overloaded function.

See also toLongLong().

source

pub unsafe fn number_u64(arg1: u64) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QByteArray::number(qulonglong arg1).

C++ documentation:

This is an overloaded function.

See also toULongLong().

source

pub unsafe fn number_double_char( arg1: c_double, f: c_char ) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QByteArray::number(double arg1, char f = …).

C++ documentation:

This is an overloaded function.

Returns a byte array that contains the printed value of n, formatted in format f with precision prec.

Argument n is formatted according to the f format specified, which is g by default, and can be any of the following:

FormatMeaning
eformat as [-]9.9e[+|-]999
Eformat as [-]9.9E[+|-]999
fformat as [-]9.9
guse e or f format, whichever is the most concise
Guse E or f format, whichever is the most concise

With 'e', 'E', and 'f', prec is the number of digits after the decimal point. With 'g' and 'G', prec is the maximum number of significant digits (trailing zeroes are omitted).

QByteArray ba = QByteArray::number(12.3456, ‘E’, 3); // ba == 1.235E+01

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also toDouble().

source

pub unsafe fn number_double(arg1: c_double) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QByteArray::number(double arg1).

C++ documentation:

This is an overloaded function.

Returns a byte array that contains the printed value of n, formatted in format f with precision prec.

Argument n is formatted according to the f format specified, which is g by default, and can be any of the following:

FormatMeaning
eformat as [-]9.9e[+|-]999
Eformat as [-]9.9E[+|-]999
fformat as [-]9.9
guse e or f format, whichever is the most concise
Guse E or f format, whichever is the most concise

With 'e', 'E', and 'f', prec is the number of digits after the decimal point. With 'g' and 'G', prec is the maximum number of significant digits (trailing zeroes are omitted).

QByteArray ba = QByteArray::number(12.3456, ‘E’, 3); // ba == 1.235E+01

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also toDouble().

source

pub unsafe fn prepend_char(&self, c: c_char) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::prepend(char c).

C++ documentation:

This is an overloaded function.

Prepends the character ch to this byte array.

source

pub unsafe fn prepend_int_char( &self, count: c_int, c: c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::prepend(int count, char c).

C++ documentation:

This is an overloaded function.

Prepends count copies of character ch to this byte array.

This function was introduced in Qt 5.7.

source

pub unsafe fn prepend_char2(&self, s: *const c_char) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::prepend(const char* s).

C++ documentation:

This is an overloaded function.

Prepends the string str to this byte array.

source

pub unsafe fn prepend_char_int( &self, s: *const c_char, len: c_int ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::prepend(const char* s, int len).

C++ documentation:

This is an overloaded function.

Prepends len bytes of the string str to this byte array.

This function was introduced in Qt 4.6.

source

pub unsafe fn prepend_q_byte_array( &self, a: impl CastInto<Ref<QByteArray>> ) -> Ref<QByteArray>

Prepends the byte array ba to this byte array and returns a reference to this byte array.

Calls C++ function: QByteArray& QByteArray::prepend(const QByteArray& a).

C++ documentation:

Prepends the byte array ba to this byte array and returns a reference to this byte array.

Example:

QByteArray x(“ship”); QByteArray y(“air”); x.prepend(y); // x == “airship”

This is the same as insert(0, ba).

Note: QByteArray is an implicitly shared class. Consequently, if you prepend to an empty byte array, then the byte array will just share the data held in ba. In this case, no copying of data is done, taking constant time. If a shared instance is modified, it will be copied (copy-on-write), taking linear time.

If the byte array being prepended to is not empty, a deep copy of the data is performed, taking linear time.

See also append() and insert().

source

pub unsafe fn push_back_char(&self, c: c_char)

This is an overloaded function.

Calls C++ function: void QByteArray::push_back(char c).

C++ documentation:

This is an overloaded function.

Same as append(ch).

source

pub unsafe fn push_back_char2(&self, c: *const c_char)

This is an overloaded function.

Calls C++ function: void QByteArray::push_back(const char* c).

C++ documentation:

This is an overloaded function.

Same as append(str).

source

pub unsafe fn push_back_q_byte_array(&self, a: impl CastInto<Ref<QByteArray>>)

This function is provided for STL compatibility. It is equivalent to append(other).

Calls C++ function: void QByteArray::push_back(const QByteArray& a).

C++ documentation:

This function is provided for STL compatibility. It is equivalent to append(other).

source

pub unsafe fn push_front_char(&self, c: c_char)

This is an overloaded function.

Calls C++ function: void QByteArray::push_front(char c).

C++ documentation:

This is an overloaded function.

Same as prepend(ch).

source

pub unsafe fn push_front_char2(&self, c: *const c_char)

This is an overloaded function.

Calls C++ function: void QByteArray::push_front(const char* c).

C++ documentation:

This is an overloaded function.

Same as prepend(str).

source

pub unsafe fn push_front_q_byte_array(&self, a: impl CastInto<Ref<QByteArray>>)

This function is provided for STL compatibility. It is equivalent to prepend(other).

Calls C++ function: void QByteArray::push_front(const QByteArray& a).

C++ documentation:

This function is provided for STL compatibility. It is equivalent to prepend(other).

source

pub unsafe fn remove(&self, index: c_int, len: c_int) -> Ref<QByteArray>

Removes len bytes from the array, starting at index position pos, and returns a reference to the array.

Calls C++ function: QByteArray& QByteArray::remove(int index, int len).

C++ documentation:

Removes len bytes from the array, starting at index position pos, and returns a reference to the array.

If pos is out of range, nothing happens. If pos is valid, but pos + len is larger than the size of the array, the array is truncated at position pos.

Example:

QByteArray ba(“Montreal”); ba.remove(1, 4); // ba == “Meal”

See also insert() and replace().

source

pub unsafe fn repeated(&self, times: c_int) -> CppBox<QByteArray>

Returns a copy of this byte array repeated the specified number of times.

Calls C++ function: QByteArray QByteArray::repeated(int times) const.

C++ documentation:

Returns a copy of this byte array repeated the specified number of times.

If times is less than 1, an empty byte array is returned.

Example:

QByteArray ba(“ab”); ba.repeated(4); // returns “abababab”

This function was introduced in Qt 4.5.

source

pub unsafe fn replace_2_int_char( &self, index: c_int, len: c_int, s: *const c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(int index, int len, const char* s).

C++ documentation:

This is an overloaded function.

Replaces len bytes from index position pos with the zero terminated string after.

Notice: this can change the length of the byte array.

source

pub unsafe fn replace_2_int_char_int( &self, index: c_int, len: c_int, s: *const c_char, alen: c_int ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(int index, int len, const char* s, int alen).

C++ documentation:

This is an overloaded function.

Replaces len bytes from index position pos with alen bytes from the string after. after is allowed to have '\0' characters.

This function was introduced in Qt 4.7.

source

pub unsafe fn replace_2_int_q_byte_array( &self, index: c_int, len: c_int, s: impl CastInto<Ref<QByteArray>> ) -> Ref<QByteArray>

Replaces len bytes from index position pos with the byte array after, and returns a reference to this byte array.

Calls C++ function: QByteArray& QByteArray::replace(int index, int len, const QByteArray& s).

C++ documentation:

Replaces len bytes from index position pos with the byte array after, and returns a reference to this byte array.

Example:

QByteArray x(“Say yes!”); QByteArray y(“no”); x.replace(4, 3, y); // x == “Say no!”

See also insert() and remove().

source

pub unsafe fn replace_char_char( &self, before: c_char, after: *const c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(char before, const char* after).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the character before with the string after.

source

pub unsafe fn replace_char_q_byte_array( &self, before: c_char, after: impl CastInto<Ref<QByteArray>> ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(char before, const QByteArray& after).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the character before with the byte array after.

source

pub unsafe fn replace_2_char( &self, before: *const c_char, after: *const c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(const char* before, const char* after).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the string before with the string after.

source

pub unsafe fn replace_char_int_char_int( &self, before: *const c_char, bsize: c_int, after: *const c_char, asize: c_int ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(const char* before, int bsize, const char* after, int asize).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the string before with the string after. Since the sizes of the strings are given by bsize and asize, they may contain zero characters and do not need to be zero-terminated.

source

pub unsafe fn replace_2_q_byte_array( &self, before: impl CastInto<Ref<QByteArray>>, after: impl CastInto<Ref<QByteArray>> ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(const QByteArray& before, const QByteArray& after).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the byte array before with the byte array after.

Example:

QByteArray ba(“colour behaviour flavour neighbour”); ba.replace(QByteArray(“ou”), QByteArray(“o”)); // ba == “color behavior flavor neighbor”

source

pub unsafe fn replace_q_byte_array_char( &self, before: impl CastInto<Ref<QByteArray>>, after: *const c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(const QByteArray& before, const char* after).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the byte array before with the string after.

source

pub unsafe fn replace_char_q_byte_array2( &self, before: *const c_char, after: impl CastInto<Ref<QByteArray>> ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(const char* before, const QByteArray& after).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the string before with the byte array after.

source

pub unsafe fn replace_2_char2( &self, before: c_char, after: c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(char before, char after).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the character before with the character after.

source

pub unsafe fn replace_q_string_char( &self, before: impl CastInto<Ref<QString>>, after: *const c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(const QString& before, const char* after).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the string before with the string after.

source

pub unsafe fn replace_char_q_string( &self, c: c_char, after: impl CastInto<Ref<QString>> ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(char c, const QString& after).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the character before with the string after. The Unicode data is converted into 8-bit characters using QString::toUtf8().

You can disable this function by defining QT_NO_CAST_TO_ASCII when you compile your applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to convert the data to const char *.

source

pub unsafe fn replace_q_string_q_byte_array( &self, before: impl CastInto<Ref<QString>>, after: impl CastInto<Ref<QByteArray>> ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::replace(const QString& before, const QByteArray& after).

C++ documentation:

This is an overloaded function.

Replaces every occurrence of the string before with the byte array after. The Unicode data is converted into 8-bit characters using QString::toUtf8().

You can disable this function by defining QT_NO_CAST_TO_ASCII when you compile your applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to convert the data to const char *.

source

pub unsafe fn reserve(&self, size: c_int)

Attempts to allocate memory for at least size bytes. If you know in advance how large the byte array will be, you can call this function, and if you call resize() often you are likely to get better performance. If size is an underestimate, the worst that will happen is that the QByteArray will be a bit slower.

Calls C++ function: void QByteArray::reserve(int size).

C++ documentation:

Attempts to allocate memory for at least size bytes. If you know in advance how large the byte array will be, you can call this function, and if you call resize() often you are likely to get better performance. If size is an underestimate, the worst that will happen is that the QByteArray will be a bit slower.

The sole purpose of this function is to provide a means of fine tuning QByteArray's memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the byte array, call resize().

See also squeeze() and capacity().

source

pub unsafe fn resize(&self, size: c_int)

Sets the size of the byte array to size bytes.

Calls C++ function: void QByteArray::resize(int size).

C++ documentation:

Sets the size of the byte array to size bytes.

If size is greater than the current size, the byte array is extended to make it size bytes with the extra bytes added to the end. The new bytes are uninitialized.

If size is less than the current size, bytes are removed from the end.

See also size() and truncate().

source

pub unsafe fn right(&self, len: c_int) -> CppBox<QByteArray>

Returns a byte array that contains the rightmost len bytes of this byte array.

Calls C++ function: QByteArray QByteArray::right(int len) const.

C++ documentation:

Returns a byte array that contains the rightmost len bytes of this byte array.

The entire byte array is returned if len is greater than size().

Example:

QByteArray x(“Pineapple”); QByteArray y = x.right(5); // y == “apple”

See also endsWith(), left(), and mid().

source

pub unsafe fn right_justified_3a( &self, width: c_int, fill: c_char, truncate: bool ) -> CppBox<QByteArray>

Returns a byte array of size width that contains the fill character followed by this byte array.

Calls C++ function: QByteArray QByteArray::rightJustified(int width, char fill = …, bool truncate = …) const.

C++ documentation:

Returns a byte array of size width that contains the fill character followed by this byte array.

If truncate is false and the size of the byte array is more than width, then the returned byte array is a copy of this byte array.

If truncate is true and the size of the byte array is more than width, then the resulting byte array is truncated at position width.

Example:

QByteArray x(“apple”); QByteArray y = x.rightJustified(8, ‘.’); // y == “…apple”

See also leftJustified().

source

pub unsafe fn right_justified_2a( &self, width: c_int, fill: c_char ) -> CppBox<QByteArray>

Returns a byte array of size width that contains the fill character followed by this byte array.

Calls C++ function: QByteArray QByteArray::rightJustified(int width, char fill = …) const.

C++ documentation:

Returns a byte array of size width that contains the fill character followed by this byte array.

If truncate is false and the size of the byte array is more than width, then the returned byte array is a copy of this byte array.

If truncate is true and the size of the byte array is more than width, then the resulting byte array is truncated at position width.

Example:

QByteArray x(“apple”); QByteArray y = x.rightJustified(8, ‘.’); // y == “…apple”

See also leftJustified().

source

pub unsafe fn right_justified_1a(&self, width: c_int) -> CppBox<QByteArray>

Returns a byte array of size width that contains the fill character followed by this byte array.

Calls C++ function: QByteArray QByteArray::rightJustified(int width) const.

C++ documentation:

Returns a byte array of size width that contains the fill character followed by this byte array.

If truncate is false and the size of the byte array is more than width, then the returned byte array is a copy of this byte array.

If truncate is true and the size of the byte array is more than width, then the resulting byte array is truncated at position width.

Example:

QByteArray x(“apple”); QByteArray y = x.rightJustified(8, ‘.’); // y == “…apple”

See also leftJustified().

source

pub unsafe fn set_num_short_int( &self, arg1: c_short, base: c_int ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(short arg1, int base = …).

C++ documentation:

This is an overloaded function.

See also toShort().

source

pub unsafe fn set_num_ushort_int( &self, arg1: c_ushort, base: c_int ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(unsigned short arg1, int base = …).

C++ documentation:

This is an overloaded function.

See also toUShort().

source

pub unsafe fn set_num_2_int(&self, arg1: c_int, base: c_int) -> Ref<QByteArray>

Sets the byte array to the printed value of n in base base (10 by default) and returns a reference to the byte array. The base can be any value between 2 and 36. For bases other than 10, n is treated as an unsigned integer.

Calls C++ function: QByteArray& QByteArray::setNum(int arg1, int base = …).

C++ documentation:

Sets the byte array to the printed value of n in base base (10 by default) and returns a reference to the byte array. The base can be any value between 2 and 36. For bases other than 10, n is treated as an unsigned integer.

Example:

QByteArray ba; int n = 63; ba.setNum(n); // ba == “63” ba.setNum(n, 16); // ba == “3f”

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also number() and toInt().

source

pub unsafe fn set_num_uint_int( &self, arg1: c_uint, base: c_int ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(unsigned int arg1, int base = …).

C++ documentation:

This is an overloaded function.

See also toUInt().

source

pub unsafe fn set_num_i64_int(&self, arg1: i64, base: c_int) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(qlonglong arg1, int base = …).

C++ documentation:

This is an overloaded function.

See also toLongLong().

source

pub unsafe fn set_num_u64_int(&self, arg1: u64, base: c_int) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(qulonglong arg1, int base = …).

C++ documentation:

This is an overloaded function.

See also toULongLong().

source

pub unsafe fn set_num_float_char_int( &self, arg1: c_float, f: c_char, prec: c_int ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(float arg1, char f = …, int prec = …).

C++ documentation:

This is an overloaded function.

Sets the byte array to the printed value of n, formatted in format f with precision prec, and returns a reference to the byte array.

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also toFloat().

source

pub unsafe fn set_num_double_char_int( &self, arg1: c_double, f: c_char, prec: c_int ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(double arg1, char f = …, int prec = …).

C++ documentation:

This is an overloaded function.

Sets the byte array to the printed value of n, formatted in format f with precision prec, and returns a reference to the byte array.

The format f can be any of the following:

FormatMeaning
eformat as [-]9.9e[+|-]999
Eformat as [-]9.9E[+|-]999
fformat as [-]9.9
guse e or f format, whichever is the most concise
Guse E or f format, whichever is the most concise

With 'e', 'E', and 'f', prec is the number of digits after the decimal point. With 'g' and 'G', prec is the maximum number of significant digits (trailing zeroes are omitted).

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also toDouble().

source

pub unsafe fn set_num_short(&self, arg1: c_short) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(short arg1).

C++ documentation:

This is an overloaded function.

See also toShort().

source

pub unsafe fn set_num_ushort(&self, arg1: c_ushort) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(unsigned short arg1).

C++ documentation:

This is an overloaded function.

See also toUShort().

source

pub unsafe fn set_num_int(&self, arg1: c_int) -> Ref<QByteArray>

Sets the byte array to the printed value of n in base base (10 by default) and returns a reference to the byte array. The base can be any value between 2 and 36. For bases other than 10, n is treated as an unsigned integer.

Calls C++ function: QByteArray& QByteArray::setNum(int arg1).

C++ documentation:

Sets the byte array to the printed value of n in base base (10 by default) and returns a reference to the byte array. The base can be any value between 2 and 36. For bases other than 10, n is treated as an unsigned integer.

Example:

QByteArray ba; int n = 63; ba.setNum(n); // ba == “63” ba.setNum(n, 16); // ba == “3f”

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also number() and toInt().

source

pub unsafe fn set_num_uint(&self, arg1: c_uint) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(unsigned int arg1).

C++ documentation:

This is an overloaded function.

See also toUInt().

source

pub unsafe fn set_num_i64(&self, arg1: i64) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(qlonglong arg1).

C++ documentation:

This is an overloaded function.

See also toLongLong().

source

pub unsafe fn set_num_u64(&self, arg1: u64) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(qulonglong arg1).

C++ documentation:

This is an overloaded function.

See also toULongLong().

source

pub unsafe fn set_num_float_char( &self, arg1: c_float, f: c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(float arg1, char f = …).

C++ documentation:

This is an overloaded function.

Sets the byte array to the printed value of n, formatted in format f with precision prec, and returns a reference to the byte array.

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also toFloat().

source

pub unsafe fn set_num_float(&self, arg1: c_float) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(float arg1).

C++ documentation:

This is an overloaded function.

Sets the byte array to the printed value of n, formatted in format f with precision prec, and returns a reference to the byte array.

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also toFloat().

source

pub unsafe fn set_num_double_char( &self, arg1: c_double, f: c_char ) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(double arg1, char f = …).

C++ documentation:

This is an overloaded function.

Sets the byte array to the printed value of n, formatted in format f with precision prec, and returns a reference to the byte array.

The format f can be any of the following:

FormatMeaning
eformat as [-]9.9e[+|-]999
Eformat as [-]9.9E[+|-]999
fformat as [-]9.9
guse e or f format, whichever is the most concise
Guse E or f format, whichever is the most concise

With 'e', 'E', and 'f', prec is the number of digits after the decimal point. With 'g' and 'G', prec is the maximum number of significant digits (trailing zeroes are omitted).

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also toDouble().

source

pub unsafe fn set_num_double(&self, arg1: c_double) -> Ref<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray& QByteArray::setNum(double arg1).

C++ documentation:

This is an overloaded function.

Sets the byte array to the printed value of n, formatted in format f with precision prec, and returns a reference to the byte array.

The format f can be any of the following:

FormatMeaning
eformat as [-]9.9e[+|-]999
Eformat as [-]9.9E[+|-]999
fformat as [-]9.9
guse e or f format, whichever is the most concise
Guse E or f format, whichever is the most concise

With 'e', 'E', and 'f', prec is the number of digits after the decimal point. With 'g' and 'G', prec is the maximum number of significant digits (trailing zeroes are omitted).

Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also toDouble().

source

pub unsafe fn set_raw_data( &self, a: *const c_char, n: c_uint ) -> Ref<QByteArray>

Resets the QByteArray to use the first size bytes of the data array. The bytes are not copied. The QByteArray will contain the data pointer. The caller guarantees that data will not be deleted or modified as long as this QByteArray and any copies of it exist that have not been modified.

Calls C++ function: QByteArray& QByteArray::setRawData(const char* a, unsigned int n).

C++ documentation:

Resets the QByteArray to use the first size bytes of the data array. The bytes are not copied. The QByteArray will contain the data pointer. The caller guarantees that data will not be deleted or modified as long as this QByteArray and any copies of it exist that have not been modified.

This function can be used instead of fromRawData() to re-use existing QByteArray objects to save memory re-allocations.

This function was introduced in Qt 4.7.

See also fromRawData(), data(), and constData().

source

pub unsafe fn shrink_to_fit(&self)

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This function is provided for STL compatibility. It is equivalent to squeeze().

Calls C++ function: void QByteArray::shrink_to_fit().

C++ documentation:

This function is provided for STL compatibility. It is equivalent to squeeze().

This function was introduced in Qt 5.10.

source

pub unsafe fn simplified(&self) -> CppBox<QByteArray>

Returns a byte array that has whitespace removed from the start and the end, and which has each sequence of internal whitespace replaced with a single space.

Calls C++ function: QByteArray QByteArray::simplified() const.

C++ documentation:

Returns a byte array that has whitespace removed from the start and the end, and which has each sequence of internal whitespace replaced with a single space.

Whitespace means any character for which the standard C++ isspace() function returns true in the C locale. This includes the ASCII isspace() function returns true in the C locale. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.

Example:

QByteArray ba(“ lots\t of\nwhitespace\r\n “); ba = ba.simplified(); // ba == “lots of whitespace”;

See also trimmed().

source

pub unsafe fn simplified_mut(&self) -> CppBox<QByteArray>

Returns a byte array that has whitespace removed from the start and the end, and which has each sequence of internal whitespace replaced with a single space.

Calls C++ function: QByteArray QByteArray::simplified().

C++ documentation:

Returns a byte array that has whitespace removed from the start and the end, and which has each sequence of internal whitespace replaced with a single space.

Whitespace means any character for which the standard C++ isspace() function returns true in the C locale. This includes the ASCII isspace() function returns true in the C locale. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.

Example:

QByteArray ba(“ lots\t of\nwhitespace\r\n “); ba = ba.simplified(); // ba == “lots of whitespace”;

See also trimmed().

source

pub unsafe fn size(&self) -> c_int

Returns the number of bytes in this byte array.

Calls C++ function: int QByteArray::size() const.

C++ documentation:

Returns the number of bytes in this byte array.

The last byte in the byte array is at position size() - 1. In addition, QByteArray ensures that the byte at position size() is always '\0', so that you can use the return value of data() and constData() as arguments to functions that expect '\0'-terminated strings. If the QByteArray object was created from a raw data that didn't include the trailing null-termination character then QByteArray doesn't add it automaticall unless the deep copy is created.

Example:

QByteArray ba(“Hello”); int n = ba.size(); // n == 5 ba.data()[0]; // returns ‘H’ ba.data()[4]; // returns ‘o’ ba.data()[5]; // returns ‘\0’

See also isEmpty() and resize().

source

pub unsafe fn split(&self, sep: c_char) -> CppBox<QListOfQByteArray>

Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays. If sep does not match anywhere in the byte array, split() returns a single-element list containing this byte array.

Calls C++ function: QList<QByteArray> QByteArray::split(char sep) const.

C++ documentation:

Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays. If sep does not match anywhere in the byte array, split() returns a single-element list containing this byte array.

source

pub unsafe fn squeeze(&self)

Releases any memory not required to store the array's data.

Calls C++ function: void QByteArray::squeeze().

C++ documentation:

Releases any memory not required to store the array’s data.

The sole purpose of this function is to provide a means of fine tuning QByteArray's memory usage. In general, you will rarely ever need to call this function.

See also reserve() and capacity().

source

pub unsafe fn starts_with_q_byte_array( &self, a: impl CastInto<Ref<QByteArray>> ) -> bool

Returns true if this byte array starts with byte array ba; otherwise returns false.

Calls C++ function: bool QByteArray::startsWith(const QByteArray& a) const.

C++ documentation:

Returns true if this byte array starts with byte array ba; otherwise returns false.

Example:

QByteArray url(“ftp://ftp.qt-project.org/”); if (url.startsWith(“ftp:”)) ...

See also endsWith() and left().

source

pub unsafe fn starts_with_char(&self, c: c_char) -> bool

This is an overloaded function.

Calls C++ function: bool QByteArray::startsWith(char c) const.

C++ documentation:

This is an overloaded function.

Returns true if this byte array starts with character ch; otherwise returns false.

source

pub unsafe fn starts_with_char2(&self, c: *const c_char) -> bool

This is an overloaded function.

Calls C++ function: bool QByteArray::startsWith(const char* c) const.

C++ documentation:

This is an overloaded function.

Returns true if this byte array starts with string str; otherwise returns false.

source

pub unsafe fn swap(&self, other: impl CastInto<Ref<QByteArray>>)

Swaps byte array other with this byte array. This operation is very fast and never fails.

Calls C++ function: void QByteArray::swap(QByteArray& other).

C++ documentation:

Swaps byte array other with this byte array. This operation is very fast and never fails.

This function was introduced in Qt 4.8.

source

pub unsafe fn to_base64_1a( &self, options: QFlags<Base64Option> ) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray QByteArray::toBase64(QFlags<QByteArray::Base64Option> options) const.

C++ documentation:

This is an overloaded function.

Returns a copy of the byte array, encoded using the options options.

QByteArray text(“<p>Hello?</p>”); text.toBase64(QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals); // returns “PHA+SGVsbG8/PC9wPg” text.toBase64(QByteArray::Base64Encoding); // returns “PHA+SGVsbG8/PC9wPg==” text.toBase64(QByteArray::Base64UrlEncoding); // returns “PHA-SGVsbG8_PC9wPg==” text.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); // returns “PHA-SGVsbG8_PC9wPg”

The algorithm used to encode Base64-encoded data is defined in RFC 4648.

This function was introduced in Qt 5.2.

See also fromBase64().

source

pub unsafe fn to_base64_0a(&self) -> CppBox<QByteArray>

Returns a copy of the byte array, encoded as Base64.

Calls C++ function: QByteArray QByteArray::toBase64() const.

C++ documentation:

Returns a copy of the byte array, encoded as Base64.


  QByteArray text("Qt is great!");
  text.toBase64();        // returns "UXQgaXMgZ3JlYXQh"

The algorithm used to encode Base64-encoded data is defined in RFC 4648.

See also fromBase64().

source

pub unsafe fn to_char(&self) -> *const c_char

Calls C++ function: const char* QByteArray::operator const char*() const.

source

pub unsafe fn to_double_1a(&self, ok: *mut bool) -> c_double

Returns the byte array converted to a double value.

Calls C++ function: double QByteArray::toDouble(bool* ok = …) const.

C++ documentation:

Returns the byte array converted to a double value.

Returns 0.0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

QByteArray string(“1234.56”); double a = string.toDouble(); // a == 1234.56

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_double_0a(&self) -> c_double

Returns the byte array converted to a double value.

Calls C++ function: double QByteArray::toDouble() const.

C++ documentation:

Returns the byte array converted to a double value.

Returns 0.0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

QByteArray string(“1234.56”); double a = string.toDouble(); // a == 1234.56

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_float_1a(&self, ok: *mut bool) -> c_float

Returns the byte array converted to a float value.

Calls C++ function: float QByteArray::toFloat(bool* ok = …) const.

C++ documentation:

Returns the byte array converted to a float value.

Returns 0.0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_float_0a(&self) -> c_float

Returns the byte array converted to a float value.

Calls C++ function: float QByteArray::toFloat() const.

C++ documentation:

Returns the byte array converted to a float value.

Returns 0.0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_hex_0a(&self) -> CppBox<QByteArray>

Returns a hex encoded copy of the byte array. The hex encoding uses the numbers 0-9 and the letters a-f.

Calls C++ function: QByteArray QByteArray::toHex() const.

C++ documentation:

Returns a hex encoded copy of the byte array. The hex encoding uses the numbers 0-9 and the letters a-f.

See also fromHex().

source

pub unsafe fn to_hex_1a(&self, separator: c_char) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray QByteArray::toHex(char separator) const.

C++ documentation:

This is an overloaded function.

Returns a hex encoded copy of the byte array. The hex encoding uses the numbers 0-9 and the letters a-f.

If separator is not '\0', the separator character is inserted between the hex bytes.

Example:

QByteArray macAddress = QByteArray::fromHex(“123456abcdef”); macAddress.toHex(‘:’); // returns “12:34:56:ab:cd:ef” macAddress.toHex(0); // returns “123456abcdef”

This function was introduced in Qt 5.9.

See also fromHex().

source

pub unsafe fn to_int_2a(&self, ok: *mut bool, base: c_int) -> c_int

Returns the byte array converted to an int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: int QByteArray::toInt(bool* ok = …, int base = …) const.

C++ documentation:

Returns the byte array converted to an int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

QByteArray str(“FF”); bool ok; int hex = str.toInt(&ok, 16); // hex == 255, ok == true int dec = str.toInt(&ok, 10); // dec == 0, ok == false

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_int_1a(&self, ok: *mut bool) -> c_int

Returns the byte array converted to an int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: int QByteArray::toInt(bool* ok = …) const.

C++ documentation:

Returns the byte array converted to an int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

QByteArray str(“FF”); bool ok; int hex = str.toInt(&ok, 16); // hex == 255, ok == true int dec = str.toInt(&ok, 10); // dec == 0, ok == false

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_int_0a(&self) -> c_int

Returns the byte array converted to an int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: int QByteArray::toInt() const.

C++ documentation:

Returns the byte array converted to an int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

QByteArray str(“FF”); bool ok; int hex = str.toInt(&ok, 16); // hex == 255, ok == true int dec = str.toInt(&ok, 10); // dec == 0, ok == false

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_long_2a(&self, ok: *mut bool, base: c_int) -> c_long

Returns the byte array converted to a long int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: long QByteArray::toLong(bool* ok = …, int base = …) const.

C++ documentation:

Returns the byte array converted to a long int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

QByteArray str(“FF”); bool ok; long hex = str.toLong(&ok, 16); // hex == 255, ok == true long dec = str.toLong(&ok, 10); // dec == 0, ok == false

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

This function was introduced in Qt 4.1.

See also number().

source

pub unsafe fn to_long_1a(&self, ok: *mut bool) -> c_long

Returns the byte array converted to a long int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: long QByteArray::toLong(bool* ok = …) const.

C++ documentation:

Returns the byte array converted to a long int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

QByteArray str(“FF”); bool ok; long hex = str.toLong(&ok, 16); // hex == 255, ok == true long dec = str.toLong(&ok, 10); // dec == 0, ok == false

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

This function was introduced in Qt 4.1.

See also number().

source

pub unsafe fn to_long_0a(&self) -> c_long

Returns the byte array converted to a long int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: long QByteArray::toLong() const.

C++ documentation:

Returns the byte array converted to a long int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

QByteArray str(“FF”); bool ok; long hex = str.toLong(&ok, 16); // hex == 255, ok == true long dec = str.toLong(&ok, 10); // dec == 0, ok == false

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

This function was introduced in Qt 4.1.

See also number().

source

pub unsafe fn to_long_long_2a(&self, ok: *mut bool, base: c_int) -> i64

Returns the byte array converted to a long long using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: qlonglong QByteArray::toLongLong(bool* ok = …, int base = …) const.

C++ documentation:

Returns the byte array converted to a long long using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_long_long_1a(&self, ok: *mut bool) -> i64

Returns the byte array converted to a long long using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: qlonglong QByteArray::toLongLong(bool* ok = …) const.

C++ documentation:

Returns the byte array converted to a long long using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_long_long_0a(&self) -> i64

Returns the byte array converted to a long long using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: qlonglong QByteArray::toLongLong() const.

C++ documentation:

Returns the byte array converted to a long long using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_lower(&self) -> CppBox<QByteArray>

Returns a lowercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.

Calls C++ function: QByteArray QByteArray::toLower() const.

C++ documentation:

Returns a lowercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.

Example:

QByteArray x(“Qt by THE QT COMPANY”); QByteArray y = x.toLower(); // y == “qt by the qt company”

See also toUpper() and 8-bit Character Comparisons.

source

pub unsafe fn to_lower_mut(&self) -> CppBox<QByteArray>

Returns a lowercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.

Calls C++ function: QByteArray QByteArray::toLower().

C++ documentation:

Returns a lowercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.

Example:

QByteArray x(“Qt by THE QT COMPANY”); QByteArray y = x.toLower(); // y == “qt by the qt company”

See also toUpper() and 8-bit Character Comparisons.

source

pub unsafe fn to_percent_encoding_3a( &self, exclude: impl CastInto<Ref<QByteArray>>, include: impl CastInto<Ref<QByteArray>>, percent: c_char ) -> CppBox<QByteArray>

Returns a URI/URL-style percent-encoded copy of this byte array. The percent parameter allows you to override the default '%' character for another.

Calls C++ function: QByteArray QByteArray::toPercentEncoding(const QByteArray& exclude = …, const QByteArray& include = …, char percent = …) const.

C++ documentation:

Returns a URI/URL-style percent-encoded copy of this byte array. The percent parameter allows you to override the default ‘%’ character for another.

By default, this function will encode all characters that are not one of the following:

ALPHA ("a" to "z" and "A" to "Z") / DIGIT (0 to 9) / "-" / "." / "_" / "~"

To prevent characters from being encoded pass them to exclude. To force characters to be encoded pass them to include. The percent character is always encoded.

Example:

QByteArray text = “{a fishy string?}”; QByteArray ba = text.toPercentEncoding(“{}”, “s”); qDebug(ba.constData()); // prints “{a fi%73hy %73tring%3F}”

The hex encoding uses the numbers 0-9 and the uppercase letters A-F.

This function was introduced in Qt 4.4.

See also fromPercentEncoding() and QUrl::toPercentEncoding().

source

pub unsafe fn to_percent_encoding_2a( &self, exclude: impl CastInto<Ref<QByteArray>>, include: impl CastInto<Ref<QByteArray>> ) -> CppBox<QByteArray>

Returns a URI/URL-style percent-encoded copy of this byte array. The percent parameter allows you to override the default '%' character for another.

Calls C++ function: QByteArray QByteArray::toPercentEncoding(const QByteArray& exclude = …, const QByteArray& include = …) const.

C++ documentation:

Returns a URI/URL-style percent-encoded copy of this byte array. The percent parameter allows you to override the default ‘%’ character for another.

By default, this function will encode all characters that are not one of the following:

ALPHA ("a" to "z" and "A" to "Z") / DIGIT (0 to 9) / "-" / "." / "_" / "~"

To prevent characters from being encoded pass them to exclude. To force characters to be encoded pass them to include. The percent character is always encoded.

Example:

QByteArray text = “{a fishy string?}”; QByteArray ba = text.toPercentEncoding(“{}”, “s”); qDebug(ba.constData()); // prints “{a fi%73hy %73tring%3F}”

The hex encoding uses the numbers 0-9 and the uppercase letters A-F.

This function was introduced in Qt 4.4.

See also fromPercentEncoding() and QUrl::toPercentEncoding().

source

pub unsafe fn to_percent_encoding_1a( &self, exclude: impl CastInto<Ref<QByteArray>> ) -> CppBox<QByteArray>

Returns a URI/URL-style percent-encoded copy of this byte array. The percent parameter allows you to override the default '%' character for another.

Calls C++ function: QByteArray QByteArray::toPercentEncoding(const QByteArray& exclude = …) const.

C++ documentation:

Returns a URI/URL-style percent-encoded copy of this byte array. The percent parameter allows you to override the default ‘%’ character for another.

By default, this function will encode all characters that are not one of the following:

ALPHA ("a" to "z" and "A" to "Z") / DIGIT (0 to 9) / "-" / "." / "_" / "~"

To prevent characters from being encoded pass them to exclude. To force characters to be encoded pass them to include. The percent character is always encoded.

Example:

QByteArray text = “{a fishy string?}”; QByteArray ba = text.toPercentEncoding(“{}”, “s”); qDebug(ba.constData()); // prints “{a fi%73hy %73tring%3F}”

The hex encoding uses the numbers 0-9 and the uppercase letters A-F.

This function was introduced in Qt 4.4.

See also fromPercentEncoding() and QUrl::toPercentEncoding().

source

pub unsafe fn to_percent_encoding_0a(&self) -> CppBox<QByteArray>

Returns a URI/URL-style percent-encoded copy of this byte array. The percent parameter allows you to override the default '%' character for another.

Calls C++ function: QByteArray QByteArray::toPercentEncoding() const.

C++ documentation:

Returns a URI/URL-style percent-encoded copy of this byte array. The percent parameter allows you to override the default ‘%’ character for another.

By default, this function will encode all characters that are not one of the following:

ALPHA ("a" to "z" and "A" to "Z") / DIGIT (0 to 9) / "-" / "." / "_" / "~"

To prevent characters from being encoded pass them to exclude. To force characters to be encoded pass them to include. The percent character is always encoded.

Example:

QByteArray text = “{a fishy string?}”; QByteArray ba = text.toPercentEncoding(“{}”, “s”); qDebug(ba.constData()); // prints “{a fi%73hy %73tring%3F}”

The hex encoding uses the numbers 0-9 and the uppercase letters A-F.

This function was introduced in Qt 4.4.

See also fromPercentEncoding() and QUrl::toPercentEncoding().

source

pub unsafe fn to_short_2a(&self, ok: *mut bool, base: c_int) -> c_short

Returns the byte array converted to a short using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: short QByteArray::toShort(bool* ok = …, int base = …) const.

C++ documentation:

Returns the byte array converted to a short using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_short_1a(&self, ok: *mut bool) -> c_short

Returns the byte array converted to a short using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: short QByteArray::toShort(bool* ok = …) const.

C++ documentation:

Returns the byte array converted to a short using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_short_0a(&self) -> c_short

Returns the byte array converted to a short using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: short QByteArray::toShort() const.

C++ documentation:

Returns the byte array converted to a short using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_u_int_2a(&self, ok: *mut bool, base: c_int) -> c_uint

Returns the byte array converted to an unsigned int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: unsigned int QByteArray::toUInt(bool* ok = …, int base = …) const.

C++ documentation:

Returns the byte array converted to an unsigned int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_u_int_1a(&self, ok: *mut bool) -> c_uint

Returns the byte array converted to an unsigned int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: unsigned int QByteArray::toUInt(bool* ok = …) const.

C++ documentation:

Returns the byte array converted to an unsigned int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_u_int_0a(&self) -> c_uint

Returns the byte array converted to an unsigned int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: unsigned int QByteArray::toUInt() const.

C++ documentation:

Returns the byte array converted to an unsigned int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_u_long_2a(&self, ok: *mut bool, base: c_int) -> c_ulong

Returns the byte array converted to an unsigned long int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: unsigned long QByteArray::toULong(bool* ok = …, int base = …) const.

C++ documentation:

Returns the byte array converted to an unsigned long int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

This function was introduced in Qt 4.1.

See also number().

source

pub unsafe fn to_u_long_1a(&self, ok: *mut bool) -> c_ulong

Returns the byte array converted to an unsigned long int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: unsigned long QByteArray::toULong(bool* ok = …) const.

C++ documentation:

Returns the byte array converted to an unsigned long int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

This function was introduced in Qt 4.1.

See also number().

source

pub unsafe fn to_u_long_0a(&self) -> c_ulong

Returns the byte array converted to an unsigned long int using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: unsigned long QByteArray::toULong() const.

C++ documentation:

Returns the byte array converted to an unsigned long int using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

This function was introduced in Qt 4.1.

See also number().

source

pub unsafe fn to_u_long_long_2a(&self, ok: *mut bool, base: c_int) -> u64

Returns the byte array converted to an unsigned long long using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: qulonglong QByteArray::toULongLong(bool* ok = …, int base = …) const.

C++ documentation:

Returns the byte array converted to an unsigned long long using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_u_long_long_1a(&self, ok: *mut bool) -> u64

Returns the byte array converted to an unsigned long long using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: qulonglong QByteArray::toULongLong(bool* ok = …) const.

C++ documentation:

Returns the byte array converted to an unsigned long long using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_u_long_long_0a(&self) -> u64

Returns the byte array converted to an unsigned long long using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: qulonglong QByteArray::toULongLong() const.

C++ documentation:

Returns the byte array converted to an unsigned long long using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_u_short_2a(&self, ok: *mut bool, base: c_int) -> c_ushort

Returns the byte array converted to an unsigned short using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: unsigned short QByteArray::toUShort(bool* ok = …, int base = …) const.

C++ documentation:

Returns the byte array converted to an unsigned short using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_u_short_1a(&self, ok: *mut bool) -> c_ushort

Returns the byte array converted to an unsigned short using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: unsigned short QByteArray::toUShort(bool* ok = …) const.

C++ documentation:

Returns the byte array converted to an unsigned short using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_u_short_0a(&self) -> c_ushort

Returns the byte array converted to an unsigned short using base base, which is 10 by default and must be between 2 and 36, or 0.

Calls C++ function: unsigned short QByteArray::toUShort() const.

C++ documentation:

Returns the byte array converted to an unsigned short using base base, which is 10 by default and must be between 2 and 36, or 0.

If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

Returns 0 if the conversion fails.

If ok is not 0: if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.

Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.

See also number().

source

pub unsafe fn to_upper(&self) -> CppBox<QByteArray>

Returns an uppercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.

Calls C++ function: QByteArray QByteArray::toUpper() const.

C++ documentation:

Returns an uppercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.

Example:

QByteArray x(“Qt by THE QT COMPANY”); QByteArray y = x.toUpper(); // y == “QT BY THE QT COMPANY”

See also toLower() and 8-bit Character Comparisons.

source

pub unsafe fn to_upper_mut(&self) -> CppBox<QByteArray>

Returns an uppercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.

Calls C++ function: QByteArray QByteArray::toUpper().

C++ documentation:

Returns an uppercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.

Example:

QByteArray x(“Qt by THE QT COMPANY”); QByteArray y = x.toUpper(); // y == “QT BY THE QT COMPANY”

See also toLower() and 8-bit Character Comparisons.

source

pub unsafe fn to_void(&self) -> *const c_void

Calls C++ function: const void* QByteArray::operator const void*() const.

source

pub unsafe fn trimmed(&self) -> CppBox<QByteArray>

Returns a byte array that has whitespace removed from the start and the end.

Calls C++ function: QByteArray QByteArray::trimmed() const.

C++ documentation:

Returns a byte array that has whitespace removed from the start and the end.

Whitespace means any character for which the standard C++ isspace() function returns true in the C locale. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.

Example:

QByteArray ba(“ lots\t of\nwhitespace\r\n “); ba = ba.trimmed(); // ba == “lots\t of\nwhitespace”;

Unlike simplified(), trimmed() leaves internal whitespace alone.

See also simplified().

source

pub unsafe fn trimmed_mut(&self) -> CppBox<QByteArray>

Returns a byte array that has whitespace removed from the start and the end.

Calls C++ function: QByteArray QByteArray::trimmed().

C++ documentation:

Returns a byte array that has whitespace removed from the start and the end.

Whitespace means any character for which the standard C++ isspace() function returns true in the C locale. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.

Example:

QByteArray ba(“ lots\t of\nwhitespace\r\n “); ba = ba.trimmed(); // ba == “lots\t of\nwhitespace”;

Unlike simplified(), trimmed() leaves internal whitespace alone.

See also simplified().

source

pub unsafe fn truncate(&self, pos: c_int)

Truncates the byte array at index position pos.

Calls C++ function: void QByteArray::truncate(int pos).

C++ documentation:

Truncates the byte array at index position pos.

If pos is beyond the end of the array, nothing happens.

Example:

QByteArray ba(“Stockholm”); ba.truncate(5); // ba == “Stock”

See also chop(), resize(), and left().

Trait Implementations§

source§

impl Add<*const i8> for &QByteArray

source§

fn add(self, a2: *const c_char) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray operator+(const QByteArray& a1, const char* a2).

C++ documentation:

This is an overloaded function.

Returns a byte array that is the result of concatenating byte array a1 and string a2.

§

type Output = CppBox<QByteArray>

The resulting type after applying the + operator.
source§

impl Add<Ref<QByteArray>> for &QByteArray

source§

fn add(self, a2: Ref<QByteArray>) -> CppBox<QByteArray>

Returns a byte array that is the result of concatenating byte array a1 and byte array a2.

Calls C++ function: QByteArray operator+(const QByteArray& a1, const QByteArray& a2).

C++ documentation:

Returns a byte array that is the result of concatenating byte array a1 and byte array a2.

See also QByteArray::operator+=().

§

type Output = CppBox<QByteArray>

The resulting type after applying the + operator.
source§

impl Add<Ref<QString>> for &QByteArray

source§

fn add(self, s: Ref<QString>) -> CppBox<QString>

Calls C++ function: QString operator+(const QByteArray& ba, const QString& s).

§

type Output = CppBox<QString>

The resulting type after applying the + operator.
source§

impl Add<i8> for &QByteArray

source§

fn add(self, a2: c_char) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: QByteArray operator+(const QByteArray& a1, char a2).

C++ documentation:

This is an overloaded function.

Returns a byte array that is the result of concatenating byte array a1 and character a2.

§

type Output = CppBox<QByteArray>

The resulting type after applying the + operator.
source§

impl Begin for QByteArray

source§

unsafe fn begin(&self) -> *const c_char

This function overloads begin().

Calls C++ function: const char* QByteArray::begin() const.

C++ documentation:

This function overloads begin().

§

type Output = *const i8

Output type.
source§

impl BeginMut for QByteArray

source§

unsafe fn begin_mut(&self) -> *mut c_char

Returns an STL-style iterator pointing to the first character in the byte-array.

Calls C++ function: char* QByteArray::begin().

C++ documentation:

Returns an STL-style iterator pointing to the first character in the byte-array.

See also constBegin() and end().

§

type Output = *mut i8

Output type.
source§

impl CppDeletable for QByteArray

source§

unsafe fn delete(&self)

Destroys the byte array.

Calls C++ function: [destructor] void QByteArray::~QByteArray().

C++ documentation:

Destroys the byte array.

source§

impl Data for QByteArray

source§

unsafe fn data(&self) -> *const c_char

This is an overloaded function.

Calls C++ function: const char* QByteArray::data() const.

C++ documentation:

This is an overloaded function.

§

type Output = *const i8

Return type of data() function.
source§

impl DataMut for QByteArray

source§

unsafe fn data_mut(&self) -> *mut c_char

Returns a pointer to the data stored in the byte array. The pointer can be used to access and modify the bytes that compose the array. The data is '\0'-terminated, i.e. the number of bytes in the returned character string is size() + 1 for the '\0' terminator.

Calls C++ function: char* QByteArray::data().

C++ documentation:

Returns a pointer to the data stored in the byte array. The pointer can be used to access and modify the bytes that compose the array. The data is ‘\0’-terminated, i.e. the number of bytes in the returned character string is size() + 1 for the ‘\0’ terminator.

Example:

QByteArray ba(“Hello world”); char data = ba.data(); while (data) { cout << “[” << *data << “]” << endl; ++data; }

The pointer remains valid as long as the byte array isn't reallocated or destroyed. For read-only access, constData() is faster because it never causes a deep copy to occur.

This function is mostly useful to pass a byte array to a function that accepts a const char *.

The following example makes a copy of the char* returned by data(), but it will corrupt the heap and cause a crash because it does not allocate a byte for the '\0' at the end:

QString tmp = “test”; QByteArray text = tmp.toLocal8Bit(); char *data = new char[text.size()]; strcpy(data, text.data()); delete [] data;

This one allocates the correct amount of space:

QString tmp = “test”; QByteArray text = tmp.toLocal8Bit(); char *data = new char[text.size() + 1]; strcpy(data, text.data()); delete [] data;

Note: A QByteArray can store any byte values including '\0's, but most functions that take char * arguments assume that the data ends at the first '\0' they encounter.

See also constData() and operator[]().

§

type Output = *mut i8

Return type of data_mut() function.
source§

impl End for QByteArray

source§

unsafe fn end(&self) -> *const c_char

This function overloads end().

Calls C++ function: const char* QByteArray::end() const.

C++ documentation:

This function overloads end().

§

type Output = *const i8

Output type.
source§

impl EndMut for QByteArray

source§

unsafe fn end_mut(&self) -> *mut c_char

Returns an STL-style iterator pointing to the imaginary character after the last character in the byte-array.

Calls C++ function: char* QByteArray::end().

C++ documentation:

Returns an STL-style iterator pointing to the imaginary character after the last character in the byte-array.

See also begin() and constEnd().

§

type Output = *mut i8

Output type.
source§

impl Ge<*const i8> for QByteArray

source§

unsafe fn ge(&self, a2: &*const c_char) -> bool

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator>=(const QByteArray& a1, const char* a2).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator>=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

source§

impl Ge<Ref<QByteArray>> for QByteArray

source§

unsafe fn ge(&self, a2: &Ref<QByteArray>) -> bool

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator>=(const QByteArray& a1, const QByteArray& a2).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator>=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

source§

impl Ge<Ref<QString>> for QByteArray

source§

unsafe fn ge(&self, s2: &Ref<QString>) -> bool

Returns true if this byte array is greater than or equal to string str; otherwise returns false.

Calls C++ function: bool QByteArray::operator>=(const QString& s2) const.

C++ documentation:

Returns true if this byte array is greater than or equal to string str; otherwise returns false.

The Unicode data is converted into 8-bit characters using QString::toUtf8().

The comparison is case sensitive.

You can disable this operator by defining QT_NO_CAST_FROM_ASCII when you compile your applications. You then need to call QString::fromUtf8(), QString::fromLatin1(), or QString::fromLocal8Bit() explicitly if you want to convert the byte array to a QString before doing the comparison.

source§

impl Ge<Ref<QStringRef>> for QByteArray

source§

unsafe fn ge(&self, rhs: &Ref<QStringRef>) -> bool

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator>=(const QByteArray& lhs, const QStringRef& rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator>=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

source§

impl Gt<*const i8> for QByteArray

source§

unsafe fn gt(&self, a2: &*const c_char) -> bool

Calls C++ function: bool operator>(const QByteArray& a1, const char* a2).

source§

impl Gt<Ref<QByteArray>> for QByteArray

source§

unsafe fn gt(&self, a2: &Ref<QByteArray>) -> bool

Calls C++ function: bool operator>(const QByteArray& a1, const QByteArray& a2).

source§

impl Gt<Ref<QString>> for QByteArray

source§

unsafe fn gt(&self, s2: &Ref<QString>) -> bool

Returns true if this byte array is lexically greater than string str; otherwise returns false.

Calls C++ function: bool QByteArray::operator>(const QString& s2) const.

C++ documentation:

Returns true if this byte array is lexically greater than string str; otherwise returns false.

The Unicode data is converted into 8-bit characters using QString::toUtf8().

The comparison is case sensitive.

You can disable this operator by defining QT_NO_CAST_FROM_ASCII when you compile your applications. You then need to call QString::fromUtf8(), QString::fromLatin1(), or QString::fromLocal8Bit() explicitly if you want to convert the byte array to a QString before doing the comparison.

source§

impl Gt<Ref<QStringRef>> for QByteArray

source§

unsafe fn gt(&self, rhs: &Ref<QStringRef>) -> bool

Calls C++ function: bool operator>(const QByteArray& lhs, const QStringRef& rhs).

source§

impl Le<*const i8> for QByteArray

source§

unsafe fn le(&self, a2: &*const c_char) -> bool

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator<=(const QByteArray& a1, const char* a2).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator<=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

source§

impl Le<Ref<QByteArray>> for QByteArray

source§

unsafe fn le(&self, a2: &Ref<QByteArray>) -> bool

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator<=(const QByteArray& a1, const QByteArray& a2).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator<=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

source§

impl Le<Ref<QString>> for QByteArray

source§

unsafe fn le(&self, s2: &Ref<QString>) -> bool

Returns true if this byte array is lexically less than or equal to string str; otherwise returns false.

Calls C++ function: bool QByteArray::operator<=(const QString& s2) const.

C++ documentation:

Returns true if this byte array is lexically less than or equal to string str; otherwise returns false.

The Unicode data is converted into 8-bit characters using QString::toUtf8().

The comparison is case sensitive.

You can disable this operator by defining QT_NO_CAST_FROM_ASCII when you compile your applications. You then need to call QString::fromUtf8(), QString::fromLatin1(), or QString::fromLocal8Bit() explicitly if you want to convert the byte array to a QString before doing the comparison.

source§

impl Le<Ref<QStringRef>> for QByteArray

source§

unsafe fn le(&self, rhs: &Ref<QStringRef>) -> bool

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator<=(const QByteArray& lhs, const QStringRef& rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator<=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

source§

impl Lt<*const i8> for QByteArray

source§

unsafe fn lt(&self, a2: &*const c_char) -> bool

Calls C++ function: bool operator<(const QByteArray& a1, const char* a2).

source§

impl Lt<Ref<QByteArray>> for QByteArray

source§

unsafe fn lt(&self, a2: &Ref<QByteArray>) -> bool

Calls C++ function: bool operator<(const QByteArray& a1, const QByteArray& a2).

source§

impl Lt<Ref<QString>> for QByteArray

source§

unsafe fn lt(&self, s2: &Ref<QString>) -> bool

Returns true if this byte array is lexically less than string str; otherwise returns false.

Calls C++ function: bool QByteArray::operator<(const QString& s2) const.

C++ documentation:

Returns true if this byte array is lexically less than string str; otherwise returns false.

The Unicode data is converted into 8-bit characters using QString::toUtf8().

The comparison is case sensitive.

You can disable this operator by defining QT_NO_CAST_FROM_ASCII when you compile your applications. You then need to call QString::fromUtf8(), QString::fromLatin1(), or QString::fromLocal8Bit() explicitly if you want to convert the byte array to a QString before doing the comparison.

source§

impl Lt<Ref<QStringRef>> for QByteArray

source§

unsafe fn lt(&self, rhs: &Ref<QStringRef>) -> bool

Calls C++ function: bool operator<(const QByteArray& lhs, const QStringRef& rhs).

source§

impl PartialEq<*const i8> for QByteArray

source§

fn eq(&self, a2: &*const c_char) -> bool

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(const QByteArray& a1, const char* a2).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Ref<QByteArray>> for QByteArray

source§

fn eq(&self, a2: &Ref<QByteArray>) -> bool

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(const QByteArray& a1, const QByteArray& a2).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Ref<QString>> for QByteArray

source§

fn eq(&self, s2: &Ref<QString>) -> bool

Returns true if this byte array is equal to string str; otherwise returns false.

Calls C++ function: bool QByteArray::operator==(const QString& s2) const.

C++ documentation:

Returns true if this byte array is equal to string str; otherwise returns false.

The Unicode data is converted into 8-bit characters using QString::toUtf8().

The comparison is case sensitive.

You can disable this operator by defining QT_NO_CAST_FROM_ASCII when you compile your applications. You then need to call QString::fromUtf8(), QString::fromLatin1(), or QString::fromLocal8Bit() explicitly if you want to convert the byte array to a QString before doing the comparison.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Ref<QStringRef>> for QByteArray

source§

fn eq(&self, rhs: &Ref<QStringRef>) -> bool

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(const QByteArray& lhs, const QStringRef& rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Size for QByteArray

source§

unsafe fn size(&self) -> usize

Returns the number of bytes in this byte array.

Calls C++ function: int QByteArray::size() const.

C++ documentation:

Returns the number of bytes in this byte array.

The last byte in the byte array is at position size() - 1. In addition, QByteArray ensures that the byte at position size() is always '\0', so that you can use the return value of data() and constData() as arguments to functions that expect '\0'-terminated strings. If the QByteArray object was created from a raw data that didn't include the trailing null-termination character then QByteArray doesn't add it automaticall unless the deep copy is created.

Example:

QByteArray ba(“Hello”); int n = ba.size(); // n == 5 ba.data()[0]; // returns ‘H’ ba.data()[4]; // returns ‘o’ ba.data()[5]; // returns ‘\0’

See also isEmpty() and resize().

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.