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