Back to index

nux  3.0.0
NTChar.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef NTCHAR_H
00024 #define NTCHAR_H
00025 
00026 namespace nux
00027 {
00028 
00029   inline TCHAR ToUpperCase ( TCHAR c )
00030   {
00031     return (c < TEXT ('a') || c > TEXT ('z') ) ? (c) : (c + TEXT ('A') - TEXT ('a') );
00032   }
00033   inline TCHAR ToLowerCase ( TCHAR c )
00034   {
00035     return (c < TEXT ('A') || c > TEXT ('Z') ) ? (c) : (c + TEXT ('a') - TEXT ('A') );
00036   }
00037   inline bool IsUpperCase ( TCHAR c )
00038   {
00039     return (c >= TEXT ('A') && c <= TEXT ('Z') );
00040   }
00041   inline bool IsLowerCase ( TCHAR c )
00042   {
00043     return (c >= TEXT ('a') && c <= TEXT ('z') );
00044   }
00045   inline bool IsAlphaChar ( TCHAR c )
00046   {
00047     return (c >= TEXT ('a') && c <= TEXT ('z') ) || (c >= TEXT ('A') && c <= TEXT ('Z') );
00048   }
00049   inline bool IsDigitChar ( TCHAR c )
00050   {
00051     return c >= TEXT ('0') && c <= TEXT ('9');
00052   }
00053   inline bool IsAlphanumericChar ( TCHAR c )
00054   {
00055     return (c >= TEXT ('a') && c <= TEXT ('z') ) || (c >= TEXT ('A') && c <= TEXT ('Z') ) || (c >= TEXT ('0') && c <= TEXT ('9') );
00056   }
00057   inline bool IsWhitespaceChar ( TCHAR c )
00058   {
00059     return c == TEXT (' ') || c == TEXT ('\t');
00060   }
00061   inline bool IsLinebreakChar ( TCHAR c )
00062   {
00063     //@todo - support for language-specific line break characters
00064     return c == TEXT ('\n');
00065   }
00066 
00068   inline bool IsSpaceChar ( TCHAR c )
00069   {
00070 #ifdef NUX_UNICODE
00071     return ( std::iswspace (c) != 0 );
00072 #else
00073     return ( std::isspace (c) != 0 );
00074 #endif
00075   }
00076 
00077 }
00078 
00079 #endif // NTCHAR_H