Qt 4.8
Classes | Typedefs | Functions
qstring.h File Reference
#include <QtCore/qchar.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qatomic.h>
#include <QtCore/qnamespace.h>
#include <string>
#include <stdarg.h>

Go to the source code of this file.

Classes

class  QCharRef
 The QCharRef class is a helper class for QString. More...
 
class  QLatin1String
 The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal. More...
 
class  QString
 The QString class provides a Unicode character string. More...
 
struct  QString::Data
 
struct  QString::Null
 
class  QStringRef
 The QStringRef class provides a thin wrapper around QString substrings. More...
 
class  QVector< T >
 The QVector class is a template class that provides a dynamic array. More...
 

Typedefs

typedef std::basic_string< wchar_t > QStdWString
 

Functions

bool operator!= (QString::Null, QString::Null)
 
bool operator!= (QString::Null, const QString &s)
 
bool operator!= (const QString &s, QString::Null)
 
QT_ASCII_CAST_WARN bool operator!= (const char *s1, const QString &s2)
 
QT_ASCII_CAST_WARN bool operator!= (const char *s1, const QLatin1String &s2)
 
bool operator!= (const QLatin1String &s1, const QLatin1String &s2)
 
bool operator!= (const QStringRef &s1, const QStringRef &s2)
 
bool operator!= (const QString &s1, const QStringRef &s2)
 
bool operator!= (const QStringRef &s1, const QString &s2)
 
bool operator!= (const QLatin1String &s1, const QStringRef &s2)
 
bool operator!= (const QStringRef &s1, const QLatin1String &s2)
 
QT_ASCII_CAST_WARN bool operator!= (const char *s1, const QStringRef &s2)
 
QT_ASCII_CAST_WARN bool operator!= (const QStringRef &s1, const char *s2)
 
const QString operator+ (const QString &s1, const QString &s2)
 
const QString operator+ (const QString &s1, QChar s2)
 
const QString operator+ (QChar s1, const QString &s2)
 
QT_ASCII_CAST_WARN const QString operator+ (const QString &s1, const char *s2)
 
QT_ASCII_CAST_WARN const QString operator+ (const char *s1, const QString &s2)
 
QT_ASCII_CAST_WARN const QString operator+ (char c, const QString &s)
 
QT_ASCII_CAST_WARN const QString operator+ (const QString &s, char c)
 
QT_ASCII_CAST_WARN const QString operator+ (const QByteArray &ba, const QString &s)
 
QT_ASCII_CAST_WARN const QString operator+ (const QString &s, const QByteArray &ba)
 
QT_ASCII_CAST_WARN bool operator< (const char *s1, const QString &s2)
 
QT_ASCII_CAST_WARN bool operator< (const char *s1, const QLatin1String &s2)
 
bool operator< (const QLatin1String &s1, const QLatin1String &s2)
 
Q_CORE_EXPORT bool operator< (const QStringRef &s1, const QStringRef &s2)
 
Q_CORE_EXPORT QDataStreamoperator<< (QDataStream &, const QString &)
 
QT_ASCII_CAST_WARN bool operator<= (const char *s1, const QString &s2)
 
QT_ASCII_CAST_WARN bool operator<= (const char *s1, const QLatin1String &s2)
 
bool operator<= (const QLatin1String &s1, const QLatin1String &s2)
 
bool operator<= (const QStringRef &s1, const QStringRef &s2)
 
bool operator== (QString::Null, QString::Null)
 
bool operator== (QString::Null, const QString &s)
 
bool operator== (const QString &s, QString::Null)
 
QT_ASCII_CAST_WARN bool operator== (const char *s1, const QString &s2)
 
QT_ASCII_CAST_WARN bool operator== (const char *s1, const QLatin1String &s2)
 
bool operator== (const QLatin1String &s1, const QLatin1String &s2)
 
Q_CORE_EXPORT bool operator== (const QStringRef &s1, const QStringRef &s2)
 
Q_CORE_EXPORT bool operator== (const QString &s1, const QStringRef &s2)
 
bool operator== (const QStringRef &s1, const QString &s2)
 
Q_CORE_EXPORT bool operator== (const QLatin1String &s1, const QStringRef &s2)
 
bool operator== (const QStringRef &s1, const QLatin1String &s2)
 
QT_ASCII_CAST_WARN bool operator== (const char *s1, const QStringRef &s2)
 
QT_ASCII_CAST_WARN bool operator== (const QStringRef &s1, const char *s2)
 
QT_ASCII_CAST_WARN bool operator> (const char *s1, const QString &s2)
 
