Gel2D - The free/open source game creation suite

gelChar.h
Go to the documentation of this file.
00001 /*
00002 Gel2D Game Engine - Cross-platform 2D gaming middleware
00003 Copyright (C) 2011 Mark D. Procarione
00004 
00005 Gel2D is free software: you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation, either version 3 of the License, or
00008 (at your option) any later version.
00009 
00010 Gel2D 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 
00016 #ifndef __GELCHAR_H__
00017 #define __GELCHAR_H__
00018 
00019 #include "gelNamespace.h"
00020 
00021 namespace gel
00022 {
00024         class GelChar
00025     {
00026         public:
00028 
00029             GelChar() { chr = '\0'; }
00030 
00032 
00033             GelChar( char ch ) { chr = ch; }
00034 
00036 
00037             bool isNull() const { return chr == 0; }
00038 
00040 
00041             bool isDigit() const;
00042 
00044 
00045             bool isLetter() const;
00046 
00048 
00049             bool isPrint() const;
00050 
00052 
00053             bool isPunct() const;
00054 
00055             bool isSpace() const;
00056             bool isSymbol() const;
00057             bool isCtrl() const;
00058 
00060 
00061             bool isUpper() const;
00062 
00064 
00065             bool isLower() const;
00066 
00068 
00070             GelChar toUpper() const;
00071 
00073 
00075             GelChar toLower() const;
00076 
00078 
00079             int toDigit() const;
00080 
00082             char toAscii() const { return chr; }
00083 
00084             GelChar &operator=( const char c )     { chr = c; return *this; }
00085             GelChar &operator=( const GelChar &ch ) { chr = ch.chr; return *this; }
00086 
00087             bool operator==( const GelChar &ch ) const { return chr == ch.chr; }
00088             bool operator!=( const GelChar &ch ) const { return chr != ch.chr; }
00089             bool operator<=( const GelChar &ch ) const { return chr <= ch.chr; }
00090             bool operator>=( const GelChar &ch ) const { return chr >= ch.chr; }
00091             bool operator< ( const GelChar &ch ) const { return chr < ch.chr; }
00092             bool operator> ( const GelChar &ch ) const { return chr > ch.chr; }
00093 
00094         private:
00095                         char chr;
00096     };
00097 
00099 
00100     class GelUChar
00101     {
00102         public:
00104 
00105             GelUChar() { chr = '\0'; }
00106 
00108 
00109             GelUChar( GELushort ch ) { chr = ch; }
00110 
00112 
00113             GelUChar( char ch ) { chr = ch; }
00114 
00115             GELushort toUnicode() const { return chr; }
00116 
00118             char toAscii() const { return chr > 0xff ? '\0' : (char)chr; }
00119 
00120             GelUChar &operator=( const char c )       { chr = c; return *this; }
00121             GelUChar &operator=( const GelUChar &ch ) { chr = ch.chr; return *this; }
00122 
00123             bool operator==( const GelUChar &ch ) const { return chr == ch.chr; }
00124             bool operator!=( const GelUChar &ch ) const { return chr != ch.chr; }
00125             bool operator<=( const GelUChar &ch ) const { return chr <= ch.chr; }
00126             bool operator>=( const GelUChar &ch ) const { return chr >= ch.chr; }
00127             bool operator< ( const GelUChar &ch ) const { return chr < ch.chr; }
00128             bool operator> ( const GelUChar &ch ) const { return chr > ch.chr; }
00129 
00130         private:
00131                         GELushort chr;
00132     };
00133 }
00134 
00135 #endif // __GELCHAR_H__