0022898: IGES import fails in german environment
[occt.git] / src / Standard / Standard_CString.hxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 //
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
8 //
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 //
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
18
19 //============================================================================
20 //==== Titre: Standard_CString.hxx
21 //==== Role : The headr file of primitve type "CString" from package "Standard"
22 //====
23 //==== Implementation:  This is a primitive type implementadef with typedef
24 //====        typedef char* Standard_CString;
25 //============================================================================
26
27 #ifndef _Standard_CString_HeaderFile
28 # define _Standard_CString_HeaderFile
29
30 # ifndef _Standard_TypeDef_HeaderFile
31 #  include <Standard_TypeDef.hxx>
32 # endif
33
34 # ifdef _MSC_VER
35 #  define strcasecmp _stricmp
36 # endif
37
38 # include <string.h>
39 # include <stdio.h>
40
41 # ifndef _Standard_Integer_HeaderFile
42 #  include <Standard_Integer.hxx>
43 # endif
44
45
46 class Handle_Standard_Type;
47
48
49 __Standard_API const Handle_Standard_Type& Standard_CString_Type_();
50
51 inline  Standard_Integer Abs (const Standard_Integer);
52 inline Standard_CString ShallowCopy (const Standard_CString Value);
53 inline Standard_Boolean IsSimilar(const Standard_CString One
54                                  ,const Standard_CString Two);
55 __Standard_API Standard_Integer HashCode (const Standard_CString,
56                            const Standard_Integer);
57 inline Standard_Integer HashCode (const Standard_CString,
58                                   const Standard_Integer,
59                                   const Standard_Integer);
60 inline Standard_Integer HashCode (const Standard_CString,
61                                   const Standard_Integer ,
62                                   const Standard_Integer ,
63                                   Standard_Integer& );
64 Standard_Integer HashCodes (const Standard_CString ,
65                             const Standard_Integer  );
66 inline Standard_Boolean ISEQUAL(const Standard_CString One ,
67                                 const Standard_Integer LenOne ,
68                                 const Standard_CString Two,
69                                 const Standard_Integer LenTwo );
70 __Standard_API Standard_Boolean ISSIMILAR(const Standard_CString One ,
71                                           const Standard_Integer Len ,
72                                           const Standard_CString Two );
73 inline Standard_Integer HASHCODE (const Standard_CString,
74                                   const Standard_Integer,
75                                   const Standard_Integer);
76 inline Standard_Integer HASHCODE (const Standard_CString,
77                                   const Standard_Integer,
78                                   const Standard_Integer ,
79                                   Standard_Integer& );
80 __Standard_API Standard_Integer HASHCODES (const Standard_CString,
81                                            const Standard_Integer);
82
83 //! Equivalents of functions from standard C library that use always C locale
84 __Standard_API double Atof    (const char* theStr);
85 __Standard_API double Strtod  (const char* theStr, char** theNextPtr);
86 __Standard_API int    Printf  (const char* theFormat, ...);
87 __Standard_API int    Fprintf (FILE* theFile, const char* theFormat, ...);
88 __Standard_API int    Sprintf (char* theBuffer, const char* theFormat, ...);
89
90 //============================================================================
91 //==== ShallowCopy: Returns a CString
92 //============================================================================
93 inline Standard_CString ShallowCopy (const Standard_CString Value)
94 {
95   return Value;
96 }
97
98 //============================================================================
99 //==== IsSimilar : Returns Standard_True if two booleans have the same value
100 //============================================================================
101 inline Standard_Boolean IsSimilar(const Standard_CString One
102                                  ,const Standard_CString Two)
103 {
104   return (strcmp(One,Two) == 0);
105 }
106
107 //============================================================================
108 //==== HashCode of CString. Returns the HashCode itself and
109 //====                              the HashCode % Upper
110 //============================================================================
111 inline Standard_Integer HashCode (const Standard_CString Value,
112                                   const Standard_Integer Len ,
113                                   const Standard_Integer Upper ,
114                                   Standard_Integer& aHashCode )
115 {
116   aHashCode = HashCodes( Value , Len );
117 //  return (Abs( aHashCode ) % Upper ) + 1 ;
118   return HashCode( (Standard_Integer)aHashCode , Upper ) ;
119 }
120
121 //============================================================================
122 //==== HashCode of CString. Returns the HashCode itself and
123 //====                              the HashCode % Upper
124 //============================================================================
125 inline Standard_Integer HashCode (const Standard_CString Value,
126                                   const Standard_Integer Len ,
127                                   const Standard_Integer Upper )
128 {
129 //  return (Abs( HashCodes( Value , Len ) ) % Upper ) + 1 ;
130   return HashCode( (Standard_Integer) HashCodes( Value , Len ) , Upper ) ;
131 }
132
133 //============================================================================
134 //==== HashCode of CString converted to uppercase. Returns the HashCode itself
135 //====                               and the HashCode % Upper
136 //============================================================================
137 inline Standard_Integer HASHCODE (const Standard_CString Value,
138                                   const Standard_Integer Len ,
139                                   const Standard_Integer Upper ,
140                                   Standard_Integer& aHashCode )
141 {
142   aHashCode = HASHCODES( Value , Len );
143 //  return (Abs( aHashCode ) % Upper ) + 1 ;
144   return HashCode( (Standard_Integer) aHashCode , Upper ) ;
145 }
146
147 //============================================================================
148 //==== HashCode of a CString converted to uppercase
149 //============================================================================
150 inline Standard_Integer HASHCODE (const Standard_CString Value,
151                                   const Standard_Integer Len ,
152                                   const Standard_Integer Upper)
153 {
154 //  return (Abs( HASHCODES( Value , Len ) ) % Upper ) + 1 ;
155   return HashCode( (Standard_Integer) HASHCODES( Value , Len ) , Upper ) ;
156 }
157
158 //============================================================================
159 // IsEqual : Returns Standard_True if two CString have the same value
160 // Comparison is done with discard of bit 5 (UpperCase<-->LowerCase)
161 // Efficient for Types and MethodNames (without copy of characters)
162 // Valid if we have only alphanumeric characters and "_" (unicity)
163 // Valid if the Strings address are aligned for Integers
164
165 //============================================================================
166 inline Standard_Boolean ISEQUAL(const Standard_CString One ,
167                                 const Standard_Integer LenOne ,
168                                 const Standard_CString Two,
169                                 const Standard_Integer LenTwo )
170 {
171
172  if ( One == Two )
173    return Standard_True ;
174  if ( LenOne != LenTwo )
175    return Standard_False ;
176
177  return ISSIMILAR( One , LenOne , Two ) ;
178
179 }
180
181 #endif