QT_ASCII_CAST_WARN bool operator> (const char *s1, const QLatin1String &s2)
 
bool operator> (const QLatin1String &s1, const QLatin1String &s2)
 
bool operator> (const QStringRef &s1, const QStringRef &s2)
 
QT_ASCII_CAST_WARN bool operator>= (const char *s1, const QString &s2)
 
QT_ASCII_CAST_WARN bool operator>= (const char *s1, const QLatin1String &s2)
 
bool operator>= (const QLatin1String &s1, const QLatin1String &s2)
 
bool operator>= (const QStringRef &s1, const QStringRef &s2)
 
Q_CORE_EXPORT QDataStreamoperator>> (QDataStream &, QString &)
 
 Q_DECLARE_TYPEINFO (QString, Q_MOVABLE_TYPE)
 
bool qStringComparisonHelper (const QString &s1, const char *s2)
 
bool qStringComparisonHelper (const QStringRef &s1, const char *s2)
 

Typedef Documentation

◆ QStdWString

typedef std::basic_string<wchar_t> QStdWString

Definition at line 58 of file qstring.h.

Function Documentation

◆ operator!=() [1/13]

bool operator!= ( QString::Null  ,
QString::Null   
)
inline

Definition at line 911 of file qstring.h.

Referenced by QString::operator+=().

911 { return false; }

◆ operator!=() [2/13]

bool operator!= ( QString::Null  ,
const QString s 
)
inline

Definition at line 912 of file qstring.h.

912 { return !s.isNull(); }
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505

◆ operator!=() [3/13]

bool operator!= ( const QString s,
QString::Null   
)
inline

Definition at line 913 of file qstring.h.

913 { return !s.isNull(); }
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505

◆ operator!=() [4/13]

QT_ASCII_CAST_WARN bool operator!= ( const char *  s1,
const QString s2 
)
related

Definition at line 938 of file qstring.h.

939 { return !qStringComparisonHelper(s2, s1); }
bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator!=() [5/13]

QT_ASCII_CAST_WARN bool operator!= ( const char *  s1,
const QLatin1String s2 
)
inline

Definition at line 951 of file qstring.h.

952 { return QString::fromAscii(s1) != s2; }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator!=() [6/13]

bool operator!= ( const QLatin1String s1,
const QLatin1String s2 
)
inline

Definition at line 964 of file qstring.h.

965 { return (qstrcmp(s1.latin1(), s2.latin1()) != 0); }
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
Definition: qbytearray.cpp:231
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661

◆ operator!=() [7/13]

bool operator!= ( const QStringRef s1,
const QStringRef s2 
)
inline

Definition at line 1203 of file qstring.h.

1204 { return !(s1 == s2); }

◆ operator!=() [8/13]

bool operator!= ( const QString s1,
const QStringRef s2 
)
inline

Definition at line 1206 of file qstring.h.

1207 { return !(s1 == s2); }

◆ operator!=() [9/13]

bool operator!= ( const QStringRef s1,
const QString s2 
)
inline

Definition at line 1210 of file qstring.h.

1211 { return s2 != s1; }

◆ operator!=() [10/13]

bool operator!= ( const QLatin1String s1,
const QStringRef s2 
)
inline

Definition at line 1213 of file qstring.h.

1214 { return !(s1 == s2); }

◆ operator!=() [11/13]

bool operator!= ( const QStringRef s1,
const QLatin1String s2 
)
inline

Definition at line 1217 of file qstring.h.

1218 { return s2 != s1; }

◆ operator!=() [12/13]

QT_ASCII_CAST_WARN bool operator!= ( const char *  s1,
const QStringRef s2 
)
inline

Definition at line 1240 of file qstring.h.

1241 { return !qStringComparisonHelper(s2, s1); }
bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator!=() [13/13]

QT_ASCII_CAST_WARN bool operator!= ( const QStringRef s1,
const char *  s2 
)
inline

Definition at line 1242 of file qstring.h.

1243 { return !qStringComparisonHelper(s1, s2); }
bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator+() [1/9]

const QString operator+ ( const QString s1,
const QString s2 
)
related

Definition at line 1021 of file qstring.h.

1022 { QString t(s1); t += s2; return t; }
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ operator+() [2/9]

const QString operator+ ( const QString s1,
QChar  s2 
)
inline

Definition at line 1023 of file qstring.h.

1024 { QString t(s1); t += s2; return t; }
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ operator+() [3/9]

const QString operator+ ( QChar  s1,
const QString s2 
)
inline

Definition at line 1025 of file qstring.h.

1026 { QString t(s1); t += s2; return t; }
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ operator+() [4/9]

QT_ASCII_CAST_WARN const QString operator+ ( const QString s1,
const char *  s2 
)
related

Definition at line 1028 of file qstring.h.

1029 { QString t(s1); t += QString::fromAscii(s2); return t; }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ operator+() [5/9]

QT_ASCII_CAST_WARN const QString operator+ ( const char *  s1,
const QString s2 
)
related

Definition at line 1030 of file qstring.h.

1031 { QString t = QString::fromAscii(s1); t += s2; return t; }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ operator+() [6/9]

QT_ASCII_CAST_WARN const QString operator+ ( char  c,
const QString s 
)
related

Definition at line 1032 of file qstring.h.

1033 { QString t = s; t.prepend(QChar::fromAscii(c)); return t; }
unsigned char c[8]
Definition: qnumeric_p.h:62
QString & prepend(QChar c)
Definition: qstring.h:261
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QChar fromAscii(char c)
Converts the ASCII character c to its equivalent QChar.
Definition: qchar.cpp:1521

◆ operator+() [7/9]

QT_ASCII_CAST_WARN const QString operator+ ( const QString s,
char  c 
)
related

Definition at line 1034 of file qstring.h.

1035 { QString t = s; t += QChar::fromAscii(c); return t; }
unsigned char c[8]
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QChar fromAscii(char c)
Converts the ASCII character c to its equivalent QChar.
Definition: qchar.cpp:1521

◆ operator+() [8/9]

QT_ASCII_CAST_WARN const QString operator+ ( const QByteArray ba,
const QString s 
)
inline

Definition at line 1036 of file qstring.h.

1037 { QString t = QString::fromAscii(ba.constData(), qstrnlen(ba.constData(), ba.size())); t += s; return t; }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
The QString class provides a Unicode character string.
Definition: qstring.h:83
uint qstrnlen(const char *str, uint maxlen)
Definition: qbytearray.h:82
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ operator+() [9/9]

QT_ASCII_CAST_WARN const QString operator+ ( const QString s,
const QByteArray ba 
)
inline

Definition at line 1038 of file qstring.h.

1039 { QString t(s); t += QString::fromAscii(ba.constData(), qstrnlen(ba.constData(), ba.size())); return t; }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
The QString class provides a Unicode character string.
Definition: qstring.h:83
uint qstrnlen(const char *str, uint maxlen)
Definition: qbytearray.h:82
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ operator<() [1/4]

QT_ASCII_CAST_WARN bool operator< ( const char *  s1,
const QString s2 
)
related

Definition at line 940 of file qstring.h.

Referenced by QString::localeAwareCompare(), QString::operator+=(), and QString::operator>=().

