qstring.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 **
4 ** Definition of the QString class, and related Unicode
5 ** functions.
6 **
7 ** Created : 920609
8 **
9 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
10 **
11 ** This file is part of the tools module of the Qt GUI Toolkit.
12 **
13 ** This file may be distributed under the terms of the Q Public License
14 ** as defined by Trolltech AS of Norway and appearing in the file
15 ** LICENSE.QPL included in the packaging of this file.
16 **
17 ** This file may be distributed and/or modified under the terms of the
18 ** GNU General Public License version 2 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.GPL included in the
20 ** packaging of this file.
21 **
22 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
23 ** licenses may use this file in accordance with the Qt Commercial License
24 ** Agreement provided with the Software.
25 **
26 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
27 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
28 **
29 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
30 ** information about Qt Commercial License Agreements.
31 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
32 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
33 **
34 ** Contact info@trolltech.com if any conditions of this licensing are
35 ** not clear to you.
36 **
37 **********************************************************************/
38 
39 #ifndef QSTRING_H
40 #define QSTRING_H
41 
42 #ifndef QT_H
43 #include "qcstring.h"
44 #endif // QT_H
45 
46 #define QT_NO_ASCII_CAST
47 
48 /*****************************************************************************
49  QString class
50  *****************************************************************************/
51 
52 class QRegExp;
53 class QString;
54 class QCharRef;
55 
57 public:
58  QChar();
59  QChar( char c );
60  QChar( uchar c );
61  QChar( uchar c, uchar r );
62  QChar( const QChar& c );
63  QChar( ushort rc );
64  QChar( short rc );
65  QChar( uint rc );
66  QChar( int rc );
67 
73 
74  // Unicode information
75 
76  enum Category
77  {
79 
83 
86  Number_Other, // No
87 
91 
93  Other_Format, // Cf
97 
103 
111 
112  Symbol_Math, // Sm
115  Symbol_Other // So
116  };
117 
119  {
120  DirL, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON,
121  DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN
122  };
123 
125  {
126  Single, Canonical, Font, NoBreak, Initial, Medial,
127  Final, Isolated, Circle, Super, Sub, Vertical,
128  Wide, Narrow, Small, Square, Compat, Fraction
129  };
130 
131  enum Joining
132  {
133  OtherJoining, Dual, Right, Center
134  };
135 
136  // ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO
137 
138  int digitValue() const;
139  QChar lower() const;
140  QChar upper() const;
141 
142  Category category() const;
143  Direction direction() const;
144  Joining joining() const;
145  bool mirrored() const;
146  QChar mirroredChar() const;
147  QString decomposition() const;
148  Decomposition decompositionTag() const;
149 
150  char latin1() const { return rw ? 0 : cl; }
151  ushort unicode() const { return (rw << 8) | cl; }
152 #ifndef QT_NO_CAST_ASCII
153  // like all ifdef'd code this is undocumented
154  operator char() const { return latin1(); }
155 #endif
156 
157  bool isNull() const { return unicode()==0; }
158  bool isPrint() const;
159  bool isPunct() const;
160  bool isSpace() const;
161  bool isMark() const;
162  bool isLetter() const;
163  bool isNumber() const;
164  bool isLetterOrNumber() const;
165  bool isDigit() const;
166 
167  uchar& cell() { return cl; }
168  uchar& row() { return rw; }
169  uchar cell() const { return cl; }
170  uchar row() const { return rw; }
171 
172  static bool networkOrdered() { return (int)net_ordered == 1; }
173 
174  friend inline int operator==( char ch, QChar c );
175  friend inline int operator==( QChar c, char ch );
176  friend inline int operator==( QChar c1, QChar c2 );
177  friend inline int operator!=( QChar c1, QChar c2 );
178  friend inline int operator!=( char ch, QChar c );
179  friend inline int operator!=( QChar c, char ch );
180  friend inline int operator<=( QChar c, char ch );
181  friend inline int operator<=( char ch, QChar c );
182  friend inline int operator<=( QChar c1, QChar c2 );
183 
184 private:
185 #if defined(_WS_X11_) || defined(_OS_WIN32_BYTESWAP_) || defined( _WS_QWS_ )
186  // XChar2b on X11, ushort on _OS_WIN32_BYTESWAP_
187  //### QWS must be defined on a platform by platform basis
190 #if defined(QT_QSTRING_UCS_4)
191  ushort grp;
192 #endif
193  enum { net_ordered = 1 };
194 #else
195  // ushort on _OS_WIN32_
196  uchar cl;
197  uchar rw;
198 #if defined(QT_QSTRING_UCS_4)
199  ushort grp;
200 #endif
201  enum { net_ordered = 0 };
202 #endif
203 };
204 
205 inline QChar::QChar()
206 {
207  rw = 0; cl = 0;
208 #ifdef QT_QSTRING_UCS_4
209  grp = 0;
210 #endif
211 }
212 inline QChar::QChar( char c )
213 {
214  rw = 0; cl = (uchar)c;
215 #ifdef QT_QSTRING_UCS_4
216  grp = 0;
217 #endif
218 }
220 {
221  rw = 0; cl = c;
222 #ifdef QT_QSTRING_UCS_4
223  grp = 0;
224 #endif
225 }
227 {
228  rw = r; cl = c;
229 #ifdef QT_QSTRING_UCS_4
230  grp = 0;
231 #endif
232 }
233 inline QChar::QChar( const QChar& c )
234 {
235  rw = c.rw; cl = c.cl;
236 #ifdef QT_QSTRING_UCS_4
237  grp = 0;
238 #endif
239 }
241 {
242  rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
243 #ifdef QT_QSTRING_UCS_4
244  grp = 0;
245 #endif
246 }
247 inline QChar::QChar( short rc )
248 {
249  rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
250 #ifdef QT_QSTRING_UCS_4
251  grp = 0;
252 #endif
253 }
255 {
256  rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
257 #ifdef QT_QSTRING_UCS_4
258  grp = 0;
259 #endif
260 }
261 inline QChar::QChar( int rc )
262 {
263  rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
264 #ifdef QT_QSTRING_UCS_4
265  grp = 0;
266 #endif
267 }
268 
269 
270 inline int operator==( char ch, QChar c )
271 {
272  return ch == c.cl && !c.rw;
273 }
274 
275 inline int operator==( QChar c, char ch )
276 {
277  return ch == c.cl && !c.rw;
278 }
279 
280 inline int operator==( QChar c1, QChar c2 )
281 {
282  return c1.cl == c2.cl
283  && c1.rw == c2.rw;
284 }
285 
286 inline int operator!=( QChar c1, QChar c2 )
287 {
288  return c1.cl != c2.cl
289  || c1.rw != c2.rw;
290 }
291 
292 inline int operator!=( char ch, QChar c )
293 {
294  return ch != c.cl || c.rw;
295 }
296 
297 inline int operator!=( QChar c, char ch )
298 {
299  return ch != c.cl || c.rw;
300 }
301 
302 inline int operator<=( QChar c, char ch )
303 {
304  return !(ch < c.cl || c.rw);
305 }
306 
307 inline int operator<=( char ch, QChar c )
308 {
309  return ch <= c.cl || c.rw;
310 }
311 
312 inline int operator<=( QChar c1, QChar c2 )
313 {
314  return c1.rw > c2.rw
315  ? FALSE
316  : c1.rw < c2.rw
317  ? TRUE
318  : c1.cl <= c2.cl;
319 }
320 
321 inline int operator>=( QChar c, char ch ) { return ch <= c; }
322 inline int operator>=( char ch, QChar c ) { return c <= ch; }
323 inline int operator>=( QChar c1, QChar c2 ) { return c2 <= c1; }
324 inline int operator<( QChar c, char ch ) { return !(ch<=c); }
325 inline int operator<( char ch, QChar c ) { return !(c<=ch); }
326 inline int operator<( QChar c1, QChar c2 ) { return !(c2<=c1); }
327 inline int operator>( QChar c, char ch ) { return !(ch>=c); }
328 inline int operator>( char ch, QChar c ) { return !(c>=ch); }
329 inline int operator>( QChar c1, QChar c2 ) { return !(c2>=c1); }
330 
331 // internal
332 struct Q_EXPORT QStringData : public QShared {
334  unicode(0), ascii(0), len(0), maxl(0), dirtyascii(0) { ref(); }
336  unicode(u), ascii(0), len(l), maxl(m), dirtyascii(0) { }
337 
338  ~QStringData() { if ( unicode ) delete[] ((char*)unicode);
339  if ( ascii ) delete[] ascii; }
340 
341  void deleteSelf();
343  char *ascii;
345  uint maxl:30;
346  uint dirtyascii:1;
347 };
348 
349 
351 {
352 public:
353  QString(); // make null string
354  QString( QChar ); // one-char string
355  QString( const QString & ); // impl-shared copy
356  QString( const QByteArray& ); // deep copy
357  QString( const QCString& ); // deep copy
358  QString( const QChar* unicode, uint length ); // deep copy
359 #ifndef QT_NO_CAST_ASCII
360  QString( const char *str ); // deep copy
361 #endif
362  ~QString();
363 
364  QString &operator=( const QString & ); // impl-shared copy
365 #ifndef QT_NO_CAST_ASCII
366  QString &operator=( const char * ); // deep copy
367 #endif
368  QString &operator=( const QCString& ); // deep copy
369  QString &operator=( QChar c );
370  QString &operator=( char c );
371 
372  //QT_STATIC_CONST QString null;
373  //bool isNull() const;
374 
375  struct Null { };
376  static const Null null;
377  inline QString(const Null &): d(shared_null) { d->ref(); }
378  inline QString &operator=(const Null &) { *this = QString(); return *this; }
379  inline bool isNull() const { return d == shared_null; }
380 
381  bool isEmpty() const;
382  uint length() const;
383  void truncate( uint pos );
384 
385 #if QT_VERSION >= 300
386 #error "fill() Should return *this, or QChar constructor should take count=1"
387 #endif
388  void fill( QChar c, int len = -1 );
389 
390  QString copy() const;
391 
392  QString arg(long a, int fieldwidth=0, int base=10) const;
393  QString arg(ulong a, int fieldwidth=0, int base=10) const;
394  QString arg(int a, int fieldwidth=0, int base=10) const;
395  QString arg(uint a, int fieldwidth=0, int base=10) const;
396  QString arg(short a, int fieldwidth=0, int base=10) const;
397  QString arg(ushort a, int fieldwidth=0, int base=10) const;
398  QString arg(char a, int fieldwidth=0) const;
399  QString arg(QChar a, int fieldwidth=0) const;
400  QString arg(const QString& a, int fieldwidth=0) const;
401  QString arg(double a, int fieldwidth=0, char fmt='g', int prec=-1) const;
402 
403  QString &sprintf( const char* format, ... )
404 #if defined(_CC_GNU_) && !defined(__INSURE__)
405  __attribute__ ((format (printf, 2, 3)))
406 #endif
407  ;
408 
409  int find( QChar c, int index=0, bool cs=TRUE ) const;
410  int find( char c, int index=0, bool cs=TRUE ) const;
411  int find( const QString &str, int index=0, bool cs=TRUE ) const;
412  int find( const QRegExp &, int index=0 ) const;
413 #ifndef QT_NO_CAST_ASCII
414  int find( const char* str, int index=0 ) const;
415 #endif
416  int findRev( QChar c, int index=-1, bool cs=TRUE) const;
417  int findRev( char c, int index=-1, bool cs=TRUE) const;
418  int findRev( const QString &str, int index=-1, bool cs=TRUE) const;
419  int findRev( const QRegExp &, int index=-1 ) const;
420 #ifndef QT_NO_CAST_ASCII
421  int findRev( const char* str, int index=-1 ) const;
422 #endif
423  int contains( QChar c, bool cs=TRUE ) const;
424  int contains( char c, bool cs=TRUE ) const
425  { return contains(QChar(c), cs); }
426 #ifndef QT_NO_CAST_ASCII
427  int contains( const char* str, bool cs=TRUE ) const;
428 #endif
429  int contains( const QString &str, bool cs=TRUE ) const;
430  int contains( const QRegExp & ) const;
431 
432  QString left( uint len ) const;
433  QString right( uint len ) const;
434  QString mid( uint index, uint len=0xffffffff) const;
435 
436  QString leftJustify( uint width, QChar fill=' ', bool trunc=FALSE)const;
437  QString rightJustify( uint width, QChar fill=' ',bool trunc=FALSE)const;
438 
439  QString lower() const;
440  QString upper() const;
441 
442  QString stripWhiteSpace() const;
443  QString simplifyWhiteSpace() const;
444 
445  QString &insert( uint index, const QString & );
446  QString &insert( uint index, const QChar*, uint len );
447  QString &insert( uint index, QChar );
448  QString &insert( uint index, char c ) { return insert(index,QChar(c)); }
449  QString &append( char );
450  QString &append( QChar );
451  QString &append( const QString & );
452  QString &prepend( char );
453  QString &prepend( QChar );
454  QString &prepend( const QString & );
455  QString &remove( uint index, uint len );
456  QString &replace( uint index, uint len, const QString & );
457  QString &replace( uint index, uint len, const QChar*, uint clen );
458  QString &replace( const QRegExp &, const QString & );
459 
460  short toShort( bool *ok=0, int base=10 ) const;
461  ushort toUShort( bool *ok=0, int base=10 ) const;
462  int toInt( bool *ok=0, int base=10 ) const;
463  uint toUInt( bool *ok=0, int base=10 ) const;
464  long toLong( bool *ok=0, int base=10 ) const;
465  ulong toULong( bool *ok=0, int base=10 ) const;
466  uint64 toUInt64( bool *ok=0, int base=10 ) const;
467  float toFloat( bool *ok=0 ) const;
468  double toDouble( bool *ok=0 ) const;
469 
470  QString &setNum( short, int base=10 );
471  QString &setNum( ushort, int base=10 );
472  QString &setNum( int, int base=10 );
473  QString &setNum( uint, int base=10 );
474  QString &setNum( long, int base=10 );
475  QString &setNum( ulong, int base=10 );
476  QString &setNum( float, char f='g', int prec=6 );
477  QString &setNum( double, char f='g', int prec=6 );
478 
479  static QString number( long, int base=10 );
480  static QString number( ulong, int base=10);
481  static QString number( int, int base=10 );
482  static QString number( uint, int base=10);
483  static QString number( double, char f='g', int prec=6 );
484 
485  void setExpand( uint index, QChar c );
486 
487  QString &operator+=( const QString &str );
488  QString &operator+=( QChar c );
489  QString &operator+=( char c );
490 
491  // Your compiler is smart enough to use the const one if it can.
492  QChar at( uint i ) const
493  { return i<d->len ? d->unicode[i] : QChar::null; }
494  QChar operator[]( int i ) const { return at((uint)i); }
495  QCharRef at( uint i );
496  QCharRef operator[]( int i );
497 
498  QChar constref(uint i) const
499  { return at(i); }
501  { // Optimized for easy-inlining by simple compilers.
502  if (d->count!=1 || i>=d->len)
503  subat(i);
504  d->dirtyascii=1;
505  return d->unicode[i];
506  }
507 
508  const QChar* unicode() const { return d->unicode; }
509  const char* ascii() const;
510  const char* latin1() const;
511  static QString fromLatin1(const char*, int len=-1);
512  const unsigned short *ucs2() const;
513  static QString fromUcs2( const unsigned short *ucs2 );
514 #ifndef QT_NO_TEXTCODEC
515  QCString utf8() const;
516  static QString fromUtf8(const char*, int len=-1);
517 #endif
518  QCString local8Bit() const;
519  static QString fromLocal8Bit(const char*, int len=-1);
520  bool operator!() const;
521 #ifndef QT_NO_ASCII_CAST
522  operator const char *() const { return latin1(); }
523 #endif
524 
525  QString &setUnicode( const QChar* unicode, uint len );
526  QString &setUnicodeCodes( const ushort* unicode_as_ushorts, uint len );
527  QString &setLatin1( const char*, int len=-1 );
528 
529  int compare( const QString& s ) const;
530  static int compare( const QString& s1, const QString& s2 )
531  { return s1.compare(s2); }
532 
533 #ifndef QT_NO_DATASTREAM
535 #endif
536  // new functions for BiDi
537  void compose();
538  QChar::Direction basicDirection();
539  QString visual(int index = 0, int len = -1);
540 
541 #ifndef QT_NO_COMPAT
542  const char* data() const { return latin1(); }
543 #endif
544 
545  bool startsWith( const QString& ) const;
546 
547 private:
548  QString( int size, bool dummy ); // allocate size incl. \0
549 
550  void deref();
551  void real_detach();
552  void setLength( uint pos );
553  void subat( uint );
554  bool findArg(int& pos, int& len) const;
555 
556  static QChar* asciiToUnicode( const char*, uint * len, uint maxlen=(uint)-1 );
557  static QChar* asciiToUnicode( const QByteArray&, uint * len );
558  static char* unicodeToAscii( const QChar*, uint len );
559 
562  static QStringData* makeSharedNull();
563 
564  friend class QConstString;
565  QString(QStringData* dd, bool /*dummy*/) : d(dd) { }
566 };
567 
569  friend class QString;
572  QCharRef(QString* str, uint pos) : s(*str), p(pos) { }
573 
574 public:
575  // Most QChar operations repeated here...
576 
577  // all this is not documented: We just say "like QChar" and let it be.
578 #if 1
579  ushort unicode() const { return s.constref(p).unicode(); }
580  char latin1() const { return s.constref(p).latin1(); }
581 
582  // An operator= for each QChar cast constructor...
583  QCharRef operator=(char c ) { s.ref(p)=c; return *this; }
584  QCharRef operator=(uchar c ) { s.ref(p)=c; return *this; }
585  QCharRef operator=(QChar c ) { s.ref(p)=c; return *this; }
586  QCharRef operator=(const QCharRef& c ) { s.ref(p)=c.unicode(); return *this; }
587  QCharRef operator=(ushort rc ) { s.ref(p)=rc; return *this; }
588  QCharRef operator=(short rc ) { s.ref(p)=rc; return *this; }
589  QCharRef operator=(uint rc ) { s.ref(p)=rc; return *this; }
590  QCharRef operator=(int rc ) { s.ref(p)=rc; return *this; }
591 
592  operator QChar () const { return s.constref(p); }
593 
594  // each function...
595  bool isNull() const { return unicode()==0; }
596  bool isPrint() const { return s.constref(p).isPrint(); }
597  bool isPunct() const { return s.constref(p).isPunct(); }
598  bool isSpace() const { return s.constref(p).isSpace(); }
599  bool isMark() const { return s.constref(p).isMark(); }
600  bool isLetter() const { return s.constref(p).isLetter(); }
601  bool isNumber() const { return s.constref(p).isNumber(); }
602  bool isLetterOrNumber() { return s.constref(p).isLetterOrNumber(); }
603  bool isDigit() const { return s.constref(p).isDigit(); }
604 
605  int digitValue() const { return s.constref(p).digitValue(); }
606  QChar lower() { return s.constref(p).lower(); }
607  QChar upper() { return s.constref(p).upper(); }
608 
609  QChar::Category category() const { return s.constref(p).category(); }
610  QChar::Direction direction() const { return s.constref(p).direction(); }
611  QChar::Joining joining() const { return s.constref(p).joining(); }
612  bool mirrored() const { return s.constref(p).mirrored(); }
613  QChar mirroredChar() const { return s.constref(p).mirroredChar(); }
614  QString decomposition() const { return s.constref(p).decomposition(); }
616 
617  // Not the non-const ones of these.
618  uchar cell() const { return s.constref(p).cell(); }
619  uchar row() const { return s.constref(p).row(); }
620 #endif
621 };
622 
623 inline QCharRef QString::at( uint i ) { return QCharRef(this,i); }
624 inline QCharRef QString::operator[]( int i ) { return at((uint)i); }
625 
626 
627 class Q_EXPORT QConstString : private QString {
628 public:
629  QConstString( QChar* unicode, uint length );
630  ~QConstString();
631  const QString& string() const { return *this; }
632 };
633 
634 
635 /*****************************************************************************
636  QString stream functions
637  *****************************************************************************/
638 #ifndef QT_NO_DATASTREAM
641 #endif
642 
643 /*****************************************************************************
644  QString inline functions
645  *****************************************************************************/
646 
647 // These two move code into makeSharedNull() and deletesData()
648 // to improve cache-coherence (and reduce code bloat), while
649 // keeping the common cases fast.
650 //
651 // No safe way to pre-init shared_null on ALL compilers/linkers.
653  d(shared_null ? shared_null : makeSharedNull())
654 {
655  d->ref();
656 }
657 //
659 {
660  if ( d->deref() ) {
661  if ( d == shared_null )
662  shared_null = 0;
663  d->deleteSelf();
664  }
665 }
666 
668 { return *this = QString(c); }
669 
670 inline QString &QString::operator=( char c )
671 { return *this = QString(QChar(c)); }
672 
673 //inline bool QString::isNull() const
674 //{ return unicode() == 0; }
675 
676 inline bool QString::operator!() const
677 { return isNull(); }
678 
679 inline uint QString::length() const
680 { return d->len; }
681 
682 inline bool QString::isEmpty() const
683 { return length() == 0; }
684 
685 inline QString QString::copy() const
686 { return QString( *this ); }
687 
688 inline QString &QString::prepend( const QString & s )
689 { return insert(0,s); }
690 
692 { return insert(0,c); }
693 
694 inline QString &QString::prepend( char c )
695 { return insert(0,c); }
696 
697 inline QString &QString::append( const QString & s )
698 { return operator+=(s); }
699 
701 { return operator+=(c); }
702 
703 inline QString &QString::append( char c )
704 { return operator+=(c); }
705 
706 inline QString &QString::setNum( short n, int base )
707 { return setNum((long)n, base); }
708 
710 { return setNum((ulong)n, base); }
711 
712 inline QString &QString::setNum( int n, int base )
713 { return setNum((long)n, base); }
714 
716 { return setNum((ulong)n, base); }
717 
718 inline QString &QString::setNum( float n, char f, int prec )
719 { return setNum((double)n,f,prec); }
720 
721 inline QString QString::arg(int a, int fieldwidth, int base) const
722 { return arg((long)a, fieldwidth, base); }
723 
724 inline QString QString::arg(uint a, int fieldwidth, int base) const
725 { return arg((ulong)a, fieldwidth, base); }
726 
727 inline QString QString::arg(short a, int fieldwidth, int base) const
728 { return arg((long)a, fieldwidth, base); }
729 
730 inline QString QString::arg(ushort a, int fieldwidth, int base) const
731 { return arg((ulong)a, fieldwidth, base); }
732 
733 inline int QString::find( char c, int index, bool cs ) const
734 { return find(QChar(c), index, cs); }
735 
736 inline int QString::findRev( char c, int index, bool cs) const
737 { return findRev( QChar(c), index, cs ); }
738 
739 
740 #ifndef QT_NO_CAST_ASCII
741 inline int QString::find( const char* str, int index ) const
742 { return find(QString::fromLatin1(str), index); }
743 
744 inline int QString::findRev( const char* str, int index ) const
745 { return findRev(QString::fromLatin1(str), index); }
746 #endif
747 
748 
749 /*****************************************************************************
750  QString non-member operators
751  *****************************************************************************/
752 
753 Q_EXPORT bool operator!=( const QString &s1, const QString &s2 );
754 Q_EXPORT bool operator<( const QString &s1, const QString &s2 );
755 Q_EXPORT bool operator<=( const QString &s1, const QString &s2 );
756 Q_EXPORT bool operator==( const QString &s1, const QString &s2 );
757 Q_EXPORT bool operator>( const QString &s1, const QString &s2 );
758 Q_EXPORT bool operator>=( const QString &s1, const QString &s2 );
759 #ifndef QT_NO_CAST_ASCII
760 Q_EXPORT bool operator!=( const QString &s1, const char *s2 );
761 Q_EXPORT bool operator<( const QString &s1, const char *s2 );
762 Q_EXPORT bool operator<=( const QString &s1, const char *s2 );
763 Q_EXPORT bool operator==( const QString &s1, const char *s2 );
764 Q_EXPORT bool operator>( const QString &s1, const char *s2 );
765 Q_EXPORT bool operator>=( const QString &s1, const char *s2 );
766 Q_EXPORT bool operator!=( const char *s1, const QString &s2 );
767 Q_EXPORT bool operator<( const char *s1, const QString &s2 );
768 Q_EXPORT bool operator<=( const char *s1, const QString &s2 );
769 Q_EXPORT bool operator==( const char *s1, const QString &s2 );
770 //Q_EXPORT bool operator>( const char *s1, const QString &s2 ); // MSVC++
771 Q_EXPORT bool operator>=( const char *s1, const QString &s2 );
772 #endif
773 
774 Q_EXPORT inline QString operator+( const QString &s1, const QString &s2 )
775 {
776  QString tmp( s1 );
777  tmp += s2;
778  return tmp;
779 }
780 
781 #ifndef QT_NO_CAST_ASCII
782 Q_EXPORT inline QString operator+( const QString &s1, const char *s2 )
783 {
784  QString tmp( s1 );
785  tmp += QString::fromLatin1(s2);
786  return tmp;
787 }
788 
789 Q_EXPORT inline QString operator+( const char *s1, const QString &s2 )
790 {
792  tmp += s2;
793  return tmp;
794 }
795 #endif
796 
797 Q_EXPORT inline QString operator+( const QString &s1, QChar c2 )
798 {
799  QString tmp( s1 );
800  tmp += c2;
801  return tmp;
802 }
803 
804 Q_EXPORT inline QString operator+( const QString &s1, char c2 )
805 {
806  QString tmp( s1 );
807  tmp += c2;
808  return tmp;
809 }
810 
811 Q_EXPORT inline QString operator+( QChar c1, const QString &s2 )
812 {
813  QString tmp;
814  tmp += c1;
815  tmp += s2;
816  return tmp;
817 }
818 
819 Q_EXPORT inline QString operator+( char c1, const QString &s2 )
820 {
821  QString tmp;
822  tmp += c1;
823  tmp += s2;
824  return tmp;
825 }
826 
827 #if defined(_OS_WIN32_)
828 extern Q_EXPORT QString qt_winQString(void*);
829 extern Q_EXPORT const void* qt_winTchar(const QString& str, bool addnul);
830 extern Q_EXPORT void* qt_winTchar_new(const QString& str);
831 extern Q_EXPORT QCString qt_winQString2MB( const QString& s, int len=-1 );
832 extern Q_EXPORT QString qt_winMB2QString( const char* mb, int len=-1 );
833 #endif
834 
835 #endif // QSTRING_H
bool deref()
Definition: qshared.h:50
bool isNumber() const
Definition: qstring.cpp:11046
uint p
Definition: qstring.h:571
Joining
Definition: qstring.h:131
A QString which uses constant Unicode data.
Definition: qstring.h:627
const QChar * unicode() const
Definition: qstring.h:508
Category
Definition: qstring.h:76
bool isEmpty() const
Definition: qstring.h:682
QChar()
Definition: qstring.h:205
uchar cl
Definition: qstring.h:189
~QStringData()
Definition: qstring.h:338
Direction direction() const
Definition: qstring.cpp:11114
char * ascii
Definition: qstring.h:343
The QRegExp class provides pattern matching using regular expressions or wildcards.
Definition: qregexp.h:46
bool isLetter() const
Definition: qstring.h:600
uchar row() const
Definition: qstring.h:619
static const int maxlen
Definition: qregexp.cpp:904
QString copy() const
Definition: qstring.h:685
uchar row() const
Definition: qstring.h:170
DoubleProduct & operator+=(DoubleProduct &left, DoubleProduct const &right)
Definition: ToyProducts.h:103
void deleteSelf()
Definition: qstring.cpp:12383
int compare(unsigned *r, sha1::digest_t const &d)
Definition: sha1_test_2.cc:60
bool isSpace() const
Definition: qstring.cpp:11006
QString & insert(uint index, char c)
Definition: qstring.h:448
std::enable_if_t< is_selector< A >, NotHelper< A > > operator!(A const &a)
Definition: Selector.h:259
ushort unicode() const
Definition: qstring.h:151
Joining joining() const
Definition: qstring.cpp:11132
uchar rw
Definition: qstring.h:188
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
bool isLetter() const
Definition: qstring.cpp:11035
QString & s
Definition: qstring.h:570
QChar operator[](int i) const
Definition: qstring.h:494
const bool FALSE
Definition: qglobal.h:370
QCharRef operator=(uint rc)
Definition: qstring.h:589
uint len
Definition: qstring.h:344
char latin1() const
Definition: qstring.h:580
QString & append(char)
Definition: qstring.h:703
bool operator<(const QString &s1, const char *s2)
Definition: qstring.cpp:14878
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
int operator!=(QChar c1, QChar c2)
Definition: qstring.h:286
bool operator>=(const QString &s1, const char *s2)
Definition: qstring.cpp:14896
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
bool isPunct() const
Definition: qstring.h:597
The QChar class provides a light-weight Unicode character.
Definition: qstring.h:56
static QStrList * l
Definition: config.cpp:1044
Category category() const
Definition: qstring.cpp:11096
Decomposition decompositionTag() const
Definition: qstring.cpp:11210
QAsciiDict< Entry > cl
unsigned char uchar
Definition: nybbler.cc:11
ushort unicode() const
Definition: qstring.h:579
QStringData()
Definition: qstring.h:333
~QString()
Definition: qstring.h:658
int digitValue() const
Definition: qstring.h:605
QString(QStringData *dd, bool)
Definition: qstring.h:565
uchar & cell()
Definition: qstring.h:167
QChar upper()
Definition: qstring.h:607
QChar constref(uint i) const
Definition: qstring.h:498
int compare(const QString &s) const
Definition: qstring.cpp:14838
bool isNumber() const
Definition: qstring.h:601
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
bool isMark() const
Definition: qstring.h:599
bool operator<=(const QString &s1, const char *s2)
Definition: qstring.cpp:14884
QString & prepend(char)
Definition: qstring.h:694
int digitValue() const
Definition: qstring.cpp:11075
QString arg(long a, int fieldwidth=0, int base=10) const
Definition: qstring.cpp:12593
uchar cell() const
Definition: qstring.h:618
const char * data() const
Definition: qstring.h:542
bool isLetterOrNumber() const
Definition: qstring.cpp:11055
int operator<=(QChar c, char ch)
Definition: qstring.h:302
QString & operator=(const Null &)
Definition: qstring.h:378
QString & setNum(short, int base=10)
Definition: qstring.h:706
QString(const Null &)
Definition: qstring.h:377
QString & operator+=(const QString &str)
Definition: qstring.cpp:14399
#define Q_PACKED
Definition: qglobal.h:283
QChar at(uint i) const
Definition: qstring.h:492
static bool networkOrdered()
Definition: qstring.h:172
QString decomposition() const
Definition: qstring.h:614
QCharRef operator=(char c)
Definition: qstring.h:583
QCharRef operator=(short rc)
Definition: qstring.h:588
uint length() const
Definition: qstring.h:679
bool mirrored() const
Definition: qstring.cpp:11149
std::void_t< T > n
const double a
static constexpr double mb
Definition: Units.h:79
QChar mirroredChar() const
Definition: qstring.cpp:11165
QT_STATIC_CONST QChar replacement
Definition: qstring.h:69
uchar cell() const
Definition: qstring.h:169
QString operator+(const QString &s1, const QString &s2)
Definition: qstring.h:774
unsigned long ulong
Definition: qglobal.h:352
QChar::Joining joining() const
Definition: qstring.h:611
bool isPrint() const
Definition: qstring.cpp:10996
#define QT_STATIC_CONST
Definition: qglobal.h:380
QCharRef operator=(QChar c)
Definition: qstring.h:585
string tmp
Definition: languages.py:63
QT_STATIC_CONST QChar byteOrderMark
Definition: qstring.h:70
bool isNull() const
Definition: qstring.h:157
QCharRef operator=(const QCharRef &c)
Definition: qstring.h:586
QChar lower() const
Definition: qstring.cpp:11229
bool isPunct() const
Definition: qstring.cpp:11026
void ref()
Definition: qshared.h:49
QString & operator=(const QString &)
Definition: qstring.cpp:12402
int findRev(QChar c, int index=-1, bool cs=TRUE) const
Definition: qstring.cpp:13021
Q_EXPORT QDataStream & operator>>(QDataStream &, QString &)
QChar mirroredChar() const
Definition: qstring.h:613
QStringData(QChar *u, uint l, uint m)
Definition: qstring.h:335
bool mirrored() const
Definition: qstring.h:612
Direction
Definition: qstring.h:118
Q_EXPORT QDataStream & operator<<(QDataStream &, const QString &)
QCharRef operator=(int rc)
Definition: qstring.h:590
unsigned short ushort
Definition: qglobal.h:350
bool isPrint() const
Definition: qstring.h:596
bool operator>(const QString &s1, const char *s2)
Definition: qstring.cpp:14890
bool isDigit() const
Definition: qstring.cpp:11066
bool isMark() const
Definition: qstring.cpp:11017
int operator<(QChar c, char ch)
Definition: qstring.h:324
QStringData * d
Definition: qstring.h:560
bool operator==(const QString &s1, const QString &s2)
Definition: qstring.cpp:14843
def fill(s)
Definition: translator.py:93
The QCharRef class is a helper class for QString.
Definition: qstring.h:568
int find(QChar c, int index=0, bool cs=TRUE) const
Definition: qstring.cpp:12902
QT_STATIC_CONST QChar byteOrderSwapped
Definition: qstring.h:71
QT_STATIC_CONST QChar nbsp
Definition: qstring.h:72
int operator==(char ch, QChar c)
Definition: qstring.h:270
QChar::Decomposition decompositionTag() const
Definition: qstring.h:615
char latin1() const
Definition: qstring.h:150
QChar * unicode
Definition: qstring.h:342
QCharRef operator=(uchar c)
Definition: qstring.h:584
QT_STATIC_CONST QChar null
Definition: qstring.h:68
int contains(char c, bool cs=TRUE) const
Definition: qstring.h:424
uchar & row()
Definition: qstring.h:168
T copy(T const &v)
bool operator!() const
Definition: qstring.h:676
bool isNull() const
Definition: qstring.h:379
cet::LibraryManager dummy("noplugin")
QCharRef(QString *str, uint pos)
Definition: qstring.h:572
The QShared struct is internally used for implementing shared classes.
Definition: qshared.h:46
bool operator!=(const QString &s1, const QString &s2)
Definition: qstring.cpp:14850
QCharRef operator=(ushort rc)
Definition: qstring.h:587
QChar lower()
Definition: qstring.h:606
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:47
int operator>=(QChar c, char ch)
Definition: qstring.h:321
static const Null null
Definition: qstring.h:376
bool isSpace() const
Definition: qstring.h:598
QChar & ref(uint i)
Definition: qstring.h:500
const char * cs
QString decomposition() const
Definition: qstring.cpp:11186
unsigned long long uint64
Definition: qglobal.h:361
bool isDigit() const
Definition: qstring.h:603
const QString & string() const
Definition: qstring.h:631
bool isNull() const
Definition: qstring.h:595
static int compare(const QString &s1, const QString &s2)
Definition: qstring.h:530
QChar::Category category() const
Definition: qstring.h:609
unsigned uint
Definition: qglobal.h:351
QString & insert(uint index, const QString &)
Definition: qstring.cpp:13523
static QCString * s
Definition: config.cpp:1042
#define Q_EXPORT
Definition: qglobal.h:468
const bool TRUE
Definition: qglobal.h:371
static QCString str
QChar upper() const
Definition: qstring.cpp:11248
int operator>(QChar c, char ch)
Definition: qstring.h:327
bool isLetterOrNumber()
Definition: qstring.h:602
QChar::Direction direction() const
Definition: qstring.h:610
QString()
Definition: qstring.h:652
static QStringData * shared_null
Definition: qstring.h:561
Decomposition
Definition: qstring.h:124