b311480e |
1 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
3415763e |
15 | //!@file Functions working with plain C strings |
7fd59977 |
16 | |
17 | #ifndef _Standard_CString_HeaderFile |
18 | # define _Standard_CString_HeaderFile |
19 | |
20 | # ifndef _Standard_TypeDef_HeaderFile |
21 | # include <Standard_TypeDef.hxx> |
22 | # endif |
23 | |
3415763e |
24 | # if defined(_MSC_VER) && ! defined(strcasecmp) |
7fd59977 |
25 | # define strcasecmp _stricmp |
26 | # endif |
27 | |
28 | # include <string.h> |
91322f44 |
29 | # include <stdio.h> |
7fd59977 |
30 | |
31 | # ifndef _Standard_Integer_HeaderFile |
32 | # include <Standard_Integer.hxx> |
33 | # endif |
34 | |
7fd59977 |
35 | __Standard_API Standard_Integer HashCode (const Standard_CString, |
36 | const Standard_Integer); |
37 | inline Standard_Integer HashCode (const Standard_CString, |
38 | const Standard_Integer, |
39 | const Standard_Integer); |
40 | inline Standard_Integer HashCode (const Standard_CString, |
41 | const Standard_Integer , |
42 | const Standard_Integer , |
43 | Standard_Integer& ); |
868dbdba |
44 | __Standard_API Standard_Integer HashCodes (const Standard_CString, |
45 | const Standard_Integer); |
7fd59977 |
46 | |
91322f44 |
47 | //! Equivalents of functions from standard C library that use always C locale |
48 | __Standard_API double Atof (const char* theStr); |
49 | __Standard_API double Strtod (const char* theStr, char** theNextPtr); |
50 | __Standard_API int Printf (const char* theFormat, ...); |
51 | __Standard_API int Fprintf (FILE* theFile, const char* theFormat, ...); |
52 | __Standard_API int Sprintf (char* theBuffer, const char* theFormat, ...); |
53 | |
7fd59977 |
54 | //============================================================================ |
42a9dcfc |
55 | //==== IsEqual : Returns Standard_True if two booleans have the same value |
7fd59977 |
56 | //============================================================================ |
42a9dcfc |
57 | inline Standard_Boolean IsEqual(const Standard_CString One |
7fd59977 |
58 | ,const Standard_CString Two) |
91322f44 |
59 | { |
7fd59977 |
60 | return (strcmp(One,Two) == 0); |
61 | } |
62 | |
7fd59977 |
63 | //============================================================================ |
64 | //==== HashCode of CString. Returns the HashCode itself and |
65 | //==== the HashCode % Upper |
66 | //============================================================================ |
67 | inline Standard_Integer HashCode (const Standard_CString Value, |
91322f44 |
68 | const Standard_Integer Len , |
7fd59977 |
69 | const Standard_Integer Upper , |
70 | Standard_Integer& aHashCode ) |
71 | { |
72 | aHashCode = HashCodes( Value , Len ); |
73 | // return (Abs( aHashCode ) % Upper ) + 1 ; |
74 | return HashCode( (Standard_Integer)aHashCode , Upper ) ; |
75 | } |
76 | |
77 | //============================================================================ |
78 | //==== HashCode of CString. Returns the HashCode itself and |
79 | //==== the HashCode % Upper |
80 | //============================================================================ |
81 | inline Standard_Integer HashCode (const Standard_CString Value, |
82 | const Standard_Integer Len , |
83 | const Standard_Integer Upper ) |
84 | { |
85 | // return (Abs( HashCodes( Value , Len ) ) % Upper ) + 1 ; |
86 | return HashCode( (Standard_Integer) HashCodes( Value , Len ) , Upper ) ; |
87 | } |
88 | |
7fd59977 |
89 | #endif |