string manipulation moved to utils

This commit is contained in:
HarrySilan 2022-07-06 11:29:12 +08:00
parent 43b66ba7f8
commit e4619ee6a1
3 changed files with 27 additions and 25 deletions

View File

@ -172,6 +172,30 @@ namespace util
return tokens;
}
std::string SplitWords(const std::string& value)
{
std::stringstream outStream;
std::stringstream inStream(value);
char ch;
inStream >> ch;
outStream << ch;
while (inStream >> ch)
{
if (isupper(ch))
outStream << " ";
outStream << ch;
}
return outStream.str();
}
std::string MakeCapital(std::string value)
{
if (islower(value[0]))
value[0] = toupper(value[0]);
return value;
}
static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"

View File

@ -37,6 +37,8 @@ namespace util
int64_t GetCurrentTimeMillisec();
std::vector<std::string> StringSplit(const std::string& delimiter, const std::string& content);
std::string SplitWords(const std::string& value);
std::string MakeCapital(std::string value);
std::string to_hex_string(uint8_t* barray, int length);
bool IsLittleEndian();

View File

@ -409,31 +409,7 @@ namespace cheat::feature
return;
}
std::string SplitWords(const std::string& value)
{
std::stringstream outStream;
std::stringstream inStream(value);
char ch;
inStream >> ch;
outStream << ch;
while (inStream >> ch)
{
if (isupper(ch))
outStream << " ";
outStream << ch;
}
return outStream.str();
}
std::string MakeCapital(std::string value)
{
if (islower(value[0]))
value[0] = toupper(value[0]);
return value;
}
#define ADD_FILTER_FIELD(section, name) AddFilter(MakeCapital(#section), SplitWords(#name), &game::filters::##section##::##name##)
#define ADD_FILTER_FIELD(section, name) AddFilter(util::MakeCapital(#section), util::SplitWords(#name), &game::filters::##section##::##name##)
void ESP::InstallFilters()
{
ADD_FILTER_FIELD(collection, Book);