diff --git a/utils/include/color_parser.h b/utils/include/color_parser.h index 32e87545d7382f428afec0f9793481fc6c18db9f..86bffb88c68c7a8a0146e8a1e5f834b82ce094cc 100644 --- a/utils/include/color_parser.h +++ b/utils/include/color_parser.h @@ -23,9 +23,6 @@ namespace Rosen { class ColorParser { public: static bool Parse(const std::string& colorStr, uint32_t& colorValue); - -private: - static bool IsValidHexString(const std::string& colorStr); }; } // namespace Rosen } // namespace OHOS diff --git a/utils/src/color_parser.cpp b/utils/src/color_parser.cpp index ecd738f79d33c360f174553f7989837be544ec1e..710ae2790618f4d703080bf67b11f5f53c7b2f69 100644 --- a/utils/src/color_parser.cpp +++ b/utils/src/color_parser.cpp @@ -14,6 +14,7 @@ */ #include "color_parser.h" +#include "string_ex.h" #include @@ -24,7 +25,6 @@ bool ColorParser::Parse(const std::string& colorStr, uint32_t& colorValue) if (colorStr.empty()) { return false; } - if (colorStr[0] == '#') { // start with '#' std::string color = colorStr.substr(1); if (!IsValidHexString(color)) { @@ -43,18 +43,5 @@ bool ColorParser::Parse(const std::string& colorStr, uint32_t& colorValue) return false; } -bool ColorParser::IsValidHexString(const std::string& colorStr) -{ - if (colorStr.empty()) { - return false; - } - for (char ch : colorStr) { - if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F')) { - continue; - } - return false; - } - return true; -} } // namespace Rosen } // namespace OHOS