mirror of
https://github.com/diamante0018/MW3ServerFreezer.git
synced 2025-04-19 11:42:53 +00:00
refactor: buff string utils
This commit is contained in:
parent
5fb61c0f8e
commit
416036d25e
@ -31,20 +31,24 @@ std::vector<std::string> split(const std::string& s, const char delim) {
|
|||||||
return elems;
|
return elems;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string to_lower(std::string text) {
|
std::string to_lower(const std::string text) {
|
||||||
std::transform(text.begin(), text.end(), text.begin(), [](const char input) {
|
std::string result;
|
||||||
return static_cast<char>(tolower(input));
|
std::ranges::transform(text, std::back_inserter(result),
|
||||||
|
[](const unsigned char input) {
|
||||||
|
return static_cast<char>(std::tolower(input));
|
||||||
});
|
});
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string to_upper(std::string text) {
|
std::string to_upper(const std::string text) {
|
||||||
std::transform(text.begin(), text.end(), text.begin(), [](const char input) {
|
std::string result;
|
||||||
return static_cast<char>(toupper(input));
|
std::ranges::transform(text, std::back_inserter(result),
|
||||||
|
[](const 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) {
|
bool starts_with(const std::string& text, const std::string& substring) {
|
||||||
|
@ -76,8 +76,8 @@ const char* va(const char* fmt, ...);
|
|||||||
|
|
||||||
std::vector<std::string> split(const std::string& s, char delim);
|
std::vector<std::string> split(const std::string& s, char delim);
|
||||||
|
|
||||||
std::string to_lower(std::string text);
|
std::string to_lower(const std::string& text);
|
||||||
std::string to_upper(std::string text);
|
std::string to_upper(const std::string& text);
|
||||||
bool starts_with(const std::string& text, const std::string& substring);
|
bool starts_with(const std::string& text, const std::string& substring);
|
||||||
bool ends_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