Public Member Functions | List of all members
QConstString Class Reference

A QString which uses constant Unicode data. More...

#include <qstring.h>

Inheritance diagram for QConstString:
QString

Public Member Functions

 QConstString (QChar *unicode, uint length)
 
 ~QConstString ()
 
const QStringstring () const
 

Additional Inherited Members

- Private Member Functions inherited from QString
 QString ()
 
 QString (QChar)
 
 QString (const QString &)
 
 QString (const QByteArray &)
 
 QString (const QCString &)
 
 QString (const QChar *unicode, uint length)
 
 QString (const char *str)
 
 ~QString ()
 
QStringoperator= (const QString &)
 
QStringoperator= (const char *)
 
QStringoperator= (const QCString &)
 
QStringoperator= (QChar c)
 
QStringoperator= (char c)
 
 QString (const Null &)
 
QStringoperator= (const Null &)
 
bool isNull () const
 
bool isEmpty () const
 
uint length () const
 
void truncate (uint pos)
 
void fill (QChar c, int len=-1)
 
QString copy () const
 
QString arg (long a, int fieldwidth=0, int base=10) const
 
QString arg (ulong a, int fieldwidth=0, int base=10) const
 
QString arg (int a, int fieldwidth=0, int base=10) const
 
QString arg (uint a, int fieldwidth=0, int base=10) const
 
QString arg (short a, int fieldwidth=0, int base=10) const
 
QString arg (ushort a, int fieldwidth=0, int base=10) const
 
QString arg (char a, int fieldwidth=0) const
 
QString arg (QChar a, int fieldwidth=0) const
 
QString arg (const QString &a, int fieldwidth=0) const
 
QString arg (double a, int fieldwidth=0, char fmt='g', int prec=-1) const
 
QStringsprintf (const char *format,...)
 
int find (QChar c, int index=0, bool cs=TRUE) const
 
int find (char c, int index=0, bool cs=TRUE) const
 
int find (const QString &str, int index=0, bool cs=TRUE) const
 
int find (const QRegExp &, int index=0) const
 
int find (const char *str, int index=0) const
 
int findRev (QChar c, int index=-1, bool cs=TRUE) const
 
int findRev (char c, int index=-1, bool cs=TRUE) const
 
int findRev (const QString &str, int index=-1, bool cs=TRUE) const
 
int findRev (const QRegExp &, int index=-1) const
 
int findRev (const char *str, int index=-1) const
 
int contains (QChar c, bool cs=TRUE) const
 
int contains (char c, bool cs=TRUE) const
 
int contains (const char *str, bool cs=TRUE) const
 
int contains (const QString &str, bool cs=TRUE) const
 
int contains (const QRegExp &) const
 
QString left (uint len) const
 
QString right (uint len) const
 
QString mid (uint index, uint len=0xffffffff) const
 
QString leftJustify (uint width, QChar fill=' ', bool trunc=FALSE) const
 
QString rightJustify (uint width, QChar fill=' ', bool trunc=FALSE) const
 
QString lower () const
 
QString upper () const
 
QString stripWhiteSpace () const
 
QString simplifyWhiteSpace () const
 
QStringinsert (uint index, const QString &)
 
QStringinsert (uint index, const QChar *, uint len)
 
QStringinsert (uint index, QChar)
 
QStringinsert (uint index, char c)
 
QStringappend (char)
 
QStringappend (QChar)
 
QStringappend (const QString &)
 
QStringprepend (char)
 
QStringprepend (QChar)
 
QStringprepend (const QString &)
 
QStringremove (uint index, uint len)
 
QStringreplace (uint index, uint len, const QString &)
 
QStringreplace (uint index, uint len, const QChar *, uint clen)
 
QStringreplace (const QRegExp &, const QString &)
 
short toShort (bool *ok=0, int base=10) const
 
ushort toUShort (bool *ok=0, int base=10) const
 
int toInt (bool *ok=0, int base=10) const
 
uint toUInt (bool *ok=0, int base=10) const
 
long toLong (bool *ok=0, int base=10) const
 
ulong toULong (bool *ok=0, int base=10) const
 
uint64 toUInt64 (bool *ok=0, int base=10) const
 
float toFloat (bool *ok=0) const
 
