42cf5bc1 |
1 | // Created on: 1997-06-19 |
2 | // Created by: Christophe LEYNADIER |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Standard_GUID_HeaderFile |
18 | #define _Standard_GUID_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Integer.hxx> |
25 | #include <Standard_ExtCharacter.hxx> |
26 | #include <Standard_Byte.hxx> |
27 | #include <Standard_CString.hxx> |
28 | #include <Standard_ExtString.hxx> |
29 | #include <Standard_UUID.hxx> |
30 | #include <Standard_PCharacter.hxx> |
31 | #include <Standard_PExtCharacter.hxx> |
32 | #include <Standard_Boolean.hxx> |
33 | #include <Standard_OStream.hxx> |
34 | |
fa53efef |
35 | #define Standard_GUID_SIZE 36 |
36 | #define Standard_GUID_SIZE_ALLOC Standard_GUID_SIZE+1 |
42cf5bc1 |
37 | |
38 | class Standard_GUID |
39 | { |
40 | public: |
41 | |
42 | DEFINE_STANDARD_ALLOC |
43 | |
44 | |
45 | Standard_EXPORT Standard_GUID(); |
46 | |
47 | //! build a GUID from an ascii string with the |
48 | //! following format: |
49 | //! Length : 36 char |
50 | //! "00000000-0000-0000-0000-000000000000" |
51 | Standard_EXPORT Standard_GUID(const Standard_CString aGuid); |
52 | |
53 | //! build a GUID from an unicode string with the |
54 | //! following format: |
55 | //! |
56 | //! "00000000-0000-0000-0000-000000000000" |
57 | Standard_EXPORT Standard_GUID(const Standard_ExtString aGuid); |
58 | |
59 | Standard_EXPORT Standard_GUID(const Standard_Integer a32b, const Standard_ExtCharacter a16b1, const Standard_ExtCharacter a16b2, const Standard_ExtCharacter a16b3, const Standard_Byte a8b1, const Standard_Byte a8b2, const Standard_Byte a8b3, const Standard_Byte a8b4, const Standard_Byte a8b5, const Standard_Byte a8b6); |
60 | |
61 | Standard_EXPORT Standard_GUID(const Standard_UUID& aGuid); |
62 | |
63 | Standard_EXPORT Standard_GUID(const Standard_GUID& aGuid); |
64 | |
65 | Standard_EXPORT Standard_UUID ToUUID() const; |
66 | |
67 | //! translate the GUID into ascii string |
68 | //! the aStrGuid is allocated by user. |
69 | //! the guid have the following format: |
70 | //! |
71 | //! "00000000-0000-0000-0000-000000000000" |
72 | Standard_EXPORT void ToCString (const Standard_PCharacter aStrGuid) const; |
73 | |
74 | //! translate the GUID into unicode string |
75 | //! the aStrGuid is allocated by user. |
76 | //! the guid have the following format: |
77 | //! |
78 | //! "00000000-0000-0000-0000-000000000000" |
79 | Standard_EXPORT void ToExtString (const Standard_PExtCharacter aStrGuid) const; |
80 | |
81 | Standard_EXPORT Standard_Boolean IsSame (const Standard_GUID& uid) const; |
82 | Standard_Boolean operator == (const Standard_GUID& uid) const |
83 | { |
84 | return IsSame(uid); |
85 | } |
86 | |
87 | Standard_EXPORT Standard_Boolean IsNotSame (const Standard_GUID& uid) const; |
88 | Standard_Boolean operator != (const Standard_GUID& uid) const |
89 | { |
90 | return IsNotSame(uid); |
91 | } |
92 | |
93 | Standard_EXPORT void Assign (const Standard_GUID& uid); |
94 | void operator = (const Standard_GUID& uid) |
95 | { |
96 | Assign(uid); |
97 | } |
98 | |
99 | Standard_EXPORT void Assign (const Standard_UUID& uid); |
100 | void operator = (const Standard_UUID& uid) |
101 | { |
102 | Assign(uid); |
103 | } |
104 | |
105 | //! Display the GUID with the following format: |
106 | //! |
107 | //! "00000000-0000-0000-0000-000000000000" |
108 | Standard_EXPORT void ShallowDump (Standard_OStream& aStream) const; |
109 | |
110 | //! Check the format of a GUID string. |
111 | //! It checks the size, the position of the '-' and the correct size of fields. |
112 | Standard_EXPORT static Standard_Boolean CheckGUIDFormat (const Standard_CString aGuid); |
113 | |
114 | //! Hash function for GUID. |
115 | Standard_EXPORT Standard_Integer Hash (const Standard_Integer Upper) const; |
116 | |
117 | //! H method used by collections. |
118 | Standard_EXPORT static Standard_Integer HashCode (const Standard_GUID& aguid, const Standard_Integer Upper); |
119 | |
120 | //! Returns True when the two GUID are the same. |
121 | Standard_EXPORT static Standard_Boolean IsEqual (const Standard_GUID& string1, const Standard_GUID& string2); |
122 | |
123 | |
124 | |
125 | |
126 | protected: |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | private: |
133 | |
134 | |
135 | |
136 | Standard_Integer my32b; |
137 | Standard_ExtCharacter my16b1; |
138 | Standard_ExtCharacter my16b2; |
139 | Standard_ExtCharacter my16b3; |
140 | Standard_Byte my8b1; |
141 | Standard_Byte my8b2; |
142 | Standard_Byte my8b3; |
143 | Standard_Byte my8b4; |
144 | Standard_Byte my8b5; |
145 | Standard_Byte my8b6; |
146 | |
147 | |
148 | }; |
149 | |
150 | |
151 | |
152 | |
153 | |
154 | |
155 | |
156 | #endif // _Standard_GUID_HeaderFile |