00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef QUUID_H
00022 #define QUUID_H
00023
00024 #ifndef QT_H
00025 #include <qstring.h>
00026 #endif // QT_H
00027
00028 #include <memory.h>
00029
00030 #if defined(Q_OS_WIN32)
00031 #ifndef GUID_DEFINED
00032 #define GUID_DEFINED
00033 typedef struct _GUID
00034 {
00035 ulong Data1;
00036 ushort Data2;
00037 ushort Data3;
00038 uchar Data4[ 8 ];
00039 } GUID;
00040 #endif
00041 #endif
00042
00043 #if defined( Q_WS_QWS ) && !defined( UUID_H_INCLUDED )
00044 typedef unsigned char uuid_t[16];
00045 #endif
00046
00047 struct Q_EXPORT QUuid
00048 {
00049 QUuid()
00050 {
00051 memset( this, 0, sizeof(QUuid) );
00052 }
00053 QUuid( uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8 )
00054 {
00055 data1 = l;
00056 data2 = w1;
00057 data3 = w2;
00058 data4[0] = b1;
00059 data4[1] = b2;
00060 data4[2] = b3;
00061 data4[3] = b4;
00062 data4[4] = b5;
00063 data4[5] = b6;
00064 data4[6] = b7;
00065 data4[7] = b8;
00066 }
00067 QUuid( const QUuid &uuid )
00068 {
00069 memcpy( this, &uuid, sizeof(QUuid) );
00070 }
00071 #ifndef QT_NO_QUUID_STRING
00072 QUuid( const QString & );
00073 QString toString() const;
00074 #endif
00075 bool isNull() const;
00076
00077 QUuid &operator=(const QUuid &orig )
00078 {
00079 memcpy( this, &orig, sizeof(QUuid) );
00080 return *this;
00081 }
00082
00083 bool operator==(const QUuid &orig ) const
00084 {
00085 return !memcmp( this, &orig, sizeof(QUuid) );
00086 }
00087
00088 bool operator!=(const QUuid &orig ) const
00089 {
00090 return !( *this == orig );
00091 }
00092
00093 inline bool operator<(const QUuid &orig) const
00094 {
00095 return ( memcmp(this, &orig, sizeof(QUuid)) < 0);
00096 }
00097
00098 inline bool operator>(const QUuid &orig) const
00099 {
00100 return ( memcmp(this, &orig, sizeof(QUuid) ) > 0);
00101 }
00102
00103 #if defined(Q_OS_WIN32)
00104
00105
00106 QUuid( const GUID &guid )
00107 {
00108 memcpy( this, &guid, sizeof(GUID) );
00109 }
00110
00111 QUuid &operator=(const GUID &orig )
00112 {
00113 memcpy( this, &orig, sizeof(QUuid) );
00114 return *this;
00115 }
00116
00117 operator GUID() const
00118 {
00119 GUID guid = { data1, data2, data3, { data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7] } };
00120 return guid;
00121 }
00122
00123 bool operator==( const GUID &guid ) const
00124 {
00125 return !memcmp( this, &guid, sizeof(QUuid) );
00126 }
00127
00128 bool operator!=( const GUID &guid ) const
00129 {
00130 return !( *this == guid );
00131 }
00132
00133 inline bool operator<(const QUuid &orig) const
00134 {
00135 return ( memcmp(this, &orig, sizeof(QUuid) ) < 0);
00136 }
00137
00138 inline bool operator>(const QUuid &orig) const
00139 {
00140 return ( memcmp(this, &orig, sizeof(QUuid) ) > 0);
00141 }
00142
00143 #endif
00144 #if defined (Q_WS_QWS)
00145 QUuid( uuid_t uuid )
00146 {
00147 memcpy( this, uuid, sizeof(uuid_t) );
00148 }
00149
00150 QUuid &operator=(const uuid_t &orig )
00151 {
00152 memcpy( this, &orig, sizeof(uuid_t) );
00153 return *this;
00154 }
00155 #endif
00156
00157 ulong data1;
00158 ushort data2;
00159 ushort data3;
00160 uchar data4[ 8 ];
00161 };
00162
00163 #endif //QUUID_H