Qtopia library API Documentation

quuid.h

00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
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     // On Windows we have a type GUID that is used by the platform API, so we
00105     // provide convenience operators to cast from and to this type.
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
KDE Logo
This file is part of the documentation for OPIE Version 1.5.5.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:08 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001