From 2829ad737affe66d373f76c35e5b20ff62593746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 30 Dec 2017 15:40:20 -0800 Subject: [PATCH] Cleanup. --- include/bx/string.h | 34 ++++++++++++++++++++-------------- src/string.cpp | 18 +++++++++++++++++- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/include/bx/string.h b/include/bx/string.h index 3f57837..641b075 100644 --- a/include/bx/string.h +++ b/include/bx/string.h @@ -100,46 +100,52 @@ namespace bx void clear(); }; - /// + /// Retruns true if character is part of space set. bool isSpace(char _ch); - /// + /// Returns true if string view contains only space characters. bool isSpace(const StringView& _str); - /// + /// Retruns true if character is uppercase. bool isUpper(char _ch); - /// + /// Returns true if string view contains only uppercase characters. bool isUpper(const StringView& _str); - /// + /// Retruns true if character is lowercase. bool isLower(char _ch); - /// + /// Returns true if string view contains only lowercase characters. bool isLower(const StringView& _str); - /// + /// Returns true if character is part of alphabet set. bool isAlpha(char _ch); - /// + /// Retruns true if string view contains only alphabet characters. bool isAlpha(const StringView& _str); - /// + /// Returns true if character is part of numeric set. bool isNumeric(char _ch); - /// + /// Retruns true if string view contains only numeric characters. bool isNumeric(const StringView& _str); - /// + /// Returns true if character is part of alpha numeric set. bool isAlphaNum(char _ch); - /// + /// Returns true if string view contains only alpha-numeric characters. bool isAlphaNum(const StringView& _str); - /// + /// Returns true if character is part of hexadecimal set. + bool isHexNum(char _ch); + + /// Returns true if string view contains only hexadecimal characters. + bool isHexNum(const StringView& _str); + + /// Returns true if character is printable. bool isPrint(char _ch); - /// + /// Returns true if string vieww contains only printable characters. bool isPrint(const StringView& _str); /// diff --git a/src/string.cpp b/src/string.cpp index cf6fc15..234632c 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -54,7 +54,18 @@ namespace bx bool isAlphaNum(char _ch) { - return isAlpha(_ch) || isNumeric(_ch); + return false + || isAlpha(_ch) + || isNumeric(_ch) + ; + } + + bool isHexNum(char _ch) + { + return false + || isInRange(toLower(_ch), 'a', 'f') + || isNumeric(_ch) + ; } bool isPrint(char _ch) @@ -110,6 +121,11 @@ namespace bx return isCharTest(_str); } + bool isHexNum(const StringView& _str) + { + return isCharTest(_str); + } + bool isPrint(const StringView& _str) { return isCharTest(_str);