PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)
Fork of PokittoLib by
WCharacter.h
00001 /* 00002 WCharacter.h - Character utility functions for Wiring & Arduino 00003 Copyright (c) 2010 Hernando Barragan. All right reserved. 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 #ifndef Character_h 00021 #define Character_h 00022 00023 #define _GLIBCXX_USE_C99_DYNAMIC 1 00024 00025 #include <ctype.h> 00026 00027 // WCharacter.h prototypes 00028 inline boolean isAlphaNumeric(int c) __attribute__((always_inline)); 00029 inline boolean isAlpha(int c) __attribute__((always_inline)); 00030 inline boolean isAscii(int c) __attribute__((always_inline)); 00031 inline boolean isWhitespace(int c) __attribute__((always_inline)); 00032 inline boolean isControl(int c) __attribute__((always_inline)); 00033 inline boolean isDigit(int c) __attribute__((always_inline)); 00034 inline boolean isGraph(int c) __attribute__((always_inline)); 00035 inline boolean isLowerCase(int c) __attribute__((always_inline)); 00036 inline boolean isPrintable(int c) __attribute__((always_inline)); 00037 inline boolean isPunct(int c) __attribute__((always_inline)); 00038 inline boolean isSpace(int c) __attribute__((always_inline)); 00039 inline boolean isUpperCase(int c) __attribute__((always_inline)); 00040 inline boolean isHexadecimalDigit(int c) __attribute__((always_inline)); 00041 inline int toAscii(int c) __attribute__((always_inline)); 00042 inline int toLowerCase(int c) __attribute__((always_inline)); 00043 inline int toUpperCase(int c)__attribute__((always_inline)); 00044 00045 00046 // Checks for an alphanumeric character. 00047 // It is equivalent to (isalpha(c) || isdigit(c)). 00048 inline boolean isAlphaNumeric(int c) 00049 { 00050 return ( isalnum(c) == 0 ? false : true); 00051 } 00052 00053 00054 // Checks for an alphabetic character. 00055 // It is equivalent to (isupper(c) || islower(c)). 00056 inline boolean isAlpha(int c) 00057 { 00058 return ( isalpha(c) == 0 ? false : true); 00059 } 00060 00061 00062 // Checks whether c is a 7-bit unsigned char value 00063 // that fits into the ASCII character set. 00064 inline boolean isAscii(int c) 00065 { 00066 return true; 00067 //return ( isascii (c) == 0 ? false : true); 00068 // jonne return ( __isascii (c) == 0 ? false : true); 00069 } 00070 00071 00072 // Checks for a blank character, that is, a space or a tab. 00073 inline boolean isWhitespace(int c) 00074 { 00075 return ( isblank (c) == 0 ? false : true); 00076 } 00077 00078 00079 // Checks for a control character. 00080 inline boolean isControl(int c) 00081 { 00082 return ( iscntrl (c) == 0 ? false : true); 00083 } 00084 00085 00086 // Checks for a digit (0 through 9). 00087 inline boolean isDigit(int c) 00088 { 00089 return ( isdigit (c) == 0 ? false : true); 00090 } 00091 00092 00093 // Checks for any printable character except space. 00094 inline boolean isGraph(int c) 00095 { 00096 return ( isgraph (c) == 0 ? false : true); 00097 } 00098 00099 00100 // Checks for a lower-case character. 00101 inline boolean isLowerCase(int c) 00102 { 00103 return (islower (c) == 0 ? false : true); 00104 } 00105 00106 00107 // Checks for any printable character including space. 00108 inline boolean isPrintable(int c) 00109 { 00110 return ( isprint (c) == 0 ? false : true); 00111 } 00112 00113 00114 // Checks for any printable character which is not a space 00115 // or an alphanumeric character. 00116 inline boolean isPunct(int c) 00117 { 00118 return ( ispunct (c) == 0 ? false : true); 00119 } 00120 00121 00122 // Checks for white-space characters. For the avr-libc library, 00123 // these are: space, formfeed ('\f'), newline ('\n'), carriage 00124 // return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). 00125 inline boolean isSpace(int c) 00126 { 00127 return ( isspace (c) == 0 ? false : true); 00128 } 00129 00130 00131 // Checks for an uppercase letter. 00132 inline boolean isUpperCase(int c) 00133 { 00134 return ( isupper (c) == 0 ? false : true); 00135 } 00136 00137 00138 // Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 00139 // 8 9 a b c d e f A B C D E F. 00140 inline boolean isHexadecimalDigit(int c) 00141 { 00142 return ( isxdigit (c) == 0 ? false : true); 00143 } 00144 00145 00146 // Converts c to a 7-bit unsigned char value that fits into the 00147 // ASCII character set, by clearing the high-order bits. 00148 inline int toAscii(int c) 00149 { 00150 return true; //jonne toascii (c); 00151 } 00152 00153 00154 // Warning: 00155 // Many people will be unhappy if you use this function. 00156 // This function will convert accented letters into random 00157 // characters. 00158 00159 // Converts the letter c to lower case, if possible. 00160 inline int toLowerCase(int c) 00161 { 00162 return tolower (c); 00163 } 00164 00165 00166 // Converts the letter c to upper case, if possible. 00167 inline int toUpperCase(int c) 00168 { 00169 return toupper (c); 00170 } 00171 00172 #endif 00173
Generated on Tue Jul 12 2022 18:08:13 by 1.7.2