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

📄 qglobal.cpp

📁 doxygen(一个自动从源代码生成文档的工具)的源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** $Id: qt/src/tools/qglobal.cpp   2.2.3   edited 2000-12-07 $**** Global functions**** Created : 920604**** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.**** This file is part of the tools module of the Qt GUI Toolkit.**** This file may be distributed under the terms of the Q Public License** as defined by Trolltech AS of Norway and appearing in the file** LICENSE.QPL included in the packaging of this file.**** This file may be distributed and/or modified under the terms of the** GNU General Public License version 2 as published by the Free Software** Foundation and appearing in the file LICENSE.GPL included in the** packaging of this file.**** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition** licenses may use this file in accordance with the Qt Commercial License** Agreement provided with the Software.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.**** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for**   information about Qt Commercial License Agreements.** See http://www.trolltech.com/qpl/ for QPL licensing information.** 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.************************************************************************/#include "qglobal.h"#include "qasciidict.h"#include "qstring.h"#include <stdio.h>#include <stdarg.h>#include <stdlib.h>// NOT REVISED/*!  \relates QApplication  Returns the Qt version number for the library, typically "1.30"  or "2.1.0".*/const char *qVersion(){    return QT_VERSION_STR;}/*****************************************************************************  System detection routines *****************************************************************************/static bool si_alreadyDone = FALSE;static int  si_wordSize;static bool si_bigEndian;/*!  \relates QApplication  Obtains information about the system.  The system's word size in bits (typically 32) is returned in \e *wordSize.  The \e *bigEndian is set to TRUE if this is a big-endian machine,  or to FALSE if this is a little-endian machine.  This function calls qFatal() with a message if the computer is truly weird  (i.e. different endianness for 16 bit and 32 bit integers).*/bool qSysInfo( int *wordSize, bool *bigEndian ){#if defined(CHECK_NULL)    ASSERT( wordSize != 0 );    ASSERT( bigEndian != 0 );#endif    if ( si_alreadyDone ) {			// run it only once	*wordSize  = si_wordSize;	*bigEndian = si_bigEndian;	return TRUE;    }    si_alreadyDone = TRUE;    si_wordSize = 0;    uint n = (uint)(~0);    while ( n ) {				// detect word size	si_wordSize++;	n /= 2;    }    *wordSize = si_wordSize;    if ( *wordSize != 64 &&	 *wordSize != 32 &&	 *wordSize != 16 ) {			// word size: 16, 32 or 64#if defined(CHECK_RANGE)	qFatal( "qSysInfo: Unsupported system word size %d", *wordSize );#endif	return FALSE;    }    if ( sizeof(Q_INT8) != 1 || sizeof(Q_INT16) != 2 || sizeof(Q_INT32) != 4 ||	 sizeof(float) != 4 || sizeof(double) != 8 ) {#if defined(CHECK_RANGE)	qFatal( "qSysInfo: Unsupported system data type size" );#endif	return FALSE;    }    bool  be16, be32;				// determine byte ordering    short ns = 0x1234;    int	  nl = 0x12345678;    unsigned char *p = (unsigned char *)(&ns);	// 16-bit integer    be16 = *p == 0x12;    p = (unsigned char *)(&nl);			// 32-bit integer    if ( p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78 )	be32 = TRUE;    else    if ( p[0] == 0x78 && p[1] == 0x56 && p[2] == 0x34 && p[3] == 0x12 )	be32 = FALSE;    else	be32 = !be16;    if ( be16 != be32 ) {			// strange machine!#if defined(CHECK_RANGE)	qFatal( "qSysInfo: Inconsistent system byte order" );#endif	return FALSE;    }    *bigEndian = si_bigEndian = be32;    return TRUE;}/*****************************************************************************  Debug output routines *****************************************************************************//*!  \fn void qDebug( const char *msg, ... )  \relates QApplication  Prints a debug message, or calls the message handler (if it has been  installed).  This function takes a format string and a list of arguments, similar to  the C printf() function.  Example:  \code    qDebug( "my window handle = %x", myWidget->id() );  \endcode  Under X11, the text is printed to stderr.  Under Windows, the text is  sent to the debugger.  \warning The internal buffer is limited to 8196 bytes (including the  0-terminator).  \sa qWarning(), qFatal(), qInstallMsgHandler(),  \link debug.html Debugging\endlink*//*!  \fn void qWarning( const char *msg, ... )  \relates QApplication  Prints a warning message, or calls the message handler (if it has been  installed).  This function takes a format string and a list of arguments, similar to  the C printf() function.  Example:  \code    void f( int c )    {	if ( c > 200 )	    qWarning( "f: bad argument, c == %d", c );    }  \endcode  Under X11, the text is printed to stderr.  Under Windows, the text is  sent to the debugger.  \warning The internal buffer is limited to 8196 bytes (including the  0-terminator).  \sa qDebug(), qFatal(), qInstallMsgHandler(),  \link debug.html Debugging\endlink*//*!  \fn void qFatal( const char *msg, ... )  \relates QApplication  Prints a fatal error message and exits, or calls the message handler (if it  has been installed).  This function takes a format string and a list of arguments, similar to  the C printf() function.  Example:  \code    int divide( int a, int b )    {	if ( b == 0 )				// program error	    qFatal( "divide: cannot divide by zero" );	return a/b;    }  \endcode  Under X11, the text is printed to stderr.  Under Windows, the text is  sent to the debugger.  \warning The internal buffer is limited to 8196 bytes (including the  0-terminator).  \sa qDebug(), qWarning(), qInstallMsgHandler(),  \link debug.html Debugging\endlink*/static msg_handler handler = 0;			// pointer to debug handler#ifdef _OS_MAC_static FILE * mac_debug=0;void qDebug( const char *msg, ... ){    mac_debug=fopen( "debug.txt", "a+" );    if(mac_debug) {	char buf[8196];	va_list ap;	va_start( ap, msg );			// use variable arg list	if ( handler ) {	    vsprintf( buf, msg, ap );	    va_end( ap );	    (*handler)( QtDebugMsg, buf );	} else {	    vfprintf( mac_debug, msg, ap );	    va_end( ap );	    fprintf( mac_debug, "\n" );		// add newline	    fflush( mac_debug );	}	fclose(mac_debug);    } else {	exit(0);    }}// copied... this looks really bad.void debug( const char *msg, ... ){    mac_debug=fopen( "debug.txt", "a+" );    if(mac_debug) {	char buf[8196];	va_list ap;	va_start( ap, msg );			// use variable arg list	if ( handler ) {	    vsprintf( buf, msg, ap );	    va_end( ap );	    (*handler)( QtDebugMsg, buf );	} else {	    vfprintf( mac_debug, msg, ap );	    va_end( ap );	    fprintf( mac_debug, "\n" );		// add newline	    fflush( mac_debug );	}	fclose(mac_debug);    }}void qWarning( const char *msg, ... ){    mac_debug=fopen( "debug.txt", "a+" );    if(mac_debug) {	char buf[8196];	va_list ap;	va_start( ap, msg );			// use variable arg list	if ( handler ) {	    vsprintf( buf, msg, ap );	    va_end( ap );	    (*handler)( QtDebugMsg, buf );	} else {	    vfprintf( mac_debug, msg, ap );	    va_end( ap );	    fprintf( mac_debug, "\n" );		// add newline	    fflush( mac_debug );	}	fclose(mac_debug);    }}// copied... this looks really bad.void warning( const char *msg, ... ){    mac_debug=fopen( "debug.txt", "a+" );    if(mac_debug) {	char buf[8196];	va_list ap;	va_start( ap, msg );			// use variable arg list	if ( handler ) {	    vsprintf( buf, msg, ap );	    va_end( ap );	    (*handler)( QtDebugMsg, buf );	} else {	    vfprintf( mac_debug, msg, ap );	    va_end( ap );	    fprintf( mac_debug, "\n" );		// add newline	    fflush( mac_debug );	}	fclose(mac_debug);    }}void qFatal( const char *msg, ... ){    mac_debug=fopen( "debug.txt", "a+");    if(mac_debug) {	char buf[8196];	va_list ap;	va_start( ap, msg );			// use variable arg list	if ( handler ) {	    vsprintf( buf, msg, ap );	    va_end( ap );	    (*handler)( QtDebugMsg, buf );	} else {	    vfprintf( mac_debug, msg, ap );	    va_end( ap );	    fprintf( mac_debug, "\n" );		// add newline

⌨️ 快捷键说明

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