Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

quuid.h

Go to the documentation of this file.
00001 #ifndef QUUID_H
00002 #define QUUID_H
00003 
00004 /****************************************************************************
00005  ** $Id:  qt/qlibrary.h   3.0.0   edited Sep 20 19:46 $
00006  **
00007  ** Definition of QLibrary class
00008  **
00009  ** Created : 2000-01-01
00010  **
00011  ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00012  **
00013  ** This file is part of the kernel module of the Qt GUI Toolkit.
00014  **
00015  ** This file may be distributed under the terms of the Q Public License
00016  ** as defined by Trolltech AS of Norway and appearing in the file
00017  ** LICENSE.QPL included in the packaging of this file.
00018  **
00019  ** This file may be distributed and/or modified under the terms of the
00020  ** GNU General Public License version 2 as published by the Free Software
00021  ** Foundation and appearing in the file LICENSE.GPL included in the
00022  ** packaging of this file.
00023  **
00024  ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00025  ** licenses may use this file in accordance with the Qt Commercial License
00026  ** Agreement provided with the Software.
00027  **
00028  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00029  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00030  **
00031  ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00032  **       information about Qt Commercial License Agreements.
00033  ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00034  ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00035  **
00036  ** Contact info@trolltech.com if any conditions of this licensing are
00037  ** not clear to you.
00038  **
00039  **     Modified by BJDC, Motorola 
00040  **
00041  **********************************************************************/
00042   
00043 #ifndef __cplusplus
00044 #error "This is a C++ header file; it requires C++ to compile."
00045 #endif
00046 
00047 #ifndef QT_H
00048 #include <qstring.h>
00049 #endif // QT_H
00050 
00051 #include <string.h>
00052 #include <memory.h>
00053 #include <qdatastream.h>
00054 
00055 /**
00056  * The QUuid class defines a Universally Unique Identifier (UUID).
00057  *
00058  * For objects or declarations that need to be uniquely identified,
00059  * UUIDs (also known as GUIDs) are widely used in order to assign a
00060  * fixed and easy to compare value to the object or declaration.
00061  * The 128-bit value of a UUID is generated by an algorithm that
00062  * guarantees that the value is unique.
00063 
00064  * In Qt, UUIDs are wrapped by the QUuid struct which provides convenience
00065  * functions for handling UUIDs. Most platforms provide a tool to generate
00066  * new UUIDs, for example, uuidgen and guidgen.
00067  */
00068 struct QUuid
00069 {
00070     /**
00071      * Constructor of QUuid   
00072      * Creates the null UUID {00000000-0000-0000-0000-000000000000}.
00073      */
00074     QUuid()
00075     {
00076         memset( this, 0, sizeof(QUuid) );
00077     }
00078 
00079     /**
00080      * Constructor of QUuid   
00081      * Creates a UUID with the value specified by the parameters,
00082      * l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8.
00083      *
00084      * @code
00085      * // {67C8770B-44F1-410A-AB9A-F9B5446F13EE}
00086      * QUuid IID_MyInterface( 0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9,
00087      * 0xb5, 0x44, 0x6f, 0x13, 0xee )
00088      * @endcode
00089      *
00090      */   
00091     QUuid( ulong l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8 )
00092     {
00093         data1 = l;
00094         data2 = w1;
00095         data3 = w2;
00096         data4[0] = b1;
00097         data4[1] = b2;
00098         data4[2] = b3;
00099         data4[3] = b4;
00100         data4[4] = b5;
00101         data4[5] = b6;
00102         data4[6] = b7;
00103         data4[7] = b8;
00104     }
00105     
00106     /**
00107      * Constructor of QUuid
00108      */
00109     QUuid( const QUuid &uuid )
00110     {
00111         memcpy( this, &uuid, sizeof(QUuid) );
00112     }
00113     
00114 #ifndef QT_NO_QUUID_STRING
00115     QUuid( const QString & );
00116     QString toString() const;
00117     operator QString() const { return toString(); }
00118 #endif
00119     
00120     /**
00121      * Returns TRUE if this is the null UUID {00000000-0000-0000-0000-000000000000};
00122      * otherwise returns FALSE.
00123      */
00124     bool isNull() const;
00125 
00126     /**
00127      * Assigns the value of uuid to this QUuid object.
00128      */
00129     QUuid &operator=(const QUuid &orig )
00130     {
00131         memcpy( this, &orig, sizeof(QUuid) );
00132         return *this;
00133     }
00134 
00135     /**
00136      * Returns TRUE if this QUuid and the other QUuid are identical;
00137      * otherwise returns FALSE.
00138      */
00139     bool operator==(const QUuid &orig ) const
00140     {
00141         uint i;
00142         if ( data1 != orig.data1 || data2 != orig.data2 ||
00143              data3 != orig.data3 )
00144             return FALSE;
00145 
00146         for( i = 0; i < 8; i++ )
00147             if ( data4[i] != orig.data4[i] )
00148                 return FALSE;
00149 
00150         return TRUE;
00151     }
00152 
00153     /**
00154      * Returns TRUE if this QUuid and the other QUuid are different;
00155      * otherwise returns FALSE.
00156      */
00157     bool operator!=(const QUuid &orig ) const
00158     {
00159         return !( *this == orig );
00160     }
00161 
00162     ulong   data1;
00163     ushort  data2;
00164     ushort  data3;
00165     uchar   data4[ 8 ];
00166 };
00167 
00168 /**
00169  * Writes the uuid quuid to the datastream s.
00170  */
00171 QDataStream &  operator>> (QDataStream & s,  QUuid & quuid);
00172 
00173 /**
00174  * Reads uuid from from the stream s into quuid.
00175  */
00176 QDataStream &  operator<< (QDataStream & s, const QUuid & quuid);
00177 
00178 #endif //QUUID_H

Generated at Wed Mar 3 13:21:58 2004 by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001