Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QStringBuilder< A, B > Class Template Reference

\inmodule QtCore More...

#include <qstringbuilder.h>

+ Inheritance diagram for QStringBuilder< A, B >:
+ Collaboration diagram for QStringBuilder< A, B >:

Public Types

typedef Concatenable::ConvertTo ConvertTo
 

Public Member Functions

 QStringBuilder (A &&a_, B &&b_)
 
 QStringBuilder (QStringBuilder &&)=default
 
 QStringBuilder (const QStringBuilder &)=default
 
 ~QStringBuilder ()=default
 
 operator ConvertTo () const
 
qsizetype size () const
 
bool isNull () const
 
- Public Member Functions inherited from QStringBuilderCommon< Builder, T >
toUpper () const
 
toLower () const
 

Public Attributes

A a
 
B b
 

Friends

class QByteArray
 
class QString
 

Additional Inherited Members

- Protected Member Functions inherited from QStringBuilderCommon< Builder, T >
resolved () const
 

Detailed Description

template<typename A, typename B>
class QStringBuilder< A, B >

\inmodule QtCore

\reentrant

Since
4.6

The QStringBuilder class is a template class that provides a facility to build up QStrings and QByteArrays from smaller chunks.

To build a QString by multiple concatenations, QString::operator+() is typically used. This causes {n - 1} allocations when building a string from {n} chunks. The same is true for QByteArray.

QStringBuilder uses expression templates to collect the individual chunks, compute the total size, allocate the required amount of memory for the final string 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 the following types:

For building QStrings:

\list

The types in the last list point are only available when QT_NO_CAST_FROM_ASCII is not defined.

For building QByteArrays:

\list

Concatenating strings with operator%() generally yields better performance than using QString::operator+() on the same chunks if there are three or more of them, and performs equally well in other cases.

Note
Defining QT_USE_QSTRINGBUILDER at build time (this is the default when building Qt libraries and tools), will make using {'+'} when concatenating strings work the same way as operator%().
See also
QLatin1StringView, QString

Definition at line 79 of file qstringbuilder.h.

Member Typedef Documentation

◆ ConvertTo

template<typename A , typename B >
typedef Concatenable::ConvertTo QStringBuilder< A, B >::ConvertTo

Definition at line 129 of file qstringbuilder.h.

Constructor & Destructor Documentation

◆ QStringBuilder() [1/3]

template<typename A , typename B >
QStringBuilder< A, B >::QStringBuilder ( A && a_,
B && b_ )
inline

Definition at line 87 of file qstringbuilder.h.

◆ QStringBuilder() [2/3]

template<typename A , typename B >
QStringBuilder< A, B >::QStringBuilder ( QStringBuilder< A, B > && )
default

◆ QStringBuilder() [3/3]

template<typename A , typename B >
QStringBuilder< A, B >::QStringBuilder ( const QStringBuilder< A, B > & )
default

◆ ~QStringBuilder()

template<typename A , typename B >
QStringBuilder< A, B >::~QStringBuilder ( )
default

Member Function Documentation

◆ isNull()

template<typename A , typename B >
bool QStringBuilder< A, B >::isNull ( ) const
inline

Definition at line 134 of file qstringbuilder.h.

References QtStringBuilder::isNull().

+ Here is the call graph for this function:

◆ operator ConvertTo()

template<typename A , typename B >
QStringBuilder< A, B >::operator ConvertTo ( ) const
inline

Definition at line 130 of file qstringbuilder.h.

◆ size()

template<typename A , typename B >
qsizetype QStringBuilder< A, B >::size ( ) const
inline

Definition at line 132 of file qstringbuilder.h.

References QConcatenable< QStringBuilder< A, B > >::size().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ QByteArray

template<typename A , typename B >
friend class QByteArray
friend

Definition at line 94 of file qstringbuilder.h.

◆ QString

template<typename A , typename B >
friend class QString
friend

Definition at line 95 of file qstringbuilder.h.

Member Data Documentation

◆ a

template<typename A , typename B >
A QStringBuilder< A, B >::a

Definition at line 139 of file qstringbuilder.h.

◆ b

template<typename A , typename B >
B QStringBuilder< A, B >::b

Definition at line 140 of file qstringbuilder.h.


The documentation for this class was generated from the following file: