Branimir Karadžić 8 years ago
parent
commit
2829ad737a
2 changed files with 37 additions and 15 deletions
  1. 20 14
      include/bx/string.h
  2. 17 1
      src/string.cpp

+ 20 - 14
include/bx/string.h

@@ -100,46 +100,52 @@ namespace bx
 		void clear();
 		void clear();
 	};
 	};
 
 
-	///
+	/// Retruns true if character is part of space set.
 	bool isSpace(char _ch);
 	bool isSpace(char _ch);
 
 
-	///
+	/// Returns true if string view contains only space characters.
 	bool isSpace(const StringView& _str);
 	bool isSpace(const StringView& _str);
 
 
-	///
+	/// Retruns true if character is uppercase.
 	bool isUpper(char _ch);
 	bool isUpper(char _ch);
 
 
-	///
+	/// Returns true if string view contains only uppercase characters.
 	bool isUpper(const StringView& _str);
 	bool isUpper(const StringView& _str);
 
 
-	///
+	/// Retruns true if character is lowercase.
 	bool isLower(char _ch);
 	bool isLower(char _ch);
 
 
-	///
+	/// Returns true if string view contains only lowercase characters.
 	bool isLower(const StringView& _str);
 	bool isLower(const StringView& _str);
 
 
-	///
+	/// Returns true if character is part of alphabet set.
 	bool isAlpha(char _ch);
 	bool isAlpha(char _ch);
 
 
-	///
+	/// Retruns true if string view contains only alphabet characters.
 	bool isAlpha(const StringView& _str);
 	bool isAlpha(const StringView& _str);
 
 
-	///
+	/// Returns true if character is part of numeric set.
 	bool isNumeric(char _ch);
 	bool isNumeric(char _ch);
 
 
-	///
+	/// Retruns true if string view contains only numeric characters.
 	bool isNumeric(const StringView& _str);
 	bool isNumeric(const StringView& _str);
 
 
-	///
+	/// Returns true if character is part of alpha numeric set.
 	bool isAlphaNum(char _ch);
 	bool isAlphaNum(char _ch);
 
 
-	///
+	/// Returns true if string view contains only alpha-numeric characters.
 	bool isAlphaNum(const StringView& _str);
 	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);
 	bool isPrint(char _ch);
 
 
-	///
+	/// Returns true if string vieww contains only printable characters.
 	bool isPrint(const StringView& _str);
 	bool isPrint(const StringView& _str);
 
 
 	///
 	///

+ 17 - 1
src/string.cpp

@@ -54,7 +54,18 @@ namespace bx
 
 
 	bool isAlphaNum(char _ch)
 	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)
 	bool isPrint(char _ch)
@@ -110,6 +121,11 @@ namespace bx
 		return isCharTest<isAlphaNum>(_str);
 		return isCharTest<isAlphaNum>(_str);
 	}
 	}
 
 
+	bool isHexNum(const StringView& _str)
+	{
+		return isCharTest<isHexNum>(_str);
+	}
+
 	bool isPrint(const StringView& _str)
 	bool isPrint(const StringView& _str)
 	{
 	{
 		return isCharTest<isPrint>(_str);
 		return isCharTest<isPrint>(_str);