arduino-emulator
Loading...
Searching...
No Matches
WCharacter.h
1/*
2 WCharacter.h - Character utility functions for Wiring & Arduino
3 Copyright (c) 2010 Hernando Barragan. All right reserved.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef Character_h
21#define Character_h
22
23#include <ctype.h>
24
25namespace arduino {
26
27// WCharacter.h prototypes
28inline bool isAlphaNumeric(int c) __attribute__((always_inline));
29inline bool isAlpha(int c) __attribute__((always_inline));
30inline bool isAscii(int c) __attribute__((always_inline));
31inline bool isWhitespace(int c) __attribute__((always_inline));
32inline bool isControl(int c) __attribute__((always_inline));
33inline bool isDigit(int c) __attribute__((always_inline));
34inline bool isGraph(int c) __attribute__((always_inline));
35inline bool isLowerCase(int c) __attribute__((always_inline));
36inline bool isPrintable(int c) __attribute__((always_inline));
37inline bool isPunct(int c) __attribute__((always_inline));
38inline bool isSpace(int c) __attribute__((always_inline));
39inline bool isUpperCase(int c) __attribute__((always_inline));
40inline bool isHexadecimalDigit(int c) __attribute__((always_inline));
41inline int toAscii(int c) __attribute__((always_inline));
42inline int toLowerCase(int c) __attribute__((always_inline));
43inline int toUpperCase(int c)__attribute__((always_inline));
44
45
46// Checks for an alphanumeric character.
47// It is equivalent to (isalpha(c) || isdigit(c)).
48inline bool isAlphaNumeric(int c)
49{
50 return ( isalnum(c) == 0 ? false : true);
51}
52
53
54// Checks for an alphabetic character.
55// It is equivalent to (isupper(c) || islower(c)).
56inline bool isAlpha(int c)
57{
58 return ( isalpha(c) == 0 ? false : true);
59}
60
61
62// Checks whether c is a 7-bit unsigned char value
63// that fits into the ASCII character set.
64inline bool isAscii(int c)
65{
66 return ((c & ~0x7f) != 0 ? false : true );
67}
68
69
70// Checks for a blank character, that is, a space or a tab.
71inline bool isWhitespace(int c)
72{
73 return ( c == '\t' || c == ' ');
74}
75
76
77// Checks for a control character.
78inline bool isControl(int c)
79{
80 return ( iscntrl (c) == 0 ? false : true);
81}
82
83
84// Checks for a digit (0 through 9).
85inline bool isDigit(int c)
86{
87 return ( isdigit (c) == 0 ? false : true);
88}
89
90
91// Checks for any printable character except space.
92inline bool isGraph(int c)
93{
94 return ( isgraph (c) == 0 ? false : true);
95}
96
97
98// Checks for a lower-case character.
99inline bool isLowerCase(int c)
100{
101 return ( c >= 'a' && c <= 'z' );
102}
103
104
105// Checks for any printable character including space.
106inline bool isPrintable(int c)
107{
108 return ( isprint (c) == 0 ? false : true);
109}
110
111
112// Checks for any printable character which is not a space
113// or an alphanumeric character.
114inline bool isPunct(int c)
115{
116 return ( isPrintable(c) && !isSpace(c) && !isAlphaNumeric(c) );
117}
118
119
120// Checks for white-space characters. For the avr-libc library,
121// these are: space, formfeed ('\f'), newline ('\n'), carriage
122// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
123inline bool isSpace(int c)
124{
125 return ( isspace (c) == 0 ? false : true);
126}
127
128
129// Checks for an uppercase letter.
130inline bool isUpperCase(int c)
131{
132 return ( isupper (c) == 0 ? false : true);
133}
134
135
136// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7
137// 8 9 a b c d e f A B C D E F.
138inline bool isHexadecimalDigit(int c)
139{
140 return ( isxdigit (c) == 0 ? false : true);
141}
142
143
144// Converts c to a 7-bit unsigned char value that fits into the
145// ASCII character set, by clearing the high-order bits.
146inline int toAscii(int c)
147{
148 return (c & 0x7f);
149}
150
151
152// Warning:
153// Many people will be unhappy if you use this function.
154// This function will convert accented letters into random
155// characters.
156
157// Converts the letter c to lower case, if possible.
158inline int toLowerCase(int c)
159{
160 return tolower (c);
161}
162
163
164// Converts the letter c to upper case, if possible.
165inline int toUpperCase(int c)
166{
167 return toupper (c);
168}
169
170}
171#endif
We provide the WiFi class to simulate the Arduino WIFI. In in Linux we can expect that networking is ...
Definition CanMsg.cpp:31