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

📄 qcstring.cpp

📁 doxygen(一个自动从源代码生成文档的工具)的源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
*/short QCString::toShort( bool *ok ) const{    long v = toLong( ok );    if ( ok && *ok && (v < -32768 || v > 32767) )	*ok = FALSE;    return (short)v;}/*!  Returns the string converted to an <code>unsigned short</code> value.  If \e ok is non-null, \e *ok is set to TRUE if there are no  conceivable errors, and FALSE if the string is not a number at all, or if  it has trailing garbage.*/ushort QCString::toUShort( bool *ok ) const{    ulong v = toULong( ok );    if ( ok && *ok && (v > 65535) )	*ok = FALSE;    return (ushort)v;}/*!  Returns the string converted to a <code>int</code> value.  If \e ok is non-null, \e *ok is set to TRUE if there are no  conceivable errors, and FALSE if the string is not a number at all,  or if it has trailing garbage.*/int QCString::toInt( bool *ok ) const{    return (int)toLong( ok );}/*!  Returns the string converted to an <code>unsigned int</code> value.  If \e ok is non-null, \e *ok is set to TRUE if there are no  conceivable errors, and FALSE if the string is not a number at all,  or if it has trailing garbage.*/uint QCString::toUInt( bool *ok ) const{    return (uint)toULong( ok );}/*!  Returns the string converted to a <code>double</code> value.  If \e ok is non-null, \e *ok is set to TRUE if there are no conceivable  errors, and FALSE if the string is not a number at all, or if it has  trailing garbage.*/double QCString::toDouble( bool *ok ) const{    char *end;    double val = strtod( data() ? data() : "", &end );    if ( ok )	*ok = ( data() && *data() && ( end == 0 || *end == '\0' ) );    return val;}/*!  Returns the string converted to a <code>float</code> value.  If \e ok is non-null, \e *ok is set to TRUE if there are no  conceivable errors, and FALSE if the string is not a number at all,  or if it has trailing garbage.*/float QCString::toFloat( bool *ok ) const{    return (float)toDouble( ok );}/*!  Makes a deep copy of \e str.  Returns a reference to the string.*/QCString &QCString::setStr( const char *str ){    detach();    if ( str )					// valid string	store( str, qstrlen(str)+1 );    else					// empty	resize( 0 );    return *this;}/*!  Sets the string to the printed value of \e n and returns a  reference to the string.*/QCString &QCString::setNum( long n ){    detach();    char buf[20];    register char *p = &buf[19];    bool neg;    if ( n < 0 ) {	neg = TRUE;	n = -n;    } else {	neg = FALSE;    }    *p = '\0';    do {	*--p = ((int)(n%10)) + '0';	n /= 10;    } while ( n );    if ( neg )	*--p = '-';    store( p, qstrlen(p)+1 );    return *this;}/*!  Sets the string to the printed unsigned value of \e n and  returns a reference to the string.*/QCString &QCString::setNum( ulong n ){    detach();    char buf[20];    register char *p = &buf[19];    *p = '\0';    do {	*--p = ((int)(n%10)) + '0';	n /= 10;    } while ( n );    store( p, qstrlen(p)+1 );    return *this;}/*!  \fn QCString &QCString::setNum( int n )  Sets the string to the printed value of \e n and returns a reference  to the string.*//*!  \fn QCString &QCString::setNum( uint n )  Sets the string to the printed unsigned value of \e n and returns a  reference to the string.*//*!  \fn QCString &QCString::setNum( short n )  Sets the string to the printed value of \e n and returns a reference  to the string.*//*!  \fn QCString &QCString::setNum( ushort n )  Sets the string to the printed unsigned value of \e n and returns a  reference to the string.*//*!  Sets the string to the printed value of \e n.  \arg \e f is the format specifier: 'f', 'F', 'e', 'E', 'g', 'G' (same  as sprintf()).  \arg \e prec is the precision.  Returns a reference to the string.*/QCString &QCString::setNum( double n, char f, int prec ){#if defined(CHECK_RANGE)    if ( !(f=='f' || f=='F' || f=='e' || f=='E' || f=='g' || f=='G') )	qWarning( "QCString::setNum: Invalid format char '%c'", f );#endif    char format[20];    register char *fs = format;			// generate format string    *fs++ = '%';				//   "%.<prec>l<f>"    if ( prec > 99 )	prec = 99;    *fs++ = '.';    if ( prec >= 10 ) {	*fs++ = prec / 10 + '0';	*fs++ = prec % 10 + '0';    } else {	*fs++ = prec + '0';    }    *fs++ = 'l';    *fs++ = f;    *fs = '\0';    return sprintf( format, n );}/*!  \fn QCString &QCString::setNum( float n, char f, int prec )  Sets the string to the printed value of \e n.  \arg \e f is the format specifier: 'f', 'F', 'e', 'E', 'g', 'G' (same  as sprintf()).  \arg \e prec is the precision.  Returns a reference to the string.*//*!  Sets the character at position \e index to \e c and expands the  string if necessary, filling with spaces.  Returns FALSE if this \e index was out of range and the string could  not be expanded, otherwise TRUE.*/bool QCString::setExpand( uint index, char c ){    detach();    uint oldlen = length();    if ( index >= oldlen ) {	if ( !QByteArray::resize( index+2 ) )	// no memory	    return FALSE;	if ( index > oldlen )	    memset( data() + oldlen, ' ', index - oldlen );	*(data() + index+1) = '\0';		// terminate padded string    }    *(data() + index) = c;    return TRUE;}/*!  \fn QCString::operator const char *() const  Returns the string data.*//*!  \fn QCString& QCString::append( const char *str )  Appends \e str to the string and returns a reference to the string.  Equivalent to operator+=(). *//*!  Appends \e str to the string and returns a reference to the string.*/QCString& QCString::operator+=( const char *str ){    if ( !str )	return *this;				// nothing to append    detach();    uint len1 = length();    uint len2 = qstrlen(str);    if ( !QByteArray::resize( len1 + len2 + 1 ) )	return *this;				// no memory    memcpy( data() + len1, str, len2 + 1 );    return *this;}/*!  Appends \e c to the string and returns a reference to the string.*/QCString &QCString::operator+=( char c ){    detach();    uint len = length();    if ( !QByteArray::resize( len + 2 ) )	return *this;				// no memory    *(data() + len) = c;    *(data() + len+1) = '\0';    return *this;}/*****************************************************************************  QCString stream functions *****************************************************************************/#ifndef QT_NO_DATASTREAM/*!  \relates QCString  Writes a string to the stream.  \sa \link datastreamformat.html Format of the QDataStream operators \endlink*/QDataStream &operator<<( QDataStream &s, const QCString &str ){    return s.writeBytes( str.data(), str.size() );}/*!  \relates QCString  Reads a string from the stream.  \sa \link datastreamformat.html Format of the QDataStream operators \endlink*/QDataStream &operator>>( QDataStream &s, QCString &str ){    str.detach();    Q_UINT32 len;    s >> len;					// read size of string    if ( len == 0 || s.eof() ) {		// end of file reached	str.resize( 0 );	return s;    }    if ( !str.QByteArray::resize( (uint)len )) {// resize string#if defined(CHECK_NULL)	qWarning( "QDataStream: Not enough memory to read QCString" );#endif	len = 0;    }    if ( len > 0 )				// not null array	s.readRawBytes( str.data(), (uint)len );    return s;}#endif //QT_NO_DATASTREAM/*****************************************************************************  Documentation for related functions *****************************************************************************//*!  \fn bool operator==( const QCString &s1, const QCString &s2 )  \relates QCString  Returns TRUE if the two strings are equal, or FALSE if they are different.  Equivalent to <code>qstrcmp(s1,s2) == 0</code>.*//*!  \fn bool operator==( const QCString &s1, const char *s2 )  \relates QCString  Returns TRUE if the two strings are equal, or FALSE if they are different.  Equivalent to <code>qstrcmp(s1,s2) == 0</code>.*//*!  \fn bool operator==( const char *s1, const QCString &s2 )  \relates QCString  Returns TRUE if the two strings are equal, or FALSE if they are different.  Equivalent to <code>qstrcmp(s1,s2) == 0</code>.*//*!  \fn bool operator!=( const QCString &s1, const QCString &s2 )  \relates QCString  Returns TRUE if the two strings are different, or FALSE if they are equal.  Equivalent to <code>qstrcmp(s1,s2) != 0</code>.*//*!  \fn bool operator!=( const QCString &s1, const char *s2 )  \relates QCString  Returns TRUE if the two strings are different, or FALSE if they are equal.  Equivalent to <code>qstrcmp(s1,s2) != 0</code>.*//*!  \fn bool operator!=( const char *s1, const QCString &s2 )  \relates QCString  Returns TRUE if the two strings are different, or FALSE if they are equal.  Equivalent to <code>qstrcmp(s1,s2) != 0</code>.*//*!  \fn bool operator<( const QCString &s1, const char *s2 )  \relates QCString  Returns TRUE if \e s1 is alphabetically less than \e s2, otherwise FALSE.  Equivalent to <code>qstrcmp(s1,s2) \< 0</code>.*//*!  \fn bool operator<( const char *s1, const QCString &s2 )  \relates QCString  Returns TRUE if \e s1 is alphabetically less than \e s2, otherwise FALSE.  Equivalent to <code>qstrcmp(s1,s2) \< 0</code>.*//*!  \fn bool operator<=( const QCString &s1, const char *s2 )  \relates QCString  Returns TRUE if \e s1 is alphabetically less than or equal to \e s2,  otherwise FALSE.  Equivalent to <code>qstrcmp(s1,s2) \<= 0</code>.*//*!  \fn bool operator<=( const char *s1, const QCString &s2 )  \relates QCString  Returns TRUE if \e s1 is alphabetically less than or equal to \e s2,  otherwise FALSE.  Equivalent to <code>qstrcmp(s1,s2) \<= 0</code>.*//*!  \fn bool operator>( const QCString &s1, const char *s2 )  \relates QCString  Returns TRUE if \e s1 is alphabetically greater than \e s2, otherwise FALSE.  Equivalent to <code>qstrcmp(s1,s2) \> 0</code>.*//*!  \fn bool operator>( const char *s1, const QCString &s2 )  \relates QCString  Returns TRUE if \e s1 is alphabetically greater than \e s2, otherwise FALSE.  Equivalent to <code>qstrcmp(s1,s2) \> 0</code>.*//*!  \fn bool operator>=( const QCString &s1, const char *s2 )  \relates QCString  Returns TRUE if \e s1 is alphabetically greater than or equal to \e s2,  otherwise FALSE.  Equivalent to <code>qstrcmp(s1,s2) \>= 0</code>.*//*!  \fn bool operator>=( const char *s1, const QCString &s2 )  \relates QCString  Returns TRUE if \e s1 is alphabetically greater than or equal to \e s2,  otherwise FALSE.  Equivalent to <code>qstrcmp(s1,s2) \>= 0</code>.*//*!  \fn QCString operator+( const QCString &s1, const QCString &s2 )  \relates QCString  Returns the concatenated string of s1 and s2.*//*!  \fn QCString operator+( const QCString &s1, const char *s2 )  \relates QCString  Returns the concatenated string of s1 and s2.*//*!  \fn QCString operator+( const char *s1, const QCString &s2 )  \relates QCString  Returns the concatenated string of s1 and s2.*//*!  \fn QCString operator+( const QCString &s, char c )  \relates QCString  Returns the concatenated string of s and c.*//*!  \fn QCString operator+( char c, const QCString &s )  \relates QCString  Returns the concatenated string of c and s.*/

⌨️ 快捷键说明

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