941 { return (QString::fromAscii(s1) < s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator<() [2/4]

QT_ASCII_CAST_WARN bool operator< ( const char *  s1,
const QLatin1String s2 
)
inline

Definition at line 953 of file qstring.h.

954 { return (QString::fromAscii(s1) < s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator<() [3/4]

bool operator< ( const QLatin1String s1,
const QLatin1String s2 
)
inline

Definition at line 966 of file qstring.h.

967 { return (qstrcmp(s1.latin1(), s2.latin1()) < 0); }
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
Definition: qbytearray.cpp:231
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661

◆ operator<() [4/4]

Q_CORE_EXPORT bool operator< ( const QStringRef s1,
const QStringRef s2 
)
related

◆ operator<<()

Q_CORE_EXPORT QDataStream& operator<< ( QDataStream ,
const QString  
)
related

Definition at line 8034 of file qstring.cpp.

8035 {
8036  if (out.version() == 1) {
8037  out << str.toLatin1();
8038  } else {
8039  if (!str.isNull() || out.version() < 3) {
8040  if ((out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)) {
8041  out.writeBytes(reinterpret_cast<const char *>(str.unicode()), sizeof(QChar) * str.length());
8042  } else {
8043  QVarLengthArray<ushort> buffer(str.length());
8044  const ushort *data = reinterpret_cast<const ushort *>(str.constData());
8045  for (int i = 0; i < str.length(); i++) {
8046  buffer[i] = qbswap(*data);
8047  ++data;
8048  }
8049  out.writeBytes(reinterpret_cast<const char *>(buffer.data()), sizeof(ushort) * buffer.size());
8050  }
8051  } else {
8052  // write null marker
8053  out << (quint32)0xffffffff;
8054  }
8055  }
8056  return out;
8057 }
void qbswap(const T src, uchar *dest)
Definition: qendian.h:74
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static const char * data(const QByteArray &arr)
unsigned short ushort
Definition: qglobal.h:995
unsigned int quint32
Definition: qglobal.h:938

◆ operator<=() [1/4]

QT_ASCII_CAST_WARN bool operator<= ( const char *  s1,
const QString s2 
)
related

Definition at line 944 of file qstring.h.

Referenced by QString::operator+=().

945 { return (QString::fromAscii(s1) <= s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator<=() [2/4]

QT_ASCII_CAST_WARN bool operator<= ( const char *  s1,
const QLatin1String s2 
)
inline

Definition at line 957 of file qstring.h.

958 { return (QString::fromAscii(s1) <= s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator<=() [3/4]

bool operator<= ( const QLatin1String s1,
const QLatin1String s2 
)
inline

Definition at line 968 of file qstring.h.

969 { return (qstrcmp(s1.latin1(), s2.latin1()) <= 0); }
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
Definition: qbytearray.cpp:231
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661

◆ operator<=() [4/4]

bool operator<= ( const QStringRef s1,
const QStringRef s2 
)
related

Definition at line 1223 of file qstring.h.

1224 { return !(s1 > s2); }

◆ operator==() [1/13]

bool operator== ( QString::Null  ,
QString::Null   
)
inline

Definition at line 908 of file qstring.h.

Referenced by QString::localeAwareCompare(), QString::operator!=(), QString::operator+=(), and QString::operator>=().

908 { return true; }

◆ operator==() [2/13]

bool operator== ( QString::Null  ,
const QString s 
)
inline

Definition at line 909 of file qstring.h.

909 { return s.isNull(); }
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505

◆ operator==() [3/13]

bool operator== ( const QString s,
QString::Null   
)
inline

Definition at line 910 of file qstring.h.

910 { return s.isNull(); }
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505

◆ operator==() [4/13]

QT_ASCII_CAST_WARN bool operator== ( const char *  s1,
const QString s2 
)
inline

Definition at line 936 of file qstring.h.

937 { return qStringComparisonHelper(s2, s1); }
bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator==() [5/13]

QT_ASCII_CAST_WARN bool operator== ( const char *  s1,
const QLatin1String s2 
)
inline

Definition at line 949 of file qstring.h.

950 { return QString::fromAscii(s1) == s2; }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator==() [6/13]

bool operator== ( const QLatin1String s1,
const QLatin1String s2 
)
inline

Definition at line 962 of file qstring.h.

963 { return (qstrcmp(s1.latin1(), s2.latin1()) == 0); }
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
Definition: qbytearray.cpp:231
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661

◆ operator==() [7/13]

Q_CORE_EXPORT bool operator== ( const QStringRef s1,
const QStringRef s2 
)
related

◆ operator==() [8/13]

Q_CORE_EXPORT bool operator== ( const QString s1,
const QStringRef s2 
)
related

◆ operator==() [9/13]

bool operator== ( const QStringRef s1,
const QString s2 
)
inline

Definition at line 1208 of file qstring.h.

1209 { return s2 == s1; }

◆ operator==() [10/13]

Q_CORE_EXPORT bool operator== ( const QLatin1String s1,
const QStringRef s2 
)
related

◆ operator==() [11/13]

bool operator== ( const QStringRef s1,
const QLatin1String s2 
)
inline

Definition at line 1215 of file qstring.h.

1216 { return s2 == s1; }

◆ operator==() [12/13]

QT_ASCII_CAST_WARN bool operator== ( const char *  s1,
const QStringRef s2 
)
inline

Definition at line 1236 of file qstring.h.

1237 { return qStringComparisonHelper(s2, s1); }
bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator==() [13/13]

QT_ASCII_CAST_WARN bool operator== ( const QStringRef s1,
const char *  s2 
)
inline

Definition at line 1238 of file qstring.h.

1239 { return qStringComparisonHelper(s1, s2); }
bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator>() [1/4]

QT_ASCII_CAST_WARN bool operator> ( const char *  s1,
const QString s2 
)
related

Definition at line 942 of file qstring.h.

Referenced by QString::operator+=(), QString::operator<=(), and QString::operator>=().

943 { return (QString::fromAscii(s1) > s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator>() [2/4]

QT_ASCII_CAST_WARN bool operator> ( const char *  s1,
const QLatin1String s2 
)
inline

Definition at line 955 of file qstring.h.

956 { return (QString::fromAscii(s1) > s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator>() [3/4]

bool operator> ( const QLatin1String s1,
const QLatin1String s2 
)
inline

Definition at line 970 of file qstring.h.

971 { return (qstrcmp(s1.latin1(), s2.latin1()) > 0); }
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
Definition: qbytearray.cpp:231
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661

◆ operator>() [4/4]

bool operator> ( const QStringRef s1,
const QStringRef s2 
)
related

Definition at line 1221 of file qstring.h.

1222 { return s2 < s1; }

◆ operator>=() [1/4]

QT_ASCII_CAST_WARN bool operator>= ( const char *  s1,
const QString s2 
)
related

Definition at line 946 of file qstring.h.

Referenced by QString::operator+=().

947 { return (QString::fromAscii(s1) >= s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator>=() [2/4]

QT_ASCII_CAST_WARN bool operator>= ( const char *  s1,
const QLatin1String s2 
)
inline

Definition at line 959 of file qstring.h.

960 { return (QString::fromAscii(s1) >= s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator>=() [3/4]

bool operator>= ( const QLatin1String s1,
const QLatin1String s2 
)
inline

Definition at line 972 of file qstring.h.

973 { return (qstrcmp(s1.latin1(), s2.latin1()) >= 0); }
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
Definition: qbytearray.cpp:231
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661

◆ operator>=() [4/4]

bool operator>= ( const QStringRef s1,
const QStringRef s2 
)
related

Definition at line 1225 of file qstring.h.

1226 { return !(s1 < s2); }

◆ operator>>()

Q_CORE_EXPORT QDataStream& operator>> ( QDataStream ,
QString  
)
related

Definition at line 8071 of file qstring.cpp.

8072 {
8073 #ifdef QT_QSTRING_UCS_4
8074 #if defined(Q_CC_GNU)
8075 #warning "operator>> not working properly"
8076 #endif
8077 #endif
8078 
8079  if (in.version() == 1) {
8080  QByteArray l;
8081  in >> l;
8082  str = QString::fromLatin1(l);
8083  } else {
8084  quint32 bytes = 0;
8085  in >> bytes; // read size of string
8086  if (bytes == 0xffffffff) { // null string
8087  str.clear();
8088  } else if (bytes > 0) { // not empty
8089  if (bytes & 0x1) {
8090  str.clear();
8091  in.setStatus(QDataStream::ReadCorruptData);
8092  return in;
8093  }
8094 
8095  const quint32 Step = 1024 * 1024;
8096  quint32 len = bytes / 2;
8097  quint32 allocated = 0;
8098 
8099  while (allocated < len) {
8100  int blockSize = qMin(Step, len - allocated);
8101  str.resize(allocated + blockSize);
8102  if (in.readRawData(reinterpret_cast<char *>(str.data()) + allocated * 2,
8103  blockSize * 2) != blockSize * 2) {
8104  str.clear();
8105  in.setStatus(QDataStream::ReadPastEnd);
8106  return in;
8107  }
8108  allocated += blockSize;
8109  }
8110 
8111  if ((in.byteOrder() == QDataStream::BigEndian)
8112  != (QSysInfo::ByteOrder == QSysInfo::BigEndian)) {
8113  ushort *data = reinterpret_cast<ushort *>(str.data());
8114  while (len--) {
8115  *data = qbswap(*data);
8116  ++data;
8117  }
8118  }
8119  } else {
8120  str = QLatin1String("");
8121  }
8122  }
8123  return in;
8124 }
const int blockSize
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void qbswap(const T src, uchar *dest)
Definition: qendian.h:74
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static const char * data(const QByteArray &arr)
unsigned short ushort
Definition: qglobal.h:995
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
unsigned int quint32
Definition: qglobal.h:938
QFactoryLoader * l

◆ Q_DECLARE_TYPEINFO()

Q_DECLARE_TYPEINFO ( QString  ,
Q_MOVABLE_TYPE   
)

Referenced by QString::fromStdWString().

◆ qStringComparisonHelper() [1/2]

bool qStringComparisonHelper ( const QString s1,
const char *  s2 
)
inline

Definition at line 916 of file qstring.h.

Referenced by operator!=(), and operator==().

917 {
918 # ifndef QT_NO_TEXTCODEC
919  if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2));
920 # endif
921  return (s1 == QLatin1String(s2));
922 }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QTextCodec * codecForCStrings
Definition: qstring.h:621

◆ qStringComparisonHelper() [2/2]

bool qStringComparisonHelper ( const QStringRef s1,
const char *  s2 
)
inline

Definition at line 1228 of file qstring.h.

1229 {
1230 # ifndef QT_NO_TEXTCODEC
1231  if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2));
1232 # endif
1233  return (s1 == QLatin1String(s2));
1234 }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QTextCodec * codecForCStrings
Definition: qstring.h:621