#include <qbytearray.h>
Inheritance diagram for QByteArray:


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 Qtopia Core).
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. 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. 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.
If you are building a QByteArray gradually and know in advance approximately how many bytes the QByteArray will contain, you can call reserve(), asking QByteArray to preallocate a certain amount of memory. You can also call capacity() to find out how much memory QByteArray actually allocated.
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().
In QByteArray, the notion of uppercase and lowercase and of which character is greater than or less than another character is locale dependent. This affects functions that support a case insensitive option or that compare or lowercase or uppercase their arguments. Case insensitive operations and comparisons will be accurate if both strings contain only ASCII characters. (If \c $LC_CTYPE is set, most Unix systems do "the right thing".) Functions that this affects include contains(), indexOf(), lastIndexOf(), operator<(), operator<=(), operator>(), operator>=(), toLower() and toUpper(). This issue does not apply to QStrings since they represent characters using Unicode. \sa QString, QBitArray Definition at line 99 of file qbytearray.h.
Public Types | |
| typedef char * | iterator |
| typedef const char * | const_iterator |
| typedef iterator | Iterator |
| typedef const_iterator | ConstIterator |
| typedef const char & | const_reference |
| typedef char & | reference |
Public Member Functions | |
| QByteArray () | |
| QByteArray (const char *) | |
| QByteArray (const char *, int size) | |
| QByteArray (int size, char c) | |
| QByteArray (const QByteArray &) | |
| ~QByteArray () | |
| QByteArray & | operator= (const QByteArray &) |
| QByteArray & | operator= (const char *str) |
| int | size () const |
| bool | isEmpty () const |
| void | resize (int size) |
| QByteArray & | fill (char c, int size=-1) |
| int | capacity () const |
| void | reserve (int size) |
| void | squeeze () |
| operator const char * () const | |
| operator const void * () const | |
| char * | data () |
| const char * | data () const |
| const char * | constData () const |
| void | detach () |
| bool | isDetached () const |
| void | clear () |
| const char | at (int i) const |
| const char | operator[] (int i) const |
| QByteRef | operator[] (int i) |
| const char | operator[] (uint i) const |
| QByteRef | operator[] (uint i) |
| int | indexOf (char c, int from=0) const |
| int | indexOf (const char *c, int from=0) const |
| int | indexOf (const QByteArray &a, int from=0) const |
| int | lastIndexOf (char c, int from=-1) const |
| int | lastIndexOf (const char *c, int from=-1) const |
| int | lastIndexOf (const QByteArray &a, int from=-1) const |
| QBool | contains (char c) const |
| QBool | contains (const char *a) const |
| QBool | contains (const QByteArray &a) const |
| int | count (char c) const |
| int | count (const char *a) const |
| int | count (const QByteArray &a) const |
| QByteArray | left (int len) const |
| QByteArray | right (int len) const |
| QByteArray | mid (int index, int len=-1) const |
| bool | startsWith (const QByteArray &a) const |
| bool | startsWith (char c) const |
| bool | startsWith (const char *c) const |
| bool | endsWith (const QByteArray &a) const |
| bool | endsWith (char c) const |
| bool | endsWith (const char *c) const |
| void | truncate (int pos) |
| void | chop (int n) |
| QByteArray | toLower () const |
| QByteArray | toUpper () const |
| QByteArray | trimmed () const |
| QByteArray | simplified () const |
| QByteArray | leftJustified (int width, char fill= ' ', bool truncate=false) const |
| QByteArray | rightJustified (int width, char fill= ' ', bool truncate=false) const |
| QByteArray & | prepend (char c) |
| QByteArray & | prepend (const char *s) |
| QByteArray & | prepend (const QByteArray &a) |
| QByteArray & | append (char c) |
| QByteArray & | append (const char *s) |
| QByteArray & | append (const QByteArray &a) |
| QByteArray & | insert (int i, char c) |
| QByteArray & | insert (int i, const char *s) |
| QByteArray & | insert (int i, const QByteArray &a) |
| QByteArray & | remove (int index, int len) |
| QByteArray & | replace (int index, int len, const char *s) |
| QByteArray & | replace (int index, int len, const QByteArray &s) |
| QByteArray & | replace (char before, const char *after) |
| QByteArray & | replace (char before, const QByteArray &after) |
| QByteArray & | replace (const char *before, const char *after) |
| QByteArray & | replace (const QByteArray &before, const QByteArray &after) |
| QByteArray & | replace (const QByteArray &before, const char *after) |
| QByteArray & | replace (const char *before, const QByteArray &after) |
| QByteArray & | replace (char before, char after) |
| QByteArray & | operator+= (char c) |
| QByteArray & | operator+= (const char *s) |
| QByteArray & | operator+= (const QByteArray &a) |
| QList< QByteArray > | split (char sep) const |
| QT_ASCII_CAST_WARN QByteArray & | append (const QString &s) |
| QT_ASCII_CAST_WARN QByteArray & | insert (int i, const QString &s) |
| QT_ASCII_CAST_WARN QByteArray & | replace (const QString &before, const char *after) |
| QT_ASCII_CAST_WARN QByteArray & | replace (char c, const QString &after) |
| QT_ASCII_CAST_WARN QByteArray & | replace (const QString &before, const QByteArray &after) |
| QT_ASCII_CAST_WARN QByteArray & | operator+= (const QString &s) |
| QT_ASCII_CAST_WARN int | indexOf (const QString &s, int from=0) const |
| QT_ASCII_CAST_WARN int | lastIndexOf (const QString &s, int from=-1) const |
| QT_ASCII_CAST_WARN bool | operator== (const QString &s2) const |
| QT_ASCII_CAST_WARN bool | operator!= (const QString &s2) const |
| QT_ASCII_CAST_WARN bool | operator< (const QString &s2) const |
| QT_ASCII_CAST_WARN bool | operator> (const QString &s2) const |
| QT_ASCII_CAST_WARN bool | operator<= (const QString &s2) const |
| QT_ASCII_CAST_WARN bool | operator>= (const QString &s2) const |
| short | toShort (bool *ok=0, int base=10) const |
| ushort | toUShort (bool *ok=0, int base=10) const |
| int | toInt (bool *ok=0, int base=10) const |
| uint | toUInt (bool *ok=0, int base=10) const |
| long | toLong (bool *ok=0, int base=10) const |
| ulong | toULong (bool *ok=0, int base=10) const |
| qlonglong | toLongLong (bool *ok=0, int base=10) const |
| qulonglong | toULongLong (bool *ok=0, int base=10) const |
| float | toFloat (bool *ok=0) const |
| double | toDouble (bool *ok=0) const |
| QByteArray | toBase64 () const |
| QByteArray & | setNum (short, int base=10) |
| QByteArray & | setNum (ushort, int base=10) |
| QByteArray & | setNum (int, int base=10) |
| QByteArray & | setNum (uint, int base=10) |
| QByteArray & | setNum (qlonglong, int base=10) |
| QByteArray & | setNum (qulonglong, int base=10) |
| QByteArray & | setNum (float, char f= 'g', int prec=6) |
| QByteArray & | setNum (double, char f= 'g', int prec=6) |
| iterator | begin () |
| const_iterator | begin () const |
| const_iterator | constBegin () const |
| iterator | end () |
| const_iterator | end () const |
| const_iterator | constEnd () const |
| void | push_back (char c) |
| void | push_back (const char *c) |
| void | push_back (const QByteArray &a) |
| void | push_front (char c) |
| void | push_front (const char *c) |
| void | push_front (const QByteArray &a) |
| int | count () const |
| int | length () const |
| bool | isNull () const |
Static Public Member Functions | |
| static QByteArray | number (int, int base=10) |
| static QByteArray | number (uint, int base=10) |
| static QByteArray | number (qlonglong, int base=10) |
| static QByteArray | number (qulonglong, int base=10) |
| static QByteArray | number (double, char f= 'g', int prec=6) |
| static QByteArray | fromRawData (const char *, int size) |
| static QByteArray | fromBase64 (const QByteArray &base64) |
Private Member Functions | |
| operator QNoImplicitBoolCast () const | |
| QByteArray (Data *dd, int, int) | |
| void | realloc (int alloc) |
| void | expand (int i) |
Private Attributes | |
| Data * | d |
Static Private Attributes | |
| static Data | shared_null |
| static Data | shared_empty |
Friends | |
| class | QByteRef |
| class | QString |
Related Functions | |
| (Note that these are not member functions.) | |
| char * | qstrdup (const char *src) |
| char * | qstrcpy (char *dst, const char *src) |
| char * | qstrncpy (char *dst, const char *src, uint len) |
| uint | qstrlen (const char *str) |
| uint | qstrnlen (const char *str, uint maxlen) |
| int | qstrcmp (const char *str1, const char *str2) |
| int | qstrncmp (const char *str1, const char *str2, uint len) |
| int | qstricmp (const char *str1, const char *str2) |
| int | qstrnicmp (const char *str1, const char *str2, uint len) |
| quint16 | qChecksum (const char *data, uint len) |
| QByteArray | qCompress (const QByteArray &data, int compressionLevel) |
| QByteArray | qCompress (const uchar *data, int nbytes, int compressionLevel) |
| QByteArray | qUncompress (const QByteArray &data) |
| QByteArray | qUncompress (const uchar *data, int nbytes) |
| QDataStream & | operator<< (QDataStream &out, const QByteArray &ba) |
| QDataStream & | operator>> (QDataStream &in, QByteArray &ba) |
| bool | operator== (const QByteArray &a1, const QByteArray &a2) |
| bool | operator== (const QByteArray &a1, const char *a2) |
| bool | operator== (const char *a1, const QByteArray &a2) |
| bool | operator!= (const QByteArray &a1, const QByteArray &a2) |
| bool | operator!= (const QByteArray &a1, const char *a2) |
| bool | operator!= (const char *a1, const QByteArray &a2) |
| bool | operator< (const QByteArray &a1, const QByteArray &a2) |
| bool | operator< (const QByteArray &a1, const char *a2) |
| bool | operator< (const char *a1, const QByteArray &a2) |
| bool | operator<= (const QByteArray &a1, const QByteArray &a2) |
| bool | operator<= (const QByteArray &a1, const char *a2) |
| bool | operator<= (const char *a1, const QByteArray &a2) |
| bool | operator> (const QByteArray &a1, const QByteArray &a2) |
| bool | operator> (const QByteArray &a1, const char *a2) |
| bool | operator> (const char *a1, const QByteArray &a2) |
| bool | operator>= (const QByteArray &a1, const QByteArray &a2) |
| bool | operator>= (const QByteArray &a1, const char *a2) |
| bool | operator>= (const char *a1, const QByteArray &a2) |
| const QByteArray | operator+ (const QByteArray &a1, const QByteArray &a2) |
| const QByteArray | operator+ (const QByteArray &a1, const char *a2) |
| const QByteArray | operator+ (const QByteArray &a1, char a2) |
| const QByteArray | operator+ (const char *a1, const QByteArray &a2) |
| const QByteArray | operator+ (char a1, const QByteArray &a2) |
| int | qvsnprintf (char *str, size_t n, const char *fmt, va_list ap) |
| int | qsnprintf (char *str, size_t n, const char *fmt,...) |
Classes | |
| struct | Data |
Definition at line 255 of file qbytearray.h.
Definition at line 256 of file qbytearray.h.
Definition at line 257 of file qbytearray.h.
Definition at line 258 of file qbytearray.h.
Definition at line 267 of file qbytearray.h.
Definition at line 268 of file qbytearray.h.
| QByteArray::QByteArray | ( | ) | [inline] |
Constructs an empty byte array.
Definition at line 324 of file qbytearray.h.
References d, QByteArray::Data::ref, and QBasicAtomic::ref().
Referenced by fromRawData(), left(), mid(), operator+(), right(), and trimmed().
00324 : d(&shared_null) { d->ref.ref(); }
Here is the call graph for this function:

