mirror of
https://github.com/diamante0018/BlackOpsPlugin.git
synced 2025-04-20 18:35:42 +00:00
refactor: buff string utils
This commit is contained in:
parent
3a699f14c4
commit
51dc00790b
@ -30,22 +30,24 @@ std::vector<std::string> split(const std::string& s, const char delim) {
|
||||
return elems;
|
||||
}
|
||||
|
||||
std::string to_lower(std::string text) {
|
||||
std::transform(text.begin(), text.end(), text.begin(),
|
||||
[](unsigned char input) {
|
||||
return static_cast<char>(std::tolower(input));
|
||||
});
|
||||
std::string to_lower(const std::string& text) {
|
||||
std::string result;
|
||||
std::ranges::transform(text, std::back_inserter(result),
|
||||
[](unsigned char input) {
|
||||
return static_cast<char>(std::tolower(input));
|
||||
});
|
||||
|
||||
return text;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string to_upper(std::string text) {
|
||||
std::transform(text.begin(), text.end(), text.begin(),
|
||||
[](unsigned char input) {
|
||||
return static_cast<char>(std::toupper(input));
|
||||
});
|
||||
std::string to_upper(const std::string& text) {
|
||||
std::string result;
|
||||
std::ranges::transform(text, std::back_inserter(result),
|
||||
[](unsigned char input) {
|
||||
return static_cast<char>(std::toupper(input));
|
||||
});
|
||||
|
||||
return text;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool starts_with(const std::string& text, const std::string& substring) {
|
||||
|
@ -76,8 +76,9 @@ const char* va(const char* fmt, ...);
|
||||
|
||||
std::vector<std::string> split(const std::string& s, char delim);
|
||||
|
||||
std::string to_lower(std::string text);
|
||||
std::string to_upper(std::string text);
|
||||
std::string to_lower(const std::string& text);
|
||||
std::string to_upper(const std::string& text);
|
||||
|
||||
bool starts_with(const std::string& text, const std::string& substring);
|
||||
bool ends_with(const std::string& text, const std::string& substring);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user