Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright (c) 2023 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Standard_CStringHasher_HeaderFile
0015 #define _Standard_CStringHasher_HeaderFile
0016 
0017 #include <Standard_CString.hxx>
0018 #include <Standard_HashUtils.hxx>
0019 #include <Standard_TypeDef.hxx>
0020 
0021 #include <functional>
0022 
0023 class Standard_CStringHasher
0024 {
0025 public:
0026 
0027   size_t operator()(const Standard_CString& theString) const noexcept
0028   {
0029     const int aLen = static_cast<int>(strlen(theString));
0030     if (aLen < 4)
0031     {
0032       return opencascade::FNVHash::hash_combine(*theString, aLen);
0033     }
0034     return opencascade::hashBytes(theString, aLen);
0035   }
0036 
0037   bool operator()(const Standard_CString& theString1,
0038                   const Standard_CString& theString2) const noexcept
0039   {
0040     return strcmp(theString1, theString2) == 0;
0041   }
0042 
0043 };
0044 
0045 #endif