FreeNOS
Character.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __LIBSTD_CHARACTER_H
19#define __LIBSTD_CHARACTER_H
20
29namespace Character
30{
38 inline bool isDigit(char c)
39 {
40 return c >= '0' && c <= '9';
41 }
42
50 inline bool isWildcard(char c)
51 {
52 return c == '*';
53 }
54
62 inline bool isLower(char c)
63 {
64 return (c) >= 'a' && (c) <= 'z';
65 }
66
74 inline bool isUpper(char c)
75 {
76 return (c) >= 'A' && (c) <= 'Z';
77 }
78
86 inline bool isAlpha(char c)
87 {
88 return isUpper(c) || isLower(c);
89 }
90
98 inline bool isAlnum(char c)
99 {
100 return isAlpha(c) || isDigit(c);
101 }
102
110 inline bool isBlank(char c)
111 {
112 return (c) == ' ' || (c) == '\t';
113 }
114
122 inline bool isWhitespace(char c)
123 {
124 return (c) == '\v' || (c) == '\f' ||
125 (c) == '\r' || (c) == '\n' || isBlank(c);
126 }
127
135 inline char lower(char c)
136 {
137 return (c >= 'A' && c <= 'Z') ? (c + 32) : (c);
138 }
139
147 inline char upper(char c)
148 {
149 return (c >= 'a' && c <= 'z') ? (c - 32) : (c);
150 }
151};
152
158#endif /* __LIBSTD_CHARACTER_H */
bool isAlpha(char c)
Test for an alphabetic character.
Definition Character.h:86
char upper(char c)
Converts the letter c to uppercase.
Definition Character.h:147
bool isAlnum(char c)
Test for an alphanumeric character.
Definition Character.h:98
bool isWildcard(char c)
Test for a wildcard character.
Definition Character.h:50
bool isDigit(char c)
Test for a decimal digit.
Definition Character.h:38
bool isLower(char c)
Test for a lowercase letter.
Definition Character.h:62
bool isWhitespace(char c)
Test for a white-space character.
Definition Character.h:122
bool isUpper(char c)
Test for an uppercase letter.
Definition Character.h:74
char lower(char c)
Converts the letter c to lowercase.
Definition Character.h:135
bool isBlank(char c)
Test for a blank character.
Definition Character.h:110