The QByteArray class provides an array of bytes. More...
#include <qstring.h>
Inherits QArray.
Inherited by QBitArray and QString.
QByteArray is defined as QArray<char>.
Constructs a null array.
See also: isNull().
Constructs a shallow copy of a.
See also: assign().
Constructs an array with room for size elements. Makes a null array if size == 0.
Note that the elements are not initialized.
See also: resize() and isNull().
[protected]
Constructs an array without allocating array space. The arguments should be (0, 0). Use at own risk.
Dereferences the array data and deletes it if this was the last reference.
Cast operator. Returns a pointer to the array.
See also: data().
Shallow copy. Dereferences the current array and references the data contained in a instead. Returns a reference to this array.
See also: operator=().
Shallow copy. Dereferences the current array and references the array data data, which contains size elements. Returns a reference to this array.
Do not delete data later, QArray takes care of that.
Returns a reference to the element at position index in the array.
This can be used to both read and set an element.
See also: operator[]().
Returns the number of times v occurs in the array.
See also: find().
Returns a deep copy of this array.
See also: detach() and duplicate().
Returns a pointer to the actual array data.
The array is a null array if data() == 0 (null pointer).
See also: isNull().
[virtual]
Detaches this array from shared array data, i.e. makes a private, deep copy of the data.
Copying will only be performed if the reference count is greater than one.
See also: copy().
Reimplemented from QGArray.
Deep copy. Dereferences the current array and obtains a copy of the data contained in a instead. Returns a reference to this array.
See also: copy().
Deep copy. Dereferences the current array and obtains a copy of the array data data instead. Returns a reference to this array.
See also: copy().
Fills the array with the value v. If size is specified as different from -1, then the array will be resized before filled.
Returns TRUE if successful, or FALSE if the memory cannot be allocated (only when size != -1).
See also: resize().
Finds the first occurrence of v, starting at position index.
Returns the position of v, or -1 if v could not be found.
See also: contains().
Returns TRUE if the array is empty, i.e. size() == 0, otherwise FALSE.
isEmpty() is equivalent with isNull() for QArray. Note that this is not the case for QString::isEmpty().
Returns TRUE if the array is null, otherwise FALSE.
A null array has size() == 0 and data() == 0.
Returns the reference count for the shared array data. This reference count is always greater than zero.
Returns TRUE if this array is different from a, otherwise FALSE.
The two arrays are bitwise compared.
See also: operator==().
Assigns a shallow copy of a to this array and returns a reference to this array.
Equivalent to assign( a ).
Returns TRUE if this array is equal to a, otherwise FALSE.
The two arrays are bitwise compared.
See also: operator!=().
Returns a reference to the element at position index in the array.
This can be used to both read and set an element. Equivalent to at().
See also: at().
Resets raw data that was set using setRawData().
The arguments must be the data and length that were passed to setRawData(). This is for consistency checking.
See also: setRawData().
Resizes (expands or shrinks) the array to size elements. The array becomes a null array if size == 0.
Returns TRUE if successful, or FALSE if the memory cannot be allocated.
New elements will not be initialized.
See also: size().
Sets raw data and returns a reference to the array.
Dereferences the current array and sets the new array data to data and the new array size to size. Do not attempt to resize or re-assign the array data when raw data has been set. Call resetRawData(d,len) to reset the array.
Setting raw data is useful because it sets QArray data without allocating memory or copying data.
Example I (intended use):
static char bindata[] = { 231, 1, 44, ... }; QByteArray a; a.setRawData( bindata, sizeof(bindata) ); // a points to bindata QDataStream s( a, IO_ReadOnly ); // open on a's data s >> <something>; // read raw bindata a.resetRawData( bindata, sizeof(bindata) ); // finished
Example II (you don't want to do this):
static char bindata[] = { 231, 1, 44, ... }; QByteArray a, b; a.setRawData( bindata, sizeof(bindata) ); // a points to bindata a.resize( 8 ); // will crash b = a; // will crash a[2] = 123; // might crash // forget to resetRawData - will crash
Warning: If you do not call resetRawData(), QArray will attempt to deallocate or reallocate the raw data, which might not be too good. Be careful.
See also: resetRawData().
Returns the size of the array (max number of elements).
The array is a null array if size() == 0.
See also: isNull() and resize().
Truncates the array at position pos.
Returns TRUE if successful, or FALSE if the memory cannot be allocated.
Equivalent to resize(pos).
See also: resize().
Returns the CRC-16 checksum of len bytes starting at data.
The checksum is independent of the byte order (endianness).
Please use qChecksum; this function is provided only for upward compatibility.
Writes a byte array to a stream and returns a reference to the stream.
The serialization format is the byte array size (Q_UINT32)
followed by
this number of bytes.
Reads a byte array from a stream and returns a reference to the stream.
Search the documentation, FAQ, qt-interest archive and more (uses
www.troll.no):
This file is part of the Qt toolkit, copyright © 1995-98 Troll Tech, all rights reserved.
It was generated from the following files:
Copyright © 1998 Troll Tech | Trademarks | Qt version 1.42
|