mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 19:48:26 +00:00
Merge branch 'master' into lsid
This commit is contained in:
+52
-7
@@ -63,11 +63,50 @@ const std::string vStringFormat(const char* format, va_list args)
|
||||
return output;
|
||||
}
|
||||
|
||||
const std::string StringFormat(const char* format, ...)
|
||||
const std::string str_tolower(std::string s)
|
||||
{
|
||||
std::transform(
|
||||
s.begin(), s.end(), s.begin(),
|
||||
[](unsigned char c) { return ::tolower(c); }
|
||||
);
|
||||
return s;
|
||||
}
|
||||
|
||||
std::vector<std::string> split(std::string str_to_split, char delimiter)
|
||||
{
|
||||
std::stringstream ss(str_to_split);
|
||||
std::string item;
|
||||
std::vector<std::string> exploded_values;
|
||||
while (std::getline(ss, item, delimiter)) {
|
||||
exploded_values.push_back(item);
|
||||
}
|
||||
|
||||
return exploded_values;
|
||||
}
|
||||
|
||||
const std::string str_toupper(std::string s)
|
||||
{
|
||||
std::transform(
|
||||
s.begin(), s.end(), s.begin(),
|
||||
[](unsigned char c) { return ::toupper(c); }
|
||||
);
|
||||
return s;
|
||||
}
|
||||
|
||||
const std::string ucfirst(std::string s)
|
||||
{
|
||||
std::string output = s;
|
||||
if (!s.empty())
|
||||
output[0] = static_cast<char>(::toupper(s[0]));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
const std::string StringFormat(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
std::string output = vStringFormat(format,args);
|
||||
std::string output = vStringFormat(format, args);
|
||||
va_end(args);
|
||||
return output;
|
||||
}
|
||||
@@ -188,12 +227,18 @@ std::string JoinString(const std::vector<std::string>& ar, const std::string &de
|
||||
return ret;
|
||||
}
|
||||
|
||||
void find_replace(std::string& string_subject, const std::string& search_string, const std::string& replace_string) {
|
||||
auto index = string_subject.find_first_of(search_string);
|
||||
while (index != std::string::npos) {
|
||||
string_subject.replace(index, index + 1, replace_string);
|
||||
index = string_subject.find_first_of(search_string);
|
||||
void find_replace(std::string &string_subject, const std::string &search_string, const std::string &replace_string)
|
||||
{
|
||||
if (string_subject.find(search_string) == std::string::npos) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t start_pos = 0;
|
||||
while((start_pos = string_subject.find(search_string, start_pos)) != std::string::npos) {
|
||||
string_subject.replace(start_pos, search_string.length(), replace_string);
|
||||
start_pos += replace_string.length();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ParseAccountString(const std::string &s, std::string &account, std::string &loginserver)
|
||||
|
||||
Reference in New Issue
Block a user