double toDouble (bool *ok=0) const
 
QStringsetNum (short, int base=10)
 
QStringsetNum (ushort, int base=10)
 
QStringsetNum (int, int base=10)
 
QStringsetNum (uint, int base=10)
 
QStringsetNum (long, int base=10)
 
QStringsetNum (ulong, int base=10)
 
QStringsetNum (float, char f='g', int prec=6)
 
QStringsetNum (double, char f='g', int prec=6)
 
void setExpand (uint index, QChar c)
 
QStringoperator+= (const QString &str)
 
QStringoperator+= (QChar c)
 
QStringoperator+= (char c)
 
QChar at (uint i) const
 
QChar operator[] (int i) const
 
QCharRef at (uint i)
 
QCharRef operator[] (int i)
 
QChar constref (uint i) const
 
QCharref (uint i)
 
const QCharunicode () const
 
const char * ascii () const
 
const char * latin1 () const
 
const unsigned short * ucs2 () const
 
QCString utf8 () const
 
QCString local8Bit () const
 
bool operator! () const
 
QStringsetUnicode (const QChar *unicode, uint len)
 
QStringsetUnicodeCodes (const ushort *unicode_as_ushorts, uint len)
 
QStringsetLatin1 (const char *, int len=-1)
 
int compare (const QString &s) const
 
void compose ()
 
QChar::Direction basicDirection ()
 
QString visual (int index=0, int len=-1)
 
const char * data () const
 
bool startsWith (const QString &) const
 
- Static Private Member Functions inherited from QString
static QString number (long, int base=10)
 
static QString number (ulong, int base=10)
 
static QString number (int, int base=10)
 
static QString number (uint, int base=10)
 
static QString number (double, char f='g', int prec=6)
 
static QString fromLatin1 (const char *, int len=-1)
 
static QString fromUcs2 (const unsigned short *ucs2)
 
static QString fromUtf8 (const char *, int len=-1)
 
static QString fromLocal8Bit (const char *, int len=-1)
 
static int compare (const QString &s1, const QString &s2)
 
- Static Private Attributes inherited from QString
static const Null null = { }
 

Detailed Description

A QString which uses constant Unicode data.

In order to minimize copying, highly optimized applications can use QConstString to provide a QString-compatible object from existing Unicode data. It is then the user's responsibility to make sure that the Unicode data must exist for the entire lifetime of the QConstString object.

Definition at line 627 of file qstring.h.

Constructor & Destructor Documentation

QConstString::QConstString ( QChar unicode,
uint  length 
)

Constructs a QConstString that uses the first length Unicode characters in the array unicode. Any attempt to modify copies of the string will cause it to create a copy of the data, thus it remains forever unmodified.

Note that unicode is not copied. The caller must be able to guarantee that unicode will not be deleted or modified. Since that is generally not the case with const strings (they are references), this constructor demands a non-const pointer even though it never modifies unicode.

Definition at line 15179 of file qstring.cpp.

15179  :
15180  QString(new QStringData(unicode, length, length),TRUE)
15181 {
15182 }
uint length() const
Definition: qstring.h:679
const bool TRUE
Definition: qglobal.h:371
QString()
Definition: qstring.h:652
QConstString::~QConstString ( )

Destroys the QConstString, creating a copy of the data if other strings are still using it.

Definition at line 15188 of file qstring.cpp.

15189 {
15190  if ( d->count > 1 ) {
15191  QChar* cp = QT_ALLOC_QCHAR_VEC( d->len );
15192  memcpy( cp, d->unicode, d->len*sizeof(QChar) );
15193  d->unicode = cp;
15194  } else {
15195  d->unicode = 0;
15196  }
15197 
15198  // The original d->unicode is now unlinked.
15199 }
uint len
Definition: qstring.h:344
uint count
Definition: qshared.h:51
The QChar class provides a light-weight Unicode character.
Definition: qstring.h:56
QStringData * d
Definition: qstring.h:560
QChar * unicode
Definition: qstring.h:342
#define QT_ALLOC_QCHAR_VEC(N)
Definition: qstring.cpp:11946

Member Function Documentation

const QString & QConstString::string ( ) const
inline

Returns a constant string referencing the data passed during construction.

Definition at line 631 of file qstring.h.

631 { return *this; }

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