| QByteArray::QByteArray | ( | const char * | str | ) |
Constructs a byte array initialized with the string str.
QByteArray makes a deep copy of the string data.
Definition at line 1201 of file qbytearray.cpp.
References QByteArray::Data::alloc, QByteArray::Data::array, d, QByteArray::Data::data, QBasicAtomic::init(), len, qMalloc(), qstrlen(), QByteArray::Data::ref, QBasicAtomic::ref(), shared_empty, shared_null, and QByteArray::Data::size.
01202 { 01203 if (!str) { 01204 d = &shared_null; 01205 } else if (!*str) { 01206 d = &shared_empty; 01207 } else { 01208 int len = qstrlen(str); 01209 d = static_cast<Data *>(qMalloc(sizeof(Data)+len)); 01210 if (!d) { 01211 d = &shared_null; 01212 } else { 01213 d->ref.init(0); 01214 d->alloc = d->size = len; 01215 d->data = d->array; 01216 memcpy(d->array, str, len+1); // include null terminator 01217 } 01218 } 01219 d->ref.ref(); 01220 }
Here is the call graph for this function:

| QByteArray::QByteArray | ( | const char * | data, | |
| int | size | |||
| ) |
Constructs a byte array containing the first size bytes of array data.
If data is 0, a null byte array is constructed.
QByteArray makes a deep copy of the string data.
Definition at line 1233 of file qbytearray.cpp.
References QByteArray::Data::alloc, QByteArray::Data::array, d, QByteArray::Data::data, QBasicAtomic::init(), qMalloc(), QByteArray::Data::ref, QBasicAtomic::ref(), shared_empty, shared_null, and QByteArray::Data::size.
01234 { 01235 if (!data) { 01236 d = &shared_null; 01237 } else if (size <= 0) { 01238 d = &shared_empty; 01239 } else { 01240 d = static_cast<Data *>(qMalloc(sizeof(Data) + size)); 01241 if (!d) { 01242 d = &shared_null; 01243 } else { 01244 d->ref.init(0); 01245 d->alloc = d->size = size; 01246 d->data = d->array; 01247 memcpy(d->array, data, size); 01248 d->array[size] = '\0'; 01249 } 01250 } 01251 d->ref.ref(); 01252 }
Here is the call graph for this function:

| QByteArray::QByteArray | ( | int | size, | |
| char | ch | |||
| ) |
Constructs a byte array of size size with every byte set to character ch.
Definition at line 1261 of file qbytearray.cpp.
References QByteArray::Data::alloc, QByteArray::Data::array, d, QByteArray::Data::data, QBasicAtomic::init(), qMalloc(), QByteArray::Data::ref, QBasicAtomic::ref(), shared_null, and QByteArray::Data::size.
01262 { 01263 if (size <= 0) { 01264 d = &shared_null; 01265 } else { 01266 d = static_cast<Data *>(qMalloc(sizeof(Data)+size)); 01267 if (!d) { 01268 d = &shared_null; 01269 } else { 01270 d->ref.init(0); 01271 d->alloc = d->size = size; 01272 d->data = d->array; 01273 d->array[size] = '\0'; 01274 memset(d->array, ch, size); 01275 } 01276 } 01277 d->ref.ref(); 01278 }
Here is the call graph for this function:

| QByteArray::QByteArray | ( | const QByteArray & | other | ) | [inline] |
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), and that takes {linear time}.
Definition at line 350 of file qbytearray.h.
References d, QByteArray::Data::ref, and QBasicAtomic::ref().
Here is the call graph for this function:

| QByteArray::~QByteArray | ( | ) | [inline] |
Destroys the byte array.
Definition at line 325 of file qbytearray.h.
References d, QBasicAtomic::deref(), qFree(), and QByteArray::Data::ref.
Here is the call graph for this function:

| QByteArray::QByteArray | ( | Data * | dd, | |
| int | , | |||
| int | ||||
| ) | [inline, private] |
| QByteArray & QByteArray::operator= | ( | const QByteArray & | other | ) |
Assigns other to this byte array and returns a reference to this byte array.
Definition at line 787 of file qbytearray.cpp.
References d, qAtomicSetPtr(), qFree(), and x.
Referenced by Q3CString::operator=().
00788 { 00789 Data *x = other.d; 00790 x->ref.ref(); 00791 x = qAtomicSetPtr(&d, x); 00792 if (!x->ref.deref()) 00793 qFree(x); 00794 return *this; 00795 }
Here is the call graph for this function:

| QByteArray & QByteArray::operator= | ( | const char * | str | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Assigns str to this byte array.
Definition at line 804 of file qbytearray.cpp.
References QByteArray::Data::alloc, d, len, qAtomicSetPtr(), qFree(), qstrlen(), realloc(), QByteArray::Data::ref, shared_empty, shared_null, size(), and x.
00805 { 00806 Data *x; 00807 if (!str) { 00808 x = &shared_null; 00809 } else if (!*str) { 00810 x = &shared_empty; 00811 } else { 00812 int len = qstrlen(str); 00813 if (d->ref != 1 || len > d->alloc || (len < d->size && len < d->alloc >> 1)) 00814 realloc(len); 00815 x = d; 00816 memcpy(x->data, str, len + 1); // include null terminator 00817 x->size = len; 00818 } 00819 x->ref.ref(); 00820 x = qAtomicSetPtr(&d, x); 00821 if (!x->ref.deref()) 00822 qFree(x); 00823 return *this; 00824 }
Here is the call graph for this function:

| int QByteArray::size | ( | ) | const [inline] |
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.
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'
Definition at line 326 of file qbytearray.h.
References d, and QByteArray::Data::size.
Referenced by QHttpPrivate::_q_slotConnected(), QHttpPrivate::_q_slotReadyRead(), QSocks5SocketEnginePrivate::_q_udpSocketReadNotification(), SaveFormAsTemplate::accept(), CPP::WriteIconData::acceptImage(), Q3Membuf::append(), QPdf::ascii85Encode(), at(), QSocks5PasswordAuthenticator::beginAuthenticate(), Sender::broadcastDatagram(), QSimpleTextCodec::buildReverseMap(), PeerWireClient::bytesAvailable(), QFtpDTP::bytesAvailable(), checksum(), cleaned(), QTextCodec::codecForHtml(), codecForHTML(), composePreprocessorOutput(), QSimpleTextCodec::convertFromUnicode(), Q3UrlOperator::copyGotData(), create_wm_client_leader(), Q3TextDrag::decode(), Q3IconDragPrivate::decode(), Q3UriDrag::decode(), ScopedTokenReplacement::doReplace(), QPSPrintEnginePrivate::drawImage(), embedData(), QPdfEnginePrivate::embedFont(), encodeEntity(), QClipboard::event(), QODBCResult::exec(), QIBaseResultPrivate::fetchBlob(), QClipboardWatcher::formats_sys(), QSqlDriver::formatValue(), QMYSQLDriver::formatValue(), fromBase64(), QUrl::fromPercentEncoding(), QUrl::fromPunycode(), Moc::generate(), generateGlyphTables(), Generator::generateSignal(), BencodeParser::getByteString(), BencodeParser::getDictionary(), BencodeParser::getInteger(), BencodeParser::getList(), getToken(), TrackerClient::httpRequestDone(), QGifHandler::imageIsComing(), QByteArrayMatcher::indexIn(), indexOf(), QSettingsPrivate::iniEscapedString(), MainWindow::loadLayout(), main(), normalizeTypeInternal(), Q3LocalFs::operationPut(), QBitArray::operator &=(), operator+(), operator<(), operator<<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), operator[](), QBitArray::operator^=(), QBitArray::operator|=(), QBitArray::operator~(), MetaInfo::parse(), QSocks5SocketEnginePrivate::parseNewConnection(), QSocks5SocketEnginePrivate::parseRequestMethodReply(), Moc::parseType(), QRingBuffer::peek(), QIODevice::peek(), Connection::processData(), PeerWireClient::processIncomingData(), Receiver::processPendingDatagrams(), Connection::processReadyRead(), Q3DnsAnswer::Q3DnsAnswer(), QBitArray::QBitArray(), qbytearray_insert(), qGetBinaryData(), qt_x11_apply_settings_in_all_apps(), qtMD5(), qUncompress(), QFtpDTP::read(), QRingBuffer::read(), QGifHandler::read(), read_xpm_body(), read_xpm_string(), Q3FtpDTP::readAll(), QIODevice::readAll(), QFtpDTP::readAll(), PeerManager::readBroadcastDatagram(), PeerWireClient::readData(), QSocks5SocketEngine::readDatagram(), Connection::readDataIntoBuffer(), PeerWireClient::readFromSocket(), QConfFileSettingsPrivate::readIniFile(), QIODevice::readLine(), replace(), QBitArray::resize(), QInternalMimeData::retrieveData(), QClipboardWatcher::retrieveData_sys(), runlengthEncode(), Translator::save(), QAbstractFormBuilder::save(), MainWindow::saveLayout(), Server::sendFortune(), Connection::sendGreetingMessage(), Connection::sendMessage(), PeerWireClient::sendPieceList(), QByteArrayMatcher::setPattern(), TorrentClient::setTorrent(), Q3UriDrag::setUris(), Q3Http::slotConnected(), Q3Http::slotReadyRead(), QFtpDTP::socketReadyRead(), Q3FtpDTP::socketReadyRead(), Q3Process::socketWrite(), Q3CString::sprintf(), Q3HttpNormalRequest::start(), SubArray::SubArray(), Symbol::Symbol(), toBase64(), QUrl::toPercentEncoding(), QUrl::toPunycode(), QKeyMapperPrivate::translateKeyEventInternal(), translateKeySym(), truncate(), FileManager::verifySinglePiece(), QSocks5SocketEngine::write(), QIBaseResultPrivate::writeBlob(), PeerWireClient::writeData(), QSocks5SocketEngine::writeDatagram(), FileWriter::writeFile(), QDesignerActions::writeOutForm(), PeerWireClient::writeToSocket(), QClipboardINCRTransaction::x11Event(), QXIMInputContext::x11FilterEvent(), QX11Data::xdndMimeDataForAtom(), and xdndObtainData().
| bool QByteArray::isEmpty | ( | ) | const [inline] |
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
Definition at line 334 of file qbytearray.h.
References d, and QByteArray::Data::size.
Referenced by QFontDatabasePrivate::addAppFont(), QPdfEnginePrivate::addBrushPattern(), QUrl::addQueryItem(), PeerWireClient::canTransferMore(), checkSymbolFont(), QTextCodec::codecForName(), create_wm_client_leader(), createReadHandler(), QDBusArgumentPrivate::createSignature(), ProReader::currentBlock(), data(), Q3MimeSourceFactory::dataInternal(), Q3ImageDrag::decode(), ScopedTokenReplacement::doReplace(), QPdfBaseEnginePrivate::drawTextItem(), PreprocessReplace::evaluateIncludeDirective(), IncludeDirectiveAnalyzer::evaluateIncludeDirective(), TrackerClient::fetchPeerList(), QualifiedNameParser::findScopeOperator(), QPSPrintEnginePrivate::flushPage(), fontFile(), QImageReader::format(), Generator::generateCode(), generateInterfaceXml(), Generator::generateMetacall(), Generator::generateSignal(), QFreetypeFace::getFace(), getLprPrinters(), QGifHandler::imageIsComing(), QTest::incidentType2String(), ProReader::insertComment(), ProReader::insertVariable(), QUrl::isEmpty(), Translator::isEmpty(), ReplaceToken::isInterestingToken(), HelpWindow::isKDERunning(), QSignalSpy::isValid(), QDBusUtil::isValidMemberName(), listInterface(), main(), QTest::messageType2String(), QX11Data::motifdndObtainData(), QPpmHandler::name(), QualifiedNameParser::nextScopeToken(), operator!=(), TranslatorMessage::operator==(), operator==(), BencodeParser::parse(), QUrlPrivate::parse(), Moc::parseFunction(), Semantic::parseFunctionDeclaration(), Moc::parseMaybeFunction(), QDBusMetaObjectGenerator::parseMethods(), QDBusMetaObjectGenerator::parseSignals(), Q3TextEdit::pasteSpecial(), PeerManager::PeerManager(), Preprocessor::preprocess(), Preprocessor::preprocessed(), PeerWireClient::processIncomingData(), Q_GLOBAL_STATIC_WITH_ARGS(), QDBusConnectionPrivate::QDBusConnectionPrivate(), qmake_mkspec_paths(), QUrl::queryItems(), QPictureIO::read(), QGifHandler::read(), read_xpm_body(), read_xpm_string(), registerFont(), MetaTranslator::release(), QInternalMimeData::renderDataHelper(), Parser::reportError(), QMainWindow::restoreState(), QInternalMimeData::retrieveData(), QMimeDataPrivate::retrieveTypedData(), MetaTranslator::save(), Translator::save(), Q3FileDialog::setDir(), QTextHtmlExporter::toHtml(), QUrl::toPercentEncoding(), QFontSubset::toTruetype(), QFontSubset::toType1(), translateKeySym(), Q3TextDeleteCommand::unexecute(), Translator::unsqueeze(), QDesignerLabel::updateBuddy(), ProReader::updateItem(), QMetaEnum::valueToKeys(), QPictureIO::write(), writeAdaptor(), QConfFileSettingsPrivate::writeIniFile(), and PeerWireClient::writeToSocket().
| void QByteArray::resize | ( | int | size | ) |
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.
Definition at line 1293 of file qbytearray.cpp.
References QByteArray::Data::alloc, QByteArray::Data::array, d, QByteArray::Data::data, qAllocMore(), qAtomicSetPtr(), qFree(), qMalloc(), realloc(), QByteArray::Data::ref, shared_empty, shared_null, QByteArray::Data::size, and x.
Referenced by QHttpPrivate::_q_slotBytesWritten(), QHttpPrivate::_q_slotReadyRead(), QPdfEnginePrivate::addImage(), QPdf::ascii85Encode(), bindFont(), QSimpleTextCodec::buildReverseMap(), chop(), cleaned(), QX11Data::clipboardReadIncrementalProperty(), composePreprocessorOutput(), compress(), QSimpleTextCodec::convertFromUnicode(), QFontLaoCodec::convertFromUnicode(), QBig5hkscsCodec::convertFromUnicode(), QEucKrCodec::convertFromUnicode(), QSjisCodec::convertFromUnicode(), QUtf8Codec::convertFromUnicode(), QGb2312Codec::convertFromUnicode(), QEucJpCodec::convertFromUnicode(), QIsciiCodec::convertFromUnicode(), QBig5Codec::convertFromUnicode(), QTsciiCodec::convertFromUnicode(), QLatin1Codec::convertFromUnicode(), QGbkCodec::convertFromUnicode(), QGb18030Codec::convertFromUnicode(), QLatin15Codec::convertFromUnicode(), QODBCResult::exec(), expand(), QIBaseResultPrivate::fetchBlob(), fill(), fromBase64(), generateGlyphTables(), getGlyphData(), getLprPrinters(), QFreetypeFace::getSfntTable(), leftJustified(), Q3CString::leftJustify(), normalizeTypeInternal(), QIBaseDriver::open(), operator>>(), Q3TextStream::operator>>(), parseSpoolInterface(), QRingBuffer::peek(), QBitArray::QBitArray(), qbytearray_insert(), qCompress(), qGetBinaryData(), qUncompress(), QRingBuffer::read(), QHttp::readAll(), Q3Http::readAll(), QIODevice::readAll(), Q3Membuf::readAll(), PeerManager::readBroadcastDatagram(), PeerWireClient::readFromSocket(), QIODevice::readLine(), remove(), QInternalMimeData::renderDataHelper(), replace(), QBitArray::resize(), rightJustified(), Q3CString::rightJustify(), Q3CString::setExpand(), TorrentClient::setTorrent(), simplified(), Q3Http::slotReadyRead(), Q3Process::socketRead(), QFtpDTP::socketReadyRead(), Q3FtpDTP::socketReadyRead(), Q3CString::sprintf(), Translator::squeeze(), toBase64(), QString::toLatin1(), QString::toUtf8(), QKeyMapperPrivate::translateKeyEventInternal(), translateKeySym(), truncate(), PeerWireClient::writeData(), Q3Process::writeToStdin(), QXIMInputContext::x11FilterEvent(), and zeroKey().
01294 { 01295 if (size <= 0) { 01296 Data *x = &shared_empty; 01297 x->ref.ref(); 01298 x = qAtomicSetPtr(&d, x); 01299 if (!x->ref.deref()) 01300 qFree(x); 01301 } else if ( d == &shared_null ) { 01302 // 01303 // Optimize the idiom: 01304 // QByteArray a; 01305 // a.resize(sz); 01306 // ... 01307 // which is used in place of the Qt 3 idiom: 01308 // QByteArray a(sz); 01309 // 01310 Data *x = static_cast<Data *>(qMalloc(sizeof(Data)+size)); 01311 x->ref.init(1); 01312 x->alloc = x->size = size; 01313 x->data = x->array; 01314 x->array[size] = '\0'; 01315 x = qAtomicSetPtr(&d, x); 01316 (void) x->ref.deref(); // cannot be 0, x points to shared_null 01317 } else { 01318 if (d->ref != 1 || size > d->alloc || (size < d->size && size < d->alloc >> 1)) 01319 realloc(qAllocMore(size, sizeof(Data))); 01320 if (d->alloc >= size) { 01321 d->size = size; 01322 if (d->data == d->array) { 01323 d->array[size] = '\0'; 01324 } 01325 } 01326 } 01327 }
Here is the call graph for this function:

| QByteArray & QByteArray::fill | ( | char | ch, | |
| int | size = -1 | |||
| ) |
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"
Definition at line 1347 of file qbytearray.cpp.
References d, QByteArray::Data::data, resize(), and QByteArray::Data::size.
Referenced by QTest::qSignalDumperCallback(), and QTest::qSignalDumperCallbackSlot().
01348 { 01349 resize(size < 0 ? d->size : size); 01350 if (d->size) 01351 memset(d->data, ch, d->size); 01352 return *this; 01353 }
Here is the call graph for this function:

| int QByteArray::capacity | ( | ) | const [inline] |
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().
Definition at line 357 of file qbytearray.h.
References QByteArray::Data::alloc, and d.
| void QByteArray::reserve | ( | int | size | ) | [inline] |
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().
Definition at line 360 of file qbytearray.h.
References QByteArray::Data::alloc, d, realloc(), and QByteArray::Data::ref.
Referenced by _IPv4Address(), cleaned(), QSettingsPrivate::iniEscapedKey(), QSettingsPrivate::iniEscapedString(), QMetaObject::invokeMethod(), QMetaObject::normalizedSignature(), normalizeTypeInternal(), QUrlPrivate::parse(), QDBusMetaObjectGenerator::write(), and QSocks5SocketEngine::writeDatagram().
Here is the call graph for this function:

| void QByteArray::squeeze | ( | ) | [inline] |
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.
Definition at line 363 of file qbytearray.h.
References QByteArray::Data::alloc, d, realloc(), and QByteArray::Data::size.
Here is the call graph for this function:

| QByteArray::operator const char * | ( | ) | const [inline] |
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. The pointer remains valid as long as the array isn't reallocated.
This operator 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.
Definition at line 336 of file qbytearray.h.
References d, and QByteArray::Data::data.
| QByteArray::operator const void * | ( | ) | const [inline] |
Returns a void pointer to the data.
This operator is mostly useful to pass a byte array to a function that accepts a void *.
Definition at line 338 of file qbytearray.h.
References d, and QByteArray::Data::data.
| char * QByteArray::data | ( | ) | [inline] |
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.
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. 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 *}.
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.
Definition at line 340 of file qbytearray.h.
References d, QByteArray::Data::data, and detach().
Referenced by QHttpPrivate::_q_slotBytesWritten(), QHttpPrivate::_q_slotReadyRead(), QSocks5SocketEnginePrivate::_q_udpSocketReadNotification(), MainWindow::actionTriggered(), QPdfEnginePrivate::addImage(), QGridLayout::addWidget(), QPdf::ascii85Encode(), QSocks5PasswordAuthenticator::beginAuthenticate(), bindFont(), Sender::broadcastDatagram(), QCoreApplicationPrivate::checkReceiverThread(), checkSymbolFont(), cleaned(), QBitArray::clearBit(), composePreprocessorOutput(), compress(), QMetaObject::connectSlotsByName(), QSimpleTextCodec::convertFromUnicode(), QFontLaoCodec::convertFromUnicode(), QBig5hkscsCodec::convertFromUnicode(), QEucKrCodec::convertFromUnicode(), QSjisCodec::convertFromUnicode(), QUtf8Codec::convertFromUnicode(), QGb2312Codec::convertFromUnicode(), QEucJpCodec::convertFromUnicode(), QIsciiCodec::convertFromUnicode(), QBig5Codec::convertFromUnicode(), QTsciiCodec::convertFromUnicode(), QLatin1Codec::convertFromUnicode(), QGbkCodec::convertFromUnicode(), QGb18030Codec::convertFromUnicode(), QLatin15Codec::convertFromUnicode(), Q3UrlOperator::copyGotData(), QBitArray::count(), create_wm_client_leader(), QFormBuilder::createLayout(), QSqlDatabasePrivate::database(), Q3UriDrag::decode(), Q3Url::decode(), encodeEntity(), Parser::error(), QClipboard::event(), TsHandler::fatalError(), UiHandler::fatalError(), QIBaseResultPrivate::fetchArray(), QIBaseResultPrivate::fetchBlob(), QFSFileEngine::fileFlags(), QFSFileEngine::fileName(), QBitArray::fill(), QMimeDataWrapper::format(), QClipboardWatcher::formats_sys(), QMYSQLDriver::formatValue(), QUrl::fromPercentEncoding(), QFont::fromString(), Moc::generate(), getFcPattern(), getLprPrinters(), QGLContext::getProcAddress(), QFreetypeFace::getSfntTable(), QFileInfoPrivate::hasAccess(), Q3CString::leftJustify(), loadFc(), loadRaw(), loadTsFile(), ProFileEvaluator::logMessage(), main(), QX11Data::motifdndObtainData(), QNativeSocketEnginePrivate::nativeBind(), QNativeSocketEnginePrivate::nativeConnect(), normalizeTypeInternal(), QIBaseDriver::open(), QPdfBaseEnginePrivate::openPrintDevice(), Q3LocalFs::operationPut(), QBitArray::operator &=(), operator>>(), Q3TextStream::operator>>(), QBitArray::operator^=(), QBitArray::operator|=(), QUrlPrivate::parse(), parsePrintersConf(), parseSpoolInterface(), QRingBuffer::peek(), PeerWireClient::processIncomingData(), Receiver::processPendingDatagrams(), Q3DnsAnswer::Q3DnsAnswer(), QBitArray::QBitArray(), qbytearray_insert(), qCompress(), qFillBufferWithString(), QMMapViewProtocol::QMMapViewProtocol(), QSessionManager::QSessionManager(), qstring_to_xtp(), qt_fontdata_from_index(), qt_x11_apply_settings_in_all_apps(), qtMD5(), qUncompress(), QVFbKeyPipeProtocol::QVFbKeyPipeProtocol(), QVFbMousePipe::QVFbMousePipe(), QFtpDTP::read(), QRingBuffer::read(), QHttp::readAll(), Q3Http::readAll(), QIODevice::readAll(), Q3Membuf::readAll(), PeerManager::readBroadcastDatagram(), PeerWireClient::readFromSocket(), QIODevice::readLine(), QResource::registerResource(), QInternalMimeData::renderDataHelper(), replace(), QMYSQLResult::reset(), QBitArray::resize(), QInternalMimeData::retrieveData(), QClipboardWatcher::retrieveData_sys(), rightJustified(), Q3CString::rightJustify(), QDomDocumentPrivate::save(), QBitArray::setBit(), Q3CString::setExpand(), QWidget::setLayout(), Q3CString::setNum(), QFSFileEngine::setPermissions(), QFSFileEngine::setSize(), Q3Http::slotBytesWritten(), Q3Http::slotConnected(), Q3Http::slotReadyRead(), sm_setProperty(), Q3Process::socketRead(), QFtpDTP::socketReadyRead(), Q3FtpDTP::socketReadyRead(), Q3Process::socketWrite(), Q3CString::sprintf(), QProcessPrivate::startDetached(), Q3FtpPI::startNextCmd(), thaiWordBreaks(), toBase64(), QBitArray::toggleBit(), QString::toLatin1(), QString::toUtf8(), QKeyMapperPrivate::translateKeyEventInternal(), translateKeySym(), QIBaseResultPrivate::writeArray(), QIBaseResultPrivate::writeBlob(), PeerWireClient::writeData(), QClipboardINCRTransaction::x11Event(), QXIMInputContext::x11FilterEvent(), QX11Data::xdndMimeDataForAtom(), xdndObtainData(), and zeroKey().
Here is the call graph for this function:

| const char * QByteArray::data | ( | ) | const [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 342 of file qbytearray.h.
References d, and QByteArray::Data::data.
| const char * QByteArray::constData | ( | ) | const [inline] |
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. The pointer remains valid as long as the byte array isn't reallocated.
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.
Definition at line 344 of file qbytearray.h.
References d, and QByteArray::Data::data.
Referenced by QAbstractSocketPrivate::_q_connectToNextAddress(), QHttpPrivate::_q_slotConnected(), QHttpPrivate::_q_slotReadyRead(), QSocks5SocketEnginePrivate::_q_udpSocketReadNotification(), ProFileEvaluator::absFileNames(), RCCResourceLibrary::addFile(), QPdfEnginePrivate::addImage(), QDBusMarshaller::append(), QCoreApplication::applicationFilePath(), QPdf::ascii85Encode(), bestFoundry(), checksum(), cleaned(), QX11Data::clipboardReadIncrementalProperty(), TranslatorMessage::comment(), QObject::connect(), QDBusConnection::connectToBus(), QAbstractSocket::connectToHost(), QAbstractSocket::connectToHostImplementation(), TranslatorMessage::context(), QBig5hkscsCodec::convertFromUnicode(), QEucKrCodec::convertFromUnicode(), QSjisCodec::convertFromUnicode(), QUtf8Codec::convertFromUnicode(), QGb2312Codec::convertFromUnicode(), QEucJpCodec::convertFromUnicode(), QBig5Codec::convertFromUnicode(), QTsciiCodec::convertFromUnicode(), QGbkCodec::convertFromUnicode(), QGb18030Codec::convertFromUnicode(), QWidgetPrivate::create_sys(), QDBusArgumentPrivate::createSignature(), QFormBuilder::createWidget(), data(), qdesigner_internal::WidgetBoxTreeView::domToCateogryList(), QPainter::drawText(), ProjectPorter::error(), Parser::error(), Ui3Reader::errorInvalidProperty(), Ui3Reader::errorInvalidSignal(), Ui3Reader::errorInvalidSlot(), ProFileEvaluator::evaluateConditionalFunction(), QSqlQuery::exec(), QODBCResult::exec(), QProcessPrivate::execChild(), ProFileEvaluator::expandVariableReferences(), QphHandler::fatalError(), QNativeSocketEnginePrivate::fetchConnectionParameters(), QAbstractSocketPrivate::fetchConnectionParameters(), TrackerClient::fetchPeerList(), QTextStreamPrivate::fillReadBuffer(), QTextStreamPrivate::flushWriteBuffer(), fontExists(), QDropEvent::format(), QHostInfoAgent::fromName(), QUrl::fromPercentEncoding(), QUrl::fromPunycode(), qdesigner_internal::SignalSlotEditor::fromUi(), Generator::generateCode(), Generator::generateEnums(), Generator::generateMetacall(), Generator::generateSignal(), QFileDialogPrivate::getEnvironmentVariable(), getSimilarityScore(), StringSimilarityMatcher::getSimilarityScore(), getToken(), TrackerClient::httpRequestDone(), QGifHandler::imageIsComing(), QByteArrayMatcher::indexIn(), QNativeSocketEngine::initialize(), QAbstractSocketPrivate::initSocketLayer(), RCCResourceLibrary::interpretResourceFile(), QMetaObject::invokeMethod(), QImageData::keys(), QMetaEnum::keysToValue(), qdesigner_internal::ResourceCache< Item >::keyToItem(), QImageData::languages(), Q3CString::leftJustify(), Rpp::RppLexer::lex(), QTcpServer::listen(), listInterface(), QResourcePrivate::load(), loadFile(), PortingRules::loadXml(), main(), match(), QNativeSocketEnginePrivate::nativeBind(), QNativeSocketEnginePrivate::nativeConnect(), QNativeSocketEnginePrivate::nativeListen(), QNativeSocketEnginePrivate::nativeReceiveDatagram(), QNativeSocketEnginePrivate::nativeSendDatagram(), QPSQLDriver::open(), QODBCDriver::open(), QMYSQLDriver::open(), QIBaseDriver::open(), QFSFileEngine::open(), QPdfBaseEnginePrivate::openPrintDevice(), QBitArray::operator &=(), operator!=(), operator+(), operator<(), QTextStream::operator<<(), operator<=(), operator==(), operator>(), operator>=(), QBitArray::operator^=(), QBitArray::operator|=(), QBitArray::operator~(), QUrlPrivate::parse(), QDateTimeParser::parse(), Index::parseDocument(), QDateTimeParser::parseFormat(), Moc::parseFunction(), Moc::parseMaybeFunction(), QSocks5SocketEnginePrivate::parseNewConnection(), QSocks5SocketEnginePrivate::parseRequestMethodReply(), Skin::parseSkinFileHeader(), QIODevice::peek(), QAuServerNAS::play(), QSqlQuery::prepare(), QIBaseResult::prepare(), QODBCDriver::primaryIndex(), QFtpPI::processReply(), processResourceFile(), proFileTagMap(), QTest::qCompare(), QDBusError::QDBusError(), QDBusServer::QDBusServer(), qGetBinaryData(), QTest::qPrintMessage(), QSharedMemory::QSharedMemory(), QShMemViewProtocol::QShMemViewProtocol(), QTest::qSignalDumperCallback(), QSignalSpy::QSignalSpy(), qSqlWarning(), QVFbKeyPipeProtocol::QVFbKeyPipeProtocol(), QVFbMousePipe::QVFbMousePipe(), qvsnprintf(), qws_dataDir(), QXIMInputContext::QXIMInputContext(), QGifHandler::read(), PeerWireClient::readData(), QSocks5SocketEngine::readDatagram(), RCCResourceLibrary::readFiles(), QConfFileSettingsPrivate::readIniFile(), Porting::readXML(), QMYSQLDriver::record(), QODBCDriver::record(), registerFont(), QDBusConnectionPrivate::relaySignal(), releaseMetaTranslator(), Q3CString::replace(), replace(), Parser::reportError(), QPSQLResult::reset(), QSQLite2Result::reset(), qdesigner_internal::PropertyEditor::resetProperty(), Q3CString::rightJustify(), QHostInfoAgent::run(), runlengthEncode(), Translator::save(), QMainWindowLayout::saveState(), set_text(), QPainter::setFont(), setOptionFlag(), QByteArrayMatcher::setPattern(), QTextBrowserPrivate::setSource(), TorrentClient::setTorrent(), Skin::setupDefaultButtons(), QWidget::setWindowRole(), Skin::skinFileName(), sm_setProperty(), QFtpDTP::socketReadyRead(), TranslatorMessage::sourceText(), Q3CString::sprintf(), QProcessPrivate::startDetached(), StringSimilarityMatcher::StringSimilarityMatcher(), QFontEngineXLFD::stringToCMap(), QODBCDriver::tables(), QBitArray::testBit(), thaiWordBreaks(), toDouble(), Q3CString::toDouble(), Q3CString::toLong(), toLongLong(), QUrl::toPercentEncoding(), QString::toStdString(), QTest::toString(), Q3CString::toULong(), toULongLong(), QTextDecoder::toUnicode(), QString::toUtf8(), translationAttempt(), QMetaType::typeName(), usage(), FileManager::verifySinglePiece(), Parser::warning(), RCCFileInfo::writeDataBlob(), QUdpSocket::writeDatagram(), RCCFileInfo::writeDataName(), FileWriter::writeFile(), QPdfEnginePrivate::writeInfo(), RCCResourceLibrary::writeInitializer(), PeerWireClient::writeToSocket(), QXIMInputContext::x11FilterEvent(), QX11Data::xdndMimeStringToAtom(), xmlToUi(), QMMapViewProtocol::~QMMapViewProtocol(), QVFbKeyPipeProtocol::~QVFbKeyPipeProtocol(), and QVFbMousePipe::~QVFbMousePipe().
| void QByteArray::detach | ( | ) | [inline] |
Definition at line 346 of file qbytearray.h.
References QByteArray::Data::array, d, QByteArray::Data::data, realloc(), QByteArray::Data::ref, and QByteArray::Data::size.
Referenced by begin(), data(), end(), remove(), replace(), and Q3CString::sprintf().
Here is the call graph for this function:

| bool QByteArray::isDetached | ( | ) | const [inline] |
| void QByteArray::clear | ( | ) |
Clears the contents of the byte array and makes it empty.
Definition at line 2474 of file qbytearray.cpp.
References d, QBasicAtomic::deref(), qFree(), QByteArray::Data::ref, QBasicAtomic::ref(), and shared_null.
Referenced by _authority(), QSocks5SocketEnginePrivate::_q_controlSocketError(), QSocks5SocketEnginePrivate::_q_emitPendingReadNotification(), ProReader::cleanup(), Translator::clear(), MetaInfo::clear(), QUrlPrivate::clear(), QFtpDTP::connectToHost(), ProReader::currentBlock(), Connection::dataLengthForCurrentDataType(), ProReader::insertVariable(), main(), QTextStream::operator>>(), operator>>(), QUrlPrivate::parse(), QKeyMapperPrivate::possibleKeysCore(), QKeyMapperPrivate::possibleKeysXKB(), Preprocessor::preprocess(), Connection::processData(), Connection::processReadyRead(), QFtpDTP::read(), QFtpDTP::readAll(), Connection::readProtocolHeader(), QUrl::setEncodedUrl(), Translator::squeeze(), ProReader::updateItem(), ProFileEvaluator::visitEndProVariable(), and QSimpleTextCodec::~QSimpleTextCodec().
02475 { 02476 if (!d->ref.deref()) 02477 qFree(d); 02478 d = &shared_null; 02479 d->ref.ref(); 02480 }
Here is the call graph for this function:

| const char QByteArray::at | ( | int | i | ) | const [inline] |
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()).
Definition at line 328 of file qbytearray.h.
References d, QByteArray::Data::data, and size().
Referenced by Rpp::Preprocessor::cleanEscapedNewLines(), Rpp::Preprocessor::cleanTokenRange(), QDBusArgumentPrivate::createSignature(), dump(), Ui3Reader::fixMethod(), fixString(), fromBase64(), QUrl::fromPunycode(), BencodeParser::getByteString(), BencodeParser::getDictionary(), BencodeParser::getInteger(), BencodeParser::getList(), QSettingsPrivate::iniEscapedString(), QSettingsPrivate::iniUnescapedStringList(), ProReader::insertVariable(), QUrlPrivate::normalized(), normalizeTypeInternal(), SubArray::operator==(), ProReader::parseline(), QSocks5SocketEnginePrivate::parseNewConnection(), QSocks5SocketEnginePrivate::parseRequestMethodReply(), Moc::parseType(), PeerWireClient::processIncomingData(), read_xpm_string(), QIODevice::readLine(), PeerWireClient::sendPieceList(), and QChar::toAscii().
Here is the call graph for this function:

| const char QByteArray::operator[] | ( | int | i | ) | const [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as at(i).
Definition at line 330 of file qbytearray.h.
References d, QByteArray::Data::data, and size().
Here is the call graph for this function:

| QByteRef QByteArray::operator[] | ( | int | i | ) | [inline] |
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:
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.
Definition at line 395 of file qbytearray.h.
References QByteRef.
| const char QByteArray::operator[] | ( | uint | i | ) | const [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 332 of file qbytearray.h.
References d, QByteArray::Data::data, and size().
Here is the call graph for this function:

| QByteRef QByteArray::operator[] | ( | uint | i | ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 397 of file qbytearray.h.
References QByteRef.
| int QByteArray::indexOf | ( | char | ch, | |
| int | from = 0 | |||
| ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 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
Definition at line 2028 of file qbytearray.cpp.
References d, QByteArray::Data::data, n, qMax(), QByteArray::Data::size, and size().
Referenced by codecForHTML(), contains(), count(), findSlot(), Ui3Reader::fixMethod(), fontFile(), generateInterfaceXml(), indexOf(), listInterface(), QTest::memberName(), QJpUnicodeConv::newConverter(), parse(), QDBusConnectionPrivate::prepareHook(), QApplicationPrivate::process_cmdline(), qt_findcharset(), read_xbm_body(), QDBusConnectionPrivate::relaySignal(), ScopedTokenReplacement::ScopedTokenReplacement(), QUrl::setEncodedUrl(), split(), and ProFileEvaluator::visitProFunction().
02029 { 02030 if (from < 0) 02031 from = qMax(from + d->size, 0); 02032 if (from < d->size) { 02033 const char *n = d->data + from - 1; 02034 const char *e = d->data + d->size; 02035 while (++n != e) 02036 if (*n == ch) 02037 return n - d->data; 02038 } 02039 return -1; 02040 }
Here is the call graph for this function:

| int QByteArray::indexOf | ( | const char * | str, | |
| int | from = 0 | |||
| ) | const [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 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.
Definition at line 479 of file qbytearray.h.
References fromRawData(), indexOf(), and qstrlen().
00480 { return indexOf(fromRawData(c, qstrlen(c)), i); }
Here is the call graph for this function:

| int QByteArray::indexOf | ( | const QByteArray & | ba, | |
| int | from = 0 | |||
| ) | const |
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
Definition at line 1943 of file qbytearray.cpp.
References d, QByteArray::Data::data, end(), indexOf(), l, REHASH, and QByteArray::Data::size.
01944 { 01945 const int l = d->size; 01946 const int ol = ba.d->size; 01947 if (from > d->size || ol + from > l) 01948 return -1; 01949 if (ol == 0) 01950 return from; 01951 if (ol == 1) 01952 return indexOf(*ba.d->data, from); 01953 01954 if (l > 500 && ol > 5) 01955 return QByteArrayMatcher(ba).indexIn(*this, from); 01956 01957 const char *needle = ba.d->data; 01958 const char *haystack = d->data + from; 01959 const char *end = d->data + (l - ol); 01960 const uint ol_minus_1 = ol - 1; 01961 uint hashNeedle = 0, hashHaystack = 0; 01962 int idx; 01963 for (idx = 0; idx < ol; ++idx) { 01964 hashNeedle = ((hashNeedle<<1) + needle[idx]); 01965 hashHaystack = ((hashHaystack<<1) + haystack[idx]); 01966 } 01967 hashHaystack -= *(haystack + ol_minus_1); 01968 01969 while (haystack <= end) { 01970 hashHaystack += *(haystack + ol_minus_1); 01971 if (hashHaystack == hashNeedle && *needle == *haystack 01972 && strncmp(needle, haystack, ol) == 0) 01973 return haystack - d->data; 01974 01975 REHASH(*haystack); 01976 ++haystack; 01977 } 01978 return -1; 01979 }
Here is the call graph for this function:

| int QByteArray::lastIndexOf | ( | char | ch, | |
| int | from = -1 | |||
| ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 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
Definition at line 2148 of file qbytearray.cpp.
References b, d, QByteArray::Data::data, n, and QByteArray::Data::size.
Referenced by fontFile(), QUrl::fromPunycode(), lastIndexOf(), main(), ScopedTokenReplacement::ScopedTokenReplacement(), and ProFileEvaluator::visitProFunction().
02149 { 02150 if (from < 0) 02151 from += d->size; 02152 else if (from > d->size) 02153 from = d->size-1; 02154 if (from >= 0) { 02155 const char *b = d->data; 02156 const char *n = d->data + from + 1; 02157 while (n-- != b) 02158 if (*n == ch) 02159 return n - b; 02160 } 02161 return -1; 02162 }
| int QByteArray::lastIndexOf | ( | const char * | str, | |
| int | from = -1 | |||
| ) | const [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 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.
Definition at line 481 of file qbytearray.h.
References fromRawData(), lastIndexOf(), and qstrlen().
00482 { return lastIndexOf(fromRawData(c, qstrlen(c)), i); }
Here is the call graph for this function:

| int QByteArray::lastIndexOf | ( | const QByteArray & | ba, | |
| int | from = -1 | |||
| ) | const |
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("azy"); x.lastIndexOf(y); // returns 6 x.lastIndexOf(y, 6); // returns 6 x.lastIndexOf(y, 5); // returns 2 x.lastIndexOf(y, 1); // returns -1
Definition at line 2061 of file qbytearray.cpp.
References d, QByteArray::Data::data, end(), h, l, lastIndexOf(), n, REHASH, and QByteArray::Data::size.
02062 { 02063 const int ol = ba.d->size; 02064 const int l = d->size; 02065 int delta = l - ol; 02066 if (from < 0) 02067 from = delta; 02068 if (from < 0 || from > l) 02069 return -1; 02070 if (from > delta) 02071 from = delta; 02072 if (ol == 1) 02073 return lastIndexOf(*ba.d->data, from); 02074 02075 const char *needle = ba.d->data; 02076 const char *haystack = d->data + from; 02077 const char *end = d->data; 02078 const uint ol_minus_1 = ol - 1; 02079 const char *n = needle + ol_minus_1; 02080 const char *h = haystack + ol_minus_1; 02081 uint hashNeedle = 0, hashHaystack = 0; 02082 int idx; 02083 for (idx = 0; idx < ol; ++idx) { 02084 hashNeedle = ((hashNeedle<<1) + *(n-idx)); 02085 hashHaystack = ((hashHaystack<<1) + *(h-idx)); 02086 } 02087 hashHaystack -= *haystack; 02088 while (haystack >= end) { 02089 hashHaystack += *haystack; 02090 if (hashHaystack == hashNeedle && strncmp(needle, haystack, ol) == 0) 02091 return haystack-d->data; 02092 --haystack; 02093 REHASH(*(haystack + ol)); 02094 } 02095 return -1; 02096 02097 }
Here is the call graph for this function:

| QBool QByteArray::contains | ( | char | ch | ) | const [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns true if the byte array contains the character ch; otherwise returns false.
Definition at line 431 of file qbytearray.h.
References indexOf().
Referenced by QSvgIOHandler::canRead(), PortingRules::checkScopeAddRule(), contains(), detectLineEndings(), Q3Url::encode(), Q3FileDialogPrivate::encodeFileName(), PreprocessReplace::evaluateText(), QProcessPrivate::execChild(), fontFile(), main(), Semantic::parseDeclaration(), QPictureHandler::QPictureHandler(), read_xbm_body(), and ScopedTokenReplacement::ScopedTokenReplacement().
Here is the call graph for this function:

| QBool QByteArray::contains | ( | const char * | str | ) | const [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns true if the byte array contains the string str; otherwise returns false.
Definition at line 483 of file qbytearray.h.
References contains(), fromRawData(), and qstrlen().
00484 { return contains(fromRawData(c, qstrlen(c))); }
Here is the call graph for this function:

| QBool QByteArray::contains | ( | const QByteArray & | ba | ) | const [inline] |
| int QByteArray::count | ( | char | ch | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns the number of occurrences of character ch in the byte array.
Definition at line 2211 of file qbytearray.cpp.
References b, d, QByteArray::Data::data, num, and QByteArray::Data::size.
Referenced by Rpp::RppTreeEvaluator::cloneTokenList(), TokenEngine::copy(), dump(), PreprocessReplace::evaluateIncludeDirective(), Rpp::RppTreeEvaluator::evaluateMacro(), Rpp::RppTreeEvaluator::evaluateMacroInternal(), QUrl::fromPercentEncoding(), ProReader::insertVariable(), ProReader::parseline(), ScopedTokenReplacement::ScopedTokenReplacement(), QUrl::toPercentEncoding(), and translationAttempt().
02212 { 02213 int num = 0; 02214 const char *i = d->data + d->size; 02215 const char *b = d->data; 02216 while (i != b) 02217 if (*--i == ch) 02218 ++num; 02219 return num; 02220 }
| int QByteArray::count | ( | const char * | str | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns the number of (potentially overlapping) occurrences of string str in the byte array.
Definition at line 2193 of file qbytearray.cpp.
References indexOf(), and num.
02194 { 02195 int num = 0; 02196 int i = -1; 02197 while ((i = indexOf(str, i + 1)) != -1) 02198 ++num; 02199 return num; 02200 }
Here is the call graph for this function:

| int QByteArray::count | ( | const QByteArray & | ba | ) | const |
Returns the number of (potentially overlapping) occurrences of byte array ba in this byte array.
Definition at line 2171 of file qbytearray.cpp.
References d, QByteArrayMatcher::indexIn(), indexOf(), num, and QByteArray::Data::size.
02172 { 02173 int num = 0; 02174 int i = -1; 02175 if (d->size > 500 && ba.d->size > 5) { 02176 QByteArrayMatcher matcher(ba); 02177 while ((i = matcher.indexIn(*this, i + 1)) != -1) 02178 ++num; 02179 } else { 02180 while ((i = indexOf(ba, i + 1)) != -1) 02181 ++num; 02182 } 02183 return num; 02184 }
Here is the call graph for this function:

| QByteArray QByteArray::left | ( | int | len | ) | const |
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"
Definition at line 2344 of file qbytearray.cpp.
References d, QByteArray::Data::data, QByteArray(), and QByteArray::Data::size.
Referenced by QTextCodec::codecForHtml(), Ui3Reader::fixMethod(), fontFile(), QUrl::fromPunycode(), generateInterfaceXml(), Generator::generateProperties(), QXIMInputContext::language(), Q3CString::left(), leftJustified(), QTest::memberName(), parse(), QMetaObject::property(), qt_findcharset(), rightJustified(), ProFileEvaluator::visitProFunction(), and wrapDSC().
02345 { 02346 if (len >= d->size) 02347 return *this; 02348 if (len < 0) 02349 len = 0; 02350 return QByteArray(d->data, len); 02351 }
Here is the call graph for this function:

| QByteArray QByteArray::right | ( | int | len | ) | const |
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"
Definition at line 2370 of file qbytearray.cpp.
References d, QByteArray::Data::data, QByteArray(), and QByteArray::Data::size.
Referenced by Moc::generate(), QApplicationPrivate::process_cmdline(), Q3CString::right(), and QUrlPrivate::toEncoded().
02371 { 02372 if (len >= d->size) 02373 return *this; 02374 if (len < 0) 02375 len = 0; 02376 return QByteArray(d->data + d->size - len, len); 02377 }
Here is the call graph for this function:

| QByteArray QByteArray::mid | ( | int | pos, | |
| int | len = -1 | |||
| ) | const |
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"
Definition at line 2397 of file qbytearray.cpp.
References d, QByteArray::Data::data, QByteArray(), shared_empty, shared_null, and QByteArray::Data::size.
Referenced by codecForHTML(), composePreprocessorOutput(), Ui3Reader::fixMethod(), fontFile(), QUrl::fromPunycode(), Moc::generate(), Generator::generateProperties(), BencodeParser::getByteString(), BencodeParser::infoSection(), Symbol::lexem(), main(), Q3CString::mid(), QJpUnicodeConv::newConverter(), Symbol::operator QByteArray(), parse(), MetaInfo::parse(), ProReader::parseline(), PeerWireClient::processIncomingData(), QMetaObject::property(), qt_findcharset(), ScopedTokenReplacement::ScopedTokenReplacement(), split(), PropertyDef::stdCppSet(), tokenize(), Symbol::unquotedLexem(), ProFileEvaluator::visitProFunction(), and wrapDSC().
02398 { 02399 if (d == &shared_null || d == &shared_empty || pos >= d->size) 02400 return QByteArray(); 02401 if (len < 0) 02402 len = d->size - pos; 02403 if (pos < 0) { 02404 len += pos; 02405 pos = 0; 02406 } 02407 if (len + pos > d->size) 02408 len = d->size - pos; 02409 if (pos == 0 && len == d->size) 02410 return *this; 02411 return QByteArray(d->data + pos, len); 02412 }
Here is the call graph for this function:

| bool QByteArray::startsWith | ( | const QByteArray & | ba | ) | const |
Returns true if this byte array starts with byte array ba; otherwise returns false.
Example:
QByteArray url("ftp://ftp.trolltech.com/"); if (url.startsWith("ftp:")) ...
Definition at line 2242 of file qbytearray.cpp.
References d, QByteArray::Data::data, and QByteArray::Data::size.
Referenced by QCoreApplication::arguments(), constRefArg(), findSlot(), QUrl::fromPunycode(), QFreetypeFace::getFace(), QXIMInputContext::language(), main(), QX11Data::motifdndObtainData(), placeCall(), and Preprocessor::preprocess().
02243 { 02244 if (d == ba.d || ba.d->size == 0) 02245 return true; 02246 if (d->size < ba.d->size) 02247 return false; 02248 return memcmp(d->data, ba.d->data, ba.d->size) == 0; 02249 }
| bool QByteArray::startsWith | ( | char | ch | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns true if this byte array starts with character ch; otherwise returns false.
Definition at line 2271 of file qbytearray.cpp.
References d, QByteArray::Data::data, and QByteArray::Data::size.
| bool QByteArray::startsWith | ( | const char * | str | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns true if this byte array starts with string str; otherwise returns false.
Definition at line 2256 of file qbytearray.cpp.
References d, QByteArray::Data::data, len, qstrlen(), qstrncmp(), and QByteArray::Data::size.
02257 { 02258 if (!str || !*str) 02259 return true; 02260 int len = qstrlen(str); 02261 if (d->size < len) 02262 return false; 02263 return qstrncmp(d->data, str, len) == 0; 02264 }
Here is the call graph for this function:

| bool QByteArray::endsWith | ( | const QByteArray & | ba | ) | const |
Returns true if this byte array ends with byte array ba; otherwise returns false.
Example:
QByteArray url("http://www.trolltech.com/index.html"); if (url.endsWith(".html")) ...
Definition at line 2291 of file qbytearray.cpp.
References d, QByteArray::Data::data, and QByteArray::Data::size.
Referenced by CPP::WriteIconData::acceptImage(), QDBusViewer::callMethod(), Connection::dataLengthForCurrentDataType(), QProcessPrivate::execChild(), Generator::generateProperties(), QTest::qSignalDumperCallback(), Connection::readDataIntoBuffer(), templateArg(), and ProReader::updateItem().
02292 { 02293 if (d == ba.d || ba.d->size == 0) 02294 return true; 02295 if (d->size < ba.d->size) 02296 return false; 02297 return memcmp(d->data + d->size - ba.d->size, ba.d->data, ba.d->size) == 0; 02298 }
| bool QByteArray::endsWith | ( | char | ch | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns true if this byte array ends with character ch; otherwise returns false.
Definition at line 2320 of file qbytearray.cpp.
References d, QByteArray::Data::data, and QByteArray::Data::size.
02321 { 02322 if (d->size == 0) 02323 return false; 02324 return d->data[d->size - 1] == ch; 02325 }
| bool QByteArray::endsWith | ( | const char * | str | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns true if this byte array ends with string str; otherwise returns false.
Definition at line 2305 of file qbytearray.cpp.
References d, QByteArray::Data::data, len, qstrlen(), qstrncmp(), and QByteArray::Data::size.
02306 { 02307 if (!str || !*str) 02308 return true; 02309 int len = qstrlen(str); 02310 if (d->size < len) 02311 return false; 02312 return qstrncmp(d->data + d->size - len, str, len) == 0; 02313 }
Here is the call graph for this function:

| void QByteArray::truncate | ( | int | pos | ) |
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"
Definition at line 1081 of file qbytearray.cpp.
References resize(), and size().
Referenced by _IPv6Address(), QIsciiCodec::convertFromUnicode(), Q3Url::decode(), fromBase64(), QMetaObject::invokeMethod(), listInterface(), QIBaseDriver::open(), QDBusMetaObjectGenerator::parseMethods(), QDBusMetaObjectGenerator::parseSignals(), QDBusConnectionPrivate::prepareHook(), QDBusConnectionPrivate::relaySignal(), and toBase64().
Here is the call graph for this function:

| void QByteArray::chop | ( | int | n | ) |
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"
Definition at line 1103 of file qbytearray.cpp.
References d, resize(), and QByteArray::Data::size.
Referenced by composePreprocessorOutput(), Connection::dataLengthForCurrentDataType(), Generator::generateProperties(), ProReader::insertVariable(), QTest::qSignalDumperCallback(), QIODevice::readAll(), and QUrlPrivate::toEncoded().
Here is the call graph for this function:

| QByteArray QByteArray::toLower | ( | ) | const |
Returns a lowercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.
Example:
QByteArray x("TROlltECH"); QByteArray y = x.toLower(); // y == "trolltech"
Definition at line 2427 of file qbytearray.cpp.
References QUnicodeTables::lower(), p, and s.
Referenced by Q3ImageDrag::canDecode(), QTextCodec::codecForHtml(), createReadHandler(), Q3MimeSourceFactory::dataInternal(), Q3ImageDrag::decode(), PreprocessReplace::evaluateIncludeDirective(), fontFile(), imageReadMimeFormats(), imageWriteMimeFormats(), FilePorter::includeAnalyse(), Q3CString::lower(), qt_fillFontDef(), Q3ImageDrag::setImage(), and ProFileEvaluator::templateType().
02428 { 02429 QByteArray s(*this); 02430 register uchar *p = reinterpret_cast<uchar *>(s.data()); 02431 if (p) { 02432 while (*p) { 02433 *p = QUnicodeTables::lower(*p); 02434 p++; 02435 } 02436 } 02437 return s; 02438 }
Here is the call graph for this function:

| QByteArray QByteArray::toUpper | ( | ) | const |
Returns an uppercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.
Example:
QByteArray x("TROlltECH"); QByteArray y = x.toUpper(); // y == "TROLLTECH"
Definition at line 2454 of file qbytearray.cpp.
References p, s, and QUnicodeTables::upper().
Referenced by Q3ImageDrag::encodedData(), MainWindow::findCodecs(), MainWindow::saveFile(), and Q3CString::upper().
02455 { 02456 QByteArray s(*this); 02457 register char *p = s.data(); 02458 if (p) { 02459 while (*p) { 02460 *p = QUnicodeTables::upper(*p); 02461 p++; 02462 } 02463 } 02464 return s; 02465 }
Here is the call graph for this function:

| QByteArray QByteArray::trimmed | ( | ) | const |
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. 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.
Definition at line 2912 of file qbytearray.cpp.
References d, QByteArray::Data::data, end(), l, QByteArray(), QByteArray::Data::ref, QBasicAtomic::ref(), s, shared_empty, QByteArray::Data::size, and start.
Referenced by CPP::WriteIconData::acceptImage(), QualifiedNameParser::findScopeOperator(), ReplaceToken::getTokenTextReplacements(), ProReader::insertComment(), ProReader::insertVariable(), QJpUnicodeConv::newConverter(), QualifiedNameParser::nextScopeToken(), QConfFileSettingsPrivate::readIniFile(), QMimeDataPrivate::retrieveTypedData(), Q3CString::stripWhiteSpace(), Semantic::typeOfDeclaration(), and ProReader::updateItem().
02913 { 02914 if (d->size == 0) 02915 return *this; 02916 const char *s = d->data; 02917 if (!isspace(uchar(*s)) && !isspace(uchar(s[d->size-1]))) 02918 return *this; 02919 int start = 0; 02920 int end = d->size - 1; 02921 while (start<=end && isspace(uchar(s[start]))) // skip white space from start 02922 start++; 02923 if (start <= end) { // only white space 02924 while (end && isspace(uchar(s[end]))) // skip white space from end 02925 end--; 02926 } 02927 int l = end - start + 1; 02928 if (l <= 0) { 02929 shared_empty.ref.ref(); 02930 return QByteArray(&shared_empty, 0, 0); 02931 } 02932 return QByteArray(s+start, l); 02933 }
Here is the call graph for this function:

| QByteArray QByteArray::simplified | ( | ) | const |
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. 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";
Definition at line 2867 of file qbytearray.cpp.
References d, QByteArray::Data::data, resize(), and QByteArray::Data::size.
Referenced by Semantic::declaratorToString(), parse(), ProReader::parseline(), Q3CString::simplifyWhiteSpace(), Semantic::typeOfDeclaration(), and wrapDSC().
02868 { 02869 if (d->size == 0) 02870 return *this; 02871 QByteArray result; 02872 result.resize(d->size); 02873 const char *from = d->data; 02874 const char *fromend = from + d->size; 02875 int outc=0; 02876 char *to = result.d->data; 02877 for (;;) { 02878 while (from!=fromend && isspace(uchar(*from))) 02879 from++; 02880 while (from!=fromend && !isspace(uchar(*from))) 02881 to[outc++] = *from++; 02882 if (from!=fromend) 02883 to[outc++] = ' '; 02884 else 02885 break; 02886 } 02887 if (outc > 0 && to[outc-1] == ' ') 02888 outc--; 02889 result.resize(outc); 02890 return result; 02891 }
Here is the call graph for this function:

| QByteArray QByteArray::leftJustified | ( | int | width, | |
| char | fill = ' ', |
|||
| bool | truncate = false | |||
| ) | const |
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..."
Definition at line 2956 of file qbytearray.cpp.
References d, QByteArray::Data::data, left(), len, resize(), and QByteArray::Data::size.
Referenced by qFillBufferWithString().
02957 { 02958 QByteArray result; 02959 int len = d->size; 02960 int padlen = width - len; 02961 if (padlen > 0) { 02962 result.resize(len+padlen); 02963 if (len) 02964 memcpy(result.d->data, d->data, len); 02965 memset(result.d->data+len, fill, padlen); 02966 } else { 02967 if (truncate) 02968 result = left(width); 02969 else 02970 result = *this; 02971 } 02972 return result; 02973 }
Here is the call graph for this function:

| QByteArray QByteArray::rightJustified | ( | int | width, | |
| char | fill = ' ', |
|||
| bool | truncate = false | |||
| ) | const |
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"
Definition at line 2996 of file qbytearray.cpp.
References d, QByteArray::Data::data, data(), left(), len, resize(), and QByteArray::Data::size.
02997 { 02998 QByteArray result; 02999 int len = d->size; 03000 int padlen = width - len; 03001 if (padlen > 0) { 03002 result.resize(len+padlen); 03003 if (len) 03004 memcpy(result.d->data+padlen, data(), len); 03005 memset(result.d->data, fill, padlen); 03006 } else { 03007 if (truncate) 03008 result = left(width); 03009 else 03010 result = *this; 03011 } 03012 return result; 03013 }
Here is the call graph for this function:

| QByteArray & QByteArray::prepend | ( | char | ch | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Prepends the character ch to this byte array.
Definition at line 1440 of file qbytearray.cpp.
References QByteArray::Data::alloc, d, QByteArray::Data::data, qAllocMore(), realloc(), QByteArray::Data::ref, and QByteArray::Data::size.
Referenced by QObject::connect(), QFormBuilder::createConnections(), Moc::generate(), QSettingsPrivate::iniEscapedKey(), normalizeTypeInternal(), parse(), Moc::parse(), Q3TextEdit::pasteSubType(), Q3CString::prepend(), push_front(), QXIMInputContext::QXIMInputContext(), QDBusAbstractAdaptor::setAutoRelaySignals(), tokenize(), QUrl::toPunycode(), and QConfFileSettingsPrivate::writeIniFile().
01441 { 01442 if (d->ref != 1 || d->size + 1 > d->alloc) 01443 realloc(qAllocMore(d->size + 1, sizeof(Data))); 01444 memmove(d->data+1, d->data, d->size); 01445 d->data[0] = ch; 01446 ++d->size; 01447 d->data[d->size] = '\0'; 01448 return *this; 01449 }
Here is the call graph for this function:

| QByteArray & QByteArray::prepend | ( | const char * | str | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Prepends the string str to this byte array.
Definition at line 1420 of file qbytearray.cpp.
References QByteArray::Data::alloc, d, QByteArray::Data::data, len, qAllocMore(), qstrlen(), realloc(), QByteArray::Data::ref, and QByteArray::Data::size.
01421 { 01422 if (str) { 01423 int len = qstrlen(str); 01424 if (d->ref != 1 || d->size + len > d->alloc) 01425 realloc(qAllocMore(d->size + len, sizeof(Data))); 01426 memmove(d->data+len, d->data, d->size); 01427 memcpy(d->data, str, len); 01428 d->size += len; 01429 d->data[d->size] = '\0'; 01430 } 01431 return *this; 01432 }
Here is the call graph for this function:

| QByteArray & QByteArray::prepend | ( | const QByteArray & | ba | ) |
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).
Definition at line 1402 of file qbytearray.cpp.
References append(), d, shared_empty, and shared_null.
01403 { 01404 if (d == &shared_null || d == &shared_empty) { 01405 *this = ba; 01406 } else if (ba.d != &shared_null) { 01407 QByteArray tmp = *this; 01408 *this = ba; 01409 append(tmp); 01410 } 01411 return *this; 01412 }
Here is the call graph for this function:

| QByteArray & QByteArray::append | ( | char | ch | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Appends the character ch to this byte array.
Definition at line 1525 of file qbytearray.cpp.
References QByteArray::Data::alloc, d, QByteArray::Data::data, qAllocMore(), realloc(), QByteArray::Data::ref, and QByteArray::Data::size.
Referenced by Q3CString::append(), append(), Rpp::RppTreeEvaluator::evaluateMacroInternal(), generateGlyphTables(), QMetaObject::invokeMethod(), operator+=(), parse(), QDBusMetaObjectGenerator::parseMethods(), QDBusMetaObjectGenerator::parseSignals(), prepend(), push_back(), QTest::qSignalDumperCallback(), read_xpm_body(), Connection::readDataIntoBuffer(), runlengthEncode(), PeerManager::sendBroadcastDatagram(), QUrl::setEncodedUrl(), tokenize(), write_pbm_image(), and QConfFileSettingsPrivate::writeIniFile().
01526 { 01527 if (d->ref != 1 || d->size + 1 > d->alloc) 01528 realloc(qAllocMore(d->size + 1, sizeof(Data))); 01529 d->data[d->size++] = ch; 01530 d->data[d->size] = '\0'; 01531 return *this; 01532 }
Here is the call graph for this function:

| QByteArray & QByteArray::append | ( | const char * | str | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Appends the string str to this byte array.
Definition at line 1507 of file qbytearray.cpp.
References QByteArray::Data::alloc, d, QByteArray::Data::data, len, qAllocMore(), qstrlen(), realloc(), QByteArray::Data::ref, and QByteArray::Data::size.
01508 { 01509 if (str) { 01510 int len = qstrlen(str); 01511 if (d->ref != 1 || d->size + len > d->alloc) 01512 realloc(qAllocMore(d->size + len, sizeof(Data))); 01513 memcpy(d->data + d->size, str, len + 1); // include null terminator 01514 d->size += len; 01515 } 01516 return *this; 01517 }
Here is the call graph for this function:

| QByteArray & QByteArray::append | ( | const QByteArray & | ba | ) |
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).
This operation is typically very fast ({constant time}), because QByteArray preallocates extra space at the end of the character data so it can grow without reallocating the entire data each time.
Definition at line 1472 of file qbytearray.cpp.
References QByteArray::Data::alloc, d, QByteArray::Data::data, qAllocMore(), realloc(), QByteArray::Data::ref, shared_empty, shared_null, and QByteArray::Data::size.
01473 { 01474 if (d == &shared_null || d == &shared_empty) { 01475 *this = ba; 01476 } else if (ba.d != &shared_null) { 01477 if (d->ref != 1 || d->size + ba.d->size > d->alloc) 01478 realloc(qAllocMore(d->size + ba.d->size, sizeof(Data))); 01479 memcpy(d->data + d->size, ba.d->data, ba.d->size); 01480 d->size += ba.d->size; 01481 d->data[d->size] = '\0'; 01482 } 01483 return *this; 01484 }
Here is the call graph for this function:

| QByteArray & QByteArray::insert | ( | int | i, | |
| char | ch | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Inserts character ch at index position i in the byte array. If i is greater than size(), the array is first extended using resize().
Definition at line 1620 of file qbytearray.cpp.
References qbytearray_insert().
Referenced by TextReplacements::apply(), charString(), FilePorter::includeAnalyse(), QSettingsPrivate::iniEscapedString(), Q3CString::insert(), insert(), replace(), MetaTranslator::save(), and write_pbm_image().
01621 { 01622 return qbytearray_insert(this, i, &ch, 1); 01623 }
Here is the call graph for this function:

| QByteArray & QByteArray::insert | ( | int | i, | |
| const char * | str | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Inserts the string str at position i in the byte array.
If i is greater than size(), the array is first extended using resize().
Definition at line 1607 of file qbytearray.cpp.
References qbytearray_insert(), and qstrlen().
01608 { 01609 return qbytearray_insert(this, i, str, qstrlen(str)); 01610 }
Here is the call graph for this function:

| QByteArray & QByteArray::insert | ( | int | i, | |
| const QByteArray & | ba | |||
| ) |
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"
Definition at line 1572 of file qbytearray.cpp.
References TokenEngine::copy(), and qbytearray_insert().
01573 { 01574 QByteArray copy(ba); 01575 return qbytearray_insert(this, i, copy.d->data, copy.d->size); 01576 }
Here is the call graph for this function:

| QByteArray & QByteArray::remove | ( | int | pos, | |
| int | len | |||
| ) |
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"
Definition at line 1643 of file qbytearray.cpp.
References d, QByteArray::Data::data, detach(), resize(), and QByteArray::Data::size.
Referenced by TextReplacements::apply(), QFreetypeFace::getFace(), QGifHandler::imageIsComing(), main(), QX11Data::motifdndObtainData(), normalizeTypeInternal(), parse(), QSocks5SocketEnginePrivate::parseNewConnection(), QSocks5SocketEnginePrivate::parseRequestMethodReply(), QGifHandler::read(), read_xpm_string(), PeerWireClient::readData(), Q3CString::remove(), replace(), and PeerWireClient::writeToSocket().
01644 { 01645 if (len <= 0 || pos >= d->size || pos < 0) 01646 return *this; 01647 detach(); 01648 if (pos + len >= d->size) { 01649 resize(pos); 01650 } else { 01651 memmove(d->data + pos, d->data + pos + len, d->size - pos - len); 01652 resize(d->size - len); 01653 } 01654 return *this; 01655 }
Here is the call graph for this function:

| QByteArray & QByteArray::replace | ( | int | pos, | |
| int | len, | |||
| const char * | after | |||
| ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 485 of file qbytearray.h.
References fromRawData(), and qstrlen().
Referenced by Semantic::declaratorToString(), encodeEntity(), Generator::generateCode(), Q3CString::replace(), replace(), QUrl::setEncodedUrl(), and QFontSubset::toType1().
Here is the call graph for this function:

| QByteArray & QByteArray::replace | ( | int | pos, | |
| int | len, | |||
| const QByteArray & | after | |||
| ) |
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!"
Definition at line 1672 of file qbytearray.cpp.
References TokenEngine::copy(), insert(), and remove().
01673 { 01674 QByteArray copy(after); 01675 remove(pos, len); 01676 return insert(pos, copy); 01677 }
Here is the call graph for this function:

| QByteArray & QByteArray::replace | ( | char | before, | |
| const char * | after | |||
| ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces every occurrence of the character before with the string after.
Definition at line 487 of file qbytearray.h.
References fromRawData(), qstrlen(), and replace().
00488 { return replace(before,