Qt 4.8
Classes | Namespaces | Functions
qstringbuilder.h File Reference
#include <QtCore/qstring.h>
#include <QtCore/qbytearray.h>
#include <string.h>

Go to the source code of this file.

Classes

struct  QAbstractConcatenable
 
struct  QConcatenable< T >
 
struct  QConcatenable< char >
 
struct  QConcatenable< char[N]>
 
struct  QConcatenable< const char * >
 
struct  QConcatenable< const char[N]>
 
struct  QConcatenable< QByteArray >
 
struct  QConcatenable< QChar >
 
struct  QConcatenable< QCharRef >
 
struct  QConcatenable< QLatin1Char >
 
struct  QConcatenable< QLatin1Literal >
 
struct  QConcatenable< QLatin1String >
 
struct  QConcatenable< QString >
 
struct  QConcatenable< QStringBuilder< A, B > >
 
struct  QConcatenable< QStringRef >
 
class  QLatin1Literal
 The QLatin1Literal class provides a thin wrapper around string literals used in source code. More...
 
class  QStringBuilder< A, B >
 The QStringBuilder class is a template class that provides a facility to build up QStrings from smaller chunks. More...
 
class  QStringBuilder< QByteArray, QByteArray >
 
class  QStringBuilder< QString, QString >
 
struct  QtStringBuilder::ConvertToTypeHelper< A, B >
 
struct  QtStringBuilder::ConvertToTypeHelper< T, QString >
 

Namespaces

 QtStringBuilder
 

Functions

template<typename A , typename B >
QStringBuilder< typename QConcatenable< A >::type, typename QConcatenable< B >::typeoperator% (const A &a, const B &b)
 
template<typename A , typename B >
QByteArrayoperator+= (QByteArray &a, const QStringBuilder< A, B > &b)
 
template<typename A , typename B >
QStringoperator+= (QString &a, const QStringBuilder< A, B > &b)
 

Function Documentation

◆ operator%()

template<typename A , typename B >
QStringBuilder<typename QConcatenable<A>::type, typename QConcatenable<B>::type> operator% ( const A a,
const B &  b 
)

Definition at line 410 of file qstringbuilder.h.

411 {
413 }
long ASN1_INTEGER_get ASN1_INTEGER * a
The QStringBuilder class is a template class that provides a facility to build up QStrings from small...

◆ operator+=() [1/2]

template<typename A , typename B >
QByteArray& operator+= ( QByteArray a,
const QStringBuilder< A, B > &  b 
)

Definition at line 427 of file qstringbuilder.h.

428 {
429 #ifndef QT_NO_CAST_TO_ASCII
430  if (sizeof(typename QConcatenable< QStringBuilder<A, B> >::ConvertTo::value_type) == sizeof(QChar)) {
431  //it is not save to optimize as in utf8 it is not possible to compute the size
432  return a += QString(b);
433  }
434 #endif
435  int len = a.size() + QConcatenable< QStringBuilder<A, B> >::size(b);
436  a.reserve(len);
437  char *it = a.data() + a.size();
438  QConcatenable< QStringBuilder<A, B> >::appendTo(b, it);
439  a.resize(len); //we need to resize after the appendTo for the case str+=foo+str
440  return a;
441 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
#define it(className, varName)
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
The QStringBuilder class is a template class that provides a facility to build up QStrings from small...
void resize(int size)
Sets the size of the byte array to size bytes.
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
void reserve(int size)
Attempts to allocate memory for at least size bytes.
Definition: qbytearray.h:449

◆ operator+=() [2/2]

template<typename A , typename B >
QString& operator+= ( QString a,
const QStringBuilder< A, B > &  b 
)

Definition at line 444 of file qstringbuilder.h.

445 {
446  int len = a.size() + QConcatenable< QStringBuilder<A, B> >::size(b);
447  a.reserve(len);
448  QChar *it = a.data() + a.size();
449  QConcatenable< QStringBuilder<A, B> >::appendTo(b, it);
450  a.resize(it - a.constData()); //may be smaller than len if there was conversion from utf8
451  return a;
452 }
#define it(className, varName)
long ASN1_INTEGER_get ASN1_INTEGER * a
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
void reserve(int size)
Attempts to allocate memory for at least size characters.
Definition: qstring.h:881
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712