00001 /***************************************************************************** 00002 * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch) 00003 ***************************************************************************** 00004 * Project : Zeus Base Library 00005 * Module : Character 00006 * Package : Zeus.ZeusBase.System 00007 * Author : Benjamin Hadorn 00008 * Date : 27.12.2011 00009 * System : Zeus-Framework 00010 ***************************************************************************** 00011 * Licence: * 00012 * This library is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU Lesser General Public License as * 00014 * published by the Free Software Foundation; either version * 00015 * 2.1 of the License, or (at your option) any later version. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU Lesser General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Lesser General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 * Changes: 00029 * 27.12.2011 bha: created zeus 2.0 00030 *****************************************************************************/ 00031 00032 #ifndef CharacterH 00033 #define CharacterH 00034 00035 #include <zeusbase/System/ZObject.h> 00036 00037 #include <ctype.h> 00038 00039 #if defined(ENABLE_LINUX_BINDING) 00040 #include <wctype.h> 00041 #endif 00042 00043 00044 BEGIN_NAMESPACE_Zeus 00045 00046 /**************************************************************************/ 00049 /**************************************************************************/ 00050 zeusbase_class TCharacter : public TZObject 00051 { 00052 public: 00053 static bool isAlpha(char cValue); 00054 static bool isAlpha(wchar_t wcValue); 00055 inline static bool isAlpha(unsigned char ucValue) { return isAlpha((char)ucValue); } 00056 00057 static bool isDigit(char cValue); 00058 static bool isDigit(wchar_t wcValue); 00059 inline static bool isDigit(unsigned char ucValue) { return isDigit((char)ucValue); } 00060 00061 static bool isHexDigit(char cValue); 00062 static bool isHexDigit(wchar_t cValue); 00063 inline static bool isHexDigit(unsigned char ucValue) { return isHexDigit((char)ucValue); } 00064 00065 static bool isAlphaNum(char cValue); 00066 static bool isAlphaNum(wchar_t wcValue); 00067 inline static bool isAlphaNum(unsigned char ucValue) { return isAlphaNum((char)ucValue); } 00068 00069 static bool isWhiteSpace(char cValue); 00070 static bool isWhiteSpace(wchar_t wcValue); 00071 inline static bool isWhiteSpace(unsigned char ucValue) { return isWhiteSpace((char)ucValue); } 00072 00073 protected: 00074 00075 private : 00076 00077 }; 00078 00079 //inline methods 00080 /***************************************************************************/ 00083 /***************************************************************************/ 00084 /*static*/ inline bool TCharacter::isAlpha(char cValue) 00085 { 00086 return (isalpha(cValue) != 0); 00087 } 00088 00089 /***************************************************************************/ 00092 /***************************************************************************/ 00093 /*static*/ inline bool TCharacter::isAlpha(wchar_t wcValue) 00094 { 00095 return (iswalpha(wcValue) != 0); 00096 } 00097 00098 /***************************************************************************/ 00101 /***************************************************************************/ 00102 /*static*/ inline bool TCharacter::isDigit(char cValue) 00103 { 00104 return (isdigit(cValue) != 0); 00105 } 00106 00107 /***************************************************************************/ 00110 /***************************************************************************/ 00111 /*static*/ inline bool TCharacter::isDigit(wchar_t wcValue) 00112 { 00113 return (iswdigit(wcValue) != 0); 00114 } 00115 00116 /***************************************************************************/ 00119 /***************************************************************************/ 00120 /*static*/ inline bool TCharacter::isHexDigit(char cValue) 00121 { 00122 return (isxdigit(cValue) != 0); 00123 } 00124 00125 /***************************************************************************/ 00128 /***************************************************************************/ 00129 /*static*/ inline bool TCharacter::isHexDigit(wchar_t wcValue) 00130 { 00131 return (iswxdigit(wcValue) != 0); 00132 } 00133 00134 /***************************************************************************/ 00137 /***************************************************************************/ 00138 /*static*/ inline bool TCharacter::isAlphaNum(char cValue) 00139 { 00140 return (isalnum(cValue) != 0); 00141 } 00142 00143 /***************************************************************************/ 00146 /***************************************************************************/ 00147 /*static*/ inline bool TCharacter::isAlphaNum(wchar_t wcValue) 00148 { 00149 return (iswalnum(wcValue) != 0); 00150 } 00151 00152 /***************************************************************************/ 00155 /***************************************************************************/ 00156 /*static*/ inline bool TCharacter::isWhiteSpace(char cValue) 00157 { 00158 return (isspace(cValue) != 0); 00159 } 00160 00161 /***************************************************************************/ 00164 /***************************************************************************/ 00165 /*static*/ inline bool TCharacter::isWhiteSpace(wchar_t wcValue) 00166 { 00167 return (isspace(wcValue) != 0); 00168 } 00169 00170 END_NAMESPACE_Zeus 00171 00172 #endif