string: add isNumber2 for sv

This commit is contained in:
Vaxry 2026-03-19 16:19:10 +00:00
parent 6b4c47661e
commit 668b22df50
Signed by: vaxry
GPG key ID: 665806380871D640
2 changed files with 5 additions and 0 deletions

View file

@ -8,6 +8,7 @@ namespace Hyprutils {
std::string trim(const std::string& in);
std::string_view trim(const std::string_view& in);
bool isNumber(const std::string& str, bool allowfloat = false);
bool isNumber2(const std::string_view& str, bool allowfloat = false);
void replaceInString(std::string& string, const std::string& what, const std::string& to);
bool truthy(const std::string_view& in);
};

View file

@ -44,6 +44,10 @@ std::string Hyprutils::String::trim(const char* in) {
}
bool Hyprutils::String::isNumber(const std::string& str, bool allowfloat) {
return isNumber2(str, allowfloat);
}
bool Hyprutils::String::isNumber2(const std::string_view& str, bool allowfloat) {
if (str.empty())
return false;