Point Cloud Library (PCL) 1.13.0
opennurbs_uuid.h
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6// McNeel & Associates.
7//
8// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10// MERCHANTABILITY ARE HEREBY DISCLAIMED.
11//
12// For complete openNURBS copyright information see <http://www.opennurbs.org>.
13//
14////////////////////////////////////////////////////////////////
15*/
16
17#if !defined(OPENNURBS_UUID_INC_)
18#define OPENNURBS_UUID_INC_
19
20// ON_UUID is a 16 byte universally unique identifier
21#if defined(UUID_DEFINED)
22typedef UUID ON_UUID;
23#elif defined(GUID_DEFINED)
24typedef GUID ON_UUID;
25#else
26
27#define ON_UUID_DECLARED_AS_CLASS
28// For uuids, it is critical that the DataN fields have
29// exactly the sizes specified below. For that reason,
30// the ON__UINTnn typedefs are used.
31class ON_CLASS ON_UUID
32{
33public:
34 ON__UINT32 Data1; // 32 bit unsigned integer
35 ON__UINT16 Data2; // 16 bit unsigned integer
36 ON__UINT16 Data3; // 16 bit unsigned integer
37 unsigned char Data4[8];
38
39 bool operator==(const ON_UUID& other) const;
40 bool operator!=(const ON_UUID& other) const;
41};
42
43#endif
44
45ON_BEGIN_EXTERNC
46
47// All bits are zero in ON_nil_uuid and
48// ON_UuidCompare( ON_nil_uuid, U ) < 0 if U != ON_nil_uuid.
49extern ON_EXTERN_DECL const ON_UUID ON_nil_uuid;
50
51// All bits are one in ON_max_uuid and
52// ON_UuidCompare( U, ON_max_uuid ) < 0 if U != ON_max_uuid.
53extern ON_EXTERN_DECL const ON_UUID ON_max_uuid;
54
55// Application ids for the versions of Rhino that
56// write 3dm files. All userdata classed defined
57// in the core Rhino.exe should use these ids
58// as the application id.
59// In situations where you want to use the id
60// for the current version of Rhino, use
61// ON_rhino_id and you won't have to update
62// your code when Rhino versions roll.
63extern ON_EXTERN_DECL const ON_UUID ON_rhino2_id;
64extern ON_EXTERN_DECL const ON_UUID ON_rhino3_id;
65extern ON_EXTERN_DECL const ON_UUID ON_rhino4_id;
66extern ON_EXTERN_DECL const ON_UUID ON_rhino5_id;
67extern ON_EXTERN_DECL const ON_UUID ON_rhino_id;
68
69// Application ids for usedata written by versions
70// of opennurbs before userdata had application ids.
71extern ON_EXTERN_DECL const ON_UUID ON_v2_userdata_id;
72extern ON_EXTERN_DECL const ON_UUID ON_v3_userdata_id;
73extern ON_EXTERN_DECL const ON_UUID ON_v4_userdata_id;
74
75// Application id for the versions of openNURBS that
76// write userdata in 3dm files. User data whose class
77// definition is in opennurbs should use these
78// ids as the user data application id.
79// No other user data should use these ids.
80// The "extern ON_EXTERN_DECL" prefix on the declarations
81// of these ids was a mistake that will be corrected when
82// the public SDK can be changed.
83// In situations where you want to use the id
84// for the current version of opennurbs, use
85// ON_opennurbs_id and you won't have to update
86// your code when opennurbs versions roll.
87extern ON_EXTERN_DECL const ON_UUID ON_opennurbs4_id;
88extern ON_EXTERN_DECL const ON_UUID ON_opennurbs5_id;
89extern ON_EXTERN_DECL const ON_UUID ON_opennurbs_id;
90
91ON_END_EXTERNC
92
93#if defined(ON_CPLUSPLUS)
94
95/*
96Description:
97 Creates a new uuid.(&a,&b) compares two uuids.
98Parameters:
99 new_uuid - [out]
100Returns:
101 True if successful.
102Remarks:
103 Only works on Windows.
104*/
105ON_DECL
106bool ON_CreateUuid( ON_UUID& uuid );
107
108/*
109Description:
110 This class is used by ON_UuidIndexList. It is used when
111 uuids are used to search for items that can be found by
112 an integer index.
113*/
114class ON_CLASS ON_UuidIndex
115{
116public:
117 ON_UuidIndex();
118
119 /*
120 Dictionary compare m_id and then m_i.
121 */
122 static
123 int CompareIdAndIndex( const ON_UuidIndex* a, const ON_UuidIndex* b );
124
125 /*
126 Dictionary compare m_id and then m_i.
127 */
128 static
129 int CompareIndexAndId( const ON_UuidIndex* a, const ON_UuidIndex* b );
130
131 /*
132 Compare m_id and ignore m_i.
133 */
134 static
135 int CompareId( const ON_UuidIndex* a, const ON_UuidIndex* b );
136
137 /*
138 Compare m_i and ignore m_id.
139 */
140 static
141 int CompareIndex( const ON_UuidIndex* a, const ON_UuidIndex* b );
142
143 // In cases when there is a discrepancy between the m_id and
144 // m_i, m_id is assumed to be valid unless comments where this
145 // class is used indicate otherwise.
146 ON_UUID m_id;
147 int m_i;
148};
149
150/*
151Description:
152 ON_UuidCompare(&a,&b) compares two uuids.
153Parameters:
154 a - [in]
155 b - [in]
156Returns:
157 @untitled table
158 -1 a < b
159 0 a == b
160 +1 a > b
161Remarks:
162 A NULL pointer is considered < a non-NULL pointer.
163*/
164ON_DECL
165int ON_UuidCompare(
166 const ON_UUID* a,
167 const ON_UUID* b
168 );
169
170/*
171Description:
172 ON_UuidCompare(a,b) compares two uuids.
173Parameters:
174 a - [in]
175 b - [in]
176Returns:
177 @untitled table
178 -1 a < b
179 0 a == b
180 +1 a > b
181*/
182ON_DECL
183int ON_UuidCompare(
184 const ON_UUID& a,
185 const ON_UUID& b
186 );
187
188/*
189Description:
190 Test uuid to see if it is nil (identically zero).
191Parameters:
192 uuid - [in]
193Returns:
194 true if uuid is nil.
195*/
196ON_DECL
197bool ON_UuidIsNil(
198 const ON_UUID& uuid
199 );
200
201/*
202Description:
203 Test uuid to see if it is not nil (not identically zero).
204Parameters:
205 uuid - [in]
206Returns:
207 true if uuid is not nil (non zero)
208*/
209ON_DECL
210bool ON_UuidIsNotNil(
211 const ON_UUID& uuid
212 );
213
214/*
215Description:
216 Converts a string like
217 "{85A08515-f383-11d3-BFE7-0010830122F0}"
218 into a uuid.
219 The brackets are optional and are ignored.
220 Hyphens can appear anywhere or be missing.
221 The hex digits can be upper or lower case.
222Parameters:
223 s - [in]
224Returns:
225 uuid.
226 If the string is not a uuid, then ON_nil_uuid is returnd.
227*/
228ON_DECL
229ON_UUID ON_UuidFromString( const char* s );
230
231/*
232Description:
233 Converts a string like
234 "{85A08515-f383-11d3-BFE7-0010830122F0}"
235 into a uuid.
236 The brackets are optional and are ignored.
237 Hyphens can appear anywhere or be missing.
238 The hex digits can be upper or lower case.
239Parameters:
240 s - [in]
241Returns:
242 uuid.
243 If the string is not a uuid, then ON_nil_uuid is returnd.
244*/
245ON_DECL
246ON_UUID ON_UuidFromString( const wchar_t* s );
247
248/*
249Description:
250 Converts a uuid to a null termintated ASCII string like
251 "85a08515-f383-11d3-bfe7-0010830122f0".
252Parameters:
253 uuid - [in]
254 s - [out] The s[] char array must have length >= 37.
255 The returned char array will have a 36
256 character uuid in s[0..35] and a null in s[36].
257Returns:
258 The pointer to the array is returned.
259*/
260ON_DECL
261char* ON_UuidToString( const ON_UUID& uuid, char* s );
262
263
264/*
265Description:
266 Converts a uuid to a null termintated UNICODE string like
267 "85a08515-f383-11d3-bfe7-0010830122f0".
268Parameters:
269 uuid - [in]
270 s - [out] The s[] wchar_t array must have length >= 37.
271 The returned char array will have a 36
272 character uuid in s[0..35] and a null in s[36].
273Returns:
274 The pointer to the array is returned.
275*/
276ON_DECL
277wchar_t* ON_UuidToString( const ON_UUID& uuid, wchar_t* s );
278
279class ON_String;
280
281/*
282Description:
283 Converts a uuid to a null termintated string like
284 "85a08515-f383-11d3-bfe7-0010830122f0".
285Parameters:
286 uuid - [in]
287 s - [out]
288Returns:
289 The pointer to the array is returned.
290*/
291ON_DECL
292const char* ON_UuidToString( const ON_UUID& uuid, ON_String& s);
293
294class ON_wString;
295
296/*
297Description:
298 Converts a uuid to a null termintated string like
299 "85a08515-f383-11d3-bfe7-0010830122f0".
300Parameters:
301 uuid - [in]
302 s - [out]
303Returns:
304 The pointer to the array is returned.
305*/
306ON_DECL
307const wchar_t* ON_UuidToString( const ON_UUID& uuid, ON_wString& s);
308
309#endif
310
311#endif
ON__UINT16 Data2
bool operator==(const ON_UUID &other) const
ON__UINT16 Data3
bool operator!=(const ON_UUID &other) const
ON__UINT32 Data1