Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:58

0001 // Created on: 1997-06-19
0002 // Created by: Christophe LEYNADIER
0003 // Copyright (c) 1997-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Standard_GUID_HeaderFile
0018 #define _Standard_GUID_HeaderFile
0019 
0020 #include <Standard_Handle.hxx>
0021 
0022 #include <Standard_Integer.hxx>
0023 #include <Standard_CString.hxx>
0024 #include <Standard_UUID.hxx>
0025 #include <Standard_PCharacter.hxx>
0026 #include <Standard_PExtCharacter.hxx>
0027 #include <Standard_OStream.hxx>
0028 
0029 #define Standard_GUID_SIZE 36
0030 #define Standard_GUID_SIZE_ALLOC Standard_GUID_SIZE+1
0031 
0032 class Standard_GUID 
0033 {
0034 public:
0035 
0036   DEFINE_STANDARD_ALLOC
0037 
0038   
0039   Standard_EXPORT Standard_GUID();
0040   
0041   //! build a GUID from an ascii string with the
0042   //! following format:
0043   //! Length : 36 char
0044   //! "00000000-0000-0000-0000-000000000000"
0045   Standard_EXPORT Standard_GUID(const Standard_CString aGuid);
0046   
0047   //! build a GUID from an unicode string with the
0048   //! following format:
0049   //!
0050   //! "00000000-0000-0000-0000-000000000000"
0051   Standard_EXPORT Standard_GUID(const Standard_ExtString aGuid);
0052   
0053   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);
0054   
0055   Standard_EXPORT Standard_GUID(const Standard_UUID& aGuid);
0056   
0057   Standard_EXPORT Standard_GUID(const Standard_GUID& aGuid);
0058   
0059   Standard_EXPORT Standard_UUID ToUUID() const;
0060   
0061   //! translate the GUID into ascii string
0062   //! the aStrGuid is allocated by user.
0063   //! the guid have the following format:
0064   //!
0065   //! "00000000-0000-0000-0000-000000000000"
0066   Standard_EXPORT void ToCString (const Standard_PCharacter aStrGuid) const;
0067   
0068   //! translate the GUID into unicode string
0069   //! the aStrGuid is allocated by user.
0070   //! the guid have the following format:
0071   //!
0072   //! "00000000-0000-0000-0000-000000000000"
0073   Standard_EXPORT void ToExtString (const Standard_PExtCharacter aStrGuid) const;
0074   
0075   Standard_EXPORT Standard_Boolean IsSame (const Standard_GUID& uid) const;
0076 Standard_Boolean operator == (const Standard_GUID& uid) const
0077 {
0078   return IsSame(uid);
0079 }
0080   
0081   Standard_EXPORT Standard_Boolean IsNotSame (const Standard_GUID& uid) const;
0082 Standard_Boolean operator != (const Standard_GUID& uid) const
0083 {
0084   return IsNotSame(uid);
0085 }
0086   
0087   Standard_EXPORT void Assign (const Standard_GUID& uid);
0088 void operator = (const Standard_GUID& uid)
0089 {
0090   Assign(uid);
0091 }
0092   
0093   Standard_EXPORT void Assign (const Standard_UUID& uid);
0094 void operator = (const Standard_UUID& uid)
0095 {
0096   Assign(uid);
0097 }
0098   
0099   //! Display the GUID with the following format:
0100   //!
0101   //! "00000000-0000-0000-0000-000000000000"
0102   Standard_EXPORT void ShallowDump (Standard_OStream& aStream) const;
0103   
0104   //! Check the format of a GUID string.
0105   //! It checks the size, the position of the '-' and the correct size of fields.
0106   Standard_EXPORT static Standard_Boolean CheckGUIDFormat (const Standard_CString aGuid);
0107 
0108   template<class T>
0109   friend struct std::hash;
0110 
0111 private:
0112 
0113   Standard_Integer my32b;
0114   Standard_ExtCharacter my16b1;
0115   Standard_ExtCharacter my16b2;
0116   Standard_ExtCharacter my16b3;
0117   Standard_Byte my8b1;
0118   Standard_Byte my8b2;
0119   Standard_Byte my8b3;
0120   Standard_Byte my8b4;
0121   Standard_Byte my8b5;
0122   Standard_Byte my8b6;
0123 };
0124 
0125 
0126 namespace std
0127 {
0128   template <>
0129   struct hash<Standard_GUID>
0130   {
0131     size_t operator()(const Standard_GUID& theGUID) const noexcept
0132     {
0133       struct GUID
0134       {
0135         Standard_Integer my32b;
0136         Standard_ExtCharacter my16b1;
0137         Standard_ExtCharacter my16b2;
0138         Standard_ExtCharacter my16b3;
0139         Standard_Byte my8b1;
0140         Standard_Byte my8b2;
0141         Standard_Byte my8b3;
0142         Standard_Byte my8b4;
0143         Standard_Byte my8b5;
0144         Standard_Byte my8b6;
0145       };
0146       GUID aGUID{ theGUID.my32b, theGUID.my16b1,
0147                   theGUID.my16b2, theGUID.my16b3,
0148                   theGUID.my8b1, theGUID.my8b2,
0149                   theGUID.my8b3, theGUID.my8b4,
0150                   theGUID.my8b5, theGUID.my8b6 };
0151       return opencascade::hashBytes(&aGUID, sizeof(GUID));
0152     }
0153   };
0154 }
0155 
0156 
0157 
0158 
0159 #endif // _Standard_GUID_HeaderFile