0023024: Update headers of OCCT files
[occt.git] / src / Standard / Standard_Character.hxx
CommitLineData
b311480e 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
7fd59977 19//============================================================================
20//==== Titre: Standard_Character.hxx
21//==== Role : The header file of primitve type "Character" from package
22//==== "Standard"
23//====
24//==== Implementation: This is a primitive type implemented as typedef
25//==== typedef char Standard_Character
26//============================================================================
27
28#ifndef _Standard_Character_HeaderFile
29#define _Standard_Character_HeaderFile
30
31#ifndef _Standard_ctype_HeaderFile
32#include <Standard_ctype.hxx>
33#endif
34
35#include <string.h>
36
37#ifndef _Standard_TypeDef_HeaderFile
38#include <Standard_TypeDef.hxx>
39#endif
40
41class Handle_Standard_Type;
42
34781c33 43__Standard_API const Handle_Standard_Type& Standard_Character_Type_();
7fd59977 44
45//class Standard_OStream;
46//void ShallowDump (const Standard_Character, Standard_OStream& );
47// =====================================
48// Method implemented in Standard_Character.cxx
49// =====================================
50__Standard_API Standard_Integer HashCode(const Standard_Character, const Standard_Integer);
51
52// ===============================================
53// Methods from Standard_Entity class which are redefined:
54// - Hascode
55// - IsEqual
56// - IsSimilar
57// - Shallowcopy
58// - ShallowDump
59// ===============================================
60
61// ===============
62// inline methods
63// ===============
64
65// ------------------------------------------------------------------
66// IsEqual : Returns Standard_True if two characters have the same value
67// ------------------------------------------------------------------
68inline Standard_Boolean IsEqual(const Standard_Character One,
69 const Standard_Character Two)
70{ return One == Two; }
71
72// ------------------------------------------------------------------
73// IsSimilar : Returns Standard_True if two characters have the same value
74// ------------------------------------------------------------------
75inline Standard_Boolean IsSimilar(const Standard_Character One,
76 const Standard_Character Two)
77{ return One == Two; }
78
79// ===============================================
80// Character classification functions
81//
82// NOTE: Character classification routines in C standard library
83// (isdigit(), isalpha() etc.) have integer argument instead of char.
84// Therefore if character from extended Ascii part of char table
85// (i.e. above 128) is passed into such functions it is converted
86// to int giving negative value (if characters are signed that
87// is default for most compilers).
88// It can be dangerous since implementation of these C functions
89// may use argument as index in the array without any checks
90// (for instance, in Microsoft VC++ -- see MSDN)
91// To avoid this, we cast char to unsigned char when passing to these functions.
92// ===============================================
93
94// ==================================================================
95// IsAlphabetic : Returns Standard_True if a character is alphabetic
96// ==================================================================
97inline Standard_Boolean IsAlphabetic(const Standard_Character me)
98{ return isalpha((unsigned char)me); }
99
100// ==================================================================
101// IsDigit : Returns Standard_True if a character is a digit
102// ==================================================================
103inline Standard_Boolean IsDigit(const Standard_Character me)
104{ return isdigit((unsigned char)me); }
105
106// ==================================================================
107// IsXDigit : Returns Standard_True if a character is a digit
108// ==================================================================
109inline Standard_Boolean IsXDigit(const Standard_Character me)
110{ return isxdigit((unsigned char)me); }
111
112// ==================================================================
113// IsAlphanumeric : Returns Standard_True if a character is alphanumeric
114// ==================================================================
115inline Standard_Boolean IsAlphanumeric(const Standard_Character me)
116{ return (IsAlphabetic(me) || IsDigit(me)) ; }
117
118// ==================================================================
119// IsControl : Returns Standard_True if a character is a control character
120// ==================================================================
121inline Standard_Boolean IsControl(const Standard_Character me)
122{ return iscntrl((unsigned char)me); }
123
124
125// ==================================================================
126// IsGraphic : Returns Standard_True if a character is graphic
127// ==================================================================
128inline Standard_Boolean IsGraphic(const Standard_Character me)
129{ return isgraph((unsigned char)me); }
130
131// ==================================================================
132// IsLowerCase : Returns Standard_True if a character is lowercase
133// ==================================================================
134inline Standard_Boolean IsLowerCase(const Standard_Character me)
135{ return islower((unsigned char)me); }
136
137// ==================================================================
138// IsPrintable : Returns Standard_True if a character is printable
139// ==================================================================
140inline Standard_Boolean IsPrintable(const Standard_Character me)
141{ return isprint((unsigned char)me); }
142
143// ==================================================================
144// IsPunctuation : Returns Standard_True if a character is a graphic and
145// not a alphanumeric character
146// ==================================================================
147inline Standard_Boolean IsPunctuation(const Standard_Character me)
148{ return ( IsGraphic(me) && !IsAlphanumeric(me)); }
149
150// ==================================================================
151// IsSpace : Returns Standard_True if a character is a space
152// ==================================================================
153inline Standard_Boolean IsSpace(const Standard_Character me)
154{ return isspace((unsigned char)me); }
155
156// ==================================================================
157// IsUppercase : Returns Standard_True if a character is uppercase
158// ==================================================================
159inline Standard_Boolean IsUpperCase(const Standard_Character me)
160{ return isupper((unsigned char)me); }
161
162// ==================================================================
163// LowerCase : Returns a lowercase character
164// ==================================================================
165inline Standard_Character LowerCase(const Standard_Character me)
166{ return (Standard_Character)(unsigned char)tolower(me); }
167
168// ==================================================================
169// UpperCase : Returns a uppercase character
170// ==================================================================
171inline Standard_Character UpperCase(const Standard_Character me)
172{ return (Standard_Character)(unsigned char)toupper(me); }
173
174// ------------------------------------------------------------------
175// ShallowCopy : Make a copy of one Character
176// ------------------------------------------------------------------
177inline Standard_Character ShallowCopy (const Standard_Character me)
178{ return me; }
179
180#endif
181
182
183
184
185
186
187
188
189
190
191
192
193
194