QtCore/qstringbuilder.h File Reference

qstringbuilder.h File Reference
#include <QtCore/qstring.h>
#include <QtCore/qbytearray.h>
#include <string.h>

Classes

class  QLatin1Literal
 
struct  QAbstractConcatenable
 
struct  QConcatenable< T >
 
class  QStringBuilder< A, B >
 
class  QStringBuilder< QString, QString >
 
class  QStringBuilder< QByteArray, QByteArray >
 
struct  QConcatenable< char >
 
struct  QConcatenable< QLatin1Char >
 
struct  QConcatenable< QChar >
 
struct  QConcatenable< QCharRef >
 
struct  QConcatenable< QLatin1String >
 
struct  QConcatenable< QLatin1Literal >
 
struct  QConcatenable< QString >
 
struct  QConcatenable< QStringRef >
 
struct  QConcatenable< char[N]>
 
struct  QConcatenable< const char[N]>
 
struct  QConcatenable< const char * >
 
struct  QConcatenable< QByteArray >
 
struct  ConvertToTypeHelper< A, B >
 
struct  ConvertToTypeHelper< T, QString >
 
struct  QConcatenable< QStringBuilder< A, B > >
 

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

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 }
GLubyte GLubyte b
Definition: GLee.h:5404
GLubyte GLubyte GLubyte a
Definition: GLee.h:5404
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
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 }
void reserve(int size)
Definition: qbytearray.h:449
void resize(int size)
char * data()
Definition: qbytearray.h:429
GLubyte GLubyte GLubyte a
Definition: GLee.h:5404
Definition: qchar.h:72
int size() const
Definition: qbytearray.h:402
GLenum GLsizei len
Definition: GLee.h:2695
GLsizeiptr size
Definition: GLee.h:1561
QString& operator+= ( QString a,
const QStringBuilder< A, B > &  b 
)

Definition at line 444 of file qstringbuilder.h.

445 {
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 }
const QChar * constData() const
Definition: qstring.h:712
int size() const
Definition: qstring.h:102
GLubyte GLubyte GLubyte a
Definition: GLee.h:5404
Definition: qchar.h:72
GLenum GLsizei len
Definition: GLee.h:2695
GLsizeiptr size
Definition: GLee.h:1561
void resize(int size)
QChar * data()
Definition: qstring.h:710
void reserve(int size)
Definition: qstring.h:881

Go to the source code of this file.