summaryrefslogtreecommitdiff
path: root/library/quuid.h
authorkergoth <kergoth>2002-01-25 22:14:26 (UTC)
committer kergoth <kergoth>2002-01-25 22:14:26 (UTC)
commit15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff)
treec2fa0399a2c47fda8e2cd0092c73a809d17f68eb /library/quuid.h
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
Diffstat (limited to 'library/quuid.h') (more/less context) (ignore whitespace changes)
-rw-r--r--library/quuid.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/library/quuid.h b/library/quuid.h
new file mode 100644
index 0000000..4f7a720
--- a/dev/null
+++ b/library/quuid.h
@@ -0,0 +1,142 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef QUUID_H
22#define QUUID_H
23
24#ifndef QT_H
25#include <qstring.h>
26#endif // QT_H
27
28#include <memory.h>
29
30#if defined(Q_OS_WIN32)
31#ifndef GUID_DEFINED
32#define GUID_DEFINED
33typedef struct _GUID
34{
35 ulong Data1;
36 ushort Data2;
37 ushort Data3;
38 uchar Data4[ 8 ];
39} GUID;
40#endif
41#endif
42
43#if defined( Q_WS_QWS ) && !defined( UUID_H_INCLUDED )
44typedef unsigned char uuid_t[16];
45#endif
46
47struct Q_EXPORT QUuid
48{
49 QUuid()
50 {
51 memset( this, 0, sizeof(QUuid) );
52 }
53 QUuid( uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8 )
54 {
55 data1 = l;
56 data2 = w1;
57 data3 = w2;
58 data4[0] = b1;
59 data4[1] = b2;
60 data4[2] = b3;
61 data4[3] = b4;
62 data4[4] = b5;
63 data4[5] = b6;
64 data4[6] = b7;
65 data4[7] = b8;
66 }
67 QUuid( const QUuid &uuid )
68 {
69 memcpy( this, &uuid, sizeof(QUuid) );
70 }
71#ifndef QT_NO_QUUID_STRING
72 QUuid( const QString & );
73 QString toString() const;
74#endif
75 bool isNull() const;
76
77 QUuid &operator=(const QUuid &orig )
78 {
79 memcpy( this, &orig, sizeof(QUuid) );
80 return *this;
81 }
82
83 bool operator==(const QUuid &orig ) const
84 {
85 return !memcmp( this, &orig, sizeof(QUuid) );
86 }
87
88 bool operator!=(const QUuid &orig ) const
89 {
90 return !( *this == orig );
91 }
92
93#if defined(Q_OS_WIN32)
94 // On Windows we have a type GUID that is used by the platform API, so we
95 // provide convenience operators to cast from and to this type.
96 QUuid( const GUID &guid )
97 {
98 memcpy( this, &guid, sizeof(GUID) );
99 }
100
101 QUuid &operator=(const GUID &orig )
102 {
103 memcpy( this, &orig, sizeof(QUuid) );
104 return *this;
105 }
106
107 operator GUID() const
108 {
109 GUID guid = { data1, data2, data3, { data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7] } };
110 return guid;
111 }
112
113 bool operator==( const GUID &guid ) const
114 {
115 return !memcmp( this, &guid, sizeof(QUuid) );
116 }
117
118 bool operator!=( const GUID &guid ) const
119 {
120 return !( *this == guid );
121 }
122#endif
123#if defined (Q_WS_QWS)
124 QUuid( uuid_t uuid )
125 {
126 memcpy( this, &uuid, sizeof(uuid_t) );
127 }
128
129 QUuid &operator=(const uuid_t &orig )
130 {
131 memcpy( this, &orig, sizeof(uuid_t) );
132 return *this;
133 }
134#endif
135
136 ulong data1;
137 ushort data2;
138 ushort data3;
139 uchar data4[ 8 ];
140};
141
142#endif //QUUID_H