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 | |
42cf5bc1 |
20 | #include <Standard_DefineAlloc.hxx> |
21 | #include <Standard_Handle.hxx> |
22 | |
23 | #include <Standard_Integer.hxx> |
24 | #include <Standard_ExtCharacter.hxx> |
25 | #include <Standard_Byte.hxx> |
26 | #include <Standard_CString.hxx> |
27 | #include <Standard_ExtString.hxx> |
28 | #include <Standard_UUID.hxx> |
29 | #include <Standard_PCharacter.hxx> |
30 | #include <Standard_PExtCharacter.hxx> |
31 | #include <Standard_Boolean.hxx> |
32 | #include <Standard_OStream.hxx> |
33 | |
fa53efef |
34 | #define Standard_GUID_SIZE 36 |
35 | #define Standard_GUID_SIZE_ALLOC Standard_GUID_SIZE+1 |
42cf5bc1 |
36 | |
37 | class Standard_GUID |
38 | { |
39 | public: |
40 | |
41 | DEFINE_STANDARD_ALLOC |
42 | |
43 | |
44 | Standard_EXPORT Standard_GUID(); |
45 | |
46 | //! build a GUID from an ascii string with the |
47 | //! following format: |
48 | //! Length : 36 char |
49 | //! "00000000-0000-0000-0000-000000000000" |
50 | Standard_EXPORT Standard_GUID(const Standard_CString aGuid); |
51 | |
52 | //! build a GUID from an unicode string with the |
53 | //! following format: |
54 | //! |
55 | //! "00000000-0000-0000-0000-000000000000" |
56 | Standard_EXPORT Standard_GUID(const Standard_ExtString aGuid); |
57 | |
58 | 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); |
59 | |
60 | Standard_EXPORT Standard_GUID(const Standard_UUID& aGuid); |
61 | |
62 | Standard_EXPORT Standard_GUID(const Standard_GUID& aGuid); |
63 | |
64 | Standard_EXPORT Standard_UUID ToUUID() const; |
65 | |
66 | //! translate the GUID into ascii string |
67 | //! the aStrGuid is allocated by user. |
68 | //! the guid have the following format: |
69 | //! |
70 | //! "00000000-0000-0000-0000-000000000000" |
71 | Standard_EXPORT void ToCString (const Standard_PCharacter aStrGuid) const; |
72 | |
73 | //! translate the GUID into unicode string |
74 | //! the aStrGuid is allocated by user. |
75 | //! the guid have the following format: |
76 | //! |
77 | //! "00000000-0000-0000-0000-000000000000" |
78 | Standard_EXPORT void ToExtString (const Standard_PExtCharacter aStrGuid) const; |
79 | |
80 | Standard_EXPORT Standard_Boolean IsSame (const Standard_GUID& uid) const; |
81 | Standard_Boolean operator == (const Standard_GUID& uid) const |
82 | { |
83 | return IsSame(uid); |
84 | } |
85 | |
86 | Standard_EXPORT Standard_Boolean IsNotSame (const Standard_GUID& uid) const; |
87 | Standard_Boolean operator != (const Standard_GUID& uid) const |
88 | { |
89 | return IsNotSame(uid); |
90 | } |
91 | |
92 | Standard_EXPORT void Assign (const Standard_GUID& uid); |
93 | void operator = (const Standard_GUID& uid) |
94 | { |
95 | Assign(uid); |
96 | } |
97 | |
98 | Standard_EXPORT void Assign (const Standard_UUID& uid); |
99 | void operator = (const Standard_UUID& uid) |
100 | { |
101 | Assign(uid); |
102 | } |
103 | |
104 | //! Display the GUID with the following format: |
105 | //! |
106 | //! "00000000-0000-0000-0000-000000000000" |
107 | Standard_EXPORT void ShallowDump (Standard_OStream& aStream) const; |
108 | |
109 | //! Check the format of a GUID string. |
110 | //! It checks the size, the position of the '-' and the correct size of fields. |
111 | Standard_EXPORT static Standard_Boolean CheckGUIDFormat (const Standard_CString aGuid); |
112 | |
113 | //! Hash function for GUID. |
114 | Standard_EXPORT Standard_Integer Hash (const Standard_Integer Upper) const; |
2b2be3fb |
115 | |
116 | //! Computes a hash code for the given GUID of the Standard_Integer type, in the range [1, theUpperBound] |
117 | //! @param theGUID the GUID which hash code is to be computed |
118 | //! @param theUpperBound the upper bound of the range a computing hash code must be within |
119 | //! @return a computed hash code, in the range [1, theUpperBound] |
120 | Standard_EXPORT static Standard_Integer HashCode (const Standard_GUID& theGUID, Standard_Integer theUpperBound); |
42cf5bc1 |
121 | |
122 | //! Returns True when the two GUID are the same. |
123 | Standard_EXPORT static Standard_Boolean IsEqual (const Standard_GUID& string1, const Standard_GUID& string2); |
124 | |
125 | |
126 | |
127 | |
128 | protected: |
129 | |
130 | |
131 | |
132 | |
133 | |
134 | private: |
135 | |
136 | |
137 | |
138 | Standard_Integer my32b; |
139 | Standard_ExtCharacter my16b1; |
140 | Standard_ExtCharacter my16b2; |
141 | Standard_ExtCharacter my16b3; |
142 | Standard_Byte my8b1; |
143 | Standard_Byte my8b2; |
144 | Standard_Byte my8b3; |
145 | Standard_Byte my8b4; |
146 | Standard_Byte my8b5; |
147 | Standard_Byte my8b6; |
148 | |
149 | |
150 | }; |
151 | |
152 | |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | #endif // _Standard_GUID_HeaderFile |