1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 //! Functions working with plain C strings
18 #ifndef _Standard_CString_HeaderFile
19 # define _Standard_CString_HeaderFile
21 #include <Standard_Macro.hxx>
26 # if defined(_MSC_VER) && ! defined(strcasecmp)
27 # define strcasecmp _stricmp
30 // C++ only definitions
33 #include <Standard_Integer.hxx>
35 //! Returns bounded hash code for the null-terminated string, in the range [1, theUpperBound]
36 //! @param theString the null-terminated string which hash code is to be computed
37 //! @param theUpperBound the upper bound of the range a computing hash code must be within
38 //! @return a computed hash code, in the range [1, theUpperBound]
39 Standard_EXPORT Standard_Integer HashCode (Standard_CString theString, Standard_Integer theUpperBound);
41 //! Returns 32-bit hash code for the first theLen characters in the string theStr.
42 //! The result is unbound (may be not only positive, but also negative)
43 //! @param theString the string which hash code is to be computed
44 //! @param theLength the length of the given string
45 //! @return a computed hash code of the given string
46 Standard_EXPORT Standard_Integer HashCodes (Standard_CString theString, Standard_Integer theLength);
48 //! Returns bounded hash code for the first theLength characters in the string theString, in the range [1, theUpperBound]
49 //! @param theString the string which hash code is to be computed
50 //! @param theLength the length of the initial substring of the given string which hash code is to be computed
51 //! @param theUpperBound the upper bound of the range a computing hash code must be within
52 //! @return a computed hash code of the given string
53 inline Standard_Integer HashCode (const Standard_CString theString,
54 const Standard_Integer theLength,
55 const Standard_Integer theUpperBound)
57 // return (Abs( HashCodes( Value , Len ) ) % Upper ) + 1 ;
58 return HashCode (HashCodes (theString, theLength), theUpperBound);
61 //! Returns Standard_True if two strings are equal
62 inline Standard_Boolean IsEqual (const Standard_CString theOne, const Standard_CString theTwo)
64 return strcmp (theOne, theTwo) == 0;
67 #endif /* __cplusplus */
71 #endif /* __cplusplus */
73 //! Equivalent of standard C function atof() that always uses C locale
74 Standard_EXPORT double Atof (const char* theStr);
76 //! Optimized equivalent of standard C function strtod() that always uses C locale
77 Standard_EXPORT double Strtod (const char* theStr, char** theNextPtr);
79 //! Equivalent of standard C function printf() that always uses C locale
80 Standard_EXPORT int Printf (const char* theFormat, ...);
82 //! Equivalent of standard C function fprintf() that always uses C locale
83 Standard_EXPORT int Fprintf (FILE* theFile, const char* theFormat, ...);
85 //! Equivalent of standard C function sprintf() that always uses C locale
86 Standard_EXPORT int Sprintf (char* theBuffer, const char* theFormat, ...);
90 #endif /* __cplusplus */