00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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,
00066 DCE = 2,
00067 Microsoft = 6,
00068 Reserved = 7
00069 };
00070
00071 enum Version {
00072 VerUnknown =-1,
00073 Time = 1,
00074 EmbeddedPOSIX = 2,
00075 Name = 3,
00076 Random = 4
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
00139
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