⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qstring.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
int QChar::digitValue() const{#ifndef QT_NO_UNICODETABLES    register int pos = QUnicodeTables::decimal_info[row()];    if( !pos )	return -1;    return QUnicodeTables::decimal_info[(pos<<8) + cell()];#else    // ##### just latin1    if ( ucs < '0' || ucs > '9' )	return -1;    else	return ucs - '0';#endif}/*!    Returns the character category.    \sa Category*/QChar::Category QChar::category() const{     return ::category( *this );}/*!    Returns the character's direction.    \sa Direction*/QChar::Direction QChar::direction() const{     return ::direction( *this );}/*!    \warning This function is not supported (it may change to use    Unicode character classes).    Returns information about the joining properties of the character    (needed for example, for Arabic).*/QChar::Joining QChar::joining() const{    return ::joining( *this );}/*!    Returns TRUE if the character is a mirrored character (one that    should be reversed if the text direction is reversed); otherwise    returns FALSE.*/bool QChar::mirrored() const{    return ::mirrored( *this );}/*!    Returns the mirrored character if this character is a mirrored    character, otherwise returns the character itself.*/QChar QChar::mirroredChar() const{    return ::mirroredChar( *this );}#ifndef QT_NO_UNICODETABLES// ### REMOVE ME 4.0static QString shared_decomp;#endif/*!    \nonreentrant    Decomposes a character into its parts. Returns QString::null if no    decomposition exists.*/const QString &QChar::decomposition() const{#ifndef QT_NO_UNICODETABLES    register int pos = QUnicodeTables::decomposition_info[row()];    if(!pos) return QString::null;    pos = QUnicodeTables::decomposition_info[(pos<<8)+cell()];    if(!pos) return QString::null;    pos+=2;    QString s;    Q_UINT16 c;    while ( (c = QUnicodeTables::decomposition_map[pos++]) != 0 )	s += QChar( c );    // ### In 4.0, return s, and not shared_decomp.  shared_decomp    // prevents this function from being reentrant.    shared_decomp = s;    return shared_decomp;#else    return QString::null;#endif}/*!    Returns the tag defining the composition of the character. Returns    QChar::Single if no decomposition exists.*/QChar::Decomposition QChar::decompositionTag() const{#ifndef QT_NO_UNICODETABLES    register int pos = QUnicodeTables::decomposition_info[row()];    if(!pos) return QChar::Single;    pos = QUnicodeTables::decomposition_info[(pos<<8)+cell()];    if(!pos) return QChar::Single;    return (QChar::Decomposition) QUnicodeTables::decomposition_map[pos];#else    return Single; // ########### FIX eg. just latin1#endif}/*!    Returns the combining class for the character as defined in the    Unicode standard. This is mainly useful as a positioning hint for    marks attached to a base character.    The Qt text rendering engine uses this information to correctly    position non spacing marks around a base character.*/unsigned char QChar::combiningClass() const{    return ::combiningClass( *this );}/*!    Returns the lowercase equivalent if the character is uppercase;    otherwise returns the character itself.*/QChar QChar::lower() const{     return ::lower( *this );}/*!    Returns the uppercase equivalent if the character is lowercase;    otherwise returns the character itself.*/QChar QChar::upper() const{     return ::upper( *this );}/*!    \fn QChar::operator char() const    Returns the Latin-1 character equivalent to the QChar, or 0. This    is mainly useful for non-internationalized software.    \sa unicode()*//*!    \fn ushort QChar::unicode() const    Returns the numeric Unicode value equal to the QChar. Normally,    you should use QChar objects as they are equivalent, but for some    low-level tasks (e.g. indexing into an array of Unicode    information), this function is useful.*//*!    \fn ushort & QChar::unicode()    \overload    Returns a reference to the numeric Unicode value equal to the    QChar.*//*****************************************************************************  Documentation of QChar related functions *****************************************************************************//*!    \fn bool operator==( QChar c1, QChar c2 )    \relates QChar    Returns TRUE if \a c1 and \a c2 are the same Unicode character;    otherwise returns FALSE.*//*!    \fn bool operator==( char ch, QChar c )    \overload    \relates QChar    Returns TRUE if \a c is the ASCII/Latin-1 character \a ch;    otherwise returns FALSE.*//*!    \fn bool operator==( QChar c, char ch )    \overload    \relates QChar    Returns TRUE if \a c is the ASCII/Latin-1 character \a ch;    otherwise returns FALSE.*//*!    \fn int operator!=( QChar c1, QChar c2 )    \relates QChar    Returns TRUE if \a c1 and \a c2 are not the same Unicode    character; otherwise returns FALSE.*//*!    \fn int operator!=( char ch, QChar c )    \overload    \relates QChar    Returns TRUE if \a c is not the ASCII/Latin-1 character \a ch;    otherwise returns FALSE.*//*!    \fn int operator!=( QChar c, char ch )    \overload    \relates QChar    Returns TRUE if \a c is not the ASCII/Latin-1 character \a ch;    otherwise returns FALSE.*//*!    \fn int operator<=( QChar c1, QChar c2 )    \relates QChar    Returns TRUE if the numeric Unicode value of \a c1 is less than    that of \a c2, or they are the same Unicode character; otherwise    returns FALSE.*//*!    \fn int operator<=( QChar c, char ch )    \overload    \relates QChar    Returns TRUE if the numeric Unicode value of \a c is less than or    equal to that of the ASCII/Latin-1 character \a ch; otherwise    returns FALSE.*//*!    \fn int operator<=( char ch, QChar c )    \overload    \relates QChar    Returns TRUE if the numeric Unicode value of the ASCII/Latin-1    character \a ch is less than or equal to that of \a c; otherwise    returns FALSE.*//*!    \fn int operator>=( QChar c1, QChar c2 )    \relates QChar    Returns TRUE if the numeric Unicode value of \a c1 is greater than    that of \a c2, or they are the same Unicode character; otherwise    returns FALSE.*//*!    \fn int operator>=( QChar c, char ch )    \overload    \relates QChar    Returns TRUE if the numeric Unicode value of \a c is greater than    or equal to that of the ASCII/Latin-1 character \a ch; otherwise    returns FALSE.*//*!    \fn int operator>=( char ch, QChar c )    \overload    \relates QChar    Returns TRUE if the numeric Unicode value of the ASCII/Latin-1    character \a ch is greater than or equal to that of \a c;    otherwise returns FALSE.*//*!    \fn int operator<( QChar c1, QChar c2 )    \relates QChar    Returns TRUE if the numeric Unicode value of \a c1 is less than    that of \a c2; otherwise returns FALSE.*//*!    \fn int operator<( QChar c, char ch )    \overload    \relates QChar    Returns TRUE if the numeric Unicode value of \a c is less than that    of the ASCII/Latin-1 character \a ch; otherwise returns FALSE.*//*!    \fn int operator<( char ch, QChar c )    \overload    \relates QChar    Returns TRUE if the numeric Unicode value of the ASCII/Latin-1    character \a ch is less than that of \a c; otherwise returns    FALSE.*//*!    \fn int operator>( QChar c1, QChar c2 )    \relates QChar    Returns TRUE if the numeric Unicode value of \a c1 is greater than    that of \a c2; otherwise returns FALSE.*//*!    \fn int operator>( QChar c, char ch )    \overload    \relates QChar    Returns TRUE if the numeric Unicode value of \a c is greater than    that of the ASCII/Latin-1 character \a ch; otherwise returns FALSE.*//*!    \fn int operator>( char ch, QChar c )    \overload    \relates QChar    Returns TRUE if the numeric Unicode value of the ASCII/Latin-1    character \a ch is greater than that of \a c; otherwise returns    FALSE.*/#ifndef QT_NO_UNICODETABLES// small class used internally in QString::Compose()class QLigature{public:    QLigature( QChar c );    Q_UINT16 first() { cur = ligatures; return cur ? *cur : 0; }    Q_UINT16 next() { return cur && *cur ? *(cur++) : 0; }    Q_UINT16 current() { return cur ? *cur : 0; }    int match(QString & str, unsigned int index);    QChar head();    QChar::Decomposition tag();private:    Q_UINT16 *ligatures;    Q_UINT16 *cur;};QLigature::QLigature( QChar c ){    register int pos = QUnicodeTables::ligature_info[c.row()];    if( !pos )	ligatures = 0;    else    {	pos = QUnicodeTables::ligature_info[(pos<<8)+c.cell()];	ligatures = (Q_UINT16 *)&(QUnicodeTables::ligature_map[pos]);    }    cur = ligatures;}QChar QLigature::head(){    if(current())	return QChar(QUnicodeTables::decomposition_map[current()+1]);    return QChar::null;}QChar::Decomposition QLigature::tag(){    if(current())	return (QChar::Decomposition) QUnicodeTables::decomposition_map[current()];    return QChar::Canonical;}int QLigature::match(QString & str, unsigned int index){    unsigned int i=index;    if(!current()) return 0;    Q_UINT16 lig = current() + 2;    Q_UINT16 ch;    while ((i < str.length()) && (ch = QUnicodeTables::decomposition_map[lig])) {	if (str[(int)i] != QChar(ch))	    return 0;	i++;	lig++;    }    if (!QUnicodeTables::decomposition_map[lig])    {	return i-index;    }    return 0;}// this function is just used in QString::compose()static inline bool format(QChar::Decomposition tag, QString & str,			  int index, int len){    unsigned int l = index + len;    unsigned int r = index;    bool left = FALSE, right = FALSE;    left = ((l < str.length()) &&	    ((str[(int)l].joining() == QChar::Dual) ||	     (str[(int)l].joining() == QChar::Right)));    if (r > 0) {	r--;	//printf("joining(right) = %d\n", str[(int)r].joining());	right = (str[(int)r].joining() == QChar::Dual);    }    switch (tag) {    case QChar::Medial:	return (left & right);    case QChar::Initial:	return (left && !right);    case QChar::Final:	return (right);// && !left);    case QChar::Isolated:    default:	return (!right && !left);    }} // format()#endif/*  QString::compose() and visual() were developed by Gordon Tisher  <tisher@uniserve.ca>, with input from Lars Knoll <knoll@mpi-hd.mpg.de>,  who developed the unicode data tables.*//*!    \warning This function is not supported in Qt 3.x. It is provided    for experimental and illustrative purposes only. It is mainly of    interest to those experimenting with Arabic and other    composition-rich texts.    Applies possible ligatures to a QString. Useful when    composition-rich text requires rendering with glyph-poor fonts,    but it also makes compositions such as QChar(0x0041) ('A') and    QChar(0x0308) (Unicode accent diaresis), giving QChar(0x00c4)    (German A Umlaut).*/void QString::compose(){#ifndef QT_NO_UNICODETABLES    unsigned int index=0, len;    unsigned int cindex = 0;    QChar code, head;    QMemArray<QChar> dia;    QString composed = *this;    while (index < length()) {	code = at(index);	//printf("\n\nligature for 0x%x:\n", code.unicode());	QLigature ligature(code);	ligature.first();	while ( ligature.current() ) {	    if ((len = ligature.match(*this, index)) != 0) {		head = ligature.head();		unsigned short code = head.unicode();		// we exclude Arabic presentation forms A and a few		// other ligatures, which are undefined in most fonts		if(!(code > 0xfb50 && code < 0xfe80) &&		   !(code > 0xfb00 && code < 0xfb2a)) {				// joining info is only needed for Arabic		    if (format(ligature.tag(), *this, index, len)) {			//printf("using ligature 0x%x, len=%d\n",code,len);			// replace letter			composed.replace(cindex, len, QChar(head));			index += len-1;			// we continue searching in case we have a final			// form because medial ones are preferred.			if ( len != 1 || ligature.tag() !=QChar::Final )			    break;		    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -