Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/quuid.h 3.3.8 edited Jan 11 14:38 $ 00003 ** 00004 ** Definition of QUuid class 00005 ** 00006 ** Created : 010523 00007 ** 00008 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00009 ** 00010 ** This file is part of the tools module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech ASA of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00022 ** licenses may use this file in accordance with the Qt Commercial License 00023 ** Agreement provided with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QUUID_H 00039 #define QUUID_H 00040 00041 #ifndef QT_H 00042 #include "qstring.h" 00043 #endif // QT_H 00044 00045 #include <string.h> 00046 00047 #if defined(Q_OS_WIN32) 00048 #ifndef GUID_DEFINED 00049 #define GUID_DEFINED 00050 typedef struct _GUID 00051 { 00052 ulong Data1; 00053 ushort Data2; 00054 ushort Data3; 00055 uchar Data4[ 8 ]; 00056 } GUID, *REFGUID, *LPGUID; 00057 #endif 00058 #endif 00059 00060 00061 struct Q_EXPORT QUuid 00062 { 00063 enum Variant { 00064 VarUnknown =-1, 00065 NCS = 0, // 0 - - 00066 DCE = 2, // 1 0 - 00067 Microsoft = 6, // 1 1 0 00068 Reserved = 7 // 1 1 1 00069 }; 00070 00071 enum Version { 00072 VerUnknown =-1, 00073 Time = 1, // 0 0 0 1 00074 EmbeddedPOSIX = 2, // 0 0 1 0 00075 Name = 3, // 0 0 1 1 00076 Random = 4 // 0 1 0 0 00077 }; 00078 00079 QUuid() 00080 { 00081 memset( this, 0, sizeof(QUuid) ); 00082 } 00083 QUuid( uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8 ) 00084 { 00085 data1 = l; 00086 data2 = w1; 00087 data3 = w2; 00088 data4[0] = b1; 00089 data4[1] = b2; 00090 data4[2] = b3; 00091 data4[3] = b4; 00092 data4[4] = b5; 00093 data4[5] = b6; 00094 data4[6] = b7; 00095 data4[7] = b8; 00096 } 00097 QUuid( const QUuid &uuid ) 00098 { 00099 memcpy( this, &uuid, sizeof(QUuid) ); 00100 } 00101 #ifndef QT_NO_QUUID_STRING 00102 QUuid( const QString & ); 00103 QUuid( const char * ); 00104 QString toString() const; 00105 operator QString() const { return toString(); } 00106 #endif 00107 bool isNull() const; 00108 00109 QUuid &operator=(const QUuid &orig ) 00110 { 00111 memcpy( this, &orig, sizeof(QUuid) ); 00112 return *this; 00113 } 00114 00115 bool operator==(const QUuid &orig ) const 00116 { 00117 uint i; 00118 if ( data1 != orig.data1 || data2 != orig.data2 || 00119 data3 != orig.data3 ) 00120 return FALSE; 00121 00122 for( i = 0; i < 8; i++ ) 00123 if ( data4[i] != orig.data4[i] ) 00124 return FALSE; 00125 00126 return TRUE; 00127 } 00128 00129 bool operator!=(const QUuid &orig ) const 00130 { 00131 return !( *this == orig ); 00132 } 00133 00134 bool operator<(const QUuid &other ) const; 00135 bool operator>(const QUuid &other ) const; 00136 00137 #if defined(Q_OS_WIN32) 00138 // On Windows we have a type GUID that is used by the platform API, so we 00139 // provide convenience operators to cast from and to this type. 00140 QUuid( const GUID &guid ) 00141 { 00142 memcpy( this, &guid, sizeof(GUID) ); 00143 } 00144 00145 QUuid &operator=(const GUID &orig ) 00146 { 00147 memcpy( this, &orig, sizeof(QUuid) ); 00148 return *this; 00149 } 00150 00151 operator GUID() const 00152 { 00153 GUID guid = { data1, data2, data3, { data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7] } }; 00154 return guid; 00155 } 00156 00157 bool operator==( const GUID &guid ) const 00158 { 00159 uint i; 00160 if ( data1 != guid.Data1 || data2 != guid.Data2 || 00161 data3 != guid.Data3 ) 00162 return FALSE; 00163 00164 for( i = 0; i < 8; i++ ) 00165 if ( data4[i] != guid.Data4[i] ) 00166 return FALSE; 00167 00168 return TRUE; 00169 } 00170 00171 bool operator!=( const GUID &guid ) const 00172 { 00173 return !( *this == guid ); 00174 } 00175 #endif 00176 static QUuid createUuid(); 00177 QUuid::Variant variant() const; 00178 QUuid::Version version() const; 00179 00180 uint data1; 00181 ushort data2; 00182 ushort data3; 00183 uchar data4[ 8 ]; 00184 }; 00185 00186 #ifndef QT_NO_DATASTREAM 00187 Q_EXPORT QDataStream &operator<<( QDataStream &, const QUuid & ); 00188 Q_EXPORT QDataStream &operator>>( QDataStream &, QUuid & ); 00189 #endif 00190 00191 #endif //QUUID_H