Simple Application Framework
1
|
00001 /* 00002 This file is part of Simple Application Framework (Saf) library. 00003 Copyright (C) 2010 - 2012 Ondrej Danek <ondrej.danek@gmail.com> 00004 00005 This library is free software: you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published 00007 by the Free Software Foundation, either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 Saf 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 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with Simple Application Framework library. If not, 00017 see <http://www.gnu.org/licenses/>. 00018 */ 00019 00028 #ifndef SAF_TEXT_CHAR_H 00029 #define SAF_TEXT_CHAR_H 00030 00031 #include "../Type.h" 00032 #include "../Type/Traits.h" 00033 00034 namespace Saf 00035 { 00037 namespace Text 00038 { 00040 class Char 00041 { 00042 private: 00044 Uint32 m_cp; 00045 00046 public: 00051 Char() 00052 {} 00053 00055 Char(const Char &c) 00056 { 00057 m_cp = c.m_cp; 00058 } 00059 00061 explicit Char(char c) 00062 { 00063 m_cp = (Uint32)c; 00064 } 00065 00067 explicit Char(Uint32 cpoint) 00068 { 00069 m_cp = cpoint; 00070 } 00071 00073 Char &operator= (const Char &c) 00074 { 00075 m_cp = c.m_cp; 00076 return *this; 00077 } 00078 00080 Uint32 CodePoint() const 00081 { 00082 return m_cp; 00083 } 00084 00090 Uint32 NumericValue() const; 00091 00093 bool IsWhiteSpace() const 00094 { 00095 return (m_cp == 32 || m_cp == 9); 00096 } 00097 00099 bool IsLetter() const 00100 { 00101 return false; 00102 } 00103 00105 bool IsUpper() const 00106 { 00107 return (m_cp >= 65 && m_cp <= 90); 00108 } 00109 00111 bool IsLower() const 00112 { 00113 return (m_cp >= 97 && m_cp <= 122); 00114 } 00115 00117 bool IsDigit() const 00118 { 00119 return (m_cp > 47 && m_cp < 58); 00120 } 00121 00123 bool operator< (const Char &c) const 00124 { 00125 return m_cp < c.m_cp; 00126 } 00127 00129 bool operator> (const Char &c) const 00130 { 00131 return m_cp > c.m_cp; 00132 } 00133 00135 bool operator== (const Char &c) const 00136 { 00137 return m_cp == c.m_cp; 00138 } 00139 00141 bool operator!= (const Char &c) const 00142 { 00143 return m_cp != c.m_cp; 00144 } 00145 }; 00146 } 00147 00149 namespace Type 00150 { 00151 // Traits specialization for Char object 00152 template <> 00153 class Traits< Text::Char > 00154 { 00155 public: 00156 static bool IsPod() 00157 { 00158 return true; 00159 } 00160 }; 00161 } 00163 } 00164 00165 #endif