#ifndef KGKCHAR_T #define KGKCHAR_T namespace kg { class KChar { public: KChar(); KChar(char c); char getChar() const; operator char() const; bool isUppercaseLetter() const; bool isLowercaseLetter() const; bool isLetter() const; bool isDigit() const; bool isWhitespace() const; bool isArithmeticOperator() const; bool isComparisonOperator() const; bool isBinaryOperator() const; bool isMathOperator() const; private: char C; }; inline KChar::KChar() : C(0) { } inline KChar::KChar(char c) : C(c) { } inline char KChar::getChar() const { return C; } inline KChar::operator char() const { return getChar(); } /** * Check if the specified character is an uppercase letter. * * @return True if c is something between A and Z. */ inline bool KChar::isUppercaseLetter() const { return (C > 64) && (C < 91); } /** * Check if the specified character is an lowercase letter. * * @return True if c is something between a and z. */ inline bool KChar::isLowercaseLetter() const { return (C > 96) && (C < 123); } /** * Check if the specified character is a letter. * * @return True if c is either an uppercase or a lowercase letter. */ inline bool KChar::isLetter() const { return isUppercaseLetter() || isLowercaseLetter(); } /** * Check if the specified character is a digit. * * @return True if c is something between 0 and 9. */ inline bool KChar::isDigit() const { return (C > 47) && (C < 58); } /** * Check if the specified character is whitespace. * * @return True if c is whitespace. */ inline bool KChar::isWhitespace() const { return (C == ' ') || (C == '\t') || (C == '\v'); } inline bool KChar::isArithmeticOperator() const { return (C == '+') || (C == '-') || (C == '*') || (C == '/') || (C == '%'); } inline bool KChar::isComparisonOperator() const { return (C == '=') || (C == '!') || (C == '<') || (C == '>'); } inline bool KChar::isBinaryOperator() const { return (C == '&') || (C == '|') || (C == '~'); } inline bool KChar::isMathOperator() const { return isArithmeticOperator() || isComparisonOperator() || isBinaryOperator(); } } #endif