From 0027a8adb72c05543bc824737b59c286dde1b8ee Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 13 Mar 2016 13:39:31 -0400 Subject: [PATCH] Rename and fix up ASCII.hh --- src/kstd/ASCII.hh | 83 +++++++++++++++++++++++++++++++++++++++++++++++ src/kstd/ascii.hh | 82 ---------------------------------------------- 2 files changed, 83 insertions(+), 82 deletions(-) create mode 100644 src/kstd/ASCII.hh delete mode 100644 src/kstd/ascii.hh diff --git a/src/kstd/ASCII.hh b/src/kstd/ASCII.hh new file mode 100644 index 0000000..fe57ff6 --- /dev/null +++ b/src/kstd/ASCII.hh @@ -0,0 +1,83 @@ +/* ascii.hh + * vim: set tw=80: + * Eryn Wells + */ +/** + * A few useful utility functions for dealing with ASCII values. + */ + +namespace kstd { + +namespace Char { + +/* + * Categorization + */ + +inline bool +isDigit(char c) +{ + return c >= '0' && c <='9'; +} + +inline bool +isHexDigit(char c) +{ + return isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); +} + +inline bool +isLower(char c) +{ + return c >= 'a' && c <= 'z'; +} + +inline bool +isUpper(char c) +{ + return c >= 'A' && c <= 'Z'; +} + +inline bool +isLetter(char c) +{ + return isLower(c) || isUpper(c); +} + +inline bool +isAlphanumeric(char c) +{ + return isLetter(c) || isDigit(c); +} + +/* + * Conversion + */ + +inline char +toLower(char c) +{ + if (isUpper(c)) { + return 'a' + (c - 'A'); + } + return c; +} + +inline char +toUpper(char c) +{ + if (isLower(c)) { + return 'A' + (c - 'a'); + } + return c; +} + +} + +namespace Int { + +void toString(int value, char *buffer, int base = 10); + +} + +} /* namespace kernel */ diff --git a/src/kstd/ascii.hh b/src/kstd/ascii.hh deleted file mode 100644 index 7dd60d7..0000000 --- a/src/kstd/ascii.hh +++ /dev/null @@ -1,82 +0,0 @@ -/* ascii.hh - * vim: set tw=80: - * Eryn Wells - */ -/** - * A few useful utility functions for dealing with ASCII values. - */ - -namespace kernel { - -struct Char -{ - /* - * Categorization - */ - - static inline bool - isDigit(char c) - { - return c >= '0' && c <='9'; - } - - static inline bool - isHexDigit(char c) - { - return isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); - } - - static inline bool - isLower(char c) - { - return c >= 'a' && c <= 'z'; - } - - static inline bool - isUpper(char c) - { - return c >= 'A' && c <= 'Z'; - } - - static inline bool - isLetter(char c) - { - return isLower(c) || isUpper(c); - } - - static inline bool - isAlphanumeric(char c) - { - return isLetter(c) || isDigit(c); - } - - /* - * Conversion - */ - - static inline char - toLower(char c) - { - if (isUpper(c)) { - return 'a' + (c - 'A'); - } - return c; - } - - static inline char - toUpper(char c) - { - if (isLower(c)) { - return 'A' + (c - 'a'); - } - return c; - } -}; - - -struct Int -{ - static void toString(int value, char *buffer, int base = 10); -}; - -} /* namespace kernel */