📄 qstring.h
字号:
/************************************************************************ Copyright (C) 2000-2005 Trolltech AS. All rights reserved.**** This file is part of the Qtopia Environment.** ** This program is free software; you can redistribute it and/or modify it** under the terms of the GNU General Public License as published by the** Free Software Foundation; either version 2 of the License, or (at your** option) any later version.** ** A copy of the GNU GPL license version 2 is included in this package as ** LICENSE.GPL.**** This program is distributed in the hope that it will be useful, but** WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ** See the GNU General Public License for more details.**** In addition, as a special exception Trolltech gives permission to link** the code of this program with Qtopia applications copyrighted, developed** and distributed by Trolltech under the terms of the Qtopia Personal Use** License Agreement. You must comply with the GNU General Public License** in all respects for all of the code used other than the applications** licensed under the Qtopia Personal Use License Agreement. If you modify** this file, you may extend this exception to your version of the file,** but you are not obligated to do so. If you do not wish to do so, delete** this exception statement from your version.** ** See http://www.trolltech.com/gpl/ for GPL licensing information.**** Contact info@trolltech.com if any conditions of this licensing are** not clear to you.************************************************************************/#ifndef QSTRING_H#define QSTRING_H#ifndef QT_H#include "qcstring.h"#endif // QT_H#ifndef QT_NO_CAST_ASCII#include <limits.h>#endif#ifndef QT_NO_STL#if defined ( Q_CC_MSVC_NET ) && _MSV_VER < 1310 // Avoids nasty warning for xlocale, line 450# pragma warning ( push )# pragma warning ( disable : 4189 )# include <string># pragma warning ( pop )#else# include <string>#endif#if defined(Q_WRONG_SB_CTYPE_MACROS) && defined(_SB_CTYPE_MACROS)#undef _SB_CTYPE_MACROS#endif#endif/***************************************************************************** QString class *****************************************************************************/class QRegExp;class QString;class QCharRef;template <class T> class QDeepCopy;class Q_EXPORT QChar {public: QChar(); QChar( char c ); QChar( uchar c ); QChar( uchar c, uchar r ); QChar( const QChar& c ); // ### remove in 4.0 to allow compiler optimization QChar( ushort rc ); QChar( short rc ); QChar( uint rc ); QChar( int rc ); QT_STATIC_CONST QChar null; // 0000 QT_STATIC_CONST QChar replacement; // FFFD QT_STATIC_CONST QChar byteOrderMark; // FEFF QT_STATIC_CONST QChar byteOrderSwapped; // FFFE QT_STATIC_CONST QChar nbsp; // 00A0 // Unicode information enum Category { NoCategory, Mark_NonSpacing, // Mn Mark_SpacingCombining, // Mc Mark_Enclosing, // Me Number_DecimalDigit, // Nd Number_Letter, // Nl Number_Other, // No Separator_Space, // Zs Separator_Line, // Zl Separator_Paragraph, // Zp Other_Control, // Cc Other_Format, // Cf Other_Surrogate, // Cs Other_PrivateUse, // Co Other_NotAssigned, // Cn Letter_Uppercase, // Lu Letter_Lowercase, // Ll Letter_Titlecase, // Lt Letter_Modifier, // Lm Letter_Other, // Lo Punctuation_Connector, // Pc Punctuation_Dash, // Pd Punctuation_Dask = Punctuation_Dash, // oops Punctuation_Open, // Ps Punctuation_Close, // Pe Punctuation_InitialQuote, // Pi Punctuation_FinalQuote, // Pf Punctuation_Other, // Po Symbol_Math, // Sm Symbol_Currency, // Sc Symbol_Modifier, // Sk Symbol_Other // So }; enum Direction { DirL, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON, DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN }; enum Decomposition { Single, Canonical, Font, NoBreak, Initial, Medial, Final, Isolated, Circle, Super, Sub, Vertical, Wide, Narrow, Small, Square, Compat, Fraction }; enum Joining { OtherJoining, Dual, Right, Center }; enum CombiningClass { Combining_BelowLeftAttached = 200, Combining_BelowAttached = 202, Combining_BelowRightAttached = 204, Combining_LeftAttached = 208, Combining_RightAttached = 210, Combining_AboveLeftAttached = 212, Combining_AboveAttached = 214, Combining_AboveRightAttached = 216, Combining_BelowLeft = 218, Combining_Below = 220, Combining_BelowRight = 222, Combining_Left = 224, Combining_Right = 226, Combining_AboveLeft = 228, Combining_Above = 230, Combining_AboveRight = 232, Combining_DoubleBelow = 233, Combining_DoubleAbove = 234, Combining_IotaSubscript = 240 }; // ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO int digitValue() const; QChar lower() const; QChar upper() const; Category category() const; Direction direction() const; Joining joining() const; bool mirrored() const; QChar mirroredChar() const; const QString &decomposition() const; // ### return just QString in 4.0 Decomposition decompositionTag() const; unsigned char combiningClass() const; char latin1() const { return ucs > 0xff ? 0 : (char) ucs; } ushort unicode() const { return ucs; } ushort &unicode() { return ucs; }#ifndef QT_NO_CAST_ASCII // like all ifdef'd code this is undocumented operator char() const { return latin1(); }#endif bool isNull() const { return unicode()==0; } bool isPrint() const; bool isPunct() const; bool isSpace() const; bool isMark() const; bool isLetter() const; bool isNumber() const; bool isLetterOrNumber() const; bool isDigit() const; bool isSymbol() const; uchar cell() const { return ((uchar) ucs & 0xff); } uchar row() const { return ((uchar) (ucs>>8)&0xff); } void setCell( uchar cell ) { ucs = (ucs & 0xff00) + cell; } void setRow( uchar row ) { ucs = (((ushort) row)<<8) + (ucs&0xff); } static bool networkOrdered() { int wordSize; bool bigEndian = FALSE; qSysInfo( &wordSize, &bigEndian ); return bigEndian; } friend inline bool operator==( char ch, QChar c ); friend inline bool operator==( QChar c, char ch ); friend inline bool operator==( QChar c1, QChar c2 ); friend inline bool operator!=( QChar c1, QChar c2 ); friend inline bool operator!=( char ch, QChar c ); friend inline bool operator!=( QChar c, char ch ); friend inline bool operator<=( QChar c, char ch ); friend inline bool operator<=( char ch, QChar c ); friend inline bool operator<=( QChar c1, QChar c2 );private: ushort ucs;#if defined(QT_QSTRING_UCS_4) ushort grp;#endif} Q_PACKED;inline QChar::QChar() : ucs( 0 )#ifdef QT_QSTRING_UCS_4 , grp( 0 )#endif{}inline QChar::QChar( char c ) : ucs( (uchar)c )#ifdef QT_QSTRING_UCS_4 , grp( 0 )#endif{}inline QChar::QChar( uchar c ) : ucs( c )#ifdef QT_QSTRING_UCS_4 , grp( 0 )#endif{}inline QChar::QChar( uchar c, uchar r ) : ucs( (r << 8) | c )#ifdef QT_QSTRING_UCS_4 , grp( 0 )#endif{}inline QChar::QChar( const QChar& c ) : ucs( c.ucs )#ifdef QT_QSTRING_UCS_4 , grp( c.grp )#endif{}inline QChar::QChar( ushort rc ) : ucs( rc )#ifdef QT_QSTRING_UCS_4 , grp( 0 )#endif{}inline QChar::QChar( short rc ) : ucs( (ushort) rc )#ifdef QT_QSTRING_UCS_4 , grp( 0 )#endif{}inline QChar::QChar( uint rc ) : ucs( (ushort ) (rc & 0xffff) )#ifdef QT_QSTRING_UCS_4 , grp( (ushort) ((rc >> 16) & 0xffff) )#endif{}inline QChar::QChar( int rc ) : ucs( (ushort) (rc & 0xffff) )#ifdef QT_QSTRING_UCS_4 , grp( (ushort) ((rc >> 16) & 0xffff) )#endif{}inline bool operator==( char ch, QChar c ){ return ((uchar) ch) == c.ucs;}inline bool operator==( QChar c, char ch ){ return ((uchar) ch) == c.ucs;}inline bool operator==( QChar c1, QChar c2 ){ return c1.ucs == c2.ucs;}inline bool operator!=( QChar c1, QChar c2 ){ return c1.ucs != c2.ucs;}inline bool operator!=( char ch, QChar c ){ return ((uchar)ch) != c.ucs;}inline bool operator!=( QChar c, char ch ){ return ((uchar) ch) != c.ucs;}inline bool operator<=( QChar c, char ch ){ return c.ucs <= ((uchar) ch);}inline bool operator<=( char ch, QChar c ){ return ((uchar) ch) <= c.ucs;}inline bool operator<=( QChar c1, QChar c2 ){ return c1.ucs <= c2.ucs;}inline bool operator>=( QChar c, char ch ) { return ch <= c; }inline bool operator>=( char ch, QChar c ) { return c <= ch; }inline bool operator>=( QChar c1, QChar c2 ) { return c2 <= c1; }inline bool operator<( QChar c, char ch ) { return !(ch<=c); }inline bool operator<( char ch, QChar c ) { return !(c<=ch); }inline bool operator<( QChar c1, QChar c2 ) { return !(c2<=c1); }inline bool operator>( QChar c, char ch ) { return !(ch>=c); }inline bool operator>( char ch, QChar c ) { return !(c>=ch); }inline bool operator>( QChar c1, QChar c2 ) { return !(c2>=c1); }// internalstruct Q_EXPORT QStringData : public QShared { QStringData() : QShared(), unicode(0), ascii(0), len(0), issimpletext(TRUE), maxl(0), islatin1(FALSE) { ref(); } QStringData(QChar *u, uint l, uint m) : QShared(), unicode(u), ascii(0), len(l), issimpletext(FALSE), maxl(m), islatin1(FALSE) { } ~QStringData() { if ( unicode ) delete[] ((char*)unicode); if ( ascii ) delete[] ascii; } void deleteSelf(); QChar *unicode; char *ascii; void setDirty() { if ( ascii ) { delete [] ascii;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -