Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/qtools/qstring.h

Source at commit 1322 created 9 years 5 months ago.
By meklort, Add doxygen to utils folder
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
47/*****************************************************************************
48 QString class
49 *****************************************************************************/
50
51class QRegExp;
52class QString;
53class QCharRef;
54
55class Q_EXPORT Q_PACKED QChar {
56public:
57 QChar();
58 QChar( char c );
59 QChar( uchar c );
60 QChar( uchar c, uchar r );
61 QChar( const QChar& c );
62 QChar( ushort rc );
63 QChar( short rc );
64 QChar( uint rc );
65 QChar( int rc );
66
67 QT_STATIC_CONST QChar null; // 0000
68 QT_STATIC_CONST QChar replacement; // FFFD
69 QT_STATIC_CONST QChar byteOrderMark; // FEFF
70 QT_STATIC_CONST QChar byteOrderSwapped; // FFFE
71 QT_STATIC_CONST QChar nbsp; // 00A0
72
73 // Unicode information
74
75 enum Category
76 {
77NoCategory,
78
79Mark_NonSpacing, // Mn
80Mark_SpacingCombining, // Mc
81Mark_Enclosing, // Me
82
83Number_DecimalDigit, // Nd
84Number_Letter, // Nl
85Number_Other, // No
86
87Separator_Space, // Zs
88Separator_Line, // Zl
89Separator_Paragraph, // Zp
90
91Other_Control, // Cc
92Other_Format, // Cf
93Other_Surrogate, // Cs
94Other_PrivateUse, // Co
95Other_NotAssigned, // Cn
96
97Letter_Uppercase, // Lu
98Letter_Lowercase, // Ll
99Letter_Titlecase, // Lt
100Letter_Modifier, // Lm
101Letter_Other, // Lo
102
103Punctuation_Connector, // Pc
104Punctuation_Dask, // Pd
105Punctuation_Open, // Ps
106Punctuation_Close, // Pe
107Punctuation_InitialQuote, // Pi
108Punctuation_FinalQuote, // Pf
109Punctuation_Other, // Po
110
111Symbol_Math, // Sm
112Symbol_Currency, // Sc
113Symbol_Modifier, // Sk
114Symbol_Other // So
115 };
116
117 enum Direction
118 {
119DirL, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON,
120DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN
121 };
122
123 enum Decomposition
124 {
125 Single, Canonical, Font, NoBreak, Initial, Medial,
126 Final, Isolated, Circle, Super, Sub, Vertical,
127 Wide, Narrow, Small, Square, Compat, Fraction
128 };
129
130 enum Joining
131 {
132OtherJoining, Dual, Right, Center
133 };
134
135 // ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO
136
137 int digitValue() const;
138 QChar lower() const;
139 QChar upper() const;
140
141 Category category() const;
142 Direction direction() const;
143 Joining joining() const;
144 bool mirrored() const;
145 QChar mirroredChar() const;
146 QString decomposition() const;
147 Decomposition decompositionTag() const;
148
149 char latin1() const { return rw ? 0 : cl; }
150 ushort unicode() const { return (rw << 8) | cl; }
151#ifndef QT_NO_CAST_ASCII
152 // like all ifdef'd code this is undocumented
153 operator char() const { return latin1(); }
154#endif
155
156 bool isNull() const { return unicode()==0; }
157 bool isPrint() const;
158 bool isPunct() const;
159 bool isSpace() const;
160 bool isMark() const;
161 bool isLetter() const;
162 bool isNumber() const;
163 bool isLetterOrNumber() const;
164 bool isDigit() const;
165
166 uchar& cell() { return cl; }
167 uchar& row() { return rw; }
168 uchar cell() const { return cl; }
169 uchar row() const { return rw; }
170
171 static bool networkOrdered() { return (int)net_ordered == 1; }
172
173 friend inline int operator==( char ch, QChar c );
174 friend inline int operator==( QChar c, char ch );
175 friend inline int operator==( QChar c1, QChar c2 );
176 friend inline int operator!=( QChar c1, QChar c2 );
177 friend inline int operator!=( char ch, QChar c );
178 friend inline int operator!=( QChar c, char ch );
179 friend inline int operator<=( QChar c, char ch );
180 friend inline int operator<=( char ch, QChar c );
181 friend inline int operator<=( QChar c1, QChar c2 );
182
183private:
184#if defined(_WS_X11_) || defined(_OS_WIN32_BYTESWAP_) || defined( _WS_QWS_ )
185 // XChar2b on X11, ushort on _OS_WIN32_BYTESWAP_
186 //### QWS must be defined on a platform by platform basis
187 uchar rw;
188 uchar cl;
189#if defined(QT_QSTRING_UCS_4)
190 ushort grp;
191#endif
192 enum { net_ordered = 1 };
193#else
194 // ushort on _OS_WIN32_
195 uchar cl;
196 uchar rw;
197#if defined(QT_QSTRING_UCS_4)
198 ushort grp;
199#endif
200 enum { net_ordered = 0 };
201#endif
202};
203
204inline QChar::QChar()
205{
206 rw = 0; cl = 0;
207#ifdef QT_QSTRING_UCS_4
208 grp = 0;
209#endif
210}
211inline QChar::QChar( char c )
212{
213 rw = 0; cl = (uchar)c;
214#ifdef QT_QSTRING_UCS_4
215 grp = 0;
216#endif
217}
218inline QChar::QChar( uchar c )
219{
220 rw = 0; cl = c;
221#ifdef QT_QSTRING_UCS_4
222 grp = 0;
223#endif
224}
225inline QChar::QChar( uchar c, uchar r )
226{
227 rw = r; cl = c;
228#ifdef QT_QSTRING_UCS_4
229 grp = 0;
230#endif
231}
232inline QChar::QChar( const QChar& c )
233{
234 rw = c.rw; cl = c.cl;
235#ifdef QT_QSTRING_UCS_4
236 grp = 0;
237#endif
238}
239inline QChar::QChar( ushort rc )
240{
241 rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
242#ifdef QT_QSTRING_UCS_4
243 grp = 0;
244#endif
245}
246inline QChar::QChar( short rc )
247{
248 rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
249#ifdef QT_QSTRING_UCS_4
250 grp = 0;
251#endif
252}
253inline QChar::QChar( uint rc )
254{
255 rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
256#ifdef QT_QSTRING_UCS_4
257 grp = 0;
258#endif
259}
260inline QChar::QChar( int rc )
261{
262 rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
263#ifdef QT_QSTRING_UCS_4
264 grp = 0;
265#endif
266}
267
268
269inline int operator==( char ch, QChar c )
270{
271 return ch == c.cl && !c.rw;
272}
273
274inline int operator==( QChar c, char ch )
275{
276 return ch == c.cl && !c.rw;
277}
278
279inline int operator==( QChar c1, QChar c2 )
280{
281 return c1.cl == c2.cl
282&& c1.rw == c2.rw;
283}
284
285inline int operator!=( QChar c1, QChar c2 )
286{
287 return c1.cl != c2.cl
288|| c1.rw != c2.rw;
289}
290
291inline int operator!=( char ch, QChar c )
292{
293 return ch != c.cl || c.rw;
294}
295
296inline int operator!=( QChar c, char ch )
297{
298 return ch != c.cl || c.rw;
299}
300
301inline int operator<=( QChar c, char ch )
302{
303 return !(ch < c.cl || c.rw);
304}
305
306inline int operator<=( char ch, QChar c )
307{
308 return ch <= c.cl || c.rw;
309}
310
311inline int operator<=( QChar c1, QChar c2 )
312{
313 return c1.rw > c2.rw
314? FALSE
315: c1.rw < c2.rw
316 ? TRUE
317 : c1.cl <= c2.cl;
318}
319
320inline int operator>=( QChar c, char ch ) { return ch <= c; }
321inline int operator>=( char ch, QChar c ) { return c <= ch; }
322inline int operator>=( QChar c1, QChar c2 ) { return c2 <= c1; }
323inline int operator<( QChar c, char ch ) { return !(ch<=c); }
324inline int operator<( char ch, QChar c ) { return !(c<=ch); }
325inline int operator<( QChar c1, QChar c2 ) { return !(c2<=c1); }
326inline int operator>( QChar c, char ch ) { return !(ch>=c); }
327inline int operator>( char ch, QChar c ) { return !(c>=ch); }
328inline int operator>( QChar c1, QChar c2 ) { return !(c2>=c1); }
329
330// internal
331struct Q_EXPORT QStringData : public QShared {
332 QStringData() :
333unicode(0), ascii(0), len(0), maxl(0), dirtyascii(0) { ref(); }
334 QStringData(QChar *u, uint l, uint m) :
335unicode(u), ascii(0), len(l), maxl(m), dirtyascii(0) { }
336
337 ~QStringData() { if ( unicode ) delete[] ((char*)unicode);
338 if ( ascii ) delete[] ascii; }
339
340 void deleteSelf();
341 QChar *unicode;
342 char *ascii;
343 uint len;
344 uint maxl:30;
345 uint dirtyascii:1;
346};
347
348
349class Q_EXPORT QString
350{
351public:
352 QString();// make null string
353 QString( QChar );// one-char string
354 QString( const QString & );// impl-shared copy
355 QString( const QByteArray& );// deep copy
356 QString( const QCString& ); // deep copy
357 QString( const QChar* unicode, uint length ); // deep copy
358#ifndef QT_NO_CAST_ASCII
359 QString( const char *str );// deep copy
360#endif
361 ~QString();
362
363 QString &operator=( const QString & );// impl-shared copy
364#ifndef QT_NO_CAST_ASCII
365 QString &operator=( const char * );// deep copy
366#endif
367 QString &operator=( const QCString& );// deep copy
368 QString &operator=( QChar c );
369 QString &operator=( char c );
370
371 //QT_STATIC_CONST QString null;
372 //boolisNull()const;
373
374 struct Null { };
375 static const Null null;
376 inline QString(const Null &): d(shared_null) { d->ref(); }
377 inline QString &operator=(const Null &) { *this = QString(); return *this; }
378 inline bool isNull() const { return d == shared_null; }
379
380 boolisEmpty()const;
381 uintlength()const;
382 voidtruncate( uint pos );
383
384#if QT_VERSION >= 300
385#error "fill() Should return *this, or QChar constructor should take count=1"
386#endif
387 voidfill( QChar c, int len = -1 );
388
389 QStringcopy()const;
390
391 QString arg(long a, int fieldwidth=0, int base=10) const;
392 QString arg(ulong a, int fieldwidth=0, int base=10) const;
393 QString arg(int a, int fieldwidth=0, int base=10) const;
394 QString arg(uint a, int fieldwidth=0, int base=10) const;
395 QString arg(short a, int fieldwidth=0, int base=10) const;
396 QString arg(ushort a, int fieldwidth=0, int base=10) const;
397 QString arg(char a, int fieldwidth=0) const;
398 QString arg(QChar a, int fieldwidth=0) const;
399 QString arg(const QString& a, int fieldwidth=0) const;
400 QString arg(double a, int fieldwidth=0, char fmt='g', int prec=-1) const;
401
402 QString &sprintf( const char* format, ... )
403#if defined(_CC_GNU_) && !defined(__INSURE__)
404__attribute__ ((format (printf, 2, 3)))
405#endif
406;
407
408 intfind( QChar c, int index=0, bool cs=TRUE ) const;
409 intfind( char c, int index=0, bool cs=TRUE ) const;
410 intfind( const QString &str, int index=0, bool cs=TRUE ) const;
411 intfind( const QRegExp &, int index=0 ) const;
412#ifndef QT_NO_CAST_ASCII
413 intfind( const char* str, int index=0 ) const;
414#endif
415 intfindRev( QChar c, int index=-1, bool cs=TRUE) const;
416 intfindRev( char c, int index=-1, bool cs=TRUE) const;
417 intfindRev( const QString &str, int index=-1, bool cs=TRUE) const;
418 intfindRev( const QRegExp &, int index=-1 ) const;
419#ifndef QT_NO_CAST_ASCII
420 intfindRev( const char* str, int index=-1 ) const;
421#endif
422 intcontains( QChar c, bool cs=TRUE ) const;
423 intcontains( char c, bool cs=TRUE ) const
424 { return contains(QChar(c), cs); }
425#ifndef QT_NO_CAST_ASCII
426 intcontains( const char* str, bool cs=TRUE ) const;
427#endif
428 intcontains( const QString &str, bool cs=TRUE ) const;
429 intcontains( const QRegExp & ) const;
430
431 QStringleft( uint len ) const;
432 QStringright( uint len ) const;
433 QStringmid( uint index, uint len=0xffffffff) const;
434
435 QStringleftJustify( uint width, QChar fill=' ', bool trunc=FALSE)const;
436 QStringrightJustify( uint width, QChar fill=' ',bool trunc=FALSE)const;
437
438 QStringlower() const;
439 QStringupper() const;
440
441 QStringstripWhiteSpace()const;
442 QStringsimplifyWhiteSpace()const;
443
444 QString &insert( uint index, const QString & );
445 QString &insert( uint index, const QChar*, uint len );
446 QString &insert( uint index, QChar );
447 QString &insert( uint index, char c ) { return insert(index,QChar(c)); }
448 QString &append( char );
449 QString &append( QChar );
450 QString &append( const QString & );
451 QString &prepend( char );
452 QString &prepend( QChar );
453 QString &prepend( const QString & );
454 QString &remove( uint index, uint len );
455 QString &replace( uint index, uint len, const QString & );
456 QString &replace( uint index, uint len, const QChar*, uint clen );
457 QString &replace( const QRegExp &, const QString & );
458
459 shorttoShort( bool *ok=0, int base=10 )const;
460 ushorttoUShort( bool *ok=0, int base=10 )const;
461 inttoInt( bool *ok=0, int base=10 )const;
462 uinttoUInt( bool *ok=0, int base=10 )const;
463 longtoLong( bool *ok=0, int base=10 )const;
464 ulongtoULong( bool *ok=0, int base=10 )const;
465 floattoFloat( bool *ok=0 )const;
466 doubletoDouble( bool *ok=0 )const;
467
468 QString &setNum( short, int base=10 );
469 QString &setNum( ushort, int base=10 );
470 QString &setNum( int, int base=10 );
471 QString &setNum( uint, int base=10 );
472 QString &setNum( long, int base=10 );
473 QString &setNum( ulong, int base=10 );
474 QString &setNum( float, char f='g', int prec=6 );
475 QString &setNum( double, char f='g', int prec=6 );
476
477 static QString number( long, int base=10 );
478 static QString number( ulong, int base=10);
479 static QString number( int, int base=10 );
480 static QString number( uint, int base=10);
481 static QString number( double, char f='g', int prec=6 );
482
483 voidsetExpand( uint index, QChar c );
484
485 QString &operator+=( const QString &str );
486 QString &operator+=( QChar c );
487 QString &operator+=( char c );
488
489 // Your compiler is smart enough to use the const one if it can.
490 QChar at( uint i ) const
491{ return i<d->len ? d->unicode[i] : QChar::null; }
492 QChar operator[]( int i ) const { return at((uint)i); }
493 QCharRef at( uint i );
494 QCharRef operator[]( int i );
495
496 QChar constref(uint i) const
497{ return at(i); }
498 QChar& ref(uint i)
499{ // Optimized for easy-inlining by simple compilers.
500 if (d->count!=1 || i>=d->len)
501subat(i);
502 d->dirtyascii=1;
503 return d->unicode[i];
504}
505
506 const QChar* unicode() const { return d->unicode; }
507 const char* ascii() const;
508 const char* latin1() const;
509 static QString fromLatin1(const char*, int len=-1);
510 const unsigned short *ucs2() const;
511 static QString fromUcs2( const unsigned short *ucs2 );
512#ifndef QT_NO_TEXTCODEC
513 QCString utf8() const;
514 static QString fromUtf8(const char*, int len=-1);
515#endif
516 QCString local8Bit() const;
517 static QString fromLocal8Bit(const char*, int len=-1);
518 bool operator!() const;
519#ifndef QT_NO_ASCII_CAST
520 operator const char *() const { return latin1(); }
521#endif
522
523 QString &setUnicode( const QChar* unicode, uint len );
524 QString &setUnicodeCodes( const ushort* unicode_as_ushorts, uint len );
525 QString &setLatin1( const char*, int len=-1 );
526
527 int compare( const QString& s ) const;
528 static int compare( const QString& s1, const QString& s2 )
529{ return s1.compare(s2); }
530
531#ifndef QT_NO_DATASTREAM
532 friend Q_EXPORT QDataStream &operator>>( QDataStream &, QString & );
533#endif
534 // new functions for BiDi
535 void compose();
536 QChar::Direction basicDirection();
537 QString visual(int index = 0, int len = -1);
538
539#ifndef QT_NO_COMPAT
540 const char* data() const { return latin1(); }
541#endif
542
543 bool startsWith( const QString& ) const;
544
545private:
546 QString( int size, bool dummy );// allocate size incl. \0
547
548 void deref();
549 void real_detach();
550 void setLength( uint pos );
551 void subat( uint );
552 bool findArg(int& pos, int& len) const;
553
554 static QChar* asciiToUnicode( const char*, uint * len, uint maxlen=(uint)-1 );
555 static QChar* asciiToUnicode( const QByteArray&, uint * len );
556 static char* unicodeToAscii( const QChar*, uint len );
557
558 QStringData *d;
559 static QStringData* shared_null;
560 static QStringData* makeSharedNull();
561
562 friend class QConstString;
563 QString(QStringData* dd, bool /*dummy*/) : d(dd) { }
564};
565
566class Q_EXPORT QCharRef {
567 friend class QString;
568 QString& s;
569 uint p;
570 QCharRef(QString* str, uint pos) : s(*str), p(pos) { }
571
572public:
573 // Most QChar operations repeated here...
574
575 // all this is not documented: We just say "like QChar" and let it be.
576#if 1
577 ushort unicode() const { return s.constref(p).unicode(); }
578 char latin1() const { return s.constref(p).latin1(); }
579
580 // An operator= for each QChar cast constructor...
581 QCharRef operator=(char c ) { s.ref(p)=c; return *this; }
582 QCharRef operator=(uchar c ) { s.ref(p)=c; return *this; }
583 QCharRef operator=(QChar c ) { s.ref(p)=c; return *this; }
584 QCharRef operator=(const QCharRef& c ) { s.ref(p)=c.unicode(); return *this; }
585 QCharRef operator=(ushort rc ) { s.ref(p)=rc; return *this; }
586 QCharRef operator=(short rc ) { s.ref(p)=rc; return *this; }
587 QCharRef operator=(uint rc ) { s.ref(p)=rc; return *this; }
588 QCharRef operator=(int rc ) { s.ref(p)=rc; return *this; }
589
590 operator QChar () const { return s.constref(p); }
591
592 // each function...
593 bool isNull() const { return unicode()==0; }
594 bool isPrint() const { return s.constref(p).isPrint(); }
595 bool isPunct() const { return s.constref(p).isPunct(); }
596 bool isSpace() const { return s.constref(p).isSpace(); }
597 bool isMark() const { return s.constref(p).isMark(); }
598 bool isLetter() const { return s.constref(p).isLetter(); }
599 bool isNumber() const { return s.constref(p).isNumber(); }
600 bool isLetterOrNumber() { return s.constref(p).isLetterOrNumber(); }
601 bool isDigit() const { return s.constref(p).isDigit(); }
602
603 int digitValue() const { return s.constref(p).digitValue(); }
604 QChar lower() { return s.constref(p).lower(); }
605 QChar upper() { return s.constref(p).upper(); }
606
607 QChar::Category category() const { return s.constref(p).category(); }
608 QChar::Direction direction() const { return s.constref(p).direction(); }
609 QChar::Joining joining() const { return s.constref(p).joining(); }
610 bool mirrored() const { return s.constref(p).mirrored(); }
611 QChar mirroredChar() const { return s.constref(p).mirroredChar(); }
612 QString decomposition() const { return s.constref(p).decomposition(); }
613 QChar::Decomposition decompositionTag() const { return s.constref(p).decompositionTag(); }
614
615 // Not the non-const ones of these.
616 uchar cell() const { return s.constref(p).cell(); }
617 uchar row() const { return s.constref(p).row(); }
618#endif
619};
620
621inline QCharRef QString::at( uint i ) { return QCharRef(this,i); }
622inline QCharRef QString::operator[]( int i ) { return at((uint)i); }
623
624
625class Q_EXPORT QConstString : private QString {
626public:
627 QConstString( QChar* unicode, uint length );
628 ~QConstString();
629 const QString& string() const { return *this; }
630};
631
632
633/*****************************************************************************
634 QString stream functions
635 *****************************************************************************/
636#ifndef QT_NO_DATASTREAM
637Q_EXPORT QDataStream &operator<<( QDataStream &, const QString & );
638Q_EXPORT QDataStream &operator>>( QDataStream &, QString & );
639#endif
640
641/*****************************************************************************
642 QString inline functions
643 *****************************************************************************/
644
645// These two move code into makeSharedNull() and deletesData()
646// to improve cache-coherence (and reduce code bloat), while
647// keeping the common cases fast.
648//
649// No safe way to pre-init shared_null on ALL compilers/linkers.
650inline QString::QString() :
651 d(shared_null ? shared_null : makeSharedNull())
652{
653 d->ref();
654}
655//
656inline QString::~QString()
657{
658 if ( d->deref() ) {
659if ( d == shared_null )
660 shared_null = 0;
661d->deleteSelf();
662 }
663}
664
665inline QString &QString::operator=( QChar c )
666{ return *this = QString(c); }
667
668inline QString &QString::operator=( char c )
669{ return *this = QString(QChar(c)); }
670
671//inline bool QString::isNull() const
672//{ return unicode() == 0; }
673
674inline bool QString::operator!() const
675{ return isNull(); }
676
677inline uint QString::length() const
678{ return d->len; }
679
680inline bool QString::isEmpty() const
681{ return length() == 0; }
682
683inline QString QString::copy() const
684{ return QString( *this ); }
685
686inline QString &QString::prepend( const QString & s )
687{ return insert(0,s); }
688
689inline QString &QString::prepend( QChar c )
690{ return insert(0,c); }
691
692inline QString &QString::prepend( char c )
693{ return insert(0,c); }
694
695inline QString &QString::append( const QString & s )
696{ return operator+=(s); }
697
698inline QString &QString::append( QChar c )
699{ return operator+=(c); }
700
701inline QString &QString::append( char c )
702{ return operator+=(c); }
703
704inline QString &QString::setNum( short n, int base )
705{ return setNum((long)n, base); }
706
707inline QString &QString::setNum( ushort n, int base )
708{ return setNum((ulong)n, base); }
709
710inline QString &QString::setNum( int n, int base )
711{ return setNum((long)n, base); }
712
713inline QString &QString::setNum( uint n, int base )
714{ return setNum((ulong)n, base); }
715
716inline QString &QString::setNum( float n, char f, int prec )
717{ return setNum((double)n,f,prec); }
718
719inline QString QString::arg(int a, int fieldwidth, int base) const
720{ return arg((long)a, fieldwidth, base); }
721
722inline QString QString::arg(uint a, int fieldwidth, int base) const
723{ return arg((ulong)a, fieldwidth, base); }
724
725inline QString QString::arg(short a, int fieldwidth, int base) const
726{ return arg((long)a, fieldwidth, base); }
727
728inline QString QString::arg(ushort a, int fieldwidth, int base) const
729{ return arg((ulong)a, fieldwidth, base); }
730
731inline int QString::find( char c, int index, bool cs ) const
732{ return find(QChar(c), index, cs); }
733
734inline int QString::findRev( char c, int index, bool cs) const
735{ return findRev( QChar(c), index, cs ); }
736
737
738#ifndef QT_NO_CAST_ASCII
739inline int QString::find( const char* str, int index ) const
740{ return find(QString::fromLatin1(str), index); }
741
742inline int QString::findRev( const char* str, int index ) const
743{ return findRev(QString::fromLatin1(str), index); }
744#endif
745
746
747/*****************************************************************************
748 QString non-member operators
749 *****************************************************************************/
750
751Q_EXPORT bool operator!=( const QString &s1, const QString &s2 );
752Q_EXPORT bool operator<( const QString &s1, const QString &s2 );
753Q_EXPORT bool operator<=( const QString &s1, const QString &s2 );
754Q_EXPORT bool operator==( const QString &s1, const QString &s2 );
755Q_EXPORT bool operator>( const QString &s1, const QString &s2 );
756Q_EXPORT bool operator>=( const QString &s1, const QString &s2 );
757#ifndef QT_NO_CAST_ASCII
758Q_EXPORT bool operator!=( const QString &s1, const char *s2 );
759Q_EXPORT bool operator<( const QString &s1, const char *s2 );
760Q_EXPORT bool operator<=( const QString &s1, const char *s2 );
761Q_EXPORT bool operator==( const QString &s1, const char *s2 );
762Q_EXPORT bool operator>( const QString &s1, const char *s2 );
763Q_EXPORT bool operator>=( const QString &s1, const char *s2 );
764Q_EXPORT bool operator!=( const char *s1, const QString &s2 );
765Q_EXPORT bool operator<( const char *s1, const QString &s2 );
766Q_EXPORT bool operator<=( const char *s1, const QString &s2 );
767Q_EXPORT bool operator==( const char *s1, const QString &s2 );
768//Q_EXPORT bool operator>( const char *s1, const QString &s2 ); // MSVC++
769Q_EXPORT bool operator>=( const char *s1, const QString &s2 );
770#endif
771
772Q_EXPORT inline QString operator+( const QString &s1, const QString &s2 )
773{
774 QString tmp( s1 );
775 tmp += s2;
776 return tmp;
777}
778
779#ifndef QT_NO_CAST_ASCII
780Q_EXPORT inline QString operator+( const QString &s1, const char *s2 )
781{
782 QString tmp( s1 );
783 tmp += QString::fromLatin1(s2);
784 return tmp;
785}
786
787Q_EXPORT inline QString operator+( const char *s1, const QString &s2 )
788{
789 QString tmp = QString::fromLatin1( s1 );
790 tmp += s2;
791 return tmp;
792}
793#endif
794
795Q_EXPORT inline QString operator+( const QString &s1, QChar c2 )
796{
797 QString tmp( s1 );
798 tmp += c2;
799 return tmp;
800}
801
802Q_EXPORT inline QString operator+( const QString &s1, char c2 )
803{
804 QString tmp( s1 );
805 tmp += c2;
806 return tmp;
807}
808
809Q_EXPORT inline QString operator+( QChar c1, const QString &s2 )
810{
811 QString tmp;
812 tmp += c1;
813 tmp += s2;
814 return tmp;
815}
816
817Q_EXPORT inline QString operator+( char c1, const QString &s2 )
818{
819 QString tmp;
820 tmp += c1;
821 tmp += s2;
822 return tmp;
823}
824
825#if defined(_OS_WIN32_)
826extern Q_EXPORT QString qt_winQString(void*);
827extern Q_EXPORT const void* qt_winTchar(const QString& str, bool addnul);
828extern Q_EXPORT void* qt_winTchar_new(const QString& str);
829extern Q_EXPORT QCString qt_winQString2MB( const QString& s, int len=-1 );
830extern Q_EXPORT QString qt_winMB2QString( const char* mb, int len=-1 );
831#endif
832
833#endif // QSTRING_H
834

Archive Download this file

Revision: 1322