ecd1c0c483565ed7bfc58480d93ea3721462e730
[occt.git] / src / Standard / Standard_GUID.hxx
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
35
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;
115   
116   //! H method used by collections.
117   Standard_EXPORT static Standard_Integer HashCode (const Standard_GUID& aguid, const Standard_Integer Upper);
118   
119   //! Returns True  when the two GUID are the same.
120   Standard_EXPORT static Standard_Boolean IsEqual (const Standard_GUID& string1, const Standard_GUID& string2);
121
122
123
124
125 protected:
126
127
128
129
130
131 private:
132
133
134
135   Standard_Integer my32b;
136   Standard_ExtCharacter my16b1;
137   Standard_ExtCharacter my16b2;
138   Standard_ExtCharacter my16b3;
139   Standard_Byte my8b1;
140   Standard_Byte my8b2;
141   Standard_Byte my8b3;
142   Standard_Byte my8b4;
143   Standard_Byte my8b5;
144   Standard_Byte my8b6;
145
146
147 };
148
149
150
151
152
153
154
155 #endif // _Standard_GUID_HeaderFile