Skip to content

Commit

Permalink
utilities: some update
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasdr committed Jan 9, 2025
1 parent def3fb3 commit a68bf37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/tdme/utilities/Integer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int Integer::viewParse(const string_view& str) {
if (trimmedStr.empty() == true) return 0;
if (trimmedStr == "-") return -0;
int result;
from_chars(&trimmedStr[0], &trimmedStr[trimmedStr.size()], result);
from_chars(trimmedStr.begin(), trimmedStr.end(), result);
return result;
}

Expand Down
7 changes: 4 additions & 3 deletions src/tdme/utilities/StringTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@ const string StringTools::trim(const string& str) {
}

const string_view StringTools::viewTrim(const string_view& str) {
if (str.empty() == true) return str;
int64_t start = 0;
for (int64_t i = 0; i < str.size(); i++) {
if (isspace(str[i]) != 0) start++; else break;
}
int64_t end = 0;
int64_t end = str.size() - 1;
for (int64_t i = str.size() - 1; i >= 0; i--) {
if (isspace(str[i]) != 0) end++; else break;
if (isspace(str[i]) != 0) end--; else break;
}
return string_view(&str[start], str.size() - start - end);
return string_view(&str[start], (end - start) + 1);
}

const string StringTools::toLowerCase(const string& str) {
Expand Down

0 comments on commit a68bf37

Please sign in to comment.