Zen C++ Libraries
Zero-dependency re-usable components for C++
Loading...
Searching...
No Matches
char.hpp
1#ifndef ZEN_CHAR_HPP
2#define ZEN_CHAR_HPP
3
4#include "zen/config.hpp"
5
6ZEN_NAMESPACE_START
7
8inline bool is_digit(char ch) {
9 return ch >= 48 && ch <= 57;
10}
11
12inline bool is_alpha(char ch) {
13 return (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122);
14}
15
16inline bool is_alphanum(char ch) {
17 return is_alpha(ch) || is_digit(ch);
18}
19
20inline bool is_lalpha(char ch) {
21 return ch >= 97 && ch <= 122;
22}
23
24inline bool is_ualpha(char ch) {
25 return ch >= 65 && ch <= 90;
26}
27
28inline bool is_whitespace(char ch) {
29 switch (ch) {
30 case ' ':
31 case '\n':
32 case '\r':
33 case '\t':
34 return true;
35 default:
36 return false;
37 }
38}
39
40inline bool is_newline(char ch) {
41 return ch == '\n';
42}
43
44inline int parse_decimal_digit(char ch) {
45 return ch - 48;
46}
47
48ZEN_NAMESPACE_END
49
50#endif // of #ifndef ZEN_CHAR_HPP