diff options
author | FormerLurker <hochgebe@gmail.com> | 2021-01-11 01:51:16 +0300 |
---|---|---|
committer | FormerLurker <hochgebe@gmail.com> | 2021-01-11 01:51:16 +0300 |
commit | 794e853bfd5c21c97457c4070cfc1633e233b003 (patch) | |
tree | 7b30026d71d61da73e4a36a29136648a2af31366 | |
parent | 8165dd6b12690ce60431208a7c70a329ceca840b (diff) |
Remove cctype header
-rw-r--r-- | GcodeProcessorLib/utilities.cpp | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/GcodeProcessorLib/utilities.cpp b/GcodeProcessorLib/utilities.cpp index 7c36515..66a1f24 100644 --- a/GcodeProcessorLib/utilities.cpp +++ b/GcodeProcessorLib/utilities.cpp @@ -25,7 +25,6 @@ #include <iostream> #include <iomanip> #include "fpconv.h" -#include <cctype> const std::string utilities::WHITESPACE_ = " \n\r\t\f\v"; const char utilities::GUID_RANGE[] = "0123456789abcdef"; @@ -312,93 +311,4 @@ std::string utilities::dtos(double x, unsigned char precision) } */ return buffer; -} - -bool utilities::is_equal_caseless(const std::string& lhs, const std::string& rhs) -{ - unsigned int sz = lhs.size(); - if (rhs.size() != sz) - { - // Sizes aren't the same, - return false; - } - for (unsigned int i = 0; i < sz; ++i) - { - if (std::tolower(lhs[i]) != std::tolower(rhs[i])) - { - return false; - } - } - return true; -} - -bool utilities::is_equal_caseless_trim(const std::string& lhs, const std::string& rhs) -{ - - unsigned int lhend = lhs.find_last_not_of(WHITESPACE_); - unsigned int lhstart = lhs.find_first_not_of(WHITESPACE_); - - unsigned int rhend = rhs.find_last_not_of(WHITESPACE_); - unsigned int rhstart = rhs.find_first_not_of(WHITESPACE_); - - unsigned int size = lhend - lhstart + 1; - // If the sizes minus the whitespace doesn't match, the strings can't match - if (size != rhend - rhstart + 1) - { - return false; - } - - // The sizes match, loop through and compare - for (unsigned int i = 0; i < size; ++i) - { - if (std::tolower(lhs[i + lhstart]) != std::tolower(rhs[i + rhstart])) - { - // Something didn't match, return false - return false; - } - } - // If we are here, it worked! - return true; -} - -/// <summary> -/// Checks to see if the lhs is in the rhs. -/// </summary> -/// <param name="lhs">The string to search for in the array. Case will be ignored, as will beginning and ending whitespace</param> -/// <param name="rhs">A null terminated LOWERCASE array of const char * that is already trimmed.</param> -/// <returns></returns> -bool utilities::is_in_caseless_trim(const std::string& lhs, const char** rhs) -{ - unsigned int lhend = lhs.find_last_not_of(WHITESPACE_); - unsigned int lhstart = lhs.find_first_not_of(WHITESPACE_); - unsigned int size = lhend - lhstart + 1; - int index = 0; - - while (rhs[index] != NULL) - { - const char* rhString = rhs[index++]; - if (rhString == NULL) - { - break; - } - // If the sizes minus the whitespace doesn't match, the strings can't match - if (size != strlen(rhString)) - { - continue; - } - - // The sizes match, loop through and compare - for (unsigned int i = 0; i < size; ++i) - { - if (std::tolower(lhs[i + lhstart]) != rhString[i]) - { - // Something didn't match, return false - continue; - } - } - return true; - } - - // If we are here, this string does not appear - return false; }
\ No newline at end of file |