Qt 4.8
|
The QStringBuilder class is a template class that provides a facility to build up QStrings from smaller chunks. More...
#include <qstringbuilder.h>
Public Functions | |
operator ConvertTo () const | |
QStringBuilder (const A &a_, const B &b_) | |
Constructs a QStringBuilder from a and b. More... | |
int | size () const |
QByteArray | toLatin1 () const |
Returns a Latin-1 representation of the string as a QByteArray. More... | |
Public Variables | |
const A & | a |
const B & | b |
Private Types | |
typedef QConcatenable< QStringBuilder< A, B > > | Concatenable |
typedef Concatenable::ConvertTo | ConvertTo |
Private Functions | |
template<typename T > | |
T | convertTo () const |
Friends | |
class | QByteArray |
class | QString |
The QStringBuilder class is a template class that provides a facility to build up QStrings from smaller chunks.
To build a QString by multiple concatenations, QString::operator+() is typically used. This causes n - 1 reallocations when building a string from n chunks.
QStringBuilder uses expression templates to collect the individual chunks, compute the total size, allocate the required amount of memory for the final QString object, and copy the chunks into the allocated memory.
The QStringBuilder class is not to be used explicitly in user code. Instances of the class are created as return values of the operator%() function, acting on objects of type QString, QLatin1String, QLatin1Literal, QStringRef, QChar, QCharRef, QLatin1Char, and char
.
Concatenating strings with operator%() generally yields better performance then using QString::operator+()
on the same chunks if there are three or more of them, and performs equally well in other cases.
Definition at line 112 of file qstringbuilder.h.
|
private |
Definition at line 136 of file qstringbuilder.h.
|
private |
Definition at line 137 of file qstringbuilder.h.
|
inline |
|
inlineprivate |
Definition at line 119 of file qstringbuilder.h.
|
inline |
Definition at line 139 of file qstringbuilder.h.
|
inline |
Definition at line 142 of file qstringbuilder.h.
|
inline |
Returns a Latin-1 representation of the string as a QByteArray.
The returned byte array is undefined if the string contains non-Latin1 characters.
Definition at line 141 of file qstringbuilder.h.
Referenced by QStringBuilder< A, B >::toLatin1().
|
friend |
Definition at line 117 of file qstringbuilder.h.
Definition at line 118 of file qstringbuilder.h.
const A& QStringBuilder< A, B >::a |
Definition at line 144 of file qstringbuilder.h.
Referenced by QConcatenable< QStringBuilder< A, B > >::appendTo(), and QConcatenable< QStringBuilder< A, B > >::size().
const B& QStringBuilder< A, B >::b |
Definition at line 145 of file qstringbuilder.h.
Referenced by QConcatenable< QStringBuilder< A, B > >::appendTo(), and QConcatenable< QStringBuilder< A, B > >::size().