Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

fxascii.h
1 /********************************************************************************
2 * *
3 * A S C I I C h a r a c t e r I n f o *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2005,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXASCII_H
22 #define FXASCII_H
23 
24 
25 /******** Generated on 2023/08/16 11:48:45 by ascii tool version 4.0.0 *********/
26 
27 
28 namespace FX {
29 
30 
31 namespace Ascii {
32 
34 enum {
35  AlphaNum = 0x0001,
36  Letter = 0x0002,
37  Control = 0x0004,
38  Digit = 0x0008,
39  Graph = 0x0010,
40  Lower = 0x0020,
41  Print = 0x0040,
42  Punct = 0x0080,
43  Space = 0x0100,
44  Upper = 0x0200,
45  HexDigit = 0x0400,
46  Blank = 0x0800,
47  Word = 0x1000,
48  Delim = 0x2000,
49  Case = 0x4000,
50  };
51 
52 
53 // Ascii character property table
54 extern FXAPI const FXushort ascii_data[256];
55 
56 // Value to ascii digit table
57 extern FXAPI const FXchar value_to_digit[256];
58 
59 // Ascii digit to valuetable
60 extern FXAPI const FXschar digit_to_value[256];
61 
62 
63 // Numeric value of ascii digit
64 static inline FXint digitValue(FXchar asc){
65  return digit_to_value[(FXuchar)asc];
66  }
67 
68 
69 // Ascii digit of numeric value
70 static inline FXint valueDigit(FXuchar asc){
71  return value_to_digit[(FXuchar)asc];
72  }
73 
74 
75 // Character properties
76 static inline FXushort charProperties(FXchar asc){
77  return ascii_data[(FXuchar)asc];
78  }
79 
80 
81 // Has upper or lower case variant
82 static inline FXbool hasCase(FXchar asc){
83  return (charProperties(asc)&Case)!=0;
84  }
85 
86 
87 // Is upper case
88 static inline FXbool isUpper(FXchar asc){
89  return (charProperties(asc)&Upper)!=0;
90  }
91 
92 
93 // Is lower case
94 static inline FXbool isLower(FXchar asc){
95  return (charProperties(asc)&Lower)!=0;
96  }
97 
98 
99 // Is title case
100 static inline FXbool isTitle(FXchar asc){
101  return (charProperties(asc)&Upper)!=0;
102  }
103 
104 
105 // Is us-ascii
106 static inline FXbool isAscii(FXchar asc){
107  return ((FXuchar)asc)<128;
108  }
109 
110 
111 // Is letter
112 static inline FXbool isLetter(FXchar asc){
113  return (charProperties(asc)&Letter)!=0;
114  }
115 
116 
117 // Is decimal digit
118 static inline FXbool isDigit(FXchar asc){
119  return (charProperties(asc)&Digit)!=0;
120  }
121 
122 
123 // Is letter or digit
124 static inline FXbool isAlphaNumeric(FXchar asc){
125  return (charProperties(asc)&AlphaNum)!=0;
126  }
127 
128 
129 // Is control character
130 static inline FXbool isControl(FXchar asc){
131  return (charProperties(asc)&Control)!=0;
132  }
133 
134 
135 // Is space
136 static inline FXbool isSpace(FXchar asc){
137  return (charProperties(asc)&Space)!=0;
138  }
139 
140 
141 // Is blank
142 static inline FXbool isBlank(FXchar asc){
143  return (charProperties(asc)&Blank)!=0;
144  }
145 
146 
147 // Is punctuation character
148 static inline FXbool isPunct(FXchar asc){
149  return (charProperties(asc)&Punct)!=0;
150  }
151 
152 
153 // Is graphic character
154 static inline FXbool isGraph(FXchar asc){
155  return (charProperties(asc)&Graph)!=0;
156  }
157 
158 
159 // Is printing character
160 static inline FXbool isPrint(FXchar asc){
161  return (charProperties(asc)&Print)!=0;
162  }
163 
164 
165 // Is hexadecimal digit
166 static inline FXbool isHexDigit(FXchar asc){
167  return (charProperties(asc)&HexDigit)!=0;
168  }
169 
170 
171 // Is octal digit
172 static inline FXbool isOctDigit(FXchar asc){
173  return (asc&0xF8)==0x30;
174  }
175 
176 
177 // Is binary digit
178 static inline FXbool isBinDigit(FXchar asc){
179  return (asc&0xFE)==0x30;
180  }
181 
182 
183 // Is word character
184 static inline FXbool isWord(FXchar asc){
185  return (charProperties(asc)&Word)!=0;
186  }
187 
188 
189 // Is delimiter character
190 static inline FXbool isDelim(FXchar asc){
191  return (charProperties(asc)&Delim)!=0;
192  }
193 
194 
195 // Convert to upper case
196 static inline FXchar toUpper(FXchar asc){
197  return (FXchar)(asc+((((96-(FXint)asc)&((FXint)asc-123))>>31)&-32));
198  }
199 
200 
201 // Convert to lower case
202 static inline FXchar toLower(FXchar asc){
203  return (FXchar)(asc+((((64-(FXint)asc)&((FXint)asc-91))>>31)&32));
204  }
205 
206 
207 // Convert to title case
208 static inline FXchar toTitle(FXchar asc){
209  return (FXchar)(asc+((((96-(FXint)asc)&((FXint)asc-123))>>31)&-32));
210  }
211 
212 }
213 
214 }
215 
216 #endif
Definition: FX4Splitter.h:28

Copyright © 1997-2022 Jeroen van der Zijp