/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/include/sgx/core/sgxlib/ctype.hpp

*/

#ifndef SGX_CORE_SGXLIB_CTYPE_HPP
#define SGX_CORE_SGXLIB_CTYPE_HPP

//
// Wrappers for the stdlib and ctype functions
//
// DEVNOTE: This can be improved on some architectures by using a look-up 
// table for each character, with flags indicating the appropriate properties.
template <typename T>	T sgxToUpper(T c) { return (c>='a' && c<='z') ? (c-'a')+'A': (c); }
template <typename T>	T sgxToLower(T c) { return (c>='A' && c<='Z') ? (c-'A')+'a': (c); }
template <typename T>	T sgxIsUpper(T c) { return (c>='A' && c<='Z'); }
template <typename T>	T sgxIsLower(T c) { return (c>='a' && c<='z'); }
template <typename T>	T sgxIsDigit(T c) { return (c>='0' && c<='9'); }
template <typename T>	T sgxIsXDigit(T c) { return (c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F'); }
template <typename T>	T sgxIsSpace(T c) { return c==' ' || c=='\t' || c=='\r' || c=='\n' || c=='\v' || c=='\f'; }
template <typename T>	T sgxIsPunct(T c) { return c=='!' || c=='\"' || c=='#' || c=='$' || c=='%' || c=='&' || c=='\'' || 
													c=='(' || c==')' || c=='*' || c=='+' || c==',' || c=='-' || c=='.' || 
													c=='/' || c==':' || c==';' || c=='<' || c=='=' || c=='>' || c=='?' || 
													c=='@' || c=='[' || c=='\\' || c==']' || c=='^' || c=='_' || c=='`' || 
													c=='{' || c=='|' || c=='}' || c=='~' ; }
template <typename T>	T sgxIsAlpha(T c) { return (c>='a' && c<='z') || (c>='A' && c<='Z'); }
template <typename T>	T sgxIsAlNum(T c) { return (c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z'); }
template <typename T>	T sgxIsPrint(T c) { return (c>=' ' && c<='?') || (c>='@' && c<='~'); }

#endif /* SGX_CORE_SGXLIB_CTYPE_HPP */


