52 #error qbytearray.h must be included before any header file that defines truncate
55 #if defined(Q_CC_GNU) && (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
57 # ifdef QT_USE_FAST_OPERATOR_PLUS
58 # undef QT_USE_FAST_OPERATOR_PLUS
60 # ifdef QT_USE_QSTRINGBUILDER
61 # undef QT_USE_QSTRINGBUILDER
77 Q_CORE_EXPORT
char *
qstrdup(const
char *);
80 {
return str ? uint(strlen(str)) : 0; }
82 inline uint
qstrnlen(
const char *str, uint maxlen)
86 while (length < maxlen && *str++)
95 Q_CORE_EXPORT
int qstrcmp(
const char *str1,
const char *str2);
99 {
return -
qstrcmp(str2, str1); }
103 return (str1 && str2) ? strncmp(str1, str2, len)
104 : (str1 ? 1 : (str2 ? -1 : 0));
106 Q_CORE_EXPORT
int qstricmp(
const char *,
const char *);
107 Q_CORE_EXPORT
int qstrnicmp(
const char *,
const char *, uint
len);
110 Q_CORE_EXPORT
int qvsnprintf(
char *str,
size_t n,
const char *fmt, va_list ap);
111 Q_CORE_EXPORT
int qsnprintf(
char *str,
size_t n,
const char *fmt, ...);
114 inline QT3_SUPPORT
void *qmemmove(
void *
dst,
const void *
src, uint
len)
115 {
return memmove(dst, src, len); }
116 inline QT3_SUPPORT uint cstrlen(
const char *str)
117 {
return uint(strlen(str)); }
118 inline QT3_SUPPORT
char *cstrcpy(
char *
dst,
const char *
src)
120 inline QT3_SUPPORT
int cstrcmp(
const char *str1,
const char *str2)
121 {
return strcmp(str1,str2); }
122 inline QT3_SUPPORT
int cstrncmp(
const char *str1,
const char *str2, uint
len)
123 {
return strncmp(str1,str2,len); }
133 template <
typename T>
class QList;
159 #ifdef Q_COMPILER_RVALUE_REFS
161 {
qSwap(d, other.d);
return *
this; }
166 inline int size()
const;
167 bool isEmpty()
const;
168 void resize(
int size);
172 int capacity()
const;
173 void reserve(
int size);
176 #ifndef QT_NO_CAST_FROM_BYTEARRAY
177 operator const char *()
const;
178 operator const void *()
const;
181 const char *
data()
const;
182 inline const char *constData()
const;
183 inline void detach();
184 bool isDetached()
const;
188 #ifdef Q_COMPILER_MANGLES_RETURN_TYPE
189 const char at(
int i)
const;
190 const char operator[](
int i)
const;
191 const char operator[](uint i)
const;
193 char at(
int i)
const;
194 char operator[](
int i)
const;
195 char operator[](uint i)
const;
200 int indexOf(
char c,
int from = 0)
const;
201 int indexOf(
const char *c,
int from = 0)
const;
202 int indexOf(
const QByteArray &
a,
int from = 0)
const;
203 int lastIndexOf(
char c,
int from = -1)
const;
204 int lastIndexOf(
const char *c,
int from = -1)
const;
205 int lastIndexOf(
const QByteArray &
a,
int from = -1)
const;
207 QBool contains(
char c)
const;
208 QBool contains(
const char *
a)
const;
210 int count(
char c)
const;
211 int count(
const char *
a)
const;
219 bool startsWith(
char c)
const;
220 bool startsWith(
const char *c)
const;
223 bool endsWith(
char c)
const;
224 bool endsWith(
const char *c)
const;
226 void truncate(
int pos);
234 QByteArray leftJustified(
int width,
char fill =
' ',
bool truncate =
false)
const;
235 QByteArray rightJustified(
int width,
char fill =
' ',
bool truncate =
false)
const;
238 inline QT3_SUPPORT
QByteArray leftJustify(uint
width,
char aFill =
' ',
bool aTruncate =
false)
const
239 {
return leftJustified(
int(width), aFill, aTruncate); }
240 inline QT3_SUPPORT
QByteArray rightJustify(uint width,
char aFill =
' ',
bool aTruncate =
false)
const
241 {
return rightJustified(
int(width), aFill, aTruncate); }
260 QByteArray &replace(
char before,
const char *after);
262 QByteArray &replace(
const char *before,
const char *after);
263 QByteArray &replace(
const char *before,
int bsize,
const char *after,
int asize);
276 #ifndef QT_NO_CAST_TO_ASCII
279 QT_ASCII_CAST_WARN
QByteArray &replace(
const QString &before,
const char *after);
284 QT_ASCII_CAST_WARN
int indexOf(
const QString &
s,
int from = 0)
const;
285 QT_ASCII_CAST_WARN
int lastIndexOf(
const QString &
s,
int from = -1)
const;
287 #ifndef QT_NO_CAST_FROM_ASCII
296 short toShort(
bool *ok = 0,
int base = 10)
const;
297 ushort toUShort(
bool *ok = 0,
int base = 10)
const;
298 int toInt(
bool *ok = 0,
int base = 10)
const;
299 uint toUInt(
bool *ok = 0,
int base = 10)
const;
300 long toLong(
bool *ok = 0,
int base = 10)
const;
301 ulong toULong(
bool *ok = 0,
int base = 10)
const;
302 qlonglong toLongLong(
bool *ok = 0,
int base = 10)
const;
303 qulonglong toULongLong(
bool *ok = 0,
int base = 10)
const;
304 float toFloat(
bool *ok = 0)
const;
305 double toDouble(
bool *ok = 0)
const;
310 char percent =
'%')
const;
318 QByteArray &setNum(
float,
char f =
'g',
int prec = 6);
319 QByteArray &setNum(
double,
char f =
'g',
int prec = 6);
323 static QByteArray number(uint,
int base = 10);
326 static QByteArray number(
double,
char f =
'g',
int prec = 6);
327 static QByteArray fromRawData(
const char *,
int size);
338 const_iterator begin()
const;
339 const_iterator constBegin()
const;
341 const_iterator
end()
const;
342 const_iterator constEnd()
const;
348 void push_back(
char c);
349 void push_back(
const char *c);
351 void push_front(
char c);
352 void push_front(
const char *c);
355 inline int count()
const {
return d->size; }
363 inline QT3_SUPPORT
QByteArray& duplicate(
const char *
a, uint
n)
365 inline QT3_SUPPORT
void resetRawData(
const char *, uint) { clear(); }
366 inline QT3_SUPPORT
QByteArray lower()
const {
return toLower(); }
367 inline QT3_SUPPORT
QByteArray upper()
const {
return toUpper(); }
368 inline QT3_SUPPORT
QByteArray stripWhiteSpace()
const {
return trimmed(); }
369 inline QT3_SUPPORT
QByteArray simplifyWhiteSpace()
const {
return simplified(); }
370 inline QT3_SUPPORT
int find(
char c,
int from = 0)
const {
return indexOf(c, from); }
371 inline QT3_SUPPORT
int find(
const char *c,
int from = 0)
const {
return indexOf(c, from); }
372 inline QT3_SUPPORT
int find(
const QByteArray &ba,
int from = 0)
const {
return indexOf(ba, from); }
373 inline QT3_SUPPORT
int findRev(
char c,
int from = -1)
const {
return lastIndexOf(c, from); }
374 inline QT3_SUPPORT
int findRev(
const char *c,
int from = -1)
const {
return lastIndexOf(c, from); }
375 inline QT3_SUPPORT
int findRev(
const QByteArray &ba,
int from = -1)
const {
return lastIndexOf(ba, from); }
376 #ifndef QT_NO_CAST_TO_ASCII
377 QT3_SUPPORT
int find(
const QString &
s,
int from = 0)
const;
378 QT3_SUPPORT
int findRev(
const QString &
s,
int from = -1)
const;
383 operator QNoImplicitBoolCast()
const;
384 static Data shared_null;
385 static Data shared_empty;
388 void realloc(
int alloc);
405 #ifdef Q_COMPILER_MANGLES_RETURN_TYPE
407 { Q_ASSERT(i >= 0 && i <
size());
return d->data[i]; }
409 { Q_ASSERT(i >= 0 && i <
size());
return d->data[i]; }
411 { Q_ASSERT(i < uint(
size()));
return d->data[i]; }
414 { Q_ASSERT(uint(i) < uint(
size()));
return d->data[i]; }
416 { Q_ASSERT(uint(i) < uint(
size()));
return d->data[i]; }
418 { Q_ASSERT(i < uint(
size()));
return d->data[i]; }
422 {
return d->size == 0; }
423 #ifndef QT_NO_CAST_FROM_BYTEARRAY
424 inline QByteArray::operator
const char *()
const
426 inline QByteArray::operator
const void *()
const
430 {
detach();
return d->data; }
436 {
if (d->ref != 1 || d->data != d->array) realloc(d->size); }
438 {
return d->ref == 1; }
443 { d->ref.ref();
if (aSize > 0)
fill(
'\0', aSize); }
450 {
if (d->ref != 1 || asize > d->alloc) realloc(asize); }
453 {
if (d->size < d->alloc) realloc(d->size); }
462 #ifdef Q_COMPILER_MANGLES_RETURN_TYPE
463 inline operator const char()
const
464 {
return i < a.d->size ? a.d->data[i] : char(0); }
466 inline operator char()
const
467 {
return i < a.d->size ? a.d->data[i] : char(0); }
470 {
if (i >= a.d->size) a.expand(i);
else a.detach();
471 a.d->data[i] =
c;
return *
this; }
473 {
if (i >= a.d->size) a.expand(i);
else a.detach();
474 a.d->data[i] = c.a.d->data[c.i];
return *
this; }
476 {
return a.d->data[i] ==
c; }
478 {
return a.d->data[i] !=
c; }
480 {
return a.d->data[i] >
c; }
482 {
return a.d->data[i] >=
c; }
484 {
return a.d->data[i] <
c; }
486 {
return a.d->data[i] <=
c; }
490 { Q_ASSERT(i >= 0);
return QByteRef(*
this, i); }
494 {
detach();
return d->data; }
500 {
detach();
return d->data + d->size; }
502 {
return d->data + d->size; }
504 {
return d->data + d->size; }
524 {
return QBool(
indexOf(a) != -1); }
526 {
return QBool(
indexOf(c) != -1); }
534 {
return !(a1==a2); }
540 {
return qstrcmp(a1, a2) < 0; }
542 {
return qstrcmp(a1, a2) < 0; }
544 {
return qstrcmp(a1, a2) < 0; }
546 {
return qstrcmp(a1, a2) <= 0; }
548 {
return qstrcmp(a1, a2) <= 0; }
550 {
return qstrcmp(a1, a2) <= 0; }
552 {
return qstrcmp(a1, a2) > 0; }
554 {
return qstrcmp(a1, a2) > 0; }
556 {
return qstrcmp(a1, a2) > 0; }
558 {
return qstrcmp(a1, a2) >= 0; }
560 {
return qstrcmp(a1, a2) >= 0; }
562 {
return qstrcmp(a1, a2) >= 0; }
563 #if !defined(QT_USE_QSTRINGBUILDER)
574 #endif // QT_USE_QSTRINGBUILDER
576 {
return QBool(
indexOf(c) != -1); }
593 {
return setNum(
double(n),f,prec); }
596 #if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
601 #ifndef QT_NO_COMPRESS
617 #ifdef QT_USE_QSTRINGBUILDER
621 #endif // QBYTEARRAY_H
Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt,...)
Q_CORE_EXPORT char * qstrcpy(char *dst, const char *src)
QByteArray & replace(int index, int len, const char *s)
void swap(QByteArray &other)
bool isSharedWith(const QByteArray &other) const
const char * const_iterator
QByteArray & operator+=(QByteArray &a, const QStringBuilder< A, B > &b)
Q_CORE_EXPORT QByteArray qUncompress(const uchar *data, int nbytes)
bool operator>(const QByteArray &a1, const QByteArray &a2)
QByteArray & append(char c)
QByteArray & fill(char c, int size=-1)
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
bool operator<=(char c) const
int indexOf(char c, int from=0) const
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
const_iterator constBegin() const
bool operator<=(const QByteArray &a1, const QByteArray &a2)
QByteRef & operator=(char c)
bool operator>(char c) const
const char * constData() const
bool operator==(const QByteArray &a1, const QByteArray &a2)
Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len)
#define QT_BEGIN_NAMESPACE
GLsizei GLsizei GLenum GLenum const GLvoid * data
char operator[](int i) const
QByteArray & prepend(char c)
Q_INLINE_TEMPLATE void qSwap(QScopedPointer< T, Cleanup > &p1, QScopedPointer< T, Cleanup > &p2)
bool operator!=(char c) const
Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap)
const QByteArray operator+(const QByteArray &a1, const QByteArray &a2)
GLuint GLuint GLsizei count
GLuint GLsizei GLsizei * length
bool operator!=(const QByteArray &a1, const QByteArray &a2)
const_iterator constEnd() const
Q_CORE_EXPORT QByteArray qCompress(const uchar *data, int nbytes, int compressionLevel=-1)
Q_CORE_EXPORT QDataStream & operator<<(QDataStream &, const QByteArray &)
uint qstrlen(const char *str)
QByteArray & operator+=(char c)
bool operator>=(const QByteArray &a1, const QByteArray &a2)
GLubyte GLubyte GLubyte a
uint qstrnlen(const char *str, uint maxlen)
int qstrncmp(const char *str1, const char *str2, uint len)
const char & const_reference
const_iterator ConstIterator
Q_DECLARE_TYPEINFO(QByteArray, Q_MOVABLE_TYPE)
QByteArray & setNum(short, int base=10)
bool operator<(const QByteArray &a1, const QByteArray &a2)
bool operator>=(char c) const
QBool contains(char c) const
Q_CORE_EXPORT int qstricmp(const char *, const char *)
Q_CORE_EXPORT QDataStream & operator>>(QDataStream &, QByteArray &)
Q_CORE_EXPORT int qstrnicmp(const char *, const char *, uint len)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
bool operator==(char c) const
Q_CORE_EXPORT char * qstrncpy(char *dst, const char *src, uint len)
QByteRef & operator=(const QByteRef &c)
bool operator<(char c) const
QT_BEGIN_HEADER QT_BEGIN_NAMESPACE Q_CORE_EXPORT char * qstrdup(const char *)